blob: a2d4ca42d0cfc195f7148fdbc39dfc54c5946cd1 [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 };
Harald Welte0472ab42018-03-12 15:02:26 +0100316 g_AllChanTypes := {
317 /* TS 1..4: TCH/F */
Vadim Yanitskiyb0970092018-07-27 02:40:43 +0700318 valueof(ts_RslChanNr_Bm(1)),
Harald Welte0472ab42018-03-12 15:02:26 +0100319 /* TS 5: TCH/H */
Vadim Yanitskiy7b8c5222018-09-16 16:55:48 +0700320 valueof(ts_RslChanNr_Lm(5,1)),
Harald Welte0472ab42018-03-12 15:02:26 +0100321 /* TS 0: SDCCH/4 */
322 valueof(ts_RslChanNr_SDCCH4(0,2)),
323 /* TS 6: SDCCH/8 */
324 valueof(ts_RslChanNr_SDCCH8(6,4))
325 };
Harald Welte629cc6b2018-03-11 17:19:05 +0100326
Harald Welte70767382018-02-21 12:16:40 +0100327 f_init_rsl(id);
Harald Welte83f6dbf2018-06-03 18:26:50 +0200328 T.start;
329 alt {
330 [] RSL_CCHAN.receive(ASP_IPA_Event:{up_down := ASP_IPA_EVENT_UP});
331 [] T.timeout {
332 setverdict(fail, "Timeout waiting for ASP_IPA_EVENT_UP");
Daniel Willmann17ddd852018-07-05 17:33:20 +0200333 mtc.stop;
Harald Welte83f6dbf2018-06-03 18:26:50 +0200334 }
335 }
Harald Welte2d142592018-02-25 13:19:44 +0100336 f_sleep(0.5); /* workaround for OS#3000 */
Harald Welte8da48242018-02-27 20:41:32 +0100337 f_init_vty(id);
Neels Hofmeyr6a84b232018-04-03 19:12:36 +0200338 f_ipa_ctrl_start(mp_ctrl_ip, mp_ctrl_port);
Harald Welte7484fc42018-02-24 14:09:45 +0100339
340 /* Send SI3 to the BTS, it is needed for various computations */
Harald Weltef10153f2018-02-25 16:34:05 +0100341 f_rsl_bcch_fill(RSL_SYSTEM_INFO_3, ts_SI3_default);
342 /* SI2 + SI4 are required for SI testing as they are mandatory defaults */
343 f_rsl_bcch_fill(RSL_SYSTEM_INFO_2, ts_SI2_default);
344 f_rsl_bcch_fill(RSL_SYSTEM_INFO_4, ts_SI4_default);
Harald Welte57fe8232018-02-26 17:52:50 +0100345
Harald Weltef26de0b2018-04-04 20:28:05 +0200346 map(self:PCU, system:PCU);
347 f_init_pcu(PCU, id, g_pcu_conn_id, g_pcu_last_info);
Harald Welte883340c2018-02-28 18:59:29 +0100348
Harald Welte84271622018-03-10 17:21:03 +0100349 if (mp_bb_trxc_port != -1) {
350 var TrxcMessage ret;
351 /* start with a default moderate timing offset equalling TA=2 */
352 f_main_trxc_connect();
353 ret := f_TRXC_transceive(BB_TRXC, g_bb_trxc_conn_id, valueof(ts_TRXC_FAKE_TIMING(2*256)));
354 }
Harald Welte70767382018-02-21 12:16:40 +0100355}
356
Harald Welte294b0a22018-03-10 23:26:48 +0100357function f_shutdown() runs on test_CT {
Daniel Willmanncc7bbeb2018-07-03 16:33:56 +0200358 /* mtc.stop cleanly stops testcase execution to avoid unclean shutdown */
Daniel Willmannb85a6292018-07-25 22:53:32 +0200359 all component.stop;
Daniel Willmanncc7bbeb2018-07-03 16:33:56 +0200360 mtc.stop;
Harald Welte294b0a22018-03-10 23:26:48 +0100361}
362
Harald Welte68e495b2018-02-25 00:05:57 +0100363/* Attach L1CTL to master test_CT (classic tests, non-handler mode) */
364function f_init_l1ctl() runs on test_CT {
365 map(self:L1CTL, system:L1CTL);
366 f_connect_reset(L1CTL);
367}
368
Harald Welte70767382018-02-21 12:16:40 +0100369type function void_fn(charstring id) runs on ConnHdlr;
370
371/* create a new test component */
Harald Weltef26de0b2018-04-04 20:28:05 +0200372function f_start_handler(void_fn fn, ConnHdlrPars pars, boolean pcu_comp := false)
Harald Welte70767382018-02-21 12:16:40 +0100373runs on test_CT return ConnHdlr {
374 var charstring id := testcasename();
375 var ConnHdlr vc_conn;
376
377 vc_conn := ConnHdlr.create(id);
378 /* connect to RSL Emulation main component */
379 connect(vc_conn:RSL, vc_RSL:CLIENT_PT);
380 connect(vc_conn:RSL_PROC, vc_RSL:RSL_PROC);
Harald Weltef26de0b2018-04-04 20:28:05 +0200381 if (pcu_comp) {
382 /* the ConnHdlr component wants to talk directly to the PCU, so disconnect
383 * it from the test_CT and connect it to the component. This obviously only
384 * works for one component, i.e. no concurrency */
385 unmap(self:PCU, system:PCU);
386 map(vc_conn:PCU, system:PCU);
387 }
Harald Welte70767382018-02-21 12:16:40 +0100388
389 vc_conn.start(f_handler_init(fn, id, pars));
390 return vc_conn;
391}
392
Harald Welte7484fc42018-02-24 14:09:45 +0100393template ASP_RSL_Unitdata ts_RSL_UD(template RSL_Message rsl, IpaStreamId sid := IPAC_PROTO_RSL_TRX0) := {
394 streamId := sid,
395 rsl := rsl
396}
397
398template ASP_RSL_Unitdata tr_RSL_UD(template RSL_Message rsl,
399 template IpaStreamId sid := IPAC_PROTO_RSL_TRX0) := {
400 streamId := sid,
401 rsl := rsl
402}
403
Harald Welte70767382018-02-21 12:16:40 +0100404private altstep as_Tguard() runs on ConnHdlr {
405 [] g_Tguard.timeout {
406 setverdict(fail, "Tguard timeout");
Daniel Willmann17ddd852018-07-05 17:33:20 +0200407 mtc.stop;
Harald Welte70767382018-02-21 12:16:40 +0100408 }
409}
410
Harald Welte68e495b2018-02-25 00:05:57 +0100411private function f_l1_tune(L1CTL_PT L1CTL) {
Pau Espin Pedrol752ffd52018-06-07 13:55:45 +0200412 f_L1CTL_FBSB(L1CTL, { false, mp_trx0_arfcn }, CCCH_MODE_COMBINED, mp_rxlev_exp);
Harald Welte70767382018-02-21 12:16:40 +0100413}
414
415private function f_trxc_connect() runs on ConnHdlr {
416 map(self:BB_TRXC, system:BB_TRXC);
417 var Result res;
Harald Weltea4d8f352018-03-01 15:47:20 +0100418 res := TRXC_CodecPort_CtrlFunct.f_IPL4_connect(BB_TRXC, mp_bb_trxc_ip, mp_bb_trxc_port,
419 "", -1, -1, {udp:={}}, {});
Harald Welte9220f632018-05-23 20:27:02 +0200420 if (not ispresent(res.connId)) {
421 setverdict(fail, "Could not connect to trx-control interface of trxcon, check your configuration");
Daniel Willmann17ddd852018-07-05 17:33:20 +0200422 mtc.stop;
Harald Welte9220f632018-05-23 20:27:02 +0200423 }
Harald Welte70767382018-02-21 12:16:40 +0100424 g_bb_trxc_conn_id := res.connId;
425}
426
427private function f_trxc_fake_rssi(uint8_t rssi) runs on ConnHdlr {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100428 var TrxcMessage ret;
429 ret := f_TRXC_transceive(BB_TRXC, g_bb_trxc_conn_id, valueof(ts_TRXC_FAKE_RSSI(rssi)));
Harald Welte70767382018-02-21 12:16:40 +0100430}
431
432private function f_trx_fake_toffs256(int16_t toffs256) runs on ConnHdlr {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100433 var TrxcMessage ret;
434 ret := f_TRXC_transceive(BB_TRXC, g_bb_trxc_conn_id, valueof(ts_TRXC_FAKE_TIMING(toffs256)));
Harald Welte70767382018-02-21 12:16:40 +0100435}
436
437/* first function started in ConnHdlr component */
438private function f_handler_init(void_fn fn, charstring id, ConnHdlrPars pars)
439runs on ConnHdlr {
440 g_pars := pars;
441 g_chan_nr := pars.chan_nr;
442
443 map(self:L1CTL, system:L1CTL);
444 f_connect_reset(L1CTL);
445
Harald Welte84271622018-03-10 17:21:03 +0100446 if (mp_bb_trxc_port != -1) {
447 f_trxc_connect();
448 }
Harald Welte70767382018-02-21 12:16:40 +0100449
450 g_Tguard.start(pars.t_guard);
451 activate(as_Tguard());
452
453 f_rslem_register(0, pars.chan_nr);
454
455 /* call the user-supplied test case function */
456 fn.apply(id);
457}
458
Harald Welteb1726c92018-03-30 11:56:38 +0200459function f_rsl_transceive_ret(template RSL_Message tx, template RSL_Message exp_rx, charstring id,
460 boolean ignore_other := false)
461runs on ConnHdlr return RSL_Message {
462 var RSL_Message rx;
Harald Welte1eba3742018-02-25 12:48:14 +0100463 timer T := 3.0;
464 RSL.send(tx);
465 T.start;
Harald Welte70767382018-02-21 12:16:40 +0100466 alt {
Harald Welteb1726c92018-03-30 11:56:38 +0200467 [] RSL.receive(exp_rx) -> value rx {
Harald Welte1eba3742018-02-25 12:48:14 +0100468 T.stop;
469 setverdict(pass);
Harald Welte70767382018-02-21 12:16:40 +0100470 }
Harald Welte1eba3742018-02-25 12:48:14 +0100471 [] T.timeout {
472 setverdict(fail, "Timeout expecting " & id);
Daniel Willmann17ddd852018-07-05 17:33:20 +0200473 mtc.stop;
Harald Welte1eba3742018-02-25 12:48:14 +0100474 }
Harald Welte21240e62018-03-11 21:43:35 +0100475 [not ignore_other] as_l1_sacch();
476 [not ignore_other] as_meas_res();
477 [not ignore_other] as_l1_dcch();
478 [not ignore_other] RSL.receive {
Harald Welte1eba3742018-02-25 12:48:14 +0100479 setverdict(fail, "Unexpected RSL message received");
Daniel Willmann17ddd852018-07-05 17:33:20 +0200480 mtc.stop;
Harald Welte70767382018-02-21 12:16:40 +0100481 }
Harald Welte21240e62018-03-11 21:43:35 +0100482 [ignore_other] RSL.receive { repeat; }
Harald Welte70767382018-02-21 12:16:40 +0100483 }
Harald Welteb1726c92018-03-30 11:56:38 +0200484 return rx;
485}
486
487function f_rsl_transceive(template RSL_Message tx, template RSL_Message exp_rx, charstring id,
488 boolean ignore_other := false)
489runs on ConnHdlr {
490 var RSL_Message rx := f_rsl_transceive_ret(tx, exp_rx, id, ignore_other);
Harald Welte70767382018-02-21 12:16:40 +0100491}
492
Harald Weltee613f962018-04-18 22:38:16 +0200493function f_rsl_chan_act(RSL_IE_ChannelMode mode, boolean encr_enable := false)
494runs on ConnHdlr {
495 var RSL_Message ch_act := valueof(ts_RSL_CHAN_ACT(g_chan_nr, mode));
496 if (encr_enable) {
497 /* append encryption related IEs, if requested */
498 var RSL_IE_EncryptionInfo encr_info;
499 encr_info := valueof(ts_RSL_IE_EncrInfo(g_pars.encr.alg_id, g_pars.encr.key));
500 ch_act.ies := ch_act.ies & { valueof(t_RSL_IE(RSL_IE_ENCR_INFO, RSL_IE_Body:{encr_info :=
501encr_info})) };
502 }
503 f_rsl_transceive(ch_act, tr_RSL_CHAN_ACT_ACK(g_chan_nr), "RSL CHAN ACT");
Harald Welte1eba3742018-02-25 12:48:14 +0100504}
505
Harald Welte70767382018-02-21 12:16:40 +0100506function f_rsl_chan_deact() runs on ConnHdlr {
Harald Welte1eba3742018-02-25 12:48:14 +0100507 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 +0100508 "RF CHAN REL", true);
Harald Welte70767382018-02-21 12:16:40 +0100509}
510
Harald Welte70767382018-02-21 12:16:40 +0100511private template ConnHdlrPars t_Pars(template RslChannelNr chan_nr,
512 template RSL_IE_ChannelMode chan_mode,
513 float t_guard := 20.0) := {
514 chan_nr := valueof(chan_nr),
515 chan_mode := valueof(chan_mode),
516 t_guard := t_guard,
517 l1_pars := {
518 dtx_enabled := false,
Harald Welte685d5982018-02-27 20:42:05 +0100519 toa256_enabled := false,
Harald Welte70767382018-02-21 12:16:40 +0100520 meas_ul := {
521 full := {
Pau Espin Pedrole9571aa2018-10-22 17:13:07 +0200522 rxlev := mp_ul_rxlev_exp,
Harald Welte70767382018-02-21 12:16:40 +0100523 rxqual := 0
524 },
525 sub := {
Pau Espin Pedrole9571aa2018-10-22 17:13:07 +0200526 rxlev := mp_ul_rxlev_exp,
Harald Welte70767382018-02-21 12:16:40 +0100527 rxqual := 0
528 }
529 },
Pau Espin Pedrol121724c2018-09-28 15:58:12 +0200530 timing_offset_256syms := mp_timing_offset_256syms_exp,
Harald Welte70767382018-02-21 12:16:40 +0100531 bs_power_level := 0,
Pau Espin Pedroled359cb2018-09-28 16:08:24 +0200532 ms_power_level := mp_ms_power_level_exp,
Pau Espin Pedrol121724c2018-09-28 15:58:12 +0200533 ms_actual_ta := mp_ms_actual_ta_exp
Harald Welte0472ab42018-03-12 15:02:26 +0100534 },
Harald Weltee613f962018-04-18 22:38:16 +0200535 spec := omit,
536 encr := omit
Harald Welte70767382018-02-21 12:16:40 +0100537}
538
Harald Welte93640c62018-02-25 16:59:33 +0100539/***********************************************************************
540 * Channel Activation / Deactivation
541 ***********************************************************************/
542
Harald Welte70767382018-02-21 12:16:40 +0100543/* Stress test: Do 500 channel activations/deactivations in rapid succession */
544function f_TC_chan_act_stress(charstring id) runs on ConnHdlr {
545 for (var integer i := 0; i < 500; i := i+1) {
546 f_rsl_chan_act(g_pars.chan_mode);
547 f_rsl_chan_deact();
548 }
549 setverdict(pass);
550}
551testcase TC_chan_act_stress() runs on test_CT {
552 var ConnHdlr vc_conn;
553 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
554 f_init(testcasename());
555 vc_conn := f_start_handler(refers(f_TC_chan_act_stress), pars);
556 vc_conn.done;
Harald Welte294b0a22018-03-10 23:26:48 +0100557 f_shutdown();
Harald Welte70767382018-02-21 12:16:40 +0100558}
559
560/* Test if re-activation of an already active channel fails as expected */
561function f_TC_chan_act_react(charstring id) runs on ConnHdlr {
562 f_rsl_chan_act(g_pars.chan_mode);
563 /* attempt to activate the same lchan again -> expect reject */
564 RSL.send(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode));
565 alt {
566 [] RSL.receive(tr_RSL_CHAN_ACT_ACK(g_chan_nr)) {
567 setverdict(fail, "Unexpected CHAN ACT ACK on double activation");
Daniel Willmann17ddd852018-07-05 17:33:20 +0200568 mtc.stop;
Harald Welte70767382018-02-21 12:16:40 +0100569 }
570 [] RSL.receive(tr_RSL_CHAN_ACT_NACK(g_chan_nr)) {
571 setverdict(pass);
572 }
573 }
574 f_rsl_chan_deact();
575}
576testcase TC_chan_act_react() runs on test_CT {
577 var ConnHdlr vc_conn;
578 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
Harald Welte294b0a22018-03-10 23:26:48 +0100579 f_init();
Harald Welte70767382018-02-21 12:16:40 +0100580 vc_conn := f_start_handler(refers(f_TC_chan_act_react), pars);
581 vc_conn.done;
Harald Welte294b0a22018-03-10 23:26:48 +0100582 f_shutdown();
Harald Welte70767382018-02-21 12:16:40 +0100583}
584
585/* Attempt to de-activate a channel that's not active */
586function f_TC_chan_deact_not_active(charstring id) runs on ConnHdlr {
587 timer T := 3.0;
588 RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr));
589 T.start;
590 alt {
591 [] RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr)) {
592 setverdict(pass);
593 }
594 [] T.timeout {
595 setverdict(fail, "Timeout expecting RF_CHAN_REL_ACK");
Daniel Willmann17ddd852018-07-05 17:33:20 +0200596 mtc.stop;
Harald Welte70767382018-02-21 12:16:40 +0100597 }
598 }
599}
600testcase TC_chan_deact_not_active() runs on test_CT {
601 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
Harald Welte294b0a22018-03-10 23:26:48 +0100602 f_init();
Harald Welte70767382018-02-21 12:16:40 +0100603 var ConnHdlr vc_conn := f_start_handler(refers(f_TC_chan_deact_not_active), pars);
604 vc_conn.done;
Harald Welte294b0a22018-03-10 23:26:48 +0100605 f_shutdown();
Harald Welte70767382018-02-21 12:16:40 +0100606}
607
608/* attempt to activate channel with wrong RSL Channel Nr IE; expect NACK */
609function f_TC_chan_act_wrong_nr(charstring id) runs on ConnHdlr {
610 RSL.send(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode));
611 alt {
612 [] RSL.receive(tr_RSL_CHAN_ACT_ACK(g_chan_nr)) {
613 setverdict(fail, "Unexpected CHAN ACT ACK");
Daniel Willmann17ddd852018-07-05 17:33:20 +0200614 mtc.stop;
Harald Welte70767382018-02-21 12:16:40 +0100615 }
616 [] RSL.receive(tr_RSL_CHAN_ACT_NACK(g_chan_nr)) {
617 setverdict(pass);
618 }
619 }
620}
621private type record WrongChanNrCase {
622 RslChannelNr chan_nr,
623 charstring description
624}
625private type record of WrongChanNrCase WrongChanNrCases;
626private template WrongChanNrCase t_WCN(template RslChannelNr chan_nr, charstring desc) := {
627 chan_nr := chan_nr,
628 description := desc
629}
630
631testcase TC_chan_act_wrong_nr() runs on test_CT {
632 var ConnHdlr vc_conn;
633 var ConnHdlrPars pars;
634
Harald Welte294b0a22018-03-10 23:26:48 +0100635 f_init();
Harald Welte70767382018-02-21 12:16:40 +0100636
637 var WrongChanNrCases wrong := {
638 valueof(t_WCN(t_RslChanNr_RACH(0), "RACH is not a dedicated channel")),
639 valueof(t_WCN(t_RslChanNr_RACH(1), "RACH doesn't exist on timeslot")),
640 valueof(t_WCN(t_RslChanNr_BCCH(0), "BCCH is not a dedicated channel")),
641 valueof(t_WCN(t_RslChanNr_PCH_AGCH(0), "PCH/AGCH is not a dedicated channel")),
642 valueof(t_WCN(t_RslChanNr_Bm(0), "TS0 cannot be TCH/F")),
643 valueof(t_WCN(t_RslChanNr_Lm(0, 0), "TS0 cannot be TCH/H")),
644 valueof(t_WCN(t_RslChanNr_Lm(0, 1), "TS0 cannot be TCH/H")),
645 valueof(t_WCN(t_RslChanNr_PDCH(0), "TS0 cannot be PDCH")),
646 valueof(t_WCN(t_RslChanNr_SDCCH8(0, 0), "TS0 cannot be SDCCH/8")),
647 valueof(t_WCN(t_RslChanNr_SDCCH8(0, 7), "TS0 cannot be SDCCH/8")),
648 valueof(t_WCN(t_RslChanNr_SDCCH4(7, 0), "TS7 cannot be SDCCH/4")),
649 valueof(t_WCN(t_RslChanNr_SDCCH4(7, 3), "TS7 cannot be SDCCH/4")),
650 valueof(t_WCN(t_RslChanNr_Lm(1, 0), "TS1 cannot be TCH/H"))
651 };
652
653 for (var integer i := 0; i < sizeof(wrong); i := i+1) {
654 pars := valueof(t_Pars(wrong[i].chan_nr, ts_RSL_ChanMode_SIGN));
655 vc_conn := f_start_handler(refers(f_TC_chan_act_wrong_nr), pars);
656 vc_conn.done;
657 }
Harald Welte294b0a22018-03-10 23:26:48 +0100658 f_shutdown();
Harald Welte70767382018-02-21 12:16:40 +0100659}
660
Harald Weltee613f962018-04-18 22:38:16 +0200661/* execute the same callback function on a variety of logical channels */
662private function f_testmatrix_each_chan(ConnHdlrPars pars, void_fn fn) runs on test_CT {
663 var ConnHdlr vc_conn;
664 f_init(testcasename());
665
666 /* test on each of the channels we have */
667 for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i+1) {
668 pars.chan_nr := valueof(g_AllChanTypes[i]);
669
670 log(testcasename(), ": XXX Starting on ", g_AllChanTypes[i]);
671 vc_conn := f_start_handler(fn, pars);
672 vc_conn.done;
673 }
674
675 f_shutdown();
676}
677
Harald Welte93640c62018-02-25 16:59:33 +0100678/***********************************************************************
Harald Welte629cc6b2018-03-11 17:19:05 +0100679 * SACCH handling
680 ***********************************************************************/
681
682private function f_exp_sacch(boolean exp) runs on ConnHdlr {
683 timer T_sacch := 3.0;
684 T_sacch.start;
685 alt {
686 [not exp] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) {
687 setverdict(fail, "Received SACCH when not expecting it");
Daniel Willmann17ddd852018-07-05 17:33:20 +0200688 mtc.stop;
Harald Welte629cc6b2018-03-11 17:19:05 +0100689 }
690 [not exp] T_sacch.timeout {
691 setverdict(pass);
692 }
693 [exp] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) {
694 setverdict(pass);
695 }
696 [exp] T_sacch.timeout {
697 setverdict(fail, "Timeout waiting for SACCH on ", g_chan_nr);
Daniel Willmann17ddd852018-07-05 17:33:20 +0200698 mtc.stop;
Harald Welte629cc6b2018-03-11 17:19:05 +0100699 }
700 [] L1CTL.receive { repeat; }
701 [] RSL.receive { repeat; }
702 }
703}
704
705/* Test if DEACTIVATE SACCH actualy deactivates its transmission (TS 48.058 4.6) */
706private function f_TC_deact_sacch(charstring id) runs on ConnHdlr {
707 f_l1_tune(L1CTL);
708 RSL.clear;
709
710 /* activate the logical channel */
711 f_est_dchan();
712 L1CTL.clear;
713
714 /* check that SACCH actually are received as expected */
715 f_exp_sacch(true);
716
717 /* deactivate SACCH on the logical channel */
718 RSL.send(ts_RSL_DEACT_SACCH(g_chan_nr));
719 f_sleep(1.0);
720 L1CTL.clear;
721
722 /* check that no SACCH are received anymore */
723 f_exp_sacch(false);
724
725 /* release the channel */
726 f_rsl_chan_deact();
727 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
728}
729testcase TC_deact_sacch() runs on test_CT {
730 var ConnHdlr vc_conn;
731 var ConnHdlrPars pars;
732 f_init();
733 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
734 //for (var integer i := 0; i < 1; i := i+1) {
735 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
736 log(testcasename(), ": Starting for ", g_AllChannels[i]);
737 vc_conn := f_start_handler(refers(f_TC_deact_sacch), pars);
738 vc_conn.done;
739 }
740 /* TODO: do the above in parallel, rather than sequentially? */
741 f_shutdown();
742}
743
Harald Welte55700662018-03-12 13:15:43 +0100744/* verify that given SACCH payload is present */
Harald Welteea17b912018-03-11 22:29:31 +0100745private function f_sacch_present(template octetstring l3_exp) runs on ConnHdlr {
746 var L1ctlDlMessage dl;
747 /* check that the specified SI5 value is actually sent */
748 timer T_sacch := 3.0;
749 L1CTL.clear;
750 T_sacch.start;
751 alt {
752 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) -> value dl {
753 var octetstring l3 := substr(dl.payload.data_ind.payload, 4, 19);
754 if (match(l3, l3_exp)) {
755 setverdict(pass);
756 } else {
757 repeat;
758 }
759 }
760 [] L1CTL.receive { repeat; }
761 [] T_sacch.timeout {
762 setverdict(fail, "Timeout waiting for SACCH ", l3_exp);
Daniel Willmann17ddd852018-07-05 17:33:20 +0200763 mtc.stop;
Harald Welteea17b912018-03-11 22:29:31 +0100764 }
765 }
766}
767
Harald Welte55700662018-03-12 13:15:43 +0100768/* verify that given SACCH payload is not present */
769private function f_sacch_missing(template octetstring l3_exp) runs on ConnHdlr {
770 var L1ctlDlMessage dl;
771 /* check that the specified SI5 value is actually sent */
772 timer T_sacch := 3.0;
773 L1CTL.clear;
774 T_sacch.start;
775 alt {
776 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) -> value dl {
777 var octetstring l3 := substr(dl.payload.data_ind.payload, 4, 19);
778 if (match(l3, l3_exp)) {
779 setverdict(fail, "Received unexpected SACCH ", dl);
Daniel Willmann3487a852018-07-05 15:41:59 +0200780 mtc.stop;
Harald Welte55700662018-03-12 13:15:43 +0100781 } else {
782 repeat;
783 }
784 }
785 [] L1CTL.receive { repeat; }
786 [] T_sacch.timeout {
787 setverdict(pass);
788 }
789 }
790}
791
Harald Welte629cc6b2018-03-11 17:19:05 +0100792/* Test for default SACCH FILL transmitted in DL SACCH (all channel types) */
Harald Welteea17b912018-03-11 22:29:31 +0100793private function f_TC_sacch_filling(charstring id) runs on ConnHdlr {
794 /* Set a known default SACCH filling for SI5 */
795 var octetstring si5 := f_rnd_octstring(19);
796 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5));
797
798 f_l1_tune(L1CTL);
799 RSL.clear;
800
801 /* activate the logical channel */
802 f_est_dchan();
803
804 /* check that the specified SI5 value is actually sent */
805 f_sacch_present(si5);
806
807 /* release the channel */
808 RSL.clear;
809 f_rsl_chan_deact();
810 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
811}
812testcase TC_sacch_filling() runs on test_CT {
813 var ConnHdlr vc_conn;
814 var ConnHdlrPars pars;
815 f_init();
816 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
817 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
818 log(testcasename(), ": Starting for ", g_AllChannels[i]);
819 vc_conn := f_start_handler(refers(f_TC_sacch_filling), pars);
820 vc_conn.done;
821 }
822 /* TODO: do the above in parallel, rather than sequentially? */
823 f_shutdown();
824}
825
Harald Welte629cc6b2018-03-11 17:19:05 +0100826/* Test for lchan-specific SACCH INFO MODIFY (TS 48.058 4.12) */
Harald Welteea17b912018-03-11 22:29:31 +0100827private function f_TC_sacch_info_mod(charstring id) runs on ConnHdlr {
828 /* Set a known default SACCH filling for SI5 */
829 var octetstring si5 := f_rnd_octstring(19);
830 var octetstring si5_diff := f_rnd_octstring(19);
831 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5));
832
833 f_l1_tune(L1CTL);
834 RSL.clear;
835
836 log("Activating channel, expecting standard SI5");
837 /* activate the logical channel */
838 f_est_dchan();
839 /* check that the specified SI5 value is actually sent */
840 f_sacch_present(si5);
841
842 /* set channel-specific different SI5 */
843 log("Setting channel specific SACCH INFO, expecting it");
844 RSL.send(ts_RSL_SACCH_INF_MOD(g_chan_nr, RSL_SYSTEM_INFO_5, si5_diff))
845 /* check that the specified lchan-specific value is now used */
846 f_sacch_present(si5_diff);
847
848 /* deactivate the channel and re-activate it, this should result in default SI5 */
849 log("De-activating and re-activating channel, expecting standard SI5");
850 f_rsl_chan_deact();
851 f_rsl_chan_act(valueof(ts_RSL_ChanMode_SIGN));
852 /* Verify that the TRX-wide default SACCH filling is present again */
853 f_sacch_present(si5);
854
855 /* release the channel */
856 RSL.clear;
857 f_rsl_chan_deact();
858 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
859}
860testcase TC_sacch_info_mod() runs on test_CT {
861 var ConnHdlr vc_conn;
862 var ConnHdlrPars pars;
863 f_init();
864 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
865 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
866 log(testcasename(), ": Starting for ", g_AllChannels[i]);
867 vc_conn := f_start_handler(refers(f_TC_sacch_info_mod), pars);
868 vc_conn.done;
869 }
870 /* TODO: do the above in parallel, rather than sequentially? */
871 f_shutdown();
872}
873
Harald Welte075d84c2018-03-12 13:07:24 +0100874/* Test SACCH scheduling of multiple different SI message types */
875private function f_TC_sacch_multi(charstring id) runs on ConnHdlr {
876 var octetstring si5 := f_rnd_octstring(19);
877 var octetstring si5bis := f_rnd_octstring(19);
878 var octetstring si5ter := f_rnd_octstring(19);
879 var octetstring si6 := f_rnd_octstring(19);
880
881 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5));
882 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5bis, si5bis));
883 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5ter, si5ter));
884 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, si6));
885
886 f_l1_tune(L1CTL);
887 RSL.clear;
888
889 /* activate the logical channel */
890 f_est_dchan();
891 L1CTL.clear;
892
893 /* check that SACCH actually are received as expected */
894 f_sacch_present(si5);
895 f_sacch_present(si5bis);
896 f_sacch_present(si5ter);
897 f_sacch_present(si6);
898
899 /* release the channel */
900 f_rsl_chan_deact();
901 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
902}
903testcase TC_sacch_multi() runs on test_CT {
904 var ConnHdlr vc_conn;
905 var ConnHdlrPars pars;
906 f_init();
907 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
908 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
909 log(testcasename(), ": Starting for ", g_AllChannels[i]);
910 vc_conn := f_start_handler(refers(f_TC_sacch_multi), pars);
911 vc_conn.done;
912 }
913 /* TODO: do the above in parallel, rather than sequentially? */
914 f_shutdown();
915}
916
Harald Welte55700662018-03-12 13:15:43 +0100917/* Test if SACH information is modified as expected */
918private function f_TC_sacch_multi_chg(charstring id) runs on ConnHdlr {
919 var octetstring si5 := f_rnd_octstring(19);
920 var octetstring si6 := f_rnd_octstring(19);
921
922 /* First, configure both SI5 and SI6 to be transmitted */
923 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5));
924 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, si6));
925
926 f_l1_tune(L1CTL);
927 RSL.clear;
928
929 /* activate the logical channel */
930 f_est_dchan();
931 L1CTL.clear;
932
933 /* check that SACCH actually are received as expected */
934 f_sacch_present(si5);
935 f_sacch_present(si6);
936
937 /* disable SI6 */
938 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, ''O));
939
940 /* check that SI5 is still transmitted */
941 f_sacch_present(si5);
942 /* check if SI6 is now gone */
943 f_sacch_missing(si6);
944
945 /* release the channel */
946 f_rsl_chan_deact();
947 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
948}
949testcase TC_sacch_multi_chg() runs on test_CT {
950 var ConnHdlr vc_conn;
951 var ConnHdlrPars pars;
952 f_init();
953 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
954 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
955 log(testcasename(), ": Starting for ", g_AllChannels[i]);
956 vc_conn := f_start_handler(refers(f_TC_sacch_multi_chg), pars);
957 vc_conn.done;
958 }
959 /* TODO: do the above in parallel, rather than sequentially? */
960 f_shutdown();
961}
962
Harald Welte075d84c2018-03-12 13:07:24 +0100963/* TODO: Test for SACCH information present in RSL CHAN ACT (overrides FILLING) */
964/* TODO: Test for SACCH transmission rules in the context of special CHAN ACT (HO) */
Harald Welte629cc6b2018-03-11 17:19:05 +0100965
966
967/***********************************************************************
Harald Welte93640c62018-02-25 16:59:33 +0100968 * RACH Handling
969 ***********************************************************************/
970
Harald Welte8c24c2b2018-02-26 08:31:31 +0100971/* like L1SAP_IS_PACKET_RACH */
972private function ra_is_ps(OCT1 ra) return boolean {
Harald Welte56c05802018-02-28 21:39:35 +0100973 if ((ra and4b 'F0'O == '70'O) and (ra and4b '0F'O != '0F'O)) {
Harald Welte8c24c2b2018-02-26 08:31:31 +0100974 return true;
975 }
976 return false;
977}
978
979/* generate a random RACH for circuit-switched */
980private function f_rnd_ra_cs() return OCT1 {
981 var OCT1 ra;
982 do {
983 ra := f_rnd_octstring(1);
984 } while (ra_is_ps(ra));
985 return ra;
986}
987
Harald Welte883340c2018-02-28 18:59:29 +0100988/* generate a random RACH for packet-switched */
989private function f_rnd_ra_ps() return OCT1 {
990 var OCT1 ra;
991 do {
992 ra := f_rnd_octstring(1);
993 } while (not ra_is_ps(ra));
994 return ra;
995}
996
Harald Welte8c24c2b2018-02-26 08:31:31 +0100997/* Send 1000 RACH requests and check their RA+FN on the RSL side */
998testcase TC_rach_content() runs on test_CT {
999 f_init(testcasename());
1000 f_init_l1ctl();
Harald Welte68e495b2018-02-25 00:05:57 +01001001 f_l1_tune(L1CTL);
Harald Welte70767382018-02-21 12:16:40 +01001002
Harald Welte8c24c2b2018-02-26 08:31:31 +01001003 var GsmFrameNumber fn_last := 0;
1004 for (var integer i := 0; i < 1000; i := i+1) {
1005 var OCT1 ra := f_rnd_ra_cs();
1006 var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra));
1007 if (fn == fn_last) {
1008 setverdict(fail, "Two RACH in same FN?!?");
Daniel Willmann17ddd852018-07-05 17:33:20 +02001009 mtc.stop;
Harald Welte8c24c2b2018-02-26 08:31:31 +01001010 }
1011 fn_last := fn;
1012
1013 timer T := 5.0;
Harald Welte56c05802018-02-28 21:39:35 +01001014 T.start;
Harald Welte8c24c2b2018-02-26 08:31:31 +01001015 alt {
1016 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_CHAN_RQD(ra, fn, ?))) {
1017 T.stop;
1018 }
1019 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_CHAN_RQD(?, ?, ?))) {
1020 setverdict(fail, "Unexpected CHAN RQD");
Daniel Willmann17ddd852018-07-05 17:33:20 +02001021 mtc.stop;
Harald Welte8c24c2b2018-02-26 08:31:31 +01001022 }
1023 [] RSL_CCHAN.receive { repeat; }
1024 [] T.timeout {
1025 setverdict(fail, "Timeout waiting for CHAN RQD");
Daniel Willmann17ddd852018-07-05 17:33:20 +02001026 mtc.stop;
Harald Welte8c24c2b2018-02-26 08:31:31 +01001027 }
1028 }
1029 }
1030 setverdict(pass);
Harald Welte294b0a22018-03-10 23:26:48 +01001031 f_shutdown();
Harald Welte70767382018-02-21 12:16:40 +01001032}
Harald Welte8c24c2b2018-02-26 08:31:31 +01001033
1034/* Send 1000 RACH Requests (flood ~ 89/s) and count if count(Abis) == count(Um) */
1035testcase TC_rach_count() runs on test_CT {
Harald Welte294b0a22018-03-10 23:26:48 +01001036 f_init();
Harald Welte8c24c2b2018-02-26 08:31:31 +01001037 f_init_l1ctl();
Harald Welte294b0a22018-03-10 23:26:48 +01001038 f_sleep(1.0);
Harald Welte8c24c2b2018-02-26 08:31:31 +01001039 f_l1_tune(L1CTL);
1040
1041 var GsmFrameNumber fn_last := 0;
1042 for (var integer i := 0; i < 1000; i := i+1) {
1043 var OCT1 ra := f_rnd_ra_cs();
1044 var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra));
1045 if (fn == fn_last) {
1046 setverdict(fail, "Two RACH in same FN?!?");
Daniel Willmann17ddd852018-07-05 17:33:20 +02001047 mtc.stop;
Harald Welte8c24c2b2018-02-26 08:31:31 +01001048 }
1049 fn_last := fn;
1050 }
1051 var integer rsl_chrqd := 0;
1052 timer T := 3.0;
Harald Welte56c05802018-02-28 21:39:35 +01001053 T.start;
Harald Welte8c24c2b2018-02-26 08:31:31 +01001054 alt {
1055 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_CHAN_RQD(?,?))) {
1056 rsl_chrqd := rsl_chrqd + 1;
Harald Weltec3a3f452018-02-26 17:37:47 +01001057 f_timer_safe_restart(T);
Harald Welte8c24c2b2018-02-26 08:31:31 +01001058 repeat;
1059 }
1060 [] RSL_CCHAN.receive { repeat; }
1061 [] T.timeout { }
1062 }
1063 if (rsl_chrqd == 1000) {
1064 setverdict(pass);
1065 } else {
1066 setverdict(fail, "Received only ", rsl_chrqd, " out of 1000 RACH");
1067 }
Harald Welte294b0a22018-03-10 23:26:48 +01001068 f_shutdown();
Harald Welte70767382018-02-21 12:16:40 +01001069}
1070
Harald Welte54a2a2d2018-02-26 09:14:05 +01001071private function f_main_trxc_connect() runs on test_CT {
1072 map(self:BB_TRXC, system:BB_TRXC);
1073 var Result res;
Harald Welted3a88a62018-03-01 16:04:52 +01001074 res := TRXC_CodecPort_CtrlFunct.f_IPL4_connect(BB_TRXC, mp_bb_trxc_ip, mp_bb_trxc_port,
1075 "", -1, -1, {udp:={}}, {});
Harald Welte9220f632018-05-23 20:27:02 +02001076 if (not ispresent(res.connId)) {
1077 setverdict(fail, "Could not connect to trx-control interface of trxcon, check your configuration");
Daniel Willmann17ddd852018-07-05 17:33:20 +02001078 mtc.stop;
Harald Welte9220f632018-05-23 20:27:02 +02001079 }
Harald Welte54a2a2d2018-02-26 09:14:05 +01001080 g_bb_trxc_conn_id := res.connId;
1081}
1082
1083private function f_rach_toffs(int16_t toffs256, boolean expect_pass) runs on test_CT {
Harald Weltef8df4cb2018-03-10 15:15:08 +01001084 var TrxcMessage ret;
Harald Welte54a2a2d2018-02-26 09:14:05 +01001085 /* tell fake_trx to use a given timing offset for all bursts */
Harald Weltef8df4cb2018-03-10 15:15:08 +01001086 ret := f_TRXC_transceive(BB_TRXC, g_bb_trxc_conn_id, valueof(ts_TRXC_FAKE_TIMING(toffs256)));
Harald Welte54a2a2d2018-02-26 09:14:05 +01001087 f_sleep(0.5);
1088
1089 /* Transmit RACH request + wait for confirmation */
1090 var OCT1 ra := f_rnd_ra_cs();
1091 var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra));
1092
1093 /* Check for expected result */
1094 timer T := 1.5;
1095 T.start;
1096 alt {
1097 [expect_pass] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_CHAN_RQD(ra, fn))) {
1098 setverdict(pass);
1099 }
1100 [not expect_pass] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_CHAN_RQD(ra, fn))) {
Harald Welteb3e30942018-03-02 10:33:42 +01001101 setverdict(fail, "RACH passed but was expected to be dropped: ", toffs256);
Daniel Willmann17ddd852018-07-05 17:33:20 +02001102 mtc.stop;
Harald Welte54a2a2d2018-02-26 09:14:05 +01001103 }
1104 [] RSL_CCHAN.receive { repeat; }
1105 [not expect_pass] T.timeout {
1106 setverdict(pass);
1107 }
1108 [expect_pass] T.timeout {
1109 setverdict(fail, "Timeout waiting for CHAN RQD");
Daniel Willmann17ddd852018-07-05 17:33:20 +02001110 mtc.stop;
Harald Welte54a2a2d2018-02-26 09:14:05 +01001111 }
1112 }
1113}
1114
1115/* Test if dropping of RACH Based on NM_ATT_MAX_TA works */
1116testcase TC_rach_max_ta() runs on test_CT {
1117 f_init(testcasename());
1118 f_init_l1ctl();
1119 f_l1_tune(L1CTL);
Harald Welte54a2a2d2018-02-26 09:14:05 +01001120 f_sleep(1.0);
1121
1122 /* default max-ta is 63 (full range of GSM timing advance */
1123
Vadim Yanitskiyc81d6e42018-03-05 22:39:01 +07001124 /* We allow early arrival up to 2 symbols */
1125 f_rach_toffs(-1*256, true);
1126 f_rach_toffs(-2*256, true);
Harald Welte54a2a2d2018-02-26 09:14:05 +01001127 f_rach_toffs(-10*256, false);
1128
1129 /* 0 / 32 / 63 bits is legal / permitted */
1130 f_rach_toffs(0, true);
1131 f_rach_toffs(32*256, true);
1132 f_rach_toffs(63*256, true);
1133
1134 /* more than 63 bits is not legal / permitted */
1135 f_rach_toffs(64*256, false);
1136 f_rach_toffs(127*256, false);
Harald Welte294b0a22018-03-10 23:26:48 +01001137 f_shutdown();
Harald Welte54a2a2d2018-02-26 09:14:05 +01001138}
Harald Welte8c24c2b2018-02-26 08:31:31 +01001139
Harald Welte93640c62018-02-25 16:59:33 +01001140/***********************************************************************
1141 * Measurement Processing / Reporting
1142 ***********************************************************************/
1143
Harald Welte70767382018-02-21 12:16:40 +01001144template LapdmAddressField ts_LapdmAddr(LapdmSapi sapi, boolean c_r) := {
1145 spare := '0'B,
1146 lpd := 0,
1147 sapi := sapi,
1148 c_r := c_r,
1149 ea := true
1150}
1151
Harald Welted879bd92018-03-12 15:01:23 +01001152template LapdmFrameAB ts_LAPDm_AB(LapdmSapi sapi, boolean c_r, boolean p, octetstring pl) := {
Harald Welte70767382018-02-21 12:16:40 +01001153 addr := ts_LapdmAddr(sapi, c_r),
Harald Welted879bd92018-03-12 15:01:23 +01001154 ctrl := ts_LapdmCtrlUI(p),
Harald Welte70767382018-02-21 12:16:40 +01001155 len := 0, /* overwritten */
1156 m := false,
1157 el := 1,
1158 payload := pl
1159}
1160
1161/* handle incoming downlink SACCH and respond with uplink SACCH (meas res) */
1162altstep as_l1_sacch() runs on ConnHdlr {
1163 var L1ctlDlMessage l1_dl;
Harald Weltef8df4cb2018-03-10 15:15:08 +01001164 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl {
Harald Welte70767382018-02-21 12:16:40 +01001165 log("SACCH received: ", l1_dl.payload.data_ind.payload);
Pau Espin Pedrole9571aa2018-10-22 17:13:07 +02001166 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 +01001167 var LapdmFrameAB lb := valueof(ts_LAPDm_AB(0, false, false, enc_GsmRrL3Message(meas_rep)));
Harald Welte70767382018-02-21 12:16:40 +01001168 log("LAPDm: ", lb);
Pau Espin Pedroled359cb2018-09-28 16:08:24 +02001169
1170 var L1ctlDataReq data_req := {
1171 l1header := valueof(ts_SacchL1Header(g_pars.l1_pars.ms_power_level, false, g_pars.l1_pars.ms_actual_ta)),
1172 l2_payload := f_pad_oct(enc_LapdmFrameAB(lb), 21, '2B'O)
1173 }
1174 log("Sending Measurement Report: ", data_req);
1175 L1CTL.send(ts_L1CTL_DATA_REQ_SACCH(g_chan_nr, ts_RslLinkID_SACCH(0), data_req));
Harald Welte70767382018-02-21 12:16:40 +01001176 repeat;
1177 }
1178}
1179
1180altstep as_l1_dcch() runs on ConnHdlr {
1181 var L1ctlDlMessage l1_dl;
Harald Weltef8df4cb2018-03-10 15:15:08 +01001182 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_DCCH(?))) -> value l1_dl {
Harald Welte70767382018-02-21 12:16:40 +01001183 log("DCCH received: ", l1_dl.payload.data_ind.payload);
1184 var octetstring pl := '010301'O;
Vadim Yanitskiy31e7c672018-07-27 02:23:16 +07001185 L1CTL.send(ts_L1CTL_DATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0),
1186 f_pad_oct(pl, 23, '2B'O)));
Harald Welte70767382018-02-21 12:16:40 +01001187 repeat;
1188 }
1189}
1190
1191type record MeasElem {
1192 uint6_t rxlev,
1193 uint3_t rxqual
1194}
1195
1196type record MeasElemFS {
1197 MeasElem full,
1198 MeasElem sub
1199}
1200
1201type record ConnL1Pars {
1202 boolean dtx_enabled,
Harald Welte685d5982018-02-27 20:42:05 +01001203 boolean toa256_enabled,
Harald Welte70767382018-02-21 12:16:40 +01001204 MeasElemFS meas_ul,
1205 int16_t timing_offset_256syms,
1206 uint5_t bs_power_level,
1207 uint5_t ms_power_level,
1208 uint8_t ms_actual_ta
1209}
1210
1211/* Convert tiing offset from 1/256th symbol to RSL Timing Offset */
1212private function toffs256s_to_rsl(int16_t toffs256s) return uint8_t {
1213 return 63 + (toffs256s/256);
1214}
1215
Harald Welted5684392018-03-10 18:22:04 +01001216private function f_max(integer a, integer b) return integer {
1217 if (a > b) {
1218 return a;
1219 } else {
1220 return b;
1221 }
1222}
1223
1224private function f_min(integer a, integer b) return integer {
1225 if (a < b) {
1226 return a;
1227 } else {
1228 return b;
1229 }
1230}
1231
1232/* compute negative tolerance val-tolerance, ensure >= min */
1233private function f_tolerance_neg(integer val, integer min, integer tolerance) return integer {
1234 val := val - tolerance;
1235 return f_max(val, min);
1236}
1237
1238/* compute positive tolerance val+tolerance, ensure <= max */
1239private function f_tolerance_pos(integer val, integer max, integer tolerance) return integer {
1240 val := val + tolerance;
1241 return f_min(val, max);
1242}
1243
1244/* return a template of (val-tolerance .. val+tolerance) ensuring it is within (min .. max) */
1245private function f_tolerance(integer val, integer min, integer max, integer tolerance)
1246return template integer {
1247 var template integer ret;
1248 ret := (f_tolerance_neg(val, min, tolerance) .. f_tolerance_pos(val, max, tolerance));
1249 return ret;
1250}
1251
1252
Harald Welte70767382018-02-21 12:16:40 +01001253/* build a template for matching measurement results against */
1254private function f_build_meas_res_tmpl() runs on ConnHdlr return template RSL_Message {
1255 var ConnL1Pars l1p := g_pars.l1_pars;
1256 var template RSL_IE_UplinkMeas ul_meas := {
1257 len := 3,
1258 rfu := '0'B,
1259 dtx_d := l1p.dtx_enabled,
Harald Welted5684392018-03-10 18:22:04 +01001260 rxlev_f_u := f_tolerance(l1p.meas_ul.full.rxlev, 0, 63, mp_tolerance_rxlev),
Harald Welte70767382018-02-21 12:16:40 +01001261 reserved1 := '00'B,
Harald Welted5684392018-03-10 18:22:04 +01001262 rxlev_s_u := f_tolerance(l1p.meas_ul.sub.rxlev, 0, 63, mp_tolerance_rxlev),
Harald Welte70767382018-02-21 12:16:40 +01001263 reserved2 := '00'B,
Harald Welted5684392018-03-10 18:22:04 +01001264 rxq_f_u := f_tolerance(l1p.meas_ul.full.rxqual, 0, 7, mp_tolerance_rxqual),
1265 rxq_s_u := f_tolerance(l1p.meas_ul.sub.rxqual, 0, 7, mp_tolerance_rxqual),
Harald Welte70767382018-02-21 12:16:40 +01001266 supp_meas_info := omit
1267 };
Harald Welte685d5982018-02-27 20:42:05 +01001268 if (l1p.toa256_enabled) {
Harald Welte15de8ba2018-06-29 08:51:42 +02001269 ul_meas.len := (3+8);
1270 ul_meas.supp_meas_info := {
Pau Espin Pedrol121724c2018-09-28 15:58:12 +02001271 toa256_mean := f_tolerance(l1p.timing_offset_256syms, -63*256, 192*256, mp_tolerance_timing_offset_256syms),
Harald Welte15de8ba2018-06-29 08:51:42 +02001272 toa256_min := ?,
1273 toa256_max := ?,
1274 toa256_std_dev := ?
1275 }
Harald Welte685d5982018-02-27 20:42:05 +01001276 }
Harald Welte70767382018-02-21 12:16:40 +01001277 var template RSL_IE_BS_Power bs_power := {
1278 reserved := 0,
1279 epc := false,
1280 fpc := false,
1281 power_level := l1p.bs_power_level
1282 };
1283 var template RSL_IE_L1Info l1_info := {
1284 ms_power_lvl := l1p.ms_power_level,
1285 fpc := false,
1286 reserved := 0,
Pau Espin Pedrol121724c2018-09-28 15:58:12 +02001287 actual_ta := f_tolerance(l1p.ms_actual_ta, 0, 63, mp_tolerance_timing_offset_256syms/256)
Harald Welte70767382018-02-21 12:16:40 +01001288 };
1289 var uint8_t offs := toffs256s_to_rsl(l1p.timing_offset_256syms);
Pau Espin Pedrol121724c2018-09-28 15:58:12 +02001290 var template uint8_t t_toffs := f_tolerance(offs, 0, 255, mp_tolerance_timing_offset_256syms/256);
Harald Welte70767382018-02-21 12:16:40 +01001291 return tr_RSL_MEAS_RES_OSMO(g_chan_nr, g_next_meas_res_nr, ul_meas, bs_power, l1_info,
1292 ?, t_toffs);
1293}
1294
1295/* verify we regularly receive measurement reports with incrementing numbers */
Vadim Yanitskiy41baf002018-10-04 17:44:50 +07001296altstep as_meas_res(boolean verify_meas := true) runs on ConnHdlr {
Harald Welte70767382018-02-21 12:16:40 +01001297 var RSL_Message rsl;
Vadim Yanitskiy41baf002018-10-04 17:44:50 +07001298 [not verify_meas] RSL.receive(tr_RSL_MEAS_RES(?)) { repeat; }
Harald Welte70767382018-02-21 12:16:40 +01001299 [] RSL.receive(f_build_meas_res_tmpl()) -> value rsl {
1300 /* increment counter of next to-be-expected meas rep */
1301 g_next_meas_res_nr := (g_next_meas_res_nr + 1) mod 256;
1302 /* Re-start the timer expecting the next MEAS RES */
Harald Weltec3a3f452018-02-26 17:37:47 +01001303 f_timer_safe_restart(g_Tmeas_exp);
Harald Welte70767382018-02-21 12:16:40 +01001304 repeat;
1305 }
1306 [] RSL.receive(tr_RSL_MEAS_RES(g_chan_nr, g_next_meas_res_nr)) -> value rsl {
Harald Weltefa45e9e2018-03-10 18:59:03 +01001307 /* increment counter of next to-be-expected meas rep */
1308 g_next_meas_res_nr := (g_next_meas_res_nr + 1) mod 256;
1309 if (g_first_meas_res) {
1310 g_first_meas_res := false;
1311 repeat;
1312 } else {
1313 setverdict(fail, "Received unspecific MEAS RES ", rsl);
Daniel Willmann17ddd852018-07-05 17:33:20 +02001314 mtc.stop;
Harald Weltefa45e9e2018-03-10 18:59:03 +01001315 }
Harald Welte70767382018-02-21 12:16:40 +01001316 }
1317 [] RSL.receive(tr_RSL_MEAS_RES(?)) -> value rsl {
1318 setverdict(fail, "Received unexpected MEAS RES ", rsl);
Daniel Willmann17ddd852018-07-05 17:33:20 +02001319 mtc.stop;
Harald Welte70767382018-02-21 12:16:40 +01001320 }
Pau Espin Pedrol425b62f2018-07-06 16:11:43 +02001321 [g_Tmeas_exp.running] g_Tmeas_exp.timeout {
Harald Welte70767382018-02-21 12:16:40 +01001322 setverdict(fail, "Didn't receive expected measurement result")
Daniel Willmann17ddd852018-07-05 17:33:20 +02001323 mtc.stop;
Harald Welte70767382018-02-21 12:16:40 +01001324 }
1325}
1326
Harald Weltee613f962018-04-18 22:38:16 +02001327private function f_alg_id_to_l1ctl(RSL_AlgId rsl_alg_id) return uint8_t {
1328 select (rsl_alg_id) {
1329 case (RSL_ALG_ID_A5_0) { return 0; }
1330 case (RSL_ALG_ID_A5_1) { return 1; }
1331 case (RSL_ALG_ID_A5_2) { return 2; }
1332 case (RSL_ALG_ID_A5_3) { return 3; }
1333 case (RSL_ALG_ID_A5_4) { return 4; }
1334 case (RSL_ALG_ID_A5_5) { return 5; }
1335 case (RSL_ALG_ID_A5_6) { return 6; }
1336 case (RSL_ALG_ID_A5_7) { return 7; }
1337 case else {
1338 setverdict(fail, "Unknwon Algorithm ID");
Daniel Willmann17ddd852018-07-05 17:33:20 +02001339 mtc.stop;
Harald Weltee613f962018-04-18 22:38:16 +02001340 }
1341 }
1342}
1343
1344private function f_alg_id_to_l3(RSL_AlgId rsl_alg_id) return BIT3 {
1345 select (rsl_alg_id) {
1346 case (RSL_ALG_ID_A5_1) { return '000'B; }
1347 case (RSL_ALG_ID_A5_2) { return '001'B; }
1348 case (RSL_ALG_ID_A5_3) { return '010'B; }
1349 case (RSL_ALG_ID_A5_4) { return '011'B; }
1350 case (RSL_ALG_ID_A5_5) { return '100'B; }
1351 case (RSL_ALG_ID_A5_6) { return '101'B; }
1352 case (RSL_ALG_ID_A5_7) { return '110'B; }
1353 case else {
1354 setverdict(fail, "Unknwon Algorithm ID");
Daniel Willmann17ddd852018-07-05 17:33:20 +02001355 mtc.stop;
Harald Weltee613f962018-04-18 22:38:16 +02001356 }
1357 }
1358}
1359
1360
Harald Welte70767382018-02-21 12:16:40 +01001361/* Establish dedicated channel: L1CTL + RSL side */
Harald Weltee613f962018-04-18 22:38:16 +02001362private function f_est_dchan(boolean encr_enable := false) runs on ConnHdlr {
Harald Welte70767382018-02-21 12:16:40 +01001363 var GsmFrameNumber fn;
1364 var ImmediateAssignment imm_ass;
1365 var integer ra := 23;
1366
Pau Espin Pedrol99a7aca2018-09-28 16:10:32 +02001367 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 +01001368 fn := f_L1CTL_RACH(L1CTL, ra);
1369 /* This arrives on CCHAN, so we cannot test for receiving CHAN RQDhere */
1370 //RSL.receive(tr_RSL_CHAN_RQD(int2oct(23,1)));
1371
1372 /* Activate channel on BTS side */
Harald Weltee613f962018-04-18 22:38:16 +02001373 f_rsl_chan_act(g_pars.chan_mode, encr_enable);
Harald Welte70767382018-02-21 12:16:40 +01001374
1375 /* Send IMM.ASS via CCHAN */
1376 var ChannelDescription ch_desc := {
1377 chan_nr := g_pars.chan_nr,
1378 tsc := 7,
1379 h := false,
1380 arfcn := mp_trx0_arfcn,
1381 maio_hsn := omit
1382 };
1383 var MobileAllocation ma := {
1384 len := 0,
1385 ma := ''B
1386 };
1387 var GsmRrMessage rr_msg := valueof(ts_IMM_ASS(ra, fn, 0, ch_desc, ma));
1388 RSL.send(ts_RSL_IMM_ASSIGN(enc_GsmRrMessage(rr_msg)));
1389
1390 /* receive IMM.ASS on MS side */
1391 var ImmediateAssignment ia_um;
1392 ia_um := f_L1CTL_WAIT_IMM_ASS(L1CTL, ra, fn);
1393 /* enable dedicated mode */
1394 f_L1CTL_DM_EST_REQ_IA(L1CTL, ia_um);
Harald Weltee613f962018-04-18 22:38:16 +02001395 /* enable encryption, if requested */
1396 if (encr_enable) {
1397 var uint8_t alg_id := f_alg_id_to_l1ctl(g_pars.encr.alg_id);
1398 f_L1CTL_CRYPTO_REQ(L1CTL, g_pars.chan_nr, alg_id, g_pars.encr.key);
1399 }
Harald Weltefa45e9e2018-03-10 18:59:03 +01001400
1401 g_first_meas_res := true;
Harald Welte70767382018-02-21 12:16:40 +01001402}
1403
1404/* establish DChan, verify existance + contents of measurement reports */
1405function f_TC_meas_res_periodic(charstring id) runs on ConnHdlr {
Harald Welte68e495b2018-02-25 00:05:57 +01001406 f_l1_tune(L1CTL);
Harald Welte70767382018-02-21 12:16:40 +01001407 RSL.clear;
1408
Pau Espin Pedrol121724c2018-09-28 15:58:12 +02001409 if (mp_bb_trxc_port != -1) {
Pau Espin Pedrole9571aa2018-10-22 17:13:07 +02001410 f_trxc_fake_rssi(rxlev2dbm(mp_ul_rxlev_exp));
Pau Espin Pedrol121724c2018-09-28 15:58:12 +02001411 f_trx_fake_toffs256(g_pars.l1_pars.timing_offset_256syms);
1412 }
Harald Welte70767382018-02-21 12:16:40 +01001413
1414 f_est_dchan();
1415
1416 /* run for a number of seconds, send SACCH + FACCH from MS side and verify
1417 * RSL measurement reports on Abis side */
1418 timer T := 8.0;
1419 T.start;
1420 alt {
1421 [] as_l1_sacch();
1422 [] as_meas_res();
1423 [] as_l1_dcch();
1424 [] L1CTL.receive { repeat; }
1425 [g_Tmeas_exp.running] T.timeout {
Daniel Willmann17ddd852018-07-05 17:33:20 +02001426 /* as_meas_res() would have done setverdict(fail) / mtc.stop in case
Harald Welte70767382018-02-21 12:16:40 +01001427 * of any earlier errors, so if we reach this timeout, we're good */
1428 setverdict(pass);
1429 }
1430 [] T.timeout {
1431 setverdict(fail, "No MEAS RES received at all");
Daniel Willmann17ddd852018-07-05 17:33:20 +02001432 mtc.stop;
Harald Welte70767382018-02-21 12:16:40 +01001433 }
1434 }
1435 f_rsl_chan_deact();
Harald Welte3dc20462018-03-10 23:03:38 +01001436 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
Harald Welte70767382018-02-21 12:16:40 +01001437}
Harald Welte0472ab42018-03-12 15:02:26 +01001438
Harald Welte70767382018-02-21 12:16:40 +01001439testcase TC_meas_res_sign_tchf() runs on test_CT {
1440 var ConnHdlr vc_conn;
1441 var ConnHdlrPars pars;
1442 f_init(testcasename());
1443 for (var integer tn := 1; tn <= 4; tn := tn+1) {
1444 pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN));
1445 vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars);
1446 vc_conn.done;
1447 }
Harald Welte294b0a22018-03-10 23:26:48 +01001448 f_shutdown();
Harald Welte70767382018-02-21 12:16:40 +01001449}
1450testcase TC_meas_res_sign_tchh() runs on test_CT {
1451 var ConnHdlr vc_conn;
1452 var ConnHdlrPars pars;
1453 f_init(testcasename());
1454 for (var integer ss := 0; ss <= 1; ss := ss+1) {
1455 pars := valueof(t_Pars(t_RslChanNr_Lm(5, ss), ts_RSL_ChanMode_SIGN));
1456 vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars);
1457 vc_conn.done;
1458 }
Harald Welte294b0a22018-03-10 23:26:48 +01001459 f_shutdown();
Harald Welte70767382018-02-21 12:16:40 +01001460}
1461testcase TC_meas_res_sign_sdcch4() runs on test_CT {
1462 var ConnHdlr vc_conn;
1463 var ConnHdlrPars pars;
1464 f_init(testcasename());
1465 for (var integer ss := 0; ss <= 3; ss := ss+1) {
1466 pars := valueof(t_Pars(t_RslChanNr_SDCCH4(0, ss), ts_RSL_ChanMode_SIGN));
1467 vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars);
1468 vc_conn.done;
1469 }
Harald Welte294b0a22018-03-10 23:26:48 +01001470 f_shutdown();
Harald Welte70767382018-02-21 12:16:40 +01001471}
1472testcase TC_meas_res_sign_sdcch8() runs on test_CT {
1473 var ConnHdlr vc_conn;
1474 var ConnHdlrPars pars;
1475 f_init(testcasename());
1476 for (var integer ss := 0; ss <= 7; ss := ss+1) {
1477 pars := valueof(t_Pars(t_RslChanNr_SDCCH8(6, ss), ts_RSL_ChanMode_SIGN));
1478 vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars);
1479 vc_conn.done;
1480 }
Harald Welte294b0a22018-03-10 23:26:48 +01001481 f_shutdown();
Harald Welte70767382018-02-21 12:16:40 +01001482}
Harald Welte685d5982018-02-27 20:42:05 +01001483testcase TC_meas_res_sign_tchh_toa256() runs on test_CT {
1484 var ConnHdlr vc_conn;
1485 var ConnHdlrPars pars;
1486 f_init(testcasename());
1487 f_vty_config(BTSVTY, "bts 0", "supp-meas-info toa256");
1488 for (var integer ss := 0; ss <= 1; ss := ss+1) {
1489 pars := valueof(t_Pars(t_RslChanNr_Lm(5, ss), ts_RSL_ChanMode_SIGN));
1490 pars.l1_pars.toa256_enabled := true;
1491 vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars);
1492 vc_conn.done;
1493 }
Harald Welte294b0a22018-03-10 23:26:48 +01001494 f_shutdown();
Harald Welte685d5982018-02-27 20:42:05 +01001495}
1496
Harald Welte70767382018-02-21 12:16:40 +01001497
Harald Welte0472ab42018-03-12 15:02:26 +01001498/* 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 +01001499private function f_TC_conn_fail_crit(charstring id) runs on ConnHdlr {
Harald Welte68e495b2018-02-25 00:05:57 +01001500 f_l1_tune(L1CTL);
Harald Welte70767382018-02-21 12:16:40 +01001501 RSL.clear;
1502
1503 f_est_dchan();
1504 f_sleep(2.0);
Harald Weltef8df4cb2018-03-10 15:15:08 +01001505 L1CTL.send(ts_L1CTL_DM_REL_REQ(g_chan_nr));
Harald Welte70767382018-02-21 12:16:40 +01001506
1507 timer T := 40.0;
1508 T.start;
1509 alt {
1510 [] RSL.receive(tr_RSL_CONN_FAIL_IND(g_chan_nr, ?)) {
1511 setverdict(pass)
1512 }
1513 [] RSL.receive { repeat };
1514 [] T.timeout {
1515 setverdict(fail, "No CONN FAIL IND received");
Daniel Willmann17ddd852018-07-05 17:33:20 +02001516 mtc.stop;
Harald Welte70767382018-02-21 12:16:40 +01001517 }
1518 }
1519 f_rsl_chan_deact();
1520}
1521testcase TC_conn_fail_crit() runs on test_CT {
1522 var ConnHdlr vc_conn;
1523 var ConnHdlrPars pars;
1524 f_init(testcasename());
1525 pars := valueof(t_Pars(t_RslChanNr_SDCCH8(6, 3), ts_RSL_ChanMode_SIGN));
1526 pars.t_guard := 60.0;
1527 vc_conn := f_start_handler(refers(f_TC_conn_fail_crit), pars);
1528 vc_conn.done;
1529}
1530
Harald Welte93640c62018-02-25 16:59:33 +01001531/***********************************************************************
1532 * Paging
1533 ***********************************************************************/
1534
Harald Welte68e495b2018-02-25 00:05:57 +01001535function tmsi_is_dummy(TMSIP_TMSI_V tmsi) return boolean {
1536 if (tmsi == 'FFFFFFFF'O) {
1537 return true;
1538 } else {
1539 return false;
1540 }
1541}
Harald Welte70767382018-02-21 12:16:40 +01001542
Philipp Maier82cb0b12018-08-31 14:41:39 +02001543type record allowedFn { integer frame_nr }
1544template allowedFn bs_ag_blks_res_0 := { frame_nr := (6, 12, 16, 22, 26, 32, 36, 42, 46) }
1545template allowedFn bs_ag_blks_res_1 := { frame_nr := (12, 16, 22, 26, 32, 36, 42, 46) }
1546template allowedFn bs_ag_blks_res_2 := { frame_nr := (16, 22, 26, 32, 36, 42, 46) }
1547template allowedFn bs_ag_blks_res_3 := { frame_nr := (22, 26, 32, 36, 42, 46) }
1548template allowedFn bs_ag_blks_res_4 := { frame_nr := (26, 32, 36, 42, 46) }
1549template allowedFn bs_ag_blks_res_5 := { frame_nr := (32, 36, 42, 46) }
1550template allowedFn bs_ag_blks_res_6 := { frame_nr := (36, 42, 46) }
1551template allowedFn bs_ag_blks_res_7 := { frame_nr := (42, 46) }
1552function check_pch_fn(integer frame_nr, integer bs_ag_blks_res) runs on test_CT
1553{
1554 var integer frame_nr_51;
1555 frame_nr_51 := frame_nr mod 51
1556
1557 var allowedFn fn_check;
1558 fn_check.frame_nr := frame_nr_51;
1559
1560 if (bs_ag_blks_res < 0 or bs_ag_blks_res > 7) {
1561 setverdict(fail, "bs_ag_blks_res out of valid range (0..7)");
1562 mtc.stop;
1563 return;
1564 }
1565
1566 if (bs_ag_blks_res == 0 and match(fn_check, bs_ag_blks_res_0)) {
1567 return;
1568 }
1569 if (bs_ag_blks_res == 1 and match(fn_check, bs_ag_blks_res_1)) {
1570 return;
1571 }
1572 if (bs_ag_blks_res == 2 and match(fn_check, bs_ag_blks_res_2)) {
1573 return;
1574 }
1575 if (bs_ag_blks_res == 3 and match(fn_check, bs_ag_blks_res_3)) {
1576 return;
1577 }
1578 if (bs_ag_blks_res == 4 and match(fn_check, bs_ag_blks_res_4)) {
1579 return;
1580 }
1581 if (bs_ag_blks_res == 5 and match(fn_check, bs_ag_blks_res_5)) {
1582 return;
1583 }
1584 if (bs_ag_blks_res == 6 and match(fn_check, bs_ag_blks_res_6)) {
1585 return;
1586 }
1587 if (bs_ag_blks_res == 7 and match(fn_check, bs_ag_blks_res_7)) {
1588 return;
1589 }
1590
1591 setverdict(fail, "received paging on AGCH");
1592 mtc.stop;
1593 return;
1594}
1595
1596altstep 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 +01001597runs on test_CT {
1598 var L1ctlDlMessage dl;
Harald Weltef8df4cb2018-03-10 15:15:08 +01001599 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?, c_DummyUI)) {
Harald Welte68e495b2018-02-25 00:05:57 +01001600 repeat;
1601 }
Harald Weltef8df4cb2018-03-10 15:15:08 +01001602 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0))) -> value dl {
Harald Welte68e495b2018-02-25 00:05:57 +01001603 var octetstring without_plen :=
1604 substr(dl.payload.data_ind.payload, 1, lengthof(dl.payload.data_ind.payload)-1);
1605 var PDU_ML3_NW_MS rr := dec_PDU_ML3_NW_MS(without_plen);
Philipp Maier82cb0b12018-08-31 14:41:39 +02001606
1607 check_pch_fn(dl.dl_info.frame_nr, cfg.bs_ag_blks_res);
1608
Harald Welte68e495b2018-02-25 00:05:57 +01001609 if (match(rr, tr_PAGING_REQ1)) {
1610 num_paging_rcv_msgs := num_paging_rcv_msgs + 1;
1611 num_paging_rcv_ids := num_paging_rcv_ids + 1;
1612 if (isvalue(rr.msgs.rrm.pagingReq_Type1.mobileIdentity2)) {
1613 num_paging_rcv_ids := num_paging_rcv_ids + 1;
1614 }
1615 } else if (match(rr, tr_PAGING_REQ2)) {
1616 num_paging_rcv_msgs := num_paging_rcv_msgs + 1;
1617 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type2.mobileIdentity1)) {
1618 num_paging_rcv_ids := num_paging_rcv_ids + 1;
1619 }
1620 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type2.mobileIdentity2)) {
1621 num_paging_rcv_ids := num_paging_rcv_ids + 1;
1622 }
1623 if (isvalue(rr.msgs.rrm.pagingReq_Type2.mobileIdentity3)) {
1624 num_paging_rcv_ids := num_paging_rcv_ids + 1;
1625 }
1626 } else if (match(rr, tr_PAGING_REQ3)) {
1627 num_paging_rcv_msgs := num_paging_rcv_msgs + 1;
1628 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity1)) {
1629 num_paging_rcv_ids := num_paging_rcv_ids + 1;
1630 }
1631 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity2)) {
1632 num_paging_rcv_ids := num_paging_rcv_ids + 1;
1633 }
1634 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity3)) {
1635 num_paging_rcv_ids := num_paging_rcv_ids + 1;
1636 }
1637 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity4)) {
1638 num_paging_rcv_ids := num_paging_rcv_ids + 1;
1639 }
1640 }
1641 repeat;
1642 }
1643}
1644
1645type record PagingTestCfg {
1646 boolean combined_ccch,
1647 integer bs_ag_blks_res,
1648 float load_factor,
1649 boolean exp_load_ind,
1650 boolean exp_overload,
1651 boolean use_tmsi
1652}
1653
1654type record PagingTestState {
1655 integer num_paging_sent,
1656 integer num_paging_rcv_msgs,
1657 integer num_paging_rcv_ids,
1658 integer num_overload
1659}
1660
1661/* receive + ignore RSL RF RES IND */
1662altstep as_rsl_res_ind() runs on test_CT {
1663 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_RF_RES_IND)) {
1664 repeat;
1665 }
1666}
1667
1668/* Helper function for paging related testing */
1669private function f_TC_paging(PagingTestCfg cfg) runs on test_CT return PagingTestState {
1670 f_init(testcasename());
1671 f_init_l1ctl();
1672 f_l1_tune(L1CTL);
1673
1674 var PagingTestState st := {
1675 num_paging_sent := 0,
1676 num_paging_rcv_msgs := 0,
1677 num_paging_rcv_ids := 0,
1678 num_overload := 0
1679 };
1680
1681 var float max_pch_blocks_per_sec := f_pch_block_rate_est(cfg.combined_ccch, cfg.bs_ag_blks_res);
1682 var float max_pch_imsi_per_sec;
1683 if (cfg.use_tmsi) {
1684 max_pch_imsi_per_sec := max_pch_blocks_per_sec * 4.0; /* Type 3 */
1685 } else {
1686 max_pch_imsi_per_sec := max_pch_blocks_per_sec * 2.0; /* Type 1 */
1687 }
1688 var float pch_blocks_per_sec := max_pch_imsi_per_sec * cfg.load_factor;
1689 var float interval := 1.0 / pch_blocks_per_sec;
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02001690 var float time_total := 20.0;
1691 var integer pkt_total := float2int(time_total * pch_blocks_per_sec);
1692 log("pch_blocks_total=", pkt_total," pch_blocks_per_sec=", pch_blocks_per_sec, " interval=", interval);
Harald Welte68e495b2018-02-25 00:05:57 +01001693
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02001694 timer T_total := 300.0; /* big value (far bigger than time_total), used to count elapsed time */
1695 T_total.start;
Harald Welte68e495b2018-02-25 00:05:57 +01001696
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02001697 timer T_itv := 0.0;
1698 T_itv.start;
1699 while (st.num_paging_sent < pkt_total) {
Harald Welte68e495b2018-02-25 00:05:57 +01001700 alt {
1701 /* check for presence of CCCH LOAD IND (paging load) */
1702 [cfg.exp_overload] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_PAGING_LOAD_IND(0))) {
1703 st.num_overload := st.num_overload + 1;
1704 repeat;
1705 }
1706 [not cfg.exp_overload] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_PAGING_LOAD_IND(0))) {
1707 setverdict(fail, "Unexpected PCH Overload");
Daniel Willmann17ddd852018-07-05 17:33:20 +02001708 mtc.stop;
Harald Welte68e495b2018-02-25 00:05:57 +01001709 }
1710 [cfg.exp_load_ind] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_PAGING_LOAD_IND)) {
1711 log("Rx LOAD_IND");
1712 /* FIXME: analyze/verify interval + contents */
1713 repeat;
1714 }
1715 /* check if paging requests arrive on Um side */
Philipp Maier82cb0b12018-08-31 14:41:39 +02001716 [] as_l1_count_paging(st.num_paging_rcv_msgs, st.num_paging_rcv_ids, cfg);
Harald Welte68e495b2018-02-25 00:05:57 +01001717 [] L1CTL.receive { repeat; }
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02001718 [] T_itv.timeout {
1719 /* Send paging cmds based on elapsed time */
1720 var integer new_sent := f_min(pkt_total, float2int(T_total.read * pch_blocks_per_sec) + 1);
1721 while (st.num_paging_sent < new_sent) {
1722 /* build mobile Identity */
1723 var MobileL3_CommonIE_Types.MobileIdentityLV mi;
1724 if (cfg.use_tmsi) {
1725 mi := valueof(ts_MI_TMSI_LV(f_rnd_octstring(4)));
1726 } else {
1727 mi := valueof(ts_MI_IMSI_LV(f_gen_imsi(st.num_paging_sent)));
1728 }
1729 var octetstring mi_enc_lv := enc_MobileIdentityLV(mi);
1730 var octetstring mi_enc := substr(mi_enc_lv, 1, lengthof(mi_enc_lv)-1);
1731
1732 /* Send RSL PAGING COMMAND */
1733 RSL_CCHAN.send(ts_RSL_UD(ts_RSL_PAGING_CMD(mi_enc, st.num_paging_sent mod 4)));
1734
1735 st.num_paging_sent := st.num_paging_sent + 1;
1736 }
1737 if (st.num_paging_sent < pkt_total) {
1738 /* Wait for interval to next PAGING COMMAND */
1739 var float time_now := T_total.read;
1740 var float next_sched := int2float(st.num_paging_sent)*interval;
1741 if (next_sched > time_now) {
1742 T_itv.start(next_sched - time_now);
1743 } else {
1744 T_itv.start(0.0);
1745 }
1746 } else {
1747 /* We are done, no need to keep counting */
1748 T_total.stop;
1749 }
1750 }
1751 [] T_total.timeout { }
Harald Welte68e495b2018-02-25 00:05:57 +01001752 [] as_rsl_res_ind();
1753 }
1754 }
1755
1756 /* wait for max 18s for paging queue to drain (size: 200, ~ 13 per s -> 15s) */
1757 timer T_wait := 18.0;
1758 T_wait.start;
1759 alt {
Philipp Maier82cb0b12018-08-31 14:41:39 +02001760 [] as_l1_count_paging(st.num_paging_rcv_msgs, st.num_paging_rcv_ids, cfg);
Harald Welte68e495b2018-02-25 00:05:57 +01001761 [] L1CTL.receive { repeat; }
1762 /* 65535 == empty paging queue, we can terminate*/
1763 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_PAGING_LOAD_IND(65535))) { }
1764 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_PAGING_LOAD_IND)) { repeat; }
1765 [] T_wait.timeout {
1766 setverdict(fail, "Waiting for empty paging queue");
Daniel Willmann17ddd852018-07-05 17:33:20 +02001767 mtc.stop;
Harald Welte68e495b2018-02-25 00:05:57 +01001768 }
1769 [] as_rsl_res_ind();
1770 }
1771
1772 log("num_paging_sent=", st.num_paging_sent, " rcvd_msgs=", st.num_paging_rcv_msgs,
1773 " rcvd_ids=", st.num_paging_rcv_ids);
1774 return st;
1775}
1776
1777/* Create ~ 80% paging load (IMSI only) sustained for about 20s, verifying that
1778 * - the number of Mobile Identities on Um PCH match the number of pages on RSL
1779 * - that CCCH LOAD IND (PCH) are being generated
1780 * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */
1781testcase TC_paging_imsi_80percent() runs on test_CT {
Philipp Maierd65d0562018-08-30 16:25:47 +02001782 var SystemInformation si3 := valueof(ts_SI3_default);
Harald Welte68e495b2018-02-25 00:05:57 +01001783 var PagingTestCfg cfg := {
1784 combined_ccch := true,
Philipp Maierd65d0562018-08-30 16:25:47 +02001785 bs_ag_blks_res := si3.payload.si3.ctrl_chan_desc.bs_ag_blks_res,
Harald Welte68e495b2018-02-25 00:05:57 +01001786 load_factor := 0.8,
1787 exp_load_ind := true,
1788 exp_overload := false,
1789 use_tmsi := false
1790 };
1791 var PagingTestState st := f_TC_paging(cfg);
1792 if (st.num_paging_sent != st.num_paging_rcv_ids) {
1793 setverdict(fail, "Expected ", st.num_paging_sent, " pagings but have ",
1794 st.num_paging_rcv_ids);
1795 } else {
1796 setverdict(pass);
1797 }
Daniel Willmanna59afab2018-07-05 16:16:32 +02001798 f_shutdown();
Harald Welte68e495b2018-02-25 00:05:57 +01001799}
1800
1801/* Create ~ 80% paging load (TMSI only) sustained for about 20s, verifying that
1802 * - the number of Mobile Identities on Um PCH match the number of pages on RSL
1803 * - that CCCH LOAD IND (PCH) are being generated
1804 * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */
1805testcase TC_paging_tmsi_80percent() runs on test_CT {
Philipp Maierd65d0562018-08-30 16:25:47 +02001806 var SystemInformation si3 := valueof(ts_SI3_default);
Harald Welte68e495b2018-02-25 00:05:57 +01001807 var PagingTestCfg cfg := {
1808 combined_ccch := true,
Philipp Maierd65d0562018-08-30 16:25:47 +02001809 bs_ag_blks_res := si3.payload.si3.ctrl_chan_desc.bs_ag_blks_res,
Harald Welte68e495b2018-02-25 00:05:57 +01001810 load_factor := 0.8,
1811 exp_load_ind := true,
1812 exp_overload := false,
1813 use_tmsi := true
1814 };
1815 var PagingTestState st := f_TC_paging(cfg);
1816 if (st.num_paging_sent != st.num_paging_rcv_ids) {
1817 setverdict(fail, "Expected ", st.num_paging_sent, " pagings but have ",
1818 st.num_paging_rcv_ids);
1819 } else {
1820 setverdict(pass);
1821 }
Daniel Willmanna59afab2018-07-05 16:16:32 +02001822 f_shutdown();
Harald Welte68e495b2018-02-25 00:05:57 +01001823}
1824
1825/* Create ~ 200% paging load (IMSI only) sustained for about 20s, verifying that
1826 * - the number of Mobile Identities on Um PCH are ~ 82% of the number of pages on RSL
1827 * - that CCCH LOAD IND (PCH) are being generated and reach 0 at some point
1828 * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */
1829testcase TC_paging_imsi_200percent() runs on test_CT {
Philipp Maierd65d0562018-08-30 16:25:47 +02001830 var SystemInformation si3 := valueof(ts_SI3_default);
Harald Welte68e495b2018-02-25 00:05:57 +01001831 var PagingTestCfg cfg := {
1832 combined_ccch := true,
Philipp Maierd65d0562018-08-30 16:25:47 +02001833 bs_ag_blks_res := si3.payload.si3.ctrl_chan_desc.bs_ag_blks_res,
Harald Welte68e495b2018-02-25 00:05:57 +01001834 load_factor := 2.0,
1835 exp_load_ind := true,
1836 exp_overload := true,
1837 use_tmsi := false
1838 };
1839 var PagingTestState st := f_TC_paging(cfg);
1840 /* We expect about 80-85% to pass, given that we can fill the paging buffer of 200
1841 * slots and will fully drain that buffer before returning */
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02001842 var template integer tpl := (st.num_paging_sent*78/100 .. st.num_paging_sent *85/100);
Harald Welte68e495b2018-02-25 00:05:57 +01001843 if (not match(st.num_paging_rcv_ids, tpl)) {
1844 setverdict(fail, "Expected ", tpl, " pagings but have ", st.num_paging_rcv_ids);
1845 } else {
1846 setverdict(pass);
1847 }
Daniel Willmanna59afab2018-07-05 16:16:32 +02001848 f_shutdown();
Harald Welte68e495b2018-02-25 00:05:57 +01001849}
1850
1851/* Create ~ 200% paging load (TMSI only) sustained for about 20s, verifying that
1852 * - the number of Mobile Identities on Um PCH are ~ 82% of the number of pages on RSL
1853 * - that CCCH LOAD IND (PCH) are being generated and reach 0 at some point
1854 * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */
1855testcase TC_paging_tmsi_200percent() runs on test_CT {
Philipp Maierd65d0562018-08-30 16:25:47 +02001856 var SystemInformation si3 := valueof(ts_SI3_default);
Harald Welte68e495b2018-02-25 00:05:57 +01001857 var PagingTestCfg cfg := {
1858 combined_ccch := true,
Philipp Maierd65d0562018-08-30 16:25:47 +02001859 bs_ag_blks_res := si3.payload.si3.ctrl_chan_desc.bs_ag_blks_res,
Harald Welte68e495b2018-02-25 00:05:57 +01001860 load_factor := 2.0,
1861 exp_load_ind := true,
1862 exp_overload := true,
1863 use_tmsi := true
1864 };
1865 var PagingTestState st := f_TC_paging(cfg);
1866 /* We expect about 70% to pass, given that we can fill the paging buffer of 200
1867 * slots and will fully drain that buffer before returning */
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02001868 var template integer tpl := (st.num_paging_sent*64/100 .. st.num_paging_sent *72/100);
Harald Welte68e495b2018-02-25 00:05:57 +01001869 if (not match(st.num_paging_rcv_ids, tpl)) {
1870 setverdict(fail, "Expected ", tpl, " pagings but have ", st.num_paging_rcv_ids);
1871 } else {
1872 setverdict(pass);
1873 }
Daniel Willmanna59afab2018-07-05 16:16:32 +02001874 f_shutdown();
Harald Welte68e495b2018-02-25 00:05:57 +01001875}
1876
1877
Harald Welte93640c62018-02-25 16:59:33 +01001878/***********************************************************************
1879 * Immediate Assignment / AGCH
1880 ***********************************************************************/
Harald Weltee8d750e2018-06-10 21:41:35 +02001881const MobileAllocation c_MA_null := {
1882 len := 0,
1883 ma := ''B
1884}
Harald Welte93640c62018-02-25 16:59:33 +01001885
Harald Weltee8d750e2018-06-10 21:41:35 +02001886template (value) ChannelDescription ts_ChanDesc(template (value) RslChannelNr chan_nr, uint3_t tsc := 7,
1887 uint12_t arfcn := 871) := {
1888 chan_nr := chan_nr,
1889 tsc := tsc,
1890 h := false,
1891 arfcn := arfcn,
1892 maio_hsn := omit
1893}
1894
1895private function f_fmt_ia_stats(integer num_tx, integer num_rx, integer num_del) return charstring {
1896 return int2str(num_tx) & " sent, "
1897 & int2str(num_rx) & " received, "
1898 & int2str(num_del) & " deleted";
1899}
1900
1901private function f_TC_imm_ass(integer num_total, float sleep_s, float exp_pass) runs on test_CT {
1902 var L1ctlDlMessage l1_dl;
1903 timer T := 10.0;
1904 var integer num_tx := 0;
1905 var integer num_rx := 0;
1906 var integer num_del := 0;
1907 var charstring res_str;
1908 var float rx_ratio;
1909
Harald Welte68e495b2018-02-25 00:05:57 +01001910 f_init(testcasename());
Harald Weltee8d750e2018-06-10 21:41:35 +02001911 f_init_l1ctl();
1912 f_l1_tune(L1CTL);
1913
1914 for (var integer i := 0; i < num_total; i := i+1) {
1915 var ChannelDescription ch_desc := valueof(ts_ChanDesc(valueof(t_RslChanNr_SDCCH4(0, 0))));
1916 var GsmRrMessage ia := valueof(ts_IMM_ASS(42, i, 5, ch_desc, c_MA_null));
1917 var octetstring ia_enc := enc_GsmRrMessage(ia);
Harald Welte68e495b2018-02-25 00:05:57 +01001918 RSL_CCHAN.send(ts_RSL_UD(ts_RSL_IMM_ASSIGN(ia_enc, 0)));
Harald Weltee8d750e2018-06-10 21:41:35 +02001919 num_tx := num_tx+1;
1920 f_sleep(sleep_s);
Harald Welte68e495b2018-02-25 00:05:57 +01001921 }
1922 /* FIXME: check if imm.ass arrive on Um side */
Harald Weltee8d750e2018-06-10 21:41:35 +02001923 T.start;
1924 alt {
1925 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_DELETE_IND(?, 0))) {
1926 num_del := num_del+1;
1927 repeat;
1928 }
1929 [] RSL_CCHAN.receive {
1930 repeat;
1931 }
1932 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?)) -> value l1_dl {
1933 /* somehow dec_SystemInformation will try to decode even non-RR as SI */
1934 var GsmRrMessage rr := dec_GsmRrMessage(l1_dl.payload.data_ind.payload);
1935 if (not match(rr, tr_IMM_ASS(42, ?, 5, ?, ?))) {
1936 /* FIXME: Why are we seeing paging requests on PCH/AGCH? */
1937 //setverdict(fail, "Unexpected IMM-ASS values on AGCH: ", rr);
Daniel Willmann17ddd852018-07-05 17:33:20 +02001938 //mtc.stop;
Harald Weltee8d750e2018-06-10 21:41:35 +02001939 } else {
1940 num_rx := num_rx+1;
1941 }
1942 repeat;
1943 }
1944 [] L1CTL.receive { repeat; }
1945 [] T.timeout { }
1946 }
1947 res_str := f_fmt_ia_stats(num_tx, num_rx, num_del);
1948 log("AGCH test: " & res_str);
1949 if (num_rx + num_del != num_tx) {
1950 setverdict(fail, "RX + DEL != TX ?!?: " & res_str);
Daniel Willmann17ddd852018-07-05 17:33:20 +02001951 mtc.stop
Harald Weltee8d750e2018-06-10 21:41:35 +02001952 }
1953 rx_ratio := int2float(num_rx) / int2float(num_tx);
1954 if (rx_ratio < exp_pass*0.8 or rx_ratio > exp_pass*1.2) {
1955 setverdict(fail, "RX ratio ("&float2str(rx_ratio)&") far from expected ("&float2str(exp_pass)&") " & res_str);
1956 } else {
1957 setverdict(pass);
1958 }
Daniel Willmann17ddd852018-07-05 17:33:20 +02001959 f_shutdown();
Harald Welte68e495b2018-02-25 00:05:57 +01001960}
1961
Harald Weltee8d750e2018-06-10 21:41:35 +02001962/* send a long burst of 1000 IMM.ASS with 20ms spacing (50 per s); expect 75% of them to be deleted */
1963testcase TC_imm_ass_1000_20ms() runs on test_CT {
1964 f_TC_imm_ass(1000, 0.02, 0.25);
1965}
1966
1967/* send a short burst of 200 IMM.ASS without any spacing; expect 95% of them to be deleted */
1968testcase TC_imm_ass_200_0ms() runs on test_CT {
1969 f_TC_imm_ass(200, 0.0, 0.05);
1970}
1971
1972/* send 150 IMM.ASS at rate of 13/s; expect none of them to be deleted */
1973testcase TC_imm_ass_200_76ms() runs on test_CT {
1974 f_TC_imm_ass(150, 0.076, 1.00);
1975}
1976
1977
1978
Harald Welte48494ca2018-02-25 16:59:50 +01001979/***********************************************************************
1980 * BCCH
1981 ***********************************************************************/
1982
1983/* tuple of Frame Number + decoded SI */
1984type record SystemInformationFn {
1985 GsmFrameNumber frame_number,
1986 SystemInformation si
1987}
1988
1989/* an arbitrary-length vector of decoded SI + gsmtap header */
1990type record of SystemInformationFn SystemInformationVector;
1991
1992/* an array of SI-vectors indexed by TC value */
1993type SystemInformationVector SystemInformationVectorPerTc[8];
1994
1995/* determine if a given SI vector contains given SI type at least once */
1996function f_si_vecslot_contains(SystemInformationVector arr, RrMessageType key, boolean bcch_ext := false) return boolean {
1997 for (var integer i:= 0; i< sizeof(arr); i := i + 1) {
1998 var integer fn_mod51 := arr[i].frame_number mod 51;
1999 if (not bcch_ext and fn_mod51 == 2 or
2000 bcch_ext and fn_mod51 == 6) {
2001 if (arr[i].si.header.message_type == key) {
2002 return true;
2003 }
2004 }
2005 }
2006 return false;
2007}
2008
2009/* ensure a given TC slot of the SI vector contains given SI type at least once at TC */
2010function f_ensure_si_vec_contains(SystemInformationVectorPerTc arr, integer tc, RrMessageType key, boolean ext_bcch := false) {
2011 if (not f_si_vecslot_contains(arr[tc], key, ext_bcch)) {
2012 setverdict(fail, "No ", key, " in TC=", tc, "!");
Daniel Willmann17ddd852018-07-05 17:33:20 +02002013 mtc.stop;
Harald Welte48494ca2018-02-25 16:59:50 +01002014 }
2015}
2016
2017/* check if a given SI vector contains given SI type at least once on any TC */
2018function f_si_vec_contains(SystemInformationVectorPerTc arr, RrMessageType key) return boolean {
2019 for (var integer tc:= 0; tc < sizeof(arr); tc := tc + 1) {
2020 if (f_si_vecslot_contains(arr[tc], key) or
2021 f_si_vecslot_contains(arr[tc], key, true)) {
2022 return true;
2023 }
2024 }
2025 return false;
2026}
2027
2028/* determine if a given SI vector contains given SI type at least N of M times */
2029function f_si_vecslot_contains_n_of_m(SystemInformationVector arr, RrMessageType key, boolean bcch_ext := false, integer n := 1, integer m := 4) return boolean {
2030 var integer count := 0;
2031 if (sizeof(arr) < m) {
2032 setverdict(fail, "Error: Insufficient SI in array");
Daniel Willmann17ddd852018-07-05 17:33:20 +02002033 mtc.stop;
Harald Welte48494ca2018-02-25 16:59:50 +01002034 }
2035 for (var integer i:= 0; i < m; i := i + 1) {
2036 var integer fn_mod51 := arr[i].frame_number mod 51;
2037 if (not bcch_ext and fn_mod51 == 2 or
2038 bcch_ext and fn_mod51 == 6) {
2039 if (arr[i].si.header.message_type == key) {
2040 count := count + 1;
2041 }
2042 }
2043 }
2044 if (count >= n) {
2045 return true;
2046 } else {
2047 return false;
2048 }
2049}
2050
2051/* ensure a given TC slot of the SI vector contains given SI type at least N out of M times at TC */
2052function f_ensure_si_vec_contains_n_of_m(SystemInformationVectorPerTc arr, integer tc, RrMessageType key, boolean ext_bcch := false, integer n, integer m) {
2053 if (not f_si_vecslot_contains_n_of_m(arr[tc], key, ext_bcch, n, m)) {
2054 setverdict(fail, "Not ", n, "/", m, " of ", key, " in TC=", tc, "!");
Daniel Willmann17ddd852018-07-05 17:33:20 +02002055 mtc.stop;
Harald Welte48494ca2018-02-25 16:59:50 +01002056 }
2057}
2058
2059/* determine if a given SI vector contains given SI type at least once */
2060function f_si_vecslot_contains_only(SystemInformationVector arr, RrMessageType key, boolean bcch_ext := false) return boolean {
2061 for (var integer i:= 0; i< sizeof(arr); i := i + 1) {
2062 var integer fn_mod51 := arr[i].frame_number mod 51;
2063 if (not bcch_ext and fn_mod51 == 2 or
2064 bcch_ext and fn_mod51 == 6) {
2065 if (arr[i].si.header.message_type != key) {
2066 return false;
2067 }
2068 }
2069 }
2070 return true;
2071}
2072
2073/* ensure a given TC slot of the SI vector contains only given SI type */
2074function f_ensure_si_vec_contains_only(SystemInformationVectorPerTc arr, integer tc, RrMessageType key, boolean ext_bcch := false) {
2075 if (not f_si_vecslot_contains_only(arr[tc], key, ext_bcch)) {
2076 setverdict(fail, "Not all ", key, " in TC=", tc, "!");
Daniel Willmann17ddd852018-07-05 17:33:20 +02002077 mtc.stop;
Harald Welte48494ca2018-02-25 16:59:50 +01002078 }
2079}
2080
2081/* SI configuration of cell, against which we validate actual SI messages */
2082type set SystemInformationConfig {
2083 boolean bcch_extended,
2084 boolean si1_present,
2085 boolean si2bis_present,
2086 boolean si2ter_present,
2087 boolean si2quater_present,
2088 boolean si7_present,
2089 boolean si8_present,
2090 boolean si9_present,
2091 boolean si13_present,
2092 boolean si13alt_present,
2093 boolean si15_present,
2094 boolean si16_present,
2095 boolean si17_present,
2096 boolean si2n_present,
2097 boolean si21_present,
2098 boolean si22_present
2099}
2100
2101/* validate the SI scheduling according to TS 45.002 version 14.1.0 Release 14, Section 6.3.1.3 */
2102function f_validate_si_scheduling(SystemInformationConfig cfg, SystemInformationVectorPerTc si_per_tc) {
2103 var integer i;
2104 for (i := 0; i < sizeof(si_per_tc); i := i + 1) {
2105 if (sizeof(si_per_tc[i]) == 0) {
Harald Welte544565a2018-03-02 10:34:08 +01002106 setverdict(fail, "No SI messages for TC=", i);
Daniel Willmann17ddd852018-07-05 17:33:20 +02002107 mtc.stop;
Harald Welte48494ca2018-02-25 16:59:50 +01002108 }
2109 }
2110 if (cfg.si1_present) {
2111 /* ii) System Information Type 1 needs to be sent if frequency hopping is in use or
2112 * when the NCH is present in a cell. If the MS finds another message on BCCH Norm
2113 * when TC = 0, it can assume that System Information Type 1 is not in use. */
2114 f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_1);
2115 /* make sure *ALL* contain SI1 */
2116 f_ensure_si_vec_contains_only(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_1);
2117 }
2118 f_ensure_si_vec_contains(si_per_tc, 1, SYSTEM_INFORMATION_TYPE_2);
2119 /* iii) A SI 2 message will be sent at least every time TC = 1 */
2120 f_ensure_si_vec_contains(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_3);
2121 f_ensure_si_vec_contains(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_3);
2122 f_ensure_si_vec_contains(si_per_tc, 3, SYSTEM_INFORMATION_TYPE_4);
2123 f_ensure_si_vec_contains(si_per_tc, 7, SYSTEM_INFORMATION_TYPE_4);
2124
2125 /* iii) System information type 2 bis or 2 ter messages are sent if needed, as determined by the
2126 * system operator. If only one of them is needed, it is sent when TC = 5. If both are
2127 * needed, 2bis is sent when TC = 5 and 2ter is sent at least once within any of 4
2128 * consecutive occurrences of TC = 4. */
2129 if (cfg.si2bis_present and not cfg.si2ter_present) {
2130 f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2bis);
2131 } else if (cfg.si2ter_present and not cfg.si2bis_present) {
2132 f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2ter);
2133 } else if (cfg.si2ter_present and cfg.si2bis_present) {
2134 f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2bis);
2135 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2ter, false, 1, 4);
2136 }
2137
2138 if (cfg.si7_present or cfg.si8_present) {
2139 /* vi) Use of System Information type 7 and 8 is not always necessary. It is necessary
2140 * if System Information type 4 does not contain all information needed for cell
2141 * selection and reselection. */
2142 if (not cfg.bcch_extended) {
2143 testcase.stop("Error: SI7/SI8 require BCCH Extd.");
2144 }
2145 if (cfg.si7_present) {
2146 f_ensure_si_vec_contains(si_per_tc, 7, SYSTEM_INFORMATION_TYPE_7, true);
2147 }
2148 if (cfg.si8_present) {
2149 f_ensure_si_vec_contains(si_per_tc, 3, SYSTEM_INFORMATION_TYPE_8, true);
2150 }
2151 }
2152
2153 if (cfg.si2quater_present) {
2154 /* iii) System information type 2 quater is sent if needed, as determined by the system
2155 * operator. If sent on BCCH Norm, it shall be sent when TC = 5 if neither of 2bis
2156 * and 2ter are used, otherwise it shall be sent at least once within any of 4
2157 * consecutive occurrences of TC = 4. If sent on BCCH Ext, it is sent at least once
2158 * within any of 4 consecutive occurrences of TC = 5. */
2159 if (not (cfg.bcch_extended)) {
2160 if (not (cfg.si2bis_present or cfg.si2ter_present)) {
2161 f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2quater);
2162 } else {
2163 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2quater, false, 1, 4);
2164 }
2165 } else {
2166 f_ensure_si_vec_contains_n_of_m(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2quater, true, 1, 4);
2167 }
2168 }
2169 if (cfg.si9_present) {
2170 /* vi) System Information type 9 is sent in those blocks with TC = 4 which are specified
2171 * in system information type 3 as defined in 3GPP TS 44.018. */
2172 f_ensure_si_vec_contains(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_9); // FIXME SI3
2173 }
2174 if (cfg.si13_present) {
2175 /* vii) System Information type 13 is only related to the GPRS service. System Information
2176 * Type 13 need only be sent if GPRS support is indicated in one or more of System
2177 * Information Type 3 or 4 or 7 or 8 messages. These messages also indicate if the
2178 * message is sent on the BCCH Norm or if the message is transmitted on the BCCH Ext.
2179 * In the case that the message is sent on the BCCH Norm, it is sent at least once
2180 * within any of 4 consecutive occurrences of TC=4. */
2181 if (not cfg.bcch_extended) {
2182 log("not-bccch-extended");
2183 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_13, false, 1, 4);
2184 } else {
2185 log("bccch-extended");
2186 f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_13, true);
2187 }
2188 if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_13alt)) {
2189 setverdict(fail, "Cannot have SI13alt and SI13");
Daniel Willmann17ddd852018-07-05 17:33:20 +02002190 mtc.stop;
Harald Welte48494ca2018-02-25 16:59:50 +01002191 }
2192 }
2193 if (cfg.si16_present or cfg.si17_present) {
2194 /* viii) System Information type 16 and 17 are only related to the SoLSA service. They
2195 * should not be sent in a cell where network sharing is used (see rule xv). */
2196 if (cfg.si22_present) {
2197 testcase.stop("Error: Cannot have SI16/SI17 and SI22!");
2198 }
2199 if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_22)) {
2200 setverdict(fail, "Cannot have SI16/SI17 and SI22!");
Daniel Willmann17ddd852018-07-05 17:33:20 +02002201 mtc.stop;
Harald Welte48494ca2018-02-25 16:59:50 +01002202 }
2203 if (not cfg.bcch_extended) {
2204 testcase.stop("Error: SI16/SI17 requires BCCH Extd!");
2205 }
2206 if (cfg.si16_present) {
2207 f_ensure_si_vec_contains(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_16, true);
2208 }
2209 if (cfg.si17_present) {
2210 f_ensure_si_vec_contains(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_17, true);
2211 }
2212 }
2213
2214 /* ix) System Information type 18 and 20 are sent in order to transmit non-GSM
2215 * broadcast information. The frequency with which they are sent is determined by the
2216 * system operator. System Information type 9 identifies the scheduling of System
2217 * Information type 18 and 20 messages. */
2218
2219 /* x) System Information Type 19 is sent if COMPACT neighbours exist. If System
2220 * Information Type 19 is present, then its scheduling shall be indicated in System
2221 * Information Type 9. */
2222
2223 if (cfg.si15_present) {
2224 /* xi) System Information Type 15 is broadcast if dynamic ARFCN mapping is used in the
2225 * PLMN. If sent on BCCH Norm, it is sent at least once within any of 4 consecutive
2226 * occurrences of TC = 4. If sent on BCCH Ext, it is sent at least once within any of
2227 * 4 consecutive occurrences of TC = 1. */
2228 if (not cfg.bcch_extended) {
2229 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_15, false, 1, 4);
2230 } else {
2231 f_ensure_si_vec_contains_n_of_m(si_per_tc, 1, SYSTEM_INFORMATION_TYPE_15, true, 1, 4);
2232 }
2233 }
2234 if (cfg.si13alt_present) {
2235 /* xii) System Information type 13 alt is only related to the GERAN Iu mode. System
2236 * Information Type 13 alt need only be sent if GERAN Iu mode support is indicated in
2237 * one or more of System Information Type 3 or 4 or 7 or 8 messages and SI 13 is not
2238 * broadcast. These messages also indicate if the message is sent on the BCCH Norm or
2239 * if the message is transmitted on the BCCH Ext. In the case that the message is sent
2240 * on the BCCH Norm, it is sent at least once within any of 4 consecutive occurrences
2241 * of TC = 4. */
2242 if (cfg.si13_present) {
2243 testcase.stop("Error: Cannot have SI13alt and SI13");
2244 }
2245 if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_13)) {
2246 setverdict(fail, "Cannot have SI13alt and SI13");
Daniel Willmann17ddd852018-07-05 17:33:20 +02002247 mtc.stop;
Harald Welte48494ca2018-02-25 16:59:50 +01002248 }
2249 if (not cfg.bcch_extended) {
2250 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_13alt, false, 1, 4);
2251 } else {
2252 f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_13alt, true);
2253 }
2254 }
2255 if (cfg.si2n_present) {
2256 /* xiii) System Information Type 2n is optionally sent on BCCH Norm or BCCH Ext if needed,
2257 * as determined by the system operator. In the case that the message is sent on the
2258 * BCCH Norm, it is sent at least once within any of 4 consecutive occurrences of TC =
2259 * 4. If the message is sent on BCCH Ext, it is sent at least once within any of 2
2260 * consecutive occurrences of TC = 4. */
2261 if (not cfg.bcch_extended) {
2262 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2n, false, 1, 4);
2263 } else {
2264 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2n, true, 2, 4);
2265 }
2266 }
2267 if (cfg.si21_present) {
2268 /* xiv) System Information Type 21 is optionally sent on BCCH Norm or BCCH Ext, as
2269 * determined by the system operator. If Extended Access Barring is in use in the cell
2270 * then this message is sent at least once within any of 4 consecutive occurrences of
2271 * TC = 4 regardless if it is sent on BCCH Norm or BCCH Ext. If BCCH Ext is used in a
2272 * cell then this message shall only be sent on BCCH Ext. */
2273 if (not cfg.bcch_extended) {
2274 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_21, false, 1, 4);
2275 } else {
2276 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_21, true, 1, 4);
2277 if (f_si_vecslot_contains(si_per_tc[4], SYSTEM_INFORMATION_TYPE_21)) {
2278 setverdict(fail, "Cannot have SI21 on BCCH Norm if BCCH Extd enabled!");
Daniel Willmann17ddd852018-07-05 17:33:20 +02002279 mtc.stop;
Harald Welte48494ca2018-02-25 16:59:50 +01002280 }
2281 }
2282 }
2283 if (cfg.si22_present) {
2284 /* xv) System Information Type 22 is sent if network sharing is in use in the cell. It
2285 * should not be sent in a cell where SoLSA is used (see rule viii). System
2286 * Information Type 22 instances shall be sent on BCCH Ext within any occurrence of TC
2287 * =2 and TC=6. */
2288 if (cfg.si16_present or cfg.si17_present) {
2289 testcase.stop("Error: Cannot have SI16/SI17 and SI22!");
2290 }
2291 if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_16) or
2292 f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_17)) {
2293 setverdict(fail, "Cannot have SI16/SI17 and SI22!");
Daniel Willmann17ddd852018-07-05 17:33:20 +02002294 mtc.stop;
Harald Welte48494ca2018-02-25 16:59:50 +01002295 }
2296 if (not cfg.bcch_extended) {
2297 testcase.stop("Error: SI22 requires BCCH Extd!");
2298 } else {
2299 f_ensure_si_vec_contains_only(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_22, true);
2300 f_ensure_si_vec_contains_only(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_22, true);
2301 }
2302 }
2303}
2304
2305/* sample Systme Information for specified duration via L1CTL */
2306function f_l1_sample_si(L1CTL_PT pt, float duration := 8.0) return SystemInformationVectorPerTc {
2307 timer T := duration;
2308 var SystemInformationVectorPerTc si_per_tc;
2309 var L1ctlDlMessage l1_dl;
2310
2311 /* initialize all per-TC vectors empty */
2312 for (var integer i:= 0; i < sizeof(si_per_tc); i := i+1) {
2313 si_per_tc[i] := {};
2314 }
2315
2316 /* flush all previous L1 queued msgs */
2317 pt.clear;
2318
2319 T.start;
2320 alt {
Harald Weltef8df4cb2018-03-10 15:15:08 +01002321 [] pt.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl {
Harald Welte48494ca2018-02-25 16:59:50 +01002322 /* somehow dec_SystemInformation will try to decode even non-RR as SI */
2323 if (not (l1_dl.payload.data_ind.payload[1] == '06'O)) {
2324 log("Ignoring non-RR SI ", l1_dl);
2325 repeat;
2326 }
2327 var SystemInformationFn sig := {
2328 frame_number := l1_dl.dl_info.frame_nr,
2329 si := dec_SystemInformation(l1_dl.payload.data_ind.payload)
2330 }
2331 var integer tc := f_gsm_compute_tc(sig.frame_number);
2332 log("SI received at TC=", tc, ": ", sig.si);
2333 /* append to the per-TC bucket */
2334 si_per_tc[tc] := si_per_tc[tc] & { sig };
2335 repeat;
2336 }
2337 [] pt.receive { repeat; }
2338 [] T.timeout { }
2339 }
2340
2341 for (var integer i:= 0; i < sizeof(si_per_tc); i := i+1) {
2342 log(testcasename(), ": TC=", i, " has #of SI=", sizeof(si_per_tc[i]));
2343 }
2344 log("si_per_tc=", si_per_tc);
2345 return si_per_tc;
2346}
2347
2348/* helper function: Set given SI via RSL + validate scheduling.
2349 * CALLER MUST MAKE SURE TO CHANGE GLOBAL si_cfg! */
2350function f_TC_si_sched() runs on test_CT {
2351 var SystemInformationVectorPerTc si_per_tc;
2352 f_init_l1ctl();
2353 f_l1_tune(L1CTL);
2354
2355 /* Sample + Validate Scheduling */
2356 si_per_tc := f_l1_sample_si(L1CTL);
2357 f_validate_si_scheduling(si_cfg, si_per_tc);
2358
2359 setverdict(pass);
2360}
2361
2362testcase TC_si_sched_default() runs on test_CT {
2363 f_init();
Harald Welte0cae4552018-03-09 22:20:26 +01002364 /* 2+3+4 are mandatory and set in f_init() */
2365 f_TC_si_sched();
Harald Welte294b0a22018-03-10 23:26:48 +01002366 f_shutdown();
Harald Welte0cae4552018-03-09 22:20:26 +01002367}
2368
2369testcase TC_si_sched_1() runs on test_CT {
2370 f_init();
2371 si_cfg.si1_present := true;
2372 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_1, '5506198fb38000000000000000000000000000e504002b'O);
Harald Welte48494ca2018-02-25 16:59:50 +01002373 f_TC_si_sched();
Harald Welte294b0a22018-03-10 23:26:48 +01002374 f_shutdown();
Harald Welte48494ca2018-02-25 16:59:50 +01002375}
2376
2377testcase TC_si_sched_2bis() runs on test_CT {
2378 f_init();
2379 si_cfg.si2bis_present := true;
2380 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O);
2381 f_TC_si_sched();
Harald Welte294b0a22018-03-10 23:26:48 +01002382 f_shutdown();
Harald Welte48494ca2018-02-25 16:59:50 +01002383}
2384
2385testcase TC_si_sched_2ter() runs on test_CT {
2386 f_init();
2387 si_cfg.si2ter_present := true;
2388 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O);
2389 f_TC_si_sched();
Harald Welte294b0a22018-03-10 23:26:48 +01002390 f_shutdown();
Harald Welte48494ca2018-02-25 16:59:50 +01002391}
2392
2393testcase TC_si_sched_2ter_2bis() runs on test_CT {
2394 f_init();
2395 si_cfg.si2bis_present := true;
2396 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O);
2397 si_cfg.si2ter_present := true;
2398 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O);
2399 f_TC_si_sched();
Harald Welte294b0a22018-03-10 23:26:48 +01002400 f_shutdown();
Harald Welte48494ca2018-02-25 16:59:50 +01002401}
2402
2403testcase TC_si_sched_2quater() runs on test_CT {
2404 f_init();
2405 si_cfg.si2quater_present := true;
2406 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2quater, '050607a8a0364aa698d72ff424feee0506d5e7fff02043'O);
2407 f_TC_si_sched();
Harald Welte294b0a22018-03-10 23:26:48 +01002408 f_shutdown();
Harald Welte48494ca2018-02-25 16:59:50 +01002409}
2410
2411testcase TC_si_sched_13() runs on test_CT {
2412 f_init();
2413 si_cfg.si13_present := true;
Harald Welte5618c2a2018-04-15 16:24:46 +02002414 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_13, '0106009000185a6fc9e08410ab2b2b2b2b2b2b2b2b2b2b'O);
Harald Welte48494ca2018-02-25 16:59:50 +01002415 f_TC_si_sched();
Harald Welte294b0a22018-03-10 23:26:48 +01002416 f_shutdown();
Harald Welte48494ca2018-02-25 16:59:50 +01002417}
2418
2419testcase TC_si_sched_13_2bis_2ter_2quater() runs on test_CT {
2420 f_init();
2421 si_cfg.si2bis_present := true;
2422 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O);
2423 si_cfg.si2ter_present := true;
2424 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O);
2425 si_cfg.si2quater_present := true;
2426 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2quater, '050607a8a0364aa698d72ff424feee0506d5e7fff02043'O);
2427 si_cfg.si13_present := true;
Harald Welte5618c2a2018-04-15 16:24:46 +02002428 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_13, '0106009000185a6fc9e08410ab2b2b2b2b2b2b2b2b2b2b'O);
Harald Welte48494ca2018-02-25 16:59:50 +01002429 f_TC_si_sched();
Harald Welte294b0a22018-03-10 23:26:48 +01002430 f_shutdown();
Harald Welte48494ca2018-02-25 16:59:50 +01002431}
2432
2433
Harald Welte68e495b2018-02-25 00:05:57 +01002434testcase TC_bcch_info() runs on test_CT {
2435 f_init(testcasename());
2436 /* FIXME: enable / disable individual BCCH info */
2437 //ts_RSL_BCCH_INFO(si_type, info);
2438 /* expect no ERROR REPORT after either of them *
2439 /* negative test: ensure ERROR REPORT on unsupported types */
Harald Welte294b0a22018-03-10 23:26:48 +01002440 f_shutdown();
Harald Welte68e495b2018-02-25 00:05:57 +01002441}
2442
Harald Welte93640c62018-02-25 16:59:33 +01002443/***********************************************************************
2444 * Low-Level Protocol Errors / ERROR REPORT
2445 ***********************************************************************/
2446
Harald Welte01d982c2018-02-25 01:31:40 +01002447private function f_exp_err_rep(template RSL_Cause cause) runs on test_CT {
2448 timer T := 5.0;
2449 T.start;
2450 alt {
2451 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_ERROR_REPORT(cause))) {
2452 setverdict(pass);
2453 }
2454 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_ERROR_REPORT(?))) {
2455 setverdict(fail, "Wrong cause in RSL ERR REP");
Daniel Willmann17ddd852018-07-05 17:33:20 +02002456 mtc.stop;
Harald Welte01d982c2018-02-25 01:31:40 +01002457 }
2458 [] RSL_CCHAN.receive {
2459 repeat;
2460 }
2461 [] T.timeout {
2462 setverdict(fail, "Timeout waiting for RSL ERR REP");
Daniel Willmann17ddd852018-07-05 17:33:20 +02002463 mtc.stop;
Harald Welte01d982c2018-02-25 01:31:40 +01002464 }
2465 }
2466}
2467
2468/* Provoke a protocol error (message too short) and match on ERROR REPORT */
2469testcase TC_rsl_protocol_error() runs on test_CT {
2470 f_init(testcasename());
2471 var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O));
2472 rsl.ies := omit;
2473 RSL_CCHAN.send(ts_RSL_UD(rsl));
2474
2475 f_exp_err_rep(RSL_ERR_PROTO);
2476}
2477
2478/* Provoke a mandatory IE error and match on ERROR REPORT */
2479testcase TC_rsl_mand_ie_error() runs on test_CT {
2480 f_init(testcasename());
2481
2482 var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O));
2483 rsl.ies := { rsl.ies[0] };
2484 RSL_CCHAN.send(ts_RSL_UD(rsl));
2485
2486 f_exp_err_rep(RSL_ERR_MAND_IE_ERROR);
2487}
2488
2489/* Provoke an IE content error and match on ERROR REPORT */
2490testcase TC_rsl_ie_content_error() runs on test_CT {
2491 f_init(testcasename());
2492 var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O));
2493 rsl.ies[1].body.sysinfo_type := RSL_SYSTEM_INFO_5;
2494 RSL_CCHAN.send(ts_RSL_UD(rsl));
2495
2496 f_exp_err_rep(RSL_ERR_IE_CONTENT);
2497}
2498
Harald Welte93640c62018-02-25 16:59:33 +01002499/***********************************************************************
2500 * IPA CRCX/MDCX/DLCS media stream handling
2501 ***********************************************************************/
2502
Harald Weltea871a382018-02-25 02:03:14 +01002503/* Send IPA DLCX to inactive lchan */
2504function f_TC_ipa_dlcx_not_active(charstring id) runs on ConnHdlr {
Harald Welte1eba3742018-02-25 12:48:14 +01002505 f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, 0), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?),
2506 "IPA DLCX ACK");
Harald Weltea871a382018-02-25 02:03:14 +01002507}
2508testcase TC_ipa_dlcx_not_active() runs on test_CT {
2509 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
2510 f_init(testcasename());
2511 var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_dlcx_not_active), pars);
2512 vc_conn.done;
2513}
Harald Welte68e495b2018-02-25 00:05:57 +01002514
Harald Weltea3f1df92018-02-25 12:49:55 +01002515/* Send IPA CRCX twice to inactive lchan */
2516function f_TC_ipa_crcx_twice_not_active(charstring id) runs on ConnHdlr {
2517 f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?),
2518 "IPA CRCX ACK");
2519 f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_NACK(g_chan_nr, RSL_ERR_RES_UNAVAIL),
2520 "IPA CRCX NACK");
2521}
2522testcase TC_ipa_crcx_twice_not_active() runs on test_CT {
2523 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
2524 f_init(testcasename());
2525 var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_twice_not_active), pars);
2526 vc_conn.done;
2527}
2528
2529/* Regular sequence of CRCX/MDCX/DLCX */
2530function f_TC_ipa_crcx_mdcx_dlcx_not_active(charstring id) runs on ConnHdlr {
2531 f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?),
2532 "IPA CRCX ACK");
2533 var uint32_t remote_ip := f_rnd_int(c_UINT32_MAX);
2534 var uint16_t remote_port := f_rnd_int(c_UINT16_MAX);
2535 var uint7_t rtp_pt2 := f_rnd_int(127);
2536 var uint16_t fake_conn_id := 23; /* we're too lazy to read it out from the CRCX ACK above */
2537 f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2),
2538 tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2),
2539 "IPA MDCX ACK");
2540 f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, fake_conn_id), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?),
2541 "IPA DLCX ACK");
2542}
2543testcase TC_ipa_crcx_mdcx_dlcx_not_active() runs on test_CT {
2544 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
2545 f_init(testcasename());
2546 var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_mdcx_dlcx_not_active), pars);
2547 vc_conn.done;
2548}
2549
Harald Welte3ae11da2018-02-25 13:36:06 +01002550/* Sequence of CRCX, 2x MDCX, DLCX */
2551function f_TC_ipa_crcx_mdcx_mdcx_dlcx_not_active(charstring id) runs on ConnHdlr {
2552 f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?),
2553 "IPA CRCX ACK");
2554 var uint32_t remote_ip := f_rnd_int(c_UINT32_MAX);
2555 var uint16_t remote_port := f_rnd_int(c_UINT16_MAX);
2556 var uint7_t rtp_pt2 := f_rnd_int(127);
2557 var uint16_t fake_conn_id := 23; /* we're too lazy to read it out from the CRCX ACK above */
2558 f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2),
2559 tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2),
2560 "IPA MDCX ACK");
2561 /* Second MDCX */
2562 remote_ip := f_rnd_int(c_UINT32_MAX);
2563 remote_port := f_rnd_int(c_UINT16_MAX);
2564 f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2),
2565 tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2),
2566 "IPA MDCX ACK");
2567 f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, fake_conn_id), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?),
2568 "IPA DLCX ACK");
2569}
2570testcase TC_ipa_crcx_mdcx_mdcx_dlcx_not_active() runs on test_CT {
2571 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
2572 f_init(testcasename());
2573 var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_mdcx_mdcx_dlcx_not_active), pars);
2574 vc_conn.done;
2575}
2576
Harald Welte9912eb52018-02-25 13:30:15 +01002577/* IPA CRCX on SDCCH/4 and SDCCH/8 (doesn't make sense) */
2578function f_TC_ipa_crcx_sdcch_not_active(charstring id) runs on ConnHdlr {
2579 f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_NACK(g_chan_nr, ?),
2580 "IPA CRCX NACK");
2581}
2582testcase TC_ipa_crcx_sdcch_not_active() runs on test_CT {
2583 var ConnHdlrPars pars;
2584 var ConnHdlr vc_conn;
2585 f_init(testcasename());
2586
2587 pars := valueof(t_Pars(t_RslChanNr_SDCCH4(0,1), ts_RSL_ChanMode_SIGN));
2588 vc_conn := f_start_handler(refers(f_TC_ipa_crcx_sdcch_not_active), pars);
2589 vc_conn.done;
2590
2591 pars := valueof(t_Pars(t_RslChanNr_SDCCH8(6,5), ts_RSL_ChanMode_SIGN));
2592 vc_conn := f_start_handler(refers(f_TC_ipa_crcx_sdcch_not_active), pars);
2593 vc_conn.done;
2594}
2595
Harald Weltea3f1df92018-02-25 12:49:55 +01002596
Harald Welte883340c2018-02-28 18:59:29 +01002597/***********************************************************************
2598 * PCU Socket related tests
2599 ***********************************************************************/
2600
2601private function f_TC_pcu_act_req(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr, boolean exp_success)
2602runs on test_CT {
2603 timer T := 3.0;
2604
2605 /* we don't expect any RTS.req before PDCH are active */
2606 T.start;
2607 alt {
2608 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(bts_nr))) {
2609 setverdict(fail, "PCU RTS.req before PDCH active?");
Daniel Willmann17ddd852018-07-05 17:33:20 +02002610 mtc.stop;
Harald Welte883340c2018-02-28 18:59:29 +01002611 }
2612 [] PCU.receive { repeat; }
2613 [] T.timeout { }
2614 }
2615
2616 /* Send PDCH activate request for known PDCH timeslot */
2617 PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, ts_nr)));
2618
2619 /* we now expect RTS.req for this timeslot (only) */
2620 T.start;
2621 alt {
2622 [exp_success] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr))) {
2623 setverdict(pass);
2624 }
2625 [not exp_success] PCU.receive(t_SD_PCUIF(g_pcu_conn_id,
2626 tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr))) {
2627 setverdict(fail, "Unexpected RTS.req for supposedly failing activation");
Daniel Willmann17ddd852018-07-05 17:33:20 +02002628 mtc.stop;
Harald Welte883340c2018-02-28 18:59:29 +01002629 }
2630 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ)) {
2631 setverdict(fail, "RTS.req for wrong TRX/TS");
Daniel Willmann17ddd852018-07-05 17:33:20 +02002632 mtc.stop;
Harald Welte883340c2018-02-28 18:59:29 +01002633 }
2634 [] PCU.receive { repeat; }
2635 [exp_success] T.timeout {
2636 setverdict(fail, "Timeout waiting for PCU RTS.req");
Daniel Willmann17ddd852018-07-05 17:33:20 +02002637 mtc.stop;
Harald Welte883340c2018-02-28 18:59:29 +01002638 }
2639 [not exp_success] T.timeout {
2640 setverdict(pass);
2641 }
2642 }
2643}
2644
2645private function f_TC_pcu_deact_req(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr)
2646runs on test_CT {
2647 timer T := 3.0;
2648
2649 /* Send PDCH activate request for known PDCH timeslot */
2650 PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_DEACT_REQ(bts_nr, trx_nr, ts_nr)));
2651
2652 PCU.clear;
2653 /* we now expect no RTS.req for this timeslot */
2654 T.start;
2655 alt {
2656 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr))) {
2657 setverdict(fail, "Received unexpected PCU RTS.req");
Daniel Willmann17ddd852018-07-05 17:33:20 +02002658 mtc.stop;
Harald Welte883340c2018-02-28 18:59:29 +01002659 }
2660 [] PCU.receive { repeat; }
2661 [] T.timeout {
2662 setverdict(pass);
2663 }
2664 }
2665}
2666
2667/* PDCH activation via PCU socket; check for presence of RTS.req */
2668testcase TC_pcu_act_req() runs on test_CT {
2669 f_init();
2670 f_TC_pcu_act_req(0, 0, 7, true);
2671}
2672
2673/* PDCH activation via PCU socket on non-PDCU timeslot */
2674testcase TC_pcu_act_req_wrong_ts() runs on test_CT {
2675 f_init();
2676 f_TC_pcu_act_req(0, 0, 1, false);
2677}
2678
2679/* PDCH activation via PCU socket on wrong BTS */
2680testcase TC_pcu_act_req_wrong_bts() runs on test_CT {
2681 f_init();
2682 f_TC_pcu_act_req(23, 0, 7, false);
2683}
2684
2685/* PDCH activation via PCU socket on wrong TRX */
2686testcase TC_pcu_act_req_wrong_trx() runs on test_CT {
2687 f_init();
2688 f_TC_pcu_act_req(0, 23, 7, false);
2689}
2690
2691/* PDCH deactivation via PCU socket; check for absence of RTS.req */
2692testcase TC_pcu_deact_req() runs on test_CT {
2693 f_init();
2694 /* Activate PDCH */
2695 f_TC_pcu_act_req(0, 0, 7, true);
2696 f_sleep(1.0);
2697 /* and De-Activate again */
2698 f_TC_pcu_deact_req(0, 0, 7);
2699}
2700
2701/* Attempt to deactivate a PDCH on a non-PDCH timeslot */
2702testcase TC_pcu_deact_req_wrong_ts() runs on test_CT {
2703 f_init();
2704 f_TC_pcu_deact_req(0, 0, 1);
2705}
2706
2707/* Test the PCU->BTS Version and BTS->PCU SI13 handshake */
2708testcase TC_pcu_ver_si13() runs on test_CT {
2709 const octetstring si13 := '00010203040506070909'O;
2710 var PCUIF_send_data sd;
2711 timer T:= 3.0;
2712 f_init();
2713
2714 /* Set SI13 via RSL */
2715 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_13, si13);
2716 PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_TXT_IND(0, PCU_VERSION, "BTS_Test v23")));
2717 T.start;
2718 alt {
2719 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_DATA_IND(0, 0, 0, ?, PCU_IF_SAPI_BCCH))) -> value sd {
2720 if (substr(sd.data.u.data_ind.data, 0, lengthof(si13)) == si13) {
2721 setverdict(pass);
2722 } else {
2723 repeat;
2724 }
2725 }
2726 [] PCU.receive { repeat; }
2727 [] T.timeout {
2728 setverdict(fail, "Timeout waiting for SI13");
Daniel Willmann17ddd852018-07-05 17:33:20 +02002729 mtc.stop;
Harald Welte883340c2018-02-28 18:59:29 +01002730 }
2731 }
2732}
2733
2734private const octetstring c_PCU_DATA := '000102030405060708090a0b0c0d0e0f10111213141516'O;
2735
2736/* helper function to send a PCU DATA.req */
2737private function f_pcu_data_req(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr,
2738 uint8_t block_nr, uint32_t fn, PCUIF_Sapi sapi, octetstring data)
2739runs on test_CT
2740{
2741 PCU.send(t_SD_PCUIF(g_pcu_conn_id,
2742 ts_PCUIF_DATA_REQ(bts_nr, trx_nr, ts_nr, block_nr, fn, sapi, data)));
2743}
2744
2745/* helper function to wait for RTS.ind for given SAPI on given BTS/TRX/TS and then send */
2746private function f_pcu_wait_rts_and_data_req(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr,
2747 PCUIF_Sapi sapi, octetstring data)
2748runs on test_CT
2749{
2750 var PCUIF_send_data sd;
2751
2752 timer T := 3.0;
2753 T.start;
2754 alt {
2755 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id,
2756 tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr, sapi))) -> value sd {
2757 f_pcu_data_req(bts_nr, trx_nr, ts_nr, sd.data.u.rts_req.block_nr,
2758 sd.data.u.rts_req.fn, sapi, data);
2759 }
2760 [] PCU.receive { repeat; }
2761 [] T.timeout {
2762 setverdict(fail, "Timeout waiting for RTS.ind");
Daniel Willmann17ddd852018-07-05 17:33:20 +02002763 mtc.stop;
Harald Welte883340c2018-02-28 18:59:29 +01002764 }
2765 }
2766}
2767
2768/* Send DATA.req on invalid BTS */
2769testcase TC_pcu_data_req_wrong_bts() runs on test_CT {
2770 f_init();
2771 f_TC_pcu_act_req(0, 0, 7, true);
2772 f_pcu_data_req(23, 0, 7, 0, 0, PCU_IF_SAPI_PDTCH, c_PCU_DATA);
2773 /* FIXME: how to check this wasn't actually sent and didn't crash BTS? */
2774 f_sleep(10.0);
2775}
2776
2777/* Send DATA.req on invalid TRX */
2778testcase TC_pcu_data_req_wrong_trx() runs on test_CT {
2779 f_init();
2780 f_TC_pcu_act_req(0, 0, 7, true);
2781 f_pcu_data_req(0, 100, 7, 0, 0, PCU_IF_SAPI_PDTCH, c_PCU_DATA);
2782 /* FIXME: how to check this wasn't actually sent and didn't crash BTS? */
2783 f_sleep(10.0);
2784}
2785
2786/* Send DATA.req on invalid timeslot */
2787testcase TC_pcu_data_req_wrong_ts() runs on test_CT {
2788 f_init();
2789 f_TC_pcu_act_req(0, 0, 7, true);
2790 f_pcu_data_req(0, 0, 70, 0, 0, PCU_IF_SAPI_PDTCH, c_PCU_DATA);
2791 /* FIXME: how to check this wasn't actually sent and didn't crash BTS? */
2792 f_sleep(10.0);
2793}
2794
2795/* Send DATA.req on timeslot that hasn't been activated */
2796testcase TC_pcu_data_req_ts_inactive() runs on test_CT {
2797 f_init();
2798 f_pcu_data_req(0, 0, 7, 0, 0, PCU_IF_SAPI_PDTCH, c_PCU_DATA);
2799 /* FIXME: how to check this wasn't actually sent and didn't crash BTS? */
2800 f_sleep(2.0);
2801}
2802
2803testcase TC_pcu_data_req_pdtch() runs on test_CT {
2804 f_init();
2805 f_TC_pcu_act_req(0, 0, 7, true);
2806 f_pcu_wait_rts_and_data_req(0, 0, 7, PCU_IF_SAPI_PDTCH, c_PCU_DATA);
2807 /* FIXME: how to check this was actually sent */
2808 f_sleep(2.0);
2809}
2810
2811testcase TC_pcu_data_req_ptcch() runs on test_CT {
2812 f_init();
2813 f_TC_pcu_act_req(0, 0, 7, true);
2814 f_pcu_wait_rts_and_data_req(0, 0, 7, PCU_IF_SAPI_PTCCH, c_PCU_DATA);
2815 /* FIXME: how to check this was actually sent */
2816 f_sleep(2.0);
2817}
2818
2819/* Send AGCH from PCU; check it appears on Um side */
2820testcase TC_pcu_data_req_agch() runs on test_CT {
2821 timer T := 3.0;
2822 f_init();
2823 f_init_l1ctl();
2824 f_l1_tune(L1CTL);
2825
2826 f_TC_pcu_act_req(0, 0, 7, true);
2827 f_pcu_data_req(0, 0, 7, 0, 0, PCU_IF_SAPI_AGCH, c_PCU_DATA);
2828
2829 T.start;
2830 alt {
Harald Weltef8df4cb2018-03-10 15:15:08 +01002831 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?, c_PCU_DATA)) {
Harald Welte883340c2018-02-28 18:59:29 +01002832 setverdict(pass);
2833 }
2834 [] L1CTL.receive { repeat; }
2835 [] T.timeout {
2836 setverdict(fail, "Timeout waiting for PCU-originated AGCH block on Um");
Daniel Willmann17ddd852018-07-05 17:33:20 +02002837 mtc.stop;
Harald Welte883340c2018-02-28 18:59:29 +01002838 }
2839 }
2840}
2841
2842/* Send IMM.ASS from PCU for PCH; check it appears on Um side */
2843testcase TC_pcu_data_req_imm_ass_pch() runs on test_CT {
2844 var octetstring imm_ass := f_rnd_octstring(23);
2845 f_init();
2846 f_init_l1ctl();
2847 f_l1_tune(L1CTL);
2848
2849 /* append 3 last imsi digits so BTS can compute pagng group */
2850 var uint32_t fn := f_PCUIF_tx_imm_ass_pch(PCU, g_pcu_conn_id, imm_ass, '123459987'H);
2851
2852 timer T := 0.5;
2853 T.start;
2854 alt {
Harald Weltef8df4cb2018-03-10 15:15:08 +01002855 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?, imm_ass)) {
Harald Welte883340c2018-02-28 18:59:29 +01002856 /* TODO: verify paging group */
2857 setverdict(pass);
2858 }
2859 [] L1CTL.receive { repeat; }
2860 [] T.timeout {
2861 setverdict(fail, "Timeout waiting for PCU-originated AGCH block on Um");
Daniel Willmann17ddd852018-07-05 17:33:20 +02002862 mtc.stop;
Harald Welte883340c2018-02-28 18:59:29 +01002863 }
2864 }
2865}
2866
2867/* Send RACH from Um side, expect it to show up on PCU socket */
2868testcase TC_pcu_rach_content() runs on test_CT {
2869 f_init();
2870 f_init_l1ctl();
2871 f_l1_tune(L1CTL);
2872
2873 var GsmFrameNumber fn_last := 0;
2874 for (var integer i := 0; i < 1000; i := i+1) {
2875 var OCT1 ra := f_rnd_ra_ps();
2876 var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra));
2877 if (fn == fn_last) {
2878 setverdict(fail, "Two RACH in same FN?!?");
Daniel Willmann17ddd852018-07-05 17:33:20 +02002879 mtc.stop;
Harald Welte883340c2018-02-28 18:59:29 +01002880 }
2881 fn_last := fn;
2882
2883 timer T := 2.0;
2884 T.start;
2885 alt {
2886 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RACH_IND(0, oct2int(ra), 0, ?, fn))) {
2887 T.stop;
2888 }
2889 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RACH_IND)) {
2890 setverdict(fail, "Unexpected RACH IND");
Daniel Willmann17ddd852018-07-05 17:33:20 +02002891 mtc.stop;
Harald Welte883340c2018-02-28 18:59:29 +01002892 }
2893 [] PCU.receive { repeat; }
2894 [] T.timeout {
2895 setverdict(fail, "Timeout waiting for RACH IND");
Daniel Willmann17ddd852018-07-05 17:33:20 +02002896 mtc.stop;
Harald Welte883340c2018-02-28 18:59:29 +01002897 }
2898 }
2899 }
2900 setverdict(pass);
2901}
2902
2903private function f_pad_oct(octetstring str, integer len, OCT1 pad) return octetstring {
2904 var integer strlen := lengthof(str);
2905 for (var integer i := 0; i < len-strlen; i := i+1) {
2906 str := str & pad;
2907 }
2908 return str;
2909}
2910
2911/* Send PAGING via RSL, expect it to shw up on PCU socket */
2912testcase TC_pcu_paging_from_rsl() runs on test_CT {
2913 f_init();
2914
2915 for (var integer i := 0; i < 100; i := i+1) {
2916 var MobileL3_CommonIE_Types.MobileIdentityLV mi;
2917 timer T := 3.0;
2918 if (i < 50) {
2919 mi := valueof(ts_MI_TMSI_LV(f_rnd_octstring(4)));
2920 } else {
2921 mi := valueof(ts_MI_IMSI_LV(f_gen_imsi(i)));
2922 }
2923 var octetstring mi_enc_lv := enc_MobileIdentityLV(mi);
2924 var octetstring mi_enc := substr(mi_enc_lv, 1, lengthof(mi_enc_lv)-1);
2925 var octetstring t_mi_lv := f_pad_oct(mi_enc_lv, 9, '00'O);
2926
2927 /* Send RSL PAGING COMMAND */
2928 RSL_CCHAN.send(ts_RSL_UD(ts_RSL_PAGING_CMD(mi_enc, i mod 4)));
2929 T.start;
2930 alt {
2931 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_PAG_REQ(0, t_mi_lv))) {
2932 }
2933 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_PAG_REQ)) {
2934 setverdict(fail, "Unexpected PAGING REQ");
Daniel Willmann17ddd852018-07-05 17:33:20 +02002935 mtc.stop;
Harald Welte883340c2018-02-28 18:59:29 +01002936 }
2937 [] PCU.receive { repeat; }
2938 [] T.timeout {
2939 setverdict(fail, "Timeout waiting for PAGING REQ");
Daniel Willmann17ddd852018-07-05 17:33:20 +02002940 mtc.stop;
Harald Welte883340c2018-02-28 18:59:29 +01002941 }
2942 }
2943 }
2944 setverdict(pass);
2945}
2946
Harald Welte3d04ae62018-04-04 20:29:05 +02002947/***********************************************************************
Harald Welte9bbbfb52018-04-05 09:33:19 +02002948 * Osmocom Style Dynamic Timeslot Support
Harald Welte3d04ae62018-04-04 20:29:05 +02002949 ***********************************************************************/
2950
2951private function f_dyn_osmo_pdch_act(integer pcu_conn_id, integer bts_nr, integer trx_nr)
2952runs on ConnHdlr {
2953 var PCUIF_send_data sd;
2954 /* Expect BTS to immediately acknowledge activation as PDCH */
2955 PCU.clear;
2956 f_rsl_chan_act(g_pars.chan_mode);
2957 /* expect INFO_IND on PCU interface listing TS as PDCH */
2958 alt {
2959 [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(bts_nr, ?))) -> value sd {
2960 if (substr(sd.data.u.info_ind.trx[trx_nr].pdch_mask, g_chan_nr.tn, 1) != '1'B) {
2961 setverdict(fail, "PCUIF_INFO_IND PDCH_MASK not '1' after PDCH ACT");
Daniel Willmann17ddd852018-07-05 17:33:20 +02002962 mtc.stop;
Harald Welte3d04ae62018-04-04 20:29:05 +02002963 }
2964 }
2965 [] PCU.receive { repeat; }
2966 }
2967 /* try to activate this PDCH from the PCU point of view */
2968 PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, g_chan_nr.tn)));
2969 /* FIXME: is there a response? */
2970}
2971
2972private function f_dyn_osmo_pdch_deact(integer pcu_conn_id, integer bts_nr, integer trx_nr)
2973runs on ConnHdlr {
2974 var PCUIF_send_data sd;
2975 /* Send RSL CHAN REL (deactivate) */
2976 PCU.clear;
2977 RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr));
2978 /* expect BTS to ask PCU to deactivate the channel */
2979 alt {
2980 [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(bts_nr, ?))) -> value sd {
2981 if (substr(sd.data.u.info_ind.trx[trx_nr].pdch_mask, g_chan_nr.tn, 1) != '0'B) {
2982 setverdict(fail, "PCUIF_INFO_IND PDCH_MASK not '0' after PDCH DEACT");
Daniel Willmann17ddd852018-07-05 17:33:20 +02002983 mtc.stop;
Harald Welte3d04ae62018-04-04 20:29:05 +02002984 }
2985 }
2986 [] PCU.receive { repeat; }
2987 }
2988 /* Emulate PCU asking BTS to deactivate PDCH */
2989 PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_DEACT_REQ(bts_nr, trx_nr, g_chan_nr.tn)));
2990 alt {
2991 [] RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr)) {
2992 setverdict(pass);
2993 }
2994 [] RSL.receive { repeat; }
2995 }
2996}
2997
2998/* Activate Osmocom-style dynamic PDCH from BSC side */
2999function f_TC_dyn_osmo_pdch_act_deact(charstring id) runs on ConnHdlr {
3000 var PCUIF_Message first_info;
3001 var integer ts_nr := g_chan_nr.tn;
3002 var integer trx_nr := 0;
3003 var integer bts_nr := 0;
3004 var integer pcu_conn_id := -1;
3005
3006 f_init_pcu(PCU, id, pcu_conn_id, first_info);
3007
3008 f_dyn_osmo_pdch_act(pcu_conn_id, bts_nr, trx_nr);
3009 f_sleep(3.0);
3010 f_dyn_osmo_pdch_deact(pcu_conn_id, bts_nr, trx_nr);
3011 setverdict(pass);
3012}
3013testcase TC_dyn_osmo_pdch_act_deact() runs on test_CT {
3014 var ConnHdlrPars pars;
3015 var ConnHdlr vc_conn;
3016 f_init(testcasename());
3017
3018 pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN));
3019 vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_act_deact), pars, true);
3020 vc_conn.done;
3021}
3022
3023/* send a RF CHAN REL for PDCH on an osmocom dynamci PDCH that's already inactive */
3024function f_TC_dyn_osmo_pdch_unsol_deact(charstring id) runs on ConnHdlr {
3025 var PCUIF_Message first_info;
Harald Welte3d04ae62018-04-04 20:29:05 +02003026 var integer pcu_conn_id := -1;
3027
3028 f_init_pcu(PCU, id, pcu_conn_id, first_info);
3029
Neels Hofmeyr9c50ca52018-05-08 20:37:54 +02003030 RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr));
3031 /* since the lchan is already released, we don't expect any PCU changes, just a rel ack. */
3032 RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr));
Harald Welte3d04ae62018-04-04 20:29:05 +02003033 setverdict(pass);
3034}
3035testcase TC_dyn_osmo_pdch_unsol_deact() runs on test_CT {
3036 var ConnHdlrPars pars;
3037 var ConnHdlr vc_conn;
3038 f_init(testcasename());
3039
3040 pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN));
3041 vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_unsol_deact), pars, true);
3042 vc_conn.done;
3043}
3044
3045/* try to RSL CHAN ACT a PDCH on an osmocom-style PDCH that's already active */
3046function f_TC_dyn_osmo_pdch_double_act(charstring id) runs on ConnHdlr {
3047 var PCUIF_Message first_info;
3048 var integer ts_nr := g_chan_nr.tn;
3049 var integer trx_nr := 0;
3050 var integer bts_nr := 0;
3051 var integer pcu_conn_id := -1;
3052
3053 f_init_pcu(PCU, id, pcu_conn_id, first_info);
3054
3055 f_dyn_osmo_pdch_act(pcu_conn_id, bts_nr, trx_nr);
Neels Hofmeyrdf936a22018-05-08 22:07:57 +02003056 /* Send a second Chan Activ and expect it to be NACKed */
3057 f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_NACK(g_chan_nr),
3058 "RSL CHAN ACT NACK");
Harald Welte3d04ae62018-04-04 20:29:05 +02003059 setverdict(pass);
3060}
3061testcase TC_dyn_osmo_pdch_double_act() runs on test_CT {
3062 var ConnHdlrPars pars;
3063 var ConnHdlr vc_conn;
3064 f_init(testcasename());
3065
3066 pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN));
3067 vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_double_act), pars, true);
3068 vc_conn.done;
3069}
3070
3071/* try to RSL CHAN ACT a TCH/F on an osmocom-style PDCH */
3072function f_TC_dyn_osmo_pdch_tchf_act(charstring id) runs on ConnHdlr {
3073 var PCUIF_Message first_info;
3074 var integer ts_nr := g_chan_nr.tn;
3075 var integer trx_nr := 0;
3076 var integer bts_nr := 0;
3077 var integer pcu_conn_id := -1;
3078 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(g_chan_nr.tn));
3079
3080 /* register for the TCH/F channel number */
3081 f_rslem_register(0, chan_nr);
3082
3083 f_init_pcu(PCU, id, pcu_conn_id, first_info);
3084
3085 f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_ACK(chan_nr),
3086 "RSL CHAN ACT");
3087 setverdict(pass);
3088}
3089testcase TC_dyn_osmo_pdch_tchf_act() runs on test_CT {
3090 var ConnHdlrPars pars;
3091 var ConnHdlr vc_conn;
3092 f_init(testcasename());
3093
3094 pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN));
3095 vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_tchf_act), pars, true);
3096 vc_conn.done;
3097}
3098
3099/* try to RSL CHAN ACT the TCH/H on an osmocom-style PDCH */
3100function f_TC_dyn_osmo_pdch_tchh_act(charstring id) runs on ConnHdlr {
3101 var PCUIF_Message first_info;
3102 var integer ts_nr := g_chan_nr.tn;
3103 var integer trx_nr := 0;
3104 var integer bts_nr := 0;
3105 var integer pcu_conn_id := -1;
3106 var RslChannelNr chan_nr[2] := { valueof(t_RslChanNr_Lm(g_chan_nr.tn, 0)),
3107 valueof(t_RslChanNr_Lm(g_chan_nr.tn, 1)) };
3108
3109 /* register for the TCH/H channel numbers */
3110 f_rslem_register(0, chan_nr[0]);
3111 f_rslem_register(0, chan_nr[1]);
3112
3113 f_init_pcu(PCU, id, pcu_conn_id, first_info);
3114
3115 f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr[1], g_pars.chan_mode),
3116 tr_RSL_CHAN_ACT_ACK(chan_nr[1]), "RSL CHAN ACT [1]");
3117 f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr[0], g_pars.chan_mode),
3118 tr_RSL_CHAN_ACT_ACK(chan_nr[0]), "RSL CHAN ACT [0]");
3119 setverdict(pass);
3120}
3121testcase TC_dyn_osmo_pdch_tchh_act() runs on test_CT {
3122 var ConnHdlrPars pars;
3123 var ConnHdlr vc_conn;
3124 f_init(testcasename());
3125
3126 pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN));
3127 vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_tchh_act), pars, true);
3128 vc_conn.done;
3129}
3130
Harald Welte9bbbfb52018-04-05 09:33:19 +02003131/***********************************************************************
3132 * IPA Style Dynamic Timeslot Support
3133 ***********************************************************************/
3134
3135private function f_dyn_ipa_pdch_act(integer pcu_conn_id, integer bts_nr, integer trx_nr)
3136runs on ConnHdlr {
3137 var PCUIF_send_data sd;
3138 /* Expect BTS to immediately acknowledge activation as PDCH */
3139 PCU.clear;
3140 RSL.send(ts_RSL_IPA_PDCH_ACT(g_chan_nr));
3141 /* expect INFO_IND on PCU interface listing TS as PDCH */
3142 alt {
3143 [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(bts_nr, ?))) -> value sd {
3144 if (substr(sd.data.u.info_ind.trx[trx_nr].pdch_mask, g_chan_nr.tn, 1) != '1'B) {
3145 setverdict(fail, "PCUIF_INFO_IND PDCH_MASK not '1' after PDCH ACT");
Daniel Willmann17ddd852018-07-05 17:33:20 +02003146 mtc.stop;
Harald Welte9bbbfb52018-04-05 09:33:19 +02003147 }
3148 }
3149 [] PCU.receive { repeat; }
3150 }
3151 /* try to activate this PDCH from the PCU point of view */
3152 PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, g_chan_nr.tn)));
3153 /* FIXME: is there a response? */
3154
3155 RSL.receive(tr_RSL_IPA_PDCH_ACT_ACK(g_chan_nr, ?));
3156}
3157
3158private function f_dyn_ipa_pdch_deact(integer pcu_conn_id, integer bts_nr, integer trx_nr)
3159runs on ConnHdlr {
3160 var PCUIF_send_data sd;
3161 /* Send RSL CHAN REL (deactivate) */
3162 RSL.send(ts_RSL_IPA_PDCH_DEACT(g_chan_nr));
3163 PCU.clear;
3164 /* expect BTS to ask PCU to deactivate the channel */
3165 alt {
3166 [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(bts_nr, ?))) -> value sd {
3167 if (substr(sd.data.u.info_ind.trx[trx_nr].pdch_mask, g_chan_nr.tn, 1) != '0'B) {
3168 setverdict(fail, "PCUIF_INFO_IND PDCH_MASK not '0' after PDCH DEACT");
Daniel Willmann17ddd852018-07-05 17:33:20 +02003169 mtc.stop;
Harald Welte9bbbfb52018-04-05 09:33:19 +02003170 }
3171 }
3172 [] PCU.receive { repeat; }
3173 }
3174 /* Emulate PCU asking BTS to deactivate PDCH */
3175 PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_DEACT_REQ(bts_nr, trx_nr, g_chan_nr.tn)));
3176 alt {
3177 [] RSL.receive(tr_RSL_IPA_PDCH_DEACT_ACK(g_chan_nr)) {
3178 setverdict(pass);
3179 }
3180 [] RSL.receive { repeat; }
3181 }
3182}
3183
3184/* Activate and de-activate an IPA-style dynamic TCH/F + PDCH */
3185function f_TC_dyn_ipa_pdch_act_deact(charstring id) runs on ConnHdlr {
3186 var PCUIF_Message first_info;
3187 var integer ts_nr := g_chan_nr.tn;
3188 var integer trx_nr := 0;
3189 var integer bts_nr := 0;
3190 var integer pcu_conn_id := -1;
3191
3192 f_init_pcu(PCU, id, pcu_conn_id, first_info);
3193
3194 f_dyn_ipa_pdch_act(pcu_conn_id, bts_nr, trx_nr);
3195 f_sleep(3.0);
3196 f_dyn_ipa_pdch_deact(pcu_conn_id, bts_nr, trx_nr);
3197
3198 setverdict(pass);
3199
3200}
3201testcase TC_dyn_ipa_pdch_act_deact() runs on test_CT {
3202 var ConnHdlrPars pars;
3203 var ConnHdlr vc_conn;
3204 f_init();
3205
3206 pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN));
3207 vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_act_deact), pars, true);
3208 vc_conn.done;
3209}
3210
3211/* try to RSL CHAN ACT a TCH/F on an IPA-style PDCH */
3212function f_TC_dyn_ipa_pdch_tchf_act(charstring id) runs on ConnHdlr {
3213 var PCUIF_Message first_info;
3214 var integer ts_nr := g_chan_nr.tn;
3215 var integer trx_nr := 0;
3216 var integer bts_nr := 0;
3217 var integer pcu_conn_id := -1;
3218
3219 f_init_pcu(PCU, id, pcu_conn_id, first_info);
3220
3221 f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_ACK(g_chan_nr),
3222 "RSL CHAN ACT");
3223 f_rsl_transceive(ts_RSL_RF_CHAN_REL(g_chan_nr), tr_RSL_RF_CHAN_REL_ACK(g_chan_nr),
3224 "RF CHAN REL", true);
3225 setverdict(pass);
3226}
3227testcase TC_dyn_ipa_pdch_tchf_act() runs on test_CT {
3228 var ConnHdlrPars pars;
3229 var ConnHdlr vc_conn;
3230 f_init(testcasename());
3231
3232 pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN));
3233 vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_tchf_act), pars, true);
3234 vc_conn.done;
3235}
3236
3237/* Activate IPA style dyn PDCH as TCH/F and then illegally try to activate it as PDCH, too */
3238function f_TC_dyn_ipa_pdch_tchf_act_pdch_act_nack(charstring id) runs on ConnHdlr {
3239 var PCUIF_Message first_info;
3240 var integer ts_nr := g_chan_nr.tn;
3241 var integer trx_nr := 0;
3242 var integer bts_nr := 0;
3243 var integer pcu_conn_id := -1;
3244
3245 f_init_pcu(PCU, id, pcu_conn_id, first_info);
3246
3247 f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_ACK(g_chan_nr),
3248 "RSL CHAN ACT");
3249
3250 RSL.send(ts_RSL_IPA_PDCH_ACT(g_chan_nr));
3251 alt {
3252 [] RSL.receive(tr_RSL_IPA_PDCH_ACT_NACK(g_chan_nr, ?));
3253 [] RSL.receive(tr_RSL_IPA_PDCH_ACT_ACK(g_chan_nr, ?)) {
3254 setverdict(fail, "Unexpected PDCH ACT ACK");
Daniel Willmann17ddd852018-07-05 17:33:20 +02003255 mtc.stop;
Harald Welte9bbbfb52018-04-05 09:33:19 +02003256 }
3257 [] RSL.receive { repeat; }
3258 }
3259
3260 f_rsl_transceive(ts_RSL_RF_CHAN_REL(g_chan_nr), tr_RSL_RF_CHAN_REL_ACK(g_chan_nr),
3261 "RF CHAN REL", true);
3262 setverdict(pass);
3263}
3264testcase TC_dyn_ipa_pdch_tchf_act_pdch_act_nack() runs on test_CT {
3265 var ConnHdlrPars pars;
3266 var ConnHdlr vc_conn;
3267 f_init(testcasename());
3268
3269 pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN));
3270 vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_tchf_act_pdch_act_nack), pars, true);
3271 vc_conn.done;
3272}
3273
3274/* try to RSL CHAN ACT a TCH/F on an IPA-style PDCH that's already in PDCH mode; expect NACK */
3275function f_TC_dyn_ipa_pdch_act_tchf_act_nack(charstring id) runs on ConnHdlr {
3276 var PCUIF_Message first_info;
3277 var integer ts_nr := g_chan_nr.tn;
3278 var integer trx_nr := 0;
3279 var integer bts_nr := 0;
3280 var integer pcu_conn_id := -1;
3281
3282 /* register for the TCH/F channel number */
3283 f_rslem_register(0, g_chan_nr);
3284
3285 f_init_pcu(PCU, id, pcu_conn_id, first_info);
3286
3287 f_dyn_ipa_pdch_act(pcu_conn_id, bts_nr, trx_nr);
3288
3289 f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_NACK(g_chan_nr),
3290 "RSL CHAN ACT");
3291
3292 f_dyn_ipa_pdch_deact(pcu_conn_id, bts_nr, trx_nr);
3293
3294 setverdict(pass);
3295}
3296testcase TC_dyn_ipa_pdch_act_tchf_act_nack() runs on test_CT {
3297 var ConnHdlrPars pars;
3298 var ConnHdlr vc_conn;
3299 f_init(testcasename());
3300
3301 pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN));
3302 vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_act_tchf_act_nack), pars, true);
3303 vc_conn.done;
3304}
3305
3306
Harald Welte0472ab42018-03-12 15:02:26 +01003307/***********************************************************************
3308 * LAPDm / RLL related
3309 ***********************************************************************/
3310
3311private function f_tx_lapdm(template (value) LapdmFrame l,
3312 template (value) RslLinkId link_id) runs on ConnHdlr {
3313 var octetstring l2 := enc_LapdmFrame(valueof(l));
3314 if (valueof(link_id.c) == SACCH) {
3315 /* prepend dummy L1 header */
Pau Espin Pedrola0fb42a2018-10-10 15:56:39 +02003316 var L1ctlDataReq l1hl2 := {
3317 l1header := valueof(ts_SacchL1Header(g_pars.l1_pars.ms_power_level, false, g_pars.l1_pars.ms_actual_ta)),
3318 l2_payload := f_pad_oct(l2, 21, '2B'O)
3319 }
3320 L1CTL.send(ts_L1CTL_DATA_REQ_SACCH(g_chan_nr, link_id, l1hl2));
3321 } else {
3322 /* If required, pad L2 frame with constant 0x2b filling */
3323 l2 := f_pad_oct(l2, 23, '2B'O);
3324
3325 log("encoding ", l, " to ", l2);
3326 L1CTL.send(ts_L1CTL_DATA_REQ(g_chan_nr, link_id, l2));
Harald Welte0472ab42018-03-12 15:02:26 +01003327 }
Harald Welte0472ab42018-03-12 15:02:26 +01003328}
3329
3330type record RllTestCase {
3331 uint3_t sapi,
3332 RslLinkId link_id,
3333 octetstring l3,
3334 boolean exp
3335}
3336type record of RllTestCase RllTestCases;
3337template RllTestCase t_EITC(uint3_t sapi, RslLinkId id, octetstring l3, boolean exp) := {
3338 sapi := sapi,
3339 link_id := id,
3340 l3 := l3,
3341 exp := exp
3342}
3343
3344/* execute the same callback function with a set of different parameters (tcs) on a
3345 * variety of logical channels */
3346private function f_rll_testmatrix(RllTestCases tcs, void_fn fn) runs on test_CT {
3347 var ConnHdlrPars pars;
3348 var ConnHdlr vc_conn;
3349 f_init(testcasename());
3350
3351 /* test on each of the channels we have */
3352 for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i+1) {
3353 pars := valueof(t_Pars(g_AllChanTypes[i], ts_RSL_ChanMode_SIGN));
3354
3355 /* test each of the test cases on the current channel */
3356 for (var integer j := 0; j < sizeof(tcs); j := j+1) {
3357 pars.spec.rll := tcs[j];
3358 log(testcasename(), ": XXX Starting ", tcs[j] , " on ", g_AllChanTypes[i]);
3359 vc_conn := f_start_handler(fn, pars);
3360 vc_conn.done;
3361 }
3362 }
3363
3364 f_shutdown();
3365}
3366
3367/* test if SABM on Um triggers EST IND (TS 48.058 3.1) */
3368private function f_TC_rll_est_ind(charstring id) runs on ConnHdlr {
3369 var RllTestCase tc := g_pars.spec.rll;
3370 timer T := 3.0;
3371
3372 f_l1_tune(L1CTL);
3373 RSL.clear;
3374
3375 /* activate the logical channel */
3376 f_est_dchan();
3377 L1CTL.clear;
3378
3379 f_tx_lapdm(ts_LAPDm_SABM(tc.sapi, cr_MO_CMD, true, tc.l3), tc.link_id);
3380 T.start;
3381 alt {
3382 [tc.l3 != ''O] RSL.receive(tr_RSL_EST_IND(g_chan_nr, tc.link_id, tc.l3)) {
3383 if (tc.exp) {
3384 setverdict(pass);
3385 } else {
3386 setverdict(fail, "Unexpected EST IND with L3 in ", tc);
Daniel Willmann17ddd852018-07-05 17:33:20 +02003387 mtc.stop;
Harald Welte0472ab42018-03-12 15:02:26 +01003388 }
3389 }
3390 [tc.l3 == ''O] RSL.receive(tr_RSL_EST_IND_NOL3(g_chan_nr, tc.link_id)) {
3391 if (tc.exp) {
3392 setverdict(pass);
3393 } else {
3394 setverdict(fail, "Unexpected EST IND without L3 in ", tc);
Daniel Willmann17ddd852018-07-05 17:33:20 +02003395 mtc.stop;
Harald Welte0472ab42018-03-12 15:02:26 +01003396 }
3397 }
Vadim Yanitskiy35677872018-10-04 17:30:21 +07003398 /* We also expect to receive the measurements */
3399 [] as_meas_res(verify_meas := false);
Harald Welte0472ab42018-03-12 15:02:26 +01003400 [tc.exp] T.timeout {
3401 setverdict(fail, "Timeout waiting for EST IND");
Daniel Willmann17ddd852018-07-05 17:33:20 +02003402 mtc.stop;
Harald Welte0472ab42018-03-12 15:02:26 +01003403 }
3404 [not tc.exp] T.timeout {
3405 setverdict(pass);
3406 }
3407 }
3408
3409 f_rsl_chan_deact();
3410 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
3411 f_rslem_unregister(0, g_chan_nr);
3412}
3413testcase TC_rll_est_ind() runs on test_CT {
3414 var RllTestCases tcs := {
Harald Welte7aacbbf2018-05-09 16:56:41 +02003415 /* SAPI0 establishment (contention resolution) */
Harald Welte0472ab42018-03-12 15:02:26 +01003416 valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), '01020304'O, true)),
Harald Welte7aacbbf2018-05-09 16:56:41 +02003417 /* normal SAPI0 establishment */
3418 valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), ''O, true)),
Harald Welte0472ab42018-03-12 15:02:26 +01003419 /* SAPI 3 doesn't support contention resolution */
3420 valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), '01020304'O, false)),
3421 valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), '01020304'O, false)),
3422 /* normal SAPI3 establishment on main DCCH */
3423 valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), ''O, true)),
3424 /* normal SAPI3 establishment on SACCH */
3425 valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), ''O, true))
3426 };
3427 f_rll_testmatrix(tcs, refers(f_TC_rll_est_ind));
3428}
3429
3430/* test if RLL EST REQ trigeres SABM on Um; UA on Um triggers EST CONF (TS 48.058 3.2) */
3431private function f_TC_rll_est_req(charstring id) runs on ConnHdlr {
3432 var RllTestCase tc := g_pars.spec.rll;
3433 var L1ctlDlMessage dl;
3434 timer T := 3.0;
3435
3436 f_l1_tune(L1CTL);
3437 RSL.clear;
3438
3439 /* activate the logical channel */
3440 f_est_dchan();
3441 L1CTL.clear;
3442
3443 /* Send a RSL EST REQ for SAPI3 on main DCCH */
3444 RSL.send(ts_RSL_EST_REQ(g_chan_nr, tc.link_id));
3445 T.start;
3446 alt {
3447 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, ?)) -> value dl {
3448 var LapdmFrame lapdm;
3449 var octetstring l2 := dl.payload.data_ind.payload;
3450 if (dl.dl_info.link_id.c == SACCH) {
3451 /* remove L1 header */
3452 l2 := substr(l2, 2, lengthof(l2)-2);
3453 }
3454 lapdm.ab := dec_LapdmFrameAB(l2);
3455 if (match(lapdm, tr_LAPDm_SABM(tc.sapi, cr_MT_CMD, true, ''O))) {
3456 setverdict(pass);
3457 } else {
3458 repeat;
3459 }
3460 }
3461 [] L1CTL.receive { repeat; }
3462 [] T.timeout {
3463 setverdict(fail, "Timeout waiting for SABM");
Daniel Willmann17ddd852018-07-05 17:33:20 +02003464 mtc.stop;
Harald Welte0472ab42018-03-12 15:02:26 +01003465 }
3466 }
3467
3468 f_rsl_chan_deact();
3469 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
3470 f_rslem_unregister(0, g_chan_nr);
3471}
3472testcase TC_rll_est_req_DCCH_3() runs on test_CT {
3473 var RllTestCases tcs := {
3474 /* normal SAPI3 establishment on main DCCH */
3475 valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), ''O, true))//,
3476 };
3477 f_rll_testmatrix(tcs, refers(f_TC_rll_est_req));
3478}
3479testcase TC_rll_est_req_ACCH_3() runs on test_CT {
3480 var RllTestCases tcs := {
3481 /* normal SAPI3 establishment on SACCH */
3482 valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), ''O, true))
3483 }
3484 f_rll_testmatrix(tcs, refers(f_TC_rll_est_req));
3485}
3486
3487/* altstep to receive a LAPDm frame matching the given template */
3488private altstep as_l1_exp_lapdm(template LapdmFrame exp) runs on ConnHdlr {
3489 var L1ctlDlMessage dl;
3490 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, ?)) -> value dl {
3491 var LapdmFrame lapdm;
3492 var octetstring l2 := dl.payload.data_ind.payload;
3493 if (dl.dl_info.link_id.c == SACCH) {
3494 /* remove L1 header */
3495 l2 := substr(l2, 2, lengthof(l2)-2);
3496 }
3497 if (ischosen(exp.ab)) {
3498 lapdm.ab := dec_LapdmFrameAB(l2);
3499 } else if (ischosen(exp.b4)) {
3500 lapdm.b4 := dec_LapdmFrameB4(l2);
3501 } else if (ischosen(exp.bbis)) {
3502 lapdm.bbis := dec_LapdmFrameBbis(l2);
3503 }
3504 log("Rx LAPDm ", lapdm);
3505 if (match(lapdm, exp)) {
3506 setverdict(pass);
3507 } else {
3508 repeat;
3509 }
3510 }
3511 [] L1CTL.receive { repeat; }
3512}
3513private function f_l1_exp_lapdm(template LapdmFrame exp, float t := 3.0) runs on ConnHdlr {
3514 timer T := t;
3515 T.start;
3516 alt {
3517 [] T.timeout {
3518 setverdict(fail, "Timeout waiting for LAPDm ", exp);
Daniel Willmann17ddd852018-07-05 17:33:20 +02003519 mtc.stop;
Harald Welte0472ab42018-03-12 15:02:26 +01003520 }
3521 [] as_l1_exp_lapdm(exp);
3522 }
3523}
3524
3525/* establish one Radio Link Layer via SABM -> UA. Use l3 for contention resolution */
3526private function f_est_rll_mo(uint3_t sapi, RslLinkId link_id, octetstring l3) runs on ConnHdlr {
3527 /* send SABM from MS -> BTS */
3528 f_tx_lapdm(ts_LAPDm_SABM(sapi, cr_MO_CMD, true, l3), link_id);
3529 /* expect RLL EST IND on Abis */
3530 alt {
3531 [l3 != ''O] RSL.receive(tr_RSL_EST_IND(g_chan_nr, link_id, l3));
3532 [l3 == ''O] RSL.receive(tr_RSL_EST_IND_NOL3(g_chan_nr, link_id));
3533 [] RSL.receive(tr_RSL_ERROR_IND(g_chan_nr, link_id, ?)) {
3534 setverdict(fail, "Failing due to RSL_ERROR_IND");
Daniel Willmann17ddd852018-07-05 17:33:20 +02003535 mtc.stop;
Harald Welte0472ab42018-03-12 15:02:26 +01003536 }
3537 [] RSL.receive { repeat; }
3538 }
3539 /* expect UA from BTS -> MS */
3540 f_l1_exp_lapdm(tr_LAPDm_UA(sapi, cr_MT_RSP, true, l3));
3541}
3542
3543/* test if DISC on Um triggers RLL REL IND (TS 48.058 3.3) */
3544private function f_TC_rll_rel_ind(charstring id) runs on ConnHdlr {
3545 var RllTestCase tc := g_pars.spec.rll;
3546
3547 f_l1_tune(L1CTL);
3548 RSL.clear;
3549
3550 /* activate the logical channel */
3551 f_est_dchan();
3552 L1CTL.clear;
3553
3554 /* first establish the link-layer */
3555 f_est_rll_mo(tc.sapi, tc.link_id, tc.l3);
3556
3557 /* then send the DISC */
3558 f_tx_lapdm(ts_LAPDm_DISC(tc.sapi, cr_MO_CMD, true), tc.link_id);
3559 /* ... and expect the REL IND on the RSL side */
3560 alt {
3561 [] RSL.receive(tr_RSL_REL_IND(g_chan_nr, tc.link_id)) {
3562 setverdict(pass);
3563 }
Vadim Yanitskiy35677872018-10-04 17:30:21 +07003564 /* We also expect to receive the measurements */
3565 [] as_meas_res(verify_meas := false);
Harald Welte0472ab42018-03-12 15:02:26 +01003566 }
3567
3568 /* release the channel */
3569 f_rsl_chan_deact();
3570 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
3571 f_rslem_unregister(0, g_chan_nr);
3572}
3573testcase TC_rll_rel_ind_DCCH_0() runs on test_CT {
3574 var RllTestCases tcs := {
3575 valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), '01020304'O, true))
3576 };
3577 f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind));
3578}
3579
3580testcase TC_rll_rel_ind_ACCH_0() runs on test_CT {
3581 var RllTestCases tcs := {
3582 valueof(t_EITC(0, valueof(ts_RslLinkID_SACCH(0)), ''O, true))
3583 };
3584 f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind));
3585}
3586testcase TC_rll_rel_ind_DCCH_3() runs on test_CT {
3587 var RllTestCases tcs := {
3588 valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), ''O, true))
3589 };
3590 f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind));
3591}
3592testcase TC_rll_rel_ind_ACCH_3() runs on test_CT {
3593 var RllTestCases tcs := {
3594 valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), ''O, true))
3595 };
3596 f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind));
3597}
3598
3599/* test if RLL REL REQ triggers DISC on Um; UA/DM triggers RLL REL CONF (TS 48.058 3.4) */
3600private function f_TC_rll_rel_req(charstring id) runs on ConnHdlr {
3601 var RllTestCase tc := g_pars.spec.rll;
3602 f_l1_tune(L1CTL);
3603 RSL.clear;
3604
3605 /* activate the logical channel */
3606 f_est_dchan();
3607 L1CTL.clear;
3608
3609 /* first establish the link-layer */
3610 f_est_rll_mo(tc.sapi, tc.link_id, tc.l3);
3611
3612 /* then send the REL REQ via RSL */
3613 RSL.send(ts_RSL_REL_REQ(g_chan_nr, tc.link_id, RSL_REL_MODE_NORMAL));
3614 /* ... and expect the DISC on the Um side */
3615 alt {
Harald Weltebc6199f2018-05-10 19:38:18 +02003616 [] as_l1_exp_lapdm(tr_LAPDm_DISC(tc.sapi, cr_MT_CMD, true)) {
Harald Welte0472ab42018-03-12 15:02:26 +01003617 /* FIXME: send a UA in resposne to the DISC */
3618 }
3619 }
3620
3621 /* release the channel */
3622 f_rsl_chan_deact();
3623 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
3624 f_rslem_unregister(0, g_chan_nr);
3625}
3626testcase TC_rll_rel_req() runs on test_CT {
3627 var RllTestCases tcs := {
3628 valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), '01020304'O, true)),
3629 valueof(t_EITC(0, valueof(ts_RslLinkID_SACCH(0)), ''O, true)),
3630 valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), ''O, true)),
3631 valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), ''O, true))
3632 };
3633 f_rll_testmatrix(tcs, refers(f_TC_rll_rel_req));
3634}
3635
3636/* test if RLL DATA REQ triggers I-frames on Um (TS 48.058 3.5) */
3637testcase TC_rll_data_req() runs on test_CT {
3638}
3639
3640/* test if I-frames on Um trigger RLL DATA IND (TS 48.058 3.6) */
3641testcase TC_rll_data_ind() runs on test_CT {
3642}
3643
3644/* test if RLL UNIT DATA REQ triggers UI-frame on Um (TS 48.058 3.7) */
3645private function f_TC_rll_ud_req(charstring id) runs on ConnHdlr {
3646 var RllTestCase tc := g_pars.spec.rll;
3647
3648 f_l1_tune(L1CTL);
3649 RSL.clear;
3650
3651 f_est_dchan();
3652 L1CTL.clear;
3653
3654 /* Send UNITDATA REQ on RSL side */
3655 RSL.send(ts_RSL_UNITDATA_REQ(g_chan_nr, tc.link_id, tc.l3));
3656 /* Expect it to arrive on the other side */
3657 if (tc.link_id.c == SACCH) {
Harald Weltee613f962018-04-18 22:38:16 +02003658 f_l1_exp_lapdm(tr_LAPDm_B4_UI(tc.sapi, cr_MT_CMD, tc.l3));
Harald Welte0472ab42018-03-12 15:02:26 +01003659 } else {
Harald Weltee613f962018-04-18 22:38:16 +02003660 f_l1_exp_lapdm(tr_LAPDm_UI(tc.sapi, cr_MT_CMD, tc.l3));
Harald Welte0472ab42018-03-12 15:02:26 +01003661 }
3662
3663 /* release the channel */
3664 f_rsl_chan_deact();
3665 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
3666 f_rslem_unregister(0, g_chan_nr);
3667}
3668testcase TC_rll_unit_data_req_DCCH() runs on test_CT {
3669 var octetstring l3 := f_rnd_octstring(15);
3670 var RllTestCases tcs := {
3671 valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), l3, true)),
3672 valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), l3, true))
3673 };
3674 f_rll_testmatrix(tcs, refers(f_TC_rll_ud_req));
3675}
3676testcase TC_rll_unit_data_req_ACCH() runs on test_CT {
3677 var octetstring l3 := f_rnd_octstring(19);
3678 var RllTestCases tcs := {
3679 valueof(t_EITC(0, valueof(ts_RslLinkID_SACCH(0)), l3, true)),
3680 valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), l3, true))
3681 };
3682 f_rll_testmatrix(tcs, refers(f_TC_rll_ud_req));
3683}
3684
3685/* test if UI-frames on Um trigger RLL UNIT DATA IND (TS 48.058 3.8) */
3686private function f_TC_rll_ud_ind(charstring id) runs on ConnHdlr {
3687 var RllTestCase tc := g_pars.spec.rll;
3688
3689 f_l1_tune(L1CTL);
3690 RSL.clear;
3691
3692 f_est_dchan();
3693 L1CTL.clear;
3694
3695 /* Send LAPDm UI frame. There is no B4 format in uplink! */
Harald Weltee613f962018-04-18 22:38:16 +02003696 f_tx_lapdm(ts_LAPDm_UI(tc.sapi, cr_MO_CMD, tc.l3), tc.link_id);
Harald Welte0472ab42018-03-12 15:02:26 +01003697 /* Expdct RLL UNITDATA IND on RSL side */
3698 alt {
3699 [] RSL.receive(tr_RSL_UNITDATA_IND(g_chan_nr, tc.link_id, tc.l3)) {
3700 setverdict(pass);
3701 }
3702 [] RSL.receive { repeat; }
3703 }
3704
3705 /* release the channel */
3706 f_rsl_chan_deact();
3707 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
3708 f_rslem_unregister(0, g_chan_nr);
3709}
3710testcase TC_rll_unit_data_ind_DCCH() runs on test_CT {
Stefan Sperlingc4181912018-07-25 17:03:08 +02003711 var octetstring l3 := f_rnd_octstring(20);
Harald Welte0472ab42018-03-12 15:02:26 +01003712 var RllTestCases tcs := {
3713 valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), l3, true)),
3714 valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), l3, true))
3715 };
3716 f_rll_testmatrix(tcs, refers(f_TC_rll_ud_ind));
3717}
3718testcase TC_rll_unit_data_ind_ACCH() runs on test_CT {
3719 var octetstring l3 := f_rnd_octstring(18);
3720 var RllTestCases tcs := {
3721 valueof(t_EITC(0, valueof(ts_RslLinkID_SACCH(0)), l3, true)),
3722 valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), l3, true))
3723 };
3724 f_rll_testmatrix(tcs, refers(f_TC_rll_ud_ind));
3725}
3726
Harald Weltee613f962018-04-18 22:38:16 +02003727/***********************************************************************
3728 * Encryption Related
3729 ***********************************************************************/
3730
3731/* send UNITDATA_REQ from BTS to MS and expect it to arrive */
3732function f_unitdata_mt(RslLinkId link_id, octetstring l3) runs on ConnHdlr {
3733 RSL.send(ts_RSL_UNITDATA_REQ(g_chan_nr, link_id, l3));
3734 if (link_id.c == SACCH) {
3735 f_l1_exp_lapdm(tr_LAPDm_B4_UI(link_id.sapi, cr_MT_CMD, l3));
3736 } else {
3737 f_l1_exp_lapdm(tr_LAPDm_UI(link_id.sapi, cr_MT_CMD, l3));
3738 }
3739}
3740
Vadim Yanitskiyad131c82018-10-04 06:18:59 +07003741/* Expect (or not expect) other kinds of messages */
3742private altstep as_rsl_any_ind(boolean exp_any) runs on ConnHdlr {
3743 [exp_any] RSL.receive { repeat; }
3744 [not exp_any] RSL.receive {
3745 setverdict(fail, "Unexpected RSL message!");
3746 mtc.stop;
3747 }
3748}
3749
Harald Weltee613f962018-04-18 22:38:16 +02003750/* Send UI frame from MS and expect it to arrive as RLL UNITDATA IND on Abis */
Vadim Yanitskiy8d8f91c2018-10-04 06:19:45 +07003751private function f_unitdata_mo(
Vadim Yanitskiy98e03152018-10-03 18:06:06 +07003752 RslLinkId link_id,
3753 octetstring l3,
3754 boolean exp_sacch := true, /* Should tolerate SACCH messages? */
Vadim Yanitskiyb9920502018-10-03 18:29:51 +07003755 boolean exp_any := false /* Should tolerate any other RSL messages? */
Vadim Yanitskiy98e03152018-10-03 18:06:06 +07003756) runs on ConnHdlr {
Harald Weltee613f962018-04-18 22:38:16 +02003757 timer T := 3.0;
3758 f_tx_lapdm(ts_LAPDm_UI(link_id.sapi, cr_MO_CMD, l3), link_id);
3759 T.start;
3760 /* Expect RLL UNITDATA IND on RSL side */
3761 alt {
3762 [] RSL.receive(tr_RSL_UNITDATA_IND(g_chan_nr, link_id, l3)) {
3763 setverdict(pass);
3764 }
Vadim Yanitskiye0b91a72018-10-04 15:44:40 +07003765 [exp_sacch] as_meas_res(verify_meas := false);
Vadim Yanitskiyad131c82018-10-04 06:18:59 +07003766 [] as_rsl_any_ind(exp_any);
Harald Weltee613f962018-04-18 22:38:16 +02003767 [] T.timeout {
3768 setverdict(fail, "Timeout waiting for UNIT_DATA_IND");
Daniel Willmann17ddd852018-07-05 17:33:20 +02003769 mtc.stop;
Harald Weltee613f962018-04-18 22:38:16 +02003770 }
Harald Weltee613f962018-04-18 22:38:16 +02003771 }
3772}
3773
Vadim Yanitskiy4d78a702018-10-03 03:59:34 +07003774/* Send I-frame from MS and expect it to arrive as RLL DATA IND on Abis */
3775private function f_data_mo(
3776 RslLinkId link_id,
3777 boolean p, uint3_t nr, uint3_t ns,
3778 octetstring l3,
3779 boolean exp_sacch := true, /* Should tolerate SACCH messages? */
Vadim Yanitskiyb9920502018-10-03 18:29:51 +07003780 boolean exp_any := false /* Should tolerate any other RSL messages? */
Vadim Yanitskiy4d78a702018-10-03 03:59:34 +07003781) runs on ConnHdlr {
3782 timer T := 3.0;
3783 f_tx_lapdm(ts_LAPDm_I(link_id.sapi, cr_MO_CMD, p, nr, ns, l3), link_id);
3784 T.start;
3785 /* Expect RLL DATA IND on RSL side */
3786 alt {
3787 [] RSL.receive(tr_RSL_DATA_IND(g_chan_nr, link_id, l3)) {
3788 setverdict(pass);
3789 }
Vadim Yanitskiye0b91a72018-10-04 15:44:40 +07003790 [exp_sacch] as_meas_res(verify_meas := false);
Vadim Yanitskiy4d78a702018-10-03 03:59:34 +07003791 [] as_rsl_any_ind(exp_any);
3792 [] T.timeout {
3793 setverdict(fail, "Timeout waiting for DATA_IND");
3794 mtc.stop;
3795 }
3796 }
3797}
3798
Harald Weltee613f962018-04-18 22:38:16 +02003799/* Test channel activation with A5/n right from the beginning (like in assignment + hand-over) */
3800function f_TC_chan_act_encr(charstring id) runs on ConnHdlr {
3801 f_l1_tune(L1CTL);
3802 f_est_dchan(true);
3803
3804 /* now we actually need to transmit some data both ways to check if the encryption works */
3805 var L1ctlDlMessage dl;
3806
Stefan Sperling603d98e2018-07-25 16:47:28 +02003807 var octetstring l3 := f_rnd_octstring(20);
Harald Weltee613f962018-04-18 22:38:16 +02003808 var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0));
3809
3810 /* send UNITDATA_REQ from BTS to MS and expect it to arrive */
3811 f_unitdata_mt(link_id, l3);
3812
3813 /* Send UI frame from MS and expect it to arrive as RLL UNITDATA IND on Abis */
3814 f_unitdata_mo(link_id, l3);
3815
3816 /* release the channel */
3817 f_rsl_chan_deact();
3818 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
3819 f_rslem_unregister(0, g_chan_nr);
3820}
3821testcase TC_chan_act_a51() runs on test_CT {
3822 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
3823 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_1, f_rnd_octstring(8)));
3824 f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr));
3825}
3826testcase TC_chan_act_a52() runs on test_CT {
3827 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
3828 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_2, f_rnd_octstring(8)));
3829 f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr));
3830}
3831testcase TC_chan_act_a53() runs on test_CT {
3832 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
3833 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_3, f_rnd_octstring(8)));
3834 f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr));
3835}
3836
3837
3838/* Test unencrypted channel activation followed by explicit ENCR CMD later */
3839function f_TC_encr_cmd(charstring id) runs on ConnHdlr {
3840 /* L3 payload doesn't matter, as it is passed transparently */
3841 var BIT3 l3_alg_id := f_alg_id_to_l3(g_pars.encr.alg_id);
3842 var octetstring l3 := enc_PDU_ML3_NW_MS(valueof(ts_RRM_CiphModeCmd(l3_alg_id)));
3843 var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0));
3844
3845 f_l1_tune(L1CTL);
3846
3847 /* first establish a dedicated channel in the clear */
3848 f_est_dchan(false);
3849
3850 /* Establish ABM */
3851 f_est_rll_mo(link_id.sapi, link_id, '23420815'O);
3852
3853 /* then send the RSL ENCR CMD with an actual RR CIPH MOD CMD inside */
3854 RSL.send(ts_RSL_ENCR_CMD(g_chan_nr, link_id, g_pars.encr.alg_id, g_pars.encr.key, l3));
3855 /* expect the L3 to arrive still unencrypted on the MS side */
3856 f_l1_exp_lapdm(tr_LAPDm_I(link_id.sapi, cr_MT_CMD, ?, ?, ?, l3));
3857
3858 /* configure L1 to apply ciphering */
3859 var uint8_t alg_id := f_alg_id_to_l1ctl(g_pars.encr.alg_id);
3860 f_L1CTL_CRYPTO_REQ(L1CTL, g_pars.chan_nr, alg_id, g_pars.encr.key);
3861
Vadim Yanitskiy4d78a702018-10-03 03:59:34 +07003862 /* send first ciphered I-frame in response and expect it on RSL */
3863 f_data_mo(link_id, true, 1, 0, '0a0b0c0d'O, exp_sacch := true);
Harald Weltee613f962018-04-18 22:38:16 +02003864
3865 /* now the BTS code should have detected the first properly encrypted uplink I-frame,
3866 * and hence enable encryption also on the downlink */
3867
3868 /* expect bi-directional communication work in encrypted mode */
3869 f_unitdata_mo(link_id, f_rnd_octstring(15));
3870 f_unitdata_mt(link_id, f_rnd_octstring(15));
3871
3872 /* release the channel */
3873 f_rsl_chan_deact();
3874 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
3875 f_rslem_unregister(0, g_chan_nr);
3876}
3877testcase TC_encr_cmd_a51() runs on test_CT {
3878 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
3879 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_1, f_rnd_octstring(8)));
3880 f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd));
3881}
3882testcase TC_encr_cmd_a52() runs on test_CT {
3883 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
3884 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_2, f_rnd_octstring(8)));
3885 f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd));
3886}
3887testcase TC_encr_cmd_a53() runs on test_CT {
3888 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
3889 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_3, f_rnd_octstring(8)));
3890 f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd));
3891}
3892
3893private function f_assert_lapdm(octetstring enc, template LapdmFrame exp_match, charstring name := "") {
3894 var LapdmFrame lf;
3895 var octetstring reenc;
3896
3897 /* decode the LAPDm frame */
3898 if (ischosen(exp_match.ab)) {
3899 lf.ab := dec_LapdmFrameAB(enc);
3900 } else {
3901 setverdict(fail, "unsupported frame type");
Daniel Willmann17ddd852018-07-05 17:33:20 +02003902 mtc.stop;
Harald Weltee613f962018-04-18 22:38:16 +02003903 }
3904
3905 /* check if decoder result matches expectation */
3906 if (not match(lf, exp_match)) {
3907 setverdict(fail, name, ": decoded LAPDm doesn't match");
Daniel Willmann17ddd852018-07-05 17:33:20 +02003908 mtc.stop;
Harald Weltee613f962018-04-18 22:38:16 +02003909 } else {
3910 log(name, ": matched");
3911 setverdict(pass);
3912 }
3913
3914 /* test if re-encoded frame equals original input */
3915 reenc := enc_LapdmFrame(lf);
3916 if (enc != reenc) {
3917 setverdict(fail, name, ": re-encoded LAPDm frame doesn't match");
Daniel Willmann17ddd852018-07-05 17:33:20 +02003918 mtc.stop;
Harald Weltee613f962018-04-18 22:38:16 +02003919 } else {
3920 setverdict(pass);
3921 }
3922}
3923
3924testcase TC_lapdm_selftest() runs on test_CT {
3925 f_assert_lapdm('030301'O, tr_LAPDm_UI(0, true, ''O), "ui_s0_empty");
3926 f_assert_lapdm('0F0301'O, tr_LAPDm_UI(3, true, ''O), "ui_s3_empty");
3927 f_assert_lapdm('013F01'O, tr_LAPDm_SABM(0, false, true, ''O), "sabm_s0_empty");
3928 f_assert_lapdm('013F1123420815'O, tr_LAPDm_SABM(0, false, true, '23420815'O), "sabm_s0_l3");
3929 f_assert_lapdm('03E101'O, tr_LAPDm_RR(0, true, false, 7), "rr_s0_7");
3930 f_assert_lapdm('03000d063505'O, tr_LAPDm_I(0, true, false, 0, 0, '063505'O), "I/0/0");
3931 f_assert_lapdm('03e00d063505'O, tr_LAPDm_I(0, true, false, 7, 0, '063505'O), "I/7/0");
3932}
3933
Stefan Sperling4880be42018-08-07 18:12:59 +02003934/***********************************************************************
3935 * DTX Related (see GSM 05.08, section 8.3)
3936 ***********************************************************************/
3937
3938/* XXX These functions must be kept in sync with g_AllChannels defined on test_CT. */
3939function f_g_chan_is_tchf() runs on ConnHdlr return boolean {
3940 return (g_chan_nr == valueof(ts_RslChanNr_Bm(1)) or
3941 g_chan_nr == valueof(ts_RslChanNr_Bm(2)) or
3942 g_chan_nr == valueof(ts_RslChanNr_Bm(3)) or
3943 g_chan_nr == valueof(ts_RslChanNr_Bm(4)));
3944}
3945function f_g_chan_is_tchh() runs on ConnHdlr return boolean {
3946 return (g_chan_nr == valueof(ts_RslChanNr_Lm(5,0)) or
3947 g_chan_nr == valueof(ts_RslChanNr_Lm(5,1)));
3948}
3949function f_g_chan_is_sdcch4() runs on ConnHdlr return boolean {
3950 return (g_chan_nr == valueof(ts_RslChanNr_SDCCH4(0,0)) or
3951 g_chan_nr == valueof(ts_RslChanNr_SDCCH4(0,1)) or
3952 g_chan_nr == valueof(ts_RslChanNr_SDCCH4(0,2)) or
3953 g_chan_nr == valueof(ts_RslChanNr_SDCCH4(0,3)));
3954}
3955function f_g_chan_is_sdcch8() runs on ConnHdlr return boolean {
3956 return (g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,0)) or
3957 g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,1)) or
3958 g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,2)) or
3959 g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,3)) or
3960 g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,4)) or
3961 g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,5)) or
3962 g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,6)) or
3963 g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,7)));
3964}
3965
3966function f_test_l2_fill_frames(boolean dtxd) runs on ConnHdlr {
3967 var L1ctlDlMessage dl;
3968 var octetstring l2_fill_frame := '0303012B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B'O;
3969 var octetstring l2_fill_frame_sacch := substr(l2_fill_frame, 0, lengthof(l2_fill_frame) - 2);
3970 var GsmFrameNumber first_fn;
3971 var boolean is_first_frame := true;
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02003972 var integer nfill_frames_sacch := 0;
3973 var integer nfill_frames_nonsacch := 0;
3974 var integer expected_fill_frames := 10000; /* initial value causes test failure if not overridden */
Stefan Sperling4880be42018-08-07 18:12:59 +02003975 /* Frames numbers (mod 104) for which a fill frame is expected on TCHF if DTX is enabled. */
3976 var Integers required_tdma_frames_dtx_tchf := { 52, 53, 54, 55, 56, 57, 58, 59 };
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02003977 const integer frame_dtx_tchf_mod := 104;
3978 /* Frame numbers (mod 104) for which a fill frame is expected at the L1SAP level,
3979 * which operates in terms of blocks rather than frames. */
3980 var Integers required_tdma_blocks_dtx_tchf := { 52, 56 };
3981 const integer block_dtx_tchf_mod := 26;
Stefan Sperling4880be42018-08-07 18:12:59 +02003982 timer T := 5.0;
3983
3984 f_l1_tune(L1CTL);
3985 RSL.clear;
3986 L1CTL.clear;
3987
3988 /* activate TCHF signalling channel */
3989 f_est_dchan(false);
3990
3991 T.start;
3992 alt {
3993 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, ?)) -> value dl {
3994 var GsmFrameNumber fn := dl.dl_info.frame_nr;
3995 var octetstring l2 := dl.payload.data_ind.payload;
3996
3997 if (is_first_frame) {
3998 is_first_frame := false;
3999 first_fn := dl.dl_info.frame_nr;
4000 }
4001
4002 if (dl.dl_info.link_id.c == SACCH) {
4003 l2 := substr(l2, 2, lengthof(l2) - 2); /* remove L1 header */
4004 if (not match(l2_fill_frame_sacch, l2)) {
4005 repeat;
4006 }
4007 } else if (not match(l2_fill_frame, l2)) {
4008 repeat;
4009 }
4010
4011 if (dtxd) {
4012 if (not f_g_chan_is_tchf()) {
4013 T.stop;
4014 f_rsl_chan_deact();
4015 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
4016 setverdict(fail, "Received fill frame on non-TCH/F channel; DTX is only allowed on TCH/F!");
4017 }
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02004018 if (fn > first_fn + frame_dtx_tchf_mod) {
Stefan Sperling4880be42018-08-07 18:12:59 +02004019 T.stop;
4020 f_rsl_chan_deact();
4021 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02004022
4023 /* With DTX enabled we can expect at least 3 fill frames for every 104 frames.
4024 * 2 SACCH, 1 TCH/F */
4025 expected_fill_frames := 3;
4026
4027 if (nfill_frames_sacch + nfill_frames_nonsacch < expected_fill_frames) {
4028 log("received only ", nfill_frames_sacch, "+", nfill_frames_nonsacch,
4029 " (SACCH+other) out of ", expected_fill_frames, " expected fill frames");
4030 setverdict(fail, "Not enough fill frames received");
Stefan Sperling4880be42018-08-07 18:12:59 +02004031 } else {
4032 setverdict(pass);
4033 }
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02004034 } else {
4035 if (dl.dl_info.link_id.c == SACCH) {
4036 nfill_frames_sacch := nfill_frames_sacch + 1;
Stefan Sperling4880be42018-08-07 18:12:59 +02004037 repeat;
4038 }
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02004039 /* On DTX TCH/F channels, fill frames occur only for specific frame numbers mod 104.
4040 * Furthermore, the L1SAP layer gives us frame numbers for the start of a block so
4041 * we should only see the subset of frames numbers which correspond to a block boundary.
4042 * TCH/F blocks are defined to start at 0,4,8,13,17,21 (modulo 26) */
4043 for (var integer i := 0; i < lengthof(required_tdma_blocks_dtx_tchf); i := i + 1) {
4044 if (fn mod frame_dtx_tchf_mod == required_tdma_blocks_dtx_tchf[i]) {
4045 nfill_frames_nonsacch := nfill_frames_nonsacch + 1;
4046 repeat;
4047 }
4048 }
4049 log("Received DTX TCH fill frame with bad frame number: ", fn,
4050 " (mod ", frame_dtx_tchf_mod, ": ", fn mod frame_dtx_tchf_mod, ")",
4051 " (mod ", block_dtx_tchf_mod, ": ", fn mod block_dtx_tchf_mod, ")");
4052 f_rsl_chan_deact();
4053 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
4054 setverdict(fail, "Unexpected L2 fill frame received on Um");
Stefan Sperling4880be42018-08-07 18:12:59 +02004055 }
Stefan Sperling4880be42018-08-07 18:12:59 +02004056 } else {
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02004057 if (dl.dl_info.link_id.c == SACCH) {
4058 nfill_frames_sacch := nfill_frames_sacch + 1;
4059 } else {
4060 nfill_frames_nonsacch := nfill_frames_nonsacch + 1;
4061 }
4062 if (fn > first_fn + frame_dtx_tchf_mod) {
Stefan Sperling4880be42018-08-07 18:12:59 +02004063 T.stop;
4064 if (f_g_chan_is_tchf()) {
4065 /* Without DTX we can expect 25 fill frames for every 104 frames.
4066 * (24 FACCH + 1 SACCH filling) */
4067 expected_fill_frames := 25;
4068 } else if (f_g_chan_is_tchh()) {
4069 /* We can expect 2 fill frames for every 104 frames. */
4070 expected_fill_frames := 2;
4071 } else if (f_g_chan_is_sdcch4() or f_g_chan_is_sdcch8()) {
4072 /* We can expect 5 fill frames for every 104 frames. */
4073 expected_fill_frames := 5;
4074 } else {
4075 f_rsl_chan_deact();
4076 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
4077 setverdict(fail, "Unknown channel type");
4078 }
4079
4080 f_rsl_chan_deact();
4081 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02004082
4083 if (nfill_frames_sacch + nfill_frames_nonsacch >= expected_fill_frames) {
Stefan Sperling4880be42018-08-07 18:12:59 +02004084 setverdict(pass);
4085 } else {
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02004086 log("received only ", nfill_frames_sacch, "+", nfill_frames_nonsacch,
4087 " (SACCH+other) out of ", expected_fill_frames, " expected fill frames");
Stefan Sperling4880be42018-08-07 18:12:59 +02004088 setverdict(fail, "Not enough fill frames received");
4089 }
4090 } else {
4091 repeat;
4092 }
4093 }
4094 }
4095 [] L1CTL.receive { repeat; }
4096 [] T.timeout {
4097 f_rsl_chan_deact();
4098 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
4099 setverdict(fail, "Timeout waiting for L2 fill frames on Um");
4100 mtc.stop;
4101 }
4102 }
4103}
4104
4105function f_TC_tch_sign_l2_fill_frame(charstring id) runs on ConnHdlr {
4106 f_test_l2_fill_frames(false);
4107}
4108
4109function f_TC_tch_sign_l2_fill_frame_dtxd(charstring id) runs on ConnHdlr {
4110 f_test_l2_fill_frames(true);
4111}
4112
4113function f_tch_sign_l2_fill_frame(boolean dtxd) runs on test_CT {
4114 var ConnHdlr vc_conn;
4115 var ConnHdlrPars pars;
4116 pars.t_guard := 60.0;
4117 f_init(testcasename());
4118 for (var integer i := 0; i < sizeof(g_AllChannels); i := i + 1) {
4119 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN(dtxd)));
4120 if (dtxd) {
4121 if (i >= 4) { /* DTX is only allowed on TCH/F */
4122 break;
4123 }
4124 vc_conn := f_start_handler(refers(f_TC_tch_sign_l2_fill_frame_dtxd), pars);
4125 } else {
4126 vc_conn := f_start_handler(refers(f_TC_tch_sign_l2_fill_frame), pars);
4127 }
4128 vc_conn.done;
4129 }
4130}
4131
4132/* Verify that L2 fill frames are sent on TCH in signaling mode if
4133 * there is nothing to transmit while DTX is disabled on downlink. */
4134testcase TC_tch_sign_l2_fill_frame() runs on test_CT {
4135 f_tch_sign_l2_fill_frame(false);
4136}
4137
4138/* Verify that particular L2 fill frames are sent on TCH in signaling mode if
4139 * there is nothing to transmit while DTX is enabled on downlink. */
4140testcase TC_tch_sign_l2_fill_frame_dtxd() runs on test_CT {
4141 f_tch_sign_l2_fill_frame(true);
4142}
Harald Welte0472ab42018-03-12 15:02:26 +01004143
Stefan Sperling0ec1c262018-10-15 15:12:52 +02004144testcase TC_chopped_ipa_ping() runs on test_CT {
4145 IPA_Testing.f_run_TC_chopped_ipa_ping(mp_rsl_ip, mp_rsl_port, LISTEN_FOR_CLIENT);
4146}
4147
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02004148testcase TC_chopped_ipa_payload() runs on test_CT {
4149 IPA_Testing.f_run_TC_chopped_ipa_payload(mp_rsl_ip, mp_rsl_port, LISTEN_FOR_CLIENT);
4150}
4151
Harald Welte0472ab42018-03-12 15:02:26 +01004152/* test generation of RLL ERR IND based on Um errors (TS 48.058 3.9) */
4153/* protocol error as per 44.006 */
4154/* link layer failure (repetition of I-frame N200 times without ACK */
4155/* repetition of SABM or DISC N200 times without ACK */
4156/* receptiom of SABM in multi-frame established state */
4157
4158
4159
4160
Harald Welte883340c2018-02-28 18:59:29 +01004161
Harald Welte68e495b2018-02-25 00:05:57 +01004162/* TODO Areas:
4163
4164* channel activation
4165** with BS_Power / MS_Power, bypassing power control loop
4166** on primary vs. secondary TRX
Harald Welte68e495b2018-02-25 00:05:57 +01004167** with timing advance from initial activation on
4168* mode modify
4169** encryption
4170** multirate
4171* check DEACTIVATE SACCH
Harald Welte68e495b2018-02-25 00:05:57 +01004172** unsupported algorithm
4173* handover detection
4174* MS Power Control
4175* BS Power Control
4176* Physical Context
Harald Welte43c54642018-09-15 17:47:04 +03004177* CCCH Load Indication for RACH
Harald Welte68e495b2018-02-25 00:05:57 +01004178* SMS Broadcast Req / Cmd / CBCH LOad Ind
4179* RF resource ind
Harald Welte68e495b2018-02-25 00:05:57 +01004180* error handling
Harald Welte43c54642018-09-15 17:47:04 +03004181** discriminator error
Harald Welte68e495b2018-02-25 00:05:57 +01004182** type error
4183** sequence error
4184** IE duplicated?
Harald Welte883340c2018-02-28 18:59:29 +01004185* PCU interface
4186** TIME_IND from BTS->PCU
4187** DATA_IND from BTS->PCU
4188** verification of PCU-originated DATA_REQ arrival on Um/MS side
Harald Welte68e495b2018-02-25 00:05:57 +01004189
4190*/
Harald Welte70767382018-02-21 12:16:40 +01004191
4192control {
4193 execute( TC_chan_act_stress() );
4194 execute( TC_chan_act_react() );
4195 execute( TC_chan_deact_not_active() );
4196 execute( TC_chan_act_wrong_nr() );
Harald Welte629cc6b2018-03-11 17:19:05 +01004197 execute( TC_deact_sacch() );
Harald Welteea17b912018-03-11 22:29:31 +01004198 execute( TC_sacch_filling() );
4199 execute( TC_sacch_info_mod() );
Harald Welte075d84c2018-03-12 13:07:24 +01004200 execute( TC_sacch_multi() );
Harald Welte55700662018-03-12 13:15:43 +01004201 execute( TC_sacch_multi_chg() );
Harald Welte8c24c2b2018-02-26 08:31:31 +01004202 execute( TC_rach_content() );
4203 execute( TC_rach_count() );
Harald Welte54a2a2d2018-02-26 09:14:05 +01004204 execute( TC_rach_max_ta() );
Harald Welte70767382018-02-21 12:16:40 +01004205 execute( TC_meas_res_sign_tchf() );
4206 execute( TC_meas_res_sign_tchh() );
4207 execute( TC_meas_res_sign_sdcch4() );
4208 execute( TC_meas_res_sign_sdcch8() );
Harald Welte685d5982018-02-27 20:42:05 +01004209 execute( TC_meas_res_sign_tchh_toa256() );
Harald Welte70767382018-02-21 12:16:40 +01004210 execute( TC_conn_fail_crit() );
Harald Welte68e495b2018-02-25 00:05:57 +01004211 execute( TC_paging_imsi_80percent() );
4212 execute( TC_paging_tmsi_80percent() );
4213 execute( TC_paging_imsi_200percent() );
4214 execute( TC_paging_tmsi_200percent() );
Harald Welte01d982c2018-02-25 01:31:40 +01004215 execute( TC_rsl_protocol_error() );
4216 execute( TC_rsl_mand_ie_error() );
4217 execute( TC_rsl_ie_content_error() );
Harald Welte48494ca2018-02-25 16:59:50 +01004218 execute( TC_si_sched_default() );
Harald Welte0cae4552018-03-09 22:20:26 +01004219 execute( TC_si_sched_1() );
Harald Welte48494ca2018-02-25 16:59:50 +01004220 execute( TC_si_sched_2bis() );
4221 execute( TC_si_sched_2ter() );
4222 execute( TC_si_sched_2ter_2bis() );
4223 execute( TC_si_sched_2quater() );
4224 execute( TC_si_sched_13() );
4225 execute( TC_si_sched_13_2bis_2ter_2quater() );
Harald Weltea871a382018-02-25 02:03:14 +01004226 execute( TC_ipa_dlcx_not_active() );
Harald Weltea3f1df92018-02-25 12:49:55 +01004227 execute( TC_ipa_crcx_twice_not_active() );
4228 execute( TC_ipa_crcx_mdcx_dlcx_not_active() );
Harald Welte3ae11da2018-02-25 13:36:06 +01004229 execute( TC_ipa_crcx_mdcx_mdcx_dlcx_not_active() );
Harald Welte9912eb52018-02-25 13:30:15 +01004230 execute( TC_ipa_crcx_sdcch_not_active() );
Harald Welte883340c2018-02-28 18:59:29 +01004231
4232 execute( TC_pcu_act_req() );
4233 execute( TC_pcu_act_req_wrong_ts() );
4234 execute( TC_pcu_act_req_wrong_bts() );
4235 execute( TC_pcu_act_req_wrong_trx() );
4236 execute( TC_pcu_deact_req() );
4237 execute( TC_pcu_deact_req_wrong_ts() );
4238 execute( TC_pcu_ver_si13() );
4239 execute( TC_pcu_data_req_wrong_bts() );
4240 execute( TC_pcu_data_req_wrong_trx() );
4241 execute( TC_pcu_data_req_wrong_ts() );
4242 execute( TC_pcu_data_req_ts_inactive() );
4243 execute( TC_pcu_data_req_pdtch() );
4244 execute( TC_pcu_data_req_ptcch() );
4245 execute( TC_pcu_data_req_agch() );
4246 execute( TC_pcu_data_req_imm_ass_pch() );
4247 execute( TC_pcu_rach_content() );
4248 execute( TC_pcu_paging_from_rsl() );
Harald Welte3d04ae62018-04-04 20:29:05 +02004249
4250 execute( TC_dyn_osmo_pdch_act_deact() );
4251 execute( TC_dyn_osmo_pdch_unsol_deact() );
4252 execute( TC_dyn_osmo_pdch_double_act() );
4253 execute( TC_dyn_osmo_pdch_tchf_act() );
4254 execute( TC_dyn_osmo_pdch_tchh_act() );
Harald Welte9bbbfb52018-04-05 09:33:19 +02004255 execute( TC_dyn_ipa_pdch_act_deact() );
4256 execute( TC_dyn_ipa_pdch_tchf_act() );
4257 execute( TC_dyn_ipa_pdch_tchf_act_pdch_act_nack() );
4258 execute( TC_dyn_ipa_pdch_act_tchf_act_nack() );
Harald Welte0472ab42018-03-12 15:02:26 +01004259
4260 execute( TC_rll_est_ind() );
4261 execute( TC_rll_est_req_DCCH_3() );
4262 execute( TC_rll_est_req_ACCH_3() );
4263 execute( TC_rll_rel_ind_DCCH_0() );
4264 execute( TC_rll_rel_ind_DCCH_3() );
4265 execute( TC_rll_rel_ind_ACCH_0() );
4266 execute( TC_rll_rel_ind_ACCH_3() );
4267 execute( TC_rll_rel_req() );
4268 execute( TC_rll_unit_data_req_DCCH() );
4269 execute( TC_rll_unit_data_req_ACCH() );
4270 execute( TC_rll_unit_data_ind_DCCH() );
4271 execute( TC_rll_unit_data_ind_ACCH() );
Harald Weltee613f962018-04-18 22:38:16 +02004272
4273 execute( TC_chan_act_a51() );
4274 execute( TC_chan_act_a52() );
4275 execute( TC_chan_act_a53() );
4276 execute( TC_encr_cmd_a51() );
4277 execute( TC_encr_cmd_a52() );
4278 execute( TC_encr_cmd_a53() );
4279
4280 execute( TC_lapdm_selftest() );
Stefan Sperling4880be42018-08-07 18:12:59 +02004281
4282 execute( TC_tch_sign_l2_fill_frame() );
4283 execute( TC_tch_sign_l2_fill_frame_dtxd() );
Stefan Sperling0ec1c262018-10-15 15:12:52 +02004284
4285 execute( TC_chopped_ipa_ping() );
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02004286 execute( TC_chopped_ipa_payload() );
Harald Welte70767382018-02-21 12:16:40 +01004287}
4288
4289
4290}