blob: ba76cf63d55da92d41cccf69f629b2b7b6f83283 [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 Welte7484fc42018-02-24 14:09:45 +010025import from MobileL3_CommonIE_Types all;
Harald Welte68e495b2018-02-25 00:05:57 +010026import from MobileL3_RRM_Types all;
27import from MobileL3_Types all;
28import from L3_Templates all;
Harald Welte7484fc42018-02-24 14:09:45 +010029
Harald Welte70767382018-02-21 12:16:40 +010030/* The tests assume a BTS with the following timeslot configuration:
31 * TS0 : Combined CCCH + SDCCH/4
32 * TS1 .. TS 4: TCH/F
33 * TS5 : TCH/H
34 * TS6 : SDCCH/8
35 * TS7 : PDCH
36 */
37
38modulepar {
39 charstring mp_rsl_ip := "127.0.0.2";
40 integer mp_rsl_port := 3003;
41 integer mp_trx0_arfcn := 871;
42 integer mp_bb_trxc_port := 5704;
43}
44
45type component test_CT extends CTRL_Adapter_CT {
Harald Welte68e495b2018-02-25 00:05:57 +010046 /* IPA Emulation component underneath RSL */
Harald Welte70767382018-02-21 12:16:40 +010047 var IPA_Emulation_CT vc_IPA;
Harald Welte68e495b2018-02-25 00:05:57 +010048 /* RSL Emulation component (for ConnHdlr tests) */
Harald Welte70767382018-02-21 12:16:40 +010049 var RSL_Emulation_CT vc_RSL;
Harald Welte68e495b2018-02-25 00:05:57 +010050 /* Direct RSL_CCHAN_PT */
Harald Welte70767382018-02-21 12:16:40 +010051 port RSL_CCHAN_PT RSL_CCHAN;
Harald Welte68e495b2018-02-25 00:05:57 +010052
53 /* L1CTL port (for classic tests) */
54 port L1CTL_PT L1CTL;
Harald Welte70767382018-02-21 12:16:40 +010055}
56
57/* an individual call / channel */
58type component ConnHdlr extends RSL_DchanHdlr {
59 port L1CTL_PT L1CTL;
60
61 port TRXC_CODEC_PT BB_TRXC;
62 var integer g_bb_trxc_conn_id;
63
64 timer g_Tguard;
65 timer g_Tmeas_exp := 2.0; /* >= 103 SACCH multiframe ~ 500ms */
66
67 var ConnHdlrPars g_pars;
68 var uint8_t g_next_meas_res_nr := 0;
69}
70
71function f_init_rsl(charstring id) runs on test_CT {
72 vc_IPA := IPA_Emulation_CT.create(id & "-RSL-IPA");
73 vc_RSL := RSL_Emulation_CT.create(id & "-RSL");
74
75 map(vc_IPA:IPA_PORT, system:IPA_CODEC_PT);
76 connect(vc_IPA:IPA_RSL_PORT, vc_RSL:IPA_PT);
77 connect(self:RSL_CCHAN, vc_RSL:CCHAN_PT);
78
79 vc_IPA.start(IPA_Emulation.main_server(mp_rsl_ip, mp_rsl_port));
80 vc_RSL.start(RSL_Emulation.main(false));
81}
82
83type record ConnHdlrPars {
84 RslChannelNr chan_nr,
85 RSL_IE_ChannelMode chan_mode,
86 float t_guard,
87 ConnL1Pars l1_pars
88}
89
Harald Welte82ccef72018-02-25 16:17:33 +010090template (value) RachControlParameters ts_RachCtrl_default := {
91 max_retrans := RACH_MAX_RETRANS_1,
92 tx_integer := '0000'B, /* 3 slots */
93 cell_barr_access := false,
94 re_not_allowed := true,
95 acc := '1111111111111111'B
96};
97
Harald Welte7484fc42018-02-24 14:09:45 +010098/* Default SYSTEM INFORMATION 3 */
Harald Welte82ccef72018-02-25 16:17:33 +010099template (value) SystemInformation ts_SI3_default := {
Harald Welte7484fc42018-02-24 14:09:45 +0100100 header := t_RrHeader(SYSTEM_INFORMATION_TYPE_3, 0),
101 payload := {
102 si3 := {
103 cell_id := 23,
104 lai := {
105 mcc_mnc := '262F42'H,
106 lac := 42
107 },
108 ctrl_chan_desc := {
109 msc_r99 := true,
110 att := true,
111 bs_ag_blks_res := 1,
112 ccch_conf := CCHAN_DESC_1CCCH_COMBINED,
Harald Welte82ccef72018-02-25 16:17:33 +0100113 si22ind := false,
Harald Welte7484fc42018-02-24 14:09:45 +0100114 cbq3 := CBQ3_IU_MODE_NOT_SUPPORTED,
115 spare := '00'B,
116 bs_pa_mfrms := 0, /* 2 multiframes */
117 t3212 := 1 /* 6 minutes */
118 },
Harald Welte82ccef72018-02-25 16:17:33 +0100119 cell_options := {
Harald Welte7484fc42018-02-24 14:09:45 +0100120 dn_ind := false,
121 pwrc := false,
122 dtx := MS_MAY_USE_UL_DTX,
123 radio_link_tout_div4 := 4/4
124 },
Harald Welte82ccef72018-02-25 16:17:33 +0100125 cell_sel_par := {
Harald Welte7484fc42018-02-24 14:09:45 +0100126 cell_resel_hyst_2dB := 0,
127 ms_txpwr_max_cch := 0,
128 acs := '0'B,
129 neci := true,
130 rxlev_access_min := 0
131 },
Harald Welte82ccef72018-02-25 16:17:33 +0100132 rach_control := ts_RachCtrl_default,
Harald Welte7484fc42018-02-24 14:09:45 +0100133 rest_octets := ''O
134 }
135 }
136}
Harald Welte70767382018-02-21 12:16:40 +0100137
138/* global init function */
Harald Welte68e495b2018-02-25 00:05:57 +0100139function f_init(charstring id := "BTS-Test") runs on test_CT {
Harald Welte70767382018-02-21 12:16:40 +0100140 f_init_rsl(id);
141 RSL_CCHAN.receive(ASP_IPA_Event:{up_down := ASP_IPA_EVENT_UP});
Harald Welte2d142592018-02-25 13:19:44 +0100142 f_sleep(0.5); /* workaround for OS#3000 */
Harald Welte7484fc42018-02-24 14:09:45 +0100143
144 /* Send SI3 to the BTS, it is needed for various computations */
Harald Welte82ccef72018-02-25 16:17:33 +0100145 var SystemInformation si3 := valueof(ts_SI3_default);
Harald Welte7484fc42018-02-24 14:09:45 +0100146 log("Sending SI3 ", si3);
Harald Welte82ccef72018-02-25 16:17:33 +0100147 var octetstring si3_enc := enc_SystemInformation(si3);
Harald Welte7484fc42018-02-24 14:09:45 +0100148 RSL_CCHAN.send(ts_RSL_UD(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_3, si3_enc)));
Harald Welte70767382018-02-21 12:16:40 +0100149}
150
Harald Welte68e495b2018-02-25 00:05:57 +0100151/* Attach L1CTL to master test_CT (classic tests, non-handler mode) */
152function f_init_l1ctl() runs on test_CT {
153 map(self:L1CTL, system:L1CTL);
154 f_connect_reset(L1CTL);
155}
156
Harald Welte70767382018-02-21 12:16:40 +0100157type function void_fn(charstring id) runs on ConnHdlr;
158
159/* create a new test component */
160function f_start_handler(void_fn fn, ConnHdlrPars pars)
161runs on test_CT return ConnHdlr {
162 var charstring id := testcasename();
163 var ConnHdlr vc_conn;
164
165 vc_conn := ConnHdlr.create(id);
166 /* connect to RSL Emulation main component */
167 connect(vc_conn:RSL, vc_RSL:CLIENT_PT);
168 connect(vc_conn:RSL_PROC, vc_RSL:RSL_PROC);
169
170 vc_conn.start(f_handler_init(fn, id, pars));
171 return vc_conn;
172}
173
Harald Welte7484fc42018-02-24 14:09:45 +0100174template ASP_RSL_Unitdata ts_RSL_UD(template RSL_Message rsl, IpaStreamId sid := IPAC_PROTO_RSL_TRX0) := {
175 streamId := sid,
176 rsl := rsl
177}
178
179template ASP_RSL_Unitdata tr_RSL_UD(template RSL_Message rsl,
180 template IpaStreamId sid := IPAC_PROTO_RSL_TRX0) := {
181 streamId := sid,
182 rsl := rsl
183}
184
Harald Welte70767382018-02-21 12:16:40 +0100185private altstep as_Tguard() runs on ConnHdlr {
186 [] g_Tguard.timeout {
187 setverdict(fail, "Tguard timeout");
188 self.stop;
189 }
190}
191
Harald Welte68e495b2018-02-25 00:05:57 +0100192private function f_l1_tune(L1CTL_PT L1CTL) {
Harald Welte70767382018-02-21 12:16:40 +0100193 f_L1CTL_FBSB(L1CTL, { false, mp_trx0_arfcn }, CCCH_MODE_COMBINED);
194}
195
196private function f_trxc_connect() runs on ConnHdlr {
197 map(self:BB_TRXC, system:BB_TRXC);
198 var Result res;
199 res := TRXC_CodecPort_CtrlFunct.f_IPL4_connect(BB_TRXC, "127.0.0.1", mp_bb_trxc_port,
200 "127.0.0.1", 0, -1, {udp:={}}, {});
201 g_bb_trxc_conn_id := res.connId;
202}
203
204private function f_trxc_fake_rssi(uint8_t rssi) runs on ConnHdlr {
205 BB_TRXC.send(ts_TRXC_Send(g_bb_trxc_conn_id, ts_TRXC_FAKE_RSSI(rssi)));
206}
207
208private function f_trx_fake_toffs256(int16_t toffs256) runs on ConnHdlr {
209 BB_TRXC.send(ts_TRXC_Send(g_bb_trxc_conn_id, ts_TRXC_FAKE_TIMING(toffs256)));
210}
211
212/* first function started in ConnHdlr component */
213private function f_handler_init(void_fn fn, charstring id, ConnHdlrPars pars)
214runs on ConnHdlr {
215 g_pars := pars;
216 g_chan_nr := pars.chan_nr;
217
218 map(self:L1CTL, system:L1CTL);
219 f_connect_reset(L1CTL);
220
221 f_trxc_connect();
222
223 g_Tguard.start(pars.t_guard);
224 activate(as_Tguard());
225
226 f_rslem_register(0, pars.chan_nr);
227
228 /* call the user-supplied test case function */
229 fn.apply(id);
230}
231
Harald Welte1eba3742018-02-25 12:48:14 +0100232function f_rsl_transceive(template RSL_Message tx, template RSL_Message exp_rx, charstring id)
233runs on ConnHdlr {
234 timer T := 3.0;
235 RSL.send(tx);
236 T.start;
Harald Welte70767382018-02-21 12:16:40 +0100237 alt {
Harald Welte1eba3742018-02-25 12:48:14 +0100238 [] RSL.receive(exp_rx) {
239 T.stop;
240 setverdict(pass);
Harald Welte70767382018-02-21 12:16:40 +0100241 }
Harald Welte1eba3742018-02-25 12:48:14 +0100242 [] T.timeout {
243 setverdict(fail, "Timeout expecting " & id);
244 self.stop;
245 }
246 [] RSL.receive {
247 setverdict(fail, "Unexpected RSL message received");
Harald Welte70767382018-02-21 12:16:40 +0100248 }
249 }
250}
251
Harald Welte1eba3742018-02-25 12:48:14 +0100252function f_rsl_chan_act(RSL_IE_ChannelMode mode) runs on ConnHdlr {
253 f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, mode), tr_RSL_CHAN_ACT_ACK(g_chan_nr),
254 "RSL CHAN ACT");
255}
256
Harald Welte70767382018-02-21 12:16:40 +0100257function f_rsl_chan_deact() runs on ConnHdlr {
Harald Welte1eba3742018-02-25 12:48:14 +0100258 f_rsl_transceive(ts_RSL_RF_CHAN_REL(g_chan_nr), tr_RSL_RF_CHAN_REL_ACK(g_chan_nr),
259 "RF CHAN REL");
Harald Welte70767382018-02-21 12:16:40 +0100260}
261
Harald Welte70767382018-02-21 12:16:40 +0100262private template ConnHdlrPars t_Pars(template RslChannelNr chan_nr,
263 template RSL_IE_ChannelMode chan_mode,
264 float t_guard := 20.0) := {
265 chan_nr := valueof(chan_nr),
266 chan_mode := valueof(chan_mode),
267 t_guard := t_guard,
268 l1_pars := {
269 dtx_enabled := false,
270 meas_ul := {
271 full := {
272 rxlev := dbm2rxlev(-53),
273 rxqual := 0
274 },
275 sub := {
276 rxlev := dbm2rxlev(-53),
277 rxqual := 0
278 }
279 },
280 timing_offset_256syms := 0,
281 bs_power_level := 0,
282 ms_power_level := 0,
283 ms_actual_ta := 0
284 }
285}
286
287/* Stress test: Do 500 channel activations/deactivations in rapid succession */
288function f_TC_chan_act_stress(charstring id) runs on ConnHdlr {
289 for (var integer i := 0; i < 500; i := i+1) {
290 f_rsl_chan_act(g_pars.chan_mode);
291 f_rsl_chan_deact();
292 }
293 setverdict(pass);
294}
295testcase TC_chan_act_stress() runs on test_CT {
296 var ConnHdlr vc_conn;
297 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
298 f_init(testcasename());
299 vc_conn := f_start_handler(refers(f_TC_chan_act_stress), pars);
300 vc_conn.done;
301}
302
303/* Test if re-activation of an already active channel fails as expected */
304function f_TC_chan_act_react(charstring id) runs on ConnHdlr {
305 f_rsl_chan_act(g_pars.chan_mode);
306 /* attempt to activate the same lchan again -> expect reject */
307 RSL.send(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode));
308 alt {
309 [] RSL.receive(tr_RSL_CHAN_ACT_ACK(g_chan_nr)) {
310 setverdict(fail, "Unexpected CHAN ACT ACK on double activation");
311 }
312 [] RSL.receive(tr_RSL_CHAN_ACT_NACK(g_chan_nr)) {
313 setverdict(pass);
314 }
315 }
316 f_rsl_chan_deact();
317}
318testcase TC_chan_act_react() runs on test_CT {
319 var ConnHdlr vc_conn;
320 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
321 f_init(testcasename());
322 vc_conn := f_start_handler(refers(f_TC_chan_act_react), pars);
323 vc_conn.done;
324}
325
326/* Attempt to de-activate a channel that's not active */
327function f_TC_chan_deact_not_active(charstring id) runs on ConnHdlr {
328 timer T := 3.0;
329 RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr));
330 T.start;
331 alt {
332 [] RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr)) {
333 setverdict(pass);
334 }
335 [] T.timeout {
336 setverdict(fail, "Timeout expecting RF_CHAN_REL_ACK");
337 }
338 }
339}
340testcase TC_chan_deact_not_active() runs on test_CT {
341 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
342 f_init(testcasename());
343 var ConnHdlr vc_conn := f_start_handler(refers(f_TC_chan_deact_not_active), pars);
344 vc_conn.done;
345}
346
347/* attempt to activate channel with wrong RSL Channel Nr IE; expect NACK */
348function f_TC_chan_act_wrong_nr(charstring id) runs on ConnHdlr {
349 RSL.send(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode));
350 alt {
351 [] RSL.receive(tr_RSL_CHAN_ACT_ACK(g_chan_nr)) {
352 setverdict(fail, "Unexpected CHAN ACT ACK");
353 }
354 [] RSL.receive(tr_RSL_CHAN_ACT_NACK(g_chan_nr)) {
355 setverdict(pass);
356 }
357 }
358}
359private type record WrongChanNrCase {
360 RslChannelNr chan_nr,
361 charstring description
362}
363private type record of WrongChanNrCase WrongChanNrCases;
364private template WrongChanNrCase t_WCN(template RslChannelNr chan_nr, charstring desc) := {
365 chan_nr := chan_nr,
366 description := desc
367}
368
369testcase TC_chan_act_wrong_nr() runs on test_CT {
370 var ConnHdlr vc_conn;
371 var ConnHdlrPars pars;
372
373 f_init(testcasename());
374
375 var WrongChanNrCases wrong := {
376 valueof(t_WCN(t_RslChanNr_RACH(0), "RACH is not a dedicated channel")),
377 valueof(t_WCN(t_RslChanNr_RACH(1), "RACH doesn't exist on timeslot")),
378 valueof(t_WCN(t_RslChanNr_BCCH(0), "BCCH is not a dedicated channel")),
379 valueof(t_WCN(t_RslChanNr_PCH_AGCH(0), "PCH/AGCH is not a dedicated channel")),
380 valueof(t_WCN(t_RslChanNr_Bm(0), "TS0 cannot be TCH/F")),
381 valueof(t_WCN(t_RslChanNr_Lm(0, 0), "TS0 cannot be TCH/H")),
382 valueof(t_WCN(t_RslChanNr_Lm(0, 1), "TS0 cannot be TCH/H")),
383 valueof(t_WCN(t_RslChanNr_PDCH(0), "TS0 cannot be PDCH")),
384 valueof(t_WCN(t_RslChanNr_SDCCH8(0, 0), "TS0 cannot be SDCCH/8")),
385 valueof(t_WCN(t_RslChanNr_SDCCH8(0, 7), "TS0 cannot be SDCCH/8")),
386 valueof(t_WCN(t_RslChanNr_SDCCH4(7, 0), "TS7 cannot be SDCCH/4")),
387 valueof(t_WCN(t_RslChanNr_SDCCH4(7, 3), "TS7 cannot be SDCCH/4")),
388 valueof(t_WCN(t_RslChanNr_Lm(1, 0), "TS1 cannot be TCH/H"))
389 };
390
391 for (var integer i := 0; i < sizeof(wrong); i := i+1) {
392 pars := valueof(t_Pars(wrong[i].chan_nr, ts_RSL_ChanMode_SIGN));
393 vc_conn := f_start_handler(refers(f_TC_chan_act_wrong_nr), pars);
394 vc_conn.done;
395 }
396}
397
398function f_TC_chan_req(charstring id) runs on ConnHdlr {
Harald Welte68e495b2018-02-25 00:05:57 +0100399 f_l1_tune(L1CTL);
Harald Welte70767382018-02-21 12:16:40 +0100400
401 RSL.clear;
402 //L1.send(DCCH_establish_req:{ra := 23});
403 /* This arrives on CCHAN, so we cannot test here */
404 //RSL.receive(tr_RSL_CHAN_RQD(int2oct(23,1)));
405}
406testcase TC_chan_req() runs on test_CT {
407 var ConnHdlr vc_conn;
408 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
409 f_init(testcasename());
410 vc_conn := f_start_handler(refers(f_TC_chan_req), pars);
411 vc_conn.done;
412}
413
414template LapdmAddressField ts_LapdmAddr(LapdmSapi sapi, boolean c_r) := {
415 spare := '0'B,
416 lpd := 0,
417 sapi := sapi,
418 c_r := c_r,
419 ea := true
420}
421
422template LapdmFrameB ts_LAPDm_B(LapdmSapi sapi, boolean c_r, boolean p, octetstring pl) := {
423 addr := ts_LapdmAddr(sapi, c_r),
424 ctrl := t_LapdmCtrlUI(p),
425 len := 0, /* overwritten */
426 m := false,
427 el := 1,
428 payload := pl
429}
430
431/* handle incoming downlink SACCH and respond with uplink SACCH (meas res) */
432altstep as_l1_sacch() runs on ConnHdlr {
433 var L1ctlDlMessage l1_dl;
434 [] L1CTL.receive(t_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl {
435 log("SACCH received: ", l1_dl.payload.data_ind.payload);
436 var GsmRrL3Message meas_rep := valueof(ts_MEAS_REP(true, 23, 23, 0, 0, omit));
437 var LapdmFrameB lb := valueof(ts_LAPDm_B(0, false, false, enc_GsmRrL3Message(meas_rep)));
438 log("LAPDm: ", lb);
439 var octetstring pl := '0000'O & enc_LapdmFrameB(lb);
440 L1CTL.send(t_L1CTL_DATA_REQ(g_chan_nr, ts_RslLinkID_SACCH(0), pl));
441 repeat;
442 }
443}
444
445altstep as_l1_dcch() runs on ConnHdlr {
446 var L1ctlDlMessage l1_dl;
447 [] L1CTL.receive(t_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_DCCH(?))) -> value l1_dl {
448 log("DCCH received: ", l1_dl.payload.data_ind.payload);
449 var octetstring pl := '010301'O;
450 L1CTL.send(t_L1CTL_DATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0), pl));
451 repeat;
452 }
453}
454
455type record MeasElem {
456 uint6_t rxlev,
457 uint3_t rxqual
458}
459
460type record MeasElemFS {
461 MeasElem full,
462 MeasElem sub
463}
464
465type record ConnL1Pars {
466 boolean dtx_enabled,
467 MeasElemFS meas_ul,
468 int16_t timing_offset_256syms,
469 uint5_t bs_power_level,
470 uint5_t ms_power_level,
471 uint8_t ms_actual_ta
472}
473
474/* Convert tiing offset from 1/256th symbol to RSL Timing Offset */
475private function toffs256s_to_rsl(int16_t toffs256s) return uint8_t {
476 return 63 + (toffs256s/256);
477}
478
479/* build a template for matching measurement results against */
480private function f_build_meas_res_tmpl() runs on ConnHdlr return template RSL_Message {
481 var ConnL1Pars l1p := g_pars.l1_pars;
482 var template RSL_IE_UplinkMeas ul_meas := {
483 len := 3,
484 rfu := '0'B,
485 dtx_d := l1p.dtx_enabled,
486 rxlev_f_u := l1p.meas_ul.full.rxlev,
487 reserved1 := '00'B,
488 rxlev_s_u := l1p.meas_ul.sub.rxlev,
489 reserved2 := '00'B,
490 rxq_f_u := l1p.meas_ul.full.rxqual,
491 rxq_s_u := l1p.meas_ul.sub.rxqual,
492 supp_meas_info := omit
493 };
494 /* HACK HACK HACK FIXME HACK HACK HACK see https://osmocom.org/issues/2988 */
495 ul_meas.rxlev_f_u := ?;
496 ul_meas.rxlev_s_u := ?;
497 ul_meas.rxq_f_u := ?;
498 ul_meas.rxq_s_u := ?;
499 var template RSL_IE_BS_Power bs_power := {
500 reserved := 0,
501 epc := false,
502 fpc := false,
503 power_level := l1p.bs_power_level
504 };
505 var template RSL_IE_L1Info l1_info := {
506 ms_power_lvl := l1p.ms_power_level,
507 fpc := false,
508 reserved := 0,
509 actual_ta := l1p.ms_actual_ta
510 };
511 var uint8_t offs := toffs256s_to_rsl(l1p.timing_offset_256syms);
512 var template uint8_t t_toffs := (offs-1 .. offs+1); /* some tolerance */
513 return tr_RSL_MEAS_RES_OSMO(g_chan_nr, g_next_meas_res_nr, ul_meas, bs_power, l1_info,
514 ?, t_toffs);
515}
516
517/* verify we regularly receive measurement reports with incrementing numbers */
518altstep as_meas_res() runs on ConnHdlr {
519 var RSL_Message rsl;
520 [] RSL.receive(f_build_meas_res_tmpl()) -> value rsl {
521 /* increment counter of next to-be-expected meas rep */
522 g_next_meas_res_nr := (g_next_meas_res_nr + 1) mod 256;
523 /* Re-start the timer expecting the next MEAS RES */
524 g_Tmeas_exp.start;
525 repeat;
526 }
527 [] RSL.receive(tr_RSL_MEAS_RES(g_chan_nr, g_next_meas_res_nr)) -> value rsl {
528 setverdict(fail, "Received unspecific MEAS RES ", rsl);
529 self.stop;
530 }
531 [] RSL.receive(tr_RSL_MEAS_RES(?)) -> value rsl {
532 setverdict(fail, "Received unexpected MEAS RES ", rsl);
533 self.stop;
534 }
535 [] g_Tmeas_exp.timeout {
536 setverdict(fail, "Didn't receive expected measurement result")
537 self.stop;
538 }
539}
540
541/* Establish dedicated channel: L1CTL + RSL side */
542private function f_est_dchan() runs on ConnHdlr {
543 var GsmFrameNumber fn;
544 var ImmediateAssignment imm_ass;
545 var integer ra := 23;
546
547 fn := f_L1CTL_RACH(L1CTL, ra);
548 /* This arrives on CCHAN, so we cannot test for receiving CHAN RQDhere */
549 //RSL.receive(tr_RSL_CHAN_RQD(int2oct(23,1)));
550
551 /* Activate channel on BTS side */
552 f_rsl_chan_act(g_pars.chan_mode);
553
554 /* Send IMM.ASS via CCHAN */
555 var ChannelDescription ch_desc := {
556 chan_nr := g_pars.chan_nr,
557 tsc := 7,
558 h := false,
559 arfcn := mp_trx0_arfcn,
560 maio_hsn := omit
561 };
562 var MobileAllocation ma := {
563 len := 0,
564 ma := ''B
565 };
566 var GsmRrMessage rr_msg := valueof(ts_IMM_ASS(ra, fn, 0, ch_desc, ma));
567 RSL.send(ts_RSL_IMM_ASSIGN(enc_GsmRrMessage(rr_msg)));
568
569 /* receive IMM.ASS on MS side */
570 var ImmediateAssignment ia_um;
571 ia_um := f_L1CTL_WAIT_IMM_ASS(L1CTL, ra, fn);
572 /* enable dedicated mode */
573 f_L1CTL_DM_EST_REQ_IA(L1CTL, ia_um);
574}
575
576/* establish DChan, verify existance + contents of measurement reports */
577function f_TC_meas_res_periodic(charstring id) runs on ConnHdlr {
Harald Welte68e495b2018-02-25 00:05:57 +0100578 f_l1_tune(L1CTL);
Harald Welte70767382018-02-21 12:16:40 +0100579 RSL.clear;
580
581 g_pars.l1_pars.meas_ul.full.rxlev := dbm2rxlev(-100);
582 g_pars.l1_pars.meas_ul.sub.rxlev := g_pars.l1_pars.meas_ul.full.rxlev;
583 f_trxc_fake_rssi(100);
584
585 g_pars.l1_pars.timing_offset_256syms := 512; /* 2 symbols */
586 f_trx_fake_toffs256(g_pars.l1_pars.timing_offset_256syms);
587
588 f_est_dchan();
589
590 /* run for a number of seconds, send SACCH + FACCH from MS side and verify
591 * RSL measurement reports on Abis side */
592 timer T := 8.0;
593 T.start;
594 alt {
595 [] as_l1_sacch();
596 [] as_meas_res();
597 [] as_l1_dcch();
598 [] L1CTL.receive { repeat; }
599 [g_Tmeas_exp.running] T.timeout {
600 /* as_meas_res() would have done setverdict(fail) / self.stop in case
601 * of any earlier errors, so if we reach this timeout, we're good */
602 setverdict(pass);
603 }
604 [] T.timeout {
605 setverdict(fail, "No MEAS RES received at all");
606 }
607 }
608 f_rsl_chan_deact();
609}
610testcase TC_meas_res_sign_tchf() runs on test_CT {
611 var ConnHdlr vc_conn;
612 var ConnHdlrPars pars;
613 f_init(testcasename());
614 for (var integer tn := 1; tn <= 4; tn := tn+1) {
615 pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN));
616 vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars);
617 vc_conn.done;
618 }
619}
620testcase TC_meas_res_sign_tchh() runs on test_CT {
621 var ConnHdlr vc_conn;
622 var ConnHdlrPars pars;
623 f_init(testcasename());
624 for (var integer ss := 0; ss <= 1; ss := ss+1) {
625 pars := valueof(t_Pars(t_RslChanNr_Lm(5, ss), ts_RSL_ChanMode_SIGN));
626 vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars);
627 vc_conn.done;
628 }
629}
630testcase TC_meas_res_sign_sdcch4() runs on test_CT {
631 var ConnHdlr vc_conn;
632 var ConnHdlrPars pars;
633 f_init(testcasename());
634 for (var integer ss := 0; ss <= 3; ss := ss+1) {
635 pars := valueof(t_Pars(t_RslChanNr_SDCCH4(0, ss), ts_RSL_ChanMode_SIGN));
636 vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars);
637 vc_conn.done;
638 }
639}
640testcase TC_meas_res_sign_sdcch8() runs on test_CT {
641 var ConnHdlr vc_conn;
642 var ConnHdlrPars pars;
643 f_init(testcasename());
644 for (var integer ss := 0; ss <= 7; ss := ss+1) {
645 pars := valueof(t_Pars(t_RslChanNr_SDCCH8(6, ss), ts_RSL_ChanMode_SIGN));
646 vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars);
647 vc_conn.done;
648 }
649}
650
651/* Test if a channel without valid uplink bursts generates RSL CONN FAIL IND */
652private function f_TC_conn_fail_crit(charstring id) runs on ConnHdlr {
Harald Welte68e495b2018-02-25 00:05:57 +0100653 f_l1_tune(L1CTL);
Harald Welte70767382018-02-21 12:16:40 +0100654 RSL.clear;
655
656 f_est_dchan();
657 f_sleep(2.0);
658 L1CTL.send(t_L1CTL_DM_REL_REQ(g_chan_nr));
659
660 timer T := 40.0;
661 T.start;
662 alt {
663 [] RSL.receive(tr_RSL_CONN_FAIL_IND(g_chan_nr, ?)) {
664 setverdict(pass)
665 }
666 [] RSL.receive { repeat };
667 [] T.timeout {
668 setverdict(fail, "No CONN FAIL IND received");
669 }
670 }
671 f_rsl_chan_deact();
672}
673testcase TC_conn_fail_crit() runs on test_CT {
674 var ConnHdlr vc_conn;
675 var ConnHdlrPars pars;
676 f_init(testcasename());
677 pars := valueof(t_Pars(t_RslChanNr_SDCCH8(6, 3), ts_RSL_ChanMode_SIGN));
678 pars.t_guard := 60.0;
679 vc_conn := f_start_handler(refers(f_TC_conn_fail_crit), pars);
680 vc_conn.done;
681}
682
Harald Welte68e495b2018-02-25 00:05:57 +0100683function tmsi_is_dummy(TMSIP_TMSI_V tmsi) return boolean {
684 if (tmsi == 'FFFFFFFF'O) {
685 return true;
686 } else {
687 return false;
688 }
689}
Harald Welte70767382018-02-21 12:16:40 +0100690
691
Harald Welte68e495b2018-02-25 00:05:57 +0100692altstep as_l1_count_paging(inout integer num_paging_rcv_msgs, inout integer num_paging_rcv_ids)
693runs on test_CT {
694 var L1ctlDlMessage dl;
695 [] L1CTL.receive(t_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?, c_DummyUI)) {
696 repeat;
697 }
698 [] L1CTL.receive(t_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0))) -> value dl {
699 var octetstring without_plen :=
700 substr(dl.payload.data_ind.payload, 1, lengthof(dl.payload.data_ind.payload)-1);
701 var PDU_ML3_NW_MS rr := dec_PDU_ML3_NW_MS(without_plen);
702 if (match(rr, tr_PAGING_REQ1)) {
703 num_paging_rcv_msgs := num_paging_rcv_msgs + 1;
704 num_paging_rcv_ids := num_paging_rcv_ids + 1;
705 if (isvalue(rr.msgs.rrm.pagingReq_Type1.mobileIdentity2)) {
706 num_paging_rcv_ids := num_paging_rcv_ids + 1;
707 }
708 } else if (match(rr, tr_PAGING_REQ2)) {
709 num_paging_rcv_msgs := num_paging_rcv_msgs + 1;
710 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type2.mobileIdentity1)) {
711 num_paging_rcv_ids := num_paging_rcv_ids + 1;
712 }
713 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type2.mobileIdentity2)) {
714 num_paging_rcv_ids := num_paging_rcv_ids + 1;
715 }
716 if (isvalue(rr.msgs.rrm.pagingReq_Type2.mobileIdentity3)) {
717 num_paging_rcv_ids := num_paging_rcv_ids + 1;
718 }
719 } else if (match(rr, tr_PAGING_REQ3)) {
720 num_paging_rcv_msgs := num_paging_rcv_msgs + 1;
721 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity1)) {
722 num_paging_rcv_ids := num_paging_rcv_ids + 1;
723 }
724 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity2)) {
725 num_paging_rcv_ids := num_paging_rcv_ids + 1;
726 }
727 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity3)) {
728 num_paging_rcv_ids := num_paging_rcv_ids + 1;
729 }
730 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity4)) {
731 num_paging_rcv_ids := num_paging_rcv_ids + 1;
732 }
733 }
734 repeat;
735 }
736}
737
738type record PagingTestCfg {
739 boolean combined_ccch,
740 integer bs_ag_blks_res,
741 float load_factor,
742 boolean exp_load_ind,
743 boolean exp_overload,
744 boolean use_tmsi
745}
746
747type record PagingTestState {
748 integer num_paging_sent,
749 integer num_paging_rcv_msgs,
750 integer num_paging_rcv_ids,
751 integer num_overload
752}
753
754/* receive + ignore RSL RF RES IND */
755altstep as_rsl_res_ind() runs on test_CT {
756 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_RF_RES_IND)) {
757 repeat;
758 }
759}
760
761/* Helper function for paging related testing */
762private function f_TC_paging(PagingTestCfg cfg) runs on test_CT return PagingTestState {
763 f_init(testcasename());
764 f_init_l1ctl();
765 f_l1_tune(L1CTL);
766
767 var PagingTestState st := {
768 num_paging_sent := 0,
769 num_paging_rcv_msgs := 0,
770 num_paging_rcv_ids := 0,
771 num_overload := 0
772 };
773
774 var float max_pch_blocks_per_sec := f_pch_block_rate_est(cfg.combined_ccch, cfg.bs_ag_blks_res);
775 var float max_pch_imsi_per_sec;
776 if (cfg.use_tmsi) {
777 max_pch_imsi_per_sec := max_pch_blocks_per_sec * 4.0; /* Type 3 */
778 } else {
779 max_pch_imsi_per_sec := max_pch_blocks_per_sec * 2.0; /* Type 1 */
780 }
781 var float pch_blocks_per_sec := max_pch_imsi_per_sec * cfg.load_factor;
782 var float interval := 1.0 / pch_blocks_per_sec;
783 log("pch_blocks_per_sec=", pch_blocks_per_sec, " interval=", interval);
784
785 for (var integer i := 0; i < float2int(20.0/interval); i := i+1) {
786 /* build mobile Identity */
787 var MobileL3_CommonIE_Types.MobileIdentityLV mi;
788 if (cfg.use_tmsi) {
789 mi := valueof(ts_MI_TMSI_LV(f_rnd_octstring(4)));
790 } else {
791 mi := valueof(ts_MI_IMSI_LV(f_gen_imsi(i)));
792 }
793 var octetstring mi_enc_lv := enc_MobileIdentityLV(mi);
794 var octetstring mi_enc := substr(mi_enc_lv, 1, lengthof(mi_enc_lv)-1);
795
796 /* Send RSL PAGING COMMAND */
797 RSL_CCHAN.send(ts_RSL_UD(ts_RSL_PAGING_CMD(mi_enc, i mod 4)));
798 st.num_paging_sent := st.num_paging_sent + 1;
799
800 /* Wait for interval to next PAGING COMMAND */
801 timer T_itv := interval;
802 T_itv.start;
803 alt {
804 /* check for presence of CCCH LOAD IND (paging load) */
805 [cfg.exp_overload] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_PAGING_LOAD_IND(0))) {
806 st.num_overload := st.num_overload + 1;
807 repeat;
808 }
809 [not cfg.exp_overload] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_PAGING_LOAD_IND(0))) {
810 setverdict(fail, "Unexpected PCH Overload");
811 }
812 [cfg.exp_load_ind] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_PAGING_LOAD_IND)) {
813 log("Rx LOAD_IND");
814 /* FIXME: analyze/verify interval + contents */
815 repeat;
816 }
817 /* check if paging requests arrive on Um side */
818 [] as_l1_count_paging(st.num_paging_rcv_msgs, st.num_paging_rcv_ids);
819 [] L1CTL.receive { repeat; }
820 [] T_itv.timeout { }
821 [] as_rsl_res_ind();
822 }
823 }
824
825 /* wait for max 18s for paging queue to drain (size: 200, ~ 13 per s -> 15s) */
826 timer T_wait := 18.0;
827 T_wait.start;
828 alt {
829 [] as_l1_count_paging(st.num_paging_rcv_msgs, st.num_paging_rcv_ids);
830 [] L1CTL.receive { repeat; }
831 /* 65535 == empty paging queue, we can terminate*/
832 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_PAGING_LOAD_IND(65535))) { }
833 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_PAGING_LOAD_IND)) { repeat; }
834 [] T_wait.timeout {
835 setverdict(fail, "Waiting for empty paging queue");
836 }
837 [] as_rsl_res_ind();
838 }
839
840 log("num_paging_sent=", st.num_paging_sent, " rcvd_msgs=", st.num_paging_rcv_msgs,
841 " rcvd_ids=", st.num_paging_rcv_ids);
842 return st;
843}
844
845/* Create ~ 80% paging load (IMSI only) sustained for about 20s, verifying that
846 * - the number of Mobile Identities on Um PCH match the number of pages on RSL
847 * - that CCCH LOAD IND (PCH) are being generated
848 * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */
849testcase TC_paging_imsi_80percent() runs on test_CT {
850 var PagingTestCfg cfg := {
851 combined_ccch := true,
852 bs_ag_blks_res := 1,
853 load_factor := 0.8,
854 exp_load_ind := true,
855 exp_overload := false,
856 use_tmsi := false
857 };
858 var PagingTestState st := f_TC_paging(cfg);
859 if (st.num_paging_sent != st.num_paging_rcv_ids) {
860 setverdict(fail, "Expected ", st.num_paging_sent, " pagings but have ",
861 st.num_paging_rcv_ids);
862 } else {
863 setverdict(pass);
864 }
865}
866
867/* Create ~ 80% paging load (TMSI only) sustained for about 20s, verifying that
868 * - the number of Mobile Identities on Um PCH match the number of pages on RSL
869 * - that CCCH LOAD IND (PCH) are being generated
870 * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */
871testcase TC_paging_tmsi_80percent() runs on test_CT {
872 var PagingTestCfg cfg := {
873 combined_ccch := true,
874 bs_ag_blks_res := 1,
875 load_factor := 0.8,
876 exp_load_ind := true,
877 exp_overload := false,
878 use_tmsi := true
879 };
880 var PagingTestState st := f_TC_paging(cfg);
881 if (st.num_paging_sent != st.num_paging_rcv_ids) {
882 setverdict(fail, "Expected ", st.num_paging_sent, " pagings but have ",
883 st.num_paging_rcv_ids);
884 } else {
885 setverdict(pass);
886 }
887}
888
889/* Create ~ 200% paging load (IMSI only) sustained for about 20s, verifying that
890 * - the number of Mobile Identities on Um PCH are ~ 82% of the number of pages on RSL
891 * - that CCCH LOAD IND (PCH) are being generated and reach 0 at some point
892 * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */
893testcase TC_paging_imsi_200percent() runs on test_CT {
894 var PagingTestCfg cfg := {
895 combined_ccch := true,
896 bs_ag_blks_res := 1,
897 load_factor := 2.0,
898 exp_load_ind := true,
899 exp_overload := true,
900 use_tmsi := false
901 };
902 var PagingTestState st := f_TC_paging(cfg);
903 /* We expect about 80-85% to pass, given that we can fill the paging buffer of 200
904 * slots and will fully drain that buffer before returning */
905 var template integer tpl := (st.num_paging_sent*80/100 .. st.num_paging_sent *85/100);
906 if (not match(st.num_paging_rcv_ids, tpl)) {
907 setverdict(fail, "Expected ", tpl, " pagings but have ", st.num_paging_rcv_ids);
908 } else {
909 setverdict(pass);
910 }
911}
912
913/* Create ~ 200% paging load (TMSI only) sustained for about 20s, verifying that
914 * - the number of Mobile Identities on Um PCH are ~ 82% of the number of pages on RSL
915 * - that CCCH LOAD IND (PCH) are being generated and reach 0 at some point
916 * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */
917testcase TC_paging_tmsi_200percent() runs on test_CT {
918 var PagingTestCfg cfg := {
919 combined_ccch := true,
920 bs_ag_blks_res := 1,
921 load_factor := 2.0,
922 exp_load_ind := true,
923 exp_overload := true,
924 use_tmsi := true
925 };
926 var PagingTestState st := f_TC_paging(cfg);
927 /* We expect about 70% to pass, given that we can fill the paging buffer of 200
928 * slots and will fully drain that buffer before returning */
929 var template integer tpl := (st.num_paging_sent*68/100 .. st.num_paging_sent *72/100);
930 if (not match(st.num_paging_rcv_ids, tpl)) {
931 setverdict(fail, "Expected ", tpl, " pagings but have ", st.num_paging_rcv_ids);
932 } else {
933 setverdict(pass);
934 }
935}
936
937
938testcase TC_imm_ass() runs on test_CT {
939 f_init(testcasename());
940 for (var integer i := 0; i < 1000; i := i+1) {
941 var octetstring ia_enc := f_rnd_octstring(8);
942 RSL_CCHAN.send(ts_RSL_UD(ts_RSL_IMM_ASSIGN(ia_enc, 0)));
943 f_sleep(0.02);
944 }
945 /* FIXME: check if imm.ass arrive on Um side */
946 /* FIXME: check for DELETE INDICATION */
947 f_sleep(100.0);
948}
949
950testcase TC_bcch_info() runs on test_CT {
951 f_init(testcasename());
952 /* FIXME: enable / disable individual BCCH info */
953 //ts_RSL_BCCH_INFO(si_type, info);
954 /* expect no ERROR REPORT after either of them *
955 /* negative test: ensure ERROR REPORT on unsupported types */
956}
957
Harald Welte01d982c2018-02-25 01:31:40 +0100958private function f_exp_err_rep(template RSL_Cause cause) runs on test_CT {
959 timer T := 5.0;
960 T.start;
961 alt {
962 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_ERROR_REPORT(cause))) {
963 setverdict(pass);
964 }
965 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_ERROR_REPORT(?))) {
966 setverdict(fail, "Wrong cause in RSL ERR REP");
967 }
968 [] RSL_CCHAN.receive {
969 repeat;
970 }
971 [] T.timeout {
972 setverdict(fail, "Timeout waiting for RSL ERR REP");
973 }
974 }
975}
976
977/* Provoke a protocol error (message too short) and match on ERROR REPORT */
978testcase TC_rsl_protocol_error() runs on test_CT {
979 f_init(testcasename());
980 var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O));
981 rsl.ies := omit;
982 RSL_CCHAN.send(ts_RSL_UD(rsl));
983
984 f_exp_err_rep(RSL_ERR_PROTO);
985}
986
987/* Provoke a mandatory IE error and match on ERROR REPORT */
988testcase TC_rsl_mand_ie_error() runs on test_CT {
989 f_init(testcasename());
990
991 var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O));
992 rsl.ies := { rsl.ies[0] };
993 RSL_CCHAN.send(ts_RSL_UD(rsl));
994
995 f_exp_err_rep(RSL_ERR_MAND_IE_ERROR);
996}
997
998/* Provoke an IE content error and match on ERROR REPORT */
999testcase TC_rsl_ie_content_error() runs on test_CT {
1000 f_init(testcasename());
1001 var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O));
1002 rsl.ies[1].body.sysinfo_type := RSL_SYSTEM_INFO_5;
1003 RSL_CCHAN.send(ts_RSL_UD(rsl));
1004
1005 f_exp_err_rep(RSL_ERR_IE_CONTENT);
1006}
1007
Harald Weltea871a382018-02-25 02:03:14 +01001008/* Send IPA DLCX to inactive lchan */
1009function f_TC_ipa_dlcx_not_active(charstring id) runs on ConnHdlr {
Harald Welte1eba3742018-02-25 12:48:14 +01001010 f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, 0), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?),
1011 "IPA DLCX ACK");
Harald Weltea871a382018-02-25 02:03:14 +01001012}
1013testcase TC_ipa_dlcx_not_active() runs on test_CT {
1014 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
1015 f_init(testcasename());
1016 var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_dlcx_not_active), pars);
1017 vc_conn.done;
1018}
Harald Welte68e495b2018-02-25 00:05:57 +01001019
Harald Weltea3f1df92018-02-25 12:49:55 +01001020/* Send IPA CRCX twice to inactive lchan */
1021function f_TC_ipa_crcx_twice_not_active(charstring id) runs on ConnHdlr {
1022 f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?),
1023 "IPA CRCX ACK");
1024 f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_NACK(g_chan_nr, RSL_ERR_RES_UNAVAIL),
1025 "IPA CRCX NACK");
1026}
1027testcase TC_ipa_crcx_twice_not_active() runs on test_CT {
1028 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
1029 f_init(testcasename());
1030 var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_twice_not_active), pars);
1031 vc_conn.done;
1032}
1033
1034/* Regular sequence of CRCX/MDCX/DLCX */
1035function f_TC_ipa_crcx_mdcx_dlcx_not_active(charstring id) runs on ConnHdlr {
1036 f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?),
1037 "IPA CRCX ACK");
1038 var uint32_t remote_ip := f_rnd_int(c_UINT32_MAX);
1039 var uint16_t remote_port := f_rnd_int(c_UINT16_MAX);
1040 var uint7_t rtp_pt2 := f_rnd_int(127);
1041 var uint16_t fake_conn_id := 23; /* we're too lazy to read it out from the CRCX ACK above */
1042 f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2),
1043 tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2),
1044 "IPA MDCX ACK");
1045 f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, fake_conn_id), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?),
1046 "IPA DLCX ACK");
1047}
1048testcase TC_ipa_crcx_mdcx_dlcx_not_active() runs on test_CT {
1049 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
1050 f_init(testcasename());
1051 var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_mdcx_dlcx_not_active), pars);
1052 vc_conn.done;
1053}
1054
Harald Welte3ae11da2018-02-25 13:36:06 +01001055/* Sequence of CRCX, 2x MDCX, DLCX */
1056function f_TC_ipa_crcx_mdcx_mdcx_dlcx_not_active(charstring id) runs on ConnHdlr {
1057 f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?),
1058 "IPA CRCX ACK");
1059 var uint32_t remote_ip := f_rnd_int(c_UINT32_MAX);
1060 var uint16_t remote_port := f_rnd_int(c_UINT16_MAX);
1061 var uint7_t rtp_pt2 := f_rnd_int(127);
1062 var uint16_t fake_conn_id := 23; /* we're too lazy to read it out from the CRCX ACK above */
1063 f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2),
1064 tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2),
1065 "IPA MDCX ACK");
1066 /* Second MDCX */
1067 remote_ip := f_rnd_int(c_UINT32_MAX);
1068 remote_port := f_rnd_int(c_UINT16_MAX);
1069 f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2),
1070 tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2),
1071 "IPA MDCX ACK");
1072 f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, fake_conn_id), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?),
1073 "IPA DLCX ACK");
1074}
1075testcase TC_ipa_crcx_mdcx_mdcx_dlcx_not_active() runs on test_CT {
1076 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
1077 f_init(testcasename());
1078 var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_mdcx_mdcx_dlcx_not_active), pars);
1079 vc_conn.done;
1080}
1081
Harald Welte9912eb52018-02-25 13:30:15 +01001082/* IPA CRCX on SDCCH/4 and SDCCH/8 (doesn't make sense) */
1083function f_TC_ipa_crcx_sdcch_not_active(charstring id) runs on ConnHdlr {
1084 f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_NACK(g_chan_nr, ?),
1085 "IPA CRCX NACK");
1086}
1087testcase TC_ipa_crcx_sdcch_not_active() runs on test_CT {
1088 var ConnHdlrPars pars;
1089 var ConnHdlr vc_conn;
1090 f_init(testcasename());
1091
1092 pars := valueof(t_Pars(t_RslChanNr_SDCCH4(0,1), ts_RSL_ChanMode_SIGN));
1093 vc_conn := f_start_handler(refers(f_TC_ipa_crcx_sdcch_not_active), pars);
1094 vc_conn.done;
1095
1096 pars := valueof(t_Pars(t_RslChanNr_SDCCH8(6,5), ts_RSL_ChanMode_SIGN));
1097 vc_conn := f_start_handler(refers(f_TC_ipa_crcx_sdcch_not_active), pars);
1098 vc_conn.done;
1099}
1100
Harald Weltea3f1df92018-02-25 12:49:55 +01001101
Harald Welte68e495b2018-02-25 00:05:57 +01001102/* TODO Areas:
1103
1104* channel activation
1105** with BS_Power / MS_Power, bypassing power control loop
1106** on primary vs. secondary TRX
1107** with encryption from initial activation on
1108** with timing advance from initial activation on
1109* mode modify
1110** encryption
1111** multirate
1112* check DEACTIVATE SACCH
1113* encryption command / intricate logic about tx-only/tx+rx/...
1114** unsupported algorithm
1115* handover detection
1116* MS Power Control
1117* BS Power Control
1118* Physical Context
1119* SACCH info modify
1120* BCCH INFO (SI Broadcasting)
1121* CCCH Load Indication for PCH and RACH
1122* Delete Indication on AGCH overflow
1123* SMS Broadcast Req / Cmd / CBCH LOad Ind
1124* RF resource ind
1125* IPA/speech related commands
1126* error handling
1127* discriminator error
1128** type error
1129** sequence error
1130** IE duplicated?
Harald Welte68e495b2018-02-25 00:05:57 +01001131
1132*/
Harald Welte70767382018-02-21 12:16:40 +01001133
1134control {
1135 execute( TC_chan_act_stress() );
1136 execute( TC_chan_act_react() );
1137 execute( TC_chan_deact_not_active() );
1138 execute( TC_chan_act_wrong_nr() );
1139 execute( TC_chan_req() );
1140 execute( TC_meas_res_sign_tchf() );
1141 execute( TC_meas_res_sign_tchh() );
1142 execute( TC_meas_res_sign_sdcch4() );
1143 execute( TC_meas_res_sign_sdcch8() );
1144 execute( TC_conn_fail_crit() );
Harald Welte68e495b2018-02-25 00:05:57 +01001145 execute( TC_paging_imsi_80percent() );
1146 execute( TC_paging_tmsi_80percent() );
1147 execute( TC_paging_imsi_200percent() );
1148 execute( TC_paging_tmsi_200percent() );
Harald Welte01d982c2018-02-25 01:31:40 +01001149 execute( TC_rsl_protocol_error() );
1150 execute( TC_rsl_mand_ie_error() );
1151 execute( TC_rsl_ie_content_error() );
Harald Weltea871a382018-02-25 02:03:14 +01001152 execute( TC_ipa_dlcx_not_active() );
Harald Weltea3f1df92018-02-25 12:49:55 +01001153 execute( TC_ipa_crcx_twice_not_active() );
1154 execute( TC_ipa_crcx_mdcx_dlcx_not_active() );
Harald Welte3ae11da2018-02-25 13:36:06 +01001155 execute( TC_ipa_crcx_mdcx_mdcx_dlcx_not_active() );
Harald Welte9912eb52018-02-25 13:30:15 +01001156 execute( TC_ipa_crcx_sdcch_not_active() );
Harald Welte70767382018-02-21 12:16:40 +01001157}
1158
1159
1160}