blob: a879f75805744306eb8fe0673cb7bbd99081b61a [file] [log] [blame]
Harald Welte70767382018-02-21 12:16:40 +01001module BTS_Tests {
2
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003import from Misc_Helpers all;
Harald Welte70767382018-02-21 12:16:40 +01004import from General_Types all;
5import from GSM_Types all;
6import from GSM_RR_Types all;
7import from Osmocom_Types all;
8import from GSM_Types all;
Harald Welte82ccef72018-02-25 16:17:33 +01009import from GSM_SystemInformation all;
Harald Welte70767382018-02-21 12:16:40 +010010import from L1CTL_PortType all;
11import from L1CTL_Types all;
12import from LAPDm_Types all;
13import from Osmocom_CTRL_Adapter all;
Neels Hofmeyr6a84b232018-04-03 19:12:36 +020014import from Osmocom_CTRL_Functions all;
Harald Welte70767382018-02-21 12:16:40 +010015
16import from RSL_Types all;
Harald Welte7484fc42018-02-24 14:09:45 +010017import from IPA_Types all;
Harald Welte70767382018-02-21 12:16:40 +010018import from IPA_Emulation all;
Stefan Sperling0ec1c262018-10-15 15:12:52 +020019import from IPA_Testing all;
Harald Welte70767382018-02-21 12:16:40 +010020import from RSL_Emulation all;
21
22import from IPL4asp_Types all;
23import from TRXC_Types all;
24import from TRXC_CodecPort all;
25import from TRXC_CodecPort_CtrlFunct all;
26
Harald Welte883340c2018-02-28 18:59:29 +010027import from PCUIF_Types all;
28import from PCUIF_CodecPort all;
29
Harald Welte7484fc42018-02-24 14:09:45 +010030import from MobileL3_CommonIE_Types all;
Harald Welte68e495b2018-02-25 00:05:57 +010031import from MobileL3_RRM_Types all;
32import from MobileL3_Types all;
33import from L3_Templates all;
Harald Welte7484fc42018-02-24 14:09:45 +010034
Harald Welte8da48242018-02-27 20:41:32 +010035import from Osmocom_VTY_Functions all;
36import from TELNETasp_PortType all;
37
Harald Welte505cf9b2018-09-15 17:47:23 +030038friend module BTS_Tests_SMSCB;
39
Harald Welte70767382018-02-21 12:16:40 +010040/* The tests assume a BTS with the following timeslot configuration:
41 * TS0 : Combined CCCH + SDCCH/4
Harald Welte3d04ae62018-04-04 20:29:05 +020042 * TS1 : TCH/F
43 * TS2 : TCH/F
44 * TS3 : TCH/F_PDCH (IPA Style)
45 * TS4 : TCH/F_TCH/H_PDCH (Osmocom Style)
Harald Welte70767382018-02-21 12:16:40 +010046 * TS5 : TCH/H
47 * TS6 : SDCCH/8
48 * TS7 : PDCH
49 */
50
51modulepar {
52 charstring mp_rsl_ip := "127.0.0.2";
53 integer mp_rsl_port := 3003;
54 integer mp_trx0_arfcn := 871;
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +070055 charstring mp_bts_trxc_ip := "127.0.0.1";
56 integer mp_bts_trxc_port := 5701;
Harald Welte883340c2018-02-28 18:59:29 +010057 charstring mp_pcu_socket := PCU_SOCK_DEFAULT;
Neels Hofmeyr6a84b232018-04-03 19:12:36 +020058 charstring mp_ctrl_ip := "127.0.0.1";
59 integer mp_ctrl_port := 4238;
Pau Espin Pedrol121724c2018-09-28 15:58:12 +020060 integer mp_tolerance_rxqual := 1;
61 integer mp_tolerance_rxlev := 3;
62 integer mp_tolerance_timing_offset_256syms := 0;
Pau Espin Pedrol752ffd52018-06-07 13:55:45 +020063 integer mp_rxlev_exp := 57;
Pau Espin Pedrole9571aa2018-10-22 17:13:07 +020064 integer mp_ul_rxlev_exp := 10;
Pau Espin Pedroled359cb2018-09-28 16:08:24 +020065 integer mp_ms_power_level_exp := 7;
Pau Espin Pedrol121724c2018-09-28 15:58:12 +020066 integer mp_ms_actual_ta_exp := 0;
67 integer mp_timing_offset_256syms_exp := 512;
Pau Espin Pedrol315e4712018-11-01 16:27:07 +010068 /* Time to wait for RSL conn from BTS during startup of test */
Philipp Maier12567e42019-04-17 14:10:05 +020069 float mp_ipa_up_timeout := 15.0;
Philipp Maiere63229e2019-04-26 12:21:37 +020070 float mp_ipa_up_delay := 0.0;
Harald Welte70767382018-02-21 12:16:40 +010071}
72
Harald Welte629cc6b2018-03-11 17:19:05 +010073type record of RslChannelNr ChannelNrs;
74
Harald Welte70767382018-02-21 12:16:40 +010075type component test_CT extends CTRL_Adapter_CT {
Harald Welte68e495b2018-02-25 00:05:57 +010076 /* IPA Emulation component underneath RSL */
Harald Welte70767382018-02-21 12:16:40 +010077 var IPA_Emulation_CT vc_IPA;
Harald Welte68e495b2018-02-25 00:05:57 +010078 /* RSL Emulation component (for ConnHdlr tests) */
Harald Welte70767382018-02-21 12:16:40 +010079 var RSL_Emulation_CT vc_RSL;
Harald Welte68e495b2018-02-25 00:05:57 +010080 /* Direct RSL_CCHAN_PT */
Harald Welte70767382018-02-21 12:16:40 +010081 port RSL_CCHAN_PT RSL_CCHAN;
Harald Welte68e495b2018-02-25 00:05:57 +010082
83 /* L1CTL port (for classic tests) */
84 port L1CTL_PT L1CTL;
Harald Welte48494ca2018-02-25 16:59:50 +010085
Harald Welte54a2a2d2018-02-26 09:14:05 +010086 /* TRXC port (for classic tests) */
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +070087 port TRXC_CODEC_PT BTS_TRXC;
88 var integer g_bts_trxc_conn_id;
Harald Welte54a2a2d2018-02-26 09:14:05 +010089
Harald Weltef50e3ae2018-09-10 10:27:56 +020090 /* VTY connections to both BTS and BSC */
Harald Welte8da48242018-02-27 20:41:32 +010091 port TELNETasp_PT BTSVTY;
Harald Weltef50e3ae2018-09-10 10:27:56 +020092 port TELNETasp_PT BSCVTY;
Harald Welte8da48242018-02-27 20:41:32 +010093
Harald Welte883340c2018-02-28 18:59:29 +010094 /* PCU Interface of BTS */
95 port PCUIF_CODEC_PT PCU;
96 var integer g_pcu_conn_id;
97 /* Last PCU INFO IND we received */
98 var PCUIF_Message g_pcu_last_info;
99
Harald Welte48494ca2018-02-25 16:59:50 +0100100 /* SI configuration */
101 var SystemInformationConfig si_cfg := {
102 bcch_extended := false,
103 si1_present := false,
104 si2bis_present := false,
105 si2ter_present := false,
106 si2quater_present := false,
107 si7_present := false,
108 si8_present := false,
109 si9_present := false,
110 si13_present := false,
111 si13alt_present := false,
112 si15_present := false,
113 si16_present := false,
114 si17_present := false,
115 si2n_present := false,
116 si21_present := false,
117 si22_present := false
118 };
Harald Welte629cc6b2018-03-11 17:19:05 +0100119
120 /* all logical channels available on the BTS */
121 var ChannelNrs g_AllChannels;
Harald Welte0472ab42018-03-12 15:02:26 +0100122 var ChannelNrs g_AllChanTypes;
Harald Welte70767382018-02-21 12:16:40 +0100123}
124
125/* an individual call / channel */
126type component ConnHdlr extends RSL_DchanHdlr {
127 port L1CTL_PT L1CTL;
128
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +0700129 port TRXC_CODEC_PT BTS_TRXC;
130 var integer g_bts_trxc_conn_id;
Harald Welte70767382018-02-21 12:16:40 +0100131
132 timer g_Tguard;
133 timer g_Tmeas_exp := 2.0; /* >= 103 SACCH multiframe ~ 500ms */
134
135 var ConnHdlrPars g_pars;
136 var uint8_t g_next_meas_res_nr := 0;
Harald Weltefa45e9e2018-03-10 18:59:03 +0100137 var boolean g_first_meas_res := true;
Harald Weltef26de0b2018-04-04 20:28:05 +0200138
139 /* PCU Interface of BTS */
140 port PCUIF_CODEC_PT PCU;
Harald Welte70767382018-02-21 12:16:40 +0100141}
142
143function f_init_rsl(charstring id) runs on test_CT {
144 vc_IPA := IPA_Emulation_CT.create(id & "-RSL-IPA");
145 vc_RSL := RSL_Emulation_CT.create(id & "-RSL");
146
147 map(vc_IPA:IPA_PORT, system:IPA_CODEC_PT);
148 connect(vc_IPA:IPA_RSL_PORT, vc_RSL:IPA_PT);
149 connect(self:RSL_CCHAN, vc_RSL:CCHAN_PT);
150
151 vc_IPA.start(IPA_Emulation.main_server(mp_rsl_ip, mp_rsl_port));
152 vc_RSL.start(RSL_Emulation.main(false));
153}
154
155type record ConnHdlrPars {
156 RslChannelNr chan_nr,
157 RSL_IE_ChannelMode chan_mode,
158 float t_guard,
Harald Welte0472ab42018-03-12 15:02:26 +0100159 ConnL1Pars l1_pars,
Harald Weltee613f962018-04-18 22:38:16 +0200160 TestSpecUnion spec optional,
161 RSL_IE_EncryptionInfo encr optional
Harald Welte0472ab42018-03-12 15:02:26 +0100162}
163
164/* Test-specific parameters */
165type union TestSpecUnion {
166 RllTestCase rll
Harald Welte70767382018-02-21 12:16:40 +0100167}
168
Harald Welte82ccef72018-02-25 16:17:33 +0100169template (value) RachControlParameters ts_RachCtrl_default := {
Harald Welte0fd1fb02018-03-10 17:19:50 +0100170 max_retrans := RACH_MAX_RETRANS_7,
171 tx_integer := '1001'B, /* 12 slots */
Harald Welte82ccef72018-02-25 16:17:33 +0100172 cell_barr_access := false,
173 re_not_allowed := true,
Harald Welteb9585f82018-03-10 17:18:47 +0100174 acc := '0000010000000000'B
Harald Welte82ccef72018-02-25 16:17:33 +0100175};
176
Harald Weltef10153f2018-02-25 16:34:05 +0100177template (value) CellSelectionParameters ts_CellSelPar_default := {
Harald Welte0fd1fb02018-03-10 17:19:50 +0100178 cell_resel_hyst_2dB := 2,
Pau Espin Pedroled359cb2018-09-28 16:08:24 +0200179 ms_txpwr_max_cch := mp_ms_power_level_exp,
Harald Weltef10153f2018-02-25 16:34:05 +0100180 acs := '0'B,
181 neci := true,
182 rxlev_access_min := 0
183}
184
185template (value) LocationAreaIdentification ts_LAI_default := {
186 mcc_mnc := '262F42'H,
187 lac := 42
188}
189
Harald Welte7484fc42018-02-24 14:09:45 +0100190/* Default SYSTEM INFORMATION 3 */
Harald Weltef8df4cb2018-03-10 15:15:08 +0100191template (value) SystemInformation ts_SI3_default := {
192 header := ts_RrHeader(SYSTEM_INFORMATION_TYPE_3, 18),
Harald Welte7484fc42018-02-24 14:09:45 +0100193 payload := {
194 si3 := {
195 cell_id := 23,
Harald Weltef10153f2018-02-25 16:34:05 +0100196 lai := ts_LAI_default,
Harald Welte7484fc42018-02-24 14:09:45 +0100197 ctrl_chan_desc := {
198 msc_r99 := true,
199 att := true,
200 bs_ag_blks_res := 1,
201 ccch_conf := CCHAN_DESC_1CCCH_COMBINED,
Harald Welte82ccef72018-02-25 16:17:33 +0100202 si22ind := false,
Harald Welte7484fc42018-02-24 14:09:45 +0100203 cbq3 := CBQ3_IU_MODE_NOT_SUPPORTED,
204 spare := '00'B,
205 bs_pa_mfrms := 0, /* 2 multiframes */
206 t3212 := 1 /* 6 minutes */
207 },
Harald Welte82ccef72018-02-25 16:17:33 +0100208 cell_options := {
Harald Welte7484fc42018-02-24 14:09:45 +0100209 dn_ind := false,
210 pwrc := false,
211 dtx := MS_MAY_USE_UL_DTX,
Harald Welte0fd1fb02018-03-10 17:19:50 +0100212 radio_link_tout_div4 := (32/4)-1
Harald Welte7484fc42018-02-24 14:09:45 +0100213 },
Harald Weltef10153f2018-02-25 16:34:05 +0100214 cell_sel_par := ts_CellSelPar_default,
Harald Welte82ccef72018-02-25 16:17:33 +0100215 rach_control := ts_RachCtrl_default,
Harald Welte3778acc2018-03-09 19:32:31 +0100216 rest_octets := '2B2B2B2B'O
Harald Welte7484fc42018-02-24 14:09:45 +0100217 }
218 }
219}
Harald Welte70767382018-02-21 12:16:40 +0100220
Harald Weltef8df4cb2018-03-10 15:15:08 +0100221template (value) SystemInformation ts_SI2_default := {
222 header := ts_RrHeader(SYSTEM_INFORMATION_TYPE_2, 22),
Harald Weltef10153f2018-02-25 16:34:05 +0100223 payload := {
224 si2 := {
225 bcch_freq_list := '00000000000000000000000000000000'O,
226 ncc_permitted := '11111111'B,
227 rach_control := ts_RachCtrl_default
228 }
229 }
230}
231
Harald Weltef8df4cb2018-03-10 15:15:08 +0100232template (value) SystemInformation ts_SI4_default := {
233 header := ts_RrHeader(SYSTEM_INFORMATION_TYPE_4, 12), /* no CBCH / restoct */
Harald Weltef10153f2018-02-25 16:34:05 +0100234 payload := {
235 si4 := {
236 lai := ts_LAI_default,
237 cell_sel_par := ts_CellSelPar_default,
238 rach_control := ts_RachCtrl_default,
239 cbch_chan_desc := omit,
240 cbch_mobile_alloc := omit,
241 rest_octets := ''O
242 }
243 }
244}
245
246function f_rsl_bcch_fill_raw(RSL_IE_SysinfoType rsl_si_type, octetstring si_enc)
247runs on test_CT {
248 log("Setting ", rsl_si_type, ": ", si_enc);
249 RSL_CCHAN.send(ts_RSL_UD(ts_RSL_BCCH_INFO(rsl_si_type, si_enc)));
250}
251
252function f_rsl_bcch_fill(RSL_IE_SysinfoType rsl_si_type, template (value) SystemInformation si_dec)
253runs on test_CT {
254 var octetstring si_enc := enc_SystemInformation(valueof(si_dec));
255 log("Setting ", rsl_si_type, ": ", si_dec);
256 f_rsl_bcch_fill_raw(rsl_si_type, si_enc);
257}
258
Harald Welte505cf9b2018-09-15 17:47:23 +0300259friend function f_init_vty(charstring id) runs on test_CT {
Harald Welte8da48242018-02-27 20:41:32 +0100260 map(self:BTSVTY, system:BTSVTY);
261 f_vty_set_prompts(BTSVTY);
262 f_vty_transceive(BTSVTY, "enable");
263}
264
Harald Welte505cf9b2018-09-15 17:47:23 +0300265friend function f_init_vty_bsc() runs on test_CT {
Harald Weltef50e3ae2018-09-10 10:27:56 +0200266 map(self:BSCVTY, system:BSCVTY);
267 f_vty_set_prompts(BSCVTY, "OsmoBSC");
268 f_vty_transceive(BSCVTY, "enable");
269}
270
Harald Welte883340c2018-02-28 18:59:29 +0100271/* PCU socket may at any time receive a new INFO.ind */
Harald Weltef26de0b2018-04-04 20:28:05 +0200272private altstep as_pcu_info_ind(PCUIF_CODEC_PT pt, integer pcu_conn_id,
273 out PCUIF_Message pcu_last_info) {
Harald Welte883340c2018-02-28 18:59:29 +0100274 var PCUIF_send_data sd;
Harald Weltef26de0b2018-04-04 20:28:05 +0200275 [] pt.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(0, ?))) -> value sd {
276 pcu_last_info := sd.data;
Harald Welted378a252018-03-13 17:02:14 +0100277 }
Harald Weltef26de0b2018-04-04 20:28:05 +0200278 [] pt.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(?, ?, ?))) -> value sd {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200279 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Invalid PCU Version/BTS Number received");
Harald Welte883340c2018-02-28 18:59:29 +0100280 }
281}
282
Harald Weltef26de0b2018-04-04 20:28:05 +0200283private function f_init_pcu(PCUIF_CODEC_PT pt, charstring id,
284 out integer pcu_conn_id, out PCUIF_Message pcu_last_info) {
Harald Welte883340c2018-02-28 18:59:29 +0100285 timer T := 2.0;
286 var PCUIF_send_data sd;
Harald Welte84271622018-03-10 17:21:03 +0100287 if (mp_pcu_socket == "") {
Harald Weltef26de0b2018-04-04 20:28:05 +0200288 pcu_conn_id := -1;
Harald Welte84271622018-03-10 17:21:03 +0100289 return;
290 }
Harald Weltef26de0b2018-04-04 20:28:05 +0200291 pcu_conn_id := f_pcuif_connect(pt, mp_pcu_socket);
Harald Welte883340c2018-02-28 18:59:29 +0100292
293 T.start;
294 alt {
Harald Weltef26de0b2018-04-04 20:28:05 +0200295 [] as_pcu_info_ind(pt, pcu_conn_id, pcu_last_info);
Harald Welte883340c2018-02-28 18:59:29 +0100296 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200297 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PCU INFO_IND");
Harald Welte883340c2018-02-28 18:59:29 +0100298 }
299 }
300}
301
Harald Welte70767382018-02-21 12:16:40 +0100302/* global init function */
Harald Welte68e495b2018-02-25 00:05:57 +0100303function f_init(charstring id := "BTS-Test") runs on test_CT {
Pau Espin Pedrol315e4712018-11-01 16:27:07 +0100304 timer T := mp_ipa_up_timeout;
Harald Welte629cc6b2018-03-11 17:19:05 +0100305 g_AllChannels := {
306 /* TS 1..4: TCH/F */
307 valueof(ts_RslChanNr_Bm(1)), valueof(ts_RslChanNr_Bm(2)),
308 valueof(ts_RslChanNr_Bm(3)), valueof(ts_RslChanNr_Bm(4)),
309 /* TS 5: TCH/H */
310 valueof(ts_RslChanNr_Lm(5,0)), valueof(ts_RslChanNr_Lm(5,1)),
311 /* TS 0: SDCCH/4 */
312 valueof(ts_RslChanNr_SDCCH4(0,0)), valueof(ts_RslChanNr_SDCCH4(0,1)),
313 valueof(ts_RslChanNr_SDCCH4(0,2)), valueof(ts_RslChanNr_SDCCH4(0,3)),
314 /* TS 6: SDCCH/8 */
315 valueof(ts_RslChanNr_SDCCH8(6,0)), valueof(ts_RslChanNr_SDCCH8(6,1)),
316 valueof(ts_RslChanNr_SDCCH8(6,2)), valueof(ts_RslChanNr_SDCCH8(6,3)),
317 valueof(ts_RslChanNr_SDCCH8(6,4)), valueof(ts_RslChanNr_SDCCH8(6,5)),
318 valueof(ts_RslChanNr_SDCCH8(6,6)), valueof(ts_RslChanNr_SDCCH8(6,7))
319 };
320
Pau Espin Pedrol3dcf38f2018-10-22 14:07:54 +0200321 /* FIXME: FACCH/H is unreliable with calypso firmware, see OS#3653 */
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +0700322 if (mp_bts_trxc_port != -1) {
Pau Espin Pedrol3dcf38f2018-10-22 14:07:54 +0200323 g_AllChanTypes := {
324 /* TS 1..4: TCH/F */
325 valueof(ts_RslChanNr_Bm(1)),
326 /* TS 5: TCH/H */
327 valueof(ts_RslChanNr_Lm(5,1)),
328 /* TS 0: SDCCH/4 */
329 valueof(ts_RslChanNr_SDCCH4(0,2)),
330 /* TS 6: SDCCH/8 */
331 valueof(ts_RslChanNr_SDCCH8(6,4))
332 };
333 } else {
334 g_AllChanTypes := {
335 /* TS 1..4: TCH/F */
336 valueof(ts_RslChanNr_Bm(1)),
337 /* TS 0: SDCCH/4 */
338 valueof(ts_RslChanNr_SDCCH4(0,2)),
339 /* TS 6: SDCCH/8 */
340 valueof(ts_RslChanNr_SDCCH8(6,4))
341 };
342 }
Harald Welte70767382018-02-21 12:16:40 +0100343 f_init_rsl(id);
Harald Welte83f6dbf2018-06-03 18:26:50 +0200344 T.start;
345 alt {
346 [] RSL_CCHAN.receive(ASP_IPA_Event:{up_down := ASP_IPA_EVENT_UP});
347 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200348 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for ASP_IPA_EVENT_UP");
Harald Welte83f6dbf2018-06-03 18:26:50 +0200349 }
350 }
Harald Welte2d142592018-02-25 13:19:44 +0100351 f_sleep(0.5); /* workaround for OS#3000 */
Harald Welte8da48242018-02-27 20:41:32 +0100352 f_init_vty(id);
Neels Hofmeyr6a84b232018-04-03 19:12:36 +0200353 f_ipa_ctrl_start(mp_ctrl_ip, mp_ctrl_port);
Harald Welte7484fc42018-02-24 14:09:45 +0100354
355 /* Send SI3 to the BTS, it is needed for various computations */
Harald Weltef10153f2018-02-25 16:34:05 +0100356 f_rsl_bcch_fill(RSL_SYSTEM_INFO_3, ts_SI3_default);
357 /* SI2 + SI4 are required for SI testing as they are mandatory defaults */
358 f_rsl_bcch_fill(RSL_SYSTEM_INFO_2, ts_SI2_default);
359 f_rsl_bcch_fill(RSL_SYSTEM_INFO_4, ts_SI4_default);
Harald Welte57fe8232018-02-26 17:52:50 +0100360
Harald Weltef26de0b2018-04-04 20:28:05 +0200361 map(self:PCU, system:PCU);
362 f_init_pcu(PCU, id, g_pcu_conn_id, g_pcu_last_info);
Harald Welte883340c2018-02-28 18:59:29 +0100363
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +0700364 if (mp_bts_trxc_port != -1) {
Harald Welte84271622018-03-10 17:21:03 +0100365 var TrxcMessage ret;
366 /* start with a default moderate timing offset equalling TA=2 */
367 f_main_trxc_connect();
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +0700368 ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, valueof(ts_TRXC_FAKE_TIMING(2*256)));
Harald Welte84271622018-03-10 17:21:03 +0100369 }
Philipp Maierd95f3402019-04-18 17:50:52 +0200370
371 /* Wait some extra time to make sure the BTS emits a stable carrier.
372 * (this is only relevant when running the tests with a physical BTS.) */
373 f_sleep(mp_ipa_up_delay);
Harald Welte70767382018-02-21 12:16:40 +0100374}
375
Harald Welte68e495b2018-02-25 00:05:57 +0100376/* Attach L1CTL to master test_CT (classic tests, non-handler mode) */
377function f_init_l1ctl() runs on test_CT {
378 map(self:L1CTL, system:L1CTL);
379 f_connect_reset(L1CTL);
380}
381
Harald Welte70767382018-02-21 12:16:40 +0100382type function void_fn(charstring id) runs on ConnHdlr;
383
384/* create a new test component */
Harald Weltef26de0b2018-04-04 20:28:05 +0200385function f_start_handler(void_fn fn, ConnHdlrPars pars, boolean pcu_comp := false)
Harald Welte70767382018-02-21 12:16:40 +0100386runs on test_CT return ConnHdlr {
387 var charstring id := testcasename();
388 var ConnHdlr vc_conn;
389
390 vc_conn := ConnHdlr.create(id);
391 /* connect to RSL Emulation main component */
392 connect(vc_conn:RSL, vc_RSL:CLIENT_PT);
393 connect(vc_conn:RSL_PROC, vc_RSL:RSL_PROC);
Harald Weltef26de0b2018-04-04 20:28:05 +0200394 if (pcu_comp) {
395 /* the ConnHdlr component wants to talk directly to the PCU, so disconnect
396 * it from the test_CT and connect it to the component. This obviously only
397 * works for one component, i.e. no concurrency */
398 unmap(self:PCU, system:PCU);
399 map(vc_conn:PCU, system:PCU);
400 }
Harald Welte70767382018-02-21 12:16:40 +0100401
402 vc_conn.start(f_handler_init(fn, id, pars));
403 return vc_conn;
404}
405
Harald Welte7484fc42018-02-24 14:09:45 +0100406template ASP_RSL_Unitdata ts_RSL_UD(template RSL_Message rsl, IpaStreamId sid := IPAC_PROTO_RSL_TRX0) := {
407 streamId := sid,
408 rsl := rsl
409}
410
411template ASP_RSL_Unitdata tr_RSL_UD(template RSL_Message rsl,
412 template IpaStreamId sid := IPAC_PROTO_RSL_TRX0) := {
413 streamId := sid,
414 rsl := rsl
415}
416
Harald Welte70767382018-02-21 12:16:40 +0100417private altstep as_Tguard() runs on ConnHdlr {
418 [] g_Tguard.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200419 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Tguard timeout");
Harald Welte70767382018-02-21 12:16:40 +0100420 }
421}
422
Harald Welte505cf9b2018-09-15 17:47:23 +0300423friend function f_l1_tune(L1CTL_PT L1CTL) {
Pau Espin Pedrol752ffd52018-06-07 13:55:45 +0200424 f_L1CTL_FBSB(L1CTL, { false, mp_trx0_arfcn }, CCCH_MODE_COMBINED, mp_rxlev_exp);
Harald Welte70767382018-02-21 12:16:40 +0100425}
426
427private function f_trxc_connect() runs on ConnHdlr {
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +0700428 map(self:BTS_TRXC, system:BTS_TRXC);
Harald Welte70767382018-02-21 12:16:40 +0100429 var Result res;
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +0700430 res := TRXC_CodecPort_CtrlFunct.f_IPL4_connect(BTS_TRXC, mp_bts_trxc_ip, mp_bts_trxc_port,
Harald Weltea4d8f352018-03-01 15:47:20 +0100431 "", -1, -1, {udp:={}}, {});
Harald Welte9220f632018-05-23 20:27:02 +0200432 if (not ispresent(res.connId)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200433 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Could not connect to trx-control interface of trxcon, check your configuration");
Harald Welte9220f632018-05-23 20:27:02 +0200434 }
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +0700435 g_bts_trxc_conn_id := res.connId;
Harald Welte70767382018-02-21 12:16:40 +0100436}
437
438private function f_trxc_fake_rssi(uint8_t rssi) runs on ConnHdlr {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100439 var TrxcMessage ret;
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +0700440 ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, valueof(ts_TRXC_FAKE_RSSI(rssi)));
Harald Welte70767382018-02-21 12:16:40 +0100441}
442
443private function f_trx_fake_toffs256(int16_t toffs256) runs on ConnHdlr {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100444 var TrxcMessage ret;
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +0700445 ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, valueof(ts_TRXC_FAKE_TIMING(toffs256)));
Harald Welte70767382018-02-21 12:16:40 +0100446}
447
448/* first function started in ConnHdlr component */
449private function f_handler_init(void_fn fn, charstring id, ConnHdlrPars pars)
450runs on ConnHdlr {
451 g_pars := pars;
452 g_chan_nr := pars.chan_nr;
453
454 map(self:L1CTL, system:L1CTL);
455 f_connect_reset(L1CTL);
456
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +0700457 if (mp_bts_trxc_port != -1) {
Harald Welte84271622018-03-10 17:21:03 +0100458 f_trxc_connect();
459 }
Harald Welte70767382018-02-21 12:16:40 +0100460
461 g_Tguard.start(pars.t_guard);
462 activate(as_Tguard());
463
464 f_rslem_register(0, pars.chan_nr);
465
466 /* call the user-supplied test case function */
467 fn.apply(id);
468}
469
Harald Welteb1726c92018-03-30 11:56:38 +0200470function f_rsl_transceive_ret(template RSL_Message tx, template RSL_Message exp_rx, charstring id,
471 boolean ignore_other := false)
472runs on ConnHdlr return RSL_Message {
473 var RSL_Message rx;
Harald Welte1eba3742018-02-25 12:48:14 +0100474 timer T := 3.0;
475 RSL.send(tx);
476 T.start;
Harald Welte70767382018-02-21 12:16:40 +0100477 alt {
Harald Welteb1726c92018-03-30 11:56:38 +0200478 [] RSL.receive(exp_rx) -> value rx {
Harald Welte1eba3742018-02-25 12:48:14 +0100479 T.stop;
480 setverdict(pass);
Harald Welte70767382018-02-21 12:16:40 +0100481 }
Harald Welte1eba3742018-02-25 12:48:14 +0100482 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200483 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout expecting " & id);
Harald Welte1eba3742018-02-25 12:48:14 +0100484 }
Harald Welte21240e62018-03-11 21:43:35 +0100485 [not ignore_other] as_l1_sacch();
486 [not ignore_other] as_meas_res();
487 [not ignore_other] as_l1_dcch();
488 [not ignore_other] RSL.receive {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200489 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RSL message received");
Harald Welte70767382018-02-21 12:16:40 +0100490 }
Harald Welte21240e62018-03-11 21:43:35 +0100491 [ignore_other] RSL.receive { repeat; }
Harald Welte70767382018-02-21 12:16:40 +0100492 }
Harald Welteb1726c92018-03-30 11:56:38 +0200493 return rx;
494}
495
496function f_rsl_transceive(template RSL_Message tx, template RSL_Message exp_rx, charstring id,
497 boolean ignore_other := false)
498runs on ConnHdlr {
499 var RSL_Message rx := f_rsl_transceive_ret(tx, exp_rx, id, ignore_other);
Harald Welte70767382018-02-21 12:16:40 +0100500}
501
Harald Welte8b01c792019-05-19 22:51:25 +0200502function f_rsl_chan_act(RSL_IE_ChannelMode mode, boolean encr_enable := false, RSL_IE_List more_ies := {},
503 RSL_IE_ActivationType act_type := t_RSL_IE_ActType_IA) runs on ConnHdlr {
504 var RSL_Message ch_act := valueof(ts_RSL_CHAN_ACT(g_chan_nr, mode, act_type));
Harald Weltee613f962018-04-18 22:38:16 +0200505 if (encr_enable) {
506 /* append encryption related IEs, if requested */
507 var RSL_IE_EncryptionInfo encr_info;
508 encr_info := valueof(ts_RSL_IE_EncrInfo(g_pars.encr.alg_id, g_pars.encr.key));
509 ch_act.ies := ch_act.ies & { valueof(t_RSL_IE(RSL_IE_ENCR_INFO, RSL_IE_Body:{encr_info :=
510encr_info})) };
511 }
Harald Weltec8d363c2019-05-19 20:36:48 +0200512 ch_act.ies := ch_act.ies & more_ies;
Harald Weltee613f962018-04-18 22:38:16 +0200513 f_rsl_transceive(ch_act, tr_RSL_CHAN_ACT_ACK(g_chan_nr), "RSL CHAN ACT");
Harald Welte1eba3742018-02-25 12:48:14 +0100514}
515
Harald Welte70767382018-02-21 12:16:40 +0100516function f_rsl_chan_deact() runs on ConnHdlr {
Harald Welte1eba3742018-02-25 12:48:14 +0100517 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 +0100518 "RF CHAN REL", true);
Harald Welte70767382018-02-21 12:16:40 +0100519}
520
Harald Welte70767382018-02-21 12:16:40 +0100521private template ConnHdlrPars t_Pars(template RslChannelNr chan_nr,
522 template RSL_IE_ChannelMode chan_mode,
523 float t_guard := 20.0) := {
524 chan_nr := valueof(chan_nr),
525 chan_mode := valueof(chan_mode),
526 t_guard := t_guard,
527 l1_pars := {
528 dtx_enabled := false,
Harald Welte685d5982018-02-27 20:42:05 +0100529 toa256_enabled := false,
Harald Welte70767382018-02-21 12:16:40 +0100530 meas_ul := {
531 full := {
Pau Espin Pedrole9571aa2018-10-22 17:13:07 +0200532 rxlev := mp_ul_rxlev_exp,
Harald Welte70767382018-02-21 12:16:40 +0100533 rxqual := 0
534 },
535 sub := {
Pau Espin Pedrole9571aa2018-10-22 17:13:07 +0200536 rxlev := mp_ul_rxlev_exp,
Harald Welte70767382018-02-21 12:16:40 +0100537 rxqual := 0
538 }
539 },
Pau Espin Pedrol121724c2018-09-28 15:58:12 +0200540 timing_offset_256syms := mp_timing_offset_256syms_exp,
Harald Welte70767382018-02-21 12:16:40 +0100541 bs_power_level := 0,
Pau Espin Pedroled359cb2018-09-28 16:08:24 +0200542 ms_power_level := mp_ms_power_level_exp,
Pau Espin Pedrol121724c2018-09-28 15:58:12 +0200543 ms_actual_ta := mp_ms_actual_ta_exp
Harald Welte0472ab42018-03-12 15:02:26 +0100544 },
Harald Weltee613f962018-04-18 22:38:16 +0200545 spec := omit,
546 encr := omit
Harald Welte70767382018-02-21 12:16:40 +0100547}
548
Harald Welte93640c62018-02-25 16:59:33 +0100549/***********************************************************************
550 * Channel Activation / Deactivation
551 ***********************************************************************/
552
Harald Welte70767382018-02-21 12:16:40 +0100553/* Stress test: Do 500 channel activations/deactivations in rapid succession */
554function f_TC_chan_act_stress(charstring id) runs on ConnHdlr {
555 for (var integer i := 0; i < 500; i := i+1) {
556 f_rsl_chan_act(g_pars.chan_mode);
557 f_rsl_chan_deact();
558 }
559 setverdict(pass);
560}
561testcase TC_chan_act_stress() runs on test_CT {
562 var ConnHdlr vc_conn;
563 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
564 f_init(testcasename());
565 vc_conn := f_start_handler(refers(f_TC_chan_act_stress), pars);
566 vc_conn.done;
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200567 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +0100568}
569
570/* Test if re-activation of an already active channel fails as expected */
571function f_TC_chan_act_react(charstring id) runs on ConnHdlr {
572 f_rsl_chan_act(g_pars.chan_mode);
573 /* attempt to activate the same lchan again -> expect reject */
574 RSL.send(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode));
575 alt {
576 [] RSL.receive(tr_RSL_CHAN_ACT_ACK(g_chan_nr)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200577 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected CHAN ACT ACK on double activation");
Harald Welte70767382018-02-21 12:16:40 +0100578 }
579 [] RSL.receive(tr_RSL_CHAN_ACT_NACK(g_chan_nr)) {
580 setverdict(pass);
581 }
582 }
583 f_rsl_chan_deact();
584}
585testcase TC_chan_act_react() runs on test_CT {
586 var ConnHdlr vc_conn;
587 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
Harald Welte294b0a22018-03-10 23:26:48 +0100588 f_init();
Harald Welte70767382018-02-21 12:16:40 +0100589 vc_conn := f_start_handler(refers(f_TC_chan_act_react), pars);
590 vc_conn.done;
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200591 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +0100592}
593
594/* Attempt to de-activate a channel that's not active */
595function f_TC_chan_deact_not_active(charstring id) runs on ConnHdlr {
596 timer T := 3.0;
597 RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr));
598 T.start;
599 alt {
600 [] RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr)) {
601 setverdict(pass);
602 }
603 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200604 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout expecting RF_CHAN_REL_ACK");
Harald Welte70767382018-02-21 12:16:40 +0100605 }
606 }
607}
608testcase TC_chan_deact_not_active() runs on test_CT {
609 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
Harald Welte294b0a22018-03-10 23:26:48 +0100610 f_init();
Harald Welte70767382018-02-21 12:16:40 +0100611 var ConnHdlr vc_conn := f_start_handler(refers(f_TC_chan_deact_not_active), pars);
612 vc_conn.done;
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200613 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +0100614}
615
616/* attempt to activate channel with wrong RSL Channel Nr IE; expect NACK */
617function f_TC_chan_act_wrong_nr(charstring id) runs on ConnHdlr {
618 RSL.send(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode));
619 alt {
620 [] RSL.receive(tr_RSL_CHAN_ACT_ACK(g_chan_nr)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200621 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected CHAN ACT ACK");
Harald Welte70767382018-02-21 12:16:40 +0100622 }
623 [] RSL.receive(tr_RSL_CHAN_ACT_NACK(g_chan_nr)) {
624 setverdict(pass);
625 }
626 }
627}
628private type record WrongChanNrCase {
629 RslChannelNr chan_nr,
630 charstring description
631}
632private type record of WrongChanNrCase WrongChanNrCases;
633private template WrongChanNrCase t_WCN(template RslChannelNr chan_nr, charstring desc) := {
634 chan_nr := chan_nr,
635 description := desc
636}
637
638testcase TC_chan_act_wrong_nr() runs on test_CT {
639 var ConnHdlr vc_conn;
640 var ConnHdlrPars pars;
641
Harald Welte294b0a22018-03-10 23:26:48 +0100642 f_init();
Harald Welte70767382018-02-21 12:16:40 +0100643
644 var WrongChanNrCases wrong := {
645 valueof(t_WCN(t_RslChanNr_RACH(0), "RACH is not a dedicated channel")),
646 valueof(t_WCN(t_RslChanNr_RACH(1), "RACH doesn't exist on timeslot")),
647 valueof(t_WCN(t_RslChanNr_BCCH(0), "BCCH is not a dedicated channel")),
648 valueof(t_WCN(t_RslChanNr_PCH_AGCH(0), "PCH/AGCH is not a dedicated channel")),
649 valueof(t_WCN(t_RslChanNr_Bm(0), "TS0 cannot be TCH/F")),
650 valueof(t_WCN(t_RslChanNr_Lm(0, 0), "TS0 cannot be TCH/H")),
651 valueof(t_WCN(t_RslChanNr_Lm(0, 1), "TS0 cannot be TCH/H")),
652 valueof(t_WCN(t_RslChanNr_PDCH(0), "TS0 cannot be PDCH")),
653 valueof(t_WCN(t_RslChanNr_SDCCH8(0, 0), "TS0 cannot be SDCCH/8")),
654 valueof(t_WCN(t_RslChanNr_SDCCH8(0, 7), "TS0 cannot be SDCCH/8")),
655 valueof(t_WCN(t_RslChanNr_SDCCH4(7, 0), "TS7 cannot be SDCCH/4")),
656 valueof(t_WCN(t_RslChanNr_SDCCH4(7, 3), "TS7 cannot be SDCCH/4")),
657 valueof(t_WCN(t_RslChanNr_Lm(1, 0), "TS1 cannot be TCH/H"))
658 };
659
660 for (var integer i := 0; i < sizeof(wrong); i := i+1) {
661 pars := valueof(t_Pars(wrong[i].chan_nr, ts_RSL_ChanMode_SIGN));
662 vc_conn := f_start_handler(refers(f_TC_chan_act_wrong_nr), pars);
663 vc_conn.done;
664 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200665 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +0100666}
667
Harald Weltee613f962018-04-18 22:38:16 +0200668/* execute the same callback function on a variety of logical channels */
669private function f_testmatrix_each_chan(ConnHdlrPars pars, void_fn fn) runs on test_CT {
670 var ConnHdlr vc_conn;
671 f_init(testcasename());
672
673 /* test on each of the channels we have */
674 for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i+1) {
675 pars.chan_nr := valueof(g_AllChanTypes[i]);
676
677 log(testcasename(), ": XXX Starting on ", g_AllChanTypes[i]);
678 vc_conn := f_start_handler(fn, pars);
679 vc_conn.done;
680 }
681
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200682 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Weltee613f962018-04-18 22:38:16 +0200683}
684
Harald Welte93640c62018-02-25 16:59:33 +0100685/***********************************************************************
Harald Welte629cc6b2018-03-11 17:19:05 +0100686 * SACCH handling
687 ***********************************************************************/
688
689private function f_exp_sacch(boolean exp) runs on ConnHdlr {
690 timer T_sacch := 3.0;
691 T_sacch.start;
692 alt {
693 [not exp] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200694 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received SACCH when not expecting it");
Harald Welte629cc6b2018-03-11 17:19:05 +0100695 }
696 [not exp] T_sacch.timeout {
697 setverdict(pass);
698 }
699 [exp] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) {
700 setverdict(pass);
701 }
702 [exp] T_sacch.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200703 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Timeout waiting for SACCH on ", g_chan_nr));
Harald Welte629cc6b2018-03-11 17:19:05 +0100704 }
705 [] L1CTL.receive { repeat; }
706 [] RSL.receive { repeat; }
707 }
708}
709
710/* Test if DEACTIVATE SACCH actualy deactivates its transmission (TS 48.058 4.6) */
711private function f_TC_deact_sacch(charstring id) runs on ConnHdlr {
712 f_l1_tune(L1CTL);
713 RSL.clear;
714
715 /* activate the logical channel */
716 f_est_dchan();
717 L1CTL.clear;
718
719 /* check that SACCH actually are received as expected */
720 f_exp_sacch(true);
721
722 /* deactivate SACCH on the logical channel */
723 RSL.send(ts_RSL_DEACT_SACCH(g_chan_nr));
724 f_sleep(1.0);
725 L1CTL.clear;
726
727 /* check that no SACCH are received anymore */
728 f_exp_sacch(false);
729
730 /* release the channel */
731 f_rsl_chan_deact();
732 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
733}
734testcase TC_deact_sacch() runs on test_CT {
735 var ConnHdlr vc_conn;
736 var ConnHdlrPars pars;
737 f_init();
738 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
739 //for (var integer i := 0; i < 1; i := i+1) {
740 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
741 log(testcasename(), ": Starting for ", g_AllChannels[i]);
742 vc_conn := f_start_handler(refers(f_TC_deact_sacch), pars);
743 vc_conn.done;
744 }
745 /* TODO: do the above in parallel, rather than sequentially? */
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200746 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte629cc6b2018-03-11 17:19:05 +0100747}
748
Harald Welte55700662018-03-12 13:15:43 +0100749/* verify that given SACCH payload is present */
Harald Welteea17b912018-03-11 22:29:31 +0100750private function f_sacch_present(template octetstring l3_exp) runs on ConnHdlr {
751 var L1ctlDlMessage dl;
752 /* check that the specified SI5 value is actually sent */
753 timer T_sacch := 3.0;
754 L1CTL.clear;
755 T_sacch.start;
756 alt {
757 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) -> value dl {
758 var octetstring l3 := substr(dl.payload.data_ind.payload, 4, 19);
759 if (match(l3, l3_exp)) {
760 setverdict(pass);
761 } else {
762 repeat;
763 }
764 }
765 [] L1CTL.receive { repeat; }
766 [] T_sacch.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200767 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Timeout waiting for SACCH ", l3_exp));
Harald Welteea17b912018-03-11 22:29:31 +0100768 }
769 }
770}
771
Harald Welte55700662018-03-12 13:15:43 +0100772/* verify that given SACCH payload is not present */
773private function f_sacch_missing(template octetstring l3_exp) runs on ConnHdlr {
774 var L1ctlDlMessage dl;
775 /* check that the specified SI5 value is actually sent */
776 timer T_sacch := 3.0;
777 L1CTL.clear;
778 T_sacch.start;
779 alt {
780 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) -> value dl {
781 var octetstring l3 := substr(dl.payload.data_ind.payload, 4, 19);
782 if (match(l3, l3_exp)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200783 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Received unexpected SACCH ", dl));
Harald Welte55700662018-03-12 13:15:43 +0100784 } else {
785 repeat;
786 }
787 }
788 [] L1CTL.receive { repeat; }
789 [] T_sacch.timeout {
790 setverdict(pass);
791 }
792 }
793}
794
Harald Welte629cc6b2018-03-11 17:19:05 +0100795/* Test for default SACCH FILL transmitted in DL SACCH (all channel types) */
Harald Welteea17b912018-03-11 22:29:31 +0100796private function f_TC_sacch_filling(charstring id) runs on ConnHdlr {
797 /* Set a known default SACCH filling for SI5 */
798 var octetstring si5 := f_rnd_octstring(19);
799 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5));
800
801 f_l1_tune(L1CTL);
802 RSL.clear;
803
804 /* activate the logical channel */
805 f_est_dchan();
806
807 /* check that the specified SI5 value is actually sent */
808 f_sacch_present(si5);
809
810 /* release the channel */
811 RSL.clear;
812 f_rsl_chan_deact();
813 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
814}
815testcase TC_sacch_filling() runs on test_CT {
816 var ConnHdlr vc_conn;
817 var ConnHdlrPars pars;
818 f_init();
819 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
820 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
821 log(testcasename(), ": Starting for ", g_AllChannels[i]);
822 vc_conn := f_start_handler(refers(f_TC_sacch_filling), pars);
823 vc_conn.done;
824 }
825 /* TODO: do the above in parallel, rather than sequentially? */
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200826 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welteea17b912018-03-11 22:29:31 +0100827}
828
Harald Welte629cc6b2018-03-11 17:19:05 +0100829/* Test for lchan-specific SACCH INFO MODIFY (TS 48.058 4.12) */
Harald Welteea17b912018-03-11 22:29:31 +0100830private function f_TC_sacch_info_mod(charstring id) runs on ConnHdlr {
831 /* Set a known default SACCH filling for SI5 */
832 var octetstring si5 := f_rnd_octstring(19);
833 var octetstring si5_diff := f_rnd_octstring(19);
834 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5));
835
836 f_l1_tune(L1CTL);
837 RSL.clear;
838
839 log("Activating channel, expecting standard SI5");
840 /* activate the logical channel */
841 f_est_dchan();
842 /* check that the specified SI5 value is actually sent */
843 f_sacch_present(si5);
844
845 /* set channel-specific different SI5 */
846 log("Setting channel specific SACCH INFO, expecting it");
847 RSL.send(ts_RSL_SACCH_INF_MOD(g_chan_nr, RSL_SYSTEM_INFO_5, si5_diff))
848 /* check that the specified lchan-specific value is now used */
849 f_sacch_present(si5_diff);
850
851 /* deactivate the channel and re-activate it, this should result in default SI5 */
852 log("De-activating and re-activating channel, expecting standard SI5");
853 f_rsl_chan_deact();
854 f_rsl_chan_act(valueof(ts_RSL_ChanMode_SIGN));
855 /* Verify that the TRX-wide default SACCH filling is present again */
856 f_sacch_present(si5);
857
858 /* release the channel */
859 RSL.clear;
860 f_rsl_chan_deact();
861 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
862}
863testcase TC_sacch_info_mod() runs on test_CT {
864 var ConnHdlr vc_conn;
865 var ConnHdlrPars pars;
866 f_init();
867 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
868 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
869 log(testcasename(), ": Starting for ", g_AllChannels[i]);
870 vc_conn := f_start_handler(refers(f_TC_sacch_info_mod), pars);
871 vc_conn.done;
872 }
873 /* TODO: do the above in parallel, rather than sequentially? */
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200874 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welteea17b912018-03-11 22:29:31 +0100875}
876
Harald Welte075d84c2018-03-12 13:07:24 +0100877/* Test SACCH scheduling of multiple different SI message types */
878private function f_TC_sacch_multi(charstring id) runs on ConnHdlr {
879 var octetstring si5 := f_rnd_octstring(19);
880 var octetstring si5bis := f_rnd_octstring(19);
881 var octetstring si5ter := f_rnd_octstring(19);
882 var octetstring si6 := f_rnd_octstring(19);
883
884 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5));
885 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5bis, si5bis));
886 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5ter, si5ter));
887 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, si6));
888
889 f_l1_tune(L1CTL);
890 RSL.clear;
891
892 /* activate the logical channel */
893 f_est_dchan();
894 L1CTL.clear;
895
896 /* check that SACCH actually are received as expected */
897 f_sacch_present(si5);
898 f_sacch_present(si5bis);
899 f_sacch_present(si5ter);
900 f_sacch_present(si6);
901
902 /* release the channel */
903 f_rsl_chan_deact();
904 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
905}
906testcase TC_sacch_multi() runs on test_CT {
907 var ConnHdlr vc_conn;
908 var ConnHdlrPars pars;
909 f_init();
910 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
911 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
912 log(testcasename(), ": Starting for ", g_AllChannels[i]);
913 vc_conn := f_start_handler(refers(f_TC_sacch_multi), pars);
914 vc_conn.done;
915 }
916 /* TODO: do the above in parallel, rather than sequentially? */
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200917 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte075d84c2018-03-12 13:07:24 +0100918}
919
Harald Welte55700662018-03-12 13:15:43 +0100920/* Test if SACH information is modified as expected */
921private function f_TC_sacch_multi_chg(charstring id) runs on ConnHdlr {
922 var octetstring si5 := f_rnd_octstring(19);
923 var octetstring si6 := f_rnd_octstring(19);
924
925 /* First, configure both SI5 and SI6 to be transmitted */
926 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5));
927 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, si6));
928
929 f_l1_tune(L1CTL);
930 RSL.clear;
931
932 /* activate the logical channel */
933 f_est_dchan();
934 L1CTL.clear;
935
936 /* check that SACCH actually are received as expected */
937 f_sacch_present(si5);
938 f_sacch_present(si6);
939
940 /* disable SI6 */
941 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, ''O));
942
943 /* check that SI5 is still transmitted */
944 f_sacch_present(si5);
945 /* check if SI6 is now gone */
946 f_sacch_missing(si6);
947
948 /* release the channel */
949 f_rsl_chan_deact();
950 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
951}
952testcase TC_sacch_multi_chg() runs on test_CT {
953 var ConnHdlr vc_conn;
954 var ConnHdlrPars pars;
955 f_init();
956 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
957 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
958 log(testcasename(), ": Starting for ", g_AllChannels[i]);
959 vc_conn := f_start_handler(refers(f_TC_sacch_multi_chg), pars);
960 vc_conn.done;
961 }
962 /* TODO: do the above in parallel, rather than sequentially? */
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200963 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte55700662018-03-12 13:15:43 +0100964}
965
Harald Weltec8d363c2019-05-19 20:36:48 +0200966/* Test for SACCH information present in RSL CHAN ACT (overrides FILLING) */
967private function f_TC_sacch_chan_act(charstring id) runs on ConnHdlr {
968 var octetstring si5 := f_rnd_octstring(19);
969 var octetstring si6 := f_rnd_octstring(19);
970 var octetstring si5_specific := f_rnd_octstring(19);
971 var octetstring si6_specific := f_rnd_octstring(19);
972
973 /* First, configure both SI5 and SI6 to be transmitted */
974 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5));
975 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, si6));
976
977 f_l1_tune(L1CTL);
978 RSL.clear;
979
980 /* activate channel with different SACCH filling */
981 var RSL_SacchInfo sacch_info := valueof(ts_RSL_SacchInfo({
982 ts_RSL_SacchInfoElem(RSL_SYSTEM_INFO_5, si5_specific),
983 ts_RSL_SacchInfoElem(RSL_SYSTEM_INFO_6, si6_specific)
984 }));
985 var RSL_IE_List addl_ies := { valueof(t_RSL_IE(RSL_IE_SACCH_INFO,
986 RSL_IE_Body:{sacch_info := sacch_info})) };
987 f_est_dchan(more_ies := addl_ies);
988
989 /* check that SACCH actually are received as expected */
990 f_sacch_present(si5_specific);
991 f_sacch_present(si6_specific);
992
993 /* release the channel */
994 f_rsl_chan_deact();
995 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
996}
997testcase TC_sacch_chan_act() runs on test_CT {
998 var ConnHdlr vc_conn;
999 var ConnHdlrPars pars;
1000 f_init();
1001
1002 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
1003 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
1004 log(testcasename(), ": Starting for ", g_AllChannels[i]);
1005 vc_conn := f_start_handler(refers(f_TC_sacch_chan_act), pars);
1006 vc_conn.done;
1007 }
1008 /* TODO: do the above in parallel, rather than sequentially? */
1009 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
1010}
1011
Harald Welte8b01c792019-05-19 22:51:25 +02001012/* verify that SACCH DL transmission is started only if MS power IE present
1013 * see section 4.1.3 of 3GPP TS 48.058 */
1014private function f_TC_sacch_chan_act_ho_async(charstring id) runs on ConnHdlr {
1015 var octetstring si5 := f_rnd_octstring(19);
1016
1017 f_l1_tune(L1CTL);
1018 RSL.clear;
1019
1020 /* Step 1: Activate ASYNC HO channel without MS power IE */
1021
1022 /* Activate channel on BTS side */
1023 f_rsl_chan_act(g_pars.chan_mode, act_type := t_RSL_IE_ActType_HO_ASYNC);
1024 /* don't perform immediate assignment here, as we're testing non-IA case */
1025 /* enable dedicated mode */
1026 f_L1CTL_DM_EST_REQ(L1CTL, {false, mp_trx0_arfcn }, g_pars.chan_nr, 7);
1027
1028 /* Verify that no DL SACCH is being received */
1029 f_sacch_missing(?);
1030
1031 f_rsl_chan_deact();
1032 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1033
1034
1035 /* Step 2: Activate ASYNC HO channel with MS power IE */
1036
1037 /* Activate channel on BTS side */
1038 var RSL_IE_List addl_ies := {
1039 valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(0)}))
1040 };
1041 f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_ASYNC);
1042 /* don't perform immediate assignment here, as we're testing non-IA case */
1043 /* enable dedicated mode */
1044 f_L1CTL_DM_EST_REQ(L1CTL, {false, mp_trx0_arfcn }, g_pars.chan_nr, 7);
1045
1046 /* Verify that DL SACCH is being received */
1047 f_sacch_present(si5);
1048
1049 f_rsl_chan_deact();
1050 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1051}
1052testcase TC_sacch_chan_act_ho_async() runs on test_CT {
1053 var ConnHdlr vc_conn;
1054 var ConnHdlrPars pars;
1055 f_init();
1056
1057 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
1058 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
1059 log(testcasename(), ": Starting for ", g_AllChannels[i]);
1060 vc_conn := f_start_handler(refers(f_TC_sacch_chan_act_ho_async), pars);
1061 vc_conn.done;
1062 }
1063 /* TODO: do the above in parallel, rather than sequentially? */
1064 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
1065}
1066
1067/* verify that SACCH DL transmission is started only if TA + MS power IEs present,
1068 * see section 4.1.4 of 3GPP TS 48.058 */
1069private function f_TC_sacch_chan_act_ho_sync(charstring id) runs on ConnHdlr {
1070 var octetstring si5 := f_rnd_octstring(19);
1071 var RSL_IE_List addl_ies;
1072
1073 f_l1_tune(L1CTL);
1074 RSL.clear;
1075
1076 /* Step 1: Activate SYNC HO channel without MS power IE */
1077
1078 /* Activate channel on BTS side */
1079 f_rsl_chan_act(g_pars.chan_mode, act_type := t_RSL_IE_ActType_HO_SYNC);
1080 /* don't perform immediate assignment here, as we're testing non-IA case */
1081 /* enable dedicated mode */
1082 f_L1CTL_DM_EST_REQ(L1CTL, {false, mp_trx0_arfcn }, g_pars.chan_nr, 7);
1083
1084 /* Verify that no DL SACCH is being received */
1085 f_sacch_missing(?);
1086
1087 f_rsl_chan_deact();
1088 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1089
1090
1091 /* Step 2a: Activate SYNC HO channel with only MS power IE */
1092
1093 /* Activate channel on BTS side */
1094 addl_ies := {
1095 valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(0)}))
1096 };
1097 f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_SYNC);
1098 /* don't perform immediate assignment here, as we're testing non-IA case */
1099 /* enable dedicated mode */
1100 f_L1CTL_DM_EST_REQ(L1CTL, {false, mp_trx0_arfcn }, g_pars.chan_nr, 7);
1101
1102 /* Verify that no DL SACCH is being received */
1103 f_sacch_missing(?);
1104
1105 f_rsl_chan_deact();
1106 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1107
1108
1109 /* Step 2b: Activate SYNC HO channel with TA IE */
1110
1111 /* Activate channel on BTS side */
1112 addl_ies := {
1113 valueof(t_RSL_IE(RSL_IE_TIMING_ADVANCE, RSL_IE_Body:{timing_adv := 0}))
1114 };
1115 f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_SYNC);
1116 /* don't perform immediate assignment here, as we're testing non-IA case */
1117 /* enable dedicated mode */
1118 f_L1CTL_DM_EST_REQ(L1CTL, {false, mp_trx0_arfcn }, g_pars.chan_nr, 7);
1119
1120 /* Verify that no DL SACCH is being received */
1121 f_sacch_missing(?);
1122
1123 f_rsl_chan_deact();
1124 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1125
1126
1127 /* Step 3: Activate SYNC HO channel with MS power IE and TA IE */
1128
1129 /* Activate channel on BTS side */
1130 addl_ies := {
1131 valueof(t_RSL_IE(RSL_IE_TIMING_ADVANCE, RSL_IE_Body:{timing_adv := 0})),
1132 valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(0)}))
1133 };
1134 f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_SYNC);
1135 /* don't perform immediate assignment here, as we're testing non-IA case */
1136 /* enable dedicated mode */
1137 f_L1CTL_DM_EST_REQ(L1CTL, {false, mp_trx0_arfcn }, g_pars.chan_nr, 7);
1138
1139 /* Verify that DL SACCH is being received */
1140 f_sacch_present(si5);
1141
1142 f_rsl_chan_deact();
1143 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1144}
1145testcase TC_sacch_chan_act_ho_sync() runs on test_CT {
1146 var ConnHdlr vc_conn;
1147 var ConnHdlrPars pars;
1148 f_init();
1149
1150 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
1151 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
1152 log(testcasename(), ": Starting for ", g_AllChannels[i]);
1153 vc_conn := f_start_handler(refers(f_TC_sacch_chan_act_ho_sync), pars);
1154 vc_conn.done;
1155 }
1156 /* TODO: do the above in parallel, rather than sequentially? */
1157 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
1158}
Harald Welte629cc6b2018-03-11 17:19:05 +01001159
1160
1161/***********************************************************************
Harald Welte93640c62018-02-25 16:59:33 +01001162 * RACH Handling
1163 ***********************************************************************/
1164
Harald Welte8c24c2b2018-02-26 08:31:31 +01001165/* like L1SAP_IS_PACKET_RACH */
1166private function ra_is_ps(OCT1 ra) return boolean {
Harald Welte56c05802018-02-28 21:39:35 +01001167 if ((ra and4b 'F0'O == '70'O) and (ra and4b '0F'O != '0F'O)) {
Harald Welte8c24c2b2018-02-26 08:31:31 +01001168 return true;
1169 }
1170 return false;
1171}
1172
1173/* generate a random RACH for circuit-switched */
1174private function f_rnd_ra_cs() return OCT1 {
1175 var OCT1 ra;
1176 do {
1177 ra := f_rnd_octstring(1);
1178 } while (ra_is_ps(ra));
1179 return ra;
1180}
1181
Harald Welte883340c2018-02-28 18:59:29 +01001182/* generate a random RACH for packet-switched */
1183private function f_rnd_ra_ps() return OCT1 {
1184 var OCT1 ra;
1185 do {
1186 ra := f_rnd_octstring(1);
1187 } while (not ra_is_ps(ra));
1188 return ra;
1189}
1190
Vadim Yanitskiy51cbc102019-04-22 06:37:30 +07001191/* generate a random 11-bit RA (packet-switched only) */
1192private function f_rnd_ra11_ps() return BIT11 {
1193 var integer ra11 := f_rnd_int(bit2int('11111111111'B));
1194 return int2bit(ra11, 11);
1195}
1196
Harald Welte8c24c2b2018-02-26 08:31:31 +01001197/* Send 1000 RACH requests and check their RA+FN on the RSL side */
1198testcase TC_rach_content() runs on test_CT {
1199 f_init(testcasename());
1200 f_init_l1ctl();
Harald Welte68e495b2018-02-25 00:05:57 +01001201 f_l1_tune(L1CTL);
Harald Welte70767382018-02-21 12:16:40 +01001202
Harald Welte8c24c2b2018-02-26 08:31:31 +01001203 var GsmFrameNumber fn_last := 0;
Maxa199a2e2019-02-25 16:31:11 +01001204 var boolean test_failed := false;
Harald Welte8c24c2b2018-02-26 08:31:31 +01001205 for (var integer i := 0; i < 1000; i := i+1) {
1206 var OCT1 ra := f_rnd_ra_cs();
1207 var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra));
1208 if (fn == fn_last) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001209 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?");
Harald Welte8c24c2b2018-02-26 08:31:31 +01001210 }
1211 fn_last := fn;
1212
1213 timer T := 5.0;
Harald Welte56c05802018-02-28 21:39:35 +01001214 T.start;
Harald Welte8c24c2b2018-02-26 08:31:31 +01001215 alt {
1216 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_CHAN_RQD(ra, fn, ?))) {
1217 T.stop;
1218 }
1219 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_CHAN_RQD(?, ?, ?))) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001220 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected CHAN RQD");
Harald Welte8c24c2b2018-02-26 08:31:31 +01001221 }
1222 [] RSL_CCHAN.receive { repeat; }
1223 [] T.timeout {
Maxa199a2e2019-02-25 16:31:11 +01001224 test_failed := true;
1225 log("[", i, "] Timeout waiting for CHAN RQD FN=", fn, " RA=", ra);
Harald Welte8c24c2b2018-02-26 08:31:31 +01001226 }
1227 }
1228 }
Maxba06feb2019-03-05 10:52:46 +01001229 if (test_failed) {
1230 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Some out of 1000 RACH requests timed out"));
Maxa199a2e2019-02-25 16:31:11 +01001231 }
Maxba06feb2019-03-05 10:52:46 +01001232 setverdict(pass);
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001233 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +01001234}
Harald Welte8c24c2b2018-02-26 08:31:31 +01001235
1236/* Send 1000 RACH Requests (flood ~ 89/s) and count if count(Abis) == count(Um) */
1237testcase TC_rach_count() runs on test_CT {
Harald Welte294b0a22018-03-10 23:26:48 +01001238 f_init();
Harald Welte8c24c2b2018-02-26 08:31:31 +01001239 f_init_l1ctl();
Harald Welte294b0a22018-03-10 23:26:48 +01001240 f_sleep(1.0);
Harald Welte8c24c2b2018-02-26 08:31:31 +01001241 f_l1_tune(L1CTL);
1242
1243 var GsmFrameNumber fn_last := 0;
1244 for (var integer i := 0; i < 1000; i := i+1) {
1245 var OCT1 ra := f_rnd_ra_cs();
1246 var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra));
1247 if (fn == fn_last) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001248 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?");
Harald Welte8c24c2b2018-02-26 08:31:31 +01001249 }
1250 fn_last := fn;
1251 }
1252 var integer rsl_chrqd := 0;
1253 timer T := 3.0;
Harald Welte56c05802018-02-28 21:39:35 +01001254 T.start;
Harald Welte8c24c2b2018-02-26 08:31:31 +01001255 alt {
1256 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_CHAN_RQD(?,?))) {
1257 rsl_chrqd := rsl_chrqd + 1;
Harald Weltec3a3f452018-02-26 17:37:47 +01001258 f_timer_safe_restart(T);
Harald Welte8c24c2b2018-02-26 08:31:31 +01001259 repeat;
1260 }
1261 [] RSL_CCHAN.receive { repeat; }
1262 [] T.timeout { }
1263 }
1264 if (rsl_chrqd == 1000) {
1265 setverdict(pass);
1266 } else {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001267 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Received only ", rsl_chrqd, " out of 1000 RACH"));
Harald Welte8c24c2b2018-02-26 08:31:31 +01001268 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001269 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +01001270}
1271
Harald Welte3453ab42019-05-24 21:19:58 +02001272private function f_vty_load_ind_thresh(integer period := 10, integer bts_nr := 0) runs on test_CT {
1273 var charstring bts_str := "bts " & int2str(bts_nr);
1274 f_vty_config2(BSCVTY, {"network", bts_str}, "ccch load-indication-threshold " & int2str(period));
1275}
1276
1277/* empirical value: Number of RACH slots per reporting interval (1s) on combined CCCH */
1278private template integer tr_rach_slots_per_interval := (90 .. 130);
1279
1280/* Expect 0 RACH load on an idle BTS that has just started up */
1281testcase TC_rach_load_idle_thresh0() runs on test_CT {
1282 var ASP_RSL_Unitdata rx_ud;
1283
1284 f_init_vty_bsc();
1285 /* send load indications even at 0% load */
1286 f_vty_load_ind_thresh(0);
1287 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
1288 f_sleep(2.0);
1289
1290 f_init();
1291
1292 timer T := 5.0;
1293 T.start;
1294 alt {
1295 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_RACH_LOAD_IND(tr_rach_slots_per_interval, 0, 0))) {
1296 setverdict(pass);
1297 repeat;
1298 }
1299 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_RACH_LOAD_IND(?, ?, ?))) -> value rx_ud {
1300 setverdict(fail, "Unexpected RACH LOAD IND: ", rx_ud);
1301 repeat;
1302 }
1303 [] RSL_CCHAN.receive {
1304 repeat;
1305 }
1306 [] T.timeout { }
1307 }
1308
1309 f_vty_load_ind_thresh(10);
1310 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
1311}
1312
1313/* Expect no RACH load indications on an idle BTS that has just started up (default threshold 10%) */
1314testcase TC_rach_load_idle_below_thresh() runs on test_CT {
1315 var ASP_RSL_Unitdata rx_ud;
1316
1317 f_init_vty_bsc();
1318 f_init();
1319
1320 timer T := 5.0;
1321 T.start;
1322 alt {
1323 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_RACH_LOAD_IND(?, ?, ?))) -> value rx_ud {
1324 setverdict(fail, "Unexpected RACH LOAD IND: ", rx_ud);
1325 repeat;
1326 }
1327 [] RSL_CCHAN.receive {
1328 repeat;
1329 }
1330 [] T.timeout {
1331 setverdict(pass);
1332 }
1333 }
1334
1335 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
1336}
1337
1338/* Expect 0 RACH load on an idle BTS that has just started up */
1339testcase TC_rach_load_count() runs on test_CT {
1340 var ASP_RSL_Unitdata rx_ud;
1341 var integer load_access_count := 0;
1342
1343 f_init_vty_bsc();
1344 /* send load indications even at 0% load */
1345 f_vty_load_ind_thresh(0);
1346 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
1347 f_sleep(2.0);
1348 f_init();
1349
1350 f_init_l1ctl();
1351 f_sleep(1.0);
1352 f_l1_tune(L1CTL);
1353
1354 var GsmFrameNumber fn_last := 0;
1355 for (var integer i := 0; i < 1000; i := i+1) {
1356 var OCT1 ra := f_rnd_ra_cs();
1357 var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra));
1358 if (fn == fn_last) {
1359 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?");
1360 }
1361 fn_last := fn;
1362 }
1363
1364 timer T := 5.0;
1365 T.start;
1366 alt {
1367 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_RACH_LOAD_IND(tr_rach_slots_per_interval, ?, ?)))
1368 -> value rx_ud {
1369 var RSL_IE_Body ie;
1370 f_rsl_find_ie(rx_ud.rsl, RSL_IE_RACH_LOAD, ie);
1371 load_access_count := load_access_count + ie.rach_load.access_count;
1372 if (ie.rach_load.busy_count < ie.rach_load.access_count) {
1373 setverdict(fail, "Access count cannot be < Busy count");
1374 }
1375 repeat;
1376 }
1377 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_RACH_LOAD_IND(?, ?, ?))) -> value rx_ud {
1378 setverdict(fail, "Unexpected RACH LOAD IND: ", rx_ud);
1379 repeat;
1380 }
1381 [] RSL_CCHAN.receive {
1382 repeat;
1383 }
1384 [] T.timeout { }
1385 }
1386 if (load_access_count == 1000) {
1387 setverdict(pass);
1388 } else {
1389 setverdict(fail, "Load reports state ", load_access_count, " RACH, but we sent 1000");
1390 }
1391
1392 f_vty_load_ind_thresh(10);
1393 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
1394}
1395
1396
1397
Harald Welte54a2a2d2018-02-26 09:14:05 +01001398private function f_main_trxc_connect() runs on test_CT {
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +07001399 map(self:BTS_TRXC, system:BTS_TRXC);
Harald Welte54a2a2d2018-02-26 09:14:05 +01001400 var Result res;
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +07001401 res := TRXC_CodecPort_CtrlFunct.f_IPL4_connect(BTS_TRXC, mp_bts_trxc_ip, mp_bts_trxc_port,
Harald Welted3a88a62018-03-01 16:04:52 +01001402 "", -1, -1, {udp:={}}, {});
Harald Welte9220f632018-05-23 20:27:02 +02001403 if (not ispresent(res.connId)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001404 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Could not connect to trx-control interface of trxcon, check your configuration");
Harald Welte9220f632018-05-23 20:27:02 +02001405 }
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +07001406 g_bts_trxc_conn_id := res.connId;
Harald Welte54a2a2d2018-02-26 09:14:05 +01001407}
1408
1409private function f_rach_toffs(int16_t toffs256, boolean expect_pass) runs on test_CT {
Harald Weltef8df4cb2018-03-10 15:15:08 +01001410 var TrxcMessage ret;
Harald Welte54a2a2d2018-02-26 09:14:05 +01001411 /* tell fake_trx to use a given timing offset for all bursts */
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +07001412 ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, valueof(ts_TRXC_FAKE_TIMING(toffs256)));
Harald Welte54a2a2d2018-02-26 09:14:05 +01001413 f_sleep(0.5);
1414
1415 /* Transmit RACH request + wait for confirmation */
1416 var OCT1 ra := f_rnd_ra_cs();
1417 var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra));
1418
1419 /* Check for expected result */
1420 timer T := 1.5;
1421 T.start;
1422 alt {
1423 [expect_pass] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_CHAN_RQD(ra, fn))) {
1424 setverdict(pass);
1425 }
1426 [not expect_pass] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_CHAN_RQD(ra, fn))) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001427 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("RACH passed but was expected to be dropped: ", toffs256));
Harald Welte54a2a2d2018-02-26 09:14:05 +01001428 }
1429 [] RSL_CCHAN.receive { repeat; }
1430 [not expect_pass] T.timeout {
1431 setverdict(pass);
1432 }
1433 [expect_pass] T.timeout {
Max6e053042019-03-14 16:34:22 +01001434 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Timeout waiting for CHAN RQD: FN=", fn, " RA=", ra));
Harald Welte54a2a2d2018-02-26 09:14:05 +01001435 }
1436 }
1437}
1438
1439/* Test if dropping of RACH Based on NM_ATT_MAX_TA works */
1440testcase TC_rach_max_ta() runs on test_CT {
1441 f_init(testcasename());
1442 f_init_l1ctl();
1443 f_l1_tune(L1CTL);
Harald Welte54a2a2d2018-02-26 09:14:05 +01001444 f_sleep(1.0);
1445
1446 /* default max-ta is 63 (full range of GSM timing advance */
1447
Vadim Yanitskiyc81d6e42018-03-05 22:39:01 +07001448 /* We allow early arrival up to 2 symbols */
1449 f_rach_toffs(-1*256, true);
1450 f_rach_toffs(-2*256, true);
Harald Welte54a2a2d2018-02-26 09:14:05 +01001451 f_rach_toffs(-10*256, false);
1452
1453 /* 0 / 32 / 63 bits is legal / permitted */
1454 f_rach_toffs(0, true);
1455 f_rach_toffs(32*256, true);
1456 f_rach_toffs(63*256, true);
1457
1458 /* more than 63 bits is not legal / permitted */
1459 f_rach_toffs(64*256, false);
1460 f_rach_toffs(127*256, false);
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001461 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte54a2a2d2018-02-26 09:14:05 +01001462}
Harald Welte8c24c2b2018-02-26 08:31:31 +01001463
Harald Welte93640c62018-02-25 16:59:33 +01001464/***********************************************************************
1465 * Measurement Processing / Reporting
1466 ***********************************************************************/
1467
Harald Welte70767382018-02-21 12:16:40 +01001468template LapdmAddressField ts_LapdmAddr(LapdmSapi sapi, boolean c_r) := {
1469 spare := '0'B,
1470 lpd := 0,
1471 sapi := sapi,
1472 c_r := c_r,
1473 ea := true
1474}
1475
Harald Welted879bd92018-03-12 15:01:23 +01001476template LapdmFrameAB ts_LAPDm_AB(LapdmSapi sapi, boolean c_r, boolean p, octetstring pl) := {
Harald Welte70767382018-02-21 12:16:40 +01001477 addr := ts_LapdmAddr(sapi, c_r),
Harald Welted879bd92018-03-12 15:01:23 +01001478 ctrl := ts_LapdmCtrlUI(p),
Harald Welte70767382018-02-21 12:16:40 +01001479 len := 0, /* overwritten */
1480 m := false,
1481 el := 1,
1482 payload := pl
1483}
1484
1485/* handle incoming downlink SACCH and respond with uplink SACCH (meas res) */
1486altstep as_l1_sacch() runs on ConnHdlr {
1487 var L1ctlDlMessage l1_dl;
Harald Weltef8df4cb2018-03-10 15:15:08 +01001488 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl {
Harald Welte70767382018-02-21 12:16:40 +01001489 log("SACCH received: ", l1_dl.payload.data_ind.payload);
Pau Espin Pedrole9571aa2018-10-22 17:13:07 +02001490 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 +01001491 var LapdmFrameAB lb := valueof(ts_LAPDm_AB(0, false, false, enc_GsmRrL3Message(meas_rep)));
Harald Welte70767382018-02-21 12:16:40 +01001492 log("LAPDm: ", lb);
Pau Espin Pedroled359cb2018-09-28 16:08:24 +02001493
1494 var L1ctlDataReq data_req := {
1495 l1header := valueof(ts_SacchL1Header(g_pars.l1_pars.ms_power_level, false, g_pars.l1_pars.ms_actual_ta)),
1496 l2_payload := f_pad_oct(enc_LapdmFrameAB(lb), 21, '2B'O)
1497 }
1498 log("Sending Measurement Report: ", data_req);
1499 L1CTL.send(ts_L1CTL_DATA_REQ_SACCH(g_chan_nr, ts_RslLinkID_SACCH(0), data_req));
Harald Welte70767382018-02-21 12:16:40 +01001500 repeat;
1501 }
1502}
1503
1504altstep as_l1_dcch() runs on ConnHdlr {
1505 var L1ctlDlMessage l1_dl;
Harald Weltef8df4cb2018-03-10 15:15:08 +01001506 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_DCCH(?))) -> value l1_dl {
Harald Welte70767382018-02-21 12:16:40 +01001507 log("DCCH received: ", l1_dl.payload.data_ind.payload);
1508 var octetstring pl := '010301'O;
Vadim Yanitskiy31e7c672018-07-27 02:23:16 +07001509 L1CTL.send(ts_L1CTL_DATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0),
1510 f_pad_oct(pl, 23, '2B'O)));
Harald Welte70767382018-02-21 12:16:40 +01001511 repeat;
1512 }
1513}
1514
1515type record MeasElem {
1516 uint6_t rxlev,
1517 uint3_t rxqual
1518}
1519
1520type record MeasElemFS {
1521 MeasElem full,
1522 MeasElem sub
1523}
1524
1525type record ConnL1Pars {
1526 boolean dtx_enabled,
Harald Welte685d5982018-02-27 20:42:05 +01001527 boolean toa256_enabled,
Harald Welte70767382018-02-21 12:16:40 +01001528 MeasElemFS meas_ul,
1529 int16_t timing_offset_256syms,
1530 uint5_t bs_power_level,
1531 uint5_t ms_power_level,
1532 uint8_t ms_actual_ta
1533}
1534
1535/* Convert tiing offset from 1/256th symbol to RSL Timing Offset */
1536private function toffs256s_to_rsl(int16_t toffs256s) return uint8_t {
1537 return 63 + (toffs256s/256);
1538}
1539
Harald Welted5684392018-03-10 18:22:04 +01001540private function f_max(integer a, integer b) return integer {
1541 if (a > b) {
1542 return a;
1543 } else {
1544 return b;
1545 }
1546}
1547
1548private function f_min(integer a, integer b) return integer {
1549 if (a < b) {
1550 return a;
1551 } else {
1552 return b;
1553 }
1554}
1555
1556/* compute negative tolerance val-tolerance, ensure >= min */
1557private function f_tolerance_neg(integer val, integer min, integer tolerance) return integer {
1558 val := val - tolerance;
1559 return f_max(val, min);
1560}
1561
1562/* compute positive tolerance val+tolerance, ensure <= max */
1563private function f_tolerance_pos(integer val, integer max, integer tolerance) return integer {
1564 val := val + tolerance;
1565 return f_min(val, max);
1566}
1567
1568/* return a template of (val-tolerance .. val+tolerance) ensuring it is within (min .. max) */
1569private function f_tolerance(integer val, integer min, integer max, integer tolerance)
1570return template integer {
1571 var template integer ret;
1572 ret := (f_tolerance_neg(val, min, tolerance) .. f_tolerance_pos(val, max, tolerance));
1573 return ret;
1574}
1575
1576
Harald Welte70767382018-02-21 12:16:40 +01001577/* build a template for matching measurement results against */
1578private function f_build_meas_res_tmpl() runs on ConnHdlr return template RSL_Message {
1579 var ConnL1Pars l1p := g_pars.l1_pars;
1580 var template RSL_IE_UplinkMeas ul_meas := {
1581 len := 3,
1582 rfu := '0'B,
1583 dtx_d := l1p.dtx_enabled,
Harald Welted5684392018-03-10 18:22:04 +01001584 rxlev_f_u := f_tolerance(l1p.meas_ul.full.rxlev, 0, 63, mp_tolerance_rxlev),
Harald Welte70767382018-02-21 12:16:40 +01001585 reserved1 := '00'B,
Harald Welted5684392018-03-10 18:22:04 +01001586 rxlev_s_u := f_tolerance(l1p.meas_ul.sub.rxlev, 0, 63, mp_tolerance_rxlev),
Harald Welte70767382018-02-21 12:16:40 +01001587 reserved2 := '00'B,
Harald Welted5684392018-03-10 18:22:04 +01001588 rxq_f_u := f_tolerance(l1p.meas_ul.full.rxqual, 0, 7, mp_tolerance_rxqual),
1589 rxq_s_u := f_tolerance(l1p.meas_ul.sub.rxqual, 0, 7, mp_tolerance_rxqual),
Harald Welte70767382018-02-21 12:16:40 +01001590 supp_meas_info := omit
1591 };
Harald Welte685d5982018-02-27 20:42:05 +01001592 if (l1p.toa256_enabled) {
Harald Welte15de8ba2018-06-29 08:51:42 +02001593 ul_meas.len := (3+8);
1594 ul_meas.supp_meas_info := {
Pau Espin Pedrol121724c2018-09-28 15:58:12 +02001595 toa256_mean := f_tolerance(l1p.timing_offset_256syms, -63*256, 192*256, mp_tolerance_timing_offset_256syms),
Harald Welte15de8ba2018-06-29 08:51:42 +02001596 toa256_min := ?,
1597 toa256_max := ?,
1598 toa256_std_dev := ?
1599 }
Harald Welte685d5982018-02-27 20:42:05 +01001600 }
Harald Welte70767382018-02-21 12:16:40 +01001601 var template RSL_IE_BS_Power bs_power := {
1602 reserved := 0,
1603 epc := false,
1604 fpc := false,
1605 power_level := l1p.bs_power_level
1606 };
1607 var template RSL_IE_L1Info l1_info := {
1608 ms_power_lvl := l1p.ms_power_level,
1609 fpc := false,
1610 reserved := 0,
Pau Espin Pedrol121724c2018-09-28 15:58:12 +02001611 actual_ta := f_tolerance(l1p.ms_actual_ta, 0, 63, mp_tolerance_timing_offset_256syms/256)
Harald Welte70767382018-02-21 12:16:40 +01001612 };
1613 var uint8_t offs := toffs256s_to_rsl(l1p.timing_offset_256syms);
Pau Espin Pedrol121724c2018-09-28 15:58:12 +02001614 var template uint8_t t_toffs := f_tolerance(offs, 0, 255, mp_tolerance_timing_offset_256syms/256);
Harald Welte70767382018-02-21 12:16:40 +01001615 return tr_RSL_MEAS_RES_OSMO(g_chan_nr, g_next_meas_res_nr, ul_meas, bs_power, l1_info,
1616 ?, t_toffs);
1617}
1618
1619/* verify we regularly receive measurement reports with incrementing numbers */
Vadim Yanitskiy41baf002018-10-04 17:44:50 +07001620altstep as_meas_res(boolean verify_meas := true) runs on ConnHdlr {
Harald Welte70767382018-02-21 12:16:40 +01001621 var RSL_Message rsl;
Vadim Yanitskiy41baf002018-10-04 17:44:50 +07001622 [not verify_meas] RSL.receive(tr_RSL_MEAS_RES(?)) { repeat; }
Harald Welte70767382018-02-21 12:16:40 +01001623 [] RSL.receive(f_build_meas_res_tmpl()) -> value rsl {
1624 /* increment counter of next to-be-expected meas rep */
1625 g_next_meas_res_nr := (g_next_meas_res_nr + 1) mod 256;
1626 /* Re-start the timer expecting the next MEAS RES */
Harald Weltec3a3f452018-02-26 17:37:47 +01001627 f_timer_safe_restart(g_Tmeas_exp);
Harald Welte70767382018-02-21 12:16:40 +01001628 repeat;
1629 }
1630 [] RSL.receive(tr_RSL_MEAS_RES(g_chan_nr, g_next_meas_res_nr)) -> value rsl {
Harald Weltefa45e9e2018-03-10 18:59:03 +01001631 /* increment counter of next to-be-expected meas rep */
1632 g_next_meas_res_nr := (g_next_meas_res_nr + 1) mod 256;
1633 if (g_first_meas_res) {
1634 g_first_meas_res := false;
1635 repeat;
1636 } else {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001637 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Received unspecific MEAS RES ", rsl));
Harald Weltefa45e9e2018-03-10 18:59:03 +01001638 }
Harald Welte70767382018-02-21 12:16:40 +01001639 }
1640 [] RSL.receive(tr_RSL_MEAS_RES(?)) -> value rsl {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001641 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Received unexpected MEAS RES ", rsl));
Harald Welte70767382018-02-21 12:16:40 +01001642 }
Pau Espin Pedrol425b62f2018-07-06 16:11:43 +02001643 [g_Tmeas_exp.running] g_Tmeas_exp.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001644 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Didn't receive expected measurement result")
Harald Welte70767382018-02-21 12:16:40 +01001645 }
1646}
1647
Harald Weltee613f962018-04-18 22:38:16 +02001648private function f_alg_id_to_l1ctl(RSL_AlgId rsl_alg_id) return uint8_t {
1649 select (rsl_alg_id) {
1650 case (RSL_ALG_ID_A5_0) { return 0; }
1651 case (RSL_ALG_ID_A5_1) { return 1; }
1652 case (RSL_ALG_ID_A5_2) { return 2; }
1653 case (RSL_ALG_ID_A5_3) { return 3; }
1654 case (RSL_ALG_ID_A5_4) { return 4; }
1655 case (RSL_ALG_ID_A5_5) { return 5; }
1656 case (RSL_ALG_ID_A5_6) { return 6; }
1657 case (RSL_ALG_ID_A5_7) { return 7; }
1658 case else {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001659 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unknwon Algorithm ID");
1660 /* Make compiler happy by calling mtc.stop here. It is already
1661 * called in f_shutdown */
Daniel Willmann17ddd852018-07-05 17:33:20 +02001662 mtc.stop;
Harald Weltee613f962018-04-18 22:38:16 +02001663 }
1664 }
1665}
1666
1667private function f_alg_id_to_l3(RSL_AlgId rsl_alg_id) return BIT3 {
1668 select (rsl_alg_id) {
1669 case (RSL_ALG_ID_A5_1) { return '000'B; }
1670 case (RSL_ALG_ID_A5_2) { return '001'B; }
1671 case (RSL_ALG_ID_A5_3) { return '010'B; }
1672 case (RSL_ALG_ID_A5_4) { return '011'B; }
1673 case (RSL_ALG_ID_A5_5) { return '100'B; }
1674 case (RSL_ALG_ID_A5_6) { return '101'B; }
1675 case (RSL_ALG_ID_A5_7) { return '110'B; }
1676 case else {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001677 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unknwon Algorithm ID");
1678 /* Make compiler happy by calling mtc.stop here. It is already
1679 * called in f_shutdown */
Daniel Willmann17ddd852018-07-05 17:33:20 +02001680 mtc.stop;
Harald Weltee613f962018-04-18 22:38:16 +02001681 }
1682 }
1683}
1684
Pau Espin Pedrol6451b042018-10-24 20:36:16 +02001685/* Send RACH request through l1CTL and wait for ChanReq on RSL BST->BSC */
1686private function f_rach_req_wait_chan_rqd(integer ra) runs on ConnHdlr return GsmFrameNumber {
1687 var GsmFrameNumber fn;
1688 timer T := 8.0;
1689
1690 /* advertise to RSL Emulation that we expect to receive confirmation from RACH */
1691 RSL.send(ts_RSLDC_ChanRqd_anyFN(int2oct(ra,1)));
1692
1693 f_L1CTL_PARAM(L1CTL, g_pars.l1_pars.ms_actual_ta, g_pars.l1_pars.ms_power_level);
1694 /* Send the actual RACH */
1695 fn := f_L1CTL_RACH(L1CTL, ra);
1696
1697 T.start;
1698 alt {
1699 [] RSL.receive(tr_RSL_CHAN_RQD(int2oct(ra,1), fn)) { setverdict(pass, "Received CHAN-RQD from RACH REQ") }
1700 [] T.timeout {
1701 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Timeout waiting for CHAN-RQD from RACH REQ <", ra, ", ", fn, ">"));
1702 }
1703 }
1704 T.stop
1705 return fn;
1706}
Harald Weltee613f962018-04-18 22:38:16 +02001707
Harald Welte70767382018-02-21 12:16:40 +01001708/* Establish dedicated channel: L1CTL + RSL side */
Harald Weltec8d363c2019-05-19 20:36:48 +02001709private function f_est_dchan(boolean encr_enable := false, RSL_IE_List more_ies := {}) runs on ConnHdlr {
Harald Welte70767382018-02-21 12:16:40 +01001710 var GsmFrameNumber fn;
1711 var ImmediateAssignment imm_ass;
1712 var integer ra := 23;
1713
Pau Espin Pedrol6451b042018-10-24 20:36:16 +02001714 /* Send RACH request and wait for ChanReq */
1715 fn := f_rach_req_wait_chan_rqd(ra);
Harald Welte70767382018-02-21 12:16:40 +01001716
1717 /* Activate channel on BTS side */
Harald Weltec8d363c2019-05-19 20:36:48 +02001718 f_rsl_chan_act(g_pars.chan_mode, encr_enable, more_ies);
Harald Welte70767382018-02-21 12:16:40 +01001719
1720 /* Send IMM.ASS via CCHAN */
1721 var ChannelDescription ch_desc := {
1722 chan_nr := g_pars.chan_nr,
1723 tsc := 7,
1724 h := false,
1725 arfcn := mp_trx0_arfcn,
1726 maio_hsn := omit
1727 };
1728 var MobileAllocation ma := {
1729 len := 0,
1730 ma := ''B
1731 };
1732 var GsmRrMessage rr_msg := valueof(ts_IMM_ASS(ra, fn, 0, ch_desc, ma));
1733 RSL.send(ts_RSL_IMM_ASSIGN(enc_GsmRrMessage(rr_msg)));
1734
1735 /* receive IMM.ASS on MS side */
1736 var ImmediateAssignment ia_um;
1737 ia_um := f_L1CTL_WAIT_IMM_ASS(L1CTL, ra, fn);
1738 /* enable dedicated mode */
1739 f_L1CTL_DM_EST_REQ_IA(L1CTL, ia_um);
Harald Weltee613f962018-04-18 22:38:16 +02001740 /* enable encryption, if requested */
1741 if (encr_enable) {
1742 var uint8_t alg_id := f_alg_id_to_l1ctl(g_pars.encr.alg_id);
1743 f_L1CTL_CRYPTO_REQ(L1CTL, g_pars.chan_nr, alg_id, g_pars.encr.key);
1744 }
Harald Weltefa45e9e2018-03-10 18:59:03 +01001745
1746 g_first_meas_res := true;
Harald Welte70767382018-02-21 12:16:40 +01001747}
1748
1749/* establish DChan, verify existance + contents of measurement reports */
1750function f_TC_meas_res_periodic(charstring id) runs on ConnHdlr {
Harald Welte68e495b2018-02-25 00:05:57 +01001751 f_l1_tune(L1CTL);
Harald Welte70767382018-02-21 12:16:40 +01001752 RSL.clear;
1753
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +07001754 if (mp_bts_trxc_port != -1) {
Pau Espin Pedrole9571aa2018-10-22 17:13:07 +02001755 f_trxc_fake_rssi(rxlev2dbm(mp_ul_rxlev_exp));
Pau Espin Pedrol121724c2018-09-28 15:58:12 +02001756 f_trx_fake_toffs256(g_pars.l1_pars.timing_offset_256syms);
1757 }
Harald Welte70767382018-02-21 12:16:40 +01001758
1759 f_est_dchan();
1760
1761 /* run for a number of seconds, send SACCH + FACCH from MS side and verify
1762 * RSL measurement reports on Abis side */
1763 timer T := 8.0;
1764 T.start;
1765 alt {
1766 [] as_l1_sacch();
1767 [] as_meas_res();
1768 [] as_l1_dcch();
1769 [] L1CTL.receive { repeat; }
1770 [g_Tmeas_exp.running] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001771 /* as_meas_res() would have done Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail) in case
Harald Welte70767382018-02-21 12:16:40 +01001772 * of any earlier errors, so if we reach this timeout, we're good */
1773 setverdict(pass);
1774 }
1775 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001776 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "No MEAS RES received at all");
Harald Welte70767382018-02-21 12:16:40 +01001777 }
1778 }
1779 f_rsl_chan_deact();
Harald Welte3dc20462018-03-10 23:03:38 +01001780 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
Harald Welte70767382018-02-21 12:16:40 +01001781}
Harald Welte0472ab42018-03-12 15:02:26 +01001782
Harald Welte70767382018-02-21 12:16:40 +01001783testcase TC_meas_res_sign_tchf() runs on test_CT {
1784 var ConnHdlr vc_conn;
1785 var ConnHdlrPars pars;
1786 f_init(testcasename());
1787 for (var integer tn := 1; tn <= 4; tn := tn+1) {
1788 pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN));
1789 vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars);
1790 vc_conn.done;
1791 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001792 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +01001793}
1794testcase TC_meas_res_sign_tchh() runs on test_CT {
1795 var ConnHdlr vc_conn;
1796 var ConnHdlrPars pars;
1797 f_init(testcasename());
1798 for (var integer ss := 0; ss <= 1; ss := ss+1) {
1799 pars := valueof(t_Pars(t_RslChanNr_Lm(5, ss), ts_RSL_ChanMode_SIGN));
1800 vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars);
1801 vc_conn.done;
1802 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001803 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +01001804}
1805testcase TC_meas_res_sign_sdcch4() runs on test_CT {
1806 var ConnHdlr vc_conn;
1807 var ConnHdlrPars pars;
1808 f_init(testcasename());
1809 for (var integer ss := 0; ss <= 3; ss := ss+1) {
1810 pars := valueof(t_Pars(t_RslChanNr_SDCCH4(0, ss), ts_RSL_ChanMode_SIGN));
1811 vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars);
1812 vc_conn.done;
1813 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001814 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +01001815}
1816testcase TC_meas_res_sign_sdcch8() runs on test_CT {
1817 var ConnHdlr vc_conn;
1818 var ConnHdlrPars pars;
1819 f_init(testcasename());
1820 for (var integer ss := 0; ss <= 7; ss := ss+1) {
1821 pars := valueof(t_Pars(t_RslChanNr_SDCCH8(6, ss), ts_RSL_ChanMode_SIGN));
1822 vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars);
1823 vc_conn.done;
1824 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001825 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +01001826}
Harald Welte685d5982018-02-27 20:42:05 +01001827testcase TC_meas_res_sign_tchh_toa256() runs on test_CT {
1828 var ConnHdlr vc_conn;
1829 var ConnHdlrPars pars;
1830 f_init(testcasename());
1831 f_vty_config(BTSVTY, "bts 0", "supp-meas-info toa256");
1832 for (var integer ss := 0; ss <= 1; ss := ss+1) {
1833 pars := valueof(t_Pars(t_RslChanNr_Lm(5, ss), ts_RSL_ChanMode_SIGN));
1834 pars.l1_pars.toa256_enabled := true;
1835 vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars);
1836 vc_conn.done;
1837 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001838 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte685d5982018-02-27 20:42:05 +01001839}
1840
Philipp Maier4d1e9c92018-12-20 11:11:56 +01001841/* establish DChan, and send MS POWER CONTROL messages via RSL, verify that
1842 * the BTS is forwarding those values to the MS via the SACCH L1 header. */
1843function f_tc_rsl_ms_pwr_ctrl(charstring id) runs on ConnHdlr {
1844 var L1ctlDlMessage l1_dl;
1845 var RSL_IE_MS_Power ms_power;
1846 var RSL_Message rsl;
1847 var uint5_t power_level := 0;
1848
1849 f_l1_tune(L1CTL);
1850 RSL.clear;
1851
1852 f_est_dchan();
1853
1854 ms_power.reserved := 0;
1855 ms_power.fpc_epc := false;
1856
1857 /* Send the first power control command. This will disable any BTS/TRX
1858 * internal power control and switch the MS (which is not in scope of
1859 * this test) to a constant power level. We start with a power level
1860 * of 0 */
1861 ms_power.power_level := power_level;
1862 rsl := valueof(ts_RSL_MS_PWR_CTRL(g_chan_nr, ms_power));
1863 RSL.send(rsl);
1864
1865 alt {
1866
1867 /* Pick all SACCH blocks for checking */
1868 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl {
1869
1870 /* The first byte of the L1 header contains the power level.
1871 * The reserved bits and the fpc bit is set to 0, so we may
1872 * compare directly. */
1873 if (not (l1_dl.payload.data_ind.payload[0] == int2oct(power_level, 1))) {
1874 setverdict(fail, "Power level in L1 header does not match the signaled (RSL) power level.");
1875 }
1876
1877 /* Signal a new power level via RSL for the next turn. */
1878 if (power_level < 31) {
1879 power_level := power_level + 1;
1880 ms_power.power_level := power_level;
1881 rsl := valueof(ts_RSL_MS_PWR_CTRL(g_chan_nr, ms_power));
1882 RSL.send(rsl);
1883 repeat;
1884 }
1885
1886 }
1887
1888 /* Ignore all other blocks */
1889 [] L1CTL.receive { repeat; }
1890
1891 }
1892
1893 f_rsl_chan_deact();
1894 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1895
1896 setverdict(pass);
1897}
1898
1899testcase TC_rsl_ms_pwr_ctrl() runs on test_CT {
1900 var ConnHdlr vc_conn;
1901 var ConnHdlrPars pars;
1902 f_init(testcasename());
1903
1904 for (var integer tn := 1; tn <= 4; tn := tn+1) {
1905 pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN));
1906 vc_conn := f_start_handler(refers(f_tc_rsl_ms_pwr_ctrl), pars);
1907 vc_conn.done;
1908 }
1909 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
1910}
Harald Welte70767382018-02-21 12:16:40 +01001911
Eric Wild6833cc92019-05-23 19:34:44 +02001912/* establish DChan, verify that the BTS sets the TA in the first SACCH L1 header.
1913TA for the IMM ASS messages is still controlled by g_pars.l1_pars.ms_actual_ta! */
1914function f_tc_rsl_chan_initial_ta(charstring id) runs on ConnHdlr {
1915 var L1ctlDlMessage l1_dl;
1916 var uint5_t ta_to_test := 16;
1917
1918
1919 f_l1_tune(L1CTL);
1920 RSL.clear;
1921
1922 /* tell fake_trx to use a given timing offset for all bursts */
1923 f_trx_fake_toffs256(ta_to_test*256);
1924
1925 f_est_dchan(more_ies :={valueof(t_RSL_IE(RSL_IE_TIMING_ADVANCE, RSL_IE_Body:{timing_adv := ta_to_test}))} );
1926
1927
1928 alt {
1929
1930 /* Pick all SACCH blocks for checking */
1931 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl {
1932
1933 /* The second byte of the L1 header contains the TA. */
1934 if (not (l1_dl.payload.data_ind.payload[1] == int2oct(ta_to_test, 1))) {
1935 setverdict(fail, "TA in L1 header does not match the signaled (RSL) TA.");
1936 }
1937
1938 }
1939
1940 /* Ignore all other blocks */
1941 [] L1CTL.receive { repeat; }
1942
1943 }
1944
1945 f_rsl_chan_deact();
1946 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1947
1948 setverdict(pass);
1949}
1950
1951testcase TC_rsl_chan_initial_ta() runs on test_CT {
1952 var ConnHdlr vc_conn;
1953 var ConnHdlrPars pars;
1954 f_init(testcasename());
1955 pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
1956 vc_conn := f_start_handler(refers(f_tc_rsl_chan_initial_ta), pars);
1957 vc_conn.done;
1958 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
1959}
1960
Harald Welte0472ab42018-03-12 15:02:26 +01001961/* 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 +01001962private function f_TC_conn_fail_crit(charstring id) runs on ConnHdlr {
Harald Welte68e495b2018-02-25 00:05:57 +01001963 f_l1_tune(L1CTL);
Harald Welte70767382018-02-21 12:16:40 +01001964 RSL.clear;
1965
1966 f_est_dchan();
1967 f_sleep(2.0);
Harald Weltef8df4cb2018-03-10 15:15:08 +01001968 L1CTL.send(ts_L1CTL_DM_REL_REQ(g_chan_nr));
Harald Welte70767382018-02-21 12:16:40 +01001969
1970 timer T := 40.0;
1971 T.start;
1972 alt {
1973 [] RSL.receive(tr_RSL_CONN_FAIL_IND(g_chan_nr, ?)) {
1974 setverdict(pass)
1975 }
1976 [] RSL.receive { repeat };
1977 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001978 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "No CONN FAIL IND received");
Harald Welte70767382018-02-21 12:16:40 +01001979 }
1980 }
1981 f_rsl_chan_deact();
1982}
1983testcase TC_conn_fail_crit() runs on test_CT {
1984 var ConnHdlr vc_conn;
1985 var ConnHdlrPars pars;
1986 f_init(testcasename());
1987 pars := valueof(t_Pars(t_RslChanNr_SDCCH8(6, 3), ts_RSL_ChanMode_SIGN));
1988 pars.t_guard := 60.0;
1989 vc_conn := f_start_handler(refers(f_TC_conn_fail_crit), pars);
1990 vc_conn.done;
1991}
1992
Harald Welte93640c62018-02-25 16:59:33 +01001993/***********************************************************************
1994 * Paging
1995 ***********************************************************************/
1996
Harald Welte68e495b2018-02-25 00:05:57 +01001997function tmsi_is_dummy(TMSIP_TMSI_V tmsi) return boolean {
1998 if (tmsi == 'FFFFFFFF'O) {
1999 return true;
2000 } else {
2001 return false;
2002 }
2003}
Harald Welte70767382018-02-21 12:16:40 +01002004
Philipp Maier82cb0b12018-08-31 14:41:39 +02002005type record allowedFn { integer frame_nr }
2006template allowedFn bs_ag_blks_res_0 := { frame_nr := (6, 12, 16, 22, 26, 32, 36, 42, 46) }
2007template allowedFn bs_ag_blks_res_1 := { frame_nr := (12, 16, 22, 26, 32, 36, 42, 46) }
2008template allowedFn bs_ag_blks_res_2 := { frame_nr := (16, 22, 26, 32, 36, 42, 46) }
2009template allowedFn bs_ag_blks_res_3 := { frame_nr := (22, 26, 32, 36, 42, 46) }
2010template allowedFn bs_ag_blks_res_4 := { frame_nr := (26, 32, 36, 42, 46) }
2011template allowedFn bs_ag_blks_res_5 := { frame_nr := (32, 36, 42, 46) }
2012template allowedFn bs_ag_blks_res_6 := { frame_nr := (36, 42, 46) }
2013template allowedFn bs_ag_blks_res_7 := { frame_nr := (42, 46) }
2014function check_pch_fn(integer frame_nr, integer bs_ag_blks_res) runs on test_CT
2015{
2016 var integer frame_nr_51;
2017 frame_nr_51 := frame_nr mod 51
2018
2019 var allowedFn fn_check;
2020 fn_check.frame_nr := frame_nr_51;
2021
2022 if (bs_ag_blks_res < 0 or bs_ag_blks_res > 7) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002023 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "bs_ag_blks_res out of valid range (0..7)");
Philipp Maier82cb0b12018-08-31 14:41:39 +02002024 return;
2025 }
2026
2027 if (bs_ag_blks_res == 0 and match(fn_check, bs_ag_blks_res_0)) {
2028 return;
2029 }
2030 if (bs_ag_blks_res == 1 and match(fn_check, bs_ag_blks_res_1)) {
2031 return;
2032 }
2033 if (bs_ag_blks_res == 2 and match(fn_check, bs_ag_blks_res_2)) {
2034 return;
2035 }
2036 if (bs_ag_blks_res == 3 and match(fn_check, bs_ag_blks_res_3)) {
2037 return;
2038 }
2039 if (bs_ag_blks_res == 4 and match(fn_check, bs_ag_blks_res_4)) {
2040 return;
2041 }
2042 if (bs_ag_blks_res == 5 and match(fn_check, bs_ag_blks_res_5)) {
2043 return;
2044 }
2045 if (bs_ag_blks_res == 6 and match(fn_check, bs_ag_blks_res_6)) {
2046 return;
2047 }
2048 if (bs_ag_blks_res == 7 and match(fn_check, bs_ag_blks_res_7)) {
2049 return;
2050 }
2051
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002052 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "received paging on AGCH");
Philipp Maier82cb0b12018-08-31 14:41:39 +02002053 return;
2054}
2055
2056altstep 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 +01002057runs on test_CT {
2058 var L1ctlDlMessage dl;
Harald Weltef8df4cb2018-03-10 15:15:08 +01002059 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?, c_DummyUI)) {
Harald Welte68e495b2018-02-25 00:05:57 +01002060 repeat;
2061 }
Harald Weltef8df4cb2018-03-10 15:15:08 +01002062 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0))) -> value dl {
Harald Welte68e495b2018-02-25 00:05:57 +01002063 var octetstring without_plen :=
2064 substr(dl.payload.data_ind.payload, 1, lengthof(dl.payload.data_ind.payload)-1);
2065 var PDU_ML3_NW_MS rr := dec_PDU_ML3_NW_MS(without_plen);
Philipp Maier82cb0b12018-08-31 14:41:39 +02002066
2067 check_pch_fn(dl.dl_info.frame_nr, cfg.bs_ag_blks_res);
2068
Harald Welte68e495b2018-02-25 00:05:57 +01002069 if (match(rr, tr_PAGING_REQ1)) {
2070 num_paging_rcv_msgs := num_paging_rcv_msgs + 1;
2071 num_paging_rcv_ids := num_paging_rcv_ids + 1;
2072 if (isvalue(rr.msgs.rrm.pagingReq_Type1.mobileIdentity2)) {
2073 num_paging_rcv_ids := num_paging_rcv_ids + 1;
2074 }
2075 } else if (match(rr, tr_PAGING_REQ2)) {
2076 num_paging_rcv_msgs := num_paging_rcv_msgs + 1;
2077 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type2.mobileIdentity1)) {
2078 num_paging_rcv_ids := num_paging_rcv_ids + 1;
2079 }
2080 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type2.mobileIdentity2)) {
2081 num_paging_rcv_ids := num_paging_rcv_ids + 1;
2082 }
2083 if (isvalue(rr.msgs.rrm.pagingReq_Type2.mobileIdentity3)) {
2084 num_paging_rcv_ids := num_paging_rcv_ids + 1;
2085 }
2086 } else if (match(rr, tr_PAGING_REQ3)) {
2087 num_paging_rcv_msgs := num_paging_rcv_msgs + 1;
2088 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity1)) {
2089 num_paging_rcv_ids := num_paging_rcv_ids + 1;
2090 }
2091 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity2)) {
2092 num_paging_rcv_ids := num_paging_rcv_ids + 1;
2093 }
2094 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity3)) {
2095 num_paging_rcv_ids := num_paging_rcv_ids + 1;
2096 }
2097 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity4)) {
2098 num_paging_rcv_ids := num_paging_rcv_ids + 1;
2099 }
2100 }
2101 repeat;
2102 }
2103}
2104
2105type record PagingTestCfg {
2106 boolean combined_ccch,
2107 integer bs_ag_blks_res,
2108 float load_factor,
2109 boolean exp_load_ind,
2110 boolean exp_overload,
2111 boolean use_tmsi
2112}
2113
2114type record PagingTestState {
2115 integer num_paging_sent,
2116 integer num_paging_rcv_msgs,
2117 integer num_paging_rcv_ids,
2118 integer num_overload
2119}
2120
2121/* receive + ignore RSL RF RES IND */
2122altstep as_rsl_res_ind() runs on test_CT {
2123 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_RF_RES_IND)) {
2124 repeat;
2125 }
2126}
2127
2128/* Helper function for paging related testing */
2129private function f_TC_paging(PagingTestCfg cfg) runs on test_CT return PagingTestState {
2130 f_init(testcasename());
2131 f_init_l1ctl();
2132 f_l1_tune(L1CTL);
2133
2134 var PagingTestState st := {
2135 num_paging_sent := 0,
2136 num_paging_rcv_msgs := 0,
2137 num_paging_rcv_ids := 0,
2138 num_overload := 0
2139 };
2140
2141 var float max_pch_blocks_per_sec := f_pch_block_rate_est(cfg.combined_ccch, cfg.bs_ag_blks_res);
2142 var float max_pch_imsi_per_sec;
2143 if (cfg.use_tmsi) {
2144 max_pch_imsi_per_sec := max_pch_blocks_per_sec * 4.0; /* Type 3 */
2145 } else {
2146 max_pch_imsi_per_sec := max_pch_blocks_per_sec * 2.0; /* Type 1 */
2147 }
2148 var float pch_blocks_per_sec := max_pch_imsi_per_sec * cfg.load_factor;
2149 var float interval := 1.0 / pch_blocks_per_sec;
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02002150 var float time_total := 20.0;
2151 var integer pkt_total := float2int(time_total * pch_blocks_per_sec);
2152 log("pch_blocks_total=", pkt_total," pch_blocks_per_sec=", pch_blocks_per_sec, " interval=", interval);
Harald Welte68e495b2018-02-25 00:05:57 +01002153
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02002154 timer T_total := 300.0; /* big value (far bigger than time_total), used to count elapsed time */
2155 T_total.start;
Harald Welte68e495b2018-02-25 00:05:57 +01002156
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02002157 timer T_itv := 0.0;
2158 T_itv.start;
2159 while (st.num_paging_sent < pkt_total) {
Harald Welte68e495b2018-02-25 00:05:57 +01002160 alt {
2161 /* check for presence of CCCH LOAD IND (paging load) */
2162 [cfg.exp_overload] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_PAGING_LOAD_IND(0))) {
2163 st.num_overload := st.num_overload + 1;
2164 repeat;
2165 }
2166 [not cfg.exp_overload] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_PAGING_LOAD_IND(0))) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002167 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected PCH Overload");
Harald Welte68e495b2018-02-25 00:05:57 +01002168 }
2169 [cfg.exp_load_ind] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_PAGING_LOAD_IND)) {
2170 log("Rx LOAD_IND");
2171 /* FIXME: analyze/verify interval + contents */
2172 repeat;
2173 }
2174 /* check if paging requests arrive on Um side */
Philipp Maier82cb0b12018-08-31 14:41:39 +02002175 [] as_l1_count_paging(st.num_paging_rcv_msgs, st.num_paging_rcv_ids, cfg);
Harald Welte68e495b2018-02-25 00:05:57 +01002176 [] L1CTL.receive { repeat; }
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02002177 [] T_itv.timeout {
2178 /* Send paging cmds based on elapsed time */
2179 var integer new_sent := f_min(pkt_total, float2int(T_total.read * pch_blocks_per_sec) + 1);
2180 while (st.num_paging_sent < new_sent) {
2181 /* build mobile Identity */
2182 var MobileL3_CommonIE_Types.MobileIdentityLV mi;
2183 if (cfg.use_tmsi) {
2184 mi := valueof(ts_MI_TMSI_LV(f_rnd_octstring(4)));
2185 } else {
2186 mi := valueof(ts_MI_IMSI_LV(f_gen_imsi(st.num_paging_sent)));
2187 }
2188 var octetstring mi_enc_lv := enc_MobileIdentityLV(mi);
2189 var octetstring mi_enc := substr(mi_enc_lv, 1, lengthof(mi_enc_lv)-1);
2190
2191 /* Send RSL PAGING COMMAND */
2192 RSL_CCHAN.send(ts_RSL_UD(ts_RSL_PAGING_CMD(mi_enc, st.num_paging_sent mod 4)));
2193
2194 st.num_paging_sent := st.num_paging_sent + 1;
2195 }
2196 if (st.num_paging_sent < pkt_total) {
2197 /* Wait for interval to next PAGING COMMAND */
2198 var float time_now := T_total.read;
2199 var float next_sched := int2float(st.num_paging_sent)*interval;
2200 if (next_sched > time_now) {
2201 T_itv.start(next_sched - time_now);
2202 } else {
2203 T_itv.start(0.0);
2204 }
2205 } else {
2206 /* We are done, no need to keep counting */
2207 T_total.stop;
2208 }
2209 }
2210 [] T_total.timeout { }
Harald Welte68e495b2018-02-25 00:05:57 +01002211 [] as_rsl_res_ind();
2212 }
2213 }
2214
2215 /* wait for max 18s for paging queue to drain (size: 200, ~ 13 per s -> 15s) */
2216 timer T_wait := 18.0;
2217 T_wait.start;
2218 alt {
Philipp Maier82cb0b12018-08-31 14:41:39 +02002219 [] as_l1_count_paging(st.num_paging_rcv_msgs, st.num_paging_rcv_ids, cfg);
Harald Welte68e495b2018-02-25 00:05:57 +01002220 [] L1CTL.receive { repeat; }
2221 /* 65535 == empty paging queue, we can terminate*/
2222 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_PAGING_LOAD_IND(65535))) { }
2223 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_PAGING_LOAD_IND)) { repeat; }
2224 [] T_wait.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002225 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Waiting for empty paging queue");
Harald Welte68e495b2018-02-25 00:05:57 +01002226 }
2227 [] as_rsl_res_ind();
2228 }
2229
2230 log("num_paging_sent=", st.num_paging_sent, " rcvd_msgs=", st.num_paging_rcv_msgs,
2231 " rcvd_ids=", st.num_paging_rcv_ids);
2232 return st;
2233}
2234
2235/* Create ~ 80% paging load (IMSI only) sustained for about 20s, verifying that
2236 * - the number of Mobile Identities on Um PCH match the number of pages on RSL
2237 * - that CCCH LOAD IND (PCH) are being generated
2238 * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */
2239testcase TC_paging_imsi_80percent() runs on test_CT {
Philipp Maierd65d0562018-08-30 16:25:47 +02002240 var SystemInformation si3 := valueof(ts_SI3_default);
Harald Welte68e495b2018-02-25 00:05:57 +01002241 var PagingTestCfg cfg := {
2242 combined_ccch := true,
Philipp Maierd65d0562018-08-30 16:25:47 +02002243 bs_ag_blks_res := si3.payload.si3.ctrl_chan_desc.bs_ag_blks_res,
Harald Welte68e495b2018-02-25 00:05:57 +01002244 load_factor := 0.8,
2245 exp_load_ind := true,
2246 exp_overload := false,
2247 use_tmsi := false
2248 };
2249 var PagingTestState st := f_TC_paging(cfg);
2250 if (st.num_paging_sent != st.num_paging_rcv_ids) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002251 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Expected ", st.num_paging_sent, " pagings but have ",
2252 st.num_paging_rcv_ids));
Harald Welte68e495b2018-02-25 00:05:57 +01002253 } else {
2254 setverdict(pass);
2255 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002256 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte68e495b2018-02-25 00:05:57 +01002257}
2258
2259/* Create ~ 80% paging load (TMSI only) sustained for about 20s, verifying that
2260 * - the number of Mobile Identities on Um PCH match the number of pages on RSL
2261 * - that CCCH LOAD IND (PCH) are being generated
2262 * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */
2263testcase TC_paging_tmsi_80percent() runs on test_CT {
Philipp Maierd65d0562018-08-30 16:25:47 +02002264 var SystemInformation si3 := valueof(ts_SI3_default);
Harald Welte68e495b2018-02-25 00:05:57 +01002265 var PagingTestCfg cfg := {
2266 combined_ccch := true,
Philipp Maierd65d0562018-08-30 16:25:47 +02002267 bs_ag_blks_res := si3.payload.si3.ctrl_chan_desc.bs_ag_blks_res,
Harald Welte68e495b2018-02-25 00:05:57 +01002268 load_factor := 0.8,
2269 exp_load_ind := true,
2270 exp_overload := false,
2271 use_tmsi := true
2272 };
2273 var PagingTestState st := f_TC_paging(cfg);
2274 if (st.num_paging_sent != st.num_paging_rcv_ids) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002275 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Expected ", st.num_paging_sent, " pagings but have ",
2276 st.num_paging_rcv_ids));
Harald Welte68e495b2018-02-25 00:05:57 +01002277 } else {
2278 setverdict(pass);
2279 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002280 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte68e495b2018-02-25 00:05:57 +01002281}
2282
2283/* Create ~ 200% paging load (IMSI only) sustained for about 20s, verifying that
2284 * - the number of Mobile Identities on Um PCH are ~ 82% of the number of pages on RSL
2285 * - that CCCH LOAD IND (PCH) are being generated and reach 0 at some point
2286 * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */
2287testcase TC_paging_imsi_200percent() runs on test_CT {
Philipp Maierd65d0562018-08-30 16:25:47 +02002288 var SystemInformation si3 := valueof(ts_SI3_default);
Harald Welte68e495b2018-02-25 00:05:57 +01002289 var PagingTestCfg cfg := {
2290 combined_ccch := true,
Philipp Maierd65d0562018-08-30 16:25:47 +02002291 bs_ag_blks_res := si3.payload.si3.ctrl_chan_desc.bs_ag_blks_res,
Harald Welte68e495b2018-02-25 00:05:57 +01002292 load_factor := 2.0,
2293 exp_load_ind := true,
2294 exp_overload := true,
2295 use_tmsi := false
2296 };
2297 var PagingTestState st := f_TC_paging(cfg);
2298 /* We expect about 80-85% to pass, given that we can fill the paging buffer of 200
2299 * slots and will fully drain that buffer before returning */
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02002300 var template integer tpl := (st.num_paging_sent*78/100 .. st.num_paging_sent *85/100);
Harald Welte68e495b2018-02-25 00:05:57 +01002301 if (not match(st.num_paging_rcv_ids, tpl)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002302 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Expected ", tpl, " pagings but have ", st.num_paging_rcv_ids));
Harald Welte68e495b2018-02-25 00:05:57 +01002303 } else {
2304 setverdict(pass);
2305 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002306 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte68e495b2018-02-25 00:05:57 +01002307}
2308
2309/* Create ~ 200% paging load (TMSI only) sustained for about 20s, verifying that
2310 * - the number of Mobile Identities on Um PCH are ~ 82% of the number of pages on RSL
2311 * - that CCCH LOAD IND (PCH) are being generated and reach 0 at some point
2312 * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */
2313testcase TC_paging_tmsi_200percent() runs on test_CT {
Philipp Maierd65d0562018-08-30 16:25:47 +02002314 var SystemInformation si3 := valueof(ts_SI3_default);
Harald Welte68e495b2018-02-25 00:05:57 +01002315 var PagingTestCfg cfg := {
2316 combined_ccch := true,
Philipp Maierd65d0562018-08-30 16:25:47 +02002317 bs_ag_blks_res := si3.payload.si3.ctrl_chan_desc.bs_ag_blks_res,
Harald Welte68e495b2018-02-25 00:05:57 +01002318 load_factor := 2.0,
2319 exp_load_ind := true,
2320 exp_overload := true,
2321 use_tmsi := true
2322 };
2323 var PagingTestState st := f_TC_paging(cfg);
2324 /* We expect about 70% to pass, given that we can fill the paging buffer of 200
2325 * slots and will fully drain that buffer before returning */
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02002326 var template integer tpl := (st.num_paging_sent*64/100 .. st.num_paging_sent *72/100);
Harald Welte68e495b2018-02-25 00:05:57 +01002327 if (not match(st.num_paging_rcv_ids, tpl)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002328 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Expected ", tpl, " pagings but have ", st.num_paging_rcv_ids));
Harald Welte68e495b2018-02-25 00:05:57 +01002329 } else {
2330 setverdict(pass);
2331 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002332 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte68e495b2018-02-25 00:05:57 +01002333}
2334
2335
Harald Welte93640c62018-02-25 16:59:33 +01002336/***********************************************************************
2337 * Immediate Assignment / AGCH
2338 ***********************************************************************/
Harald Weltee8d750e2018-06-10 21:41:35 +02002339const MobileAllocation c_MA_null := {
2340 len := 0,
2341 ma := ''B
2342}
Harald Welte93640c62018-02-25 16:59:33 +01002343
Harald Weltee8d750e2018-06-10 21:41:35 +02002344template (value) ChannelDescription ts_ChanDesc(template (value) RslChannelNr chan_nr, uint3_t tsc := 7,
2345 uint12_t arfcn := 871) := {
2346 chan_nr := chan_nr,
2347 tsc := tsc,
2348 h := false,
2349 arfcn := arfcn,
2350 maio_hsn := omit
2351}
2352
2353private function f_fmt_ia_stats(integer num_tx, integer num_rx, integer num_del) return charstring {
2354 return int2str(num_tx) & " sent, "
2355 & int2str(num_rx) & " received, "
2356 & int2str(num_del) & " deleted";
2357}
2358
2359private function f_TC_imm_ass(integer num_total, float sleep_s, float exp_pass) runs on test_CT {
2360 var L1ctlDlMessage l1_dl;
2361 timer T := 10.0;
2362 var integer num_tx := 0;
2363 var integer num_rx := 0;
2364 var integer num_del := 0;
2365 var charstring res_str;
2366 var float rx_ratio;
2367
Harald Welte68e495b2018-02-25 00:05:57 +01002368 f_init(testcasename());
Harald Weltee8d750e2018-06-10 21:41:35 +02002369 f_init_l1ctl();
2370 f_l1_tune(L1CTL);
2371
2372 for (var integer i := 0; i < num_total; i := i+1) {
2373 var ChannelDescription ch_desc := valueof(ts_ChanDesc(valueof(t_RslChanNr_SDCCH4(0, 0))));
2374 var GsmRrMessage ia := valueof(ts_IMM_ASS(42, i, 5, ch_desc, c_MA_null));
2375 var octetstring ia_enc := enc_GsmRrMessage(ia);
Harald Welte68e495b2018-02-25 00:05:57 +01002376 RSL_CCHAN.send(ts_RSL_UD(ts_RSL_IMM_ASSIGN(ia_enc, 0)));
Harald Weltee8d750e2018-06-10 21:41:35 +02002377 num_tx := num_tx+1;
2378 f_sleep(sleep_s);
Harald Welte68e495b2018-02-25 00:05:57 +01002379 }
2380 /* FIXME: check if imm.ass arrive on Um side */
Harald Weltee8d750e2018-06-10 21:41:35 +02002381 T.start;
2382 alt {
2383 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_DELETE_IND(?, 0))) {
2384 num_del := num_del+1;
2385 repeat;
2386 }
2387 [] RSL_CCHAN.receive {
2388 repeat;
2389 }
2390 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?)) -> value l1_dl {
2391 /* somehow dec_SystemInformation will try to decode even non-RR as SI */
2392 var GsmRrMessage rr := dec_GsmRrMessage(l1_dl.payload.data_ind.payload);
2393 if (not match(rr, tr_IMM_ASS(42, ?, 5, ?, ?))) {
2394 /* FIXME: Why are we seeing paging requests on PCH/AGCH? */
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002395 //Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Unexpected IMM-ASS values on AGCH: ", rr));
Harald Weltee8d750e2018-06-10 21:41:35 +02002396 } else {
2397 num_rx := num_rx+1;
2398 }
2399 repeat;
2400 }
2401 [] L1CTL.receive { repeat; }
2402 [] T.timeout { }
2403 }
2404 res_str := f_fmt_ia_stats(num_tx, num_rx, num_del);
2405 log("AGCH test: " & res_str);
2406 if (num_rx + num_del != num_tx) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002407 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "RX + DEL != TX ?!?: " & res_str);
Harald Weltee8d750e2018-06-10 21:41:35 +02002408 }
2409 rx_ratio := int2float(num_rx) / int2float(num_tx);
2410 if (rx_ratio < exp_pass*0.8 or rx_ratio > exp_pass*1.2) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002411 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "RX ratio ("&float2str(rx_ratio)&") far from expected ("&float2str(exp_pass)&") " & res_str);
Harald Weltee8d750e2018-06-10 21:41:35 +02002412 } else {
2413 setverdict(pass);
2414 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002415 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte68e495b2018-02-25 00:05:57 +01002416}
2417
Harald Weltee8d750e2018-06-10 21:41:35 +02002418/* send a long burst of 1000 IMM.ASS with 20ms spacing (50 per s); expect 75% of them to be deleted */
2419testcase TC_imm_ass_1000_20ms() runs on test_CT {
2420 f_TC_imm_ass(1000, 0.02, 0.25);
2421}
2422
2423/* send a short burst of 200 IMM.ASS without any spacing; expect 95% of them to be deleted */
2424testcase TC_imm_ass_200_0ms() runs on test_CT {
2425 f_TC_imm_ass(200, 0.0, 0.05);
2426}
2427
2428/* send 150 IMM.ASS at rate of 13/s; expect none of them to be deleted */
2429testcase TC_imm_ass_200_76ms() runs on test_CT {
2430 f_TC_imm_ass(150, 0.076, 1.00);
2431}
2432
2433
2434
Harald Welte48494ca2018-02-25 16:59:50 +01002435/***********************************************************************
2436 * BCCH
2437 ***********************************************************************/
2438
2439/* tuple of Frame Number + decoded SI */
2440type record SystemInformationFn {
2441 GsmFrameNumber frame_number,
2442 SystemInformation si
2443}
2444
2445/* an arbitrary-length vector of decoded SI + gsmtap header */
2446type record of SystemInformationFn SystemInformationVector;
2447
2448/* an array of SI-vectors indexed by TC value */
2449type SystemInformationVector SystemInformationVectorPerTc[8];
2450
2451/* determine if a given SI vector contains given SI type at least once */
2452function f_si_vecslot_contains(SystemInformationVector arr, RrMessageType key, boolean bcch_ext := false) return boolean {
2453 for (var integer i:= 0; i< sizeof(arr); i := i + 1) {
2454 var integer fn_mod51 := arr[i].frame_number mod 51;
2455 if (not bcch_ext and fn_mod51 == 2 or
2456 bcch_ext and fn_mod51 == 6) {
2457 if (arr[i].si.header.message_type == key) {
2458 return true;
2459 }
2460 }
2461 }
2462 return false;
2463}
2464
2465/* ensure a given TC slot of the SI vector contains given SI type at least once at TC */
2466function f_ensure_si_vec_contains(SystemInformationVectorPerTc arr, integer tc, RrMessageType key, boolean ext_bcch := false) {
2467 if (not f_si_vecslot_contains(arr[tc], key, ext_bcch)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002468 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("No ", key, " in TC=", tc, "!"));
Harald Welte48494ca2018-02-25 16:59:50 +01002469 }
2470}
2471
2472/* check if a given SI vector contains given SI type at least once on any TC */
2473function f_si_vec_contains(SystemInformationVectorPerTc arr, RrMessageType key) return boolean {
2474 for (var integer tc:= 0; tc < sizeof(arr); tc := tc + 1) {
2475 if (f_si_vecslot_contains(arr[tc], key) or
2476 f_si_vecslot_contains(arr[tc], key, true)) {
2477 return true;
2478 }
2479 }
2480 return false;
2481}
2482
2483/* determine if a given SI vector contains given SI type at least N of M times */
2484function f_si_vecslot_contains_n_of_m(SystemInformationVector arr, RrMessageType key, boolean bcch_ext := false, integer n := 1, integer m := 4) return boolean {
2485 var integer count := 0;
2486 if (sizeof(arr) < m) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002487 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Error: Insufficient SI in array");
Harald Welte48494ca2018-02-25 16:59:50 +01002488 }
2489 for (var integer i:= 0; i < m; i := i + 1) {
2490 var integer fn_mod51 := arr[i].frame_number mod 51;
2491 if (not bcch_ext and fn_mod51 == 2 or
2492 bcch_ext and fn_mod51 == 6) {
2493 if (arr[i].si.header.message_type == key) {
2494 count := count + 1;
2495 }
2496 }
2497 }
2498 if (count >= n) {
2499 return true;
2500 } else {
2501 return false;
2502 }
2503}
2504
2505/* ensure a given TC slot of the SI vector contains given SI type at least N out of M times at TC */
2506function f_ensure_si_vec_contains_n_of_m(SystemInformationVectorPerTc arr, integer tc, RrMessageType key, boolean ext_bcch := false, integer n, integer m) {
2507 if (not f_si_vecslot_contains_n_of_m(arr[tc], key, ext_bcch, n, m)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002508 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Not ", n, "/", m, " of ", key, " in TC=", tc, "!"));
Harald Welte48494ca2018-02-25 16:59:50 +01002509 }
2510}
2511
2512/* determine if a given SI vector contains given SI type at least once */
2513function f_si_vecslot_contains_only(SystemInformationVector arr, RrMessageType key, boolean bcch_ext := false) return boolean {
2514 for (var integer i:= 0; i< sizeof(arr); i := i + 1) {
2515 var integer fn_mod51 := arr[i].frame_number mod 51;
2516 if (not bcch_ext and fn_mod51 == 2 or
2517 bcch_ext and fn_mod51 == 6) {
2518 if (arr[i].si.header.message_type != key) {
2519 return false;
2520 }
2521 }
2522 }
2523 return true;
2524}
2525
2526/* ensure a given TC slot of the SI vector contains only given SI type */
2527function f_ensure_si_vec_contains_only(SystemInformationVectorPerTc arr, integer tc, RrMessageType key, boolean ext_bcch := false) {
2528 if (not f_si_vecslot_contains_only(arr[tc], key, ext_bcch)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002529 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Not all ", key, " in TC=", tc, "!"));
Harald Welte48494ca2018-02-25 16:59:50 +01002530 }
2531}
2532
2533/* SI configuration of cell, against which we validate actual SI messages */
2534type set SystemInformationConfig {
2535 boolean bcch_extended,
2536 boolean si1_present,
2537 boolean si2bis_present,
2538 boolean si2ter_present,
2539 boolean si2quater_present,
2540 boolean si7_present,
2541 boolean si8_present,
2542 boolean si9_present,
2543 boolean si13_present,
2544 boolean si13alt_present,
2545 boolean si15_present,
2546 boolean si16_present,
2547 boolean si17_present,
2548 boolean si2n_present,
2549 boolean si21_present,
2550 boolean si22_present
2551}
2552
2553/* validate the SI scheduling according to TS 45.002 version 14.1.0 Release 14, Section 6.3.1.3 */
2554function f_validate_si_scheduling(SystemInformationConfig cfg, SystemInformationVectorPerTc si_per_tc) {
2555 var integer i;
2556 for (i := 0; i < sizeof(si_per_tc); i := i + 1) {
2557 if (sizeof(si_per_tc[i]) == 0) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002558 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("No SI messages for TC=", i));
Harald Welte48494ca2018-02-25 16:59:50 +01002559 }
2560 }
2561 if (cfg.si1_present) {
2562 /* ii) System Information Type 1 needs to be sent if frequency hopping is in use or
2563 * when the NCH is present in a cell. If the MS finds another message on BCCH Norm
2564 * when TC = 0, it can assume that System Information Type 1 is not in use. */
2565 f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_1);
2566 /* make sure *ALL* contain SI1 */
2567 f_ensure_si_vec_contains_only(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_1);
2568 }
2569 f_ensure_si_vec_contains(si_per_tc, 1, SYSTEM_INFORMATION_TYPE_2);
2570 /* iii) A SI 2 message will be sent at least every time TC = 1 */
2571 f_ensure_si_vec_contains(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_3);
2572 f_ensure_si_vec_contains(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_3);
2573 f_ensure_si_vec_contains(si_per_tc, 3, SYSTEM_INFORMATION_TYPE_4);
2574 f_ensure_si_vec_contains(si_per_tc, 7, SYSTEM_INFORMATION_TYPE_4);
2575
2576 /* iii) System information type 2 bis or 2 ter messages are sent if needed, as determined by the
2577 * system operator. If only one of them is needed, it is sent when TC = 5. If both are
2578 * needed, 2bis is sent when TC = 5 and 2ter is sent at least once within any of 4
2579 * consecutive occurrences of TC = 4. */
2580 if (cfg.si2bis_present and not cfg.si2ter_present) {
2581 f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2bis);
2582 } else if (cfg.si2ter_present and not cfg.si2bis_present) {
2583 f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2ter);
2584 } else if (cfg.si2ter_present and cfg.si2bis_present) {
2585 f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2bis);
2586 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2ter, false, 1, 4);
2587 }
2588
2589 if (cfg.si7_present or cfg.si8_present) {
2590 /* vi) Use of System Information type 7 and 8 is not always necessary. It is necessary
2591 * if System Information type 4 does not contain all information needed for cell
2592 * selection and reselection. */
2593 if (not cfg.bcch_extended) {
2594 testcase.stop("Error: SI7/SI8 require BCCH Extd.");
2595 }
2596 if (cfg.si7_present) {
2597 f_ensure_si_vec_contains(si_per_tc, 7, SYSTEM_INFORMATION_TYPE_7, true);
2598 }
2599 if (cfg.si8_present) {
2600 f_ensure_si_vec_contains(si_per_tc, 3, SYSTEM_INFORMATION_TYPE_8, true);
2601 }
2602 }
2603
2604 if (cfg.si2quater_present) {
2605 /* iii) System information type 2 quater is sent if needed, as determined by the system
2606 * operator. If sent on BCCH Norm, it shall be sent when TC = 5 if neither of 2bis
2607 * and 2ter are used, otherwise it shall be sent at least once within any of 4
2608 * consecutive occurrences of TC = 4. If sent on BCCH Ext, it is sent at least once
2609 * within any of 4 consecutive occurrences of TC = 5. */
2610 if (not (cfg.bcch_extended)) {
2611 if (not (cfg.si2bis_present or cfg.si2ter_present)) {
2612 f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2quater);
2613 } else {
2614 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2quater, false, 1, 4);
2615 }
2616 } else {
2617 f_ensure_si_vec_contains_n_of_m(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2quater, true, 1, 4);
2618 }
2619 }
2620 if (cfg.si9_present) {
2621 /* vi) System Information type 9 is sent in those blocks with TC = 4 which are specified
2622 * in system information type 3 as defined in 3GPP TS 44.018. */
2623 f_ensure_si_vec_contains(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_9); // FIXME SI3
2624 }
2625 if (cfg.si13_present) {
2626 /* vii) System Information type 13 is only related to the GPRS service. System Information
2627 * Type 13 need only be sent if GPRS support is indicated in one or more of System
2628 * Information Type 3 or 4 or 7 or 8 messages. These messages also indicate if the
2629 * message is sent on the BCCH Norm or if the message is transmitted on the BCCH Ext.
2630 * In the case that the message is sent on the BCCH Norm, it is sent at least once
2631 * within any of 4 consecutive occurrences of TC=4. */
2632 if (not cfg.bcch_extended) {
2633 log("not-bccch-extended");
2634 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_13, false, 1, 4);
2635 } else {
2636 log("bccch-extended");
2637 f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_13, true);
2638 }
2639 if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_13alt)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002640 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Cannot have SI13alt and SI13");
Harald Welte48494ca2018-02-25 16:59:50 +01002641 }
2642 }
2643 if (cfg.si16_present or cfg.si17_present) {
2644 /* viii) System Information type 16 and 17 are only related to the SoLSA service. They
2645 * should not be sent in a cell where network sharing is used (see rule xv). */
2646 if (cfg.si22_present) {
2647 testcase.stop("Error: Cannot have SI16/SI17 and SI22!");
2648 }
2649 if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_22)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002650 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Cannot have SI16/SI17 and SI22!");
Harald Welte48494ca2018-02-25 16:59:50 +01002651 }
2652 if (not cfg.bcch_extended) {
2653 testcase.stop("Error: SI16/SI17 requires BCCH Extd!");
2654 }
2655 if (cfg.si16_present) {
2656 f_ensure_si_vec_contains(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_16, true);
2657 }
2658 if (cfg.si17_present) {
2659 f_ensure_si_vec_contains(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_17, true);
2660 }
2661 }
2662
2663 /* ix) System Information type 18 and 20 are sent in order to transmit non-GSM
2664 * broadcast information. The frequency with which they are sent is determined by the
2665 * system operator. System Information type 9 identifies the scheduling of System
2666 * Information type 18 and 20 messages. */
2667
2668 /* x) System Information Type 19 is sent if COMPACT neighbours exist. If System
2669 * Information Type 19 is present, then its scheduling shall be indicated in System
2670 * Information Type 9. */
2671
2672 if (cfg.si15_present) {
2673 /* xi) System Information Type 15 is broadcast if dynamic ARFCN mapping is used in the
2674 * PLMN. If sent on BCCH Norm, it is sent at least once within any of 4 consecutive
2675 * occurrences of TC = 4. If sent on BCCH Ext, it is sent at least once within any of
2676 * 4 consecutive occurrences of TC = 1. */
2677 if (not cfg.bcch_extended) {
2678 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_15, false, 1, 4);
2679 } else {
2680 f_ensure_si_vec_contains_n_of_m(si_per_tc, 1, SYSTEM_INFORMATION_TYPE_15, true, 1, 4);
2681 }
2682 }
2683 if (cfg.si13alt_present) {
2684 /* xii) System Information type 13 alt is only related to the GERAN Iu mode. System
2685 * Information Type 13 alt need only be sent if GERAN Iu mode support is indicated in
2686 * one or more of System Information Type 3 or 4 or 7 or 8 messages and SI 13 is not
2687 * broadcast. These messages also indicate if the message is sent on the BCCH Norm or
2688 * if the message is transmitted on the BCCH Ext. In the case that the message is sent
2689 * on the BCCH Norm, it is sent at least once within any of 4 consecutive occurrences
2690 * of TC = 4. */
2691 if (cfg.si13_present) {
2692 testcase.stop("Error: Cannot have SI13alt and SI13");
2693 }
2694 if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_13)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002695 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Cannot have SI13alt and SI13");
Harald Welte48494ca2018-02-25 16:59:50 +01002696 }
2697 if (not cfg.bcch_extended) {
2698 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_13alt, false, 1, 4);
2699 } else {
2700 f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_13alt, true);
2701 }
2702 }
2703 if (cfg.si2n_present) {
2704 /* xiii) System Information Type 2n is optionally sent on BCCH Norm or BCCH Ext if needed,
2705 * as determined by the system operator. In the case that the message is sent on the
2706 * BCCH Norm, it is sent at least once within any of 4 consecutive occurrences of TC =
2707 * 4. If the message is sent on BCCH Ext, it is sent at least once within any of 2
2708 * consecutive occurrences of TC = 4. */
2709 if (not cfg.bcch_extended) {
2710 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2n, false, 1, 4);
2711 } else {
2712 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2n, true, 2, 4);
2713 }
2714 }
2715 if (cfg.si21_present) {
2716 /* xiv) System Information Type 21 is optionally sent on BCCH Norm or BCCH Ext, as
2717 * determined by the system operator. If Extended Access Barring is in use in the cell
2718 * then this message is sent at least once within any of 4 consecutive occurrences of
2719 * TC = 4 regardless if it is sent on BCCH Norm or BCCH Ext. If BCCH Ext is used in a
2720 * cell then this message shall only be sent on BCCH Ext. */
2721 if (not cfg.bcch_extended) {
2722 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_21, false, 1, 4);
2723 } else {
2724 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_21, true, 1, 4);
2725 if (f_si_vecslot_contains(si_per_tc[4], SYSTEM_INFORMATION_TYPE_21)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002726 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Cannot have SI21 on BCCH Norm if BCCH Extd enabled!");
Harald Welte48494ca2018-02-25 16:59:50 +01002727 }
2728 }
2729 }
2730 if (cfg.si22_present) {
2731 /* xv) System Information Type 22 is sent if network sharing is in use in the cell. It
2732 * should not be sent in a cell where SoLSA is used (see rule viii). System
2733 * Information Type 22 instances shall be sent on BCCH Ext within any occurrence of TC
2734 * =2 and TC=6. */
2735 if (cfg.si16_present or cfg.si17_present) {
2736 testcase.stop("Error: Cannot have SI16/SI17 and SI22!");
2737 }
2738 if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_16) or
2739 f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_17)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002740 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Cannot have SI16/SI17 and SI22!");
Harald Welte48494ca2018-02-25 16:59:50 +01002741 }
2742 if (not cfg.bcch_extended) {
2743 testcase.stop("Error: SI22 requires BCCH Extd!");
2744 } else {
2745 f_ensure_si_vec_contains_only(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_22, true);
2746 f_ensure_si_vec_contains_only(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_22, true);
2747 }
2748 }
2749}
2750
2751/* sample Systme Information for specified duration via L1CTL */
2752function f_l1_sample_si(L1CTL_PT pt, float duration := 8.0) return SystemInformationVectorPerTc {
2753 timer T := duration;
2754 var SystemInformationVectorPerTc si_per_tc;
2755 var L1ctlDlMessage l1_dl;
2756
2757 /* initialize all per-TC vectors empty */
2758 for (var integer i:= 0; i < sizeof(si_per_tc); i := i+1) {
2759 si_per_tc[i] := {};
2760 }
2761
2762 /* flush all previous L1 queued msgs */
2763 pt.clear;
2764
2765 T.start;
2766 alt {
Harald Weltef8df4cb2018-03-10 15:15:08 +01002767 [] pt.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl {
Harald Welte48494ca2018-02-25 16:59:50 +01002768 /* somehow dec_SystemInformation will try to decode even non-RR as SI */
2769 if (not (l1_dl.payload.data_ind.payload[1] == '06'O)) {
2770 log("Ignoring non-RR SI ", l1_dl);
2771 repeat;
2772 }
2773 var SystemInformationFn sig := {
2774 frame_number := l1_dl.dl_info.frame_nr,
2775 si := dec_SystemInformation(l1_dl.payload.data_ind.payload)
2776 }
2777 var integer tc := f_gsm_compute_tc(sig.frame_number);
2778 log("SI received at TC=", tc, ": ", sig.si);
2779 /* append to the per-TC bucket */
2780 si_per_tc[tc] := si_per_tc[tc] & { sig };
2781 repeat;
2782 }
2783 [] pt.receive { repeat; }
2784 [] T.timeout { }
2785 }
2786
2787 for (var integer i:= 0; i < sizeof(si_per_tc); i := i+1) {
2788 log(testcasename(), ": TC=", i, " has #of SI=", sizeof(si_per_tc[i]));
2789 }
2790 log("si_per_tc=", si_per_tc);
2791 return si_per_tc;
2792}
2793
2794/* helper function: Set given SI via RSL + validate scheduling.
2795 * CALLER MUST MAKE SURE TO CHANGE GLOBAL si_cfg! */
2796function f_TC_si_sched() runs on test_CT {
2797 var SystemInformationVectorPerTc si_per_tc;
2798 f_init_l1ctl();
2799 f_l1_tune(L1CTL);
2800
2801 /* Sample + Validate Scheduling */
2802 si_per_tc := f_l1_sample_si(L1CTL);
2803 f_validate_si_scheduling(si_cfg, si_per_tc);
2804
2805 setverdict(pass);
2806}
2807
2808testcase TC_si_sched_default() runs on test_CT {
2809 f_init();
Harald Welte0cae4552018-03-09 22:20:26 +01002810 /* 2+3+4 are mandatory and set in f_init() */
2811 f_TC_si_sched();
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002812 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte0cae4552018-03-09 22:20:26 +01002813}
2814
2815testcase TC_si_sched_1() runs on test_CT {
2816 f_init();
2817 si_cfg.si1_present := true;
2818 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_1, '5506198fb38000000000000000000000000000e504002b'O);
Harald Welte48494ca2018-02-25 16:59:50 +01002819 f_TC_si_sched();
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002820 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte48494ca2018-02-25 16:59:50 +01002821}
2822
2823testcase TC_si_sched_2bis() runs on test_CT {
2824 f_init();
2825 si_cfg.si2bis_present := true;
2826 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O);
2827 f_TC_si_sched();
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002828 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte48494ca2018-02-25 16:59:50 +01002829}
2830
2831testcase TC_si_sched_2ter() runs on test_CT {
2832 f_init();
2833 si_cfg.si2ter_present := true;
2834 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O);
2835 f_TC_si_sched();
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002836 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte48494ca2018-02-25 16:59:50 +01002837}
2838
2839testcase TC_si_sched_2ter_2bis() runs on test_CT {
2840 f_init();
2841 si_cfg.si2bis_present := true;
2842 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O);
2843 si_cfg.si2ter_present := true;
2844 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O);
2845 f_TC_si_sched();
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002846 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte48494ca2018-02-25 16:59:50 +01002847}
2848
2849testcase TC_si_sched_2quater() runs on test_CT {
2850 f_init();
2851 si_cfg.si2quater_present := true;
2852 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2quater, '050607a8a0364aa698d72ff424feee0506d5e7fff02043'O);
2853 f_TC_si_sched();
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002854 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte48494ca2018-02-25 16:59:50 +01002855}
2856
2857testcase TC_si_sched_13() runs on test_CT {
2858 f_init();
2859 si_cfg.si13_present := true;
Harald Welte5618c2a2018-04-15 16:24:46 +02002860 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_13, '0106009000185a6fc9e08410ab2b2b2b2b2b2b2b2b2b2b'O);
Harald Welte48494ca2018-02-25 16:59:50 +01002861 f_TC_si_sched();
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002862 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte48494ca2018-02-25 16:59:50 +01002863}
2864
2865testcase TC_si_sched_13_2bis_2ter_2quater() runs on test_CT {
2866 f_init();
2867 si_cfg.si2bis_present := true;
2868 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O);
2869 si_cfg.si2ter_present := true;
2870 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O);
2871 si_cfg.si2quater_present := true;
2872 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2quater, '050607a8a0364aa698d72ff424feee0506d5e7fff02043'O);
2873 si_cfg.si13_present := true;
Harald Welte5618c2a2018-04-15 16:24:46 +02002874 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_13, '0106009000185a6fc9e08410ab2b2b2b2b2b2b2b2b2b2b'O);
Harald Welte48494ca2018-02-25 16:59:50 +01002875 f_TC_si_sched();
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002876 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte48494ca2018-02-25 16:59:50 +01002877}
2878
2879
Harald Welte68e495b2018-02-25 00:05:57 +01002880testcase TC_bcch_info() runs on test_CT {
2881 f_init(testcasename());
2882 /* FIXME: enable / disable individual BCCH info */
2883 //ts_RSL_BCCH_INFO(si_type, info);
2884 /* expect no ERROR REPORT after either of them *
2885 /* negative test: ensure ERROR REPORT on unsupported types */
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002886 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte68e495b2018-02-25 00:05:57 +01002887}
2888
Harald Welte93640c62018-02-25 16:59:33 +01002889/***********************************************************************
2890 * Low-Level Protocol Errors / ERROR REPORT
2891 ***********************************************************************/
2892
Harald Welte01d982c2018-02-25 01:31:40 +01002893private function f_exp_err_rep(template RSL_Cause cause) runs on test_CT {
2894 timer T := 5.0;
2895 T.start;
2896 alt {
2897 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_ERROR_REPORT(cause))) {
2898 setverdict(pass);
2899 }
2900 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_ERROR_REPORT(?))) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002901 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Wrong cause in RSL ERR REP");
Harald Welte01d982c2018-02-25 01:31:40 +01002902 }
2903 [] RSL_CCHAN.receive {
2904 repeat;
2905 }
2906 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002907 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RSL ERR REP");
Harald Welte01d982c2018-02-25 01:31:40 +01002908 }
2909 }
2910}
2911
2912/* Provoke a protocol error (message too short) and match on ERROR REPORT */
2913testcase TC_rsl_protocol_error() runs on test_CT {
2914 f_init(testcasename());
2915 var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O));
2916 rsl.ies := omit;
2917 RSL_CCHAN.send(ts_RSL_UD(rsl));
2918
2919 f_exp_err_rep(RSL_ERR_PROTO);
2920}
2921
2922/* Provoke a mandatory IE error and match on ERROR REPORT */
2923testcase TC_rsl_mand_ie_error() runs on test_CT {
2924 f_init(testcasename());
2925
2926 var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O));
2927 rsl.ies := { rsl.ies[0] };
2928 RSL_CCHAN.send(ts_RSL_UD(rsl));
2929
2930 f_exp_err_rep(RSL_ERR_MAND_IE_ERROR);
2931}
2932
2933/* Provoke an IE content error and match on ERROR REPORT */
2934testcase TC_rsl_ie_content_error() runs on test_CT {
2935 f_init(testcasename());
2936 var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O));
2937 rsl.ies[1].body.sysinfo_type := RSL_SYSTEM_INFO_5;
2938 RSL_CCHAN.send(ts_RSL_UD(rsl));
2939
2940 f_exp_err_rep(RSL_ERR_IE_CONTENT);
2941}
2942
Harald Welteee25aae2019-05-19 14:32:37 +02002943/* attempt to activate channel with wrong RSL Message Discriminator IE */
2944function f_TC_chan_act_wrong_mdisc(charstring id) runs on ConnHdlr {
2945 var template RSL_Message rsl := ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode);
2946 rsl.msg_disc := ts_RSL_MsgDisc(RSL_MDISC_RESERVED, false);
2947 RSL.send(rsl);
2948 f_rslem_unregister(0, g_chan_nr);
2949}
2950testcase TC_err_rep_wrong_mdisc() runs on test_CT {
2951 var ConnHdlr vc_conn;
2952 var ConnHdlrPars pars := valueof(t_Pars(ts_RslChanNr_SDCCH4(0,0), ts_RSL_ChanMode_SIGN));
2953
2954 f_init(testcasename());
2955
2956 vc_conn := f_start_handler(refers(f_TC_chan_act_wrong_mdisc), pars);
2957 vc_conn.done;
2958 f_exp_err_rep(RSL_ERR_MSG_DISCR);
2959
2960 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
2961}
2962
2963/* Send messages with wrong message type */
2964function f_TC_wrong_msg_type_dchan(charstring id) runs on ConnHdlr {
2965 var template (value) RSL_Message rsl_tx;
2966 rsl_tx := ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode);
2967 rsl_tx.msg_type := RSL_MT_NOT_CMD;
2968 RSL.send(rsl_tx);
2969 f_rslem_unregister(0, g_chan_nr);
2970}
2971function f_TC_wrong_msg_type_rll(charstring id) runs on ConnHdlr {
2972 var template (value) RSL_Message rsl_tx;
2973 /* we first have to activate the dedicated channel */
2974 f_rsl_chan_act(g_pars.chan_mode);
2975 /* ... to then send an invalid RLL message */
2976 rsl_tx := ts_RSL_UNITDATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0), '0102'O);
2977 rsl_tx.msg_type := RSL_MT_CBCH_LOAD_IND;
2978 RSL.send(rsl_tx);
2979 f_rslem_unregister(0, g_chan_nr);
2980}
2981testcase TC_err_rep_wrong_msg_type() runs on test_CT {
2982 var ConnHdlr vc_conn;
2983 var ConnHdlrPars pars := valueof(t_Pars(ts_RslChanNr_SDCCH4(0,0), ts_RSL_ChanMode_SIGN));
2984 var template (value) RSL_Message rsl_tx;
2985
2986 f_init(testcasename());
2987
2988 /* Common Channel with wrong message type */
2989 RSL_CCHAN.clear;
2990 rsl_tx := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O));
2991 rsl_tx.msg_type := RSL_MT_LOCATION_INFO;
2992 RSL_CCHAN.send(ts_RSL_UD(rsl_tx));
2993 f_exp_err_rep(RSL_ERR_MSG_TYPE);
2994
2995 /* TRX Management */
2996 RSL_CCHAN.clear;
2997 rsl_tx := ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, ''O);
2998 rsl_tx.msg_type := RSL_MT_UNIT_DATA_IND;
2999 RSL_CCHAN.send(ts_RSL_UD(rsl_tx));
3000 f_exp_err_rep(RSL_ERR_MSG_TYPE);
3001
3002 /* Dedicated Channel */
3003 RSL_CCHAN.clear;
3004 vc_conn := f_start_handler(refers(f_TC_wrong_msg_type_dchan), pars);
3005 vc_conn.done;
3006 f_exp_err_rep(RSL_ERR_MSG_TYPE);
3007
3008 /* RLL */
3009 RSL_CCHAN.clear;
3010 vc_conn := f_start_handler(refers(f_TC_wrong_msg_type_rll), pars);
3011 vc_conn.done;
3012 f_exp_err_rep(RSL_ERR_MSG_TYPE);
3013}
3014
3015/* Send messages in wrong sequence (RLL to an inactive lchan) */
3016function f_TC_err_rep_wrong_sequence(charstring id) runs on ConnHdlr {
3017 RSL.send(ts_RSL_UNITDATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0), '0102'O));
3018 f_rslem_unregister(0, g_chan_nr);
3019}
3020testcase TC_err_rep_wrong_sequence() runs on test_CT {
3021 var ConnHdlr vc_conn;
3022 var ConnHdlrPars pars := valueof(t_Pars(ts_RslChanNr_SDCCH4(0,0), ts_RSL_ChanMode_SIGN));
3023
3024 f_init(testcasename());
3025
3026 RSL_CCHAN.clear;
3027 vc_conn := f_start_handler(refers(f_TC_err_rep_wrong_sequence), pars);
3028 vc_conn.done;
3029 f_exp_err_rep(RSL_ERR_MSG_SEQ);
3030}
3031
Harald Welte93640c62018-02-25 16:59:33 +01003032/***********************************************************************
3033 * IPA CRCX/MDCX/DLCS media stream handling
3034 ***********************************************************************/
3035
Harald Weltea871a382018-02-25 02:03:14 +01003036/* Send IPA DLCX to inactive lchan */
3037function f_TC_ipa_dlcx_not_active(charstring id) runs on ConnHdlr {
Harald Welte1eba3742018-02-25 12:48:14 +01003038 f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, 0), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?),
3039 "IPA DLCX ACK");
Harald Weltea871a382018-02-25 02:03:14 +01003040}
3041testcase TC_ipa_dlcx_not_active() runs on test_CT {
3042 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
3043 f_init(testcasename());
3044 var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_dlcx_not_active), pars);
3045 vc_conn.done;
3046}
Harald Welte68e495b2018-02-25 00:05:57 +01003047
Harald Weltea3f1df92018-02-25 12:49:55 +01003048/* Send IPA CRCX twice to inactive lchan */
3049function f_TC_ipa_crcx_twice_not_active(charstring id) runs on ConnHdlr {
3050 f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?),
3051 "IPA CRCX ACK");
3052 f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_NACK(g_chan_nr, RSL_ERR_RES_UNAVAIL),
3053 "IPA CRCX NACK");
3054}
3055testcase TC_ipa_crcx_twice_not_active() runs on test_CT {
3056 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
3057 f_init(testcasename());
3058 var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_twice_not_active), pars);
3059 vc_conn.done;
3060}
3061
3062/* Regular sequence of CRCX/MDCX/DLCX */
3063function f_TC_ipa_crcx_mdcx_dlcx_not_active(charstring id) runs on ConnHdlr {
3064 f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?),
3065 "IPA CRCX ACK");
3066 var uint32_t remote_ip := f_rnd_int(c_UINT32_MAX);
3067 var uint16_t remote_port := f_rnd_int(c_UINT16_MAX);
3068 var uint7_t rtp_pt2 := f_rnd_int(127);
3069 var uint16_t fake_conn_id := 23; /* we're too lazy to read it out from the CRCX ACK above */
3070 f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2),
3071 tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2),
3072 "IPA MDCX ACK");
3073 f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, fake_conn_id), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?),
3074 "IPA DLCX ACK");
3075}
3076testcase TC_ipa_crcx_mdcx_dlcx_not_active() runs on test_CT {
3077 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
3078 f_init(testcasename());
3079 var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_mdcx_dlcx_not_active), pars);
3080 vc_conn.done;
3081}
3082
Harald Welte3ae11da2018-02-25 13:36:06 +01003083/* Sequence of CRCX, 2x MDCX, DLCX */
3084function f_TC_ipa_crcx_mdcx_mdcx_dlcx_not_active(charstring id) runs on ConnHdlr {
3085 f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?),
3086 "IPA CRCX ACK");
3087 var uint32_t remote_ip := f_rnd_int(c_UINT32_MAX);
3088 var uint16_t remote_port := f_rnd_int(c_UINT16_MAX);
3089 var uint7_t rtp_pt2 := f_rnd_int(127);
3090 var uint16_t fake_conn_id := 23; /* we're too lazy to read it out from the CRCX ACK above */
3091 f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2),
3092 tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2),
3093 "IPA MDCX ACK");
3094 /* Second MDCX */
3095 remote_ip := f_rnd_int(c_UINT32_MAX);
3096 remote_port := f_rnd_int(c_UINT16_MAX);
3097 f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2),
3098 tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2),
3099 "IPA MDCX ACK");
3100 f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, fake_conn_id), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?),
3101 "IPA DLCX ACK");
3102}
3103testcase TC_ipa_crcx_mdcx_mdcx_dlcx_not_active() runs on test_CT {
3104 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
3105 f_init(testcasename());
3106 var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_mdcx_mdcx_dlcx_not_active), pars);
3107 vc_conn.done;
3108}
3109
Harald Welte9912eb52018-02-25 13:30:15 +01003110/* IPA CRCX on SDCCH/4 and SDCCH/8 (doesn't make sense) */
3111function f_TC_ipa_crcx_sdcch_not_active(charstring id) runs on ConnHdlr {
3112 f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_NACK(g_chan_nr, ?),
3113 "IPA CRCX NACK");
3114}
3115testcase TC_ipa_crcx_sdcch_not_active() runs on test_CT {
3116 var ConnHdlrPars pars;
3117 var ConnHdlr vc_conn;
3118 f_init(testcasename());
3119
3120 pars := valueof(t_Pars(t_RslChanNr_SDCCH4(0,1), ts_RSL_ChanMode_SIGN));
3121 vc_conn := f_start_handler(refers(f_TC_ipa_crcx_sdcch_not_active), pars);
3122 vc_conn.done;
3123
3124 pars := valueof(t_Pars(t_RslChanNr_SDCCH8(6,5), ts_RSL_ChanMode_SIGN));
3125 vc_conn := f_start_handler(refers(f_TC_ipa_crcx_sdcch_not_active), pars);
3126 vc_conn.done;
3127}
3128
Harald Weltea3f1df92018-02-25 12:49:55 +01003129
Harald Welte883340c2018-02-28 18:59:29 +01003130/***********************************************************************
3131 * PCU Socket related tests
3132 ***********************************************************************/
3133
3134private function f_TC_pcu_act_req(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr, boolean exp_success)
3135runs on test_CT {
3136 timer T := 3.0;
3137
3138 /* we don't expect any RTS.req before PDCH are active */
3139 T.start;
3140 alt {
3141 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(bts_nr))) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003142 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "PCU RTS.req before PDCH active?");
Harald Welte883340c2018-02-28 18:59:29 +01003143 }
3144 [] PCU.receive { repeat; }
3145 [] T.timeout { }
3146 }
3147
3148 /* Send PDCH activate request for known PDCH timeslot */
3149 PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, ts_nr)));
3150
3151 /* we now expect RTS.req for this timeslot (only) */
3152 T.start;
3153 alt {
3154 [exp_success] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr))) {
3155 setverdict(pass);
3156 }
3157 [not exp_success] PCU.receive(t_SD_PCUIF(g_pcu_conn_id,
3158 tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr))) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003159 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RTS.req for supposedly failing activation");
Harald Welte883340c2018-02-28 18:59:29 +01003160 }
3161 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003162 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "RTS.req for wrong TRX/TS");
Harald Welte883340c2018-02-28 18:59:29 +01003163 }
3164 [] PCU.receive { repeat; }
3165 [exp_success] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003166 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PCU RTS.req");
Harald Welte883340c2018-02-28 18:59:29 +01003167 }
3168 [not exp_success] T.timeout {
3169 setverdict(pass);
3170 }
3171 }
3172}
3173
3174private function f_TC_pcu_deact_req(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr)
3175runs on test_CT {
3176 timer T := 3.0;
3177
3178 /* Send PDCH activate request for known PDCH timeslot */
3179 PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_DEACT_REQ(bts_nr, trx_nr, ts_nr)));
3180
3181 PCU.clear;
3182 /* we now expect no RTS.req for this timeslot */
3183 T.start;
3184 alt {
3185 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr))) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003186 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received unexpected PCU RTS.req");
Harald Welte883340c2018-02-28 18:59:29 +01003187 }
3188 [] PCU.receive { repeat; }
3189 [] T.timeout {
3190 setverdict(pass);
3191 }
3192 }
3193}
3194
Max2c6f5632019-03-18 17:25:17 +01003195private function f_init_pcu_test() runs on test_CT {
3196 f_init();
3197 PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_TXT_IND(0, PCU_VERSION, testcasename())));
3198}
3199
Harald Welte883340c2018-02-28 18:59:29 +01003200/* PDCH activation via PCU socket; check for presence of RTS.req */
3201testcase TC_pcu_act_req() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01003202 f_init_pcu_test();
3203
Harald Welte883340c2018-02-28 18:59:29 +01003204 f_TC_pcu_act_req(0, 0, 7, true);
3205}
3206
3207/* PDCH activation via PCU socket on non-PDCU timeslot */
3208testcase TC_pcu_act_req_wrong_ts() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01003209 f_init_pcu_test();
3210
Harald Welte883340c2018-02-28 18:59:29 +01003211 f_TC_pcu_act_req(0, 0, 1, false);
3212}
3213
3214/* PDCH activation via PCU socket on wrong BTS */
3215testcase TC_pcu_act_req_wrong_bts() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01003216 f_init_pcu_test();
3217
Harald Welte883340c2018-02-28 18:59:29 +01003218 f_TC_pcu_act_req(23, 0, 7, false);
3219}
3220
3221/* PDCH activation via PCU socket on wrong TRX */
3222testcase TC_pcu_act_req_wrong_trx() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01003223 f_init_pcu_test();
3224
Harald Welte883340c2018-02-28 18:59:29 +01003225 f_TC_pcu_act_req(0, 23, 7, false);
3226}
3227
3228/* PDCH deactivation via PCU socket; check for absence of RTS.req */
3229testcase TC_pcu_deact_req() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01003230 f_init_pcu_test();
3231
Harald Welte883340c2018-02-28 18:59:29 +01003232 /* Activate PDCH */
3233 f_TC_pcu_act_req(0, 0, 7, true);
3234 f_sleep(1.0);
3235 /* and De-Activate again */
3236 f_TC_pcu_deact_req(0, 0, 7);
3237}
3238
3239/* Attempt to deactivate a PDCH on a non-PDCH timeslot */
3240testcase TC_pcu_deact_req_wrong_ts() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01003241 f_init_pcu_test();
3242
Harald Welte883340c2018-02-28 18:59:29 +01003243 f_TC_pcu_deact_req(0, 0, 1);
3244}
3245
3246/* Test the PCU->BTS Version and BTS->PCU SI13 handshake */
3247testcase TC_pcu_ver_si13() runs on test_CT {
3248 const octetstring si13 := '00010203040506070909'O;
3249 var PCUIF_send_data sd;
3250 timer T:= 3.0;
Max2c6f5632019-03-18 17:25:17 +01003251 f_init_pcu_test();
Harald Welte883340c2018-02-28 18:59:29 +01003252
3253 /* Set SI13 via RSL */
3254 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_13, si13);
Max2c6f5632019-03-18 17:25:17 +01003255
Harald Welte883340c2018-02-28 18:59:29 +01003256 T.start;
3257 alt {
3258 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_DATA_IND(0, 0, 0, ?, PCU_IF_SAPI_BCCH))) -> value sd {
3259 if (substr(sd.data.u.data_ind.data, 0, lengthof(si13)) == si13) {
3260 setverdict(pass);
3261 } else {
3262 repeat;
3263 }
3264 }
3265 [] PCU.receive { repeat; }
3266 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003267 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for SI13");
Harald Welte883340c2018-02-28 18:59:29 +01003268 }
3269 }
3270}
3271
3272private const octetstring c_PCU_DATA := '000102030405060708090a0b0c0d0e0f10111213141516'O;
3273
3274/* helper function to send a PCU DATA.req */
3275private function f_pcu_data_req(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr,
3276 uint8_t block_nr, uint32_t fn, PCUIF_Sapi sapi, octetstring data)
3277runs on test_CT
3278{
3279 PCU.send(t_SD_PCUIF(g_pcu_conn_id,
3280 ts_PCUIF_DATA_REQ(bts_nr, trx_nr, ts_nr, block_nr, fn, sapi, data)));
3281}
3282
3283/* helper function to wait for RTS.ind for given SAPI on given BTS/TRX/TS and then send */
3284private function f_pcu_wait_rts_and_data_req(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr,
3285 PCUIF_Sapi sapi, octetstring data)
3286runs on test_CT
3287{
3288 var PCUIF_send_data sd;
3289
3290 timer T := 3.0;
3291 T.start;
3292 alt {
3293 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id,
3294 tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr, sapi))) -> value sd {
3295 f_pcu_data_req(bts_nr, trx_nr, ts_nr, sd.data.u.rts_req.block_nr,
3296 sd.data.u.rts_req.fn, sapi, data);
3297 }
3298 [] PCU.receive { repeat; }
3299 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003300 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RTS.ind");
Harald Welte883340c2018-02-28 18:59:29 +01003301 }
3302 }
3303}
3304
3305/* Send DATA.req on invalid BTS */
3306testcase TC_pcu_data_req_wrong_bts() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01003307 f_init_pcu_test();
3308
Harald Welte883340c2018-02-28 18:59:29 +01003309 f_TC_pcu_act_req(0, 0, 7, true);
3310 f_pcu_data_req(23, 0, 7, 0, 0, PCU_IF_SAPI_PDTCH, c_PCU_DATA);
3311 /* FIXME: how to check this wasn't actually sent and didn't crash BTS? */
3312 f_sleep(10.0);
3313}
3314
3315/* Send DATA.req on invalid TRX */
3316testcase TC_pcu_data_req_wrong_trx() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01003317 f_init_pcu_test();
3318
Harald Welte883340c2018-02-28 18:59:29 +01003319 f_TC_pcu_act_req(0, 0, 7, true);
3320 f_pcu_data_req(0, 100, 7, 0, 0, PCU_IF_SAPI_PDTCH, c_PCU_DATA);
3321 /* FIXME: how to check this wasn't actually sent and didn't crash BTS? */
3322 f_sleep(10.0);
3323}
3324
3325/* Send DATA.req on invalid timeslot */
3326testcase TC_pcu_data_req_wrong_ts() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01003327 f_init_pcu_test();
3328
Harald Welte883340c2018-02-28 18:59:29 +01003329 f_TC_pcu_act_req(0, 0, 7, true);
3330 f_pcu_data_req(0, 0, 70, 0, 0, PCU_IF_SAPI_PDTCH, c_PCU_DATA);
3331 /* FIXME: how to check this wasn't actually sent and didn't crash BTS? */
3332 f_sleep(10.0);
3333}
3334
3335/* Send DATA.req on timeslot that hasn't been activated */
3336testcase TC_pcu_data_req_ts_inactive() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01003337 f_init_pcu_test();
3338
Harald Welte883340c2018-02-28 18:59:29 +01003339 f_pcu_data_req(0, 0, 7, 0, 0, PCU_IF_SAPI_PDTCH, c_PCU_DATA);
3340 /* FIXME: how to check this wasn't actually sent and didn't crash BTS? */
3341 f_sleep(2.0);
3342}
3343
3344testcase TC_pcu_data_req_pdtch() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01003345 f_init_pcu_test();
3346
Harald Welte883340c2018-02-28 18:59:29 +01003347 f_TC_pcu_act_req(0, 0, 7, true);
3348 f_pcu_wait_rts_and_data_req(0, 0, 7, PCU_IF_SAPI_PDTCH, c_PCU_DATA);
3349 /* FIXME: how to check this was actually sent */
3350 f_sleep(2.0);
3351}
3352
3353testcase TC_pcu_data_req_ptcch() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01003354 f_init_pcu_test();
3355
Harald Welte883340c2018-02-28 18:59:29 +01003356 f_TC_pcu_act_req(0, 0, 7, true);
3357 f_pcu_wait_rts_and_data_req(0, 0, 7, PCU_IF_SAPI_PTCCH, c_PCU_DATA);
3358 /* FIXME: how to check this was actually sent */
3359 f_sleep(2.0);
3360}
3361
3362/* Send AGCH from PCU; check it appears on Um side */
3363testcase TC_pcu_data_req_agch() runs on test_CT {
3364 timer T := 3.0;
Max2c6f5632019-03-18 17:25:17 +01003365 f_init_pcu_test();
Harald Welte883340c2018-02-28 18:59:29 +01003366 f_init_l1ctl();
3367 f_l1_tune(L1CTL);
3368
3369 f_TC_pcu_act_req(0, 0, 7, true);
3370 f_pcu_data_req(0, 0, 7, 0, 0, PCU_IF_SAPI_AGCH, c_PCU_DATA);
3371
3372 T.start;
3373 alt {
Harald Weltef8df4cb2018-03-10 15:15:08 +01003374 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?, c_PCU_DATA)) {
Harald Welte883340c2018-02-28 18:59:29 +01003375 setverdict(pass);
3376 }
3377 [] L1CTL.receive { repeat; }
3378 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003379 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PCU-originated AGCH block on Um");
Harald Welte883340c2018-02-28 18:59:29 +01003380 }
3381 }
3382}
3383
3384/* Send IMM.ASS from PCU for PCH; check it appears on Um side */
3385testcase TC_pcu_data_req_imm_ass_pch() runs on test_CT {
3386 var octetstring imm_ass := f_rnd_octstring(23);
Max2c6f5632019-03-18 17:25:17 +01003387 f_init_pcu_test();
Harald Welte883340c2018-02-28 18:59:29 +01003388 f_init_l1ctl();
3389 f_l1_tune(L1CTL);
3390
3391 /* append 3 last imsi digits so BTS can compute pagng group */
3392 var uint32_t fn := f_PCUIF_tx_imm_ass_pch(PCU, g_pcu_conn_id, imm_ass, '123459987'H);
3393
3394 timer T := 0.5;
3395 T.start;
3396 alt {
Harald Weltef8df4cb2018-03-10 15:15:08 +01003397 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?, imm_ass)) {
Harald Welte883340c2018-02-28 18:59:29 +01003398 /* TODO: verify paging group */
3399 setverdict(pass);
3400 }
3401 [] L1CTL.receive { repeat; }
3402 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003403 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PCU-originated AGCH block on Um");
Harald Welte883340c2018-02-28 18:59:29 +01003404 }
3405 }
3406}
3407
3408/* Send RACH from Um side, expect it to show up on PCU socket */
3409testcase TC_pcu_rach_content() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01003410 f_init_pcu_test();
Harald Welte883340c2018-02-28 18:59:29 +01003411 f_init_l1ctl();
3412 f_l1_tune(L1CTL);
3413
3414 var GsmFrameNumber fn_last := 0;
3415 for (var integer i := 0; i < 1000; i := i+1) {
3416 var OCT1 ra := f_rnd_ra_ps();
3417 var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra));
3418 if (fn == fn_last) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003419 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?");
Harald Welte883340c2018-02-28 18:59:29 +01003420 }
3421 fn_last := fn;
3422
3423 timer T := 2.0;
3424 T.start;
3425 alt {
3426 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RACH_IND(0, oct2int(ra), 0, ?, fn))) {
3427 T.stop;
3428 }
3429 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RACH_IND)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003430 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RACH IND");
Harald Welte883340c2018-02-28 18:59:29 +01003431 }
3432 [] PCU.receive { repeat; }
3433 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003434 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RACH IND");
Harald Welte883340c2018-02-28 18:59:29 +01003435 }
3436 }
3437 }
3438 setverdict(pass);
3439}
3440
Vadim Yanitskiy51cbc102019-04-22 06:37:30 +07003441/* Send extended (11-bit, TS1 & TS2) RACH bursts from the Um side,
3442 * expect them to show up on PCU socket (with proper BURST_TYPE_*). */
3443testcase TC_pcu_ext_rach_content() runs on test_CT {
3444 var template PCUIF_Message pcu_rach_ind;
3445 var GsmFrameNumber fn_last := 0;
3446 var L1ctlRachSynchSeq synch_seq;
3447 var PCUIF_BurstType pcu_bt;
3448 var GsmFrameNumber fn;
3449 var BIT11 ra11;
3450
3451 f_init_pcu_test();
3452 f_init_l1ctl();
3453 f_l1_tune(L1CTL);
3454
3455 for (var integer i := 0; i < 1000; i := i+1) {
3456 /* We need to test both TS1 & TS2 */
3457 if (i rem 2 == 0) {
3458 synch_seq := RACH_SYNCH_SEQ_TS1;
3459 pcu_bt := BURST_TYPE_1;
3460 } else {
3461 synch_seq := RACH_SYNCH_SEQ_TS2;
3462 pcu_bt := BURST_TYPE_2;
3463 }
3464
3465 ra11 := f_rnd_ra11_ps();
3466 fn := f_L1CTL_EXT_RACH(L1CTL, bit2int(ra11), synch_seq);
3467 if (fn == fn_last) {
3468 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
3469 "Two RACH in same FN?!?");
3470 }
3471 fn_last := fn;
3472
3473 /* Compose the expected message */
3474 pcu_rach_ind := tr_PCUIF_RACH_IND(
3475 bts_nr := 0,
3476 ra := bit2int(ra11),
3477 is_11bit := 1,
3478 burst_type := pcu_bt,
3479 fn := fn);
3480
3481 timer T := 2.0;
3482 T.start;
3483 alt {
3484 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, pcu_rach_ind)) {
3485 T.stop;
3486 }
3487 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RACH_IND)) {
3488 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RACH IND");
3489 }
3490 [] PCU.receive { repeat; }
3491 [] T.timeout {
3492 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RACH IND");
3493 }
3494 }
3495 }
3496 setverdict(pass);
3497}
3498
Harald Welte883340c2018-02-28 18:59:29 +01003499private function f_pad_oct(octetstring str, integer len, OCT1 pad) return octetstring {
3500 var integer strlen := lengthof(str);
3501 for (var integer i := 0; i < len-strlen; i := i+1) {
3502 str := str & pad;
3503 }
3504 return str;
3505}
3506
3507/* Send PAGING via RSL, expect it to shw up on PCU socket */
3508testcase TC_pcu_paging_from_rsl() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01003509 f_init_pcu_test();
Harald Welte883340c2018-02-28 18:59:29 +01003510
3511 for (var integer i := 0; i < 100; i := i+1) {
3512 var MobileL3_CommonIE_Types.MobileIdentityLV mi;
3513 timer T := 3.0;
3514 if (i < 50) {
3515 mi := valueof(ts_MI_TMSI_LV(f_rnd_octstring(4)));
3516 } else {
3517 mi := valueof(ts_MI_IMSI_LV(f_gen_imsi(i)));
3518 }
3519 var octetstring mi_enc_lv := enc_MobileIdentityLV(mi);
3520 var octetstring mi_enc := substr(mi_enc_lv, 1, lengthof(mi_enc_lv)-1);
3521 var octetstring t_mi_lv := f_pad_oct(mi_enc_lv, 9, '00'O);
3522
3523 /* Send RSL PAGING COMMAND */
3524 RSL_CCHAN.send(ts_RSL_UD(ts_RSL_PAGING_CMD(mi_enc, i mod 4)));
3525 T.start;
3526 alt {
3527 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_PAG_REQ(0, t_mi_lv))) {
3528 }
3529 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_PAG_REQ)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003530 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected PAGING REQ");
Harald Welte883340c2018-02-28 18:59:29 +01003531 }
3532 [] PCU.receive { repeat; }
3533 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003534 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PAGING REQ");
Harald Welte883340c2018-02-28 18:59:29 +01003535 }
3536 }
3537 }
3538 setverdict(pass);
3539}
3540
Harald Welted66c9b82019-05-25 09:03:15 +02003541/* test for periodic TIME_IND; check number of FN expired and number of TIME_IND within frames */
3542testcase TC_pcu_time_ind() runs on test_CT {
3543 var PCUIF_send_data pcu_sd;
3544 var integer num_time_ind := 0;
3545 var integer first_fn, last_fn;
3546 var float test_duration := 5.0;
3547 timer T;
3548
3549 f_init_pcu_test();
3550 f_TC_pcu_act_req(0, 0, 7, true);
3551
3552 PCU.clear;
3553 T.start(test_duration);
3554 alt {
3555 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_TIME_IND(0, ?))) -> value pcu_sd {
3556 num_time_ind := num_time_ind + 1;
3557 if (not isbound(first_fn)) {
3558 first_fn := pcu_sd.data.u.time_ind.fn;
3559 }
3560 last_fn := pcu_sd.data.u.time_ind.fn;
3561 repeat;
3562 }
3563 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_TIME_IND(?, ?))) -> value pcu_sd {
3564 setverdict(fail, "Received unexpected PCUIF_TIME_IND: ", pcu_sd.data);
3565 repeat;
3566 }
3567 [] PCU.receive {
3568 repeat;
3569 }
3570 [] T.timeout {}
3571 }
3572 var integer fn_expired := last_fn - first_fn;
3573 log(fn_expired, " fn expired with ", num_time_ind, " PCU_TIME.ind");
3574
3575 /* verify the number of frames expired matches our expectation */
3576 const float c_GSM_FN_DURATION_MS := 4.61538;
3577 var float fn_expected := test_duration * 1000.0 / c_GSM_FN_DURATION_MS;
3578 var template integer t_fn_expected := f_tolerance(float2int(fn_expected), 1, 100000, 10);
3579 if (not match(fn_expired, t_fn_expected)) {
3580 setverdict(fail, "Number of TDMA Frames (", fn_expired, ") not matching ", t_fn_expected);
3581 }
3582
3583 /* There are three TIME.ind in every fn MOD 13 */
3584 var float time_ind_expected := int2float(fn_expired) * 3.0 / 13.0;
3585 /* Add some tolerance */
3586 var template integer t_time_ind_exp := f_tolerance(float2int(time_ind_expected), 1, 100000, 5);
3587 if (not match(num_time_ind, t_time_ind_exp)) {
3588 setverdict(fail, "Number of TIME.ind (", num_time_ind, ") not matching ", t_time_ind_exp);
3589 }
3590
3591 setverdict(pass);
3592}
3593
3594
Harald Welte3d04ae62018-04-04 20:29:05 +02003595/***********************************************************************
Harald Welte9bbbfb52018-04-05 09:33:19 +02003596 * Osmocom Style Dynamic Timeslot Support
Harald Welte3d04ae62018-04-04 20:29:05 +02003597 ***********************************************************************/
3598
3599private function f_dyn_osmo_pdch_act(integer pcu_conn_id, integer bts_nr, integer trx_nr)
3600runs on ConnHdlr {
3601 var PCUIF_send_data sd;
3602 /* Expect BTS to immediately acknowledge activation as PDCH */
3603 PCU.clear;
3604 f_rsl_chan_act(g_pars.chan_mode);
3605 /* expect INFO_IND on PCU interface listing TS as PDCH */
3606 alt {
3607 [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(bts_nr, ?))) -> value sd {
3608 if (substr(sd.data.u.info_ind.trx[trx_nr].pdch_mask, g_chan_nr.tn, 1) != '1'B) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003609 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "PCUIF_INFO_IND PDCH_MASK not '1' after PDCH ACT");
Harald Welte3d04ae62018-04-04 20:29:05 +02003610 }
3611 }
3612 [] PCU.receive { repeat; }
3613 }
3614 /* try to activate this PDCH from the PCU point of view */
3615 PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, g_chan_nr.tn)));
3616 /* FIXME: is there a response? */
3617}
3618
3619private function f_dyn_osmo_pdch_deact(integer pcu_conn_id, integer bts_nr, integer trx_nr)
3620runs on ConnHdlr {
3621 var PCUIF_send_data sd;
3622 /* Send RSL CHAN REL (deactivate) */
3623 PCU.clear;
3624 RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr));
3625 /* expect BTS to ask PCU to deactivate the channel */
3626 alt {
3627 [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(bts_nr, ?))) -> value sd {
3628 if (substr(sd.data.u.info_ind.trx[trx_nr].pdch_mask, g_chan_nr.tn, 1) != '0'B) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003629 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "PCUIF_INFO_IND PDCH_MASK not '0' after PDCH DEACT");
Harald Welte3d04ae62018-04-04 20:29:05 +02003630 }
3631 }
3632 [] PCU.receive { repeat; }
3633 }
3634 /* Emulate PCU asking BTS to deactivate PDCH */
3635 PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_DEACT_REQ(bts_nr, trx_nr, g_chan_nr.tn)));
3636 alt {
3637 [] RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr)) {
3638 setverdict(pass);
3639 }
3640 [] RSL.receive { repeat; }
3641 }
3642}
3643
3644/* Activate Osmocom-style dynamic PDCH from BSC side */
3645function f_TC_dyn_osmo_pdch_act_deact(charstring id) runs on ConnHdlr {
3646 var PCUIF_Message first_info;
3647 var integer ts_nr := g_chan_nr.tn;
3648 var integer trx_nr := 0;
3649 var integer bts_nr := 0;
3650 var integer pcu_conn_id := -1;
3651
3652 f_init_pcu(PCU, id, pcu_conn_id, first_info);
3653
3654 f_dyn_osmo_pdch_act(pcu_conn_id, bts_nr, trx_nr);
3655 f_sleep(3.0);
3656 f_dyn_osmo_pdch_deact(pcu_conn_id, bts_nr, trx_nr);
3657 setverdict(pass);
3658}
3659testcase TC_dyn_osmo_pdch_act_deact() runs on test_CT {
3660 var ConnHdlrPars pars;
3661 var ConnHdlr vc_conn;
3662 f_init(testcasename());
3663
3664 pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN));
3665 vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_act_deact), pars, true);
3666 vc_conn.done;
3667}
3668
3669/* send a RF CHAN REL for PDCH on an osmocom dynamci PDCH that's already inactive */
3670function f_TC_dyn_osmo_pdch_unsol_deact(charstring id) runs on ConnHdlr {
3671 var PCUIF_Message first_info;
Harald Welte3d04ae62018-04-04 20:29:05 +02003672 var integer pcu_conn_id := -1;
3673
3674 f_init_pcu(PCU, id, pcu_conn_id, first_info);
3675
Neels Hofmeyr9c50ca52018-05-08 20:37:54 +02003676 RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr));
3677 /* since the lchan is already released, we don't expect any PCU changes, just a rel ack. */
3678 RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr));
Harald Welte3d04ae62018-04-04 20:29:05 +02003679 setverdict(pass);
3680}
3681testcase TC_dyn_osmo_pdch_unsol_deact() runs on test_CT {
3682 var ConnHdlrPars pars;
3683 var ConnHdlr vc_conn;
3684 f_init(testcasename());
3685
3686 pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN));
3687 vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_unsol_deact), pars, true);
3688 vc_conn.done;
3689}
3690
3691/* try to RSL CHAN ACT a PDCH on an osmocom-style PDCH that's already active */
3692function f_TC_dyn_osmo_pdch_double_act(charstring id) runs on ConnHdlr {
3693 var PCUIF_Message first_info;
3694 var integer ts_nr := g_chan_nr.tn;
3695 var integer trx_nr := 0;
3696 var integer bts_nr := 0;
3697 var integer pcu_conn_id := -1;
3698
3699 f_init_pcu(PCU, id, pcu_conn_id, first_info);
3700
3701 f_dyn_osmo_pdch_act(pcu_conn_id, bts_nr, trx_nr);
Neels Hofmeyrdf936a22018-05-08 22:07:57 +02003702 /* Send a second Chan Activ and expect it to be NACKed */
3703 f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_NACK(g_chan_nr),
3704 "RSL CHAN ACT NACK");
Harald Welte3d04ae62018-04-04 20:29:05 +02003705 setverdict(pass);
3706}
3707testcase TC_dyn_osmo_pdch_double_act() runs on test_CT {
3708 var ConnHdlrPars pars;
3709 var ConnHdlr vc_conn;
3710 f_init(testcasename());
3711
3712 pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN));
3713 vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_double_act), pars, true);
3714 vc_conn.done;
3715}
3716
3717/* try to RSL CHAN ACT a TCH/F on an osmocom-style PDCH */
3718function f_TC_dyn_osmo_pdch_tchf_act(charstring id) runs on ConnHdlr {
3719 var PCUIF_Message first_info;
3720 var integer ts_nr := g_chan_nr.tn;
3721 var integer trx_nr := 0;
3722 var integer bts_nr := 0;
3723 var integer pcu_conn_id := -1;
3724 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(g_chan_nr.tn));
3725
3726 /* register for the TCH/F channel number */
3727 f_rslem_register(0, chan_nr);
3728
3729 f_init_pcu(PCU, id, pcu_conn_id, first_info);
3730
3731 f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_ACK(chan_nr),
3732 "RSL CHAN ACT");
3733 setverdict(pass);
3734}
3735testcase TC_dyn_osmo_pdch_tchf_act() runs on test_CT {
3736 var ConnHdlrPars pars;
3737 var ConnHdlr vc_conn;
3738 f_init(testcasename());
3739
3740 pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN));
3741 vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_tchf_act), pars, true);
3742 vc_conn.done;
3743}
3744
3745/* try to RSL CHAN ACT the TCH/H on an osmocom-style PDCH */
3746function f_TC_dyn_osmo_pdch_tchh_act(charstring id) runs on ConnHdlr {
3747 var PCUIF_Message first_info;
3748 var integer ts_nr := g_chan_nr.tn;
3749 var integer trx_nr := 0;
3750 var integer bts_nr := 0;
3751 var integer pcu_conn_id := -1;
3752 var RslChannelNr chan_nr[2] := { valueof(t_RslChanNr_Lm(g_chan_nr.tn, 0)),
3753 valueof(t_RslChanNr_Lm(g_chan_nr.tn, 1)) };
3754
3755 /* register for the TCH/H channel numbers */
3756 f_rslem_register(0, chan_nr[0]);
3757 f_rslem_register(0, chan_nr[1]);
3758
3759 f_init_pcu(PCU, id, pcu_conn_id, first_info);
3760
3761 f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr[1], g_pars.chan_mode),
3762 tr_RSL_CHAN_ACT_ACK(chan_nr[1]), "RSL CHAN ACT [1]");
3763 f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr[0], g_pars.chan_mode),
3764 tr_RSL_CHAN_ACT_ACK(chan_nr[0]), "RSL CHAN ACT [0]");
3765 setverdict(pass);
3766}
3767testcase TC_dyn_osmo_pdch_tchh_act() runs on test_CT {
3768 var ConnHdlrPars pars;
3769 var ConnHdlr vc_conn;
3770 f_init(testcasename());
3771
3772 pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN));
3773 vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_tchh_act), pars, true);
3774 vc_conn.done;
3775}
3776
Harald Welte9bbbfb52018-04-05 09:33:19 +02003777/***********************************************************************
3778 * IPA Style Dynamic Timeslot Support
3779 ***********************************************************************/
3780
3781private function f_dyn_ipa_pdch_act(integer pcu_conn_id, integer bts_nr, integer trx_nr)
3782runs on ConnHdlr {
3783 var PCUIF_send_data sd;
3784 /* Expect BTS to immediately acknowledge activation as PDCH */
3785 PCU.clear;
3786 RSL.send(ts_RSL_IPA_PDCH_ACT(g_chan_nr));
3787 /* expect INFO_IND on PCU interface listing TS as PDCH */
Pau Espin Pedrol446e07b2019-02-18 21:18:36 +01003788 timer T_wait := 2.0;
3789 T_wait.start;
Harald Welte9bbbfb52018-04-05 09:33:19 +02003790 alt {
3791 [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(bts_nr, ?))) -> value sd {
3792 if (substr(sd.data.u.info_ind.trx[trx_nr].pdch_mask, g_chan_nr.tn, 1) != '1'B) {
Pau Espin Pedrol446e07b2019-02-18 21:18:36 +01003793 log("PCUIF_INFO_IND PDCH_MASK not yet '1' after PDCH ACT on TS", g_chan_nr.tn,
3794 " mask:", sd.data.u.info_ind.trx[trx_nr].pdch_mask);
3795 repeat;
Harald Welte9bbbfb52018-04-05 09:33:19 +02003796 }
3797 }
3798 [] PCU.receive { repeat; }
Pau Espin Pedrol446e07b2019-02-18 21:18:36 +01003799 [] T_wait.timeout {
3800 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
3801 log2str("Timeout waiting for PCUIF_INFO_IND PDCH_MASK to be '1' on TS", g_chan_nr.tn));
3802 }
Harald Welte9bbbfb52018-04-05 09:33:19 +02003803 }
3804 /* try to activate this PDCH from the PCU point of view */
3805 PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, g_chan_nr.tn)));
3806 /* FIXME: is there a response? */
3807
3808 RSL.receive(tr_RSL_IPA_PDCH_ACT_ACK(g_chan_nr, ?));
3809}
3810
3811private function f_dyn_ipa_pdch_deact(integer pcu_conn_id, integer bts_nr, integer trx_nr)
3812runs on ConnHdlr {
3813 var PCUIF_send_data sd;
3814 /* Send RSL CHAN REL (deactivate) */
3815 RSL.send(ts_RSL_IPA_PDCH_DEACT(g_chan_nr));
3816 PCU.clear;
3817 /* expect BTS to ask PCU to deactivate the channel */
Pau Espin Pedrol446e07b2019-02-18 21:18:36 +01003818 timer T_wait := 2.0;
3819 T_wait.start;
Harald Welte9bbbfb52018-04-05 09:33:19 +02003820 alt {
3821 [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(bts_nr, ?))) -> value sd {
3822 if (substr(sd.data.u.info_ind.trx[trx_nr].pdch_mask, g_chan_nr.tn, 1) != '0'B) {
Pau Espin Pedrol446e07b2019-02-18 21:18:36 +01003823 log("PCUIF_INFO_IND PDCH_MASK not yet '0' after PDCH DEACT on TS", g_chan_nr.tn,
3824 " mask:", sd.data.u.info_ind.trx[trx_nr].pdch_mask);
3825 repeat;
Harald Welte9bbbfb52018-04-05 09:33:19 +02003826 }
3827 }
3828 [] PCU.receive { repeat; }
Pau Espin Pedrol446e07b2019-02-18 21:18:36 +01003829 [] T_wait.timeout {
3830 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
3831 log2str("Timeout waiting for PCUIF_INFO_IND PDCH_MASK to be '0' on TS", g_chan_nr.tn));
3832 }
Harald Welte9bbbfb52018-04-05 09:33:19 +02003833 }
3834 /* Emulate PCU asking BTS to deactivate PDCH */
3835 PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_DEACT_REQ(bts_nr, trx_nr, g_chan_nr.tn)));
3836 alt {
3837 [] RSL.receive(tr_RSL_IPA_PDCH_DEACT_ACK(g_chan_nr)) {
3838 setverdict(pass);
3839 }
3840 [] RSL.receive { repeat; }
3841 }
3842}
3843
3844/* Activate and de-activate an IPA-style dynamic TCH/F + PDCH */
3845function f_TC_dyn_ipa_pdch_act_deact(charstring id) runs on ConnHdlr {
3846 var PCUIF_Message first_info;
3847 var integer ts_nr := g_chan_nr.tn;
3848 var integer trx_nr := 0;
3849 var integer bts_nr := 0;
3850 var integer pcu_conn_id := -1;
3851
3852 f_init_pcu(PCU, id, pcu_conn_id, first_info);
3853
3854 f_dyn_ipa_pdch_act(pcu_conn_id, bts_nr, trx_nr);
3855 f_sleep(3.0);
3856 f_dyn_ipa_pdch_deact(pcu_conn_id, bts_nr, trx_nr);
3857
3858 setverdict(pass);
3859
3860}
3861testcase TC_dyn_ipa_pdch_act_deact() runs on test_CT {
3862 var ConnHdlrPars pars;
3863 var ConnHdlr vc_conn;
3864 f_init();
3865
3866 pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN));
3867 vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_act_deact), pars, true);
3868 vc_conn.done;
3869}
3870
3871/* try to RSL CHAN ACT a TCH/F on an IPA-style PDCH */
3872function f_TC_dyn_ipa_pdch_tchf_act(charstring id) runs on ConnHdlr {
3873 var PCUIF_Message first_info;
3874 var integer ts_nr := g_chan_nr.tn;
3875 var integer trx_nr := 0;
3876 var integer bts_nr := 0;
3877 var integer pcu_conn_id := -1;
3878
3879 f_init_pcu(PCU, id, pcu_conn_id, first_info);
3880
3881 f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_ACK(g_chan_nr),
3882 "RSL CHAN ACT");
3883 f_rsl_transceive(ts_RSL_RF_CHAN_REL(g_chan_nr), tr_RSL_RF_CHAN_REL_ACK(g_chan_nr),
3884 "RF CHAN REL", true);
3885 setverdict(pass);
3886}
3887testcase TC_dyn_ipa_pdch_tchf_act() runs on test_CT {
3888 var ConnHdlrPars pars;
3889 var ConnHdlr vc_conn;
3890 f_init(testcasename());
3891
3892 pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN));
3893 vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_tchf_act), pars, true);
3894 vc_conn.done;
3895}
3896
3897/* Activate IPA style dyn PDCH as TCH/F and then illegally try to activate it as PDCH, too */
3898function f_TC_dyn_ipa_pdch_tchf_act_pdch_act_nack(charstring id) runs on ConnHdlr {
3899 var PCUIF_Message first_info;
3900 var integer ts_nr := g_chan_nr.tn;
3901 var integer trx_nr := 0;
3902 var integer bts_nr := 0;
3903 var integer pcu_conn_id := -1;
3904
3905 f_init_pcu(PCU, id, pcu_conn_id, first_info);
3906
3907 f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_ACK(g_chan_nr),
3908 "RSL CHAN ACT");
3909
3910 RSL.send(ts_RSL_IPA_PDCH_ACT(g_chan_nr));
3911 alt {
3912 [] RSL.receive(tr_RSL_IPA_PDCH_ACT_NACK(g_chan_nr, ?));
3913 [] RSL.receive(tr_RSL_IPA_PDCH_ACT_ACK(g_chan_nr, ?)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003914 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected PDCH ACT ACK");
Harald Welte9bbbfb52018-04-05 09:33:19 +02003915 }
3916 [] RSL.receive { repeat; }
3917 }
3918
3919 f_rsl_transceive(ts_RSL_RF_CHAN_REL(g_chan_nr), tr_RSL_RF_CHAN_REL_ACK(g_chan_nr),
3920 "RF CHAN REL", true);
3921 setverdict(pass);
3922}
3923testcase TC_dyn_ipa_pdch_tchf_act_pdch_act_nack() runs on test_CT {
3924 var ConnHdlrPars pars;
3925 var ConnHdlr vc_conn;
3926 f_init(testcasename());
3927
3928 pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN));
3929 vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_tchf_act_pdch_act_nack), pars, true);
3930 vc_conn.done;
3931}
3932
3933/* try to RSL CHAN ACT a TCH/F on an IPA-style PDCH that's already in PDCH mode; expect NACK */
3934function f_TC_dyn_ipa_pdch_act_tchf_act_nack(charstring id) runs on ConnHdlr {
3935 var PCUIF_Message first_info;
3936 var integer ts_nr := g_chan_nr.tn;
3937 var integer trx_nr := 0;
3938 var integer bts_nr := 0;
3939 var integer pcu_conn_id := -1;
3940
3941 /* register for the TCH/F channel number */
3942 f_rslem_register(0, g_chan_nr);
3943
3944 f_init_pcu(PCU, id, pcu_conn_id, first_info);
3945
3946 f_dyn_ipa_pdch_act(pcu_conn_id, bts_nr, trx_nr);
3947
3948 f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_NACK(g_chan_nr),
3949 "RSL CHAN ACT");
3950
3951 f_dyn_ipa_pdch_deact(pcu_conn_id, bts_nr, trx_nr);
3952
3953 setverdict(pass);
3954}
3955testcase TC_dyn_ipa_pdch_act_tchf_act_nack() runs on test_CT {
3956 var ConnHdlrPars pars;
3957 var ConnHdlr vc_conn;
3958 f_init(testcasename());
3959
3960 pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN));
3961 vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_act_tchf_act_nack), pars, true);
3962 vc_conn.done;
3963}
3964
3965
Harald Welte0472ab42018-03-12 15:02:26 +01003966/***********************************************************************
3967 * LAPDm / RLL related
3968 ***********************************************************************/
3969
3970private function f_tx_lapdm(template (value) LapdmFrame l,
3971 template (value) RslLinkId link_id) runs on ConnHdlr {
3972 var octetstring l2 := enc_LapdmFrame(valueof(l));
3973 if (valueof(link_id.c) == SACCH) {
3974 /* prepend dummy L1 header */
Pau Espin Pedrola0fb42a2018-10-10 15:56:39 +02003975 var L1ctlDataReq l1hl2 := {
3976 l1header := valueof(ts_SacchL1Header(g_pars.l1_pars.ms_power_level, false, g_pars.l1_pars.ms_actual_ta)),
3977 l2_payload := f_pad_oct(l2, 21, '2B'O)
3978 }
3979 L1CTL.send(ts_L1CTL_DATA_REQ_SACCH(g_chan_nr, link_id, l1hl2));
3980 } else {
3981 /* If required, pad L2 frame with constant 0x2b filling */
3982 l2 := f_pad_oct(l2, 23, '2B'O);
3983
3984 log("encoding ", l, " to ", l2);
3985 L1CTL.send(ts_L1CTL_DATA_REQ(g_chan_nr, link_id, l2));
Harald Welte0472ab42018-03-12 15:02:26 +01003986 }
Harald Welte0472ab42018-03-12 15:02:26 +01003987}
3988
3989type record RllTestCase {
3990 uint3_t sapi,
3991 RslLinkId link_id,
3992 octetstring l3,
3993 boolean exp
3994}
3995type record of RllTestCase RllTestCases;
3996template RllTestCase t_EITC(uint3_t sapi, RslLinkId id, octetstring l3, boolean exp) := {
3997 sapi := sapi,
3998 link_id := id,
3999 l3 := l3,
4000 exp := exp
4001}
4002
4003/* execute the same callback function with a set of different parameters (tcs) on a
4004 * variety of logical channels */
4005private function f_rll_testmatrix(RllTestCases tcs, void_fn fn) runs on test_CT {
4006 var ConnHdlrPars pars;
4007 var ConnHdlr vc_conn;
4008 f_init(testcasename());
4009
4010 /* test on each of the channels we have */
4011 for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i+1) {
4012 pars := valueof(t_Pars(g_AllChanTypes[i], ts_RSL_ChanMode_SIGN));
4013
4014 /* test each of the test cases on the current channel */
4015 for (var integer j := 0; j < sizeof(tcs); j := j+1) {
4016 pars.spec.rll := tcs[j];
4017 log(testcasename(), ": XXX Starting ", tcs[j] , " on ", g_AllChanTypes[i]);
4018 vc_conn := f_start_handler(fn, pars);
4019 vc_conn.done;
4020 }
4021 }
4022
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004023 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte0472ab42018-03-12 15:02:26 +01004024}
4025
4026/* test if SABM on Um triggers EST IND (TS 48.058 3.1) */
4027private function f_TC_rll_est_ind(charstring id) runs on ConnHdlr {
4028 var RllTestCase tc := g_pars.spec.rll;
4029 timer T := 3.0;
4030
4031 f_l1_tune(L1CTL);
4032 RSL.clear;
4033
4034 /* activate the logical channel */
4035 f_est_dchan();
4036 L1CTL.clear;
4037
4038 f_tx_lapdm(ts_LAPDm_SABM(tc.sapi, cr_MO_CMD, true, tc.l3), tc.link_id);
4039 T.start;
4040 alt {
4041 [tc.l3 != ''O] RSL.receive(tr_RSL_EST_IND(g_chan_nr, tc.link_id, tc.l3)) {
4042 if (tc.exp) {
4043 setverdict(pass);
4044 } else {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004045 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Unexpected EST IND with L3 in ", tc));
Harald Welte0472ab42018-03-12 15:02:26 +01004046 }
4047 }
4048 [tc.l3 == ''O] RSL.receive(tr_RSL_EST_IND_NOL3(g_chan_nr, tc.link_id)) {
4049 if (tc.exp) {
4050 setverdict(pass);
4051 } else {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004052 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Unexpected EST IND without L3 in ", tc));
Harald Welte0472ab42018-03-12 15:02:26 +01004053 }
4054 }
Vadim Yanitskiy35677872018-10-04 17:30:21 +07004055 /* We also expect to receive the measurements */
4056 [] as_meas_res(verify_meas := false);
Harald Welte0472ab42018-03-12 15:02:26 +01004057 [tc.exp] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004058 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for EST IND");
Harald Welte0472ab42018-03-12 15:02:26 +01004059 }
4060 [not tc.exp] T.timeout {
4061 setverdict(pass);
4062 }
4063 }
4064
4065 f_rsl_chan_deact();
4066 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
4067 f_rslem_unregister(0, g_chan_nr);
4068}
4069testcase TC_rll_est_ind() runs on test_CT {
4070 var RllTestCases tcs := {
Harald Welte7aacbbf2018-05-09 16:56:41 +02004071 /* SAPI0 establishment (contention resolution) */
Harald Welte0472ab42018-03-12 15:02:26 +01004072 valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), '01020304'O, true)),
Harald Welte7aacbbf2018-05-09 16:56:41 +02004073 /* normal SAPI0 establishment */
4074 valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), ''O, true)),
Harald Welte0472ab42018-03-12 15:02:26 +01004075 /* SAPI 3 doesn't support contention resolution */
4076 valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), '01020304'O, false)),
4077 valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), '01020304'O, false)),
4078 /* normal SAPI3 establishment on main DCCH */
4079 valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), ''O, true)),
4080 /* normal SAPI3 establishment on SACCH */
4081 valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), ''O, true))
4082 };
4083 f_rll_testmatrix(tcs, refers(f_TC_rll_est_ind));
4084}
4085
4086/* test if RLL EST REQ trigeres SABM on Um; UA on Um triggers EST CONF (TS 48.058 3.2) */
4087private function f_TC_rll_est_req(charstring id) runs on ConnHdlr {
4088 var RllTestCase tc := g_pars.spec.rll;
4089 var L1ctlDlMessage dl;
4090 timer T := 3.0;
4091
4092 f_l1_tune(L1CTL);
4093 RSL.clear;
4094
4095 /* activate the logical channel */
4096 f_est_dchan();
4097 L1CTL.clear;
4098
4099 /* Send a RSL EST REQ for SAPI3 on main DCCH */
4100 RSL.send(ts_RSL_EST_REQ(g_chan_nr, tc.link_id));
4101 T.start;
4102 alt {
4103 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, ?)) -> value dl {
4104 var LapdmFrame lapdm;
4105 var octetstring l2 := dl.payload.data_ind.payload;
4106 if (dl.dl_info.link_id.c == SACCH) {
4107 /* remove L1 header */
4108 l2 := substr(l2, 2, lengthof(l2)-2);
4109 }
4110 lapdm.ab := dec_LapdmFrameAB(l2);
4111 if (match(lapdm, tr_LAPDm_SABM(tc.sapi, cr_MT_CMD, true, ''O))) {
4112 setverdict(pass);
4113 } else {
4114 repeat;
4115 }
4116 }
4117 [] L1CTL.receive { repeat; }
4118 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004119 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for SABM");
Harald Welte0472ab42018-03-12 15:02:26 +01004120 }
4121 }
4122
4123 f_rsl_chan_deact();
4124 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
4125 f_rslem_unregister(0, g_chan_nr);
4126}
4127testcase TC_rll_est_req_DCCH_3() runs on test_CT {
4128 var RllTestCases tcs := {
4129 /* normal SAPI3 establishment on main DCCH */
4130 valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), ''O, true))//,
4131 };
4132 f_rll_testmatrix(tcs, refers(f_TC_rll_est_req));
4133}
4134testcase TC_rll_est_req_ACCH_3() runs on test_CT {
4135 var RllTestCases tcs := {
4136 /* normal SAPI3 establishment on SACCH */
4137 valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), ''O, true))
4138 }
4139 f_rll_testmatrix(tcs, refers(f_TC_rll_est_req));
4140}
4141
4142/* altstep to receive a LAPDm frame matching the given template */
4143private altstep as_l1_exp_lapdm(template LapdmFrame exp) runs on ConnHdlr {
4144 var L1ctlDlMessage dl;
4145 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, ?)) -> value dl {
4146 var LapdmFrame lapdm;
4147 var octetstring l2 := dl.payload.data_ind.payload;
4148 if (dl.dl_info.link_id.c == SACCH) {
4149 /* remove L1 header */
4150 l2 := substr(l2, 2, lengthof(l2)-2);
4151 }
4152 if (ischosen(exp.ab)) {
4153 lapdm.ab := dec_LapdmFrameAB(l2);
4154 } else if (ischosen(exp.b4)) {
4155 lapdm.b4 := dec_LapdmFrameB4(l2);
4156 } else if (ischosen(exp.bbis)) {
4157 lapdm.bbis := dec_LapdmFrameBbis(l2);
4158 }
4159 log("Rx LAPDm ", lapdm);
4160 if (match(lapdm, exp)) {
4161 setverdict(pass);
4162 } else {
4163 repeat;
4164 }
4165 }
4166 [] L1CTL.receive { repeat; }
4167}
4168private function f_l1_exp_lapdm(template LapdmFrame exp, float t := 3.0) runs on ConnHdlr {
4169 timer T := t;
4170 T.start;
4171 alt {
4172 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004173 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Timeout waiting for LAPDm ", exp));
Harald Welte0472ab42018-03-12 15:02:26 +01004174 }
4175 [] as_l1_exp_lapdm(exp);
4176 }
4177}
4178
4179/* establish one Radio Link Layer via SABM -> UA. Use l3 for contention resolution */
4180private function f_est_rll_mo(uint3_t sapi, RslLinkId link_id, octetstring l3) runs on ConnHdlr {
4181 /* send SABM from MS -> BTS */
4182 f_tx_lapdm(ts_LAPDm_SABM(sapi, cr_MO_CMD, true, l3), link_id);
4183 /* expect RLL EST IND on Abis */
4184 alt {
4185 [l3 != ''O] RSL.receive(tr_RSL_EST_IND(g_chan_nr, link_id, l3));
4186 [l3 == ''O] RSL.receive(tr_RSL_EST_IND_NOL3(g_chan_nr, link_id));
4187 [] RSL.receive(tr_RSL_ERROR_IND(g_chan_nr, link_id, ?)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004188 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Failing due to RSL_ERROR_IND");
Harald Welte0472ab42018-03-12 15:02:26 +01004189 }
4190 [] RSL.receive { repeat; }
4191 }
4192 /* expect UA from BTS -> MS */
4193 f_l1_exp_lapdm(tr_LAPDm_UA(sapi, cr_MT_RSP, true, l3));
4194}
4195
4196/* test if DISC on Um triggers RLL REL IND (TS 48.058 3.3) */
4197private function f_TC_rll_rel_ind(charstring id) runs on ConnHdlr {
4198 var RllTestCase tc := g_pars.spec.rll;
4199
4200 f_l1_tune(L1CTL);
4201 RSL.clear;
4202
4203 /* activate the logical channel */
4204 f_est_dchan();
4205 L1CTL.clear;
4206
4207 /* first establish the link-layer */
4208 f_est_rll_mo(tc.sapi, tc.link_id, tc.l3);
4209
4210 /* then send the DISC */
4211 f_tx_lapdm(ts_LAPDm_DISC(tc.sapi, cr_MO_CMD, true), tc.link_id);
4212 /* ... and expect the REL IND on the RSL side */
4213 alt {
4214 [] RSL.receive(tr_RSL_REL_IND(g_chan_nr, tc.link_id)) {
4215 setverdict(pass);
4216 }
Vadim Yanitskiy35677872018-10-04 17:30:21 +07004217 /* We also expect to receive the measurements */
4218 [] as_meas_res(verify_meas := false);
Harald Welte0472ab42018-03-12 15:02:26 +01004219 }
4220
4221 /* release the channel */
4222 f_rsl_chan_deact();
4223 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
4224 f_rslem_unregister(0, g_chan_nr);
4225}
4226testcase TC_rll_rel_ind_DCCH_0() runs on test_CT {
4227 var RllTestCases tcs := {
4228 valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), '01020304'O, true))
4229 };
4230 f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind));
4231}
4232
4233testcase TC_rll_rel_ind_ACCH_0() runs on test_CT {
4234 var RllTestCases tcs := {
4235 valueof(t_EITC(0, valueof(ts_RslLinkID_SACCH(0)), ''O, true))
4236 };
4237 f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind));
4238}
4239testcase TC_rll_rel_ind_DCCH_3() runs on test_CT {
4240 var RllTestCases tcs := {
4241 valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), ''O, true))
4242 };
4243 f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind));
4244}
4245testcase TC_rll_rel_ind_ACCH_3() runs on test_CT {
4246 var RllTestCases tcs := {
4247 valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), ''O, true))
4248 };
4249 f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind));
4250}
4251
4252/* test if RLL REL REQ triggers DISC on Um; UA/DM triggers RLL REL CONF (TS 48.058 3.4) */
4253private function f_TC_rll_rel_req(charstring id) runs on ConnHdlr {
4254 var RllTestCase tc := g_pars.spec.rll;
4255 f_l1_tune(L1CTL);
4256 RSL.clear;
4257
4258 /* activate the logical channel */
4259 f_est_dchan();
4260 L1CTL.clear;
4261
4262 /* first establish the link-layer */
4263 f_est_rll_mo(tc.sapi, tc.link_id, tc.l3);
4264
4265 /* then send the REL REQ via RSL */
4266 RSL.send(ts_RSL_REL_REQ(g_chan_nr, tc.link_id, RSL_REL_MODE_NORMAL));
4267 /* ... and expect the DISC on the Um side */
4268 alt {
Harald Weltebc6199f2018-05-10 19:38:18 +02004269 [] as_l1_exp_lapdm(tr_LAPDm_DISC(tc.sapi, cr_MT_CMD, true)) {
Harald Welte0472ab42018-03-12 15:02:26 +01004270 /* FIXME: send a UA in resposne to the DISC */
4271 }
4272 }
4273
4274 /* release the channel */
4275 f_rsl_chan_deact();
4276 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
4277 f_rslem_unregister(0, g_chan_nr);
4278}
4279testcase TC_rll_rel_req() runs on test_CT {
4280 var RllTestCases tcs := {
4281 valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), '01020304'O, true)),
4282 valueof(t_EITC(0, valueof(ts_RslLinkID_SACCH(0)), ''O, true)),
4283 valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), ''O, true)),
4284 valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), ''O, true))
4285 };
4286 f_rll_testmatrix(tcs, refers(f_TC_rll_rel_req));
4287}
4288
4289/* test if RLL DATA REQ triggers I-frames on Um (TS 48.058 3.5) */
4290testcase TC_rll_data_req() runs on test_CT {
4291}
4292
4293/* test if I-frames on Um trigger RLL DATA IND (TS 48.058 3.6) */
4294testcase TC_rll_data_ind() runs on test_CT {
4295}
4296
4297/* test if RLL UNIT DATA REQ triggers UI-frame on Um (TS 48.058 3.7) */
4298private function f_TC_rll_ud_req(charstring id) runs on ConnHdlr {
4299 var RllTestCase tc := g_pars.spec.rll;
4300
4301 f_l1_tune(L1CTL);
4302 RSL.clear;
4303
4304 f_est_dchan();
4305 L1CTL.clear;
4306
4307 /* Send UNITDATA REQ on RSL side */
4308 RSL.send(ts_RSL_UNITDATA_REQ(g_chan_nr, tc.link_id, tc.l3));
4309 /* Expect it to arrive on the other side */
4310 if (tc.link_id.c == SACCH) {
Harald Weltee613f962018-04-18 22:38:16 +02004311 f_l1_exp_lapdm(tr_LAPDm_B4_UI(tc.sapi, cr_MT_CMD, tc.l3));
Harald Welte0472ab42018-03-12 15:02:26 +01004312 } else {
Harald Weltee613f962018-04-18 22:38:16 +02004313 f_l1_exp_lapdm(tr_LAPDm_UI(tc.sapi, cr_MT_CMD, tc.l3));
Harald Welte0472ab42018-03-12 15:02:26 +01004314 }
4315
4316 /* release the channel */
4317 f_rsl_chan_deact();
4318 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
4319 f_rslem_unregister(0, g_chan_nr);
4320}
4321testcase TC_rll_unit_data_req_DCCH() runs on test_CT {
4322 var octetstring l3 := f_rnd_octstring(15);
4323 var RllTestCases tcs := {
4324 valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), l3, true)),
4325 valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), l3, true))
4326 };
4327 f_rll_testmatrix(tcs, refers(f_TC_rll_ud_req));
4328}
4329testcase TC_rll_unit_data_req_ACCH() runs on test_CT {
4330 var octetstring l3 := f_rnd_octstring(19);
4331 var RllTestCases tcs := {
4332 valueof(t_EITC(0, valueof(ts_RslLinkID_SACCH(0)), l3, true)),
4333 valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), l3, true))
4334 };
4335 f_rll_testmatrix(tcs, refers(f_TC_rll_ud_req));
4336}
4337
4338/* test if UI-frames on Um trigger RLL UNIT DATA IND (TS 48.058 3.8) */
4339private function f_TC_rll_ud_ind(charstring id) runs on ConnHdlr {
4340 var RllTestCase tc := g_pars.spec.rll;
4341
4342 f_l1_tune(L1CTL);
4343 RSL.clear;
4344
4345 f_est_dchan();
4346 L1CTL.clear;
4347
4348 /* Send LAPDm UI frame. There is no B4 format in uplink! */
Harald Weltee613f962018-04-18 22:38:16 +02004349 f_tx_lapdm(ts_LAPDm_UI(tc.sapi, cr_MO_CMD, tc.l3), tc.link_id);
Harald Welte0472ab42018-03-12 15:02:26 +01004350 /* Expdct RLL UNITDATA IND on RSL side */
4351 alt {
4352 [] RSL.receive(tr_RSL_UNITDATA_IND(g_chan_nr, tc.link_id, tc.l3)) {
4353 setverdict(pass);
4354 }
4355 [] RSL.receive { repeat; }
4356 }
4357
4358 /* release the channel */
4359 f_rsl_chan_deact();
4360 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
4361 f_rslem_unregister(0, g_chan_nr);
4362}
4363testcase TC_rll_unit_data_ind_DCCH() runs on test_CT {
Stefan Sperlingc4181912018-07-25 17:03:08 +02004364 var octetstring l3 := f_rnd_octstring(20);
Harald Welte0472ab42018-03-12 15:02:26 +01004365 var RllTestCases tcs := {
4366 valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), l3, true)),
4367 valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), l3, true))
4368 };
4369 f_rll_testmatrix(tcs, refers(f_TC_rll_ud_ind));
4370}
4371testcase TC_rll_unit_data_ind_ACCH() runs on test_CT {
4372 var octetstring l3 := f_rnd_octstring(18);
4373 var RllTestCases tcs := {
4374 valueof(t_EITC(0, valueof(ts_RslLinkID_SACCH(0)), l3, true)),
4375 valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), l3, true))
4376 };
4377 f_rll_testmatrix(tcs, refers(f_TC_rll_ud_ind));
4378}
4379
Harald Weltee613f962018-04-18 22:38:16 +02004380/***********************************************************************
4381 * Encryption Related
4382 ***********************************************************************/
4383
4384/* send UNITDATA_REQ from BTS to MS and expect it to arrive */
4385function f_unitdata_mt(RslLinkId link_id, octetstring l3) runs on ConnHdlr {
4386 RSL.send(ts_RSL_UNITDATA_REQ(g_chan_nr, link_id, l3));
4387 if (link_id.c == SACCH) {
4388 f_l1_exp_lapdm(tr_LAPDm_B4_UI(link_id.sapi, cr_MT_CMD, l3));
4389 } else {
4390 f_l1_exp_lapdm(tr_LAPDm_UI(link_id.sapi, cr_MT_CMD, l3));
4391 }
4392}
4393
Vadim Yanitskiyad131c82018-10-04 06:18:59 +07004394/* Expect (or not expect) other kinds of messages */
4395private altstep as_rsl_any_ind(boolean exp_any) runs on ConnHdlr {
4396 [exp_any] RSL.receive { repeat; }
4397 [not exp_any] RSL.receive {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004398 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RSL message!");
Vadim Yanitskiyad131c82018-10-04 06:18:59 +07004399 }
4400}
4401
Harald Weltee613f962018-04-18 22:38:16 +02004402/* Send UI frame from MS and expect it to arrive as RLL UNITDATA IND on Abis */
Vadim Yanitskiy8d8f91c2018-10-04 06:19:45 +07004403private function f_unitdata_mo(
Vadim Yanitskiy98e03152018-10-03 18:06:06 +07004404 RslLinkId link_id,
4405 octetstring l3,
4406 boolean exp_sacch := true, /* Should tolerate SACCH messages? */
Vadim Yanitskiyb9920502018-10-03 18:29:51 +07004407 boolean exp_any := false /* Should tolerate any other RSL messages? */
Vadim Yanitskiy98e03152018-10-03 18:06:06 +07004408) runs on ConnHdlr {
Harald Weltee613f962018-04-18 22:38:16 +02004409 timer T := 3.0;
4410 f_tx_lapdm(ts_LAPDm_UI(link_id.sapi, cr_MO_CMD, l3), link_id);
4411 T.start;
4412 /* Expect RLL UNITDATA IND on RSL side */
4413 alt {
4414 [] RSL.receive(tr_RSL_UNITDATA_IND(g_chan_nr, link_id, l3)) {
4415 setverdict(pass);
4416 }
Vadim Yanitskiye0b91a72018-10-04 15:44:40 +07004417 [exp_sacch] as_meas_res(verify_meas := false);
Vadim Yanitskiyad131c82018-10-04 06:18:59 +07004418 [] as_rsl_any_ind(exp_any);
Harald Weltee613f962018-04-18 22:38:16 +02004419 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004420 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for UNIT_DATA_IND");
Harald Weltee613f962018-04-18 22:38:16 +02004421 }
Harald Weltee613f962018-04-18 22:38:16 +02004422 }
4423}
4424
Vadim Yanitskiy4d78a702018-10-03 03:59:34 +07004425/* Send I-frame from MS and expect it to arrive as RLL DATA IND on Abis */
4426private function f_data_mo(
4427 RslLinkId link_id,
4428 boolean p, uint3_t nr, uint3_t ns,
4429 octetstring l3,
4430 boolean exp_sacch := true, /* Should tolerate SACCH messages? */
Vadim Yanitskiyb9920502018-10-03 18:29:51 +07004431 boolean exp_any := false /* Should tolerate any other RSL messages? */
Vadim Yanitskiy4d78a702018-10-03 03:59:34 +07004432) runs on ConnHdlr {
4433 timer T := 3.0;
4434 f_tx_lapdm(ts_LAPDm_I(link_id.sapi, cr_MO_CMD, p, nr, ns, l3), link_id);
4435 T.start;
4436 /* Expect RLL DATA IND on RSL side */
4437 alt {
4438 [] RSL.receive(tr_RSL_DATA_IND(g_chan_nr, link_id, l3)) {
4439 setverdict(pass);
4440 }
Vadim Yanitskiye0b91a72018-10-04 15:44:40 +07004441 [exp_sacch] as_meas_res(verify_meas := false);
Vadim Yanitskiy4d78a702018-10-03 03:59:34 +07004442 [] as_rsl_any_ind(exp_any);
4443 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004444 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for DATA_IND");
Vadim Yanitskiy4d78a702018-10-03 03:59:34 +07004445 }
4446 }
4447}
4448
Harald Weltee613f962018-04-18 22:38:16 +02004449/* Test channel activation with A5/n right from the beginning (like in assignment + hand-over) */
4450function f_TC_chan_act_encr(charstring id) runs on ConnHdlr {
4451 f_l1_tune(L1CTL);
4452 f_est_dchan(true);
4453
4454 /* now we actually need to transmit some data both ways to check if the encryption works */
4455 var L1ctlDlMessage dl;
4456
Stefan Sperling603d98e2018-07-25 16:47:28 +02004457 var octetstring l3 := f_rnd_octstring(20);
Harald Weltee613f962018-04-18 22:38:16 +02004458 var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0));
4459
4460 /* send UNITDATA_REQ from BTS to MS and expect it to arrive */
4461 f_unitdata_mt(link_id, l3);
4462
4463 /* Send UI frame from MS and expect it to arrive as RLL UNITDATA IND on Abis */
4464 f_unitdata_mo(link_id, l3);
4465
4466 /* release the channel */
4467 f_rsl_chan_deact();
4468 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
4469 f_rslem_unregister(0, g_chan_nr);
4470}
4471testcase TC_chan_act_a51() runs on test_CT {
4472 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
4473 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_1, f_rnd_octstring(8)));
4474 f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr));
4475}
4476testcase TC_chan_act_a52() runs on test_CT {
4477 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
4478 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_2, f_rnd_octstring(8)));
4479 f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr));
4480}
4481testcase TC_chan_act_a53() runs on test_CT {
4482 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
4483 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_3, f_rnd_octstring(8)));
4484 f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr));
4485}
4486
4487
4488/* Test unencrypted channel activation followed by explicit ENCR CMD later */
4489function f_TC_encr_cmd(charstring id) runs on ConnHdlr {
4490 /* L3 payload doesn't matter, as it is passed transparently */
4491 var BIT3 l3_alg_id := f_alg_id_to_l3(g_pars.encr.alg_id);
4492 var octetstring l3 := enc_PDU_ML3_NW_MS(valueof(ts_RRM_CiphModeCmd(l3_alg_id)));
4493 var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0));
4494
4495 f_l1_tune(L1CTL);
4496
4497 /* first establish a dedicated channel in the clear */
4498 f_est_dchan(false);
4499
4500 /* Establish ABM */
4501 f_est_rll_mo(link_id.sapi, link_id, '23420815'O);
4502
4503 /* then send the RSL ENCR CMD with an actual RR CIPH MOD CMD inside */
4504 RSL.send(ts_RSL_ENCR_CMD(g_chan_nr, link_id, g_pars.encr.alg_id, g_pars.encr.key, l3));
4505 /* expect the L3 to arrive still unencrypted on the MS side */
4506 f_l1_exp_lapdm(tr_LAPDm_I(link_id.sapi, cr_MT_CMD, ?, ?, ?, l3));
4507
4508 /* configure L1 to apply ciphering */
4509 var uint8_t alg_id := f_alg_id_to_l1ctl(g_pars.encr.alg_id);
4510 f_L1CTL_CRYPTO_REQ(L1CTL, g_pars.chan_nr, alg_id, g_pars.encr.key);
4511
Vadim Yanitskiy4d78a702018-10-03 03:59:34 +07004512 /* send first ciphered I-frame in response and expect it on RSL */
4513 f_data_mo(link_id, true, 1, 0, '0a0b0c0d'O, exp_sacch := true);
Harald Weltee613f962018-04-18 22:38:16 +02004514
4515 /* now the BTS code should have detected the first properly encrypted uplink I-frame,
4516 * and hence enable encryption also on the downlink */
4517
4518 /* expect bi-directional communication work in encrypted mode */
4519 f_unitdata_mo(link_id, f_rnd_octstring(15));
4520 f_unitdata_mt(link_id, f_rnd_octstring(15));
4521
4522 /* release the channel */
4523 f_rsl_chan_deact();
4524 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
4525 f_rslem_unregister(0, g_chan_nr);
4526}
4527testcase TC_encr_cmd_a51() runs on test_CT {
4528 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
4529 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_1, f_rnd_octstring(8)));
4530 f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd));
4531}
4532testcase TC_encr_cmd_a52() runs on test_CT {
4533 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
4534 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_2, f_rnd_octstring(8)));
4535 f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd));
4536}
4537testcase TC_encr_cmd_a53() runs on test_CT {
4538 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
4539 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_3, f_rnd_octstring(8)));
4540 f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd));
4541}
4542
4543private function f_assert_lapdm(octetstring enc, template LapdmFrame exp_match, charstring name := "") {
4544 var LapdmFrame lf;
4545 var octetstring reenc;
4546
4547 /* decode the LAPDm frame */
4548 if (ischosen(exp_match.ab)) {
4549 lf.ab := dec_LapdmFrameAB(enc);
4550 } else {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004551 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "unsupported frame type");
Harald Weltee613f962018-04-18 22:38:16 +02004552 }
4553
4554 /* check if decoder result matches expectation */
4555 if (not match(lf, exp_match)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004556 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str(name, ": decoded LAPDm doesn't match"));
Harald Weltee613f962018-04-18 22:38:16 +02004557 } else {
4558 log(name, ": matched");
4559 setverdict(pass);
4560 }
4561
4562 /* test if re-encoded frame equals original input */
4563 reenc := enc_LapdmFrame(lf);
4564 if (enc != reenc) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004565 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str(name, ": re-encoded LAPDm frame doesn't match"));
Harald Weltee613f962018-04-18 22:38:16 +02004566 } else {
4567 setverdict(pass);
4568 }
4569}
4570
4571testcase TC_lapdm_selftest() runs on test_CT {
4572 f_assert_lapdm('030301'O, tr_LAPDm_UI(0, true, ''O), "ui_s0_empty");
4573 f_assert_lapdm('0F0301'O, tr_LAPDm_UI(3, true, ''O), "ui_s3_empty");
4574 f_assert_lapdm('013F01'O, tr_LAPDm_SABM(0, false, true, ''O), "sabm_s0_empty");
4575 f_assert_lapdm('013F1123420815'O, tr_LAPDm_SABM(0, false, true, '23420815'O), "sabm_s0_l3");
4576 f_assert_lapdm('03E101'O, tr_LAPDm_RR(0, true, false, 7), "rr_s0_7");
4577 f_assert_lapdm('03000d063505'O, tr_LAPDm_I(0, true, false, 0, 0, '063505'O), "I/0/0");
4578 f_assert_lapdm('03e00d063505'O, tr_LAPDm_I(0, true, false, 7, 0, '063505'O), "I/7/0");
4579}
4580
Stefan Sperling4880be42018-08-07 18:12:59 +02004581/***********************************************************************
4582 * DTX Related (see GSM 05.08, section 8.3)
4583 ***********************************************************************/
4584
4585/* XXX These functions must be kept in sync with g_AllChannels defined on test_CT. */
4586function f_g_chan_is_tchf() runs on ConnHdlr return boolean {
4587 return (g_chan_nr == valueof(ts_RslChanNr_Bm(1)) or
4588 g_chan_nr == valueof(ts_RslChanNr_Bm(2)) or
4589 g_chan_nr == valueof(ts_RslChanNr_Bm(3)) or
4590 g_chan_nr == valueof(ts_RslChanNr_Bm(4)));
4591}
4592function f_g_chan_is_tchh() runs on ConnHdlr return boolean {
4593 return (g_chan_nr == valueof(ts_RslChanNr_Lm(5,0)) or
4594 g_chan_nr == valueof(ts_RslChanNr_Lm(5,1)));
4595}
4596function f_g_chan_is_sdcch4() runs on ConnHdlr return boolean {
4597 return (g_chan_nr == valueof(ts_RslChanNr_SDCCH4(0,0)) or
4598 g_chan_nr == valueof(ts_RslChanNr_SDCCH4(0,1)) or
4599 g_chan_nr == valueof(ts_RslChanNr_SDCCH4(0,2)) or
4600 g_chan_nr == valueof(ts_RslChanNr_SDCCH4(0,3)));
4601}
4602function f_g_chan_is_sdcch8() runs on ConnHdlr return boolean {
4603 return (g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,0)) or
4604 g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,1)) or
4605 g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,2)) or
4606 g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,3)) or
4607 g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,4)) or
4608 g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,5)) or
4609 g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,6)) or
4610 g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,7)));
4611}
4612
4613function f_test_l2_fill_frames(boolean dtxd) runs on ConnHdlr {
4614 var L1ctlDlMessage dl;
4615 var octetstring l2_fill_frame := '0303012B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B'O;
4616 var octetstring l2_fill_frame_sacch := substr(l2_fill_frame, 0, lengthof(l2_fill_frame) - 2);
4617 var GsmFrameNumber first_fn;
4618 var boolean is_first_frame := true;
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02004619 var integer nfill_frames_sacch := 0;
4620 var integer nfill_frames_nonsacch := 0;
4621 var integer expected_fill_frames := 10000; /* initial value causes test failure if not overridden */
Stefan Sperling4880be42018-08-07 18:12:59 +02004622 /* Frames numbers (mod 104) for which a fill frame is expected on TCHF if DTX is enabled. */
4623 var Integers required_tdma_frames_dtx_tchf := { 52, 53, 54, 55, 56, 57, 58, 59 };
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02004624 const integer frame_dtx_tchf_mod := 104;
4625 /* Frame numbers (mod 104) for which a fill frame is expected at the L1SAP level,
4626 * which operates in terms of blocks rather than frames. */
4627 var Integers required_tdma_blocks_dtx_tchf := { 52, 56 };
4628 const integer block_dtx_tchf_mod := 26;
Stefan Sperling4880be42018-08-07 18:12:59 +02004629 timer T := 5.0;
4630
4631 f_l1_tune(L1CTL);
4632 RSL.clear;
4633 L1CTL.clear;
4634
4635 /* activate TCHF signalling channel */
4636 f_est_dchan(false);
4637
4638 T.start;
4639 alt {
4640 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, ?)) -> value dl {
4641 var GsmFrameNumber fn := dl.dl_info.frame_nr;
4642 var octetstring l2 := dl.payload.data_ind.payload;
4643
4644 if (is_first_frame) {
4645 is_first_frame := false;
4646 first_fn := dl.dl_info.frame_nr;
4647 }
4648
4649 if (dl.dl_info.link_id.c == SACCH) {
4650 l2 := substr(l2, 2, lengthof(l2) - 2); /* remove L1 header */
4651 if (not match(l2_fill_frame_sacch, l2)) {
4652 repeat;
4653 }
4654 } else if (not match(l2_fill_frame, l2)) {
4655 repeat;
4656 }
4657
4658 if (dtxd) {
4659 if (not f_g_chan_is_tchf()) {
4660 T.stop;
4661 f_rsl_chan_deact();
4662 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004663 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received fill frame on non-TCH/F channel; DTX is only allowed on TCH/F!");
Stefan Sperling4880be42018-08-07 18:12:59 +02004664 }
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02004665 if (fn > first_fn + frame_dtx_tchf_mod) {
Stefan Sperling4880be42018-08-07 18:12:59 +02004666 T.stop;
4667 f_rsl_chan_deact();
4668 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02004669
4670 /* With DTX enabled we can expect at least 3 fill frames for every 104 frames.
4671 * 2 SACCH, 1 TCH/F */
4672 expected_fill_frames := 3;
4673
4674 if (nfill_frames_sacch + nfill_frames_nonsacch < expected_fill_frames) {
4675 log("received only ", nfill_frames_sacch, "+", nfill_frames_nonsacch,
4676 " (SACCH+other) out of ", expected_fill_frames, " expected fill frames");
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004677 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Not enough fill frames received");
Stefan Sperling4880be42018-08-07 18:12:59 +02004678 } else {
4679 setverdict(pass);
4680 }
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02004681 } else {
4682 if (dl.dl_info.link_id.c == SACCH) {
4683 nfill_frames_sacch := nfill_frames_sacch + 1;
Stefan Sperling4880be42018-08-07 18:12:59 +02004684 repeat;
4685 }
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02004686 /* On DTX TCH/F channels, fill frames occur only for specific frame numbers mod 104.
4687 * Furthermore, the L1SAP layer gives us frame numbers for the start of a block so
4688 * we should only see the subset of frames numbers which correspond to a block boundary.
4689 * TCH/F blocks are defined to start at 0,4,8,13,17,21 (modulo 26) */
4690 for (var integer i := 0; i < lengthof(required_tdma_blocks_dtx_tchf); i := i + 1) {
4691 if (fn mod frame_dtx_tchf_mod == required_tdma_blocks_dtx_tchf[i]) {
4692 nfill_frames_nonsacch := nfill_frames_nonsacch + 1;
4693 repeat;
4694 }
4695 }
4696 log("Received DTX TCH fill frame with bad frame number: ", fn,
4697 " (mod ", frame_dtx_tchf_mod, ": ", fn mod frame_dtx_tchf_mod, ")",
4698 " (mod ", block_dtx_tchf_mod, ": ", fn mod block_dtx_tchf_mod, ")");
4699 f_rsl_chan_deact();
4700 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004701 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected L2 fill frame received on Um");
Stefan Sperling4880be42018-08-07 18:12:59 +02004702 }
Stefan Sperling4880be42018-08-07 18:12:59 +02004703 } else {
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02004704 if (dl.dl_info.link_id.c == SACCH) {
4705 nfill_frames_sacch := nfill_frames_sacch + 1;
4706 } else {
4707 nfill_frames_nonsacch := nfill_frames_nonsacch + 1;
4708 }
4709 if (fn > first_fn + frame_dtx_tchf_mod) {
Stefan Sperling4880be42018-08-07 18:12:59 +02004710 T.stop;
4711 if (f_g_chan_is_tchf()) {
4712 /* Without DTX we can expect 25 fill frames for every 104 frames.
4713 * (24 FACCH + 1 SACCH filling) */
4714 expected_fill_frames := 25;
4715 } else if (f_g_chan_is_tchh()) {
4716 /* We can expect 2 fill frames for every 104 frames. */
4717 expected_fill_frames := 2;
4718 } else if (f_g_chan_is_sdcch4() or f_g_chan_is_sdcch8()) {
4719 /* We can expect 5 fill frames for every 104 frames. */
4720 expected_fill_frames := 5;
4721 } else {
4722 f_rsl_chan_deact();
4723 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004724 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unknown channel type");
Stefan Sperling4880be42018-08-07 18:12:59 +02004725 }
4726
4727 f_rsl_chan_deact();
4728 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02004729
4730 if (nfill_frames_sacch + nfill_frames_nonsacch >= expected_fill_frames) {
Stefan Sperling4880be42018-08-07 18:12:59 +02004731 setverdict(pass);
4732 } else {
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02004733 log("received only ", nfill_frames_sacch, "+", nfill_frames_nonsacch,
4734 " (SACCH+other) out of ", expected_fill_frames, " expected fill frames");
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004735 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Not enough fill frames received");
Stefan Sperling4880be42018-08-07 18:12:59 +02004736 }
4737 } else {
4738 repeat;
4739 }
4740 }
4741 }
4742 [] L1CTL.receive { repeat; }
4743 [] T.timeout {
4744 f_rsl_chan_deact();
4745 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004746 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for L2 fill frames on Um");
Stefan Sperling4880be42018-08-07 18:12:59 +02004747 }
4748 }
4749}
4750
4751function f_TC_tch_sign_l2_fill_frame(charstring id) runs on ConnHdlr {
4752 f_test_l2_fill_frames(false);
4753}
4754
4755function f_TC_tch_sign_l2_fill_frame_dtxd(charstring id) runs on ConnHdlr {
4756 f_test_l2_fill_frames(true);
4757}
4758
4759function f_tch_sign_l2_fill_frame(boolean dtxd) runs on test_CT {
4760 var ConnHdlr vc_conn;
4761 var ConnHdlrPars pars;
4762 pars.t_guard := 60.0;
4763 f_init(testcasename());
4764 for (var integer i := 0; i < sizeof(g_AllChannels); i := i + 1) {
4765 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN(dtxd)));
4766 if (dtxd) {
4767 if (i >= 4) { /* DTX is only allowed on TCH/F */
4768 break;
4769 }
4770 vc_conn := f_start_handler(refers(f_TC_tch_sign_l2_fill_frame_dtxd), pars);
4771 } else {
4772 vc_conn := f_start_handler(refers(f_TC_tch_sign_l2_fill_frame), pars);
4773 }
4774 vc_conn.done;
4775 }
4776}
4777
4778/* Verify that L2 fill frames are sent on TCH in signaling mode if
4779 * there is nothing to transmit while DTX is disabled on downlink. */
4780testcase TC_tch_sign_l2_fill_frame() runs on test_CT {
4781 f_tch_sign_l2_fill_frame(false);
4782}
4783
4784/* Verify that particular L2 fill frames are sent on TCH in signaling mode if
4785 * there is nothing to transmit while DTX is enabled on downlink. */
4786testcase TC_tch_sign_l2_fill_frame_dtxd() runs on test_CT {
4787 f_tch_sign_l2_fill_frame(true);
4788}
Harald Welte0472ab42018-03-12 15:02:26 +01004789
Stefan Sperling0ec1c262018-10-15 15:12:52 +02004790testcase TC_chopped_ipa_ping() runs on test_CT {
4791 IPA_Testing.f_run_TC_chopped_ipa_ping(mp_rsl_ip, mp_rsl_port, LISTEN_FOR_CLIENT);
4792}
4793
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02004794testcase TC_chopped_ipa_payload() runs on test_CT {
4795 IPA_Testing.f_run_TC_chopped_ipa_payload(mp_rsl_ip, mp_rsl_port, LISTEN_FOR_CLIENT);
4796}
4797
Harald Welte0472ab42018-03-12 15:02:26 +01004798/* test generation of RLL ERR IND based on Um errors (TS 48.058 3.9) */
4799/* protocol error as per 44.006 */
4800/* link layer failure (repetition of I-frame N200 times without ACK */
4801/* repetition of SABM or DISC N200 times without ACK */
4802/* receptiom of SABM in multi-frame established state */
4803
4804
Harald Welte68e495b2018-02-25 00:05:57 +01004805/* TODO Areas:
4806
4807* channel activation
4808** with BS_Power / MS_Power, bypassing power control loop
4809** on primary vs. secondary TRX
Harald Welte68e495b2018-02-25 00:05:57 +01004810** with timing advance from initial activation on
4811* mode modify
4812** encryption
4813** multirate
4814* check DEACTIVATE SACCH
Harald Welte68e495b2018-02-25 00:05:57 +01004815** unsupported algorithm
4816* handover detection
Harald Welte68e495b2018-02-25 00:05:57 +01004817* BS Power Control
4818* Physical Context
Harald Welte68e495b2018-02-25 00:05:57 +01004819* RF resource ind
Harald Welte68e495b2018-02-25 00:05:57 +01004820* error handling
Harald Welte68e495b2018-02-25 00:05:57 +01004821** IE duplicated?
Harald Welte883340c2018-02-28 18:59:29 +01004822* PCU interface
Harald Welte883340c2018-02-28 18:59:29 +01004823** DATA_IND from BTS->PCU
4824** verification of PCU-originated DATA_REQ arrival on Um/MS side
Harald Welte68e495b2018-02-25 00:05:57 +01004825
4826*/
Harald Welte70767382018-02-21 12:16:40 +01004827
4828control {
4829 execute( TC_chan_act_stress() );
4830 execute( TC_chan_act_react() );
4831 execute( TC_chan_deact_not_active() );
4832 execute( TC_chan_act_wrong_nr() );
Harald Welte629cc6b2018-03-11 17:19:05 +01004833 execute( TC_deact_sacch() );
Harald Welteea17b912018-03-11 22:29:31 +01004834 execute( TC_sacch_filling() );
4835 execute( TC_sacch_info_mod() );
Harald Welte075d84c2018-03-12 13:07:24 +01004836 execute( TC_sacch_multi() );
Harald Welte55700662018-03-12 13:15:43 +01004837 execute( TC_sacch_multi_chg() );
Harald Weltec8d363c2019-05-19 20:36:48 +02004838 execute( TC_sacch_chan_act() );
Harald Welte8b01c792019-05-19 22:51:25 +02004839 execute( TC_sacch_chan_act_ho_async() );
4840 execute( TC_sacch_chan_act_ho_sync() );
Harald Welte8c24c2b2018-02-26 08:31:31 +01004841 execute( TC_rach_content() );
4842 execute( TC_rach_count() );
Harald Welte54a2a2d2018-02-26 09:14:05 +01004843 execute( TC_rach_max_ta() );
Harald Welte3453ab42019-05-24 21:19:58 +02004844 execute( TC_rach_load_idle_thresh0() );
4845 execute( TC_rach_load_idle_below_thresh() );
4846 execute( TC_rach_load_count() );
Harald Welte70767382018-02-21 12:16:40 +01004847 execute( TC_meas_res_sign_tchf() );
4848 execute( TC_meas_res_sign_tchh() );
4849 execute( TC_meas_res_sign_sdcch4() );
4850 execute( TC_meas_res_sign_sdcch8() );
Harald Welte685d5982018-02-27 20:42:05 +01004851 execute( TC_meas_res_sign_tchh_toa256() );
Philipp Maier4d1e9c92018-12-20 11:11:56 +01004852 execute( TC_rsl_ms_pwr_ctrl() );
Eric Wild6833cc92019-05-23 19:34:44 +02004853 execute( TC_rsl_chan_initial_ta() );
Harald Welte70767382018-02-21 12:16:40 +01004854 execute( TC_conn_fail_crit() );
Harald Welte68e495b2018-02-25 00:05:57 +01004855 execute( TC_paging_imsi_80percent() );
4856 execute( TC_paging_tmsi_80percent() );
4857 execute( TC_paging_imsi_200percent() );
4858 execute( TC_paging_tmsi_200percent() );
Harald Welte01d982c2018-02-25 01:31:40 +01004859 execute( TC_rsl_protocol_error() );
4860 execute( TC_rsl_mand_ie_error() );
4861 execute( TC_rsl_ie_content_error() );
Harald Welte48494ca2018-02-25 16:59:50 +01004862 execute( TC_si_sched_default() );
Harald Welte0cae4552018-03-09 22:20:26 +01004863 execute( TC_si_sched_1() );
Harald Welte48494ca2018-02-25 16:59:50 +01004864 execute( TC_si_sched_2bis() );
4865 execute( TC_si_sched_2ter() );
4866 execute( TC_si_sched_2ter_2bis() );
4867 execute( TC_si_sched_2quater() );
4868 execute( TC_si_sched_13() );
4869 execute( TC_si_sched_13_2bis_2ter_2quater() );
Harald Weltea871a382018-02-25 02:03:14 +01004870 execute( TC_ipa_dlcx_not_active() );
Harald Weltea3f1df92018-02-25 12:49:55 +01004871 execute( TC_ipa_crcx_twice_not_active() );
4872 execute( TC_ipa_crcx_mdcx_dlcx_not_active() );
Harald Welte3ae11da2018-02-25 13:36:06 +01004873 execute( TC_ipa_crcx_mdcx_mdcx_dlcx_not_active() );
Harald Welte9912eb52018-02-25 13:30:15 +01004874 execute( TC_ipa_crcx_sdcch_not_active() );
Harald Welte883340c2018-02-28 18:59:29 +01004875
Pau Espin Pedrola14a8af2018-11-20 13:12:22 +01004876 if (mp_pcu_socket != "") {
4877 execute( TC_pcu_act_req() );
4878 execute( TC_pcu_act_req_wrong_ts() );
4879 execute( TC_pcu_act_req_wrong_bts() );
4880 execute( TC_pcu_act_req_wrong_trx() );
4881 execute( TC_pcu_deact_req() );
4882 execute( TC_pcu_deact_req_wrong_ts() );
4883 execute( TC_pcu_ver_si13() );
4884 execute( TC_pcu_data_req_wrong_bts() );
4885 execute( TC_pcu_data_req_wrong_trx() );
4886 execute( TC_pcu_data_req_wrong_ts() );
4887 execute( TC_pcu_data_req_ts_inactive() );
4888 execute( TC_pcu_data_req_pdtch() );
4889 execute( TC_pcu_data_req_ptcch() );
4890 execute( TC_pcu_data_req_agch() );
4891 execute( TC_pcu_data_req_imm_ass_pch() );
4892 execute( TC_pcu_rach_content() );
Vadim Yanitskiy51cbc102019-04-22 06:37:30 +07004893 execute( TC_pcu_ext_rach_content() );
Pau Espin Pedrola14a8af2018-11-20 13:12:22 +01004894 execute( TC_pcu_paging_from_rsl() );
Harald Welted66c9b82019-05-25 09:03:15 +02004895 execute( TC_pcu_time_ind() );
Pau Espin Pedrola14a8af2018-11-20 13:12:22 +01004896 } else {
4897 log("PCU socket path not available, skipping PCU tests");
4898 }
Harald Welte3d04ae62018-04-04 20:29:05 +02004899
4900 execute( TC_dyn_osmo_pdch_act_deact() );
4901 execute( TC_dyn_osmo_pdch_unsol_deact() );
4902 execute( TC_dyn_osmo_pdch_double_act() );
4903 execute( TC_dyn_osmo_pdch_tchf_act() );
4904 execute( TC_dyn_osmo_pdch_tchh_act() );
Harald Welte9bbbfb52018-04-05 09:33:19 +02004905 execute( TC_dyn_ipa_pdch_act_deact() );
4906 execute( TC_dyn_ipa_pdch_tchf_act() );
4907 execute( TC_dyn_ipa_pdch_tchf_act_pdch_act_nack() );
4908 execute( TC_dyn_ipa_pdch_act_tchf_act_nack() );
Harald Welte0472ab42018-03-12 15:02:26 +01004909
4910 execute( TC_rll_est_ind() );
4911 execute( TC_rll_est_req_DCCH_3() );
4912 execute( TC_rll_est_req_ACCH_3() );
4913 execute( TC_rll_rel_ind_DCCH_0() );
4914 execute( TC_rll_rel_ind_DCCH_3() );
4915 execute( TC_rll_rel_ind_ACCH_0() );
4916 execute( TC_rll_rel_ind_ACCH_3() );
4917 execute( TC_rll_rel_req() );
4918 execute( TC_rll_unit_data_req_DCCH() );
4919 execute( TC_rll_unit_data_req_ACCH() );
4920 execute( TC_rll_unit_data_ind_DCCH() );
4921 execute( TC_rll_unit_data_ind_ACCH() );
Harald Weltee613f962018-04-18 22:38:16 +02004922
4923 execute( TC_chan_act_a51() );
4924 execute( TC_chan_act_a52() );
4925 execute( TC_chan_act_a53() );
4926 execute( TC_encr_cmd_a51() );
4927 execute( TC_encr_cmd_a52() );
4928 execute( TC_encr_cmd_a53() );
4929
Harald Welteee25aae2019-05-19 14:32:37 +02004930 execute( TC_err_rep_wrong_mdisc() );
4931 execute( TC_err_rep_wrong_msg_type() );
4932 execute( TC_err_rep_wrong_sequence() );
4933
Harald Weltee613f962018-04-18 22:38:16 +02004934 execute( TC_lapdm_selftest() );
Stefan Sperling4880be42018-08-07 18:12:59 +02004935
4936 execute( TC_tch_sign_l2_fill_frame() );
4937 execute( TC_tch_sign_l2_fill_frame_dtxd() );
Stefan Sperling0ec1c262018-10-15 15:12:52 +02004938
4939 execute( TC_chopped_ipa_ping() );
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02004940 execute( TC_chopped_ipa_payload() );
Harald Welte70767382018-02-21 12:16:40 +01004941}
4942
4943
4944}