blob: fe0a9338e618e77007d4b04c8dfe145e05623126 [file] [log] [blame]
Harald Welte70767382018-02-21 12:16:40 +01001module BTS_Tests {
2
3import from General_Types all;
4import from GSM_Types all;
5import from GSM_RR_Types all;
6import from Osmocom_Types all;
7import from GSM_Types all;
Harald Welte82ccef72018-02-25 16:17:33 +01008import from GSM_SystemInformation all;
Harald Welte70767382018-02-21 12:16:40 +01009import from L1CTL_PortType all;
10import from L1CTL_Types all;
11import from LAPDm_Types all;
12import from Osmocom_CTRL_Adapter all;
Neels Hofmeyr6a84b232018-04-03 19:12:36 +020013import from Osmocom_CTRL_Functions all;
Harald Welte70767382018-02-21 12:16:40 +010014
15import from RSL_Types all;
Harald Welte7484fc42018-02-24 14:09:45 +010016import from IPA_Types all;
Harald Welte70767382018-02-21 12:16:40 +010017import from IPA_Emulation all;
Stefan Sperling0ec1c262018-10-15 15:12:52 +020018import from IPA_Testing all;
Harald Welte70767382018-02-21 12:16:40 +010019import from RSL_Emulation all;
20
21import from IPL4asp_Types all;
22import from TRXC_Types all;
23import from TRXC_CodecPort all;
24import from TRXC_CodecPort_CtrlFunct all;
25
Harald Welte883340c2018-02-28 18:59:29 +010026import from PCUIF_Types all;
27import from PCUIF_CodecPort all;
28
Harald Welte7484fc42018-02-24 14:09:45 +010029import from MobileL3_CommonIE_Types all;
Harald Welte68e495b2018-02-25 00:05:57 +010030import from MobileL3_RRM_Types all;
31import from MobileL3_Types all;
32import from L3_Templates all;
Harald Welte7484fc42018-02-24 14:09:45 +010033
Harald Welte8da48242018-02-27 20:41:32 +010034import from Osmocom_VTY_Functions all;
35import from TELNETasp_PortType all;
36
Harald Welte70767382018-02-21 12:16:40 +010037/* The tests assume a BTS with the following timeslot configuration:
38 * TS0 : Combined CCCH + SDCCH/4
Harald Welte3d04ae62018-04-04 20:29:05 +020039 * TS1 : TCH/F
40 * TS2 : TCH/F
41 * TS3 : TCH/F_PDCH (IPA Style)
42 * TS4 : TCH/F_TCH/H_PDCH (Osmocom Style)
Harald Welte70767382018-02-21 12:16:40 +010043 * TS5 : TCH/H
44 * TS6 : SDCCH/8
45 * TS7 : PDCH
46 */
47
48modulepar {
49 charstring mp_rsl_ip := "127.0.0.2";
50 integer mp_rsl_port := 3003;
51 integer mp_trx0_arfcn := 871;
Harald Weltea4d8f352018-03-01 15:47:20 +010052 charstring mp_bb_trxc_ip := "127.0.0.1";
Harald Welteef3e1c92018-02-28 23:40:14 +010053 integer mp_bb_trxc_port := 6701;
Harald Welte883340c2018-02-28 18:59:29 +010054 charstring mp_pcu_socket := PCU_SOCK_DEFAULT;
Neels Hofmeyr6a84b232018-04-03 19:12:36 +020055 charstring mp_ctrl_ip := "127.0.0.1";
56 integer mp_ctrl_port := 4238;
Pau Espin Pedrol121724c2018-09-28 15:58:12 +020057 integer mp_tolerance_rxqual := 1;
58 integer mp_tolerance_rxlev := 3;
59 integer mp_tolerance_timing_offset_256syms := 0;
Pau Espin Pedrol752ffd52018-06-07 13:55:45 +020060 integer mp_rxlev_exp := 57;
Pau Espin Pedrole9571aa2018-10-22 17:13:07 +020061 integer mp_ul_rxlev_exp := 10;
Pau Espin Pedroled359cb2018-09-28 16:08:24 +020062 integer mp_ms_power_level_exp := 7;
Pau Espin Pedrol121724c2018-09-28 15:58:12 +020063 integer mp_ms_actual_ta_exp := 0;
64 integer mp_timing_offset_256syms_exp := 512;
Harald Welte70767382018-02-21 12:16:40 +010065}
66
Harald Welte629cc6b2018-03-11 17:19:05 +010067type record of RslChannelNr ChannelNrs;
68
Harald Welte70767382018-02-21 12:16:40 +010069type component test_CT extends CTRL_Adapter_CT {
Harald Welte68e495b2018-02-25 00:05:57 +010070 /* IPA Emulation component underneath RSL */
Harald Welte70767382018-02-21 12:16:40 +010071 var IPA_Emulation_CT vc_IPA;
Harald Welte68e495b2018-02-25 00:05:57 +010072 /* RSL Emulation component (for ConnHdlr tests) */
Harald Welte70767382018-02-21 12:16:40 +010073 var RSL_Emulation_CT vc_RSL;
Harald Welte68e495b2018-02-25 00:05:57 +010074 /* Direct RSL_CCHAN_PT */
Harald Welte70767382018-02-21 12:16:40 +010075 port RSL_CCHAN_PT RSL_CCHAN;
Harald Welte68e495b2018-02-25 00:05:57 +010076
77 /* L1CTL port (for classic tests) */
78 port L1CTL_PT L1CTL;
Harald Welte48494ca2018-02-25 16:59:50 +010079
Harald Welte54a2a2d2018-02-26 09:14:05 +010080 /* TRXC port (for classic tests) */
81 port TRXC_CODEC_PT BB_TRXC;
82 var integer g_bb_trxc_conn_id;
83
Harald Weltef50e3ae2018-09-10 10:27:56 +020084 /* VTY connections to both BTS and BSC */
Harald Welte8da48242018-02-27 20:41:32 +010085 port TELNETasp_PT BTSVTY;
Harald Weltef50e3ae2018-09-10 10:27:56 +020086 port TELNETasp_PT BSCVTY;
Harald Welte8da48242018-02-27 20:41:32 +010087
Harald Welte883340c2018-02-28 18:59:29 +010088 /* PCU Interface of BTS */
89 port PCUIF_CODEC_PT PCU;
90 var integer g_pcu_conn_id;
91 /* Last PCU INFO IND we received */
92 var PCUIF_Message g_pcu_last_info;
93
Harald Welte48494ca2018-02-25 16:59:50 +010094 /* SI configuration */
95 var SystemInformationConfig si_cfg := {
96 bcch_extended := false,
97 si1_present := false,
98 si2bis_present := false,
99 si2ter_present := false,
100 si2quater_present := false,
101 si7_present := false,
102 si8_present := false,
103 si9_present := false,
104 si13_present := false,
105 si13alt_present := false,
106 si15_present := false,
107 si16_present := false,
108 si17_present := false,
109 si2n_present := false,
110 si21_present := false,
111 si22_present := false
112 };
Harald Welte629cc6b2018-03-11 17:19:05 +0100113
114 /* all logical channels available on the BTS */
115 var ChannelNrs g_AllChannels;
Harald Welte0472ab42018-03-12 15:02:26 +0100116 var ChannelNrs g_AllChanTypes;
Harald Welte70767382018-02-21 12:16:40 +0100117}
118
119/* an individual call / channel */
120type component ConnHdlr extends RSL_DchanHdlr {
121 port L1CTL_PT L1CTL;
122
123 port TRXC_CODEC_PT BB_TRXC;
124 var integer g_bb_trxc_conn_id;
125
126 timer g_Tguard;
127 timer g_Tmeas_exp := 2.0; /* >= 103 SACCH multiframe ~ 500ms */
128
129 var ConnHdlrPars g_pars;
130 var uint8_t g_next_meas_res_nr := 0;
Harald Weltefa45e9e2018-03-10 18:59:03 +0100131 var boolean g_first_meas_res := true;
Harald Weltef26de0b2018-04-04 20:28:05 +0200132
133 /* PCU Interface of BTS */
134 port PCUIF_CODEC_PT PCU;
Harald Welte70767382018-02-21 12:16:40 +0100135}
136
137function f_init_rsl(charstring id) runs on test_CT {
138 vc_IPA := IPA_Emulation_CT.create(id & "-RSL-IPA");
139 vc_RSL := RSL_Emulation_CT.create(id & "-RSL");
140
141 map(vc_IPA:IPA_PORT, system:IPA_CODEC_PT);
142 connect(vc_IPA:IPA_RSL_PORT, vc_RSL:IPA_PT);
143 connect(self:RSL_CCHAN, vc_RSL:CCHAN_PT);
144
145 vc_IPA.start(IPA_Emulation.main_server(mp_rsl_ip, mp_rsl_port));
146 vc_RSL.start(RSL_Emulation.main(false));
147}
148
149type record ConnHdlrPars {
150 RslChannelNr chan_nr,
151 RSL_IE_ChannelMode chan_mode,
152 float t_guard,
Harald Welte0472ab42018-03-12 15:02:26 +0100153 ConnL1Pars l1_pars,
Harald Weltee613f962018-04-18 22:38:16 +0200154 TestSpecUnion spec optional,
155 RSL_IE_EncryptionInfo encr optional
Harald Welte0472ab42018-03-12 15:02:26 +0100156}
157
158/* Test-specific parameters */
159type union TestSpecUnion {
160 RllTestCase rll
Harald Welte70767382018-02-21 12:16:40 +0100161}
162
Harald Welte82ccef72018-02-25 16:17:33 +0100163template (value) RachControlParameters ts_RachCtrl_default := {
Harald Welte0fd1fb02018-03-10 17:19:50 +0100164 max_retrans := RACH_MAX_RETRANS_7,
165 tx_integer := '1001'B, /* 12 slots */
Harald Welte82ccef72018-02-25 16:17:33 +0100166 cell_barr_access := false,
167 re_not_allowed := true,
Harald Welteb9585f82018-03-10 17:18:47 +0100168 acc := '0000010000000000'B
Harald Welte82ccef72018-02-25 16:17:33 +0100169};
170
Harald Weltef10153f2018-02-25 16:34:05 +0100171template (value) CellSelectionParameters ts_CellSelPar_default := {
Harald Welte0fd1fb02018-03-10 17:19:50 +0100172 cell_resel_hyst_2dB := 2,
Pau Espin Pedroled359cb2018-09-28 16:08:24 +0200173 ms_txpwr_max_cch := mp_ms_power_level_exp,
Harald Weltef10153f2018-02-25 16:34:05 +0100174 acs := '0'B,
175 neci := true,
176 rxlev_access_min := 0
177}
178
179template (value) LocationAreaIdentification ts_LAI_default := {
180 mcc_mnc := '262F42'H,
181 lac := 42
182}
183
Harald Welte7484fc42018-02-24 14:09:45 +0100184/* Default SYSTEM INFORMATION 3 */
Harald Weltef8df4cb2018-03-10 15:15:08 +0100185template (value) SystemInformation ts_SI3_default := {
186 header := ts_RrHeader(SYSTEM_INFORMATION_TYPE_3, 18),
Harald Welte7484fc42018-02-24 14:09:45 +0100187 payload := {
188 si3 := {
189 cell_id := 23,
Harald Weltef10153f2018-02-25 16:34:05 +0100190 lai := ts_LAI_default,
Harald Welte7484fc42018-02-24 14:09:45 +0100191 ctrl_chan_desc := {
192 msc_r99 := true,
193 att := true,
194 bs_ag_blks_res := 1,
195 ccch_conf := CCHAN_DESC_1CCCH_COMBINED,
Harald Welte82ccef72018-02-25 16:17:33 +0100196 si22ind := false,
Harald Welte7484fc42018-02-24 14:09:45 +0100197 cbq3 := CBQ3_IU_MODE_NOT_SUPPORTED,
198 spare := '00'B,
199 bs_pa_mfrms := 0, /* 2 multiframes */
200 t3212 := 1 /* 6 minutes */
201 },
Harald Welte82ccef72018-02-25 16:17:33 +0100202 cell_options := {
Harald Welte7484fc42018-02-24 14:09:45 +0100203 dn_ind := false,
204 pwrc := false,
205 dtx := MS_MAY_USE_UL_DTX,
Harald Welte0fd1fb02018-03-10 17:19:50 +0100206 radio_link_tout_div4 := (32/4)-1
Harald Welte7484fc42018-02-24 14:09:45 +0100207 },
Harald Weltef10153f2018-02-25 16:34:05 +0100208 cell_sel_par := ts_CellSelPar_default,
Harald Welte82ccef72018-02-25 16:17:33 +0100209 rach_control := ts_RachCtrl_default,
Harald Welte3778acc2018-03-09 19:32:31 +0100210 rest_octets := '2B2B2B2B'O
Harald Welte7484fc42018-02-24 14:09:45 +0100211 }
212 }
213}
Harald Welte70767382018-02-21 12:16:40 +0100214
Harald Weltef8df4cb2018-03-10 15:15:08 +0100215template (value) SystemInformation ts_SI2_default := {
216 header := ts_RrHeader(SYSTEM_INFORMATION_TYPE_2, 22),
Harald Weltef10153f2018-02-25 16:34:05 +0100217 payload := {
218 si2 := {
219 bcch_freq_list := '00000000000000000000000000000000'O,
220 ncc_permitted := '11111111'B,
221 rach_control := ts_RachCtrl_default
222 }
223 }
224}
225
Harald Weltef8df4cb2018-03-10 15:15:08 +0100226template (value) SystemInformation ts_SI4_default := {
227 header := ts_RrHeader(SYSTEM_INFORMATION_TYPE_4, 12), /* no CBCH / restoct */
Harald Weltef10153f2018-02-25 16:34:05 +0100228 payload := {
229 si4 := {
230 lai := ts_LAI_default,
231 cell_sel_par := ts_CellSelPar_default,
232 rach_control := ts_RachCtrl_default,
233 cbch_chan_desc := omit,
234 cbch_mobile_alloc := omit,
235 rest_octets := ''O
236 }
237 }
238}
239
240function f_rsl_bcch_fill_raw(RSL_IE_SysinfoType rsl_si_type, octetstring si_enc)
241runs on test_CT {
242 log("Setting ", rsl_si_type, ": ", si_enc);
243 RSL_CCHAN.send(ts_RSL_UD(ts_RSL_BCCH_INFO(rsl_si_type, si_enc)));
244}
245
246function f_rsl_bcch_fill(RSL_IE_SysinfoType rsl_si_type, template (value) SystemInformation si_dec)
247runs on test_CT {
248 var octetstring si_enc := enc_SystemInformation(valueof(si_dec));
249 log("Setting ", rsl_si_type, ": ", si_dec);
250 f_rsl_bcch_fill_raw(rsl_si_type, si_enc);
251}
252
Harald Welte8da48242018-02-27 20:41:32 +0100253private function f_init_vty(charstring id) runs on test_CT {
254 map(self:BTSVTY, system:BTSVTY);
255 f_vty_set_prompts(BTSVTY);
256 f_vty_transceive(BTSVTY, "enable");
257}
258
Harald Weltef50e3ae2018-09-10 10:27:56 +0200259private function f_init_vty_bsc() runs on test_CT {
260 map(self:BSCVTY, system:BSCVTY);
261 f_vty_set_prompts(BSCVTY, "OsmoBSC");
262 f_vty_transceive(BSCVTY, "enable");
263}
264
Harald Welte883340c2018-02-28 18:59:29 +0100265/* PCU socket may at any time receive a new INFO.ind */
Harald Weltef26de0b2018-04-04 20:28:05 +0200266private altstep as_pcu_info_ind(PCUIF_CODEC_PT pt, integer pcu_conn_id,
267 out PCUIF_Message pcu_last_info) {
Harald Welte883340c2018-02-28 18:59:29 +0100268 var PCUIF_send_data sd;
Harald Weltef26de0b2018-04-04 20:28:05 +0200269 [] pt.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(0, ?))) -> value sd {
270 pcu_last_info := sd.data;
Harald Welted378a252018-03-13 17:02:14 +0100271 }
Harald Weltef26de0b2018-04-04 20:28:05 +0200272 [] pt.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(?, ?, ?))) -> value sd {
Harald Welted378a252018-03-13 17:02:14 +0100273 setverdict(fail, "Invalid PCU Version/BTS Number received");
Daniel Willmann17ddd852018-07-05 17:33:20 +0200274 mtc.stop;
Harald Welte883340c2018-02-28 18:59:29 +0100275 }
276}
277
Harald Weltef26de0b2018-04-04 20:28:05 +0200278private function f_init_pcu(PCUIF_CODEC_PT pt, charstring id,
279 out integer pcu_conn_id, out PCUIF_Message pcu_last_info) {
Harald Welte883340c2018-02-28 18:59:29 +0100280 timer T := 2.0;
281 var PCUIF_send_data sd;
Harald Welte84271622018-03-10 17:21:03 +0100282 if (mp_pcu_socket == "") {
Harald Weltef26de0b2018-04-04 20:28:05 +0200283 pcu_conn_id := -1;
Harald Welte84271622018-03-10 17:21:03 +0100284 return;
285 }
Harald Weltef26de0b2018-04-04 20:28:05 +0200286 pcu_conn_id := f_pcuif_connect(pt, mp_pcu_socket);
Harald Welte883340c2018-02-28 18:59:29 +0100287
288 T.start;
289 alt {
Harald Weltef26de0b2018-04-04 20:28:05 +0200290 [] as_pcu_info_ind(pt, pcu_conn_id, pcu_last_info);
Harald Welte883340c2018-02-28 18:59:29 +0100291 [] T.timeout {
292 setverdict(fail, "Timeout waiting for PCU INFO_IND");
Daniel Willmann17ddd852018-07-05 17:33:20 +0200293 mtc.stop;
Harald Welte883340c2018-02-28 18:59:29 +0100294 }
295 }
296}
297
Harald Welte70767382018-02-21 12:16:40 +0100298/* global init function */
Harald Welte68e495b2018-02-25 00:05:57 +0100299function f_init(charstring id := "BTS-Test") runs on test_CT {
Harald Welte83f6dbf2018-06-03 18:26:50 +0200300 timer T := 10.0;
Harald Welte629cc6b2018-03-11 17:19:05 +0100301 g_AllChannels := {
302 /* TS 1..4: TCH/F */
303 valueof(ts_RslChanNr_Bm(1)), valueof(ts_RslChanNr_Bm(2)),
304 valueof(ts_RslChanNr_Bm(3)), valueof(ts_RslChanNr_Bm(4)),
305 /* TS 5: TCH/H */
306 valueof(ts_RslChanNr_Lm(5,0)), valueof(ts_RslChanNr_Lm(5,1)),
307 /* TS 0: SDCCH/4 */
308 valueof(ts_RslChanNr_SDCCH4(0,0)), valueof(ts_RslChanNr_SDCCH4(0,1)),
309 valueof(ts_RslChanNr_SDCCH4(0,2)), valueof(ts_RslChanNr_SDCCH4(0,3)),
310 /* TS 6: SDCCH/8 */
311 valueof(ts_RslChanNr_SDCCH8(6,0)), valueof(ts_RslChanNr_SDCCH8(6,1)),
312 valueof(ts_RslChanNr_SDCCH8(6,2)), valueof(ts_RslChanNr_SDCCH8(6,3)),
313 valueof(ts_RslChanNr_SDCCH8(6,4)), valueof(ts_RslChanNr_SDCCH8(6,5)),
314 valueof(ts_RslChanNr_SDCCH8(6,6)), valueof(ts_RslChanNr_SDCCH8(6,7))
315 };
316
Pau Espin Pedrol3dcf38f2018-10-22 14:07:54 +0200317 /* FIXME: FACCH/H is unreliable with calypso firmware, see OS#3653 */
318 if (mp_bb_trxc_port != -1) {
319 g_AllChanTypes := {
320 /* TS 1..4: TCH/F */
321 valueof(ts_RslChanNr_Bm(1)),
322 /* TS 5: TCH/H */
323 valueof(ts_RslChanNr_Lm(5,1)),
324 /* TS 0: SDCCH/4 */
325 valueof(ts_RslChanNr_SDCCH4(0,2)),
326 /* TS 6: SDCCH/8 */
327 valueof(ts_RslChanNr_SDCCH8(6,4))
328 };
329 } else {
330 g_AllChanTypes := {
331 /* TS 1..4: TCH/F */
332 valueof(ts_RslChanNr_Bm(1)),
333 /* TS 0: SDCCH/4 */
334 valueof(ts_RslChanNr_SDCCH4(0,2)),
335 /* TS 6: SDCCH/8 */
336 valueof(ts_RslChanNr_SDCCH8(6,4))
337 };
338 }
Harald Welte70767382018-02-21 12:16:40 +0100339 f_init_rsl(id);
Harald Welte83f6dbf2018-06-03 18:26:50 +0200340 T.start;
341 alt {
342 [] RSL_CCHAN.receive(ASP_IPA_Event:{up_down := ASP_IPA_EVENT_UP});
343 [] T.timeout {
344 setverdict(fail, "Timeout waiting for ASP_IPA_EVENT_UP");
Daniel Willmann17ddd852018-07-05 17:33:20 +0200345 mtc.stop;
Harald Welte83f6dbf2018-06-03 18:26:50 +0200346 }
347 }
Harald Welte2d142592018-02-25 13:19:44 +0100348 f_sleep(0.5); /* workaround for OS#3000 */
Harald Welte8da48242018-02-27 20:41:32 +0100349 f_init_vty(id);
Neels Hofmeyr6a84b232018-04-03 19:12:36 +0200350 f_ipa_ctrl_start(mp_ctrl_ip, mp_ctrl_port);
Harald Welte7484fc42018-02-24 14:09:45 +0100351
352 /* Send SI3 to the BTS, it is needed for various computations */
Harald Weltef10153f2018-02-25 16:34:05 +0100353 f_rsl_bcch_fill(RSL_SYSTEM_INFO_3, ts_SI3_default);
354 /* SI2 + SI4 are required for SI testing as they are mandatory defaults */
355 f_rsl_bcch_fill(RSL_SYSTEM_INFO_2, ts_SI2_default);
356 f_rsl_bcch_fill(RSL_SYSTEM_INFO_4, ts_SI4_default);
Harald Welte57fe8232018-02-26 17:52:50 +0100357
Harald Weltef26de0b2018-04-04 20:28:05 +0200358 map(self:PCU, system:PCU);
359 f_init_pcu(PCU, id, g_pcu_conn_id, g_pcu_last_info);
Harald Welte883340c2018-02-28 18:59:29 +0100360
Harald Welte84271622018-03-10 17:21:03 +0100361 if (mp_bb_trxc_port != -1) {
362 var TrxcMessage ret;
363 /* start with a default moderate timing offset equalling TA=2 */
364 f_main_trxc_connect();
365 ret := f_TRXC_transceive(BB_TRXC, g_bb_trxc_conn_id, valueof(ts_TRXC_FAKE_TIMING(2*256)));
366 }
Harald Welte70767382018-02-21 12:16:40 +0100367}
368
Harald Welte294b0a22018-03-10 23:26:48 +0100369function f_shutdown() runs on test_CT {
Daniel Willmanncc7bbeb2018-07-03 16:33:56 +0200370 /* mtc.stop cleanly stops testcase execution to avoid unclean shutdown */
Daniel Willmannb85a6292018-07-25 22:53:32 +0200371 all component.stop;
Daniel Willmanncc7bbeb2018-07-03 16:33:56 +0200372 mtc.stop;
Harald Welte294b0a22018-03-10 23:26:48 +0100373}
374
Harald Welte68e495b2018-02-25 00:05:57 +0100375/* Attach L1CTL to master test_CT (classic tests, non-handler mode) */
376function f_init_l1ctl() runs on test_CT {
377 map(self:L1CTL, system:L1CTL);
378 f_connect_reset(L1CTL);
379}
380
Harald Welte70767382018-02-21 12:16:40 +0100381type function void_fn(charstring id) runs on ConnHdlr;
382
383/* create a new test component */
Harald Weltef26de0b2018-04-04 20:28:05 +0200384function f_start_handler(void_fn fn, ConnHdlrPars pars, boolean pcu_comp := false)
Harald Welte70767382018-02-21 12:16:40 +0100385runs on test_CT return ConnHdlr {
386 var charstring id := testcasename();
387 var ConnHdlr vc_conn;
388
389 vc_conn := ConnHdlr.create(id);
390 /* connect to RSL Emulation main component */
391 connect(vc_conn:RSL, vc_RSL:CLIENT_PT);
392 connect(vc_conn:RSL_PROC, vc_RSL:RSL_PROC);
Harald Weltef26de0b2018-04-04 20:28:05 +0200393 if (pcu_comp) {
394 /* the ConnHdlr component wants to talk directly to the PCU, so disconnect
395 * it from the test_CT and connect it to the component. This obviously only
396 * works for one component, i.e. no concurrency */
397 unmap(self:PCU, system:PCU);
398 map(vc_conn:PCU, system:PCU);
399 }
Harald Welte70767382018-02-21 12:16:40 +0100400
401 vc_conn.start(f_handler_init(fn, id, pars));
402 return vc_conn;
403}
404
Harald Welte7484fc42018-02-24 14:09:45 +0100405template ASP_RSL_Unitdata ts_RSL_UD(template RSL_Message rsl, IpaStreamId sid := IPAC_PROTO_RSL_TRX0) := {
406 streamId := sid,
407 rsl := rsl
408}
409
410template ASP_RSL_Unitdata tr_RSL_UD(template RSL_Message rsl,
411 template IpaStreamId sid := IPAC_PROTO_RSL_TRX0) := {
412 streamId := sid,
413 rsl := rsl
414}
415
Harald Welte70767382018-02-21 12:16:40 +0100416private altstep as_Tguard() runs on ConnHdlr {
417 [] g_Tguard.timeout {
418 setverdict(fail, "Tguard timeout");
Daniel Willmann17ddd852018-07-05 17:33:20 +0200419 mtc.stop;
Harald Welte70767382018-02-21 12:16:40 +0100420 }
421}
422
Harald Welte68e495b2018-02-25 00:05:57 +0100423private function f_l1_tune(L1CTL_PT L1CTL) {
Pau Espin Pedrol752ffd52018-06-07 13:55:45 +0200424 f_L1CTL_FBSB(L1CTL, { false, mp_trx0_arfcn }, CCCH_MODE_COMBINED, mp_rxlev_exp);
Harald Welte70767382018-02-21 12:16:40 +0100425}
426
427private function f_trxc_connect() runs on ConnHdlr {
428 map(self:BB_TRXC, system:BB_TRXC);
429 var Result res;
Harald Weltea4d8f352018-03-01 15:47:20 +0100430 res := TRXC_CodecPort_CtrlFunct.f_IPL4_connect(BB_TRXC, mp_bb_trxc_ip, mp_bb_trxc_port,
431 "", -1, -1, {udp:={}}, {});
Harald Welte9220f632018-05-23 20:27:02 +0200432 if (not ispresent(res.connId)) {
433 setverdict(fail, "Could not connect to trx-control interface of trxcon, check your configuration");
Daniel Willmann17ddd852018-07-05 17:33:20 +0200434 mtc.stop;
Harald Welte9220f632018-05-23 20:27:02 +0200435 }
Harald Welte70767382018-02-21 12:16:40 +0100436 g_bb_trxc_conn_id := res.connId;
437}
438
439private function f_trxc_fake_rssi(uint8_t rssi) runs on ConnHdlr {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100440 var TrxcMessage ret;
441 ret := f_TRXC_transceive(BB_TRXC, g_bb_trxc_conn_id, valueof(ts_TRXC_FAKE_RSSI(rssi)));
Harald Welte70767382018-02-21 12:16:40 +0100442}
443
444private function f_trx_fake_toffs256(int16_t toffs256) runs on ConnHdlr {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100445 var TrxcMessage ret;
446 ret := f_TRXC_transceive(BB_TRXC, g_bb_trxc_conn_id, valueof(ts_TRXC_FAKE_TIMING(toffs256)));
Harald Welte70767382018-02-21 12:16:40 +0100447}
448
449/* first function started in ConnHdlr component */
450private function f_handler_init(void_fn fn, charstring id, ConnHdlrPars pars)
451runs on ConnHdlr {
452 g_pars := pars;
453 g_chan_nr := pars.chan_nr;
454
455 map(self:L1CTL, system:L1CTL);
456 f_connect_reset(L1CTL);
457
Harald Welte84271622018-03-10 17:21:03 +0100458 if (mp_bb_trxc_port != -1) {
459 f_trxc_connect();
460 }
Harald Welte70767382018-02-21 12:16:40 +0100461
462 g_Tguard.start(pars.t_guard);
463 activate(as_Tguard());
464
465 f_rslem_register(0, pars.chan_nr);
466
467 /* call the user-supplied test case function */
468 fn.apply(id);
469}
470
Harald Welteb1726c92018-03-30 11:56:38 +0200471function f_rsl_transceive_ret(template RSL_Message tx, template RSL_Message exp_rx, charstring id,
472 boolean ignore_other := false)
473runs on ConnHdlr return RSL_Message {
474 var RSL_Message rx;
Harald Welte1eba3742018-02-25 12:48:14 +0100475 timer T := 3.0;
476 RSL.send(tx);
477 T.start;
Harald Welte70767382018-02-21 12:16:40 +0100478 alt {
Harald Welteb1726c92018-03-30 11:56:38 +0200479 [] RSL.receive(exp_rx) -> value rx {
Harald Welte1eba3742018-02-25 12:48:14 +0100480 T.stop;
481 setverdict(pass);
Harald Welte70767382018-02-21 12:16:40 +0100482 }
Harald Welte1eba3742018-02-25 12:48:14 +0100483 [] T.timeout {
484 setverdict(fail, "Timeout expecting " & id);
Daniel Willmann17ddd852018-07-05 17:33:20 +0200485 mtc.stop;
Harald Welte1eba3742018-02-25 12:48:14 +0100486 }
Harald Welte21240e62018-03-11 21:43:35 +0100487 [not ignore_other] as_l1_sacch();
488 [not ignore_other] as_meas_res();
489 [not ignore_other] as_l1_dcch();
490 [not ignore_other] RSL.receive {
Harald Welte1eba3742018-02-25 12:48:14 +0100491 setverdict(fail, "Unexpected RSL message received");
Daniel Willmann17ddd852018-07-05 17:33:20 +0200492 mtc.stop;
Harald Welte70767382018-02-21 12:16:40 +0100493 }
Harald Welte21240e62018-03-11 21:43:35 +0100494 [ignore_other] RSL.receive { repeat; }
Harald Welte70767382018-02-21 12:16:40 +0100495 }
Harald Welteb1726c92018-03-30 11:56:38 +0200496 return rx;
497}
498
499function f_rsl_transceive(template RSL_Message tx, template RSL_Message exp_rx, charstring id,
500 boolean ignore_other := false)
501runs on ConnHdlr {
502 var RSL_Message rx := f_rsl_transceive_ret(tx, exp_rx, id, ignore_other);
Harald Welte70767382018-02-21 12:16:40 +0100503}
504
Harald Weltee613f962018-04-18 22:38:16 +0200505function f_rsl_chan_act(RSL_IE_ChannelMode mode, boolean encr_enable := false)
506runs on ConnHdlr {
507 var RSL_Message ch_act := valueof(ts_RSL_CHAN_ACT(g_chan_nr, mode));
508 if (encr_enable) {
509 /* append encryption related IEs, if requested */
510 var RSL_IE_EncryptionInfo encr_info;
511 encr_info := valueof(ts_RSL_IE_EncrInfo(g_pars.encr.alg_id, g_pars.encr.key));
512 ch_act.ies := ch_act.ies & { valueof(t_RSL_IE(RSL_IE_ENCR_INFO, RSL_IE_Body:{encr_info :=
513encr_info})) };
514 }
515 f_rsl_transceive(ch_act, tr_RSL_CHAN_ACT_ACK(g_chan_nr), "RSL CHAN ACT");
Harald Welte1eba3742018-02-25 12:48:14 +0100516}
517
Harald Welte70767382018-02-21 12:16:40 +0100518function f_rsl_chan_deact() runs on ConnHdlr {
Harald Welte1eba3742018-02-25 12:48:14 +0100519 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 +0100520 "RF CHAN REL", true);
Harald Welte70767382018-02-21 12:16:40 +0100521}
522
Harald Welte70767382018-02-21 12:16:40 +0100523private template ConnHdlrPars t_Pars(template RslChannelNr chan_nr,
524 template RSL_IE_ChannelMode chan_mode,
525 float t_guard := 20.0) := {
526 chan_nr := valueof(chan_nr),
527 chan_mode := valueof(chan_mode),
528 t_guard := t_guard,
529 l1_pars := {
530 dtx_enabled := false,
Harald Welte685d5982018-02-27 20:42:05 +0100531 toa256_enabled := false,
Harald Welte70767382018-02-21 12:16:40 +0100532 meas_ul := {
533 full := {
Pau Espin Pedrole9571aa2018-10-22 17:13:07 +0200534 rxlev := mp_ul_rxlev_exp,
Harald Welte70767382018-02-21 12:16:40 +0100535 rxqual := 0
536 },
537 sub := {
Pau Espin Pedrole9571aa2018-10-22 17:13:07 +0200538 rxlev := mp_ul_rxlev_exp,
Harald Welte70767382018-02-21 12:16:40 +0100539 rxqual := 0
540 }
541 },
Pau Espin Pedrol121724c2018-09-28 15:58:12 +0200542 timing_offset_256syms := mp_timing_offset_256syms_exp,
Harald Welte70767382018-02-21 12:16:40 +0100543 bs_power_level := 0,
Pau Espin Pedroled359cb2018-09-28 16:08:24 +0200544 ms_power_level := mp_ms_power_level_exp,
Pau Espin Pedrol121724c2018-09-28 15:58:12 +0200545 ms_actual_ta := mp_ms_actual_ta_exp
Harald Welte0472ab42018-03-12 15:02:26 +0100546 },
Harald Weltee613f962018-04-18 22:38:16 +0200547 spec := omit,
548 encr := omit
Harald Welte70767382018-02-21 12:16:40 +0100549}
550
Harald Welte93640c62018-02-25 16:59:33 +0100551/***********************************************************************
552 * Channel Activation / Deactivation
553 ***********************************************************************/
554
Harald Welte70767382018-02-21 12:16:40 +0100555/* Stress test: Do 500 channel activations/deactivations in rapid succession */
556function f_TC_chan_act_stress(charstring id) runs on ConnHdlr {
557 for (var integer i := 0; i < 500; i := i+1) {
558 f_rsl_chan_act(g_pars.chan_mode);
559 f_rsl_chan_deact();
560 }
561 setverdict(pass);
562}
563testcase TC_chan_act_stress() runs on test_CT {
564 var ConnHdlr vc_conn;
565 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
566 f_init(testcasename());
567 vc_conn := f_start_handler(refers(f_TC_chan_act_stress), pars);
568 vc_conn.done;
Harald Welte294b0a22018-03-10 23:26:48 +0100569 f_shutdown();
Harald Welte70767382018-02-21 12:16:40 +0100570}
571
572/* Test if re-activation of an already active channel fails as expected */
573function f_TC_chan_act_react(charstring id) runs on ConnHdlr {
574 f_rsl_chan_act(g_pars.chan_mode);
575 /* attempt to activate the same lchan again -> expect reject */
576 RSL.send(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode));
577 alt {
578 [] RSL.receive(tr_RSL_CHAN_ACT_ACK(g_chan_nr)) {
579 setverdict(fail, "Unexpected CHAN ACT ACK on double activation");
Daniel Willmann17ddd852018-07-05 17:33:20 +0200580 mtc.stop;
Harald Welte70767382018-02-21 12:16:40 +0100581 }
582 [] RSL.receive(tr_RSL_CHAN_ACT_NACK(g_chan_nr)) {
583 setverdict(pass);
584 }
585 }
586 f_rsl_chan_deact();
587}
588testcase TC_chan_act_react() runs on test_CT {
589 var ConnHdlr vc_conn;
590 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
Harald Welte294b0a22018-03-10 23:26:48 +0100591 f_init();
Harald Welte70767382018-02-21 12:16:40 +0100592 vc_conn := f_start_handler(refers(f_TC_chan_act_react), pars);
593 vc_conn.done;
Harald Welte294b0a22018-03-10 23:26:48 +0100594 f_shutdown();
Harald Welte70767382018-02-21 12:16:40 +0100595}
596
597/* Attempt to de-activate a channel that's not active */
598function f_TC_chan_deact_not_active(charstring id) runs on ConnHdlr {
599 timer T := 3.0;
600 RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr));
601 T.start;
602 alt {
603 [] RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr)) {
604 setverdict(pass);
605 }
606 [] T.timeout {
607 setverdict(fail, "Timeout expecting RF_CHAN_REL_ACK");
Daniel Willmann17ddd852018-07-05 17:33:20 +0200608 mtc.stop;
Harald Welte70767382018-02-21 12:16:40 +0100609 }
610 }
611}
612testcase TC_chan_deact_not_active() runs on test_CT {
613 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
Harald Welte294b0a22018-03-10 23:26:48 +0100614 f_init();
Harald Welte70767382018-02-21 12:16:40 +0100615 var ConnHdlr vc_conn := f_start_handler(refers(f_TC_chan_deact_not_active), pars);
616 vc_conn.done;
Harald Welte294b0a22018-03-10 23:26:48 +0100617 f_shutdown();
Harald Welte70767382018-02-21 12:16:40 +0100618}
619
620/* attempt to activate channel with wrong RSL Channel Nr IE; expect NACK */
621function f_TC_chan_act_wrong_nr(charstring id) runs on ConnHdlr {
622 RSL.send(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode));
623 alt {
624 [] RSL.receive(tr_RSL_CHAN_ACT_ACK(g_chan_nr)) {
625 setverdict(fail, "Unexpected CHAN ACT ACK");
Daniel Willmann17ddd852018-07-05 17:33:20 +0200626 mtc.stop;
Harald Welte70767382018-02-21 12:16:40 +0100627 }
628 [] RSL.receive(tr_RSL_CHAN_ACT_NACK(g_chan_nr)) {
629 setverdict(pass);
630 }
631 }
632}
633private type record WrongChanNrCase {
634 RslChannelNr chan_nr,
635 charstring description
636}
637private type record of WrongChanNrCase WrongChanNrCases;
638private template WrongChanNrCase t_WCN(template RslChannelNr chan_nr, charstring desc) := {
639 chan_nr := chan_nr,
640 description := desc
641}
642
643testcase TC_chan_act_wrong_nr() runs on test_CT {
644 var ConnHdlr vc_conn;
645 var ConnHdlrPars pars;
646
Harald Welte294b0a22018-03-10 23:26:48 +0100647 f_init();
Harald Welte70767382018-02-21 12:16:40 +0100648
649 var WrongChanNrCases wrong := {
650 valueof(t_WCN(t_RslChanNr_RACH(0), "RACH is not a dedicated channel")),
651 valueof(t_WCN(t_RslChanNr_RACH(1), "RACH doesn't exist on timeslot")),
652 valueof(t_WCN(t_RslChanNr_BCCH(0), "BCCH is not a dedicated channel")),
653 valueof(t_WCN(t_RslChanNr_PCH_AGCH(0), "PCH/AGCH is not a dedicated channel")),
654 valueof(t_WCN(t_RslChanNr_Bm(0), "TS0 cannot be TCH/F")),
655 valueof(t_WCN(t_RslChanNr_Lm(0, 0), "TS0 cannot be TCH/H")),
656 valueof(t_WCN(t_RslChanNr_Lm(0, 1), "TS0 cannot be TCH/H")),
657 valueof(t_WCN(t_RslChanNr_PDCH(0), "TS0 cannot be PDCH")),
658 valueof(t_WCN(t_RslChanNr_SDCCH8(0, 0), "TS0 cannot be SDCCH/8")),
659 valueof(t_WCN(t_RslChanNr_SDCCH8(0, 7), "TS0 cannot be SDCCH/8")),
660 valueof(t_WCN(t_RslChanNr_SDCCH4(7, 0), "TS7 cannot be SDCCH/4")),
661 valueof(t_WCN(t_RslChanNr_SDCCH4(7, 3), "TS7 cannot be SDCCH/4")),
662 valueof(t_WCN(t_RslChanNr_Lm(1, 0), "TS1 cannot be TCH/H"))
663 };
664
665 for (var integer i := 0; i < sizeof(wrong); i := i+1) {
666 pars := valueof(t_Pars(wrong[i].chan_nr, ts_RSL_ChanMode_SIGN));
667 vc_conn := f_start_handler(refers(f_TC_chan_act_wrong_nr), pars);
668 vc_conn.done;
669 }
Harald Welte294b0a22018-03-10 23:26:48 +0100670 f_shutdown();
Harald Welte70767382018-02-21 12:16:40 +0100671}
672
Harald Weltee613f962018-04-18 22:38:16 +0200673/* execute the same callback function on a variety of logical channels */
674private function f_testmatrix_each_chan(ConnHdlrPars pars, void_fn fn) runs on test_CT {
675 var ConnHdlr vc_conn;
676 f_init(testcasename());
677
678 /* test on each of the channels we have */
679 for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i+1) {
680 pars.chan_nr := valueof(g_AllChanTypes[i]);
681
682 log(testcasename(), ": XXX Starting on ", g_AllChanTypes[i]);
683 vc_conn := f_start_handler(fn, pars);
684 vc_conn.done;
685 }
686
687 f_shutdown();
688}
689
Harald Welte93640c62018-02-25 16:59:33 +0100690/***********************************************************************
Harald Welte629cc6b2018-03-11 17:19:05 +0100691 * SACCH handling
692 ***********************************************************************/
693
694private function f_exp_sacch(boolean exp) runs on ConnHdlr {
695 timer T_sacch := 3.0;
696 T_sacch.start;
697 alt {
698 [not exp] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) {
699 setverdict(fail, "Received SACCH when not expecting it");
Daniel Willmann17ddd852018-07-05 17:33:20 +0200700 mtc.stop;
Harald Welte629cc6b2018-03-11 17:19:05 +0100701 }
702 [not exp] T_sacch.timeout {
703 setverdict(pass);
704 }
705 [exp] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) {
706 setverdict(pass);
707 }
708 [exp] T_sacch.timeout {
709 setverdict(fail, "Timeout waiting for SACCH on ", g_chan_nr);
Daniel Willmann17ddd852018-07-05 17:33:20 +0200710 mtc.stop;
Harald Welte629cc6b2018-03-11 17:19:05 +0100711 }
712 [] L1CTL.receive { repeat; }
713 [] RSL.receive { repeat; }
714 }
715}
716
717/* Test if DEACTIVATE SACCH actualy deactivates its transmission (TS 48.058 4.6) */
718private function f_TC_deact_sacch(charstring id) runs on ConnHdlr {
719 f_l1_tune(L1CTL);
720 RSL.clear;
721
722 /* activate the logical channel */
723 f_est_dchan();
724 L1CTL.clear;
725
726 /* check that SACCH actually are received as expected */
727 f_exp_sacch(true);
728
729 /* deactivate SACCH on the logical channel */
730 RSL.send(ts_RSL_DEACT_SACCH(g_chan_nr));
731 f_sleep(1.0);
732 L1CTL.clear;
733
734 /* check that no SACCH are received anymore */
735 f_exp_sacch(false);
736
737 /* release the channel */
738 f_rsl_chan_deact();
739 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
740}
741testcase TC_deact_sacch() runs on test_CT {
742 var ConnHdlr vc_conn;
743 var ConnHdlrPars pars;
744 f_init();
745 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
746 //for (var integer i := 0; i < 1; i := i+1) {
747 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
748 log(testcasename(), ": Starting for ", g_AllChannels[i]);
749 vc_conn := f_start_handler(refers(f_TC_deact_sacch), pars);
750 vc_conn.done;
751 }
752 /* TODO: do the above in parallel, rather than sequentially? */
753 f_shutdown();
754}
755
Harald Welte55700662018-03-12 13:15:43 +0100756/* verify that given SACCH payload is present */
Harald Welteea17b912018-03-11 22:29:31 +0100757private function f_sacch_present(template octetstring l3_exp) runs on ConnHdlr {
758 var L1ctlDlMessage dl;
759 /* check that the specified SI5 value is actually sent */
760 timer T_sacch := 3.0;
761 L1CTL.clear;
762 T_sacch.start;
763 alt {
764 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) -> value dl {
765 var octetstring l3 := substr(dl.payload.data_ind.payload, 4, 19);
766 if (match(l3, l3_exp)) {
767 setverdict(pass);
768 } else {
769 repeat;
770 }
771 }
772 [] L1CTL.receive { repeat; }
773 [] T_sacch.timeout {
774 setverdict(fail, "Timeout waiting for SACCH ", l3_exp);
Daniel Willmann17ddd852018-07-05 17:33:20 +0200775 mtc.stop;
Harald Welteea17b912018-03-11 22:29:31 +0100776 }
777 }
778}
779
Harald Welte55700662018-03-12 13:15:43 +0100780/* verify that given SACCH payload is not present */
781private function f_sacch_missing(template octetstring l3_exp) runs on ConnHdlr {
782 var L1ctlDlMessage dl;
783 /* check that the specified SI5 value is actually sent */
784 timer T_sacch := 3.0;
785 L1CTL.clear;
786 T_sacch.start;
787 alt {
788 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) -> value dl {
789 var octetstring l3 := substr(dl.payload.data_ind.payload, 4, 19);
790 if (match(l3, l3_exp)) {
791 setverdict(fail, "Received unexpected SACCH ", dl);
Daniel Willmann3487a852018-07-05 15:41:59 +0200792 mtc.stop;
Harald Welte55700662018-03-12 13:15:43 +0100793 } else {
794 repeat;
795 }
796 }
797 [] L1CTL.receive { repeat; }
798 [] T_sacch.timeout {
799 setverdict(pass);
800 }
801 }
802}
803
Harald Welte629cc6b2018-03-11 17:19:05 +0100804/* Test for default SACCH FILL transmitted in DL SACCH (all channel types) */
Harald Welteea17b912018-03-11 22:29:31 +0100805private function f_TC_sacch_filling(charstring id) runs on ConnHdlr {
806 /* Set a known default SACCH filling for SI5 */
807 var octetstring si5 := f_rnd_octstring(19);
808 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5));
809
810 f_l1_tune(L1CTL);
811 RSL.clear;
812
813 /* activate the logical channel */
814 f_est_dchan();
815
816 /* check that the specified SI5 value is actually sent */
817 f_sacch_present(si5);
818
819 /* release the channel */
820 RSL.clear;
821 f_rsl_chan_deact();
822 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
823}
824testcase TC_sacch_filling() runs on test_CT {
825 var ConnHdlr vc_conn;
826 var ConnHdlrPars pars;
827 f_init();
828 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
829 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
830 log(testcasename(), ": Starting for ", g_AllChannels[i]);
831 vc_conn := f_start_handler(refers(f_TC_sacch_filling), pars);
832 vc_conn.done;
833 }
834 /* TODO: do the above in parallel, rather than sequentially? */
835 f_shutdown();
836}
837
Harald Welte629cc6b2018-03-11 17:19:05 +0100838/* Test for lchan-specific SACCH INFO MODIFY (TS 48.058 4.12) */
Harald Welteea17b912018-03-11 22:29:31 +0100839private function f_TC_sacch_info_mod(charstring id) runs on ConnHdlr {
840 /* Set a known default SACCH filling for SI5 */
841 var octetstring si5 := f_rnd_octstring(19);
842 var octetstring si5_diff := f_rnd_octstring(19);
843 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5));
844
845 f_l1_tune(L1CTL);
846 RSL.clear;
847
848 log("Activating channel, expecting standard SI5");
849 /* activate the logical channel */
850 f_est_dchan();
851 /* check that the specified SI5 value is actually sent */
852 f_sacch_present(si5);
853
854 /* set channel-specific different SI5 */
855 log("Setting channel specific SACCH INFO, expecting it");
856 RSL.send(ts_RSL_SACCH_INF_MOD(g_chan_nr, RSL_SYSTEM_INFO_5, si5_diff))
857 /* check that the specified lchan-specific value is now used */
858 f_sacch_present(si5_diff);
859
860 /* deactivate the channel and re-activate it, this should result in default SI5 */
861 log("De-activating and re-activating channel, expecting standard SI5");
862 f_rsl_chan_deact();
863 f_rsl_chan_act(valueof(ts_RSL_ChanMode_SIGN));
864 /* Verify that the TRX-wide default SACCH filling is present again */
865 f_sacch_present(si5);
866
867 /* release the channel */
868 RSL.clear;
869 f_rsl_chan_deact();
870 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
871}
872testcase TC_sacch_info_mod() runs on test_CT {
873 var ConnHdlr vc_conn;
874 var ConnHdlrPars pars;
875 f_init();
876 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
877 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
878 log(testcasename(), ": Starting for ", g_AllChannels[i]);
879 vc_conn := f_start_handler(refers(f_TC_sacch_info_mod), pars);
880 vc_conn.done;
881 }
882 /* TODO: do the above in parallel, rather than sequentially? */
883 f_shutdown();
884}
885
Harald Welte075d84c2018-03-12 13:07:24 +0100886/* Test SACCH scheduling of multiple different SI message types */
887private function f_TC_sacch_multi(charstring id) runs on ConnHdlr {
888 var octetstring si5 := f_rnd_octstring(19);
889 var octetstring si5bis := f_rnd_octstring(19);
890 var octetstring si5ter := f_rnd_octstring(19);
891 var octetstring si6 := f_rnd_octstring(19);
892
893 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5));
894 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5bis, si5bis));
895 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5ter, si5ter));
896 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, si6));
897
898 f_l1_tune(L1CTL);
899 RSL.clear;
900
901 /* activate the logical channel */
902 f_est_dchan();
903 L1CTL.clear;
904
905 /* check that SACCH actually are received as expected */
906 f_sacch_present(si5);
907 f_sacch_present(si5bis);
908 f_sacch_present(si5ter);
909 f_sacch_present(si6);
910
911 /* release the channel */
912 f_rsl_chan_deact();
913 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
914}
915testcase TC_sacch_multi() runs on test_CT {
916 var ConnHdlr vc_conn;
917 var ConnHdlrPars pars;
918 f_init();
919 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
920 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
921 log(testcasename(), ": Starting for ", g_AllChannels[i]);
922 vc_conn := f_start_handler(refers(f_TC_sacch_multi), pars);
923 vc_conn.done;
924 }
925 /* TODO: do the above in parallel, rather than sequentially? */
926 f_shutdown();
927}
928
Harald Welte55700662018-03-12 13:15:43 +0100929/* Test if SACH information is modified as expected */
930private function f_TC_sacch_multi_chg(charstring id) runs on ConnHdlr {
931 var octetstring si5 := f_rnd_octstring(19);
932 var octetstring si6 := f_rnd_octstring(19);
933
934 /* First, configure both SI5 and SI6 to be transmitted */
935 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5));
936 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, si6));
937
938 f_l1_tune(L1CTL);
939 RSL.clear;
940
941 /* activate the logical channel */
942 f_est_dchan();
943 L1CTL.clear;
944
945 /* check that SACCH actually are received as expected */
946 f_sacch_present(si5);
947 f_sacch_present(si6);
948
949 /* disable SI6 */
950 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, ''O));
951
952 /* check that SI5 is still transmitted */
953 f_sacch_present(si5);
954 /* check if SI6 is now gone */
955 f_sacch_missing(si6);
956
957 /* release the channel */
958 f_rsl_chan_deact();
959 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
960}
961testcase TC_sacch_multi_chg() runs on test_CT {
962 var ConnHdlr vc_conn;
963 var ConnHdlrPars pars;
964 f_init();
965 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
966 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
967 log(testcasename(), ": Starting for ", g_AllChannels[i]);
968 vc_conn := f_start_handler(refers(f_TC_sacch_multi_chg), pars);
969 vc_conn.done;
970 }
971 /* TODO: do the above in parallel, rather than sequentially? */
972 f_shutdown();
973}
974
Harald Welte075d84c2018-03-12 13:07:24 +0100975/* TODO: Test for SACCH information present in RSL CHAN ACT (overrides FILLING) */
976/* TODO: Test for SACCH transmission rules in the context of special CHAN ACT (HO) */
Harald Welte629cc6b2018-03-11 17:19:05 +0100977
978
979/***********************************************************************
Harald Welte93640c62018-02-25 16:59:33 +0100980 * RACH Handling
981 ***********************************************************************/
982
Harald Welte8c24c2b2018-02-26 08:31:31 +0100983/* like L1SAP_IS_PACKET_RACH */
984private function ra_is_ps(OCT1 ra) return boolean {
Harald Welte56c05802018-02-28 21:39:35 +0100985 if ((ra and4b 'F0'O == '70'O) and (ra and4b '0F'O != '0F'O)) {
Harald Welte8c24c2b2018-02-26 08:31:31 +0100986 return true;
987 }
988 return false;
989}
990
991/* generate a random RACH for circuit-switched */
992private function f_rnd_ra_cs() return OCT1 {
993 var OCT1 ra;
994 do {
995 ra := f_rnd_octstring(1);
996 } while (ra_is_ps(ra));
997 return ra;
998}
999
Harald Welte883340c2018-02-28 18:59:29 +01001000/* generate a random RACH for packet-switched */
1001private function f_rnd_ra_ps() return OCT1 {
1002 var OCT1 ra;
1003 do {
1004 ra := f_rnd_octstring(1);
1005 } while (not ra_is_ps(ra));
1006 return ra;
1007}
1008
Harald Welte8c24c2b2018-02-26 08:31:31 +01001009/* Send 1000 RACH requests and check their RA+FN on the RSL side */
1010testcase TC_rach_content() runs on test_CT {
1011 f_init(testcasename());
1012 f_init_l1ctl();
Harald Welte68e495b2018-02-25 00:05:57 +01001013 f_l1_tune(L1CTL);
Harald Welte70767382018-02-21 12:16:40 +01001014
Harald Welte8c24c2b2018-02-26 08:31:31 +01001015 var GsmFrameNumber fn_last := 0;
1016 for (var integer i := 0; i < 1000; i := i+1) {
1017 var OCT1 ra := f_rnd_ra_cs();
1018 var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra));
1019 if (fn == fn_last) {
1020 setverdict(fail, "Two RACH in same FN?!?");
Daniel Willmann17ddd852018-07-05 17:33:20 +02001021 mtc.stop;
Harald Welte8c24c2b2018-02-26 08:31:31 +01001022 }
1023 fn_last := fn;
1024
1025 timer T := 5.0;
Harald Welte56c05802018-02-28 21:39:35 +01001026 T.start;
Harald Welte8c24c2b2018-02-26 08:31:31 +01001027 alt {
1028 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_CHAN_RQD(ra, fn, ?))) {
1029 T.stop;
1030 }
1031 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_CHAN_RQD(?, ?, ?))) {
1032 setverdict(fail, "Unexpected CHAN RQD");
Daniel Willmann17ddd852018-07-05 17:33:20 +02001033 mtc.stop;
Harald Welte8c24c2b2018-02-26 08:31:31 +01001034 }
1035 [] RSL_CCHAN.receive { repeat; }
1036 [] T.timeout {
1037 setverdict(fail, "Timeout waiting for CHAN RQD");
Daniel Willmann17ddd852018-07-05 17:33:20 +02001038 mtc.stop;
Harald Welte8c24c2b2018-02-26 08:31:31 +01001039 }
1040 }
1041 }
1042 setverdict(pass);
Harald Welte294b0a22018-03-10 23:26:48 +01001043 f_shutdown();
Harald Welte70767382018-02-21 12:16:40 +01001044}
Harald Welte8c24c2b2018-02-26 08:31:31 +01001045
1046/* Send 1000 RACH Requests (flood ~ 89/s) and count if count(Abis) == count(Um) */
1047testcase TC_rach_count() runs on test_CT {
Harald Welte294b0a22018-03-10 23:26:48 +01001048 f_init();
Harald Welte8c24c2b2018-02-26 08:31:31 +01001049 f_init_l1ctl();
Harald Welte294b0a22018-03-10 23:26:48 +01001050 f_sleep(1.0);
Harald Welte8c24c2b2018-02-26 08:31:31 +01001051 f_l1_tune(L1CTL);
1052
1053 var GsmFrameNumber fn_last := 0;
1054 for (var integer i := 0; i < 1000; i := i+1) {
1055 var OCT1 ra := f_rnd_ra_cs();
1056 var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra));
1057 if (fn == fn_last) {
1058 setverdict(fail, "Two RACH in same FN?!?");
Daniel Willmann17ddd852018-07-05 17:33:20 +02001059 mtc.stop;
Harald Welte8c24c2b2018-02-26 08:31:31 +01001060 }
1061 fn_last := fn;
1062 }
1063 var integer rsl_chrqd := 0;
1064 timer T := 3.0;
Harald Welte56c05802018-02-28 21:39:35 +01001065 T.start;
Harald Welte8c24c2b2018-02-26 08:31:31 +01001066 alt {
1067 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_CHAN_RQD(?,?))) {
1068 rsl_chrqd := rsl_chrqd + 1;
Harald Weltec3a3f452018-02-26 17:37:47 +01001069 f_timer_safe_restart(T);
Harald Welte8c24c2b2018-02-26 08:31:31 +01001070 repeat;
1071 }
1072 [] RSL_CCHAN.receive { repeat; }
1073 [] T.timeout { }
1074 }
1075 if (rsl_chrqd == 1000) {
1076 setverdict(pass);
1077 } else {
1078 setverdict(fail, "Received only ", rsl_chrqd, " out of 1000 RACH");
1079 }
Harald Welte294b0a22018-03-10 23:26:48 +01001080 f_shutdown();
Harald Welte70767382018-02-21 12:16:40 +01001081}
1082
Harald Welte54a2a2d2018-02-26 09:14:05 +01001083private function f_main_trxc_connect() runs on test_CT {
1084 map(self:BB_TRXC, system:BB_TRXC);
1085 var Result res;
Harald Welted3a88a62018-03-01 16:04:52 +01001086 res := TRXC_CodecPort_CtrlFunct.f_IPL4_connect(BB_TRXC, mp_bb_trxc_ip, mp_bb_trxc_port,
1087 "", -1, -1, {udp:={}}, {});
Harald Welte9220f632018-05-23 20:27:02 +02001088 if (not ispresent(res.connId)) {
1089 setverdict(fail, "Could not connect to trx-control interface of trxcon, check your configuration");
Daniel Willmann17ddd852018-07-05 17:33:20 +02001090 mtc.stop;
Harald Welte9220f632018-05-23 20:27:02 +02001091 }
Harald Welte54a2a2d2018-02-26 09:14:05 +01001092 g_bb_trxc_conn_id := res.connId;
1093}
1094
1095private function f_rach_toffs(int16_t toffs256, boolean expect_pass) runs on test_CT {
Harald Weltef8df4cb2018-03-10 15:15:08 +01001096 var TrxcMessage ret;
Harald Welte54a2a2d2018-02-26 09:14:05 +01001097 /* tell fake_trx to use a given timing offset for all bursts */
Harald Weltef8df4cb2018-03-10 15:15:08 +01001098 ret := f_TRXC_transceive(BB_TRXC, g_bb_trxc_conn_id, valueof(ts_TRXC_FAKE_TIMING(toffs256)));
Harald Welte54a2a2d2018-02-26 09:14:05 +01001099 f_sleep(0.5);
1100
1101 /* Transmit RACH request + wait for confirmation */
1102 var OCT1 ra := f_rnd_ra_cs();
1103 var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra));
1104
1105 /* Check for expected result */
1106 timer T := 1.5;
1107 T.start;
1108 alt {
1109 [expect_pass] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_CHAN_RQD(ra, fn))) {
1110 setverdict(pass);
1111 }
1112 [not expect_pass] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_CHAN_RQD(ra, fn))) {
Harald Welteb3e30942018-03-02 10:33:42 +01001113 setverdict(fail, "RACH passed but was expected to be dropped: ", toffs256);
Daniel Willmann17ddd852018-07-05 17:33:20 +02001114 mtc.stop;
Harald Welte54a2a2d2018-02-26 09:14:05 +01001115 }
1116 [] RSL_CCHAN.receive { repeat; }
1117 [not expect_pass] T.timeout {
1118 setverdict(pass);
1119 }
1120 [expect_pass] T.timeout {
1121 setverdict(fail, "Timeout waiting for CHAN RQD");
Daniel Willmann17ddd852018-07-05 17:33:20 +02001122 mtc.stop;
Harald Welte54a2a2d2018-02-26 09:14:05 +01001123 }
1124 }
1125}
1126
1127/* Test if dropping of RACH Based on NM_ATT_MAX_TA works */
1128testcase TC_rach_max_ta() runs on test_CT {
1129 f_init(testcasename());
1130 f_init_l1ctl();
1131 f_l1_tune(L1CTL);
Harald Welte54a2a2d2018-02-26 09:14:05 +01001132 f_sleep(1.0);
1133
1134 /* default max-ta is 63 (full range of GSM timing advance */
1135
Vadim Yanitskiyc81d6e42018-03-05 22:39:01 +07001136 /* We allow early arrival up to 2 symbols */
1137 f_rach_toffs(-1*256, true);
1138 f_rach_toffs(-2*256, true);
Harald Welte54a2a2d2018-02-26 09:14:05 +01001139 f_rach_toffs(-10*256, false);
1140
1141 /* 0 / 32 / 63 bits is legal / permitted */
1142 f_rach_toffs(0, true);
1143 f_rach_toffs(32*256, true);
1144 f_rach_toffs(63*256, true);
1145
1146 /* more than 63 bits is not legal / permitted */
1147 f_rach_toffs(64*256, false);
1148 f_rach_toffs(127*256, false);
Harald Welte294b0a22018-03-10 23:26:48 +01001149 f_shutdown();
Harald Welte54a2a2d2018-02-26 09:14:05 +01001150}
Harald Welte8c24c2b2018-02-26 08:31:31 +01001151
Harald Welte93640c62018-02-25 16:59:33 +01001152/***********************************************************************
1153 * Measurement Processing / Reporting
1154 ***********************************************************************/
1155
Harald Welte70767382018-02-21 12:16:40 +01001156template LapdmAddressField ts_LapdmAddr(LapdmSapi sapi, boolean c_r) := {
1157 spare := '0'B,
1158 lpd := 0,
1159 sapi := sapi,
1160 c_r := c_r,
1161 ea := true
1162}
1163
Harald Welted879bd92018-03-12 15:01:23 +01001164template LapdmFrameAB ts_LAPDm_AB(LapdmSapi sapi, boolean c_r, boolean p, octetstring pl) := {
Harald Welte70767382018-02-21 12:16:40 +01001165 addr := ts_LapdmAddr(sapi, c_r),
Harald Welted879bd92018-03-12 15:01:23 +01001166 ctrl := ts_LapdmCtrlUI(p),
Harald Welte70767382018-02-21 12:16:40 +01001167 len := 0, /* overwritten */
1168 m := false,
1169 el := 1,
1170 payload := pl
1171}
1172
1173/* handle incoming downlink SACCH and respond with uplink SACCH (meas res) */
1174altstep as_l1_sacch() runs on ConnHdlr {
1175 var L1ctlDlMessage l1_dl;
Harald Weltef8df4cb2018-03-10 15:15:08 +01001176 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl {
Harald Welte70767382018-02-21 12:16:40 +01001177 log("SACCH received: ", l1_dl.payload.data_ind.payload);
Pau Espin Pedrole9571aa2018-10-22 17:13:07 +02001178 var GsmRrL3Message meas_rep := valueof(ts_MEAS_REP(true, mp_rxlev_exp, mp_rxlev_exp, 0, 0, omit));
Harald Welted879bd92018-03-12 15:01:23 +01001179 var LapdmFrameAB lb := valueof(ts_LAPDm_AB(0, false, false, enc_GsmRrL3Message(meas_rep)));
Harald Welte70767382018-02-21 12:16:40 +01001180 log("LAPDm: ", lb);
Pau Espin Pedroled359cb2018-09-28 16:08:24 +02001181
1182 var L1ctlDataReq data_req := {
1183 l1header := valueof(ts_SacchL1Header(g_pars.l1_pars.ms_power_level, false, g_pars.l1_pars.ms_actual_ta)),
1184 l2_payload := f_pad_oct(enc_LapdmFrameAB(lb), 21, '2B'O)
1185 }
1186 log("Sending Measurement Report: ", data_req);
1187 L1CTL.send(ts_L1CTL_DATA_REQ_SACCH(g_chan_nr, ts_RslLinkID_SACCH(0), data_req));
Harald Welte70767382018-02-21 12:16:40 +01001188 repeat;
1189 }
1190}
1191
1192altstep as_l1_dcch() runs on ConnHdlr {
1193 var L1ctlDlMessage l1_dl;
Harald Weltef8df4cb2018-03-10 15:15:08 +01001194 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_DCCH(?))) -> value l1_dl {
Harald Welte70767382018-02-21 12:16:40 +01001195 log("DCCH received: ", l1_dl.payload.data_ind.payload);
1196 var octetstring pl := '010301'O;
Vadim Yanitskiy31e7c672018-07-27 02:23:16 +07001197 L1CTL.send(ts_L1CTL_DATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0),
1198 f_pad_oct(pl, 23, '2B'O)));
Harald Welte70767382018-02-21 12:16:40 +01001199 repeat;
1200 }
1201}
1202
1203type record MeasElem {
1204 uint6_t rxlev,
1205 uint3_t rxqual
1206}
1207
1208type record MeasElemFS {
1209 MeasElem full,
1210 MeasElem sub
1211}
1212
1213type record ConnL1Pars {
1214 boolean dtx_enabled,
Harald Welte685d5982018-02-27 20:42:05 +01001215 boolean toa256_enabled,
Harald Welte70767382018-02-21 12:16:40 +01001216 MeasElemFS meas_ul,
1217 int16_t timing_offset_256syms,
1218 uint5_t bs_power_level,
1219 uint5_t ms_power_level,
1220 uint8_t ms_actual_ta
1221}
1222
1223/* Convert tiing offset from 1/256th symbol to RSL Timing Offset */
1224private function toffs256s_to_rsl(int16_t toffs256s) return uint8_t {
1225 return 63 + (toffs256s/256);
1226}
1227
Harald Welted5684392018-03-10 18:22:04 +01001228private function f_max(integer a, integer b) return integer {
1229 if (a > b) {
1230 return a;
1231 } else {
1232 return b;
1233 }
1234}
1235
1236private function f_min(integer a, integer b) return integer {
1237 if (a < b) {
1238 return a;
1239 } else {
1240 return b;
1241 }
1242}
1243
1244/* compute negative tolerance val-tolerance, ensure >= min */
1245private function f_tolerance_neg(integer val, integer min, integer tolerance) return integer {
1246 val := val - tolerance;
1247 return f_max(val, min);
1248}
1249
1250/* compute positive tolerance val+tolerance, ensure <= max */
1251private function f_tolerance_pos(integer val, integer max, integer tolerance) return integer {
1252 val := val + tolerance;
1253 return f_min(val, max);
1254}
1255
1256/* return a template of (val-tolerance .. val+tolerance) ensuring it is within (min .. max) */
1257private function f_tolerance(integer val, integer min, integer max, integer tolerance)
1258return template integer {
1259 var template integer ret;
1260 ret := (f_tolerance_neg(val, min, tolerance) .. f_tolerance_pos(val, max, tolerance));
1261 return ret;
1262}
1263
1264
Harald Welte70767382018-02-21 12:16:40 +01001265/* build a template for matching measurement results against */
1266private function f_build_meas_res_tmpl() runs on ConnHdlr return template RSL_Message {
1267 var ConnL1Pars l1p := g_pars.l1_pars;
1268 var template RSL_IE_UplinkMeas ul_meas := {
1269 len := 3,
1270 rfu := '0'B,
1271 dtx_d := l1p.dtx_enabled,
Harald Welted5684392018-03-10 18:22:04 +01001272 rxlev_f_u := f_tolerance(l1p.meas_ul.full.rxlev, 0, 63, mp_tolerance_rxlev),
Harald Welte70767382018-02-21 12:16:40 +01001273 reserved1 := '00'B,
Harald Welted5684392018-03-10 18:22:04 +01001274 rxlev_s_u := f_tolerance(l1p.meas_ul.sub.rxlev, 0, 63, mp_tolerance_rxlev),
Harald Welte70767382018-02-21 12:16:40 +01001275 reserved2 := '00'B,
Harald Welted5684392018-03-10 18:22:04 +01001276 rxq_f_u := f_tolerance(l1p.meas_ul.full.rxqual, 0, 7, mp_tolerance_rxqual),
1277 rxq_s_u := f_tolerance(l1p.meas_ul.sub.rxqual, 0, 7, mp_tolerance_rxqual),
Harald Welte70767382018-02-21 12:16:40 +01001278 supp_meas_info := omit
1279 };
Harald Welte685d5982018-02-27 20:42:05 +01001280 if (l1p.toa256_enabled) {
Harald Welte15de8ba2018-06-29 08:51:42 +02001281 ul_meas.len := (3+8);
1282 ul_meas.supp_meas_info := {
Pau Espin Pedrol121724c2018-09-28 15:58:12 +02001283 toa256_mean := f_tolerance(l1p.timing_offset_256syms, -63*256, 192*256, mp_tolerance_timing_offset_256syms),
Harald Welte15de8ba2018-06-29 08:51:42 +02001284 toa256_min := ?,
1285 toa256_max := ?,
1286 toa256_std_dev := ?
1287 }
Harald Welte685d5982018-02-27 20:42:05 +01001288 }
Harald Welte70767382018-02-21 12:16:40 +01001289 var template RSL_IE_BS_Power bs_power := {
1290 reserved := 0,
1291 epc := false,
1292 fpc := false,
1293 power_level := l1p.bs_power_level
1294 };
1295 var template RSL_IE_L1Info l1_info := {
1296 ms_power_lvl := l1p.ms_power_level,
1297 fpc := false,
1298 reserved := 0,
Pau Espin Pedrol121724c2018-09-28 15:58:12 +02001299 actual_ta := f_tolerance(l1p.ms_actual_ta, 0, 63, mp_tolerance_timing_offset_256syms/256)
Harald Welte70767382018-02-21 12:16:40 +01001300 };
1301 var uint8_t offs := toffs256s_to_rsl(l1p.timing_offset_256syms);
Pau Espin Pedrol121724c2018-09-28 15:58:12 +02001302 var template uint8_t t_toffs := f_tolerance(offs, 0, 255, mp_tolerance_timing_offset_256syms/256);
Harald Welte70767382018-02-21 12:16:40 +01001303 return tr_RSL_MEAS_RES_OSMO(g_chan_nr, g_next_meas_res_nr, ul_meas, bs_power, l1_info,
1304 ?, t_toffs);
1305}
1306
1307/* verify we regularly receive measurement reports with incrementing numbers */
Vadim Yanitskiy41baf002018-10-04 17:44:50 +07001308altstep as_meas_res(boolean verify_meas := true) runs on ConnHdlr {
Harald Welte70767382018-02-21 12:16:40 +01001309 var RSL_Message rsl;
Vadim Yanitskiy41baf002018-10-04 17:44:50 +07001310 [not verify_meas] RSL.receive(tr_RSL_MEAS_RES(?)) { repeat; }
Harald Welte70767382018-02-21 12:16:40 +01001311 [] RSL.receive(f_build_meas_res_tmpl()) -> value rsl {
1312 /* increment counter of next to-be-expected meas rep */
1313 g_next_meas_res_nr := (g_next_meas_res_nr + 1) mod 256;
1314 /* Re-start the timer expecting the next MEAS RES */
Harald Weltec3a3f452018-02-26 17:37:47 +01001315 f_timer_safe_restart(g_Tmeas_exp);
Harald Welte70767382018-02-21 12:16:40 +01001316 repeat;
1317 }
1318 [] RSL.receive(tr_RSL_MEAS_RES(g_chan_nr, g_next_meas_res_nr)) -> value rsl {
Harald Weltefa45e9e2018-03-10 18:59:03 +01001319 /* increment counter of next to-be-expected meas rep */
1320 g_next_meas_res_nr := (g_next_meas_res_nr + 1) mod 256;
1321 if (g_first_meas_res) {
1322 g_first_meas_res := false;
1323 repeat;
1324 } else {
1325 setverdict(fail, "Received unspecific MEAS RES ", rsl);
Daniel Willmann17ddd852018-07-05 17:33:20 +02001326 mtc.stop;
Harald Weltefa45e9e2018-03-10 18:59:03 +01001327 }
Harald Welte70767382018-02-21 12:16:40 +01001328 }
1329 [] RSL.receive(tr_RSL_MEAS_RES(?)) -> value rsl {
1330 setverdict(fail, "Received unexpected MEAS RES ", rsl);
Daniel Willmann17ddd852018-07-05 17:33:20 +02001331 mtc.stop;
Harald Welte70767382018-02-21 12:16:40 +01001332 }
Pau Espin Pedrol425b62f2018-07-06 16:11:43 +02001333 [g_Tmeas_exp.running] g_Tmeas_exp.timeout {
Harald Welte70767382018-02-21 12:16:40 +01001334 setverdict(fail, "Didn't receive expected measurement result")
Daniel Willmann17ddd852018-07-05 17:33:20 +02001335 mtc.stop;
Harald Welte70767382018-02-21 12:16:40 +01001336 }
1337}
1338
Harald Weltee613f962018-04-18 22:38:16 +02001339private function f_alg_id_to_l1ctl(RSL_AlgId rsl_alg_id) return uint8_t {
1340 select (rsl_alg_id) {
1341 case (RSL_ALG_ID_A5_0) { return 0; }
1342 case (RSL_ALG_ID_A5_1) { return 1; }
1343 case (RSL_ALG_ID_A5_2) { return 2; }
1344 case (RSL_ALG_ID_A5_3) { return 3; }
1345 case (RSL_ALG_ID_A5_4) { return 4; }
1346 case (RSL_ALG_ID_A5_5) { return 5; }
1347 case (RSL_ALG_ID_A5_6) { return 6; }
1348 case (RSL_ALG_ID_A5_7) { return 7; }
1349 case else {
1350 setverdict(fail, "Unknwon Algorithm ID");
Daniel Willmann17ddd852018-07-05 17:33:20 +02001351 mtc.stop;
Harald Weltee613f962018-04-18 22:38:16 +02001352 }
1353 }
1354}
1355
1356private function f_alg_id_to_l3(RSL_AlgId rsl_alg_id) return BIT3 {
1357 select (rsl_alg_id) {
1358 case (RSL_ALG_ID_A5_1) { return '000'B; }
1359 case (RSL_ALG_ID_A5_2) { return '001'B; }
1360 case (RSL_ALG_ID_A5_3) { return '010'B; }
1361 case (RSL_ALG_ID_A5_4) { return '011'B; }
1362 case (RSL_ALG_ID_A5_5) { return '100'B; }
1363 case (RSL_ALG_ID_A5_6) { return '101'B; }
1364 case (RSL_ALG_ID_A5_7) { return '110'B; }
1365 case else {
1366 setverdict(fail, "Unknwon Algorithm ID");
Daniel Willmann17ddd852018-07-05 17:33:20 +02001367 mtc.stop;
Harald Weltee613f962018-04-18 22:38:16 +02001368 }
1369 }
1370}
1371
1372
Harald Welte70767382018-02-21 12:16:40 +01001373/* Establish dedicated channel: L1CTL + RSL side */
Harald Weltee613f962018-04-18 22:38:16 +02001374private function f_est_dchan(boolean encr_enable := false) runs on ConnHdlr {
Harald Welte70767382018-02-21 12:16:40 +01001375 var GsmFrameNumber fn;
1376 var ImmediateAssignment imm_ass;
1377 var integer ra := 23;
1378
Pau Espin Pedrol99a7aca2018-09-28 16:10:32 +02001379 f_L1CTL_PARAM(L1CTL, g_pars.l1_pars.ms_actual_ta, g_pars.l1_pars.ms_power_level);
Harald Welte70767382018-02-21 12:16:40 +01001380 fn := f_L1CTL_RACH(L1CTL, ra);
1381 /* This arrives on CCHAN, so we cannot test for receiving CHAN RQDhere */
1382 //RSL.receive(tr_RSL_CHAN_RQD(int2oct(23,1)));
1383
1384 /* Activate channel on BTS side */
Harald Weltee613f962018-04-18 22:38:16 +02001385 f_rsl_chan_act(g_pars.chan_mode, encr_enable);
Harald Welte70767382018-02-21 12:16:40 +01001386
1387 /* Send IMM.ASS via CCHAN */
1388 var ChannelDescription ch_desc := {
1389 chan_nr := g_pars.chan_nr,
1390 tsc := 7,
1391 h := false,
1392 arfcn := mp_trx0_arfcn,
1393 maio_hsn := omit
1394 };
1395 var MobileAllocation ma := {
1396 len := 0,
1397 ma := ''B
1398 };
1399 var GsmRrMessage rr_msg := valueof(ts_IMM_ASS(ra, fn, 0, ch_desc, ma));
1400 RSL.send(ts_RSL_IMM_ASSIGN(enc_GsmRrMessage(rr_msg)));
1401
1402 /* receive IMM.ASS on MS side */
1403 var ImmediateAssignment ia_um;
1404 ia_um := f_L1CTL_WAIT_IMM_ASS(L1CTL, ra, fn);
1405 /* enable dedicated mode */
1406 f_L1CTL_DM_EST_REQ_IA(L1CTL, ia_um);
Harald Weltee613f962018-04-18 22:38:16 +02001407 /* enable encryption, if requested */
1408 if (encr_enable) {
1409 var uint8_t alg_id := f_alg_id_to_l1ctl(g_pars.encr.alg_id);
1410 f_L1CTL_CRYPTO_REQ(L1CTL, g_pars.chan_nr, alg_id, g_pars.encr.key);
1411 }
Harald Weltefa45e9e2018-03-10 18:59:03 +01001412
1413 g_first_meas_res := true;
Harald Welte70767382018-02-21 12:16:40 +01001414}
1415
1416/* establish DChan, verify existance + contents of measurement reports */
1417function f_TC_meas_res_periodic(charstring id) runs on ConnHdlr {
Harald Welte68e495b2018-02-25 00:05:57 +01001418 f_l1_tune(L1CTL);
Harald Welte70767382018-02-21 12:16:40 +01001419 RSL.clear;
1420
Pau Espin Pedrol121724c2018-09-28 15:58:12 +02001421 if (mp_bb_trxc_port != -1) {
Pau Espin Pedrole9571aa2018-10-22 17:13:07 +02001422 f_trxc_fake_rssi(rxlev2dbm(mp_ul_rxlev_exp));
Pau Espin Pedrol121724c2018-09-28 15:58:12 +02001423 f_trx_fake_toffs256(g_pars.l1_pars.timing_offset_256syms);
1424 }
Harald Welte70767382018-02-21 12:16:40 +01001425
1426 f_est_dchan();
1427
1428 /* run for a number of seconds, send SACCH + FACCH from MS side and verify
1429 * RSL measurement reports on Abis side */
1430 timer T := 8.0;
1431 T.start;
1432 alt {
1433 [] as_l1_sacch();
1434 [] as_meas_res();
1435 [] as_l1_dcch();
1436 [] L1CTL.receive { repeat; }
1437 [g_Tmeas_exp.running] T.timeout {
Daniel Willmann17ddd852018-07-05 17:33:20 +02001438 /* as_meas_res() would have done setverdict(fail) / mtc.stop in case
Harald Welte70767382018-02-21 12:16:40 +01001439 * of any earlier errors, so if we reach this timeout, we're good */
1440 setverdict(pass);
1441 }
1442 [] T.timeout {
1443 setverdict(fail, "No MEAS RES received at all");
Daniel Willmann17ddd852018-07-05 17:33:20 +02001444 mtc.stop;
Harald Welte70767382018-02-21 12:16:40 +01001445 }
1446 }
1447 f_rsl_chan_deact();
Harald Welte3dc20462018-03-10 23:03:38 +01001448 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
Harald Welte70767382018-02-21 12:16:40 +01001449}
Harald Welte0472ab42018-03-12 15:02:26 +01001450
Harald Welte70767382018-02-21 12:16:40 +01001451testcase TC_meas_res_sign_tchf() runs on test_CT {
1452 var ConnHdlr vc_conn;
1453 var ConnHdlrPars pars;
1454 f_init(testcasename());
1455 for (var integer tn := 1; tn <= 4; tn := tn+1) {
1456 pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN));
1457 vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars);
1458 vc_conn.done;
1459 }
Harald Welte294b0a22018-03-10 23:26:48 +01001460 f_shutdown();
Harald Welte70767382018-02-21 12:16:40 +01001461}
1462testcase TC_meas_res_sign_tchh() runs on test_CT {
1463 var ConnHdlr vc_conn;
1464 var ConnHdlrPars pars;
1465 f_init(testcasename());
1466 for (var integer ss := 0; ss <= 1; ss := ss+1) {
1467 pars := valueof(t_Pars(t_RslChanNr_Lm(5, ss), ts_RSL_ChanMode_SIGN));
1468 vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars);
1469 vc_conn.done;
1470 }
Harald Welte294b0a22018-03-10 23:26:48 +01001471 f_shutdown();
Harald Welte70767382018-02-21 12:16:40 +01001472}
1473testcase TC_meas_res_sign_sdcch4() runs on test_CT {
1474 var ConnHdlr vc_conn;
1475 var ConnHdlrPars pars;
1476 f_init(testcasename());
1477 for (var integer ss := 0; ss <= 3; ss := ss+1) {
1478 pars := valueof(t_Pars(t_RslChanNr_SDCCH4(0, ss), ts_RSL_ChanMode_SIGN));
1479 vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars);
1480 vc_conn.done;
1481 }
Harald Welte294b0a22018-03-10 23:26:48 +01001482 f_shutdown();
Harald Welte70767382018-02-21 12:16:40 +01001483}
1484testcase TC_meas_res_sign_sdcch8() runs on test_CT {
1485 var ConnHdlr vc_conn;
1486 var ConnHdlrPars pars;
1487 f_init(testcasename());
1488 for (var integer ss := 0; ss <= 7; ss := ss+1) {
1489 pars := valueof(t_Pars(t_RslChanNr_SDCCH8(6, ss), ts_RSL_ChanMode_SIGN));
1490 vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars);
1491 vc_conn.done;
1492 }
Harald Welte294b0a22018-03-10 23:26:48 +01001493 f_shutdown();
Harald Welte70767382018-02-21 12:16:40 +01001494}
Harald Welte685d5982018-02-27 20:42:05 +01001495testcase TC_meas_res_sign_tchh_toa256() runs on test_CT {
1496 var ConnHdlr vc_conn;
1497 var ConnHdlrPars pars;
1498 f_init(testcasename());
1499 f_vty_config(BTSVTY, "bts 0", "supp-meas-info toa256");
1500 for (var integer ss := 0; ss <= 1; ss := ss+1) {
1501 pars := valueof(t_Pars(t_RslChanNr_Lm(5, ss), ts_RSL_ChanMode_SIGN));
1502 pars.l1_pars.toa256_enabled := true;
1503 vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars);
1504 vc_conn.done;
1505 }
Harald Welte294b0a22018-03-10 23:26:48 +01001506 f_shutdown();
Harald Welte685d5982018-02-27 20:42:05 +01001507}
1508
Harald Welte70767382018-02-21 12:16:40 +01001509
Harald Welte0472ab42018-03-12 15:02:26 +01001510/* Test if a channel without valid uplink bursts generates RSL CONN FAIL IND (TS 48.058 4.10) */
Harald Welte70767382018-02-21 12:16:40 +01001511private function f_TC_conn_fail_crit(charstring id) runs on ConnHdlr {
Harald Welte68e495b2018-02-25 00:05:57 +01001512 f_l1_tune(L1CTL);
Harald Welte70767382018-02-21 12:16:40 +01001513 RSL.clear;
1514
1515 f_est_dchan();
1516 f_sleep(2.0);
Harald Weltef8df4cb2018-03-10 15:15:08 +01001517 L1CTL.send(ts_L1CTL_DM_REL_REQ(g_chan_nr));
Harald Welte70767382018-02-21 12:16:40 +01001518
1519 timer T := 40.0;
1520 T.start;
1521 alt {
1522 [] RSL.receive(tr_RSL_CONN_FAIL_IND(g_chan_nr, ?)) {
1523 setverdict(pass)
1524 }
1525 [] RSL.receive { repeat };
1526 [] T.timeout {
1527 setverdict(fail, "No CONN FAIL IND received");
Daniel Willmann17ddd852018-07-05 17:33:20 +02001528 mtc.stop;
Harald Welte70767382018-02-21 12:16:40 +01001529 }
1530 }
1531 f_rsl_chan_deact();
1532}
1533testcase TC_conn_fail_crit() runs on test_CT {
1534 var ConnHdlr vc_conn;
1535 var ConnHdlrPars pars;
1536 f_init(testcasename());
1537 pars := valueof(t_Pars(t_RslChanNr_SDCCH8(6, 3), ts_RSL_ChanMode_SIGN));
1538 pars.t_guard := 60.0;
1539 vc_conn := f_start_handler(refers(f_TC_conn_fail_crit), pars);
1540 vc_conn.done;
1541}
1542
Harald Welte93640c62018-02-25 16:59:33 +01001543/***********************************************************************
1544 * Paging
1545 ***********************************************************************/
1546
Harald Welte68e495b2018-02-25 00:05:57 +01001547function tmsi_is_dummy(TMSIP_TMSI_V tmsi) return boolean {
1548 if (tmsi == 'FFFFFFFF'O) {
1549 return true;
1550 } else {
1551 return false;
1552 }
1553}
Harald Welte70767382018-02-21 12:16:40 +01001554
Philipp Maier82cb0b12018-08-31 14:41:39 +02001555type record allowedFn { integer frame_nr }
1556template allowedFn bs_ag_blks_res_0 := { frame_nr := (6, 12, 16, 22, 26, 32, 36, 42, 46) }
1557template allowedFn bs_ag_blks_res_1 := { frame_nr := (12, 16, 22, 26, 32, 36, 42, 46) }
1558template allowedFn bs_ag_blks_res_2 := { frame_nr := (16, 22, 26, 32, 36, 42, 46) }
1559template allowedFn bs_ag_blks_res_3 := { frame_nr := (22, 26, 32, 36, 42, 46) }
1560template allowedFn bs_ag_blks_res_4 := { frame_nr := (26, 32, 36, 42, 46) }
1561template allowedFn bs_ag_blks_res_5 := { frame_nr := (32, 36, 42, 46) }
1562template allowedFn bs_ag_blks_res_6 := { frame_nr := (36, 42, 46) }
1563template allowedFn bs_ag_blks_res_7 := { frame_nr := (42, 46) }
1564function check_pch_fn(integer frame_nr, integer bs_ag_blks_res) runs on test_CT
1565{
1566 var integer frame_nr_51;
1567 frame_nr_51 := frame_nr mod 51
1568
1569 var allowedFn fn_check;
1570 fn_check.frame_nr := frame_nr_51;
1571
1572 if (bs_ag_blks_res < 0 or bs_ag_blks_res > 7) {
1573 setverdict(fail, "bs_ag_blks_res out of valid range (0..7)");
1574 mtc.stop;
1575 return;
1576 }
1577
1578 if (bs_ag_blks_res == 0 and match(fn_check, bs_ag_blks_res_0)) {
1579 return;
1580 }
1581 if (bs_ag_blks_res == 1 and match(fn_check, bs_ag_blks_res_1)) {
1582 return;
1583 }
1584 if (bs_ag_blks_res == 2 and match(fn_check, bs_ag_blks_res_2)) {
1585 return;
1586 }
1587 if (bs_ag_blks_res == 3 and match(fn_check, bs_ag_blks_res_3)) {
1588 return;
1589 }
1590 if (bs_ag_blks_res == 4 and match(fn_check, bs_ag_blks_res_4)) {
1591 return;
1592 }
1593 if (bs_ag_blks_res == 5 and match(fn_check, bs_ag_blks_res_5)) {
1594 return;
1595 }
1596 if (bs_ag_blks_res == 6 and match(fn_check, bs_ag_blks_res_6)) {
1597 return;
1598 }
1599 if (bs_ag_blks_res == 7 and match(fn_check, bs_ag_blks_res_7)) {
1600 return;
1601 }
1602
1603 setverdict(fail, "received paging on AGCH");
1604 mtc.stop;
1605 return;
1606}
1607
1608altstep as_l1_count_paging(inout integer num_paging_rcv_msgs, inout integer num_paging_rcv_ids, PagingTestCfg cfg)
Harald Welte68e495b2018-02-25 00:05:57 +01001609runs on test_CT {
1610 var L1ctlDlMessage dl;
Harald Weltef8df4cb2018-03-10 15:15:08 +01001611 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?, c_DummyUI)) {
Harald Welte68e495b2018-02-25 00:05:57 +01001612 repeat;
1613 }
Harald Weltef8df4cb2018-03-10 15:15:08 +01001614 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0))) -> value dl {
Harald Welte68e495b2018-02-25 00:05:57 +01001615 var octetstring without_plen :=
1616 substr(dl.payload.data_ind.payload, 1, lengthof(dl.payload.data_ind.payload)-1);
1617 var PDU_ML3_NW_MS rr := dec_PDU_ML3_NW_MS(without_plen);
Philipp Maier82cb0b12018-08-31 14:41:39 +02001618
1619 check_pch_fn(dl.dl_info.frame_nr, cfg.bs_ag_blks_res);
1620
Harald Welte68e495b2018-02-25 00:05:57 +01001621 if (match(rr, tr_PAGING_REQ1)) {
1622 num_paging_rcv_msgs := num_paging_rcv_msgs + 1;
1623 num_paging_rcv_ids := num_paging_rcv_ids + 1;
1624 if (isvalue(rr.msgs.rrm.pagingReq_Type1.mobileIdentity2)) {
1625 num_paging_rcv_ids := num_paging_rcv_ids + 1;
1626 }
1627 } else if (match(rr, tr_PAGING_REQ2)) {
1628 num_paging_rcv_msgs := num_paging_rcv_msgs + 1;
1629 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type2.mobileIdentity1)) {
1630 num_paging_rcv_ids := num_paging_rcv_ids + 1;
1631 }
1632 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type2.mobileIdentity2)) {
1633 num_paging_rcv_ids := num_paging_rcv_ids + 1;
1634 }
1635 if (isvalue(rr.msgs.rrm.pagingReq_Type2.mobileIdentity3)) {
1636 num_paging_rcv_ids := num_paging_rcv_ids + 1;
1637 }
1638 } else if (match(rr, tr_PAGING_REQ3)) {
1639 num_paging_rcv_msgs := num_paging_rcv_msgs + 1;
1640 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity1)) {
1641 num_paging_rcv_ids := num_paging_rcv_ids + 1;
1642 }
1643 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity2)) {
1644 num_paging_rcv_ids := num_paging_rcv_ids + 1;
1645 }
1646 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity3)) {
1647 num_paging_rcv_ids := num_paging_rcv_ids + 1;
1648 }
1649 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity4)) {
1650 num_paging_rcv_ids := num_paging_rcv_ids + 1;
1651 }
1652 }
1653 repeat;
1654 }
1655}
1656
1657type record PagingTestCfg {
1658 boolean combined_ccch,
1659 integer bs_ag_blks_res,
1660 float load_factor,
1661 boolean exp_load_ind,
1662 boolean exp_overload,
1663 boolean use_tmsi
1664}
1665
1666type record PagingTestState {
1667 integer num_paging_sent,
1668 integer num_paging_rcv_msgs,
1669 integer num_paging_rcv_ids,
1670 integer num_overload
1671}
1672
1673/* receive + ignore RSL RF RES IND */
1674altstep as_rsl_res_ind() runs on test_CT {
1675 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_RF_RES_IND)) {
1676 repeat;
1677 }
1678}
1679
1680/* Helper function for paging related testing */
1681private function f_TC_paging(PagingTestCfg cfg) runs on test_CT return PagingTestState {
1682 f_init(testcasename());
1683 f_init_l1ctl();
1684 f_l1_tune(L1CTL);
1685
1686 var PagingTestState st := {
1687 num_paging_sent := 0,
1688 num_paging_rcv_msgs := 0,
1689 num_paging_rcv_ids := 0,
1690 num_overload := 0
1691 };
1692
1693 var float max_pch_blocks_per_sec := f_pch_block_rate_est(cfg.combined_ccch, cfg.bs_ag_blks_res);
1694 var float max_pch_imsi_per_sec;
1695 if (cfg.use_tmsi) {
1696 max_pch_imsi_per_sec := max_pch_blocks_per_sec * 4.0; /* Type 3 */
1697 } else {
1698 max_pch_imsi_per_sec := max_pch_blocks_per_sec * 2.0; /* Type 1 */
1699 }
1700 var float pch_blocks_per_sec := max_pch_imsi_per_sec * cfg.load_factor;
1701 var float interval := 1.0 / pch_blocks_per_sec;
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02001702 var float time_total := 20.0;
1703 var integer pkt_total := float2int(time_total * pch_blocks_per_sec);
1704 log("pch_blocks_total=", pkt_total," pch_blocks_per_sec=", pch_blocks_per_sec, " interval=", interval);
Harald Welte68e495b2018-02-25 00:05:57 +01001705
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02001706 timer T_total := 300.0; /* big value (far bigger than time_total), used to count elapsed time */
1707 T_total.start;
Harald Welte68e495b2018-02-25 00:05:57 +01001708
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02001709 timer T_itv := 0.0;
1710 T_itv.start;
1711 while (st.num_paging_sent < pkt_total) {
Harald Welte68e495b2018-02-25 00:05:57 +01001712 alt {
1713 /* check for presence of CCCH LOAD IND (paging load) */
1714 [cfg.exp_overload] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_PAGING_LOAD_IND(0))) {
1715 st.num_overload := st.num_overload + 1;
1716 repeat;
1717 }
1718 [not cfg.exp_overload] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_PAGING_LOAD_IND(0))) {
1719 setverdict(fail, "Unexpected PCH Overload");
Daniel Willmann17ddd852018-07-05 17:33:20 +02001720 mtc.stop;
Harald Welte68e495b2018-02-25 00:05:57 +01001721 }
1722 [cfg.exp_load_ind] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_PAGING_LOAD_IND)) {
1723 log("Rx LOAD_IND");
1724 /* FIXME: analyze/verify interval + contents */
1725 repeat;
1726 }
1727 /* check if paging requests arrive on Um side */
Philipp Maier82cb0b12018-08-31 14:41:39 +02001728 [] as_l1_count_paging(st.num_paging_rcv_msgs, st.num_paging_rcv_ids, cfg);
Harald Welte68e495b2018-02-25 00:05:57 +01001729 [] L1CTL.receive { repeat; }
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02001730 [] T_itv.timeout {
1731 /* Send paging cmds based on elapsed time */
1732 var integer new_sent := f_min(pkt_total, float2int(T_total.read * pch_blocks_per_sec) + 1);
1733 while (st.num_paging_sent < new_sent) {
1734 /* build mobile Identity */
1735 var MobileL3_CommonIE_Types.MobileIdentityLV mi;
1736 if (cfg.use_tmsi) {
1737 mi := valueof(ts_MI_TMSI_LV(f_rnd_octstring(4)));
1738 } else {
1739 mi := valueof(ts_MI_IMSI_LV(f_gen_imsi(st.num_paging_sent)));
1740 }
1741 var octetstring mi_enc_lv := enc_MobileIdentityLV(mi);
1742 var octetstring mi_enc := substr(mi_enc_lv, 1, lengthof(mi_enc_lv)-1);
1743
1744 /* Send RSL PAGING COMMAND */
1745 RSL_CCHAN.send(ts_RSL_UD(ts_RSL_PAGING_CMD(mi_enc, st.num_paging_sent mod 4)));
1746
1747 st.num_paging_sent := st.num_paging_sent + 1;
1748 }
1749 if (st.num_paging_sent < pkt_total) {
1750 /* Wait for interval to next PAGING COMMAND */
1751 var float time_now := T_total.read;
1752 var float next_sched := int2float(st.num_paging_sent)*interval;
1753 if (next_sched > time_now) {
1754 T_itv.start(next_sched - time_now);
1755 } else {
1756 T_itv.start(0.0);
1757 }
1758 } else {
1759 /* We are done, no need to keep counting */
1760 T_total.stop;
1761 }
1762 }
1763 [] T_total.timeout { }
Harald Welte68e495b2018-02-25 00:05:57 +01001764 [] as_rsl_res_ind();
1765 }
1766 }
1767
1768 /* wait for max 18s for paging queue to drain (size: 200, ~ 13 per s -> 15s) */
1769 timer T_wait := 18.0;
1770 T_wait.start;
1771 alt {
Philipp Maier82cb0b12018-08-31 14:41:39 +02001772 [] as_l1_count_paging(st.num_paging_rcv_msgs, st.num_paging_rcv_ids, cfg);
Harald Welte68e495b2018-02-25 00:05:57 +01001773 [] L1CTL.receive { repeat; }
1774 /* 65535 == empty paging queue, we can terminate*/
1775 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_PAGING_LOAD_IND(65535))) { }
1776 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_PAGING_LOAD_IND)) { repeat; }
1777 [] T_wait.timeout {
1778 setverdict(fail, "Waiting for empty paging queue");
Daniel Willmann17ddd852018-07-05 17:33:20 +02001779 mtc.stop;
Harald Welte68e495b2018-02-25 00:05:57 +01001780 }
1781 [] as_rsl_res_ind();
1782 }
1783
1784 log("num_paging_sent=", st.num_paging_sent, " rcvd_msgs=", st.num_paging_rcv_msgs,
1785 " rcvd_ids=", st.num_paging_rcv_ids);
1786 return st;
1787}
1788
1789/* Create ~ 80% paging load (IMSI only) sustained for about 20s, verifying that
1790 * - the number of Mobile Identities on Um PCH match the number of pages on RSL
1791 * - that CCCH LOAD IND (PCH) are being generated
1792 * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */
1793testcase TC_paging_imsi_80percent() runs on test_CT {
Philipp Maierd65d0562018-08-30 16:25:47 +02001794 var SystemInformation si3 := valueof(ts_SI3_default);
Harald Welte68e495b2018-02-25 00:05:57 +01001795 var PagingTestCfg cfg := {
1796 combined_ccch := true,
Philipp Maierd65d0562018-08-30 16:25:47 +02001797 bs_ag_blks_res := si3.payload.si3.ctrl_chan_desc.bs_ag_blks_res,
Harald Welte68e495b2018-02-25 00:05:57 +01001798 load_factor := 0.8,
1799 exp_load_ind := true,
1800 exp_overload := false,
1801 use_tmsi := false
1802 };
1803 var PagingTestState st := f_TC_paging(cfg);
1804 if (st.num_paging_sent != st.num_paging_rcv_ids) {
1805 setverdict(fail, "Expected ", st.num_paging_sent, " pagings but have ",
1806 st.num_paging_rcv_ids);
1807 } else {
1808 setverdict(pass);
1809 }
Daniel Willmanna59afab2018-07-05 16:16:32 +02001810 f_shutdown();
Harald Welte68e495b2018-02-25 00:05:57 +01001811}
1812
1813/* Create ~ 80% paging load (TMSI only) sustained for about 20s, verifying that
1814 * - the number of Mobile Identities on Um PCH match the number of pages on RSL
1815 * - that CCCH LOAD IND (PCH) are being generated
1816 * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */
1817testcase TC_paging_tmsi_80percent() runs on test_CT {
Philipp Maierd65d0562018-08-30 16:25:47 +02001818 var SystemInformation si3 := valueof(ts_SI3_default);
Harald Welte68e495b2018-02-25 00:05:57 +01001819 var PagingTestCfg cfg := {
1820 combined_ccch := true,
Philipp Maierd65d0562018-08-30 16:25:47 +02001821 bs_ag_blks_res := si3.payload.si3.ctrl_chan_desc.bs_ag_blks_res,
Harald Welte68e495b2018-02-25 00:05:57 +01001822 load_factor := 0.8,
1823 exp_load_ind := true,
1824 exp_overload := false,
1825 use_tmsi := true
1826 };
1827 var PagingTestState st := f_TC_paging(cfg);
1828 if (st.num_paging_sent != st.num_paging_rcv_ids) {
1829 setverdict(fail, "Expected ", st.num_paging_sent, " pagings but have ",
1830 st.num_paging_rcv_ids);
1831 } else {
1832 setverdict(pass);
1833 }
Daniel Willmanna59afab2018-07-05 16:16:32 +02001834 f_shutdown();
Harald Welte68e495b2018-02-25 00:05:57 +01001835}
1836
1837/* Create ~ 200% paging load (IMSI only) sustained for about 20s, verifying that
1838 * - the number of Mobile Identities on Um PCH are ~ 82% of the number of pages on RSL
1839 * - that CCCH LOAD IND (PCH) are being generated and reach 0 at some point
1840 * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */
1841testcase TC_paging_imsi_200percent() runs on test_CT {
Philipp Maierd65d0562018-08-30 16:25:47 +02001842 var SystemInformation si3 := valueof(ts_SI3_default);
Harald Welte68e495b2018-02-25 00:05:57 +01001843 var PagingTestCfg cfg := {
1844 combined_ccch := true,
Philipp Maierd65d0562018-08-30 16:25:47 +02001845 bs_ag_blks_res := si3.payload.si3.ctrl_chan_desc.bs_ag_blks_res,
Harald Welte68e495b2018-02-25 00:05:57 +01001846 load_factor := 2.0,
1847 exp_load_ind := true,
1848 exp_overload := true,
1849 use_tmsi := false
1850 };
1851 var PagingTestState st := f_TC_paging(cfg);
1852 /* We expect about 80-85% to pass, given that we can fill the paging buffer of 200
1853 * slots and will fully drain that buffer before returning */
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02001854 var template integer tpl := (st.num_paging_sent*78/100 .. st.num_paging_sent *85/100);
Harald Welte68e495b2018-02-25 00:05:57 +01001855 if (not match(st.num_paging_rcv_ids, tpl)) {
1856 setverdict(fail, "Expected ", tpl, " pagings but have ", st.num_paging_rcv_ids);
1857 } else {
1858 setverdict(pass);
1859 }
Daniel Willmanna59afab2018-07-05 16:16:32 +02001860 f_shutdown();
Harald Welte68e495b2018-02-25 00:05:57 +01001861}
1862
1863/* Create ~ 200% paging load (TMSI only) sustained for about 20s, verifying that
1864 * - the number of Mobile Identities on Um PCH are ~ 82% of the number of pages on RSL
1865 * - that CCCH LOAD IND (PCH) are being generated and reach 0 at some point
1866 * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */
1867testcase TC_paging_tmsi_200percent() runs on test_CT {
Philipp Maierd65d0562018-08-30 16:25:47 +02001868 var SystemInformation si3 := valueof(ts_SI3_default);
Harald Welte68e495b2018-02-25 00:05:57 +01001869 var PagingTestCfg cfg := {
1870 combined_ccch := true,
Philipp Maierd65d0562018-08-30 16:25:47 +02001871 bs_ag_blks_res := si3.payload.si3.ctrl_chan_desc.bs_ag_blks_res,
Harald Welte68e495b2018-02-25 00:05:57 +01001872 load_factor := 2.0,
1873 exp_load_ind := true,
1874 exp_overload := true,
1875 use_tmsi := true
1876 };
1877 var PagingTestState st := f_TC_paging(cfg);
1878 /* We expect about 70% to pass, given that we can fill the paging buffer of 200
1879 * slots and will fully drain that buffer before returning */
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02001880 var template integer tpl := (st.num_paging_sent*64/100 .. st.num_paging_sent *72/100);
Harald Welte68e495b2018-02-25 00:05:57 +01001881 if (not match(st.num_paging_rcv_ids, tpl)) {
1882 setverdict(fail, "Expected ", tpl, " pagings but have ", st.num_paging_rcv_ids);
1883 } else {
1884 setverdict(pass);
1885 }
Daniel Willmanna59afab2018-07-05 16:16:32 +02001886 f_shutdown();
Harald Welte68e495b2018-02-25 00:05:57 +01001887}
1888
1889
Harald Welte93640c62018-02-25 16:59:33 +01001890/***********************************************************************
1891 * Immediate Assignment / AGCH
1892 ***********************************************************************/
Harald Weltee8d750e2018-06-10 21:41:35 +02001893const MobileAllocation c_MA_null := {
1894 len := 0,
1895 ma := ''B
1896}
Harald Welte93640c62018-02-25 16:59:33 +01001897
Harald Weltee8d750e2018-06-10 21:41:35 +02001898template (value) ChannelDescription ts_ChanDesc(template (value) RslChannelNr chan_nr, uint3_t tsc := 7,
1899 uint12_t arfcn := 871) := {
1900 chan_nr := chan_nr,
1901 tsc := tsc,
1902 h := false,
1903 arfcn := arfcn,
1904 maio_hsn := omit
1905}
1906
1907private function f_fmt_ia_stats(integer num_tx, integer num_rx, integer num_del) return charstring {
1908 return int2str(num_tx) & " sent, "
1909 & int2str(num_rx) & " received, "
1910 & int2str(num_del) & " deleted";
1911}
1912
1913private function f_TC_imm_ass(integer num_total, float sleep_s, float exp_pass) runs on test_CT {
1914 var L1ctlDlMessage l1_dl;
1915 timer T := 10.0;
1916 var integer num_tx := 0;
1917 var integer num_rx := 0;
1918 var integer num_del := 0;
1919 var charstring res_str;
1920 var float rx_ratio;
1921
Harald Welte68e495b2018-02-25 00:05:57 +01001922 f_init(testcasename());
Harald Weltee8d750e2018-06-10 21:41:35 +02001923 f_init_l1ctl();
1924 f_l1_tune(L1CTL);
1925
1926 for (var integer i := 0; i < num_total; i := i+1) {
1927 var ChannelDescription ch_desc := valueof(ts_ChanDesc(valueof(t_RslChanNr_SDCCH4(0, 0))));
1928 var GsmRrMessage ia := valueof(ts_IMM_ASS(42, i, 5, ch_desc, c_MA_null));
1929 var octetstring ia_enc := enc_GsmRrMessage(ia);
Harald Welte68e495b2018-02-25 00:05:57 +01001930 RSL_CCHAN.send(ts_RSL_UD(ts_RSL_IMM_ASSIGN(ia_enc, 0)));
Harald Weltee8d750e2018-06-10 21:41:35 +02001931 num_tx := num_tx+1;
1932 f_sleep(sleep_s);
Harald Welte68e495b2018-02-25 00:05:57 +01001933 }
1934 /* FIXME: check if imm.ass arrive on Um side */
Harald Weltee8d750e2018-06-10 21:41:35 +02001935 T.start;
1936 alt {
1937 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_DELETE_IND(?, 0))) {
1938 num_del := num_del+1;
1939 repeat;
1940 }
1941 [] RSL_CCHAN.receive {
1942 repeat;
1943 }
1944 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?)) -> value l1_dl {
1945 /* somehow dec_SystemInformation will try to decode even non-RR as SI */
1946 var GsmRrMessage rr := dec_GsmRrMessage(l1_dl.payload.data_ind.payload);
1947 if (not match(rr, tr_IMM_ASS(42, ?, 5, ?, ?))) {
1948 /* FIXME: Why are we seeing paging requests on PCH/AGCH? */
1949 //setverdict(fail, "Unexpected IMM-ASS values on AGCH: ", rr);
Daniel Willmann17ddd852018-07-05 17:33:20 +02001950 //mtc.stop;
Harald Weltee8d750e2018-06-10 21:41:35 +02001951 } else {
1952 num_rx := num_rx+1;
1953 }
1954 repeat;
1955 }
1956 [] L1CTL.receive { repeat; }
1957 [] T.timeout { }
1958 }
1959 res_str := f_fmt_ia_stats(num_tx, num_rx, num_del);
1960 log("AGCH test: " & res_str);
1961 if (num_rx + num_del != num_tx) {
1962 setverdict(fail, "RX + DEL != TX ?!?: " & res_str);
Daniel Willmann17ddd852018-07-05 17:33:20 +02001963 mtc.stop
Harald Weltee8d750e2018-06-10 21:41:35 +02001964 }
1965 rx_ratio := int2float(num_rx) / int2float(num_tx);
1966 if (rx_ratio < exp_pass*0.8 or rx_ratio > exp_pass*1.2) {
1967 setverdict(fail, "RX ratio ("&float2str(rx_ratio)&") far from expected ("&float2str(exp_pass)&") " & res_str);
1968 } else {
1969 setverdict(pass);
1970 }
Daniel Willmann17ddd852018-07-05 17:33:20 +02001971 f_shutdown();
Harald Welte68e495b2018-02-25 00:05:57 +01001972}
1973
Harald Weltee8d750e2018-06-10 21:41:35 +02001974/* send a long burst of 1000 IMM.ASS with 20ms spacing (50 per s); expect 75% of them to be deleted */
1975testcase TC_imm_ass_1000_20ms() runs on test_CT {
1976 f_TC_imm_ass(1000, 0.02, 0.25);
1977}
1978
1979/* send a short burst of 200 IMM.ASS without any spacing; expect 95% of them to be deleted */
1980testcase TC_imm_ass_200_0ms() runs on test_CT {
1981 f_TC_imm_ass(200, 0.0, 0.05);
1982}
1983
1984/* send 150 IMM.ASS at rate of 13/s; expect none of them to be deleted */
1985testcase TC_imm_ass_200_76ms() runs on test_CT {
1986 f_TC_imm_ass(150, 0.076, 1.00);
1987}
1988
1989
1990
Harald Welte48494ca2018-02-25 16:59:50 +01001991/***********************************************************************
1992 * BCCH
1993 ***********************************************************************/
1994
1995/* tuple of Frame Number + decoded SI */
1996type record SystemInformationFn {
1997 GsmFrameNumber frame_number,
1998 SystemInformation si
1999}
2000
2001/* an arbitrary-length vector of decoded SI + gsmtap header */
2002type record of SystemInformationFn SystemInformationVector;
2003
2004/* an array of SI-vectors indexed by TC value */
2005type SystemInformationVector SystemInformationVectorPerTc[8];
2006
2007/* determine if a given SI vector contains given SI type at least once */
2008function f_si_vecslot_contains(SystemInformationVector arr, RrMessageType key, boolean bcch_ext := false) return boolean {
2009 for (var integer i:= 0; i< sizeof(arr); i := i + 1) {
2010 var integer fn_mod51 := arr[i].frame_number mod 51;
2011 if (not bcch_ext and fn_mod51 == 2 or
2012 bcch_ext and fn_mod51 == 6) {
2013 if (arr[i].si.header.message_type == key) {
2014 return true;
2015 }
2016 }
2017 }
2018 return false;
2019}
2020
2021/* ensure a given TC slot of the SI vector contains given SI type at least once at TC */
2022function f_ensure_si_vec_contains(SystemInformationVectorPerTc arr, integer tc, RrMessageType key, boolean ext_bcch := false) {
2023 if (not f_si_vecslot_contains(arr[tc], key, ext_bcch)) {
2024 setverdict(fail, "No ", key, " in TC=", tc, "!");
Daniel Willmann17ddd852018-07-05 17:33:20 +02002025 mtc.stop;
Harald Welte48494ca2018-02-25 16:59:50 +01002026 }
2027}
2028
2029/* check if a given SI vector contains given SI type at least once on any TC */
2030function f_si_vec_contains(SystemInformationVectorPerTc arr, RrMessageType key) return boolean {
2031 for (var integer tc:= 0; tc < sizeof(arr); tc := tc + 1) {
2032 if (f_si_vecslot_contains(arr[tc], key) or
2033 f_si_vecslot_contains(arr[tc], key, true)) {
2034 return true;
2035 }
2036 }
2037 return false;
2038}
2039
2040/* determine if a given SI vector contains given SI type at least N of M times */
2041function f_si_vecslot_contains_n_of_m(SystemInformationVector arr, RrMessageType key, boolean bcch_ext := false, integer n := 1, integer m := 4) return boolean {
2042 var integer count := 0;
2043 if (sizeof(arr) < m) {
2044 setverdict(fail, "Error: Insufficient SI in array");
Daniel Willmann17ddd852018-07-05 17:33:20 +02002045 mtc.stop;
Harald Welte48494ca2018-02-25 16:59:50 +01002046 }
2047 for (var integer i:= 0; i < m; i := i + 1) {
2048 var integer fn_mod51 := arr[i].frame_number mod 51;
2049 if (not bcch_ext and fn_mod51 == 2 or
2050 bcch_ext and fn_mod51 == 6) {
2051 if (arr[i].si.header.message_type == key) {
2052 count := count + 1;
2053 }
2054 }
2055 }
2056 if (count >= n) {
2057 return true;
2058 } else {
2059 return false;
2060 }
2061}
2062
2063/* ensure a given TC slot of the SI vector contains given SI type at least N out of M times at TC */
2064function f_ensure_si_vec_contains_n_of_m(SystemInformationVectorPerTc arr, integer tc, RrMessageType key, boolean ext_bcch := false, integer n, integer m) {
2065 if (not f_si_vecslot_contains_n_of_m(arr[tc], key, ext_bcch, n, m)) {
2066 setverdict(fail, "Not ", n, "/", m, " of ", key, " in TC=", tc, "!");
Daniel Willmann17ddd852018-07-05 17:33:20 +02002067 mtc.stop;
Harald Welte48494ca2018-02-25 16:59:50 +01002068 }
2069}
2070
2071/* determine if a given SI vector contains given SI type at least once */
2072function f_si_vecslot_contains_only(SystemInformationVector arr, RrMessageType key, boolean bcch_ext := false) return boolean {
2073 for (var integer i:= 0; i< sizeof(arr); i := i + 1) {
2074 var integer fn_mod51 := arr[i].frame_number mod 51;
2075 if (not bcch_ext and fn_mod51 == 2 or
2076 bcch_ext and fn_mod51 == 6) {
2077 if (arr[i].si.header.message_type != key) {
2078 return false;
2079 }
2080 }
2081 }
2082 return true;
2083}
2084
2085/* ensure a given TC slot of the SI vector contains only given SI type */
2086function f_ensure_si_vec_contains_only(SystemInformationVectorPerTc arr, integer tc, RrMessageType key, boolean ext_bcch := false) {
2087 if (not f_si_vecslot_contains_only(arr[tc], key, ext_bcch)) {
2088 setverdict(fail, "Not all ", key, " in TC=", tc, "!");
Daniel Willmann17ddd852018-07-05 17:33:20 +02002089 mtc.stop;
Harald Welte48494ca2018-02-25 16:59:50 +01002090 }
2091}
2092
2093/* SI configuration of cell, against which we validate actual SI messages */
2094type set SystemInformationConfig {
2095 boolean bcch_extended,
2096 boolean si1_present,
2097 boolean si2bis_present,
2098 boolean si2ter_present,
2099 boolean si2quater_present,
2100 boolean si7_present,
2101 boolean si8_present,
2102 boolean si9_present,
2103 boolean si13_present,
2104 boolean si13alt_present,
2105 boolean si15_present,
2106 boolean si16_present,
2107 boolean si17_present,
2108 boolean si2n_present,
2109 boolean si21_present,
2110 boolean si22_present
2111}
2112
2113/* validate the SI scheduling according to TS 45.002 version 14.1.0 Release 14, Section 6.3.1.3 */
2114function f_validate_si_scheduling(SystemInformationConfig cfg, SystemInformationVectorPerTc si_per_tc) {
2115 var integer i;
2116 for (i := 0; i < sizeof(si_per_tc); i := i + 1) {
2117 if (sizeof(si_per_tc[i]) == 0) {
Harald Welte544565a2018-03-02 10:34:08 +01002118 setverdict(fail, "No SI messages for TC=", i);
Daniel Willmann17ddd852018-07-05 17:33:20 +02002119 mtc.stop;
Harald Welte48494ca2018-02-25 16:59:50 +01002120 }
2121 }
2122 if (cfg.si1_present) {
2123 /* ii) System Information Type 1 needs to be sent if frequency hopping is in use or
2124 * when the NCH is present in a cell. If the MS finds another message on BCCH Norm
2125 * when TC = 0, it can assume that System Information Type 1 is not in use. */
2126 f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_1);
2127 /* make sure *ALL* contain SI1 */
2128 f_ensure_si_vec_contains_only(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_1);
2129 }
2130 f_ensure_si_vec_contains(si_per_tc, 1, SYSTEM_INFORMATION_TYPE_2);
2131 /* iii) A SI 2 message will be sent at least every time TC = 1 */
2132 f_ensure_si_vec_contains(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_3);
2133 f_ensure_si_vec_contains(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_3);
2134 f_ensure_si_vec_contains(si_per_tc, 3, SYSTEM_INFORMATION_TYPE_4);
2135 f_ensure_si_vec_contains(si_per_tc, 7, SYSTEM_INFORMATION_TYPE_4);
2136
2137 /* iii) System information type 2 bis or 2 ter messages are sent if needed, as determined by the
2138 * system operator. If only one of them is needed, it is sent when TC = 5. If both are
2139 * needed, 2bis is sent when TC = 5 and 2ter is sent at least once within any of 4
2140 * consecutive occurrences of TC = 4. */
2141 if (cfg.si2bis_present and not cfg.si2ter_present) {
2142 f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2bis);
2143 } else if (cfg.si2ter_present and not cfg.si2bis_present) {
2144 f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2ter);
2145 } else if (cfg.si2ter_present and cfg.si2bis_present) {
2146 f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2bis);
2147 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2ter, false, 1, 4);
2148 }
2149
2150 if (cfg.si7_present or cfg.si8_present) {
2151 /* vi) Use of System Information type 7 and 8 is not always necessary. It is necessary
2152 * if System Information type 4 does not contain all information needed for cell
2153 * selection and reselection. */
2154 if (not cfg.bcch_extended) {
2155 testcase.stop("Error: SI7/SI8 require BCCH Extd.");
2156 }
2157 if (cfg.si7_present) {
2158 f_ensure_si_vec_contains(si_per_tc, 7, SYSTEM_INFORMATION_TYPE_7, true);
2159 }
2160 if (cfg.si8_present) {
2161 f_ensure_si_vec_contains(si_per_tc, 3, SYSTEM_INFORMATION_TYPE_8, true);
2162 }
2163 }
2164
2165 if (cfg.si2quater_present) {
2166 /* iii) System information type 2 quater is sent if needed, as determined by the system
2167 * operator. If sent on BCCH Norm, it shall be sent when TC = 5 if neither of 2bis
2168 * and 2ter are used, otherwise it shall be sent at least once within any of 4
2169 * consecutive occurrences of TC = 4. If sent on BCCH Ext, it is sent at least once
2170 * within any of 4 consecutive occurrences of TC = 5. */
2171 if (not (cfg.bcch_extended)) {
2172 if (not (cfg.si2bis_present or cfg.si2ter_present)) {
2173 f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2quater);
2174 } else {
2175 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2quater, false, 1, 4);
2176 }
2177 } else {
2178 f_ensure_si_vec_contains_n_of_m(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2quater, true, 1, 4);
2179 }
2180 }
2181 if (cfg.si9_present) {
2182 /* vi) System Information type 9 is sent in those blocks with TC = 4 which are specified
2183 * in system information type 3 as defined in 3GPP TS 44.018. */
2184 f_ensure_si_vec_contains(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_9); // FIXME SI3
2185 }
2186 if (cfg.si13_present) {
2187 /* vii) System Information type 13 is only related to the GPRS service. System Information
2188 * Type 13 need only be sent if GPRS support is indicated in one or more of System
2189 * Information Type 3 or 4 or 7 or 8 messages. These messages also indicate if the
2190 * message is sent on the BCCH Norm or if the message is transmitted on the BCCH Ext.
2191 * In the case that the message is sent on the BCCH Norm, it is sent at least once
2192 * within any of 4 consecutive occurrences of TC=4. */
2193 if (not cfg.bcch_extended) {
2194 log("not-bccch-extended");
2195 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_13, false, 1, 4);
2196 } else {
2197 log("bccch-extended");
2198 f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_13, true);
2199 }
2200 if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_13alt)) {
2201 setverdict(fail, "Cannot have SI13alt and SI13");
Daniel Willmann17ddd852018-07-05 17:33:20 +02002202 mtc.stop;
Harald Welte48494ca2018-02-25 16:59:50 +01002203 }
2204 }
2205 if (cfg.si16_present or cfg.si17_present) {
2206 /* viii) System Information type 16 and 17 are only related to the SoLSA service. They
2207 * should not be sent in a cell where network sharing is used (see rule xv). */
2208 if (cfg.si22_present) {
2209 testcase.stop("Error: Cannot have SI16/SI17 and SI22!");
2210 }
2211 if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_22)) {
2212 setverdict(fail, "Cannot have SI16/SI17 and SI22!");
Daniel Willmann17ddd852018-07-05 17:33:20 +02002213 mtc.stop;
Harald Welte48494ca2018-02-25 16:59:50 +01002214 }
2215 if (not cfg.bcch_extended) {
2216 testcase.stop("Error: SI16/SI17 requires BCCH Extd!");
2217 }
2218 if (cfg.si16_present) {
2219 f_ensure_si_vec_contains(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_16, true);
2220 }
2221 if (cfg.si17_present) {
2222 f_ensure_si_vec_contains(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_17, true);
2223 }
2224 }
2225
2226 /* ix) System Information type 18 and 20 are sent in order to transmit non-GSM
2227 * broadcast information. The frequency with which they are sent is determined by the
2228 * system operator. System Information type 9 identifies the scheduling of System
2229 * Information type 18 and 20 messages. */
2230
2231 /* x) System Information Type 19 is sent if COMPACT neighbours exist. If System
2232 * Information Type 19 is present, then its scheduling shall be indicated in System
2233 * Information Type 9. */
2234
2235 if (cfg.si15_present) {
2236 /* xi) System Information Type 15 is broadcast if dynamic ARFCN mapping is used in the
2237 * PLMN. If sent on BCCH Norm, it is sent at least once within any of 4 consecutive
2238 * occurrences of TC = 4. If sent on BCCH Ext, it is sent at least once within any of
2239 * 4 consecutive occurrences of TC = 1. */
2240 if (not cfg.bcch_extended) {
2241 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_15, false, 1, 4);
2242 } else {
2243 f_ensure_si_vec_contains_n_of_m(si_per_tc, 1, SYSTEM_INFORMATION_TYPE_15, true, 1, 4);
2244 }
2245 }
2246 if (cfg.si13alt_present) {
2247 /* xii) System Information type 13 alt is only related to the GERAN Iu mode. System
2248 * Information Type 13 alt need only be sent if GERAN Iu mode support is indicated in
2249 * one or more of System Information Type 3 or 4 or 7 or 8 messages and SI 13 is not
2250 * broadcast. These messages also indicate if the message is sent on the BCCH Norm or
2251 * if the message is transmitted on the BCCH Ext. In the case that the message is sent
2252 * on the BCCH Norm, it is sent at least once within any of 4 consecutive occurrences
2253 * of TC = 4. */
2254 if (cfg.si13_present) {
2255 testcase.stop("Error: Cannot have SI13alt and SI13");
2256 }
2257 if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_13)) {
2258 setverdict(fail, "Cannot have SI13alt and SI13");
Daniel Willmann17ddd852018-07-05 17:33:20 +02002259 mtc.stop;
Harald Welte48494ca2018-02-25 16:59:50 +01002260 }
2261 if (not cfg.bcch_extended) {
2262 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_13alt, false, 1, 4);
2263 } else {
2264 f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_13alt, true);
2265 }
2266 }
2267 if (cfg.si2n_present) {
2268 /* xiii) System Information Type 2n is optionally sent on BCCH Norm or BCCH Ext if needed,
2269 * as determined by the system operator. In the case that the message is sent on the
2270 * BCCH Norm, it is sent at least once within any of 4 consecutive occurrences of TC =
2271 * 4. If the message is sent on BCCH Ext, it is sent at least once within any of 2
2272 * consecutive occurrences of TC = 4. */
2273 if (not cfg.bcch_extended) {
2274 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2n, false, 1, 4);
2275 } else {
2276 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2n, true, 2, 4);
2277 }
2278 }
2279 if (cfg.si21_present) {
2280 /* xiv) System Information Type 21 is optionally sent on BCCH Norm or BCCH Ext, as
2281 * determined by the system operator. If Extended Access Barring is in use in the cell
2282 * then this message is sent at least once within any of 4 consecutive occurrences of
2283 * TC = 4 regardless if it is sent on BCCH Norm or BCCH Ext. If BCCH Ext is used in a
2284 * cell then this message shall only be sent on BCCH Ext. */
2285 if (not cfg.bcch_extended) {
2286 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_21, false, 1, 4);
2287 } else {
2288 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_21, true, 1, 4);
2289 if (f_si_vecslot_contains(si_per_tc[4], SYSTEM_INFORMATION_TYPE_21)) {
2290 setverdict(fail, "Cannot have SI21 on BCCH Norm if BCCH Extd enabled!");
Daniel Willmann17ddd852018-07-05 17:33:20 +02002291 mtc.stop;
Harald Welte48494ca2018-02-25 16:59:50 +01002292 }
2293 }
2294 }
2295 if (cfg.si22_present) {
2296 /* xv) System Information Type 22 is sent if network sharing is in use in the cell. It
2297 * should not be sent in a cell where SoLSA is used (see rule viii). System
2298 * Information Type 22 instances shall be sent on BCCH Ext within any occurrence of TC
2299 * =2 and TC=6. */
2300 if (cfg.si16_present or cfg.si17_present) {
2301 testcase.stop("Error: Cannot have SI16/SI17 and SI22!");
2302 }
2303 if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_16) or
2304 f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_17)) {
2305 setverdict(fail, "Cannot have SI16/SI17 and SI22!");
Daniel Willmann17ddd852018-07-05 17:33:20 +02002306 mtc.stop;
Harald Welte48494ca2018-02-25 16:59:50 +01002307 }
2308 if (not cfg.bcch_extended) {
2309 testcase.stop("Error: SI22 requires BCCH Extd!");
2310 } else {
2311 f_ensure_si_vec_contains_only(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_22, true);
2312 f_ensure_si_vec_contains_only(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_22, true);
2313 }
2314 }
2315}
2316
2317/* sample Systme Information for specified duration via L1CTL */
2318function f_l1_sample_si(L1CTL_PT pt, float duration := 8.0) return SystemInformationVectorPerTc {
2319 timer T := duration;
2320 var SystemInformationVectorPerTc si_per_tc;
2321 var L1ctlDlMessage l1_dl;
2322
2323 /* initialize all per-TC vectors empty */
2324 for (var integer i:= 0; i < sizeof(si_per_tc); i := i+1) {
2325 si_per_tc[i] := {};
2326 }
2327
2328 /* flush all previous L1 queued msgs */
2329 pt.clear;
2330
2331 T.start;
2332 alt {
Harald Weltef8df4cb2018-03-10 15:15:08 +01002333 [] pt.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl {
Harald Welte48494ca2018-02-25 16:59:50 +01002334 /* somehow dec_SystemInformation will try to decode even non-RR as SI */
2335 if (not (l1_dl.payload.data_ind.payload[1] == '06'O)) {
2336 log("Ignoring non-RR SI ", l1_dl);
2337 repeat;
2338 }
2339 var SystemInformationFn sig := {
2340 frame_number := l1_dl.dl_info.frame_nr,
2341 si := dec_SystemInformation(l1_dl.payload.data_ind.payload)
2342 }
2343 var integer tc := f_gsm_compute_tc(sig.frame_number);
2344 log("SI received at TC=", tc, ": ", sig.si);
2345 /* append to the per-TC bucket */
2346 si_per_tc[tc] := si_per_tc[tc] & { sig };
2347 repeat;
2348 }
2349 [] pt.receive { repeat; }
2350 [] T.timeout { }
2351 }
2352
2353 for (var integer i:= 0; i < sizeof(si_per_tc); i := i+1) {
2354 log(testcasename(), ": TC=", i, " has #of SI=", sizeof(si_per_tc[i]));
2355 }
2356 log("si_per_tc=", si_per_tc);
2357 return si_per_tc;
2358}
2359
2360/* helper function: Set given SI via RSL + validate scheduling.
2361 * CALLER MUST MAKE SURE TO CHANGE GLOBAL si_cfg! */
2362function f_TC_si_sched() runs on test_CT {
2363 var SystemInformationVectorPerTc si_per_tc;
2364 f_init_l1ctl();
2365 f_l1_tune(L1CTL);
2366
2367 /* Sample + Validate Scheduling */
2368 si_per_tc := f_l1_sample_si(L1CTL);
2369 f_validate_si_scheduling(si_cfg, si_per_tc);
2370
2371 setverdict(pass);
2372}
2373
2374testcase TC_si_sched_default() runs on test_CT {
2375 f_init();
Harald Welte0cae4552018-03-09 22:20:26 +01002376 /* 2+3+4 are mandatory and set in f_init() */
2377 f_TC_si_sched();
Harald Welte294b0a22018-03-10 23:26:48 +01002378 f_shutdown();
Harald Welte0cae4552018-03-09 22:20:26 +01002379}
2380
2381testcase TC_si_sched_1() runs on test_CT {
2382 f_init();
2383 si_cfg.si1_present := true;
2384 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_1, '5506198fb38000000000000000000000000000e504002b'O);
Harald Welte48494ca2018-02-25 16:59:50 +01002385 f_TC_si_sched();
Harald Welte294b0a22018-03-10 23:26:48 +01002386 f_shutdown();
Harald Welte48494ca2018-02-25 16:59:50 +01002387}
2388
2389testcase TC_si_sched_2bis() runs on test_CT {
2390 f_init();
2391 si_cfg.si2bis_present := true;
2392 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O);
2393 f_TC_si_sched();
Harald Welte294b0a22018-03-10 23:26:48 +01002394 f_shutdown();
Harald Welte48494ca2018-02-25 16:59:50 +01002395}
2396
2397testcase TC_si_sched_2ter() runs on test_CT {
2398 f_init();
2399 si_cfg.si2ter_present := true;
2400 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O);
2401 f_TC_si_sched();
Harald Welte294b0a22018-03-10 23:26:48 +01002402 f_shutdown();
Harald Welte48494ca2018-02-25 16:59:50 +01002403}
2404
2405testcase TC_si_sched_2ter_2bis() runs on test_CT {
2406 f_init();
2407 si_cfg.si2bis_present := true;
2408 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O);
2409 si_cfg.si2ter_present := true;
2410 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O);
2411 f_TC_si_sched();
Harald Welte294b0a22018-03-10 23:26:48 +01002412 f_shutdown();
Harald Welte48494ca2018-02-25 16:59:50 +01002413}
2414
2415testcase TC_si_sched_2quater() runs on test_CT {
2416 f_init();
2417 si_cfg.si2quater_present := true;
2418 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2quater, '050607a8a0364aa698d72ff424feee0506d5e7fff02043'O);
2419 f_TC_si_sched();
Harald Welte294b0a22018-03-10 23:26:48 +01002420 f_shutdown();
Harald Welte48494ca2018-02-25 16:59:50 +01002421}
2422
2423testcase TC_si_sched_13() runs on test_CT {
2424 f_init();
2425 si_cfg.si13_present := true;
Harald Welte5618c2a2018-04-15 16:24:46 +02002426 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_13, '0106009000185a6fc9e08410ab2b2b2b2b2b2b2b2b2b2b'O);
Harald Welte48494ca2018-02-25 16:59:50 +01002427 f_TC_si_sched();
Harald Welte294b0a22018-03-10 23:26:48 +01002428 f_shutdown();
Harald Welte48494ca2018-02-25 16:59:50 +01002429}
2430
2431testcase TC_si_sched_13_2bis_2ter_2quater() runs on test_CT {
2432 f_init();
2433 si_cfg.si2bis_present := true;
2434 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O);
2435 si_cfg.si2ter_present := true;
2436 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O);
2437 si_cfg.si2quater_present := true;
2438 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2quater, '050607a8a0364aa698d72ff424feee0506d5e7fff02043'O);
2439 si_cfg.si13_present := true;
Harald Welte5618c2a2018-04-15 16:24:46 +02002440 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_13, '0106009000185a6fc9e08410ab2b2b2b2b2b2b2b2b2b2b'O);
Harald Welte48494ca2018-02-25 16:59:50 +01002441 f_TC_si_sched();
Harald Welte294b0a22018-03-10 23:26:48 +01002442 f_shutdown();
Harald Welte48494ca2018-02-25 16:59:50 +01002443}
2444
2445
Harald Welte68e495b2018-02-25 00:05:57 +01002446testcase TC_bcch_info() runs on test_CT {
2447 f_init(testcasename());
2448 /* FIXME: enable / disable individual BCCH info */
2449 //ts_RSL_BCCH_INFO(si_type, info);
2450 /* expect no ERROR REPORT after either of them *
2451 /* negative test: ensure ERROR REPORT on unsupported types */
Harald Welte294b0a22018-03-10 23:26:48 +01002452 f_shutdown();
Harald Welte68e495b2018-02-25 00:05:57 +01002453}
2454
Harald Welte93640c62018-02-25 16:59:33 +01002455/***********************************************************************
2456 * Low-Level Protocol Errors / ERROR REPORT
2457 ***********************************************************************/
2458
Harald Welte01d982c2018-02-25 01:31:40 +01002459private function f_exp_err_rep(template RSL_Cause cause) runs on test_CT {
2460 timer T := 5.0;
2461 T.start;
2462 alt {
2463 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_ERROR_REPORT(cause))) {
2464 setverdict(pass);
2465 }
2466 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_ERROR_REPORT(?))) {
2467 setverdict(fail, "Wrong cause in RSL ERR REP");
Daniel Willmann17ddd852018-07-05 17:33:20 +02002468 mtc.stop;
Harald Welte01d982c2018-02-25 01:31:40 +01002469 }
2470 [] RSL_CCHAN.receive {
2471 repeat;
2472 }
2473 [] T.timeout {
2474 setverdict(fail, "Timeout waiting for RSL ERR REP");
Daniel Willmann17ddd852018-07-05 17:33:20 +02002475 mtc.stop;
Harald Welte01d982c2018-02-25 01:31:40 +01002476 }
2477 }
2478}
2479
2480/* Provoke a protocol error (message too short) and match on ERROR REPORT */
2481testcase TC_rsl_protocol_error() runs on test_CT {
2482 f_init(testcasename());
2483 var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O));
2484 rsl.ies := omit;
2485 RSL_CCHAN.send(ts_RSL_UD(rsl));
2486
2487 f_exp_err_rep(RSL_ERR_PROTO);
2488}
2489
2490/* Provoke a mandatory IE error and match on ERROR REPORT */
2491testcase TC_rsl_mand_ie_error() runs on test_CT {
2492 f_init(testcasename());
2493
2494 var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O));
2495 rsl.ies := { rsl.ies[0] };
2496 RSL_CCHAN.send(ts_RSL_UD(rsl));
2497
2498 f_exp_err_rep(RSL_ERR_MAND_IE_ERROR);
2499}
2500
2501/* Provoke an IE content error and match on ERROR REPORT */
2502testcase TC_rsl_ie_content_error() runs on test_CT {
2503 f_init(testcasename());
2504 var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O));
2505 rsl.ies[1].body.sysinfo_type := RSL_SYSTEM_INFO_5;
2506 RSL_CCHAN.send(ts_RSL_UD(rsl));
2507
2508 f_exp_err_rep(RSL_ERR_IE_CONTENT);
2509}
2510
Harald Welte93640c62018-02-25 16:59:33 +01002511/***********************************************************************
2512 * IPA CRCX/MDCX/DLCS media stream handling
2513 ***********************************************************************/
2514
Harald Weltea871a382018-02-25 02:03:14 +01002515/* Send IPA DLCX to inactive lchan */
2516function f_TC_ipa_dlcx_not_active(charstring id) runs on ConnHdlr {
Harald Welte1eba3742018-02-25 12:48:14 +01002517 f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, 0), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?),
2518 "IPA DLCX ACK");
Harald Weltea871a382018-02-25 02:03:14 +01002519}
2520testcase TC_ipa_dlcx_not_active() runs on test_CT {
2521 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
2522 f_init(testcasename());
2523 var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_dlcx_not_active), pars);
2524 vc_conn.done;
2525}
Harald Welte68e495b2018-02-25 00:05:57 +01002526
Harald Weltea3f1df92018-02-25 12:49:55 +01002527/* Send IPA CRCX twice to inactive lchan */
2528function f_TC_ipa_crcx_twice_not_active(charstring id) runs on ConnHdlr {
2529 f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?),
2530 "IPA CRCX ACK");
2531 f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_NACK(g_chan_nr, RSL_ERR_RES_UNAVAIL),
2532 "IPA CRCX NACK");
2533}
2534testcase TC_ipa_crcx_twice_not_active() runs on test_CT {
2535 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
2536 f_init(testcasename());
2537 var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_twice_not_active), pars);
2538 vc_conn.done;
2539}
2540
2541/* Regular sequence of CRCX/MDCX/DLCX */
2542function f_TC_ipa_crcx_mdcx_dlcx_not_active(charstring id) runs on ConnHdlr {
2543 f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?),
2544 "IPA CRCX ACK");
2545 var uint32_t remote_ip := f_rnd_int(c_UINT32_MAX);
2546 var uint16_t remote_port := f_rnd_int(c_UINT16_MAX);
2547 var uint7_t rtp_pt2 := f_rnd_int(127);
2548 var uint16_t fake_conn_id := 23; /* we're too lazy to read it out from the CRCX ACK above */
2549 f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2),
2550 tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2),
2551 "IPA MDCX ACK");
2552 f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, fake_conn_id), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?),
2553 "IPA DLCX ACK");
2554}
2555testcase TC_ipa_crcx_mdcx_dlcx_not_active() runs on test_CT {
2556 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
2557 f_init(testcasename());
2558 var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_mdcx_dlcx_not_active), pars);
2559 vc_conn.done;
2560}
2561
Harald Welte3ae11da2018-02-25 13:36:06 +01002562/* Sequence of CRCX, 2x MDCX, DLCX */
2563function f_TC_ipa_crcx_mdcx_mdcx_dlcx_not_active(charstring id) runs on ConnHdlr {
2564 f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?),
2565 "IPA CRCX ACK");
2566 var uint32_t remote_ip := f_rnd_int(c_UINT32_MAX);
2567 var uint16_t remote_port := f_rnd_int(c_UINT16_MAX);
2568 var uint7_t rtp_pt2 := f_rnd_int(127);
2569 var uint16_t fake_conn_id := 23; /* we're too lazy to read it out from the CRCX ACK above */
2570 f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2),
2571 tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2),
2572 "IPA MDCX ACK");
2573 /* Second MDCX */
2574 remote_ip := f_rnd_int(c_UINT32_MAX);
2575 remote_port := f_rnd_int(c_UINT16_MAX);
2576 f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2),
2577 tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2),
2578 "IPA MDCX ACK");
2579 f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, fake_conn_id), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?),
2580 "IPA DLCX ACK");
2581}
2582testcase TC_ipa_crcx_mdcx_mdcx_dlcx_not_active() runs on test_CT {
2583 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
2584 f_init(testcasename());
2585 var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_mdcx_mdcx_dlcx_not_active), pars);
2586 vc_conn.done;
2587}
2588
Harald Welte9912eb52018-02-25 13:30:15 +01002589/* IPA CRCX on SDCCH/4 and SDCCH/8 (doesn't make sense) */
2590function f_TC_ipa_crcx_sdcch_not_active(charstring id) runs on ConnHdlr {
2591 f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_NACK(g_chan_nr, ?),
2592 "IPA CRCX NACK");
2593}
2594testcase TC_ipa_crcx_sdcch_not_active() runs on test_CT {
2595 var ConnHdlrPars pars;
2596 var ConnHdlr vc_conn;
2597 f_init(testcasename());
2598
2599 pars := valueof(t_Pars(t_RslChanNr_SDCCH4(0,1), ts_RSL_ChanMode_SIGN));
2600 vc_conn := f_start_handler(refers(f_TC_ipa_crcx_sdcch_not_active), pars);
2601 vc_conn.done;
2602
2603 pars := valueof(t_Pars(t_RslChanNr_SDCCH8(6,5), ts_RSL_ChanMode_SIGN));
2604 vc_conn := f_start_handler(refers(f_TC_ipa_crcx_sdcch_not_active), pars);
2605 vc_conn.done;
2606}
2607
Harald Weltea3f1df92018-02-25 12:49:55 +01002608
Harald Welte883340c2018-02-28 18:59:29 +01002609/***********************************************************************
2610 * PCU Socket related tests
2611 ***********************************************************************/
2612
2613private function f_TC_pcu_act_req(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr, boolean exp_success)
2614runs on test_CT {
2615 timer T := 3.0;
2616
2617 /* we don't expect any RTS.req before PDCH are active */
2618 T.start;
2619 alt {
2620 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(bts_nr))) {
2621 setverdict(fail, "PCU RTS.req before PDCH active?");
Daniel Willmann17ddd852018-07-05 17:33:20 +02002622 mtc.stop;
Harald Welte883340c2018-02-28 18:59:29 +01002623 }
2624 [] PCU.receive { repeat; }
2625 [] T.timeout { }
2626 }
2627
2628 /* Send PDCH activate request for known PDCH timeslot */
2629 PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, ts_nr)));
2630
2631 /* we now expect RTS.req for this timeslot (only) */
2632 T.start;
2633 alt {
2634 [exp_success] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr))) {
2635 setverdict(pass);
2636 }
2637 [not exp_success] PCU.receive(t_SD_PCUIF(g_pcu_conn_id,
2638 tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr))) {
2639 setverdict(fail, "Unexpected RTS.req for supposedly failing activation");
Daniel Willmann17ddd852018-07-05 17:33:20 +02002640 mtc.stop;
Harald Welte883340c2018-02-28 18:59:29 +01002641 }
2642 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ)) {
2643 setverdict(fail, "RTS.req for wrong TRX/TS");
Daniel Willmann17ddd852018-07-05 17:33:20 +02002644 mtc.stop;
Harald Welte883340c2018-02-28 18:59:29 +01002645 }
2646 [] PCU.receive { repeat; }
2647 [exp_success] T.timeout {
2648 setverdict(fail, "Timeout waiting for PCU RTS.req");
Daniel Willmann17ddd852018-07-05 17:33:20 +02002649 mtc.stop;
Harald Welte883340c2018-02-28 18:59:29 +01002650 }
2651 [not exp_success] T.timeout {
2652 setverdict(pass);
2653 }
2654 }
2655}
2656
2657private function f_TC_pcu_deact_req(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr)
2658runs on test_CT {
2659 timer T := 3.0;
2660
2661 /* Send PDCH activate request for known PDCH timeslot */
2662 PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_DEACT_REQ(bts_nr, trx_nr, ts_nr)));
2663
2664 PCU.clear;
2665 /* we now expect no RTS.req for this timeslot */
2666 T.start;
2667 alt {
2668 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr))) {
2669 setverdict(fail, "Received unexpected PCU RTS.req");
Daniel Willmann17ddd852018-07-05 17:33:20 +02002670 mtc.stop;
Harald Welte883340c2018-02-28 18:59:29 +01002671 }
2672 [] PCU.receive { repeat; }
2673 [] T.timeout {
2674 setverdict(pass);
2675 }
2676 }
2677}
2678
2679/* PDCH activation via PCU socket; check for presence of RTS.req */
2680testcase TC_pcu_act_req() runs on test_CT {
2681 f_init();
2682 f_TC_pcu_act_req(0, 0, 7, true);
2683}
2684
2685/* PDCH activation via PCU socket on non-PDCU timeslot */
2686testcase TC_pcu_act_req_wrong_ts() runs on test_CT {
2687 f_init();
2688 f_TC_pcu_act_req(0, 0, 1, false);
2689}
2690
2691/* PDCH activation via PCU socket on wrong BTS */
2692testcase TC_pcu_act_req_wrong_bts() runs on test_CT {
2693 f_init();
2694 f_TC_pcu_act_req(23, 0, 7, false);
2695}
2696
2697/* PDCH activation via PCU socket on wrong TRX */
2698testcase TC_pcu_act_req_wrong_trx() runs on test_CT {
2699 f_init();
2700 f_TC_pcu_act_req(0, 23, 7, false);
2701}
2702
2703/* PDCH deactivation via PCU socket; check for absence of RTS.req */
2704testcase TC_pcu_deact_req() runs on test_CT {
2705 f_init();
2706 /* Activate PDCH */
2707 f_TC_pcu_act_req(0, 0, 7, true);
2708 f_sleep(1.0);
2709 /* and De-Activate again */
2710 f_TC_pcu_deact_req(0, 0, 7);
2711}
2712
2713/* Attempt to deactivate a PDCH on a non-PDCH timeslot */
2714testcase TC_pcu_deact_req_wrong_ts() runs on test_CT {
2715 f_init();
2716 f_TC_pcu_deact_req(0, 0, 1);
2717}
2718
2719/* Test the PCU->BTS Version and BTS->PCU SI13 handshake */
2720testcase TC_pcu_ver_si13() runs on test_CT {
2721 const octetstring si13 := '00010203040506070909'O;
2722 var PCUIF_send_data sd;
2723 timer T:= 3.0;
2724 f_init();
2725
2726 /* Set SI13 via RSL */
2727 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_13, si13);
2728 PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_TXT_IND(0, PCU_VERSION, "BTS_Test v23")));
2729 T.start;
2730 alt {
2731 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_DATA_IND(0, 0, 0, ?, PCU_IF_SAPI_BCCH))) -> value sd {
2732 if (substr(sd.data.u.data_ind.data, 0, lengthof(si13)) == si13) {
2733 setverdict(pass);
2734 } else {
2735 repeat;
2736 }
2737 }
2738 [] PCU.receive { repeat; }
2739 [] T.timeout {
2740 setverdict(fail, "Timeout waiting for SI13");
Daniel Willmann17ddd852018-07-05 17:33:20 +02002741 mtc.stop;
Harald Welte883340c2018-02-28 18:59:29 +01002742 }
2743 }
2744}
2745
2746private const octetstring c_PCU_DATA := '000102030405060708090a0b0c0d0e0f10111213141516'O;
2747
2748/* helper function to send a PCU DATA.req */
2749private function f_pcu_data_req(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr,
2750 uint8_t block_nr, uint32_t fn, PCUIF_Sapi sapi, octetstring data)
2751runs on test_CT
2752{
2753 PCU.send(t_SD_PCUIF(g_pcu_conn_id,
2754 ts_PCUIF_DATA_REQ(bts_nr, trx_nr, ts_nr, block_nr, fn, sapi, data)));
2755}
2756
2757/* helper function to wait for RTS.ind for given SAPI on given BTS/TRX/TS and then send */
2758private function f_pcu_wait_rts_and_data_req(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr,
2759 PCUIF_Sapi sapi, octetstring data)
2760runs on test_CT
2761{
2762 var PCUIF_send_data sd;
2763
2764 timer T := 3.0;
2765 T.start;
2766 alt {
2767 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id,
2768 tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr, sapi))) -> value sd {
2769 f_pcu_data_req(bts_nr, trx_nr, ts_nr, sd.data.u.rts_req.block_nr,
2770 sd.data.u.rts_req.fn, sapi, data);
2771 }
2772 [] PCU.receive { repeat; }
2773 [] T.timeout {
2774 setverdict(fail, "Timeout waiting for RTS.ind");
Daniel Willmann17ddd852018-07-05 17:33:20 +02002775 mtc.stop;
Harald Welte883340c2018-02-28 18:59:29 +01002776 }
2777 }
2778}
2779
2780/* Send DATA.req on invalid BTS */
2781testcase TC_pcu_data_req_wrong_bts() runs on test_CT {
2782 f_init();
2783 f_TC_pcu_act_req(0, 0, 7, true);
2784 f_pcu_data_req(23, 0, 7, 0, 0, PCU_IF_SAPI_PDTCH, c_PCU_DATA);
2785 /* FIXME: how to check this wasn't actually sent and didn't crash BTS? */
2786 f_sleep(10.0);
2787}
2788
2789/* Send DATA.req on invalid TRX */
2790testcase TC_pcu_data_req_wrong_trx() runs on test_CT {
2791 f_init();
2792 f_TC_pcu_act_req(0, 0, 7, true);
2793 f_pcu_data_req(0, 100, 7, 0, 0, PCU_IF_SAPI_PDTCH, c_PCU_DATA);
2794 /* FIXME: how to check this wasn't actually sent and didn't crash BTS? */
2795 f_sleep(10.0);
2796}
2797
2798/* Send DATA.req on invalid timeslot */
2799testcase TC_pcu_data_req_wrong_ts() runs on test_CT {
2800 f_init();
2801 f_TC_pcu_act_req(0, 0, 7, true);
2802 f_pcu_data_req(0, 0, 70, 0, 0, PCU_IF_SAPI_PDTCH, c_PCU_DATA);
2803 /* FIXME: how to check this wasn't actually sent and didn't crash BTS? */
2804 f_sleep(10.0);
2805}
2806
2807/* Send DATA.req on timeslot that hasn't been activated */
2808testcase TC_pcu_data_req_ts_inactive() runs on test_CT {
2809 f_init();
2810 f_pcu_data_req(0, 0, 7, 0, 0, PCU_IF_SAPI_PDTCH, c_PCU_DATA);
2811 /* FIXME: how to check this wasn't actually sent and didn't crash BTS? */
2812 f_sleep(2.0);
2813}
2814
2815testcase TC_pcu_data_req_pdtch() runs on test_CT {
2816 f_init();
2817 f_TC_pcu_act_req(0, 0, 7, true);
2818 f_pcu_wait_rts_and_data_req(0, 0, 7, PCU_IF_SAPI_PDTCH, c_PCU_DATA);
2819 /* FIXME: how to check this was actually sent */
2820 f_sleep(2.0);
2821}
2822
2823testcase TC_pcu_data_req_ptcch() runs on test_CT {
2824 f_init();
2825 f_TC_pcu_act_req(0, 0, 7, true);
2826 f_pcu_wait_rts_and_data_req(0, 0, 7, PCU_IF_SAPI_PTCCH, c_PCU_DATA);
2827 /* FIXME: how to check this was actually sent */
2828 f_sleep(2.0);
2829}
2830
2831/* Send AGCH from PCU; check it appears on Um side */
2832testcase TC_pcu_data_req_agch() runs on test_CT {
2833 timer T := 3.0;
2834 f_init();
2835 f_init_l1ctl();
2836 f_l1_tune(L1CTL);
2837
2838 f_TC_pcu_act_req(0, 0, 7, true);
2839 f_pcu_data_req(0, 0, 7, 0, 0, PCU_IF_SAPI_AGCH, c_PCU_DATA);
2840
2841 T.start;
2842 alt {
Harald Weltef8df4cb2018-03-10 15:15:08 +01002843 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?, c_PCU_DATA)) {
Harald Welte883340c2018-02-28 18:59:29 +01002844 setverdict(pass);
2845 }
2846 [] L1CTL.receive { repeat; }
2847 [] T.timeout {
2848 setverdict(fail, "Timeout waiting for PCU-originated AGCH block on Um");
Daniel Willmann17ddd852018-07-05 17:33:20 +02002849 mtc.stop;
Harald Welte883340c2018-02-28 18:59:29 +01002850 }
2851 }
2852}
2853
2854/* Send IMM.ASS from PCU for PCH; check it appears on Um side */
2855testcase TC_pcu_data_req_imm_ass_pch() runs on test_CT {
2856 var octetstring imm_ass := f_rnd_octstring(23);
2857 f_init();
2858 f_init_l1ctl();
2859 f_l1_tune(L1CTL);
2860
2861 /* append 3 last imsi digits so BTS can compute pagng group */
2862 var uint32_t fn := f_PCUIF_tx_imm_ass_pch(PCU, g_pcu_conn_id, imm_ass, '123459987'H);
2863
2864 timer T := 0.5;
2865 T.start;
2866 alt {
Harald Weltef8df4cb2018-03-10 15:15:08 +01002867 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?, imm_ass)) {
Harald Welte883340c2018-02-28 18:59:29 +01002868 /* TODO: verify paging group */
2869 setverdict(pass);
2870 }
2871 [] L1CTL.receive { repeat; }
2872 [] T.timeout {
2873 setverdict(fail, "Timeout waiting for PCU-originated AGCH block on Um");
Daniel Willmann17ddd852018-07-05 17:33:20 +02002874 mtc.stop;
Harald Welte883340c2018-02-28 18:59:29 +01002875 }
2876 }
2877}
2878
2879/* Send RACH from Um side, expect it to show up on PCU socket */
2880testcase TC_pcu_rach_content() runs on test_CT {
2881 f_init();
2882 f_init_l1ctl();
2883 f_l1_tune(L1CTL);
2884
2885 var GsmFrameNumber fn_last := 0;
2886 for (var integer i := 0; i < 1000; i := i+1) {
2887 var OCT1 ra := f_rnd_ra_ps();
2888 var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra));
2889 if (fn == fn_last) {
2890 setverdict(fail, "Two RACH in same FN?!?");
Daniel Willmann17ddd852018-07-05 17:33:20 +02002891 mtc.stop;
Harald Welte883340c2018-02-28 18:59:29 +01002892 }
2893 fn_last := fn;
2894
2895 timer T := 2.0;
2896 T.start;
2897 alt {
2898 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RACH_IND(0, oct2int(ra), 0, ?, fn))) {
2899 T.stop;
2900 }
2901 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RACH_IND)) {
2902 setverdict(fail, "Unexpected RACH IND");
Daniel Willmann17ddd852018-07-05 17:33:20 +02002903 mtc.stop;
Harald Welte883340c2018-02-28 18:59:29 +01002904 }
2905 [] PCU.receive { repeat; }
2906 [] T.timeout {
2907 setverdict(fail, "Timeout waiting for RACH IND");
Daniel Willmann17ddd852018-07-05 17:33:20 +02002908 mtc.stop;
Harald Welte883340c2018-02-28 18:59:29 +01002909 }
2910 }
2911 }
2912 setverdict(pass);
2913}
2914
2915private function f_pad_oct(octetstring str, integer len, OCT1 pad) return octetstring {
2916 var integer strlen := lengthof(str);
2917 for (var integer i := 0; i < len-strlen; i := i+1) {
2918 str := str & pad;
2919 }
2920 return str;
2921}
2922
2923/* Send PAGING via RSL, expect it to shw up on PCU socket */
2924testcase TC_pcu_paging_from_rsl() runs on test_CT {
2925 f_init();
2926
2927 for (var integer i := 0; i < 100; i := i+1) {
2928 var MobileL3_CommonIE_Types.MobileIdentityLV mi;
2929 timer T := 3.0;
2930 if (i < 50) {
2931 mi := valueof(ts_MI_TMSI_LV(f_rnd_octstring(4)));
2932 } else {
2933 mi := valueof(ts_MI_IMSI_LV(f_gen_imsi(i)));
2934 }
2935 var octetstring mi_enc_lv := enc_MobileIdentityLV(mi);
2936 var octetstring mi_enc := substr(mi_enc_lv, 1, lengthof(mi_enc_lv)-1);
2937 var octetstring t_mi_lv := f_pad_oct(mi_enc_lv, 9, '00'O);
2938
2939 /* Send RSL PAGING COMMAND */
2940 RSL_CCHAN.send(ts_RSL_UD(ts_RSL_PAGING_CMD(mi_enc, i mod 4)));
2941 T.start;
2942 alt {
2943 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_PAG_REQ(0, t_mi_lv))) {
2944 }
2945 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_PAG_REQ)) {
2946 setverdict(fail, "Unexpected PAGING REQ");
Daniel Willmann17ddd852018-07-05 17:33:20 +02002947 mtc.stop;
Harald Welte883340c2018-02-28 18:59:29 +01002948 }
2949 [] PCU.receive { repeat; }
2950 [] T.timeout {
2951 setverdict(fail, "Timeout waiting for PAGING REQ");
Daniel Willmann17ddd852018-07-05 17:33:20 +02002952 mtc.stop;
Harald Welte883340c2018-02-28 18:59:29 +01002953 }
2954 }
2955 }
2956 setverdict(pass);
2957}
2958
Harald Welte3d04ae62018-04-04 20:29:05 +02002959/***********************************************************************
Harald Welte9bbbfb52018-04-05 09:33:19 +02002960 * Osmocom Style Dynamic Timeslot Support
Harald Welte3d04ae62018-04-04 20:29:05 +02002961 ***********************************************************************/
2962
2963private function f_dyn_osmo_pdch_act(integer pcu_conn_id, integer bts_nr, integer trx_nr)
2964runs on ConnHdlr {
2965 var PCUIF_send_data sd;
2966 /* Expect BTS to immediately acknowledge activation as PDCH */
2967 PCU.clear;
2968 f_rsl_chan_act(g_pars.chan_mode);
2969 /* expect INFO_IND on PCU interface listing TS as PDCH */
2970 alt {
2971 [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(bts_nr, ?))) -> value sd {
2972 if (substr(sd.data.u.info_ind.trx[trx_nr].pdch_mask, g_chan_nr.tn, 1) != '1'B) {
2973 setverdict(fail, "PCUIF_INFO_IND PDCH_MASK not '1' after PDCH ACT");
Daniel Willmann17ddd852018-07-05 17:33:20 +02002974 mtc.stop;
Harald Welte3d04ae62018-04-04 20:29:05 +02002975 }
2976 }
2977 [] PCU.receive { repeat; }
2978 }
2979 /* try to activate this PDCH from the PCU point of view */
2980 PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, g_chan_nr.tn)));
2981 /* FIXME: is there a response? */
2982}
2983
2984private function f_dyn_osmo_pdch_deact(integer pcu_conn_id, integer bts_nr, integer trx_nr)
2985runs on ConnHdlr {
2986 var PCUIF_send_data sd;
2987 /* Send RSL CHAN REL (deactivate) */
2988 PCU.clear;
2989 RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr));
2990 /* expect BTS to ask PCU to deactivate the channel */
2991 alt {
2992 [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(bts_nr, ?))) -> value sd {
2993 if (substr(sd.data.u.info_ind.trx[trx_nr].pdch_mask, g_chan_nr.tn, 1) != '0'B) {
2994 setverdict(fail, "PCUIF_INFO_IND PDCH_MASK not '0' after PDCH DEACT");
Daniel Willmann17ddd852018-07-05 17:33:20 +02002995 mtc.stop;
Harald Welte3d04ae62018-04-04 20:29:05 +02002996 }
2997 }
2998 [] PCU.receive { repeat; }
2999 }
3000 /* Emulate PCU asking BTS to deactivate PDCH */
3001 PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_DEACT_REQ(bts_nr, trx_nr, g_chan_nr.tn)));
3002 alt {
3003 [] RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr)) {
3004 setverdict(pass);
3005 }
3006 [] RSL.receive { repeat; }
3007 }
3008}
3009
3010/* Activate Osmocom-style dynamic PDCH from BSC side */
3011function f_TC_dyn_osmo_pdch_act_deact(charstring id) runs on ConnHdlr {
3012 var PCUIF_Message first_info;
3013 var integer ts_nr := g_chan_nr.tn;
3014 var integer trx_nr := 0;
3015 var integer bts_nr := 0;
3016 var integer pcu_conn_id := -1;
3017
3018 f_init_pcu(PCU, id, pcu_conn_id, first_info);
3019
3020 f_dyn_osmo_pdch_act(pcu_conn_id, bts_nr, trx_nr);
3021 f_sleep(3.0);
3022 f_dyn_osmo_pdch_deact(pcu_conn_id, bts_nr, trx_nr);
3023 setverdict(pass);
3024}
3025testcase TC_dyn_osmo_pdch_act_deact() runs on test_CT {
3026 var ConnHdlrPars pars;
3027 var ConnHdlr vc_conn;
3028 f_init(testcasename());
3029
3030 pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN));
3031 vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_act_deact), pars, true);
3032 vc_conn.done;
3033}
3034
3035/* send a RF CHAN REL for PDCH on an osmocom dynamci PDCH that's already inactive */
3036function f_TC_dyn_osmo_pdch_unsol_deact(charstring id) runs on ConnHdlr {
3037 var PCUIF_Message first_info;
Harald Welte3d04ae62018-04-04 20:29:05 +02003038 var integer pcu_conn_id := -1;
3039
3040 f_init_pcu(PCU, id, pcu_conn_id, first_info);
3041
Neels Hofmeyr9c50ca52018-05-08 20:37:54 +02003042 RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr));
3043 /* since the lchan is already released, we don't expect any PCU changes, just a rel ack. */
3044 RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr));
Harald Welte3d04ae62018-04-04 20:29:05 +02003045 setverdict(pass);
3046}
3047testcase TC_dyn_osmo_pdch_unsol_deact() runs on test_CT {
3048 var ConnHdlrPars pars;
3049 var ConnHdlr vc_conn;
3050 f_init(testcasename());
3051
3052 pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN));
3053 vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_unsol_deact), pars, true);
3054 vc_conn.done;
3055}
3056
3057/* try to RSL CHAN ACT a PDCH on an osmocom-style PDCH that's already active */
3058function f_TC_dyn_osmo_pdch_double_act(charstring id) runs on ConnHdlr {
3059 var PCUIF_Message first_info;
3060 var integer ts_nr := g_chan_nr.tn;
3061 var integer trx_nr := 0;
3062 var integer bts_nr := 0;
3063 var integer pcu_conn_id := -1;
3064
3065 f_init_pcu(PCU, id, pcu_conn_id, first_info);
3066
3067 f_dyn_osmo_pdch_act(pcu_conn_id, bts_nr, trx_nr);
Neels Hofmeyrdf936a22018-05-08 22:07:57 +02003068 /* Send a second Chan Activ and expect it to be NACKed */
3069 f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_NACK(g_chan_nr),
3070 "RSL CHAN ACT NACK");
Harald Welte3d04ae62018-04-04 20:29:05 +02003071 setverdict(pass);
3072}
3073testcase TC_dyn_osmo_pdch_double_act() runs on test_CT {
3074 var ConnHdlrPars pars;
3075 var ConnHdlr vc_conn;
3076 f_init(testcasename());
3077
3078 pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN));
3079 vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_double_act), pars, true);
3080 vc_conn.done;
3081}
3082
3083/* try to RSL CHAN ACT a TCH/F on an osmocom-style PDCH */
3084function f_TC_dyn_osmo_pdch_tchf_act(charstring id) runs on ConnHdlr {
3085 var PCUIF_Message first_info;
3086 var integer ts_nr := g_chan_nr.tn;
3087 var integer trx_nr := 0;
3088 var integer bts_nr := 0;
3089 var integer pcu_conn_id := -1;
3090 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(g_chan_nr.tn));
3091
3092 /* register for the TCH/F channel number */
3093 f_rslem_register(0, chan_nr);
3094
3095 f_init_pcu(PCU, id, pcu_conn_id, first_info);
3096
3097 f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_ACK(chan_nr),
3098 "RSL CHAN ACT");
3099 setverdict(pass);
3100}
3101testcase TC_dyn_osmo_pdch_tchf_act() runs on test_CT {
3102 var ConnHdlrPars pars;
3103 var ConnHdlr vc_conn;
3104 f_init(testcasename());
3105
3106 pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN));
3107 vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_tchf_act), pars, true);
3108 vc_conn.done;
3109}
3110
3111/* try to RSL CHAN ACT the TCH/H on an osmocom-style PDCH */
3112function f_TC_dyn_osmo_pdch_tchh_act(charstring id) runs on ConnHdlr {
3113 var PCUIF_Message first_info;
3114 var integer ts_nr := g_chan_nr.tn;
3115 var integer trx_nr := 0;
3116 var integer bts_nr := 0;
3117 var integer pcu_conn_id := -1;
3118 var RslChannelNr chan_nr[2] := { valueof(t_RslChanNr_Lm(g_chan_nr.tn, 0)),
3119 valueof(t_RslChanNr_Lm(g_chan_nr.tn, 1)) };
3120
3121 /* register for the TCH/H channel numbers */
3122 f_rslem_register(0, chan_nr[0]);
3123 f_rslem_register(0, chan_nr[1]);
3124
3125 f_init_pcu(PCU, id, pcu_conn_id, first_info);
3126
3127 f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr[1], g_pars.chan_mode),
3128 tr_RSL_CHAN_ACT_ACK(chan_nr[1]), "RSL CHAN ACT [1]");
3129 f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr[0], g_pars.chan_mode),
3130 tr_RSL_CHAN_ACT_ACK(chan_nr[0]), "RSL CHAN ACT [0]");
3131 setverdict(pass);
3132}
3133testcase TC_dyn_osmo_pdch_tchh_act() runs on test_CT {
3134 var ConnHdlrPars pars;
3135 var ConnHdlr vc_conn;
3136 f_init(testcasename());
3137
3138 pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN));
3139 vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_tchh_act), pars, true);
3140 vc_conn.done;
3141}
3142
Harald Welte9bbbfb52018-04-05 09:33:19 +02003143/***********************************************************************
3144 * IPA Style Dynamic Timeslot Support
3145 ***********************************************************************/
3146
3147private function f_dyn_ipa_pdch_act(integer pcu_conn_id, integer bts_nr, integer trx_nr)
3148runs on ConnHdlr {
3149 var PCUIF_send_data sd;
3150 /* Expect BTS to immediately acknowledge activation as PDCH */
3151 PCU.clear;
3152 RSL.send(ts_RSL_IPA_PDCH_ACT(g_chan_nr));
3153 /* expect INFO_IND on PCU interface listing TS as PDCH */
3154 alt {
3155 [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(bts_nr, ?))) -> value sd {
3156 if (substr(sd.data.u.info_ind.trx[trx_nr].pdch_mask, g_chan_nr.tn, 1) != '1'B) {
3157 setverdict(fail, "PCUIF_INFO_IND PDCH_MASK not '1' after PDCH ACT");
Daniel Willmann17ddd852018-07-05 17:33:20 +02003158 mtc.stop;
Harald Welte9bbbfb52018-04-05 09:33:19 +02003159 }
3160 }
3161 [] PCU.receive { repeat; }
3162 }
3163 /* try to activate this PDCH from the PCU point of view */
3164 PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, g_chan_nr.tn)));
3165 /* FIXME: is there a response? */
3166
3167 RSL.receive(tr_RSL_IPA_PDCH_ACT_ACK(g_chan_nr, ?));
3168}
3169
3170private function f_dyn_ipa_pdch_deact(integer pcu_conn_id, integer bts_nr, integer trx_nr)
3171runs on ConnHdlr {
3172 var PCUIF_send_data sd;
3173 /* Send RSL CHAN REL (deactivate) */
3174 RSL.send(ts_RSL_IPA_PDCH_DEACT(g_chan_nr));
3175 PCU.clear;
3176 /* expect BTS to ask PCU to deactivate the channel */
3177 alt {
3178 [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(bts_nr, ?))) -> value sd {
3179 if (substr(sd.data.u.info_ind.trx[trx_nr].pdch_mask, g_chan_nr.tn, 1) != '0'B) {
3180 setverdict(fail, "PCUIF_INFO_IND PDCH_MASK not '0' after PDCH DEACT");
Daniel Willmann17ddd852018-07-05 17:33:20 +02003181 mtc.stop;
Harald Welte9bbbfb52018-04-05 09:33:19 +02003182 }
3183 }
3184 [] PCU.receive { repeat; }
3185 }
3186 /* Emulate PCU asking BTS to deactivate PDCH */
3187 PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_DEACT_REQ(bts_nr, trx_nr, g_chan_nr.tn)));
3188 alt {
3189 [] RSL.receive(tr_RSL_IPA_PDCH_DEACT_ACK(g_chan_nr)) {
3190 setverdict(pass);
3191 }
3192 [] RSL.receive { repeat; }
3193 }
3194}
3195
3196/* Activate and de-activate an IPA-style dynamic TCH/F + PDCH */
3197function f_TC_dyn_ipa_pdch_act_deact(charstring id) runs on ConnHdlr {
3198 var PCUIF_Message first_info;
3199 var integer ts_nr := g_chan_nr.tn;
3200 var integer trx_nr := 0;
3201 var integer bts_nr := 0;
3202 var integer pcu_conn_id := -1;
3203
3204 f_init_pcu(PCU, id, pcu_conn_id, first_info);
3205
3206 f_dyn_ipa_pdch_act(pcu_conn_id, bts_nr, trx_nr);
3207 f_sleep(3.0);
3208 f_dyn_ipa_pdch_deact(pcu_conn_id, bts_nr, trx_nr);
3209
3210 setverdict(pass);
3211
3212}
3213testcase TC_dyn_ipa_pdch_act_deact() runs on test_CT {
3214 var ConnHdlrPars pars;
3215 var ConnHdlr vc_conn;
3216 f_init();
3217
3218 pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN));
3219 vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_act_deact), pars, true);
3220 vc_conn.done;
3221}
3222
3223/* try to RSL CHAN ACT a TCH/F on an IPA-style PDCH */
3224function f_TC_dyn_ipa_pdch_tchf_act(charstring id) runs on ConnHdlr {
3225 var PCUIF_Message first_info;
3226 var integer ts_nr := g_chan_nr.tn;
3227 var integer trx_nr := 0;
3228 var integer bts_nr := 0;
3229 var integer pcu_conn_id := -1;
3230
3231 f_init_pcu(PCU, id, pcu_conn_id, first_info);
3232
3233 f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_ACK(g_chan_nr),
3234 "RSL CHAN ACT");
3235 f_rsl_transceive(ts_RSL_RF_CHAN_REL(g_chan_nr), tr_RSL_RF_CHAN_REL_ACK(g_chan_nr),
3236 "RF CHAN REL", true);
3237 setverdict(pass);
3238}
3239testcase TC_dyn_ipa_pdch_tchf_act() runs on test_CT {
3240 var ConnHdlrPars pars;
3241 var ConnHdlr vc_conn;
3242 f_init(testcasename());
3243
3244 pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN));
3245 vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_tchf_act), pars, true);
3246 vc_conn.done;
3247}
3248
3249/* Activate IPA style dyn PDCH as TCH/F and then illegally try to activate it as PDCH, too */
3250function f_TC_dyn_ipa_pdch_tchf_act_pdch_act_nack(charstring id) runs on ConnHdlr {
3251 var PCUIF_Message first_info;
3252 var integer ts_nr := g_chan_nr.tn;
3253 var integer trx_nr := 0;
3254 var integer bts_nr := 0;
3255 var integer pcu_conn_id := -1;
3256
3257 f_init_pcu(PCU, id, pcu_conn_id, first_info);
3258
3259 f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_ACK(g_chan_nr),
3260 "RSL CHAN ACT");
3261
3262 RSL.send(ts_RSL_IPA_PDCH_ACT(g_chan_nr));
3263 alt {
3264 [] RSL.receive(tr_RSL_IPA_PDCH_ACT_NACK(g_chan_nr, ?));
3265 [] RSL.receive(tr_RSL_IPA_PDCH_ACT_ACK(g_chan_nr, ?)) {
3266 setverdict(fail, "Unexpected PDCH ACT ACK");
Daniel Willmann17ddd852018-07-05 17:33:20 +02003267 mtc.stop;
Harald Welte9bbbfb52018-04-05 09:33:19 +02003268 }
3269 [] RSL.receive { repeat; }
3270 }
3271
3272 f_rsl_transceive(ts_RSL_RF_CHAN_REL(g_chan_nr), tr_RSL_RF_CHAN_REL_ACK(g_chan_nr),
3273 "RF CHAN REL", true);
3274 setverdict(pass);
3275}
3276testcase TC_dyn_ipa_pdch_tchf_act_pdch_act_nack() runs on test_CT {
3277 var ConnHdlrPars pars;
3278 var ConnHdlr vc_conn;
3279 f_init(testcasename());
3280
3281 pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN));
3282 vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_tchf_act_pdch_act_nack), pars, true);
3283 vc_conn.done;
3284}
3285
3286/* try to RSL CHAN ACT a TCH/F on an IPA-style PDCH that's already in PDCH mode; expect NACK */
3287function f_TC_dyn_ipa_pdch_act_tchf_act_nack(charstring id) runs on ConnHdlr {
3288 var PCUIF_Message first_info;
3289 var integer ts_nr := g_chan_nr.tn;
3290 var integer trx_nr := 0;
3291 var integer bts_nr := 0;
3292 var integer pcu_conn_id := -1;
3293
3294 /* register for the TCH/F channel number */
3295 f_rslem_register(0, g_chan_nr);
3296
3297 f_init_pcu(PCU, id, pcu_conn_id, first_info);
3298
3299 f_dyn_ipa_pdch_act(pcu_conn_id, bts_nr, trx_nr);
3300
3301 f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_NACK(g_chan_nr),
3302 "RSL CHAN ACT");
3303
3304 f_dyn_ipa_pdch_deact(pcu_conn_id, bts_nr, trx_nr);
3305
3306 setverdict(pass);
3307}
3308testcase TC_dyn_ipa_pdch_act_tchf_act_nack() runs on test_CT {
3309 var ConnHdlrPars pars;
3310 var ConnHdlr vc_conn;
3311 f_init(testcasename());
3312
3313 pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN));
3314 vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_act_tchf_act_nack), pars, true);
3315 vc_conn.done;
3316}
3317
3318
Harald Welte0472ab42018-03-12 15:02:26 +01003319/***********************************************************************
3320 * LAPDm / RLL related
3321 ***********************************************************************/
3322
3323private function f_tx_lapdm(template (value) LapdmFrame l,
3324 template (value) RslLinkId link_id) runs on ConnHdlr {
3325 var octetstring l2 := enc_LapdmFrame(valueof(l));
3326 if (valueof(link_id.c) == SACCH) {
3327 /* prepend dummy L1 header */
Pau Espin Pedrola0fb42a2018-10-10 15:56:39 +02003328 var L1ctlDataReq l1hl2 := {
3329 l1header := valueof(ts_SacchL1Header(g_pars.l1_pars.ms_power_level, false, g_pars.l1_pars.ms_actual_ta)),
3330 l2_payload := f_pad_oct(l2, 21, '2B'O)
3331 }
3332 L1CTL.send(ts_L1CTL_DATA_REQ_SACCH(g_chan_nr, link_id, l1hl2));
3333 } else {
3334 /* If required, pad L2 frame with constant 0x2b filling */
3335 l2 := f_pad_oct(l2, 23, '2B'O);
3336
3337 log("encoding ", l, " to ", l2);
3338 L1CTL.send(ts_L1CTL_DATA_REQ(g_chan_nr, link_id, l2));
Harald Welte0472ab42018-03-12 15:02:26 +01003339 }
Harald Welte0472ab42018-03-12 15:02:26 +01003340}
3341
3342type record RllTestCase {
3343 uint3_t sapi,
3344 RslLinkId link_id,
3345 octetstring l3,
3346 boolean exp
3347}
3348type record of RllTestCase RllTestCases;
3349template RllTestCase t_EITC(uint3_t sapi, RslLinkId id, octetstring l3, boolean exp) := {
3350 sapi := sapi,
3351 link_id := id,
3352 l3 := l3,
3353 exp := exp
3354}
3355
3356/* execute the same callback function with a set of different parameters (tcs) on a
3357 * variety of logical channels */
3358private function f_rll_testmatrix(RllTestCases tcs, void_fn fn) runs on test_CT {
3359 var ConnHdlrPars pars;
3360 var ConnHdlr vc_conn;
3361 f_init(testcasename());
3362
3363 /* test on each of the channels we have */
3364 for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i+1) {
3365 pars := valueof(t_Pars(g_AllChanTypes[i], ts_RSL_ChanMode_SIGN));
3366
3367 /* test each of the test cases on the current channel */
3368 for (var integer j := 0; j < sizeof(tcs); j := j+1) {
3369 pars.spec.rll := tcs[j];
3370 log(testcasename(), ": XXX Starting ", tcs[j] , " on ", g_AllChanTypes[i]);
3371 vc_conn := f_start_handler(fn, pars);
3372 vc_conn.done;
3373 }
3374 }
3375
3376 f_shutdown();
3377}
3378
3379/* test if SABM on Um triggers EST IND (TS 48.058 3.1) */
3380private function f_TC_rll_est_ind(charstring id) runs on ConnHdlr {
3381 var RllTestCase tc := g_pars.spec.rll;
3382 timer T := 3.0;
3383
3384 f_l1_tune(L1CTL);
3385 RSL.clear;
3386
3387 /* activate the logical channel */
3388 f_est_dchan();
3389 L1CTL.clear;
3390
3391 f_tx_lapdm(ts_LAPDm_SABM(tc.sapi, cr_MO_CMD, true, tc.l3), tc.link_id);
3392 T.start;
3393 alt {
3394 [tc.l3 != ''O] RSL.receive(tr_RSL_EST_IND(g_chan_nr, tc.link_id, tc.l3)) {
3395 if (tc.exp) {
3396 setverdict(pass);
3397 } else {
3398 setverdict(fail, "Unexpected EST IND with L3 in ", tc);
Daniel Willmann17ddd852018-07-05 17:33:20 +02003399 mtc.stop;
Harald Welte0472ab42018-03-12 15:02:26 +01003400 }
3401 }
3402 [tc.l3 == ''O] RSL.receive(tr_RSL_EST_IND_NOL3(g_chan_nr, tc.link_id)) {
3403 if (tc.exp) {
3404 setverdict(pass);
3405 } else {
3406 setverdict(fail, "Unexpected EST IND without L3 in ", tc);
Daniel Willmann17ddd852018-07-05 17:33:20 +02003407 mtc.stop;
Harald Welte0472ab42018-03-12 15:02:26 +01003408 }
3409 }
Vadim Yanitskiy35677872018-10-04 17:30:21 +07003410 /* We also expect to receive the measurements */
3411 [] as_meas_res(verify_meas := false);
Harald Welte0472ab42018-03-12 15:02:26 +01003412 [tc.exp] T.timeout {
3413 setverdict(fail, "Timeout waiting for EST IND");
Daniel Willmann17ddd852018-07-05 17:33:20 +02003414 mtc.stop;
Harald Welte0472ab42018-03-12 15:02:26 +01003415 }
3416 [not tc.exp] T.timeout {
3417 setverdict(pass);
3418 }
3419 }
3420
3421 f_rsl_chan_deact();
3422 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
3423 f_rslem_unregister(0, g_chan_nr);
3424}
3425testcase TC_rll_est_ind() runs on test_CT {
3426 var RllTestCases tcs := {
Harald Welte7aacbbf2018-05-09 16:56:41 +02003427 /* SAPI0 establishment (contention resolution) */
Harald Welte0472ab42018-03-12 15:02:26 +01003428 valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), '01020304'O, true)),
Harald Welte7aacbbf2018-05-09 16:56:41 +02003429 /* normal SAPI0 establishment */
3430 valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), ''O, true)),
Harald Welte0472ab42018-03-12 15:02:26 +01003431 /* SAPI 3 doesn't support contention resolution */
3432 valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), '01020304'O, false)),
3433 valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), '01020304'O, false)),
3434 /* normal SAPI3 establishment on main DCCH */
3435 valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), ''O, true)),
3436 /* normal SAPI3 establishment on SACCH */
3437 valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), ''O, true))
3438 };
3439 f_rll_testmatrix(tcs, refers(f_TC_rll_est_ind));
3440}
3441
3442/* test if RLL EST REQ trigeres SABM on Um; UA on Um triggers EST CONF (TS 48.058 3.2) */
3443private function f_TC_rll_est_req(charstring id) runs on ConnHdlr {
3444 var RllTestCase tc := g_pars.spec.rll;
3445 var L1ctlDlMessage dl;
3446 timer T := 3.0;
3447
3448 f_l1_tune(L1CTL);
3449 RSL.clear;
3450
3451 /* activate the logical channel */
3452 f_est_dchan();
3453 L1CTL.clear;
3454
3455 /* Send a RSL EST REQ for SAPI3 on main DCCH */
3456 RSL.send(ts_RSL_EST_REQ(g_chan_nr, tc.link_id));
3457 T.start;
3458 alt {
3459 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, ?)) -> value dl {
3460 var LapdmFrame lapdm;
3461 var octetstring l2 := dl.payload.data_ind.payload;
3462 if (dl.dl_info.link_id.c == SACCH) {
3463 /* remove L1 header */
3464 l2 := substr(l2, 2, lengthof(l2)-2);
3465 }
3466 lapdm.ab := dec_LapdmFrameAB(l2);
3467 if (match(lapdm, tr_LAPDm_SABM(tc.sapi, cr_MT_CMD, true, ''O))) {
3468 setverdict(pass);
3469 } else {
3470 repeat;
3471 }
3472 }
3473 [] L1CTL.receive { repeat; }
3474 [] T.timeout {
3475 setverdict(fail, "Timeout waiting for SABM");
Daniel Willmann17ddd852018-07-05 17:33:20 +02003476 mtc.stop;
Harald Welte0472ab42018-03-12 15:02:26 +01003477 }
3478 }
3479
3480 f_rsl_chan_deact();
3481 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
3482 f_rslem_unregister(0, g_chan_nr);
3483}
3484testcase TC_rll_est_req_DCCH_3() runs on test_CT {
3485 var RllTestCases tcs := {
3486 /* normal SAPI3 establishment on main DCCH */
3487 valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), ''O, true))//,
3488 };
3489 f_rll_testmatrix(tcs, refers(f_TC_rll_est_req));
3490}
3491testcase TC_rll_est_req_ACCH_3() runs on test_CT {
3492 var RllTestCases tcs := {
3493 /* normal SAPI3 establishment on SACCH */
3494 valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), ''O, true))
3495 }
3496 f_rll_testmatrix(tcs, refers(f_TC_rll_est_req));
3497}
3498
3499/* altstep to receive a LAPDm frame matching the given template */
3500private altstep as_l1_exp_lapdm(template LapdmFrame exp) runs on ConnHdlr {
3501 var L1ctlDlMessage dl;
3502 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, ?)) -> value dl {
3503 var LapdmFrame lapdm;
3504 var octetstring l2 := dl.payload.data_ind.payload;
3505 if (dl.dl_info.link_id.c == SACCH) {
3506 /* remove L1 header */
3507 l2 := substr(l2, 2, lengthof(l2)-2);
3508 }
3509 if (ischosen(exp.ab)) {
3510 lapdm.ab := dec_LapdmFrameAB(l2);
3511 } else if (ischosen(exp.b4)) {
3512 lapdm.b4 := dec_LapdmFrameB4(l2);
3513 } else if (ischosen(exp.bbis)) {
3514 lapdm.bbis := dec_LapdmFrameBbis(l2);
3515 }
3516 log("Rx LAPDm ", lapdm);
3517 if (match(lapdm, exp)) {
3518 setverdict(pass);
3519 } else {
3520 repeat;
3521 }
3522 }
3523 [] L1CTL.receive { repeat; }
3524}
3525private function f_l1_exp_lapdm(template LapdmFrame exp, float t := 3.0) runs on ConnHdlr {
3526 timer T := t;
3527 T.start;
3528 alt {
3529 [] T.timeout {
3530 setverdict(fail, "Timeout waiting for LAPDm ", exp);
Daniel Willmann17ddd852018-07-05 17:33:20 +02003531 mtc.stop;
Harald Welte0472ab42018-03-12 15:02:26 +01003532 }
3533 [] as_l1_exp_lapdm(exp);
3534 }
3535}
3536
3537/* establish one Radio Link Layer via SABM -> UA. Use l3 for contention resolution */
3538private function f_est_rll_mo(uint3_t sapi, RslLinkId link_id, octetstring l3) runs on ConnHdlr {
3539 /* send SABM from MS -> BTS */
3540 f_tx_lapdm(ts_LAPDm_SABM(sapi, cr_MO_CMD, true, l3), link_id);
3541 /* expect RLL EST IND on Abis */
3542 alt {
3543 [l3 != ''O] RSL.receive(tr_RSL_EST_IND(g_chan_nr, link_id, l3));
3544 [l3 == ''O] RSL.receive(tr_RSL_EST_IND_NOL3(g_chan_nr, link_id));
3545 [] RSL.receive(tr_RSL_ERROR_IND(g_chan_nr, link_id, ?)) {
3546 setverdict(fail, "Failing due to RSL_ERROR_IND");
Daniel Willmann17ddd852018-07-05 17:33:20 +02003547 mtc.stop;
Harald Welte0472ab42018-03-12 15:02:26 +01003548 }
3549 [] RSL.receive { repeat; }
3550 }
3551 /* expect UA from BTS -> MS */
3552 f_l1_exp_lapdm(tr_LAPDm_UA(sapi, cr_MT_RSP, true, l3));
3553}
3554
3555/* test if DISC on Um triggers RLL REL IND (TS 48.058 3.3) */
3556private function f_TC_rll_rel_ind(charstring id) runs on ConnHdlr {
3557 var RllTestCase tc := g_pars.spec.rll;
3558
3559 f_l1_tune(L1CTL);
3560 RSL.clear;
3561
3562 /* activate the logical channel */
3563 f_est_dchan();
3564 L1CTL.clear;
3565
3566 /* first establish the link-layer */
3567 f_est_rll_mo(tc.sapi, tc.link_id, tc.l3);
3568
3569 /* then send the DISC */
3570 f_tx_lapdm(ts_LAPDm_DISC(tc.sapi, cr_MO_CMD, true), tc.link_id);
3571 /* ... and expect the REL IND on the RSL side */
3572 alt {
3573 [] RSL.receive(tr_RSL_REL_IND(g_chan_nr, tc.link_id)) {
3574 setverdict(pass);
3575 }
Vadim Yanitskiy35677872018-10-04 17:30:21 +07003576 /* We also expect to receive the measurements */
3577 [] as_meas_res(verify_meas := false);
Harald Welte0472ab42018-03-12 15:02:26 +01003578 }
3579
3580 /* release the channel */
3581 f_rsl_chan_deact();
3582 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
3583 f_rslem_unregister(0, g_chan_nr);
3584}
3585testcase TC_rll_rel_ind_DCCH_0() runs on test_CT {
3586 var RllTestCases tcs := {
3587 valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), '01020304'O, true))
3588 };
3589 f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind));
3590}
3591
3592testcase TC_rll_rel_ind_ACCH_0() runs on test_CT {
3593 var RllTestCases tcs := {
3594 valueof(t_EITC(0, valueof(ts_RslLinkID_SACCH(0)), ''O, true))
3595 };
3596 f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind));
3597}
3598testcase TC_rll_rel_ind_DCCH_3() runs on test_CT {
3599 var RllTestCases tcs := {
3600 valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), ''O, true))
3601 };
3602 f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind));
3603}
3604testcase TC_rll_rel_ind_ACCH_3() runs on test_CT {
3605 var RllTestCases tcs := {
3606 valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), ''O, true))
3607 };
3608 f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind));
3609}
3610
3611/* test if RLL REL REQ triggers DISC on Um; UA/DM triggers RLL REL CONF (TS 48.058 3.4) */
3612private function f_TC_rll_rel_req(charstring id) runs on ConnHdlr {
3613 var RllTestCase tc := g_pars.spec.rll;
3614 f_l1_tune(L1CTL);
3615 RSL.clear;
3616
3617 /* activate the logical channel */
3618 f_est_dchan();
3619 L1CTL.clear;
3620
3621 /* first establish the link-layer */
3622 f_est_rll_mo(tc.sapi, tc.link_id, tc.l3);
3623
3624 /* then send the REL REQ via RSL */
3625 RSL.send(ts_RSL_REL_REQ(g_chan_nr, tc.link_id, RSL_REL_MODE_NORMAL));
3626 /* ... and expect the DISC on the Um side */
3627 alt {
Harald Weltebc6199f2018-05-10 19:38:18 +02003628 [] as_l1_exp_lapdm(tr_LAPDm_DISC(tc.sapi, cr_MT_CMD, true)) {
Harald Welte0472ab42018-03-12 15:02:26 +01003629 /* FIXME: send a UA in resposne to the DISC */
3630 }
3631 }
3632
3633 /* release the channel */
3634 f_rsl_chan_deact();
3635 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
3636 f_rslem_unregister(0, g_chan_nr);
3637}
3638testcase TC_rll_rel_req() runs on test_CT {
3639 var RllTestCases tcs := {
3640 valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), '01020304'O, true)),
3641 valueof(t_EITC(0, valueof(ts_RslLinkID_SACCH(0)), ''O, true)),
3642 valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), ''O, true)),
3643 valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), ''O, true))
3644 };
3645 f_rll_testmatrix(tcs, refers(f_TC_rll_rel_req));
3646}
3647
3648/* test if RLL DATA REQ triggers I-frames on Um (TS 48.058 3.5) */
3649testcase TC_rll_data_req() runs on test_CT {
3650}
3651
3652/* test if I-frames on Um trigger RLL DATA IND (TS 48.058 3.6) */
3653testcase TC_rll_data_ind() runs on test_CT {
3654}
3655
3656/* test if RLL UNIT DATA REQ triggers UI-frame on Um (TS 48.058 3.7) */
3657private function f_TC_rll_ud_req(charstring id) runs on ConnHdlr {
3658 var RllTestCase tc := g_pars.spec.rll;
3659
3660 f_l1_tune(L1CTL);
3661 RSL.clear;
3662
3663 f_est_dchan();
3664 L1CTL.clear;
3665
3666 /* Send UNITDATA REQ on RSL side */
3667 RSL.send(ts_RSL_UNITDATA_REQ(g_chan_nr, tc.link_id, tc.l3));
3668 /* Expect it to arrive on the other side */
3669 if (tc.link_id.c == SACCH) {
Harald Weltee613f962018-04-18 22:38:16 +02003670 f_l1_exp_lapdm(tr_LAPDm_B4_UI(tc.sapi, cr_MT_CMD, tc.l3));
Harald Welte0472ab42018-03-12 15:02:26 +01003671 } else {
Harald Weltee613f962018-04-18 22:38:16 +02003672 f_l1_exp_lapdm(tr_LAPDm_UI(tc.sapi, cr_MT_CMD, tc.l3));
Harald Welte0472ab42018-03-12 15:02:26 +01003673 }
3674
3675 /* release the channel */
3676 f_rsl_chan_deact();
3677 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
3678 f_rslem_unregister(0, g_chan_nr);
3679}
3680testcase TC_rll_unit_data_req_DCCH() runs on test_CT {
3681 var octetstring l3 := f_rnd_octstring(15);
3682 var RllTestCases tcs := {
3683 valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), l3, true)),
3684 valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), l3, true))
3685 };
3686 f_rll_testmatrix(tcs, refers(f_TC_rll_ud_req));
3687}
3688testcase TC_rll_unit_data_req_ACCH() runs on test_CT {
3689 var octetstring l3 := f_rnd_octstring(19);
3690 var RllTestCases tcs := {
3691 valueof(t_EITC(0, valueof(ts_RslLinkID_SACCH(0)), l3, true)),
3692 valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), l3, true))
3693 };
3694 f_rll_testmatrix(tcs, refers(f_TC_rll_ud_req));
3695}
3696
3697/* test if UI-frames on Um trigger RLL UNIT DATA IND (TS 48.058 3.8) */
3698private function f_TC_rll_ud_ind(charstring id) runs on ConnHdlr {
3699 var RllTestCase tc := g_pars.spec.rll;
3700
3701 f_l1_tune(L1CTL);
3702 RSL.clear;
3703
3704 f_est_dchan();
3705 L1CTL.clear;
3706
3707 /* Send LAPDm UI frame. There is no B4 format in uplink! */
Harald Weltee613f962018-04-18 22:38:16 +02003708 f_tx_lapdm(ts_LAPDm_UI(tc.sapi, cr_MO_CMD, tc.l3), tc.link_id);
Harald Welte0472ab42018-03-12 15:02:26 +01003709 /* Expdct RLL UNITDATA IND on RSL side */
3710 alt {
3711 [] RSL.receive(tr_RSL_UNITDATA_IND(g_chan_nr, tc.link_id, tc.l3)) {
3712 setverdict(pass);
3713 }
3714 [] RSL.receive { repeat; }
3715 }
3716
3717 /* release the channel */
3718 f_rsl_chan_deact();
3719 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
3720 f_rslem_unregister(0, g_chan_nr);
3721}
3722testcase TC_rll_unit_data_ind_DCCH() runs on test_CT {
Stefan Sperlingc4181912018-07-25 17:03:08 +02003723 var octetstring l3 := f_rnd_octstring(20);
Harald Welte0472ab42018-03-12 15:02:26 +01003724 var RllTestCases tcs := {
3725 valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), l3, true)),
3726 valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), l3, true))
3727 };
3728 f_rll_testmatrix(tcs, refers(f_TC_rll_ud_ind));
3729}
3730testcase TC_rll_unit_data_ind_ACCH() runs on test_CT {
3731 var octetstring l3 := f_rnd_octstring(18);
3732 var RllTestCases tcs := {
3733 valueof(t_EITC(0, valueof(ts_RslLinkID_SACCH(0)), l3, true)),
3734 valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), l3, true))
3735 };
3736 f_rll_testmatrix(tcs, refers(f_TC_rll_ud_ind));
3737}
3738
Harald Weltee613f962018-04-18 22:38:16 +02003739/***********************************************************************
3740 * Encryption Related
3741 ***********************************************************************/
3742
3743/* send UNITDATA_REQ from BTS to MS and expect it to arrive */
3744function f_unitdata_mt(RslLinkId link_id, octetstring l3) runs on ConnHdlr {
3745 RSL.send(ts_RSL_UNITDATA_REQ(g_chan_nr, link_id, l3));
3746 if (link_id.c == SACCH) {
3747 f_l1_exp_lapdm(tr_LAPDm_B4_UI(link_id.sapi, cr_MT_CMD, l3));
3748 } else {
3749 f_l1_exp_lapdm(tr_LAPDm_UI(link_id.sapi, cr_MT_CMD, l3));
3750 }
3751}
3752
Vadim Yanitskiyad131c82018-10-04 06:18:59 +07003753/* Expect (or not expect) other kinds of messages */
3754private altstep as_rsl_any_ind(boolean exp_any) runs on ConnHdlr {
3755 [exp_any] RSL.receive { repeat; }
3756 [not exp_any] RSL.receive {
3757 setverdict(fail, "Unexpected RSL message!");
3758 mtc.stop;
3759 }
3760}
3761
Harald Weltee613f962018-04-18 22:38:16 +02003762/* Send UI frame from MS and expect it to arrive as RLL UNITDATA IND on Abis */
Vadim Yanitskiy8d8f91c2018-10-04 06:19:45 +07003763private function f_unitdata_mo(
Vadim Yanitskiy98e03152018-10-03 18:06:06 +07003764 RslLinkId link_id,
3765 octetstring l3,
3766 boolean exp_sacch := true, /* Should tolerate SACCH messages? */
Vadim Yanitskiyb9920502018-10-03 18:29:51 +07003767 boolean exp_any := false /* Should tolerate any other RSL messages? */
Vadim Yanitskiy98e03152018-10-03 18:06:06 +07003768) runs on ConnHdlr {
Harald Weltee613f962018-04-18 22:38:16 +02003769 timer T := 3.0;
3770 f_tx_lapdm(ts_LAPDm_UI(link_id.sapi, cr_MO_CMD, l3), link_id);
3771 T.start;
3772 /* Expect RLL UNITDATA IND on RSL side */
3773 alt {
3774 [] RSL.receive(tr_RSL_UNITDATA_IND(g_chan_nr, link_id, l3)) {
3775 setverdict(pass);
3776 }
Vadim Yanitskiye0b91a72018-10-04 15:44:40 +07003777 [exp_sacch] as_meas_res(verify_meas := false);
Vadim Yanitskiyad131c82018-10-04 06:18:59 +07003778 [] as_rsl_any_ind(exp_any);
Harald Weltee613f962018-04-18 22:38:16 +02003779 [] T.timeout {
3780 setverdict(fail, "Timeout waiting for UNIT_DATA_IND");
Daniel Willmann17ddd852018-07-05 17:33:20 +02003781 mtc.stop;
Harald Weltee613f962018-04-18 22:38:16 +02003782 }
Harald Weltee613f962018-04-18 22:38:16 +02003783 }
3784}
3785
Vadim Yanitskiy4d78a702018-10-03 03:59:34 +07003786/* Send I-frame from MS and expect it to arrive as RLL DATA IND on Abis */
3787private function f_data_mo(
3788 RslLinkId link_id,
3789 boolean p, uint3_t nr, uint3_t ns,
3790 octetstring l3,
3791 boolean exp_sacch := true, /* Should tolerate SACCH messages? */
Vadim Yanitskiyb9920502018-10-03 18:29:51 +07003792 boolean exp_any := false /* Should tolerate any other RSL messages? */
Vadim Yanitskiy4d78a702018-10-03 03:59:34 +07003793) runs on ConnHdlr {
3794 timer T := 3.0;
3795 f_tx_lapdm(ts_LAPDm_I(link_id.sapi, cr_MO_CMD, p, nr, ns, l3), link_id);
3796 T.start;
3797 /* Expect RLL DATA IND on RSL side */
3798 alt {
3799 [] RSL.receive(tr_RSL_DATA_IND(g_chan_nr, link_id, l3)) {
3800 setverdict(pass);
3801 }
Vadim Yanitskiye0b91a72018-10-04 15:44:40 +07003802 [exp_sacch] as_meas_res(verify_meas := false);
Vadim Yanitskiy4d78a702018-10-03 03:59:34 +07003803 [] as_rsl_any_ind(exp_any);
3804 [] T.timeout {
3805 setverdict(fail, "Timeout waiting for DATA_IND");
3806 mtc.stop;
3807 }
3808 }
3809}
3810
Harald Weltee613f962018-04-18 22:38:16 +02003811/* Test channel activation with A5/n right from the beginning (like in assignment + hand-over) */
3812function f_TC_chan_act_encr(charstring id) runs on ConnHdlr {
3813 f_l1_tune(L1CTL);
3814 f_est_dchan(true);
3815
3816 /* now we actually need to transmit some data both ways to check if the encryption works */
3817 var L1ctlDlMessage dl;
3818
Stefan Sperling603d98e2018-07-25 16:47:28 +02003819 var octetstring l3 := f_rnd_octstring(20);
Harald Weltee613f962018-04-18 22:38:16 +02003820 var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0));
3821
3822 /* send UNITDATA_REQ from BTS to MS and expect it to arrive */
3823 f_unitdata_mt(link_id, l3);
3824
3825 /* Send UI frame from MS and expect it to arrive as RLL UNITDATA IND on Abis */
3826 f_unitdata_mo(link_id, l3);
3827
3828 /* release the channel */
3829 f_rsl_chan_deact();
3830 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
3831 f_rslem_unregister(0, g_chan_nr);
3832}
3833testcase TC_chan_act_a51() runs on test_CT {
3834 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
3835 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_1, f_rnd_octstring(8)));
3836 f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr));
3837}
3838testcase TC_chan_act_a52() runs on test_CT {
3839 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
3840 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_2, f_rnd_octstring(8)));
3841 f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr));
3842}
3843testcase TC_chan_act_a53() runs on test_CT {
3844 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
3845 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_3, f_rnd_octstring(8)));
3846 f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr));
3847}
3848
3849
3850/* Test unencrypted channel activation followed by explicit ENCR CMD later */
3851function f_TC_encr_cmd(charstring id) runs on ConnHdlr {
3852 /* L3 payload doesn't matter, as it is passed transparently */
3853 var BIT3 l3_alg_id := f_alg_id_to_l3(g_pars.encr.alg_id);
3854 var octetstring l3 := enc_PDU_ML3_NW_MS(valueof(ts_RRM_CiphModeCmd(l3_alg_id)));
3855 var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0));
3856
3857 f_l1_tune(L1CTL);
3858
3859 /* first establish a dedicated channel in the clear */
3860 f_est_dchan(false);
3861
3862 /* Establish ABM */
3863 f_est_rll_mo(link_id.sapi, link_id, '23420815'O);
3864
3865 /* then send the RSL ENCR CMD with an actual RR CIPH MOD CMD inside */
3866 RSL.send(ts_RSL_ENCR_CMD(g_chan_nr, link_id, g_pars.encr.alg_id, g_pars.encr.key, l3));
3867 /* expect the L3 to arrive still unencrypted on the MS side */
3868 f_l1_exp_lapdm(tr_LAPDm_I(link_id.sapi, cr_MT_CMD, ?, ?, ?, l3));
3869
3870 /* configure L1 to apply ciphering */
3871 var uint8_t alg_id := f_alg_id_to_l1ctl(g_pars.encr.alg_id);
3872 f_L1CTL_CRYPTO_REQ(L1CTL, g_pars.chan_nr, alg_id, g_pars.encr.key);
3873
Vadim Yanitskiy4d78a702018-10-03 03:59:34 +07003874 /* send first ciphered I-frame in response and expect it on RSL */
3875 f_data_mo(link_id, true, 1, 0, '0a0b0c0d'O, exp_sacch := true);
Harald Weltee613f962018-04-18 22:38:16 +02003876
3877 /* now the BTS code should have detected the first properly encrypted uplink I-frame,
3878 * and hence enable encryption also on the downlink */
3879
3880 /* expect bi-directional communication work in encrypted mode */
3881 f_unitdata_mo(link_id, f_rnd_octstring(15));
3882 f_unitdata_mt(link_id, f_rnd_octstring(15));
3883
3884 /* release the channel */
3885 f_rsl_chan_deact();
3886 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
3887 f_rslem_unregister(0, g_chan_nr);
3888}
3889testcase TC_encr_cmd_a51() runs on test_CT {
3890 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
3891 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_1, f_rnd_octstring(8)));
3892 f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd));
3893}
3894testcase TC_encr_cmd_a52() runs on test_CT {
3895 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
3896 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_2, f_rnd_octstring(8)));
3897 f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd));
3898}
3899testcase TC_encr_cmd_a53() runs on test_CT {
3900 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
3901 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_3, f_rnd_octstring(8)));
3902 f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd));
3903}
3904
3905private function f_assert_lapdm(octetstring enc, template LapdmFrame exp_match, charstring name := "") {
3906 var LapdmFrame lf;
3907 var octetstring reenc;
3908
3909 /* decode the LAPDm frame */
3910 if (ischosen(exp_match.ab)) {
3911 lf.ab := dec_LapdmFrameAB(enc);
3912 } else {
3913 setverdict(fail, "unsupported frame type");
Daniel Willmann17ddd852018-07-05 17:33:20 +02003914 mtc.stop;
Harald Weltee613f962018-04-18 22:38:16 +02003915 }
3916
3917 /* check if decoder result matches expectation */
3918 if (not match(lf, exp_match)) {
3919 setverdict(fail, name, ": decoded LAPDm doesn't match");
Daniel Willmann17ddd852018-07-05 17:33:20 +02003920 mtc.stop;
Harald Weltee613f962018-04-18 22:38:16 +02003921 } else {
3922 log(name, ": matched");
3923 setverdict(pass);
3924 }
3925
3926 /* test if re-encoded frame equals original input */
3927 reenc := enc_LapdmFrame(lf);
3928 if (enc != reenc) {
3929 setverdict(fail, name, ": re-encoded LAPDm frame doesn't match");
Daniel Willmann17ddd852018-07-05 17:33:20 +02003930 mtc.stop;
Harald Weltee613f962018-04-18 22:38:16 +02003931 } else {
3932 setverdict(pass);
3933 }
3934}
3935
3936testcase TC_lapdm_selftest() runs on test_CT {
3937 f_assert_lapdm('030301'O, tr_LAPDm_UI(0, true, ''O), "ui_s0_empty");
3938 f_assert_lapdm('0F0301'O, tr_LAPDm_UI(3, true, ''O), "ui_s3_empty");
3939 f_assert_lapdm('013F01'O, tr_LAPDm_SABM(0, false, true, ''O), "sabm_s0_empty");
3940 f_assert_lapdm('013F1123420815'O, tr_LAPDm_SABM(0, false, true, '23420815'O), "sabm_s0_l3");
3941 f_assert_lapdm('03E101'O, tr_LAPDm_RR(0, true, false, 7), "rr_s0_7");
3942 f_assert_lapdm('03000d063505'O, tr_LAPDm_I(0, true, false, 0, 0, '063505'O), "I/0/0");
3943 f_assert_lapdm('03e00d063505'O, tr_LAPDm_I(0, true, false, 7, 0, '063505'O), "I/7/0");
3944}
3945
Stefan Sperling4880be42018-08-07 18:12:59 +02003946/***********************************************************************
3947 * DTX Related (see GSM 05.08, section 8.3)
3948 ***********************************************************************/
3949
3950/* XXX These functions must be kept in sync with g_AllChannels defined on test_CT. */
3951function f_g_chan_is_tchf() runs on ConnHdlr return boolean {
3952 return (g_chan_nr == valueof(ts_RslChanNr_Bm(1)) or
3953 g_chan_nr == valueof(ts_RslChanNr_Bm(2)) or
3954 g_chan_nr == valueof(ts_RslChanNr_Bm(3)) or
3955 g_chan_nr == valueof(ts_RslChanNr_Bm(4)));
3956}
3957function f_g_chan_is_tchh() runs on ConnHdlr return boolean {
3958 return (g_chan_nr == valueof(ts_RslChanNr_Lm(5,0)) or
3959 g_chan_nr == valueof(ts_RslChanNr_Lm(5,1)));
3960}
3961function f_g_chan_is_sdcch4() runs on ConnHdlr return boolean {
3962 return (g_chan_nr == valueof(ts_RslChanNr_SDCCH4(0,0)) or
3963 g_chan_nr == valueof(ts_RslChanNr_SDCCH4(0,1)) or
3964 g_chan_nr == valueof(ts_RslChanNr_SDCCH4(0,2)) or
3965 g_chan_nr == valueof(ts_RslChanNr_SDCCH4(0,3)));
3966}
3967function f_g_chan_is_sdcch8() runs on ConnHdlr return boolean {
3968 return (g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,0)) or
3969 g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,1)) or
3970 g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,2)) or
3971 g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,3)) or
3972 g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,4)) or
3973 g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,5)) or
3974 g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,6)) or
3975 g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,7)));
3976}
3977
3978function f_test_l2_fill_frames(boolean dtxd) runs on ConnHdlr {
3979 var L1ctlDlMessage dl;
3980 var octetstring l2_fill_frame := '0303012B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B'O;
3981 var octetstring l2_fill_frame_sacch := substr(l2_fill_frame, 0, lengthof(l2_fill_frame) - 2);
3982 var GsmFrameNumber first_fn;
3983 var boolean is_first_frame := true;
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02003984 var integer nfill_frames_sacch := 0;
3985 var integer nfill_frames_nonsacch := 0;
3986 var integer expected_fill_frames := 10000; /* initial value causes test failure if not overridden */
Stefan Sperling4880be42018-08-07 18:12:59 +02003987 /* Frames numbers (mod 104) for which a fill frame is expected on TCHF if DTX is enabled. */
3988 var Integers required_tdma_frames_dtx_tchf := { 52, 53, 54, 55, 56, 57, 58, 59 };
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02003989 const integer frame_dtx_tchf_mod := 104;
3990 /* Frame numbers (mod 104) for which a fill frame is expected at the L1SAP level,
3991 * which operates in terms of blocks rather than frames. */
3992 var Integers required_tdma_blocks_dtx_tchf := { 52, 56 };
3993 const integer block_dtx_tchf_mod := 26;
Stefan Sperling4880be42018-08-07 18:12:59 +02003994 timer T := 5.0;
3995
3996 f_l1_tune(L1CTL);
3997 RSL.clear;
3998 L1CTL.clear;
3999
4000 /* activate TCHF signalling channel */
4001 f_est_dchan(false);
4002
4003 T.start;
4004 alt {
4005 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, ?)) -> value dl {
4006 var GsmFrameNumber fn := dl.dl_info.frame_nr;
4007 var octetstring l2 := dl.payload.data_ind.payload;
4008
4009 if (is_first_frame) {
4010 is_first_frame := false;
4011 first_fn := dl.dl_info.frame_nr;
4012 }
4013
4014 if (dl.dl_info.link_id.c == SACCH) {
4015 l2 := substr(l2, 2, lengthof(l2) - 2); /* remove L1 header */
4016 if (not match(l2_fill_frame_sacch, l2)) {
4017 repeat;
4018 }
4019 } else if (not match(l2_fill_frame, l2)) {
4020 repeat;
4021 }
4022
4023 if (dtxd) {
4024 if (not f_g_chan_is_tchf()) {
4025 T.stop;
4026 f_rsl_chan_deact();
4027 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
4028 setverdict(fail, "Received fill frame on non-TCH/F channel; DTX is only allowed on TCH/F!");
4029 }
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02004030 if (fn > first_fn + frame_dtx_tchf_mod) {
Stefan Sperling4880be42018-08-07 18:12:59 +02004031 T.stop;
4032 f_rsl_chan_deact();
4033 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02004034
4035 /* With DTX enabled we can expect at least 3 fill frames for every 104 frames.
4036 * 2 SACCH, 1 TCH/F */
4037 expected_fill_frames := 3;
4038
4039 if (nfill_frames_sacch + nfill_frames_nonsacch < expected_fill_frames) {
4040 log("received only ", nfill_frames_sacch, "+", nfill_frames_nonsacch,
4041 " (SACCH+other) out of ", expected_fill_frames, " expected fill frames");
4042 setverdict(fail, "Not enough fill frames received");
Stefan Sperling4880be42018-08-07 18:12:59 +02004043 } else {
4044 setverdict(pass);
4045 }
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02004046 } else {
4047 if (dl.dl_info.link_id.c == SACCH) {
4048 nfill_frames_sacch := nfill_frames_sacch + 1;
Stefan Sperling4880be42018-08-07 18:12:59 +02004049 repeat;
4050 }
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02004051 /* On DTX TCH/F channels, fill frames occur only for specific frame numbers mod 104.
4052 * Furthermore, the L1SAP layer gives us frame numbers for the start of a block so
4053 * we should only see the subset of frames numbers which correspond to a block boundary.
4054 * TCH/F blocks are defined to start at 0,4,8,13,17,21 (modulo 26) */
4055 for (var integer i := 0; i < lengthof(required_tdma_blocks_dtx_tchf); i := i + 1) {
4056 if (fn mod frame_dtx_tchf_mod == required_tdma_blocks_dtx_tchf[i]) {
4057 nfill_frames_nonsacch := nfill_frames_nonsacch + 1;
4058 repeat;
4059 }
4060 }
4061 log("Received DTX TCH fill frame with bad frame number: ", fn,
4062 " (mod ", frame_dtx_tchf_mod, ": ", fn mod frame_dtx_tchf_mod, ")",
4063 " (mod ", block_dtx_tchf_mod, ": ", fn mod block_dtx_tchf_mod, ")");
4064 f_rsl_chan_deact();
4065 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
4066 setverdict(fail, "Unexpected L2 fill frame received on Um");
Stefan Sperling4880be42018-08-07 18:12:59 +02004067 }
Stefan Sperling4880be42018-08-07 18:12:59 +02004068 } else {
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02004069 if (dl.dl_info.link_id.c == SACCH) {
4070 nfill_frames_sacch := nfill_frames_sacch + 1;
4071 } else {
4072 nfill_frames_nonsacch := nfill_frames_nonsacch + 1;
4073 }
4074 if (fn > first_fn + frame_dtx_tchf_mod) {
Stefan Sperling4880be42018-08-07 18:12:59 +02004075 T.stop;
4076 if (f_g_chan_is_tchf()) {
4077 /* Without DTX we can expect 25 fill frames for every 104 frames.
4078 * (24 FACCH + 1 SACCH filling) */
4079 expected_fill_frames := 25;
4080 } else if (f_g_chan_is_tchh()) {
4081 /* We can expect 2 fill frames for every 104 frames. */
4082 expected_fill_frames := 2;
4083 } else if (f_g_chan_is_sdcch4() or f_g_chan_is_sdcch8()) {
4084 /* We can expect 5 fill frames for every 104 frames. */
4085 expected_fill_frames := 5;
4086 } else {
4087 f_rsl_chan_deact();
4088 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
4089 setverdict(fail, "Unknown channel type");
4090 }
4091
4092 f_rsl_chan_deact();
4093 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02004094
4095 if (nfill_frames_sacch + nfill_frames_nonsacch >= expected_fill_frames) {
Stefan Sperling4880be42018-08-07 18:12:59 +02004096 setverdict(pass);
4097 } else {
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02004098 log("received only ", nfill_frames_sacch, "+", nfill_frames_nonsacch,
4099 " (SACCH+other) out of ", expected_fill_frames, " expected fill frames");
Stefan Sperling4880be42018-08-07 18:12:59 +02004100 setverdict(fail, "Not enough fill frames received");
4101 }
4102 } else {
4103 repeat;
4104 }
4105 }
4106 }
4107 [] L1CTL.receive { repeat; }
4108 [] T.timeout {
4109 f_rsl_chan_deact();
4110 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
4111 setverdict(fail, "Timeout waiting for L2 fill frames on Um");
4112 mtc.stop;
4113 }
4114 }
4115}
4116
4117function f_TC_tch_sign_l2_fill_frame(charstring id) runs on ConnHdlr {
4118 f_test_l2_fill_frames(false);
4119}
4120
4121function f_TC_tch_sign_l2_fill_frame_dtxd(charstring id) runs on ConnHdlr {
4122 f_test_l2_fill_frames(true);
4123}
4124
4125function f_tch_sign_l2_fill_frame(boolean dtxd) runs on test_CT {
4126 var ConnHdlr vc_conn;
4127 var ConnHdlrPars pars;
4128 pars.t_guard := 60.0;
4129 f_init(testcasename());
4130 for (var integer i := 0; i < sizeof(g_AllChannels); i := i + 1) {
4131 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN(dtxd)));
4132 if (dtxd) {
4133 if (i >= 4) { /* DTX is only allowed on TCH/F */
4134 break;
4135 }
4136 vc_conn := f_start_handler(refers(f_TC_tch_sign_l2_fill_frame_dtxd), pars);
4137 } else {
4138 vc_conn := f_start_handler(refers(f_TC_tch_sign_l2_fill_frame), pars);
4139 }
4140 vc_conn.done;
4141 }
4142}
4143
4144/* Verify that L2 fill frames are sent on TCH in signaling mode if
4145 * there is nothing to transmit while DTX is disabled on downlink. */
4146testcase TC_tch_sign_l2_fill_frame() runs on test_CT {
4147 f_tch_sign_l2_fill_frame(false);
4148}
4149
4150/* Verify that particular L2 fill frames are sent on TCH in signaling mode if
4151 * there is nothing to transmit while DTX is enabled on downlink. */
4152testcase TC_tch_sign_l2_fill_frame_dtxd() runs on test_CT {
4153 f_tch_sign_l2_fill_frame(true);
4154}
Harald Welte0472ab42018-03-12 15:02:26 +01004155
Stefan Sperling0ec1c262018-10-15 15:12:52 +02004156testcase TC_chopped_ipa_ping() runs on test_CT {
4157 IPA_Testing.f_run_TC_chopped_ipa_ping(mp_rsl_ip, mp_rsl_port, LISTEN_FOR_CLIENT);
4158}
4159
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02004160testcase TC_chopped_ipa_payload() runs on test_CT {
4161 IPA_Testing.f_run_TC_chopped_ipa_payload(mp_rsl_ip, mp_rsl_port, LISTEN_FOR_CLIENT);
4162}
4163
Harald Welte0472ab42018-03-12 15:02:26 +01004164/* test generation of RLL ERR IND based on Um errors (TS 48.058 3.9) */
4165/* protocol error as per 44.006 */
4166/* link layer failure (repetition of I-frame N200 times without ACK */
4167/* repetition of SABM or DISC N200 times without ACK */
4168/* receptiom of SABM in multi-frame established state */
4169
4170
4171
4172
Harald Welte883340c2018-02-28 18:59:29 +01004173
Harald Welte68e495b2018-02-25 00:05:57 +01004174/* TODO Areas:
4175
4176* channel activation
4177** with BS_Power / MS_Power, bypassing power control loop
4178** on primary vs. secondary TRX
Harald Welte68e495b2018-02-25 00:05:57 +01004179** with timing advance from initial activation on
4180* mode modify
4181** encryption
4182** multirate
4183* check DEACTIVATE SACCH
Harald Welte68e495b2018-02-25 00:05:57 +01004184** unsupported algorithm
4185* handover detection
4186* MS Power Control
4187* BS Power Control
4188* Physical Context
Harald Welte43c54642018-09-15 17:47:04 +03004189* CCCH Load Indication for RACH
Harald Welte68e495b2018-02-25 00:05:57 +01004190* SMS Broadcast Req / Cmd / CBCH LOad Ind
4191* RF resource ind
Harald Welte68e495b2018-02-25 00:05:57 +01004192* error handling
Harald Welte43c54642018-09-15 17:47:04 +03004193** discriminator error
Harald Welte68e495b2018-02-25 00:05:57 +01004194** type error
4195** sequence error
4196** IE duplicated?
Harald Welte883340c2018-02-28 18:59:29 +01004197* PCU interface
4198** TIME_IND from BTS->PCU
4199** DATA_IND from BTS->PCU
4200** verification of PCU-originated DATA_REQ arrival on Um/MS side
Harald Welte68e495b2018-02-25 00:05:57 +01004201
4202*/
Harald Welte70767382018-02-21 12:16:40 +01004203
4204control {
4205 execute( TC_chan_act_stress() );
4206 execute( TC_chan_act_react() );
4207 execute( TC_chan_deact_not_active() );
4208 execute( TC_chan_act_wrong_nr() );
Harald Welte629cc6b2018-03-11 17:19:05 +01004209 execute( TC_deact_sacch() );
Harald Welteea17b912018-03-11 22:29:31 +01004210 execute( TC_sacch_filling() );
4211 execute( TC_sacch_info_mod() );
Harald Welte075d84c2018-03-12 13:07:24 +01004212 execute( TC_sacch_multi() );
Harald Welte55700662018-03-12 13:15:43 +01004213 execute( TC_sacch_multi_chg() );
Harald Welte8c24c2b2018-02-26 08:31:31 +01004214 execute( TC_rach_content() );
4215 execute( TC_rach_count() );
Harald Welte54a2a2d2018-02-26 09:14:05 +01004216 execute( TC_rach_max_ta() );
Harald Welte70767382018-02-21 12:16:40 +01004217 execute( TC_meas_res_sign_tchf() );
4218 execute( TC_meas_res_sign_tchh() );
4219 execute( TC_meas_res_sign_sdcch4() );
4220 execute( TC_meas_res_sign_sdcch8() );
Harald Welte685d5982018-02-27 20:42:05 +01004221 execute( TC_meas_res_sign_tchh_toa256() );
Harald Welte70767382018-02-21 12:16:40 +01004222 execute( TC_conn_fail_crit() );
Harald Welte68e495b2018-02-25 00:05:57 +01004223 execute( TC_paging_imsi_80percent() );
4224 execute( TC_paging_tmsi_80percent() );
4225 execute( TC_paging_imsi_200percent() );
4226 execute( TC_paging_tmsi_200percent() );
Harald Welte01d982c2018-02-25 01:31:40 +01004227 execute( TC_rsl_protocol_error() );
4228 execute( TC_rsl_mand_ie_error() );
4229 execute( TC_rsl_ie_content_error() );
Harald Welte48494ca2018-02-25 16:59:50 +01004230 execute( TC_si_sched_default() );
Harald Welte0cae4552018-03-09 22:20:26 +01004231 execute( TC_si_sched_1() );
Harald Welte48494ca2018-02-25 16:59:50 +01004232 execute( TC_si_sched_2bis() );
4233 execute( TC_si_sched_2ter() );
4234 execute( TC_si_sched_2ter_2bis() );
4235 execute( TC_si_sched_2quater() );
4236 execute( TC_si_sched_13() );
4237 execute( TC_si_sched_13_2bis_2ter_2quater() );
Harald Weltea871a382018-02-25 02:03:14 +01004238 execute( TC_ipa_dlcx_not_active() );
Harald Weltea3f1df92018-02-25 12:49:55 +01004239 execute( TC_ipa_crcx_twice_not_active() );
4240 execute( TC_ipa_crcx_mdcx_dlcx_not_active() );
Harald Welte3ae11da2018-02-25 13:36:06 +01004241 execute( TC_ipa_crcx_mdcx_mdcx_dlcx_not_active() );
Harald Welte9912eb52018-02-25 13:30:15 +01004242 execute( TC_ipa_crcx_sdcch_not_active() );
Harald Welte883340c2018-02-28 18:59:29 +01004243
4244 execute( TC_pcu_act_req() );
4245 execute( TC_pcu_act_req_wrong_ts() );
4246 execute( TC_pcu_act_req_wrong_bts() );
4247 execute( TC_pcu_act_req_wrong_trx() );
4248 execute( TC_pcu_deact_req() );
4249 execute( TC_pcu_deact_req_wrong_ts() );
4250 execute( TC_pcu_ver_si13() );
4251 execute( TC_pcu_data_req_wrong_bts() );
4252 execute( TC_pcu_data_req_wrong_trx() );
4253 execute( TC_pcu_data_req_wrong_ts() );
4254 execute( TC_pcu_data_req_ts_inactive() );
4255 execute( TC_pcu_data_req_pdtch() );
4256 execute( TC_pcu_data_req_ptcch() );
4257 execute( TC_pcu_data_req_agch() );
4258 execute( TC_pcu_data_req_imm_ass_pch() );
4259 execute( TC_pcu_rach_content() );
4260 execute( TC_pcu_paging_from_rsl() );
Harald Welte3d04ae62018-04-04 20:29:05 +02004261
4262 execute( TC_dyn_osmo_pdch_act_deact() );
4263 execute( TC_dyn_osmo_pdch_unsol_deact() );
4264 execute( TC_dyn_osmo_pdch_double_act() );
4265 execute( TC_dyn_osmo_pdch_tchf_act() );
4266 execute( TC_dyn_osmo_pdch_tchh_act() );
Harald Welte9bbbfb52018-04-05 09:33:19 +02004267 execute( TC_dyn_ipa_pdch_act_deact() );
4268 execute( TC_dyn_ipa_pdch_tchf_act() );
4269 execute( TC_dyn_ipa_pdch_tchf_act_pdch_act_nack() );
4270 execute( TC_dyn_ipa_pdch_act_tchf_act_nack() );
Harald Welte0472ab42018-03-12 15:02:26 +01004271
4272 execute( TC_rll_est_ind() );
4273 execute( TC_rll_est_req_DCCH_3() );
4274 execute( TC_rll_est_req_ACCH_3() );
4275 execute( TC_rll_rel_ind_DCCH_0() );
4276 execute( TC_rll_rel_ind_DCCH_3() );
4277 execute( TC_rll_rel_ind_ACCH_0() );
4278 execute( TC_rll_rel_ind_ACCH_3() );
4279 execute( TC_rll_rel_req() );
4280 execute( TC_rll_unit_data_req_DCCH() );
4281 execute( TC_rll_unit_data_req_ACCH() );
4282 execute( TC_rll_unit_data_ind_DCCH() );
4283 execute( TC_rll_unit_data_ind_ACCH() );
Harald Weltee613f962018-04-18 22:38:16 +02004284
4285 execute( TC_chan_act_a51() );
4286 execute( TC_chan_act_a52() );
4287 execute( TC_chan_act_a53() );
4288 execute( TC_encr_cmd_a51() );
4289 execute( TC_encr_cmd_a52() );
4290 execute( TC_encr_cmd_a53() );
4291
4292 execute( TC_lapdm_selftest() );
Stefan Sperling4880be42018-08-07 18:12:59 +02004293
4294 execute( TC_tch_sign_l2_fill_frame() );
4295 execute( TC_tch_sign_l2_fill_frame_dtxd() );
Stefan Sperling0ec1c262018-10-15 15:12:52 +02004296
4297 execute( TC_chopped_ipa_ping() );
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02004298 execute( TC_chopped_ipa_payload() );
Harald Welte70767382018-02-21 12:16:40 +01004299}
4300
4301
4302}