blob: 012df4739f9de0590d7532f3e52623b6ec66de75 [file] [log] [blame]
Harald Welte70767382018-02-21 12:16:40 +01001module BTS_Tests {
2
Harald Welte14906952019-05-27 09:19:49 +02003/* Integration Tests for OsmoBTS
Harald Welte34b5a952019-05-27 11:54:11 +02004 * (C) 2018-2019 by Harald Welte <laforge@gnumonks.org>
Harald Welte14906952019-05-27 09:19:49 +02005 * contributions by Vadim Yanitskiy and sysmocom - s.f.m.c. GmbH
6 * All rights reserved.
7 *
8 * Released under the terms of GNU General Public License, Version 2 or
9 * (at your option) any later version.
10 *
Harald Welte34b5a952019-05-27 11:54:11 +020011 * SPDX-License-Identifier: GPL-2.0-or-later
12 *
Harald Welte14906952019-05-27 09:19:49 +020013 * This test suite tests OsmoBTS by attaching to the external interfaces
14 * such as Abis RSL, PCU, VTY as well as by attaching to a MS L1 implementation
15 * using the L1CTL protocol/interface.
16 *
17 * You can run the tests with
18 * a) osmo-bts-trx + trxcon + fake_trx (without any hardware)
19 * b) any osmo-bts-* + OsmocomBB layer1 + osmocon (with real BTS hardware)
20 * c) osmo-bts-virtual + virt_phy (without any hardware)
21 *
22 * Some of the tests will only run on a subset of those three configurations
23 * due to limitations in the respective L1.
24 */
25
Daniel Willmann0fcc4d32018-10-23 20:32:19 +020026import from Misc_Helpers all;
Harald Welte70767382018-02-21 12:16:40 +010027import from General_Types all;
28import from GSM_Types all;
29import from GSM_RR_Types all;
30import from Osmocom_Types all;
31import from GSM_Types all;
Vadim Yanitskiy5d2cf442020-05-02 16:49:17 +070032import from GSM_RestOctets all;
Harald Welte82ccef72018-02-25 16:17:33 +010033import from GSM_SystemInformation all;
Harald Welte70767382018-02-21 12:16:40 +010034import from L1CTL_PortType all;
35import from L1CTL_Types all;
36import from LAPDm_Types all;
Harald Weltead033dc2019-05-25 17:28:16 +020037import from LAPDm_RAW_PT all;
Harald Welte70767382018-02-21 12:16:40 +010038import from Osmocom_CTRL_Adapter all;
Neels Hofmeyr6a84b232018-04-03 19:12:36 +020039import from Osmocom_CTRL_Functions all;
Harald Welte70767382018-02-21 12:16:40 +010040
41import from RSL_Types all;
Harald Welte7484fc42018-02-24 14:09:45 +010042import from IPA_Types all;
Harald Welte70767382018-02-21 12:16:40 +010043import from IPA_Emulation all;
Stefan Sperling0ec1c262018-10-15 15:12:52 +020044import from IPA_Testing all;
Harald Welte70767382018-02-21 12:16:40 +010045import from RSL_Emulation all;
46
47import from IPL4asp_Types all;
48import from TRXC_Types all;
49import from TRXC_CodecPort all;
50import from TRXC_CodecPort_CtrlFunct all;
51
Harald Welte883340c2018-02-28 18:59:29 +010052import from PCUIF_Types all;
53import from PCUIF_CodecPort all;
Harald Weltea2e0e942019-05-27 18:12:53 +020054import from UD_Types all;
Harald Welte883340c2018-02-28 18:59:29 +010055
Harald Welte7484fc42018-02-24 14:09:45 +010056import from MobileL3_CommonIE_Types all;
Harald Welte68e495b2018-02-25 00:05:57 +010057import from MobileL3_RRM_Types all;
58import from MobileL3_Types all;
59import from L3_Templates all;
Harald Welteeaa9a862019-05-26 23:01:08 +020060import from L3_Common all;
61import from MobileL3_GMM_SM_Types all;
Harald Welte7484fc42018-02-24 14:09:45 +010062
Harald Welte8da48242018-02-27 20:41:32 +010063import from Osmocom_VTY_Functions all;
64import from TELNETasp_PortType all;
Harald Welte2f2b2b72019-05-31 22:24:57 +020065import from BTS_Tests_LAPDm all;
Harald Welte8da48242018-02-27 20:41:32 +010066
Harald Welte505cf9b2018-09-15 17:47:23 +030067friend module BTS_Tests_SMSCB;
Harald Weltead033dc2019-05-25 17:28:16 +020068friend module BTS_Tests_virtphy;
Harald Welte2f2b2b72019-05-31 22:24:57 +020069friend module BTS_Tests_LAPDm;
Pau Espin Pedrol5a012ee2020-02-06 19:33:22 +010070friend module BTS_Tests_perf;
Harald Welte505cf9b2018-09-15 17:47:23 +030071
Harald Welte70767382018-02-21 12:16:40 +010072/* The tests assume a BTS with the following timeslot configuration:
73 * TS0 : Combined CCCH + SDCCH/4
Harald Welte3d04ae62018-04-04 20:29:05 +020074 * TS1 : TCH/F
75 * TS2 : TCH/F
76 * TS3 : TCH/F_PDCH (IPA Style)
77 * TS4 : TCH/F_TCH/H_PDCH (Osmocom Style)
Harald Welte70767382018-02-21 12:16:40 +010078 * TS5 : TCH/H
79 * TS6 : SDCCH/8
80 * TS7 : PDCH
81 */
82
83modulepar {
84 charstring mp_rsl_ip := "127.0.0.2";
85 integer mp_rsl_port := 3003;
86 integer mp_trx0_arfcn := 871;
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +070087 charstring mp_bts_trxc_ip := "127.0.0.1";
88 integer mp_bts_trxc_port := 5701;
Harald Welte883340c2018-02-28 18:59:29 +010089 charstring mp_pcu_socket := PCU_SOCK_DEFAULT;
Neels Hofmeyr6a84b232018-04-03 19:12:36 +020090 charstring mp_ctrl_ip := "127.0.0.1";
91 integer mp_ctrl_port := 4238;
Harald Welte07bd2d22019-05-25 11:03:30 +020092 charstring mp_bsc_ctrl_ip := "127.0.0.1";
93 integer mp_bsc_ctrl_port := 4249;
Pau Espin Pedrol121724c2018-09-28 15:58:12 +020094 integer mp_tolerance_rxqual := 1;
95 integer mp_tolerance_rxlev := 3;
96 integer mp_tolerance_timing_offset_256syms := 0;
Pau Espin Pedrol752ffd52018-06-07 13:55:45 +020097 integer mp_rxlev_exp := 57;
Pau Espin Pedrole9571aa2018-10-22 17:13:07 +020098 integer mp_ul_rxlev_exp := 10;
Pau Espin Pedroled359cb2018-09-28 16:08:24 +020099 integer mp_ms_power_level_exp := 7;
Pau Espin Pedrol121724c2018-09-28 15:58:12 +0200100 integer mp_ms_actual_ta_exp := 0;
101 integer mp_timing_offset_256syms_exp := 512;
Pau Espin Pedrol315e4712018-11-01 16:27:07 +0100102 /* Time to wait for RSL conn from BTS during startup of test */
Philipp Maier12567e42019-04-17 14:10:05 +0200103 float mp_ipa_up_timeout := 15.0;
Philipp Maiere63229e2019-04-26 12:21:37 +0200104 float mp_ipa_up_delay := 0.0;
Harald Weltead033dc2019-05-25 17:28:16 +0200105 /* false for now, as only virtphy supports it, not calypso-l1 nor trxcon */
106 boolean mp_l1_supports_gprs := false;
Harald Welte70767382018-02-21 12:16:40 +0100107}
108
Harald Welte629cc6b2018-03-11 17:19:05 +0100109type record of RslChannelNr ChannelNrs;
110
Harald Welte70767382018-02-21 12:16:40 +0100111type component test_CT extends CTRL_Adapter_CT {
Harald Welte68e495b2018-02-25 00:05:57 +0100112 /* IPA Emulation component underneath RSL */
Harald Welte70767382018-02-21 12:16:40 +0100113 var IPA_Emulation_CT vc_IPA;
Harald Welte68e495b2018-02-25 00:05:57 +0100114 /* RSL Emulation component (for ConnHdlr tests) */
Harald Welte70767382018-02-21 12:16:40 +0100115 var RSL_Emulation_CT vc_RSL;
Harald Welte68e495b2018-02-25 00:05:57 +0100116 /* Direct RSL_CCHAN_PT */
Harald Welte70767382018-02-21 12:16:40 +0100117 port RSL_CCHAN_PT RSL_CCHAN;
Harald Welte68e495b2018-02-25 00:05:57 +0100118
119 /* L1CTL port (for classic tests) */
120 port L1CTL_PT L1CTL;
Harald Welte48494ca2018-02-25 16:59:50 +0100121
Vadim Yanitskiyf4e997c2019-06-04 21:40:33 +0700122 /* Optional TRXC connection to FakeTRX (BTS side) */
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +0700123 port TRXC_CODEC_PT BTS_TRXC;
124 var integer g_bts_trxc_conn_id;
Harald Welte54a2a2d2018-02-26 09:14:05 +0100125
Harald Weltef50e3ae2018-09-10 10:27:56 +0200126 /* VTY connections to both BTS and BSC */
Harald Welte8da48242018-02-27 20:41:32 +0100127 port TELNETasp_PT BTSVTY;
Harald Weltef50e3ae2018-09-10 10:27:56 +0200128 port TELNETasp_PT BSCVTY;
Harald Welte8da48242018-02-27 20:41:32 +0100129
Harald Welte883340c2018-02-28 18:59:29 +0100130 /* PCU Interface of BTS */
131 port PCUIF_CODEC_PT PCU;
132 var integer g_pcu_conn_id;
133 /* Last PCU INFO IND we received */
134 var PCUIF_Message g_pcu_last_info;
135
Harald Welte48494ca2018-02-25 16:59:50 +0100136 /* SI configuration */
137 var SystemInformationConfig si_cfg := {
138 bcch_extended := false,
139 si1_present := false,
140 si2bis_present := false,
141 si2ter_present := false,
142 si2quater_present := false,
143 si7_present := false,
144 si8_present := false,
145 si9_present := false,
146 si13_present := false,
147 si13alt_present := false,
148 si15_present := false,
149 si16_present := false,
150 si17_present := false,
151 si2n_present := false,
152 si21_present := false,
153 si22_present := false
154 };
Harald Welte629cc6b2018-03-11 17:19:05 +0100155
156 /* all logical channels available on the BTS */
157 var ChannelNrs g_AllChannels;
Harald Welte0472ab42018-03-12 15:02:26 +0100158 var ChannelNrs g_AllChanTypes;
Harald Welte70767382018-02-21 12:16:40 +0100159}
160
161/* an individual call / channel */
Harald Welte2f2b2b72019-05-31 22:24:57 +0200162type component ConnHdlr extends RSL_DchanHdlr, lapdm_test_CT {
Harald Welte70767382018-02-21 12:16:40 +0100163 port L1CTL_PT L1CTL;
164
Vadim Yanitskiyf4e997c2019-06-04 21:40:33 +0700165 /* Optional TRXC connection to FakeTRX (BTS side) */
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +0700166 port TRXC_CODEC_PT BTS_TRXC;
167 var integer g_bts_trxc_conn_id;
Harald Welte70767382018-02-21 12:16:40 +0100168
169 timer g_Tguard;
170 timer g_Tmeas_exp := 2.0; /* >= 103 SACCH multiframe ~ 500ms */
171
172 var ConnHdlrPars g_pars;
173 var uint8_t g_next_meas_res_nr := 0;
Harald Weltefa45e9e2018-03-10 18:59:03 +0100174 var boolean g_first_meas_res := true;
Harald Weltef26de0b2018-04-04 20:28:05 +0200175
176 /* PCU Interface of BTS */
177 port PCUIF_CODEC_PT PCU;
Harald Welte70767382018-02-21 12:16:40 +0100178}
179
180function f_init_rsl(charstring id) runs on test_CT {
Vadim Yanitskiyc9c9e292020-05-18 23:31:40 +0700181 timer T := mp_ipa_up_timeout;
182
Harald Welte70767382018-02-21 12:16:40 +0100183 vc_IPA := IPA_Emulation_CT.create(id & "-RSL-IPA");
184 vc_RSL := RSL_Emulation_CT.create(id & "-RSL");
185
186 map(vc_IPA:IPA_PORT, system:IPA_CODEC_PT);
187 connect(vc_IPA:IPA_RSL_PORT, vc_RSL:IPA_PT);
188 connect(self:RSL_CCHAN, vc_RSL:CCHAN_PT);
189
190 vc_IPA.start(IPA_Emulation.main_server(mp_rsl_ip, mp_rsl_port));
191 vc_RSL.start(RSL_Emulation.main(false));
Vadim Yanitskiyc9c9e292020-05-18 23:31:40 +0700192
193 T.start;
194 alt {
195 [] RSL_CCHAN.receive(tr_ASP_IPA_EV(ASP_IPA_EVENT_UP));
196 [] T.timeout {
197 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for ASP_IPA_EVENT_UP");
198 }
199 }
Harald Welte70767382018-02-21 12:16:40 +0100200}
201
202type record ConnHdlrPars {
203 RslChannelNr chan_nr,
204 RSL_IE_ChannelMode chan_mode,
205 float t_guard,
Harald Welte0472ab42018-03-12 15:02:26 +0100206 ConnL1Pars l1_pars,
Harald Weltee613f962018-04-18 22:38:16 +0200207 TestSpecUnion spec optional,
Eric Wild61edb7e2019-06-03 12:38:31 +0200208 RSL_IE_EncryptionInfo encr optional,
209 BtsBand bts0_band optional
Harald Welte0472ab42018-03-12 15:02:26 +0100210}
211
212/* Test-specific parameters */
213type union TestSpecUnion {
214 RllTestCase rll
Harald Welte70767382018-02-21 12:16:40 +0100215}
216
Harald Welte82ccef72018-02-25 16:17:33 +0100217template (value) RachControlParameters ts_RachCtrl_default := {
Harald Welte0fd1fb02018-03-10 17:19:50 +0100218 max_retrans := RACH_MAX_RETRANS_7,
219 tx_integer := '1001'B, /* 12 slots */
Harald Welte82ccef72018-02-25 16:17:33 +0100220 cell_barr_access := false,
221 re_not_allowed := true,
Harald Welteb9585f82018-03-10 17:18:47 +0100222 acc := '0000010000000000'B
Harald Welte82ccef72018-02-25 16:17:33 +0100223};
224
Harald Weltef10153f2018-02-25 16:34:05 +0100225template (value) CellSelectionParameters ts_CellSelPar_default := {
Harald Welte0fd1fb02018-03-10 17:19:50 +0100226 cell_resel_hyst_2dB := 2,
Pau Espin Pedroled359cb2018-09-28 16:08:24 +0200227 ms_txpwr_max_cch := mp_ms_power_level_exp,
Harald Weltef10153f2018-02-25 16:34:05 +0100228 acs := '0'B,
229 neci := true,
230 rxlev_access_min := 0
231}
232
233template (value) LocationAreaIdentification ts_LAI_default := {
234 mcc_mnc := '262F42'H,
235 lac := 42
236}
237
Vadim Yanitskiy12cf3d92020-05-05 00:19:50 +0700238private template (value) GPRSIndicator ts_GPRSIndicator_def := {
239 ra_colour := 0,
240 si13_pos := '0'B
241}
242
243private template (value) SI3RestOctets ts_SI3RestOctets_def
244modifies ts_SI3RestOctets := {
245 gprs_ind := {
246 presence := CSN1_H,
247 ind := ts_GPRSIndicator_def
248 }
249}
250
251private template (value) SI4RestOctets ts_SI4RestOctets_def
252modifies ts_SI4RestOctets := {
253 gprs_ind := {
Vadim Yanitskiyab5363f2020-05-05 00:30:22 +0700254 presence := CSN1_H,
255 ind := ts_GPRSIndicator_def
Vadim Yanitskiy12cf3d92020-05-05 00:19:50 +0700256 }
257}
258
Harald Welte7484fc42018-02-24 14:09:45 +0100259/* Default SYSTEM INFORMATION 3 */
Harald Weltef8df4cb2018-03-10 15:15:08 +0100260template (value) SystemInformation ts_SI3_default := {
261 header := ts_RrHeader(SYSTEM_INFORMATION_TYPE_3, 18),
Harald Welte7484fc42018-02-24 14:09:45 +0100262 payload := {
263 si3 := {
264 cell_id := 23,
Harald Weltef10153f2018-02-25 16:34:05 +0100265 lai := ts_LAI_default,
Harald Welte7484fc42018-02-24 14:09:45 +0100266 ctrl_chan_desc := {
267 msc_r99 := true,
268 att := true,
269 bs_ag_blks_res := 1,
270 ccch_conf := CCHAN_DESC_1CCCH_COMBINED,
Harald Welte82ccef72018-02-25 16:17:33 +0100271 si22ind := false,
Harald Welte7484fc42018-02-24 14:09:45 +0100272 cbq3 := CBQ3_IU_MODE_NOT_SUPPORTED,
273 spare := '00'B,
274 bs_pa_mfrms := 0, /* 2 multiframes */
275 t3212 := 1 /* 6 minutes */
276 },
Harald Welte82ccef72018-02-25 16:17:33 +0100277 cell_options := {
Harald Welte7484fc42018-02-24 14:09:45 +0100278 dn_ind := false,
279 pwrc := false,
280 dtx := MS_MAY_USE_UL_DTX,
Harald Welte0fd1fb02018-03-10 17:19:50 +0100281 radio_link_tout_div4 := (32/4)-1
Harald Welte7484fc42018-02-24 14:09:45 +0100282 },
Harald Weltef10153f2018-02-25 16:34:05 +0100283 cell_sel_par := ts_CellSelPar_default,
Harald Welte82ccef72018-02-25 16:17:33 +0100284 rach_control := ts_RachCtrl_default,
Vadim Yanitskiy12cf3d92020-05-05 00:19:50 +0700285 rest_octets := enc_SI3RestOctets(valueof(ts_SI3RestOctets_def))
Harald Welte7484fc42018-02-24 14:09:45 +0100286 }
287 }
288}
Harald Welte70767382018-02-21 12:16:40 +0100289
Harald Weltef8df4cb2018-03-10 15:15:08 +0100290template (value) SystemInformation ts_SI2_default := {
291 header := ts_RrHeader(SYSTEM_INFORMATION_TYPE_2, 22),
Harald Weltef10153f2018-02-25 16:34:05 +0100292 payload := {
293 si2 := {
294 bcch_freq_list := '00000000000000000000000000000000'O,
295 ncc_permitted := '11111111'B,
296 rach_control := ts_RachCtrl_default
297 }
298 }
299}
300
Harald Weltef8df4cb2018-03-10 15:15:08 +0100301template (value) SystemInformation ts_SI4_default := {
302 header := ts_RrHeader(SYSTEM_INFORMATION_TYPE_4, 12), /* no CBCH / restoct */
Harald Weltef10153f2018-02-25 16:34:05 +0100303 payload := {
304 si4 := {
305 lai := ts_LAI_default,
306 cell_sel_par := ts_CellSelPar_default,
307 rach_control := ts_RachCtrl_default,
308 cbch_chan_desc := omit,
309 cbch_mobile_alloc := omit,
Vadim Yanitskiy12cf3d92020-05-05 00:19:50 +0700310 rest_octets := enc_SI4RestOctets(valueof(ts_SI4RestOctets_def))
Harald Weltef10153f2018-02-25 16:34:05 +0100311 }
312 }
313}
314
315function f_rsl_bcch_fill_raw(RSL_IE_SysinfoType rsl_si_type, octetstring si_enc)
316runs on test_CT {
317 log("Setting ", rsl_si_type, ": ", si_enc);
318 RSL_CCHAN.send(ts_RSL_UD(ts_RSL_BCCH_INFO(rsl_si_type, si_enc)));
319}
320
321function f_rsl_bcch_fill(RSL_IE_SysinfoType rsl_si_type, template (value) SystemInformation si_dec)
322runs on test_CT {
323 var octetstring si_enc := enc_SystemInformation(valueof(si_dec));
324 log("Setting ", rsl_si_type, ": ", si_dec);
325 f_rsl_bcch_fill_raw(rsl_si_type, si_enc);
326}
327
Harald Welte505cf9b2018-09-15 17:47:23 +0300328friend function f_init_vty(charstring id) runs on test_CT {
Harald Welte8da48242018-02-27 20:41:32 +0100329 map(self:BTSVTY, system:BTSVTY);
330 f_vty_set_prompts(BTSVTY);
331 f_vty_transceive(BTSVTY, "enable");
332}
333
Harald Welte505cf9b2018-09-15 17:47:23 +0300334friend function f_init_vty_bsc() runs on test_CT {
Harald Weltef50e3ae2018-09-10 10:27:56 +0200335 map(self:BSCVTY, system:BSCVTY);
336 f_vty_set_prompts(BSCVTY, "OsmoBSC");
337 f_vty_transceive(BSCVTY, "enable");
338}
339
Harald Welte883340c2018-02-28 18:59:29 +0100340/* PCU socket may at any time receive a new INFO.ind */
Harald Weltef26de0b2018-04-04 20:28:05 +0200341private altstep as_pcu_info_ind(PCUIF_CODEC_PT pt, integer pcu_conn_id,
342 out PCUIF_Message pcu_last_info) {
Harald Welte883340c2018-02-28 18:59:29 +0100343 var PCUIF_send_data sd;
Harald Weltef26de0b2018-04-04 20:28:05 +0200344 [] pt.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(0, ?))) -> value sd {
345 pcu_last_info := sd.data;
Harald Welted378a252018-03-13 17:02:14 +0100346 }
Harald Weltef26de0b2018-04-04 20:28:05 +0200347 [] pt.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(?, ?, ?))) -> value sd {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200348 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Invalid PCU Version/BTS Number received");
Harald Welte883340c2018-02-28 18:59:29 +0100349 }
350}
351
Harald Weltef26de0b2018-04-04 20:28:05 +0200352private function f_init_pcu(PCUIF_CODEC_PT pt, charstring id,
353 out integer pcu_conn_id, out PCUIF_Message pcu_last_info) {
Harald Welte883340c2018-02-28 18:59:29 +0100354 timer T := 2.0;
355 var PCUIF_send_data sd;
Harald Welte84271622018-03-10 17:21:03 +0100356 if (mp_pcu_socket == "") {
Harald Weltef26de0b2018-04-04 20:28:05 +0200357 pcu_conn_id := -1;
Harald Welte84271622018-03-10 17:21:03 +0100358 return;
359 }
Harald Weltef26de0b2018-04-04 20:28:05 +0200360 pcu_conn_id := f_pcuif_connect(pt, mp_pcu_socket);
Harald Welte883340c2018-02-28 18:59:29 +0100361
362 T.start;
363 alt {
Harald Weltef26de0b2018-04-04 20:28:05 +0200364 [] as_pcu_info_ind(pt, pcu_conn_id, pcu_last_info);
Harald Welte883340c2018-02-28 18:59:29 +0100365 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200366 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PCU INFO_IND");
Harald Welte883340c2018-02-28 18:59:29 +0100367 }
368 }
369}
370
Vadim Yanitskiyf4e997c2019-06-04 21:40:33 +0700371private function f_init_trxc(TRXC_CODEC_PT pt, charstring id,
372 out integer trxc_conn_id) {
373 var Result res;
374
375 res := TRXC_CodecPort_CtrlFunct.f_IPL4_connect(pt, mp_bts_trxc_ip, mp_bts_trxc_port,
376 "", -1, -1, { udp := {} }, {});
377 if (not ispresent(res.connId)) {
378 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
379 "Could not connect to the control (TRXC) interface " &
380 "of FakeTRX, check your configuration");
381 }
382 trxc_conn_id := res.connId;
383}
384
Harald Welte70767382018-02-21 12:16:40 +0100385/* global init function */
Harald Welte10474062019-05-30 16:48:17 +0200386function f_init() runs on test_CT {
387 var charstring id := testcasename();
Harald Welte629cc6b2018-03-11 17:19:05 +0100388 g_AllChannels := {
389 /* TS 1..4: TCH/F */
390 valueof(ts_RslChanNr_Bm(1)), valueof(ts_RslChanNr_Bm(2)),
391 valueof(ts_RslChanNr_Bm(3)), valueof(ts_RslChanNr_Bm(4)),
392 /* TS 5: TCH/H */
393 valueof(ts_RslChanNr_Lm(5,0)), valueof(ts_RslChanNr_Lm(5,1)),
394 /* TS 0: SDCCH/4 */
395 valueof(ts_RslChanNr_SDCCH4(0,0)), valueof(ts_RslChanNr_SDCCH4(0,1)),
396 valueof(ts_RslChanNr_SDCCH4(0,2)), valueof(ts_RslChanNr_SDCCH4(0,3)),
397 /* TS 6: SDCCH/8 */
398 valueof(ts_RslChanNr_SDCCH8(6,0)), valueof(ts_RslChanNr_SDCCH8(6,1)),
399 valueof(ts_RslChanNr_SDCCH8(6,2)), valueof(ts_RslChanNr_SDCCH8(6,3)),
400 valueof(ts_RslChanNr_SDCCH8(6,4)), valueof(ts_RslChanNr_SDCCH8(6,5)),
401 valueof(ts_RslChanNr_SDCCH8(6,6)), valueof(ts_RslChanNr_SDCCH8(6,7))
402 };
403
Pau Espin Pedrol3dcf38f2018-10-22 14:07:54 +0200404 /* FIXME: FACCH/H is unreliable with calypso firmware, see OS#3653 */
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +0700405 if (mp_bts_trxc_port != -1) {
Pau Espin Pedrol3dcf38f2018-10-22 14:07:54 +0200406 g_AllChanTypes := {
407 /* TS 1..4: TCH/F */
408 valueof(ts_RslChanNr_Bm(1)),
409 /* TS 5: TCH/H */
410 valueof(ts_RslChanNr_Lm(5,1)),
411 /* TS 0: SDCCH/4 */
412 valueof(ts_RslChanNr_SDCCH4(0,2)),
413 /* TS 6: SDCCH/8 */
414 valueof(ts_RslChanNr_SDCCH8(6,4))
415 };
416 } else {
417 g_AllChanTypes := {
418 /* TS 1..4: TCH/F */
419 valueof(ts_RslChanNr_Bm(1)),
420 /* TS 0: SDCCH/4 */
421 valueof(ts_RslChanNr_SDCCH4(0,2)),
422 /* TS 6: SDCCH/8 */
423 valueof(ts_RslChanNr_SDCCH8(6,4))
424 };
425 }
Harald Welte70767382018-02-21 12:16:40 +0100426 f_init_rsl(id);
Harald Welte2d142592018-02-25 13:19:44 +0100427 f_sleep(0.5); /* workaround for OS#3000 */
Harald Welte8da48242018-02-27 20:41:32 +0100428 f_init_vty(id);
Neels Hofmeyr6a84b232018-04-03 19:12:36 +0200429 f_ipa_ctrl_start(mp_ctrl_ip, mp_ctrl_port);
Harald Welte7484fc42018-02-24 14:09:45 +0100430
431 /* Send SI3 to the BTS, it is needed for various computations */
Harald Weltef10153f2018-02-25 16:34:05 +0100432 f_rsl_bcch_fill(RSL_SYSTEM_INFO_3, ts_SI3_default);
433 /* SI2 + SI4 are required for SI testing as they are mandatory defaults */
434 f_rsl_bcch_fill(RSL_SYSTEM_INFO_2, ts_SI2_default);
435 f_rsl_bcch_fill(RSL_SYSTEM_INFO_4, ts_SI4_default);
Harald Welte57fe8232018-02-26 17:52:50 +0100436
Harald Weltef26de0b2018-04-04 20:28:05 +0200437 map(self:PCU, system:PCU);
438 f_init_pcu(PCU, id, g_pcu_conn_id, g_pcu_last_info);
Harald Welte883340c2018-02-28 18:59:29 +0100439
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +0700440 if (mp_bts_trxc_port != -1) {
Harald Welte84271622018-03-10 17:21:03 +0100441 var TrxcMessage ret;
Vadim Yanitskiyf4e997c2019-06-04 21:40:33 +0700442
443 /* Init TRXC interface to FakeTRX */
444 map(self:BTS_TRXC, system:BTS_TRXC);
445 f_init_trxc(BTS_TRXC, id, g_bts_trxc_conn_id);
446
Vadim Yanitskiy10d72462019-06-04 22:27:52 +0700447 /* Start with a default moderate timing offset equalling TA=2, and RSSI=-60 */
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +0700448 ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, valueof(ts_TRXC_FAKE_TIMING(2*256)));
Vadim Yanitskiy10d72462019-06-04 22:27:52 +0700449 ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, valueof(ts_TRXC_FAKE_RSSI(-60)));
Vadim Yanitskiyde535e02019-07-26 16:29:27 +0700450 /* OsmoBTS may have different AB / NB threshold (see MIN_QUAL_NORM, MIN_QUAL_RACH) */
451 ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, valueof(ts_TRXC_FAKE_CI(60)));
Harald Welte84271622018-03-10 17:21:03 +0100452 }
Philipp Maierd95f3402019-04-18 17:50:52 +0200453
454 /* Wait some extra time to make sure the BTS emits a stable carrier.
455 * (this is only relevant when running the tests with a physical BTS.) */
456 f_sleep(mp_ipa_up_delay);
Harald Welte70767382018-02-21 12:16:40 +0100457}
458
Harald Welte68e495b2018-02-25 00:05:57 +0100459/* Attach L1CTL to master test_CT (classic tests, non-handler mode) */
460function f_init_l1ctl() runs on test_CT {
461 map(self:L1CTL, system:L1CTL);
462 f_connect_reset(L1CTL);
463}
464
Harald Welte70767382018-02-21 12:16:40 +0100465type function void_fn(charstring id) runs on ConnHdlr;
466
467/* create a new test component */
Vadim Yanitskiyf4e997c2019-06-04 21:40:33 +0700468function f_start_handler(void_fn fn, ConnHdlrPars pars,
469 boolean pcu_comp := false,
470 boolean trxc_comp := false)
Harald Welte70767382018-02-21 12:16:40 +0100471runs on test_CT return ConnHdlr {
472 var charstring id := testcasename();
473 var ConnHdlr vc_conn;
474
475 vc_conn := ConnHdlr.create(id);
476 /* connect to RSL Emulation main component */
477 connect(vc_conn:RSL, vc_RSL:CLIENT_PT);
478 connect(vc_conn:RSL_PROC, vc_RSL:RSL_PROC);
Vadim Yanitskiyf4e997c2019-06-04 21:40:33 +0700479
480 /* The ConnHdlr component may want to talk to some ports directly,
481 * so we disconnect it from the test_CT and connect it to the component.
482 * This obviously only works for one component, i.e. no concurrency. */
Harald Weltef26de0b2018-04-04 20:28:05 +0200483 if (pcu_comp) {
Harald Weltef26de0b2018-04-04 20:28:05 +0200484 unmap(self:PCU, system:PCU);
485 map(vc_conn:PCU, system:PCU);
486 }
Vadim Yanitskiyf4e997c2019-06-04 21:40:33 +0700487 if (trxc_comp) {
488 unmap(self:BTS_TRXC, system:BTS_TRXC);
489 map(vc_conn:BTS_TRXC, system:BTS_TRXC);
490 }
Harald Welte70767382018-02-21 12:16:40 +0100491
492 vc_conn.start(f_handler_init(fn, id, pars));
493 return vc_conn;
494}
495
Harald Welte7484fc42018-02-24 14:09:45 +0100496template ASP_RSL_Unitdata ts_RSL_UD(template RSL_Message rsl, IpaStreamId sid := IPAC_PROTO_RSL_TRX0) := {
497 streamId := sid,
498 rsl := rsl
499}
500
501template ASP_RSL_Unitdata tr_RSL_UD(template RSL_Message rsl,
502 template IpaStreamId sid := IPAC_PROTO_RSL_TRX0) := {
503 streamId := sid,
504 rsl := rsl
505}
506
Harald Welte70767382018-02-21 12:16:40 +0100507private altstep as_Tguard() runs on ConnHdlr {
508 [] g_Tguard.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200509 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Tguard timeout");
Harald Welte70767382018-02-21 12:16:40 +0100510 }
511}
512
Harald Welte990a3612019-05-27 14:02:13 +0200513friend function f_l1_tune(L1CTL_PT L1CTL, L1ctlCcchMode ccch_mode := CCCH_MODE_COMBINED) {
514 f_L1CTL_FBSB(L1CTL, { false, mp_trx0_arfcn }, ccch_mode, mp_rxlev_exp);
Harald Welte70767382018-02-21 12:16:40 +0100515}
516
Vadim Yanitskiy2f01fbd2019-06-01 01:32:48 +0700517private function f_trxc_fake_rssi(TRXC_RSSI rssi) runs on ConnHdlr {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100518 var TrxcMessage ret;
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +0700519 ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, valueof(ts_TRXC_FAKE_RSSI(rssi)));
Harald Welte70767382018-02-21 12:16:40 +0100520}
521
Vadim Yanitskiydc8db922019-06-04 21:58:15 +0700522private function f_trxc_fake_toffs256(int16_t toffs256) runs on ConnHdlr {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100523 var TrxcMessage ret;
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +0700524 ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, valueof(ts_TRXC_FAKE_TIMING(toffs256)));
Harald Welte70767382018-02-21 12:16:40 +0100525}
526
527/* first function started in ConnHdlr component */
528private function f_handler_init(void_fn fn, charstring id, ConnHdlrPars pars)
529runs on ConnHdlr {
530 g_pars := pars;
531 g_chan_nr := pars.chan_nr;
532
533 map(self:L1CTL, system:L1CTL);
534 f_connect_reset(L1CTL);
535
Harald Welted48c0c72019-06-05 10:01:15 +0200536 if (mp_bts_trxc_port != -1 and BTS_TRXC.checkstate("Mapped")) {
Vadim Yanitskiyf4e997c2019-06-04 21:40:33 +0700537 f_init_trxc(BTS_TRXC, id, g_bts_trxc_conn_id);
Harald Welte84271622018-03-10 17:21:03 +0100538 }
Harald Welte70767382018-02-21 12:16:40 +0100539
540 g_Tguard.start(pars.t_guard);
541 activate(as_Tguard());
542
543 f_rslem_register(0, pars.chan_nr);
544
545 /* call the user-supplied test case function */
546 fn.apply(id);
547}
548
Harald Welteb1726c92018-03-30 11:56:38 +0200549function f_rsl_transceive_ret(template RSL_Message tx, template RSL_Message exp_rx, charstring id,
550 boolean ignore_other := false)
551runs on ConnHdlr return RSL_Message {
552 var RSL_Message rx;
Harald Welte1eba3742018-02-25 12:48:14 +0100553 timer T := 3.0;
554 RSL.send(tx);
555 T.start;
Harald Welte70767382018-02-21 12:16:40 +0100556 alt {
Harald Welteb1726c92018-03-30 11:56:38 +0200557 [] RSL.receive(exp_rx) -> value rx {
Harald Welte1eba3742018-02-25 12:48:14 +0100558 T.stop;
559 setverdict(pass);
Harald Welte70767382018-02-21 12:16:40 +0100560 }
Harald Welte1eba3742018-02-25 12:48:14 +0100561 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200562 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout expecting " & id);
Harald Welte1eba3742018-02-25 12:48:14 +0100563 }
Harald Welte21240e62018-03-11 21:43:35 +0100564 [not ignore_other] as_l1_sacch();
565 [not ignore_other] as_meas_res();
566 [not ignore_other] as_l1_dcch();
567 [not ignore_other] RSL.receive {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200568 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RSL message received");
Harald Welte70767382018-02-21 12:16:40 +0100569 }
Harald Welte21240e62018-03-11 21:43:35 +0100570 [ignore_other] RSL.receive { repeat; }
Harald Welte70767382018-02-21 12:16:40 +0100571 }
Harald Welteb1726c92018-03-30 11:56:38 +0200572 return rx;
573}
574
575function f_rsl_transceive(template RSL_Message tx, template RSL_Message exp_rx, charstring id,
576 boolean ignore_other := false)
577runs on ConnHdlr {
578 var RSL_Message rx := f_rsl_transceive_ret(tx, exp_rx, id, ignore_other);
Harald Welte70767382018-02-21 12:16:40 +0100579}
580
Harald Welte8b01c792019-05-19 22:51:25 +0200581function f_rsl_chan_act(RSL_IE_ChannelMode mode, boolean encr_enable := false, RSL_IE_List more_ies := {},
582 RSL_IE_ActivationType act_type := t_RSL_IE_ActType_IA) runs on ConnHdlr {
583 var RSL_Message ch_act := valueof(ts_RSL_CHAN_ACT(g_chan_nr, mode, act_type));
Harald Weltee613f962018-04-18 22:38:16 +0200584 if (encr_enable) {
585 /* append encryption related IEs, if requested */
586 var RSL_IE_EncryptionInfo encr_info;
587 encr_info := valueof(ts_RSL_IE_EncrInfo(g_pars.encr.alg_id, g_pars.encr.key));
588 ch_act.ies := ch_act.ies & { valueof(t_RSL_IE(RSL_IE_ENCR_INFO, RSL_IE_Body:{encr_info :=
589encr_info})) };
590 }
Harald Weltec8d363c2019-05-19 20:36:48 +0200591 ch_act.ies := ch_act.ies & more_ies;
Harald Weltee613f962018-04-18 22:38:16 +0200592 f_rsl_transceive(ch_act, tr_RSL_CHAN_ACT_ACK(g_chan_nr), "RSL CHAN ACT");
Harald Welte1eba3742018-02-25 12:48:14 +0100593}
594
Harald Welte70767382018-02-21 12:16:40 +0100595function f_rsl_chan_deact() runs on ConnHdlr {
Harald Welte1eba3742018-02-25 12:48:14 +0100596 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 +0100597 "RF CHAN REL", true);
Harald Welte70767382018-02-21 12:16:40 +0100598}
599
Harald Welte2f2b2b72019-05-31 22:24:57 +0200600friend template ConnHdlrPars t_Pars(template RslChannelNr chan_nr,
Harald Welte70767382018-02-21 12:16:40 +0100601 template RSL_IE_ChannelMode chan_mode,
602 float t_guard := 20.0) := {
603 chan_nr := valueof(chan_nr),
604 chan_mode := valueof(chan_mode),
605 t_guard := t_guard,
606 l1_pars := {
607 dtx_enabled := false,
Harald Welte685d5982018-02-27 20:42:05 +0100608 toa256_enabled := false,
Harald Welte70767382018-02-21 12:16:40 +0100609 meas_ul := {
610 full := {
Pau Espin Pedrole9571aa2018-10-22 17:13:07 +0200611 rxlev := mp_ul_rxlev_exp,
Harald Welte70767382018-02-21 12:16:40 +0100612 rxqual := 0
613 },
614 sub := {
Pau Espin Pedrole9571aa2018-10-22 17:13:07 +0200615 rxlev := mp_ul_rxlev_exp,
Harald Welte70767382018-02-21 12:16:40 +0100616 rxqual := 0
617 }
618 },
Pau Espin Pedrol121724c2018-09-28 15:58:12 +0200619 timing_offset_256syms := mp_timing_offset_256syms_exp,
Harald Welte70767382018-02-21 12:16:40 +0100620 bs_power_level := 0,
Pau Espin Pedroled359cb2018-09-28 16:08:24 +0200621 ms_power_level := mp_ms_power_level_exp,
Pau Espin Pedrol121724c2018-09-28 15:58:12 +0200622 ms_actual_ta := mp_ms_actual_ta_exp
Harald Welte0472ab42018-03-12 15:02:26 +0100623 },
Harald Weltee613f962018-04-18 22:38:16 +0200624 spec := omit,
Eric Wild61edb7e2019-06-03 12:38:31 +0200625 encr := omit,
626 bts0_band := omit
Harald Welte70767382018-02-21 12:16:40 +0100627}
628
Harald Welte93640c62018-02-25 16:59:33 +0100629/***********************************************************************
630 * Channel Activation / Deactivation
631 ***********************************************************************/
632
Harald Welte70767382018-02-21 12:16:40 +0100633/* Stress test: Do 500 channel activations/deactivations in rapid succession */
634function f_TC_chan_act_stress(charstring id) runs on ConnHdlr {
635 for (var integer i := 0; i < 500; i := i+1) {
636 f_rsl_chan_act(g_pars.chan_mode);
637 f_rsl_chan_deact();
638 }
639 setverdict(pass);
640}
641testcase TC_chan_act_stress() runs on test_CT {
642 var ConnHdlr vc_conn;
643 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
Harald Welte10474062019-05-30 16:48:17 +0200644 f_init();
Harald Welte70767382018-02-21 12:16:40 +0100645 vc_conn := f_start_handler(refers(f_TC_chan_act_stress), pars);
646 vc_conn.done;
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200647 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +0100648}
649
650/* Test if re-activation of an already active channel fails as expected */
651function f_TC_chan_act_react(charstring id) runs on ConnHdlr {
652 f_rsl_chan_act(g_pars.chan_mode);
653 /* attempt to activate the same lchan again -> expect reject */
654 RSL.send(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode));
655 alt {
656 [] RSL.receive(tr_RSL_CHAN_ACT_ACK(g_chan_nr)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200657 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected CHAN ACT ACK on double activation");
Harald Welte70767382018-02-21 12:16:40 +0100658 }
659 [] RSL.receive(tr_RSL_CHAN_ACT_NACK(g_chan_nr)) {
660 setverdict(pass);
661 }
662 }
663 f_rsl_chan_deact();
664}
665testcase TC_chan_act_react() runs on test_CT {
666 var ConnHdlr vc_conn;
667 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
Harald Welte294b0a22018-03-10 23:26:48 +0100668 f_init();
Harald Welte70767382018-02-21 12:16:40 +0100669 vc_conn := f_start_handler(refers(f_TC_chan_act_react), pars);
670 vc_conn.done;
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200671 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +0100672}
673
674/* Attempt to de-activate a channel that's not active */
675function f_TC_chan_deact_not_active(charstring id) runs on ConnHdlr {
676 timer T := 3.0;
677 RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr));
678 T.start;
679 alt {
680 [] RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr)) {
681 setverdict(pass);
682 }
683 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200684 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout expecting RF_CHAN_REL_ACK");
Harald Welte70767382018-02-21 12:16:40 +0100685 }
686 }
687}
688testcase TC_chan_deact_not_active() runs on test_CT {
689 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
Harald Welte294b0a22018-03-10 23:26:48 +0100690 f_init();
Harald Welte70767382018-02-21 12:16:40 +0100691 var ConnHdlr vc_conn := f_start_handler(refers(f_TC_chan_deact_not_active), pars);
692 vc_conn.done;
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200693 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +0100694}
695
696/* attempt to activate channel with wrong RSL Channel Nr IE; expect NACK */
697function f_TC_chan_act_wrong_nr(charstring id) runs on ConnHdlr {
698 RSL.send(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode));
699 alt {
700 [] RSL.receive(tr_RSL_CHAN_ACT_ACK(g_chan_nr)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200701 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected CHAN ACT ACK");
Harald Welte70767382018-02-21 12:16:40 +0100702 }
703 [] RSL.receive(tr_RSL_CHAN_ACT_NACK(g_chan_nr)) {
704 setverdict(pass);
705 }
706 }
707}
708private type record WrongChanNrCase {
709 RslChannelNr chan_nr,
710 charstring description
711}
712private type record of WrongChanNrCase WrongChanNrCases;
713private template WrongChanNrCase t_WCN(template RslChannelNr chan_nr, charstring desc) := {
714 chan_nr := chan_nr,
715 description := desc
716}
717
718testcase TC_chan_act_wrong_nr() runs on test_CT {
719 var ConnHdlr vc_conn;
720 var ConnHdlrPars pars;
721
Harald Welte294b0a22018-03-10 23:26:48 +0100722 f_init();
Harald Welte70767382018-02-21 12:16:40 +0100723
724 var WrongChanNrCases wrong := {
725 valueof(t_WCN(t_RslChanNr_RACH(0), "RACH is not a dedicated channel")),
726 valueof(t_WCN(t_RslChanNr_RACH(1), "RACH doesn't exist on timeslot")),
727 valueof(t_WCN(t_RslChanNr_BCCH(0), "BCCH is not a dedicated channel")),
728 valueof(t_WCN(t_RslChanNr_PCH_AGCH(0), "PCH/AGCH is not a dedicated channel")),
729 valueof(t_WCN(t_RslChanNr_Bm(0), "TS0 cannot be TCH/F")),
730 valueof(t_WCN(t_RslChanNr_Lm(0, 0), "TS0 cannot be TCH/H")),
731 valueof(t_WCN(t_RslChanNr_Lm(0, 1), "TS0 cannot be TCH/H")),
732 valueof(t_WCN(t_RslChanNr_PDCH(0), "TS0 cannot be PDCH")),
733 valueof(t_WCN(t_RslChanNr_SDCCH8(0, 0), "TS0 cannot be SDCCH/8")),
734 valueof(t_WCN(t_RslChanNr_SDCCH8(0, 7), "TS0 cannot be SDCCH/8")),
735 valueof(t_WCN(t_RslChanNr_SDCCH4(7, 0), "TS7 cannot be SDCCH/4")),
736 valueof(t_WCN(t_RslChanNr_SDCCH4(7, 3), "TS7 cannot be SDCCH/4")),
737 valueof(t_WCN(t_RslChanNr_Lm(1, 0), "TS1 cannot be TCH/H"))
738 };
739
740 for (var integer i := 0; i < sizeof(wrong); i := i+1) {
741 pars := valueof(t_Pars(wrong[i].chan_nr, ts_RSL_ChanMode_SIGN));
742 vc_conn := f_start_handler(refers(f_TC_chan_act_wrong_nr), pars);
743 vc_conn.done;
744 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200745 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +0100746}
747
Harald Weltee613f962018-04-18 22:38:16 +0200748/* execute the same callback function on a variety of logical channels */
Harald Welte2f2b2b72019-05-31 22:24:57 +0200749friend function f_testmatrix_each_chan(ConnHdlrPars pars, void_fn fn) runs on test_CT {
Harald Weltee613f962018-04-18 22:38:16 +0200750 var ConnHdlr vc_conn;
Harald Welte10474062019-05-30 16:48:17 +0200751 f_init();
Harald Weltee613f962018-04-18 22:38:16 +0200752
753 /* test on each of the channels we have */
754 for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i+1) {
755 pars.chan_nr := valueof(g_AllChanTypes[i]);
756
757 log(testcasename(), ": XXX Starting on ", g_AllChanTypes[i]);
758 vc_conn := f_start_handler(fn, pars);
759 vc_conn.done;
760 }
761
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200762 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Weltee613f962018-04-18 22:38:16 +0200763}
764
Harald Welte93640c62018-02-25 16:59:33 +0100765/***********************************************************************
Harald Welte629cc6b2018-03-11 17:19:05 +0100766 * SACCH handling
767 ***********************************************************************/
768
769private function f_exp_sacch(boolean exp) runs on ConnHdlr {
770 timer T_sacch := 3.0;
771 T_sacch.start;
772 alt {
773 [not exp] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200774 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received SACCH when not expecting it");
Harald Welte629cc6b2018-03-11 17:19:05 +0100775 }
776 [not exp] T_sacch.timeout {
777 setverdict(pass);
778 }
779 [exp] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) {
780 setverdict(pass);
781 }
782 [exp] T_sacch.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200783 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Timeout waiting for SACCH on ", g_chan_nr));
Harald Welte629cc6b2018-03-11 17:19:05 +0100784 }
785 [] L1CTL.receive { repeat; }
786 [] RSL.receive { repeat; }
787 }
788}
789
790/* Test if DEACTIVATE SACCH actualy deactivates its transmission (TS 48.058 4.6) */
791private function f_TC_deact_sacch(charstring id) runs on ConnHdlr {
792 f_l1_tune(L1CTL);
793 RSL.clear;
794
795 /* activate the logical channel */
796 f_est_dchan();
797 L1CTL.clear;
798
799 /* check that SACCH actually are received as expected */
800 f_exp_sacch(true);
801
802 /* deactivate SACCH on the logical channel */
803 RSL.send(ts_RSL_DEACT_SACCH(g_chan_nr));
804 f_sleep(1.0);
805 L1CTL.clear;
806
807 /* check that no SACCH are received anymore */
808 f_exp_sacch(false);
809
810 /* release the channel */
811 f_rsl_chan_deact();
812 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
813}
814testcase TC_deact_sacch() runs on test_CT {
815 var ConnHdlr vc_conn;
816 var ConnHdlrPars pars;
817 f_init();
818 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
819 //for (var integer i := 0; i < 1; 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_deact_sacch), 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 Welte629cc6b2018-03-11 17:19:05 +0100827}
828
Harald Welte55700662018-03-12 13:15:43 +0100829/* verify that given SACCH payload is present */
Harald Welteea17b912018-03-11 22:29:31 +0100830private function f_sacch_present(template octetstring l3_exp) runs on ConnHdlr {
831 var L1ctlDlMessage dl;
832 /* check that the specified SI5 value is actually sent */
833 timer T_sacch := 3.0;
834 L1CTL.clear;
835 T_sacch.start;
836 alt {
837 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) -> value dl {
838 var octetstring l3 := substr(dl.payload.data_ind.payload, 4, 19);
839 if (match(l3, l3_exp)) {
840 setverdict(pass);
841 } else {
842 repeat;
843 }
844 }
845 [] L1CTL.receive { repeat; }
846 [] T_sacch.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200847 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Timeout waiting for SACCH ", l3_exp));
Harald Welteea17b912018-03-11 22:29:31 +0100848 }
849 }
850}
851
Harald Welte55700662018-03-12 13:15:43 +0100852/* verify that given SACCH payload is not present */
853private function f_sacch_missing(template octetstring l3_exp) runs on ConnHdlr {
854 var L1ctlDlMessage dl;
855 /* check that the specified SI5 value is actually sent */
856 timer T_sacch := 3.0;
857 L1CTL.clear;
858 T_sacch.start;
859 alt {
860 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) -> value dl {
861 var octetstring l3 := substr(dl.payload.data_ind.payload, 4, 19);
862 if (match(l3, l3_exp)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200863 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Received unexpected SACCH ", dl));
Harald Welte55700662018-03-12 13:15:43 +0100864 } else {
865 repeat;
866 }
867 }
868 [] L1CTL.receive { repeat; }
869 [] T_sacch.timeout {
870 setverdict(pass);
871 }
872 }
873}
874
Harald Welte629cc6b2018-03-11 17:19:05 +0100875/* Test for default SACCH FILL transmitted in DL SACCH (all channel types) */
Harald Welteea17b912018-03-11 22:29:31 +0100876private function f_TC_sacch_filling(charstring id) runs on ConnHdlr {
877 /* Set a known default SACCH filling for SI5 */
878 var octetstring si5 := f_rnd_octstring(19);
879 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5));
880
881 f_l1_tune(L1CTL);
882 RSL.clear;
883
884 /* activate the logical channel */
885 f_est_dchan();
886
887 /* check that the specified SI5 value is actually sent */
888 f_sacch_present(si5);
889
890 /* release the channel */
891 RSL.clear;
892 f_rsl_chan_deact();
893 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
894}
895testcase TC_sacch_filling() runs on test_CT {
896 var ConnHdlr vc_conn;
897 var ConnHdlrPars pars;
898 f_init();
899 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
900 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
901 log(testcasename(), ": Starting for ", g_AllChannels[i]);
902 vc_conn := f_start_handler(refers(f_TC_sacch_filling), pars);
903 vc_conn.done;
904 }
905 /* TODO: do the above in parallel, rather than sequentially? */
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200906 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welteea17b912018-03-11 22:29:31 +0100907}
908
Harald Welte629cc6b2018-03-11 17:19:05 +0100909/* Test for lchan-specific SACCH INFO MODIFY (TS 48.058 4.12) */
Harald Welteea17b912018-03-11 22:29:31 +0100910private function f_TC_sacch_info_mod(charstring id) runs on ConnHdlr {
911 /* Set a known default SACCH filling for SI5 */
912 var octetstring si5 := f_rnd_octstring(19);
913 var octetstring si5_diff := f_rnd_octstring(19);
914 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5));
915
916 f_l1_tune(L1CTL);
917 RSL.clear;
918
919 log("Activating channel, expecting standard SI5");
920 /* activate the logical channel */
921 f_est_dchan();
922 /* check that the specified SI5 value is actually sent */
923 f_sacch_present(si5);
924
925 /* set channel-specific different SI5 */
926 log("Setting channel specific SACCH INFO, expecting it");
927 RSL.send(ts_RSL_SACCH_INF_MOD(g_chan_nr, RSL_SYSTEM_INFO_5, si5_diff))
928 /* check that the specified lchan-specific value is now used */
929 f_sacch_present(si5_diff);
930
931 /* deactivate the channel and re-activate it, this should result in default SI5 */
932 log("De-activating and re-activating channel, expecting standard SI5");
933 f_rsl_chan_deact();
934 f_rsl_chan_act(valueof(ts_RSL_ChanMode_SIGN));
935 /* Verify that the TRX-wide default SACCH filling is present again */
936 f_sacch_present(si5);
937
938 /* release the channel */
939 RSL.clear;
940 f_rsl_chan_deact();
941 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
942}
943testcase TC_sacch_info_mod() runs on test_CT {
944 var ConnHdlr vc_conn;
945 var ConnHdlrPars pars;
946 f_init();
947 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
948 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
949 log(testcasename(), ": Starting for ", g_AllChannels[i]);
950 vc_conn := f_start_handler(refers(f_TC_sacch_info_mod), pars);
951 vc_conn.done;
952 }
953 /* TODO: do the above in parallel, rather than sequentially? */
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200954 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welteea17b912018-03-11 22:29:31 +0100955}
956
Harald Welte075d84c2018-03-12 13:07:24 +0100957/* Test SACCH scheduling of multiple different SI message types */
958private function f_TC_sacch_multi(charstring id) runs on ConnHdlr {
959 var octetstring si5 := f_rnd_octstring(19);
960 var octetstring si5bis := f_rnd_octstring(19);
961 var octetstring si5ter := f_rnd_octstring(19);
962 var octetstring si6 := f_rnd_octstring(19);
963
964 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5));
965 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5bis, si5bis));
966 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5ter, si5ter));
967 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, si6));
968
969 f_l1_tune(L1CTL);
970 RSL.clear;
971
972 /* activate the logical channel */
973 f_est_dchan();
974 L1CTL.clear;
975
976 /* check that SACCH actually are received as expected */
977 f_sacch_present(si5);
978 f_sacch_present(si5bis);
979 f_sacch_present(si5ter);
980 f_sacch_present(si6);
981
982 /* release the channel */
983 f_rsl_chan_deact();
984 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
985}
986testcase TC_sacch_multi() runs on test_CT {
987 var ConnHdlr vc_conn;
988 var ConnHdlrPars pars;
989 f_init();
990 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
991 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
992 log(testcasename(), ": Starting for ", g_AllChannels[i]);
993 vc_conn := f_start_handler(refers(f_TC_sacch_multi), pars);
994 vc_conn.done;
995 }
996 /* TODO: do the above in parallel, rather than sequentially? */
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200997 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte075d84c2018-03-12 13:07:24 +0100998}
999
Harald Welte55700662018-03-12 13:15:43 +01001000/* Test if SACH information is modified as expected */
1001private function f_TC_sacch_multi_chg(charstring id) runs on ConnHdlr {
1002 var octetstring si5 := f_rnd_octstring(19);
1003 var octetstring si6 := f_rnd_octstring(19);
1004
1005 /* First, configure both SI5 and SI6 to be transmitted */
1006 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5));
1007 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, si6));
1008
1009 f_l1_tune(L1CTL);
1010 RSL.clear;
1011
1012 /* activate the logical channel */
1013 f_est_dchan();
1014 L1CTL.clear;
1015
1016 /* check that SACCH actually are received as expected */
1017 f_sacch_present(si5);
1018 f_sacch_present(si6);
1019
1020 /* disable SI6 */
1021 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, ''O));
1022
1023 /* check that SI5 is still transmitted */
1024 f_sacch_present(si5);
1025 /* check if SI6 is now gone */
1026 f_sacch_missing(si6);
1027
1028 /* release the channel */
1029 f_rsl_chan_deact();
1030 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1031}
1032testcase TC_sacch_multi_chg() runs on test_CT {
1033 var ConnHdlr vc_conn;
1034 var ConnHdlrPars pars;
1035 f_init();
1036 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
1037 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
1038 log(testcasename(), ": Starting for ", g_AllChannels[i]);
1039 vc_conn := f_start_handler(refers(f_TC_sacch_multi_chg), pars);
1040 vc_conn.done;
1041 }
1042 /* TODO: do the above in parallel, rather than sequentially? */
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001043 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte55700662018-03-12 13:15:43 +01001044}
1045
Harald Weltec8d363c2019-05-19 20:36:48 +02001046/* Test for SACCH information present in RSL CHAN ACT (overrides FILLING) */
1047private function f_TC_sacch_chan_act(charstring id) runs on ConnHdlr {
1048 var octetstring si5 := f_rnd_octstring(19);
1049 var octetstring si6 := f_rnd_octstring(19);
1050 var octetstring si5_specific := f_rnd_octstring(19);
1051 var octetstring si6_specific := f_rnd_octstring(19);
1052
1053 /* First, configure both SI5 and SI6 to be transmitted */
1054 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5));
1055 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, si6));
1056
1057 f_l1_tune(L1CTL);
1058 RSL.clear;
1059
1060 /* activate channel with different SACCH filling */
1061 var RSL_SacchInfo sacch_info := valueof(ts_RSL_SacchInfo({
1062 ts_RSL_SacchInfoElem(RSL_SYSTEM_INFO_5, si5_specific),
1063 ts_RSL_SacchInfoElem(RSL_SYSTEM_INFO_6, si6_specific)
1064 }));
1065 var RSL_IE_List addl_ies := { valueof(t_RSL_IE(RSL_IE_SACCH_INFO,
1066 RSL_IE_Body:{sacch_info := sacch_info})) };
1067 f_est_dchan(more_ies := addl_ies);
1068
1069 /* check that SACCH actually are received as expected */
1070 f_sacch_present(si5_specific);
1071 f_sacch_present(si6_specific);
1072
1073 /* release the channel */
1074 f_rsl_chan_deact();
1075 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1076}
1077testcase TC_sacch_chan_act() runs on test_CT {
1078 var ConnHdlr vc_conn;
1079 var ConnHdlrPars pars;
1080 f_init();
1081
1082 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
1083 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
1084 log(testcasename(), ": Starting for ", g_AllChannels[i]);
1085 vc_conn := f_start_handler(refers(f_TC_sacch_chan_act), pars);
1086 vc_conn.done;
1087 }
1088 /* TODO: do the above in parallel, rather than sequentially? */
1089 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
1090}
1091
Harald Welte8b01c792019-05-19 22:51:25 +02001092/* verify that SACCH DL transmission is started only if MS power IE present
1093 * see section 4.1.3 of 3GPP TS 48.058 */
1094private function f_TC_sacch_chan_act_ho_async(charstring id) runs on ConnHdlr {
1095 var octetstring si5 := f_rnd_octstring(19);
1096
1097 f_l1_tune(L1CTL);
1098 RSL.clear;
1099
1100 /* Step 1: Activate ASYNC HO channel without MS power IE */
1101
1102 /* Activate channel on BTS side */
1103 f_rsl_chan_act(g_pars.chan_mode, act_type := t_RSL_IE_ActType_HO_ASYNC);
1104 /* don't perform immediate assignment here, as we're testing non-IA case */
1105 /* enable dedicated mode */
1106 f_L1CTL_DM_EST_REQ(L1CTL, {false, mp_trx0_arfcn }, g_pars.chan_nr, 7);
1107
1108 /* Verify that no DL SACCH is being received */
1109 f_sacch_missing(?);
1110
1111 f_rsl_chan_deact();
1112 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1113
1114
1115 /* Step 2: Activate ASYNC HO channel with MS power IE */
1116
1117 /* Activate channel on BTS side */
1118 var RSL_IE_List addl_ies := {
1119 valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(0)}))
1120 };
1121 f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_ASYNC);
1122 /* don't perform immediate assignment here, as we're testing non-IA case */
1123 /* enable dedicated mode */
1124 f_L1CTL_DM_EST_REQ(L1CTL, {false, mp_trx0_arfcn }, g_pars.chan_nr, 7);
1125
1126 /* Verify that DL SACCH is being received */
1127 f_sacch_present(si5);
1128
1129 f_rsl_chan_deact();
1130 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1131}
1132testcase TC_sacch_chan_act_ho_async() runs on test_CT {
1133 var ConnHdlr vc_conn;
1134 var ConnHdlrPars pars;
1135 f_init();
1136
1137 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
1138 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
1139 log(testcasename(), ": Starting for ", g_AllChannels[i]);
1140 vc_conn := f_start_handler(refers(f_TC_sacch_chan_act_ho_async), pars);
1141 vc_conn.done;
1142 }
1143 /* TODO: do the above in parallel, rather than sequentially? */
1144 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
1145}
1146
1147/* verify that SACCH DL transmission is started only if TA + MS power IEs present,
1148 * see section 4.1.4 of 3GPP TS 48.058 */
1149private function f_TC_sacch_chan_act_ho_sync(charstring id) runs on ConnHdlr {
1150 var octetstring si5 := f_rnd_octstring(19);
1151 var RSL_IE_List addl_ies;
1152
1153 f_l1_tune(L1CTL);
1154 RSL.clear;
1155
1156 /* Step 1: Activate SYNC HO channel without MS power IE */
1157
1158 /* Activate channel on BTS side */
1159 f_rsl_chan_act(g_pars.chan_mode, act_type := t_RSL_IE_ActType_HO_SYNC);
1160 /* don't perform immediate assignment here, as we're testing non-IA case */
1161 /* enable dedicated mode */
1162 f_L1CTL_DM_EST_REQ(L1CTL, {false, mp_trx0_arfcn }, g_pars.chan_nr, 7);
1163
1164 /* Verify that no DL SACCH is being received */
1165 f_sacch_missing(?);
1166
1167 f_rsl_chan_deact();
1168 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1169
1170
1171 /* Step 2a: Activate SYNC HO channel with only MS power IE */
1172
1173 /* Activate channel on BTS side */
1174 addl_ies := {
1175 valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(0)}))
1176 };
1177 f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_SYNC);
1178 /* don't perform immediate assignment here, as we're testing non-IA case */
1179 /* enable dedicated mode */
1180 f_L1CTL_DM_EST_REQ(L1CTL, {false, mp_trx0_arfcn }, g_pars.chan_nr, 7);
1181
1182 /* Verify that no DL SACCH is being received */
1183 f_sacch_missing(?);
1184
1185 f_rsl_chan_deact();
1186 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1187
1188
1189 /* Step 2b: Activate SYNC HO channel with TA IE */
1190
1191 /* Activate channel on BTS side */
1192 addl_ies := {
1193 valueof(t_RSL_IE(RSL_IE_TIMING_ADVANCE, RSL_IE_Body:{timing_adv := 0}))
1194 };
1195 f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_SYNC);
1196 /* don't perform immediate assignment here, as we're testing non-IA case */
1197 /* enable dedicated mode */
1198 f_L1CTL_DM_EST_REQ(L1CTL, {false, mp_trx0_arfcn }, g_pars.chan_nr, 7);
1199
1200 /* Verify that no DL SACCH is being received */
1201 f_sacch_missing(?);
1202
1203 f_rsl_chan_deact();
1204 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1205
1206
1207 /* Step 3: Activate SYNC HO channel with MS power IE and TA IE */
1208
1209 /* Activate channel on BTS side */
1210 addl_ies := {
1211 valueof(t_RSL_IE(RSL_IE_TIMING_ADVANCE, RSL_IE_Body:{timing_adv := 0})),
1212 valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(0)}))
1213 };
1214 f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_SYNC);
1215 /* don't perform immediate assignment here, as we're testing non-IA case */
1216 /* enable dedicated mode */
1217 f_L1CTL_DM_EST_REQ(L1CTL, {false, mp_trx0_arfcn }, g_pars.chan_nr, 7);
1218
1219 /* Verify that DL SACCH is being received */
1220 f_sacch_present(si5);
1221
1222 f_rsl_chan_deact();
1223 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1224}
1225testcase TC_sacch_chan_act_ho_sync() runs on test_CT {
1226 var ConnHdlr vc_conn;
1227 var ConnHdlrPars pars;
1228 f_init();
1229
1230 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
1231 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
1232 log(testcasename(), ": Starting for ", g_AllChannels[i]);
1233 vc_conn := f_start_handler(refers(f_TC_sacch_chan_act_ho_sync), pars);
1234 vc_conn.done;
1235 }
1236 /* TODO: do the above in parallel, rather than sequentially? */
1237 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
1238}
Harald Welte629cc6b2018-03-11 17:19:05 +01001239
1240
1241/***********************************************************************
Harald Welte93640c62018-02-25 16:59:33 +01001242 * RACH Handling
1243 ***********************************************************************/
1244
Harald Welte8c24c2b2018-02-26 08:31:31 +01001245/* like L1SAP_IS_PACKET_RACH */
1246private function ra_is_ps(OCT1 ra) return boolean {
Harald Welte56c05802018-02-28 21:39:35 +01001247 if ((ra and4b 'F0'O == '70'O) and (ra and4b '0F'O != '0F'O)) {
Harald Welte8c24c2b2018-02-26 08:31:31 +01001248 return true;
1249 }
1250 return false;
1251}
1252
1253/* generate a random RACH for circuit-switched */
1254private function f_rnd_ra_cs() return OCT1 {
1255 var OCT1 ra;
1256 do {
1257 ra := f_rnd_octstring(1);
1258 } while (ra_is_ps(ra));
1259 return ra;
1260}
1261
Harald Welte883340c2018-02-28 18:59:29 +01001262/* generate a random RACH for packet-switched */
1263private function f_rnd_ra_ps() return OCT1 {
1264 var OCT1 ra;
1265 do {
1266 ra := f_rnd_octstring(1);
1267 } while (not ra_is_ps(ra));
1268 return ra;
1269}
1270
Vadim Yanitskiy51cbc102019-04-22 06:37:30 +07001271/* generate a random 11-bit RA (packet-switched only) */
1272private function f_rnd_ra11_ps() return BIT11 {
1273 var integer ra11 := f_rnd_int(bit2int('11111111111'B));
1274 return int2bit(ra11, 11);
1275}
1276
Harald Welte8c24c2b2018-02-26 08:31:31 +01001277/* Send 1000 RACH requests and check their RA+FN on the RSL side */
1278testcase TC_rach_content() runs on test_CT {
Harald Welte10474062019-05-30 16:48:17 +02001279 f_init();
Harald Welte8c24c2b2018-02-26 08:31:31 +01001280 f_init_l1ctl();
Harald Welte68e495b2018-02-25 00:05:57 +01001281 f_l1_tune(L1CTL);
Harald Welte70767382018-02-21 12:16:40 +01001282
Harald Welte8c24c2b2018-02-26 08:31:31 +01001283 var GsmFrameNumber fn_last := 0;
Maxa199a2e2019-02-25 16:31:11 +01001284 var boolean test_failed := false;
Harald Welte8c24c2b2018-02-26 08:31:31 +01001285 for (var integer i := 0; i < 1000; i := i+1) {
1286 var OCT1 ra := f_rnd_ra_cs();
1287 var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra));
1288 if (fn == fn_last) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001289 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?");
Harald Welte8c24c2b2018-02-26 08:31:31 +01001290 }
1291 fn_last := fn;
1292
1293 timer T := 5.0;
Harald Welte56c05802018-02-28 21:39:35 +01001294 T.start;
Harald Welte8c24c2b2018-02-26 08:31:31 +01001295 alt {
Vadim Yanitskiyab448a52019-05-31 20:24:03 +07001296 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_CHAN_RQD(ra, fn, t_RslChanNr_RACH(0)))) {
Harald Welte8c24c2b2018-02-26 08:31:31 +01001297 T.stop;
1298 }
Vadim Yanitskiyab448a52019-05-31 20:24:03 +07001299 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_CHAN_RQD(?, ?, ?, ?))) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001300 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected CHAN RQD");
Harald Welte8c24c2b2018-02-26 08:31:31 +01001301 }
1302 [] RSL_CCHAN.receive { repeat; }
1303 [] T.timeout {
Maxa199a2e2019-02-25 16:31:11 +01001304 test_failed := true;
1305 log("[", i, "] Timeout waiting for CHAN RQD FN=", fn, " RA=", ra);
Harald Welte8c24c2b2018-02-26 08:31:31 +01001306 }
1307 }
1308 }
Maxba06feb2019-03-05 10:52:46 +01001309 if (test_failed) {
1310 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Some out of 1000 RACH requests timed out"));
Maxa199a2e2019-02-25 16:31:11 +01001311 }
Maxba06feb2019-03-05 10:52:46 +01001312 setverdict(pass);
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001313 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +01001314}
Harald Welte8c24c2b2018-02-26 08:31:31 +01001315
1316/* Send 1000 RACH Requests (flood ~ 89/s) and count if count(Abis) == count(Um) */
1317testcase TC_rach_count() runs on test_CT {
Harald Welte294b0a22018-03-10 23:26:48 +01001318 f_init();
Harald Welte8c24c2b2018-02-26 08:31:31 +01001319 f_init_l1ctl();
Harald Welte294b0a22018-03-10 23:26:48 +01001320 f_sleep(1.0);
Harald Welte8c24c2b2018-02-26 08:31:31 +01001321 f_l1_tune(L1CTL);
1322
1323 var GsmFrameNumber fn_last := 0;
1324 for (var integer i := 0; i < 1000; i := i+1) {
1325 var OCT1 ra := f_rnd_ra_cs();
1326 var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra));
1327 if (fn == fn_last) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001328 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?");
Harald Welte8c24c2b2018-02-26 08:31:31 +01001329 }
1330 fn_last := fn;
1331 }
1332 var integer rsl_chrqd := 0;
1333 timer T := 3.0;
Harald Welte56c05802018-02-28 21:39:35 +01001334 T.start;
Harald Welte8c24c2b2018-02-26 08:31:31 +01001335 alt {
1336 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_CHAN_RQD(?,?))) {
1337 rsl_chrqd := rsl_chrqd + 1;
Harald Weltec3a3f452018-02-26 17:37:47 +01001338 f_timer_safe_restart(T);
Harald Welte8c24c2b2018-02-26 08:31:31 +01001339 repeat;
1340 }
1341 [] RSL_CCHAN.receive { repeat; }
1342 [] T.timeout { }
1343 }
1344 if (rsl_chrqd == 1000) {
1345 setverdict(pass);
1346 } else {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001347 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Received only ", rsl_chrqd, " out of 1000 RACH"));
Harald Welte8c24c2b2018-02-26 08:31:31 +01001348 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001349 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +01001350}
1351
Harald Welte3453ab42019-05-24 21:19:58 +02001352private function f_vty_load_ind_thresh(integer period := 10, integer bts_nr := 0) runs on test_CT {
1353 var charstring bts_str := "bts " & int2str(bts_nr);
1354 f_vty_config2(BSCVTY, {"network", bts_str}, "ccch load-indication-threshold " & int2str(period));
1355}
1356
1357/* empirical value: Number of RACH slots per reporting interval (1s) on combined CCCH */
1358private template integer tr_rach_slots_per_interval := (90 .. 130);
1359
1360/* Expect 0 RACH load on an idle BTS that has just started up */
1361testcase TC_rach_load_idle_thresh0() runs on test_CT {
1362 var ASP_RSL_Unitdata rx_ud;
1363
1364 f_init_vty_bsc();
1365 /* send load indications even at 0% load */
1366 f_vty_load_ind_thresh(0);
1367 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
1368 f_sleep(2.0);
1369
1370 f_init();
1371
1372 timer T := 5.0;
1373 T.start;
1374 alt {
1375 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_RACH_LOAD_IND(tr_rach_slots_per_interval, 0, 0))) {
1376 setverdict(pass);
1377 repeat;
1378 }
1379 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_RACH_LOAD_IND(?, ?, ?))) -> value rx_ud {
1380 setverdict(fail, "Unexpected RACH LOAD IND: ", rx_ud);
1381 repeat;
1382 }
1383 [] RSL_CCHAN.receive {
1384 repeat;
1385 }
1386 [] T.timeout { }
1387 }
1388
1389 f_vty_load_ind_thresh(10);
1390 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
1391}
1392
1393/* Expect no RACH load indications on an idle BTS that has just started up (default threshold 10%) */
1394testcase TC_rach_load_idle_below_thresh() runs on test_CT {
1395 var ASP_RSL_Unitdata rx_ud;
1396
1397 f_init_vty_bsc();
1398 f_init();
1399
1400 timer T := 5.0;
1401 T.start;
1402 alt {
1403 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_RACH_LOAD_IND(?, ?, ?))) -> value rx_ud {
1404 setverdict(fail, "Unexpected RACH LOAD IND: ", rx_ud);
1405 repeat;
1406 }
1407 [] RSL_CCHAN.receive {
1408 repeat;
1409 }
1410 [] T.timeout {
1411 setverdict(pass);
1412 }
1413 }
1414
1415 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
1416}
1417
1418/* Expect 0 RACH load on an idle BTS that has just started up */
1419testcase TC_rach_load_count() runs on test_CT {
1420 var ASP_RSL_Unitdata rx_ud;
1421 var integer load_access_count := 0;
1422
1423 f_init_vty_bsc();
1424 /* send load indications even at 0% load */
1425 f_vty_load_ind_thresh(0);
1426 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
1427 f_sleep(2.0);
1428 f_init();
1429
1430 f_init_l1ctl();
1431 f_sleep(1.0);
1432 f_l1_tune(L1CTL);
1433
1434 var GsmFrameNumber fn_last := 0;
1435 for (var integer i := 0; i < 1000; i := i+1) {
1436 var OCT1 ra := f_rnd_ra_cs();
1437 var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra));
1438 if (fn == fn_last) {
1439 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?");
1440 }
1441 fn_last := fn;
1442 }
1443
1444 timer T := 5.0;
1445 T.start;
1446 alt {
1447 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_RACH_LOAD_IND(tr_rach_slots_per_interval, ?, ?)))
1448 -> value rx_ud {
1449 var RSL_IE_Body ie;
1450 f_rsl_find_ie(rx_ud.rsl, RSL_IE_RACH_LOAD, ie);
1451 load_access_count := load_access_count + ie.rach_load.access_count;
1452 if (ie.rach_load.busy_count < ie.rach_load.access_count) {
1453 setverdict(fail, "Access count cannot be < Busy count");
1454 }
1455 repeat;
1456 }
1457 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_RACH_LOAD_IND(?, ?, ?))) -> value rx_ud {
1458 setverdict(fail, "Unexpected RACH LOAD IND: ", rx_ud);
1459 repeat;
1460 }
1461 [] RSL_CCHAN.receive {
1462 repeat;
1463 }
1464 [] T.timeout { }
1465 }
1466 if (load_access_count == 1000) {
1467 setverdict(pass);
1468 } else {
1469 setverdict(fail, "Load reports state ", load_access_count, " RACH, but we sent 1000");
1470 }
1471
1472 f_vty_load_ind_thresh(10);
1473 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
1474}
1475
Harald Welte54a2a2d2018-02-26 09:14:05 +01001476private function f_rach_toffs(int16_t toffs256, boolean expect_pass) runs on test_CT {
Harald Weltef8df4cb2018-03-10 15:15:08 +01001477 var TrxcMessage ret;
Harald Welte54a2a2d2018-02-26 09:14:05 +01001478 /* tell fake_trx to use a given timing offset for all bursts */
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +07001479 ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, valueof(ts_TRXC_FAKE_TIMING(toffs256)));
Harald Welte54a2a2d2018-02-26 09:14:05 +01001480 f_sleep(0.5);
1481
1482 /* Transmit RACH request + wait for confirmation */
1483 var OCT1 ra := f_rnd_ra_cs();
1484 var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra));
1485
1486 /* Check for expected result */
1487 timer T := 1.5;
1488 T.start;
1489 alt {
1490 [expect_pass] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_CHAN_RQD(ra, fn))) {
1491 setverdict(pass);
1492 }
1493 [not expect_pass] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_CHAN_RQD(ra, fn))) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001494 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("RACH passed but was expected to be dropped: ", toffs256));
Harald Welte54a2a2d2018-02-26 09:14:05 +01001495 }
1496 [] RSL_CCHAN.receive { repeat; }
1497 [not expect_pass] T.timeout {
1498 setverdict(pass);
1499 }
1500 [expect_pass] T.timeout {
Max6e053042019-03-14 16:34:22 +01001501 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Timeout waiting for CHAN RQD: FN=", fn, " RA=", ra));
Harald Welte54a2a2d2018-02-26 09:14:05 +01001502 }
1503 }
1504}
1505
1506/* Test if dropping of RACH Based on NM_ATT_MAX_TA works */
1507testcase TC_rach_max_ta() runs on test_CT {
Harald Welte10474062019-05-30 16:48:17 +02001508 f_init();
Harald Welte54a2a2d2018-02-26 09:14:05 +01001509 f_init_l1ctl();
1510 f_l1_tune(L1CTL);
Harald Welte54a2a2d2018-02-26 09:14:05 +01001511 f_sleep(1.0);
1512
1513 /* default max-ta is 63 (full range of GSM timing advance */
1514
Vadim Yanitskiyc81d6e42018-03-05 22:39:01 +07001515 /* We allow early arrival up to 2 symbols */
1516 f_rach_toffs(-1*256, true);
1517 f_rach_toffs(-2*256, true);
Harald Welte54a2a2d2018-02-26 09:14:05 +01001518 f_rach_toffs(-10*256, false);
1519
1520 /* 0 / 32 / 63 bits is legal / permitted */
1521 f_rach_toffs(0, true);
1522 f_rach_toffs(32*256, true);
1523 f_rach_toffs(63*256, true);
1524
1525 /* more than 63 bits is not legal / permitted */
1526 f_rach_toffs(64*256, false);
1527 f_rach_toffs(127*256, false);
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001528 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte54a2a2d2018-02-26 09:14:05 +01001529}
Harald Welte8c24c2b2018-02-26 08:31:31 +01001530
Vadim Yanitskiy7c2c10c2019-05-31 20:42:01 +07001531function f_TC_ho_rach(charstring id) runs on ConnHdlr {
1532 var GsmFrameNumber fn;
1533 var RSL_Message rm;
1534
1535 f_l1_tune(L1CTL);
1536 RSL.clear;
1537
1538 /* Generate a random Handover Reference */
1539 var integer ho_ref := oct2int(f_rnd_octstring(1));
1540
1541 /* Handover Reference IE (see 3GPP TS 48.058, 9.3.9) */
1542 var RSL_IE ho_ref_ie := valueof(t_RSL_IE(RSL_IE_HANDO_REF,
1543 RSL_IE_Body:{ handover_ref := ho_ref }));
1544
1545 /* Activate a channel on the BTS side (no encryption) */
1546 f_rsl_chan_act(g_pars.chan_mode, more_ies := { ho_ref_ie },
1547 act_type := t_RSL_IE_ActType_HO_SYNC);
1548
1549 /* Switch the MS side (e.g. trxcon) to a dedicated channel without
1550 * waiting for Immediate Assignment and sending Access Burst */
1551 f_L1CTL_DM_EST_REQ(L1CTL, { false, mp_trx0_arfcn }, g_pars.chan_nr, 7);
1552
1553 /* Send handover Access Burst */
1554 fn := f_L1CTL_RACH(L1CTL, ho_ref, chan_nr := g_pars.chan_nr);
1555
1556 /* TODO: test mismatching Handover Reference, and missing IE */
1557
1558 /* Wait for handover detection */
1559 timer T := 3.0;
1560 T.start;
1561 alt {
1562 [] RSL.receive(tr_RSL_HANDO_DET(g_pars.chan_nr)) -> value rm {
1563 log("Handover RACH has been detected: ", rm);
1564 setverdict(pass);
1565 }
1566 [] RSL.receive(tr_RSL_CHAN_RQD(?, ?, ?, ?)) -> value rm {
1567 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
1568 log2str("RSL_CHAN_RQD was not expected: ", rm));
1569 }
1570 [] RSL.receive { repeat; }
1571 [] T.timeout {
1572 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
1573 log2str("Timeout waiting for handover RACH: FN=", fn, " RA=", ho_ref));
1574 }
1575 }
1576
1577 /* Release the channel */
1578 f_rsl_chan_deact();
1579 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1580}
1581
1582/* Test handover RACH detection */
1583testcase TC_ho_rach() runs on test_CT {
1584 var ConnHdlrPars pars;
1585 var ConnHdlr vc_conn;
1586
1587 f_init();
1588
1589 for (var integer i := 0; i < sizeof(g_AllChannels); i := i + 1) {
1590 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
1591 log(testcasename(), ": Starting for ", g_AllChannels[i]);
1592 vc_conn := f_start_handler(refers(f_TC_ho_rach), pars);
1593 vc_conn.done;
1594 }
1595
1596 /* TODO: do the above in parallel, rather than sequentially? */
1597 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
1598}
1599
Harald Welte93640c62018-02-25 16:59:33 +01001600/***********************************************************************
1601 * Measurement Processing / Reporting
1602 ***********************************************************************/
1603
Harald Welte70767382018-02-21 12:16:40 +01001604template LapdmAddressField ts_LapdmAddr(LapdmSapi sapi, boolean c_r) := {
1605 spare := '0'B,
1606 lpd := 0,
1607 sapi := sapi,
1608 c_r := c_r,
1609 ea := true
1610}
1611
Harald Welted879bd92018-03-12 15:01:23 +01001612template LapdmFrameAB ts_LAPDm_AB(LapdmSapi sapi, boolean c_r, boolean p, octetstring pl) := {
Harald Welte70767382018-02-21 12:16:40 +01001613 addr := ts_LapdmAddr(sapi, c_r),
Harald Welted879bd92018-03-12 15:01:23 +01001614 ctrl := ts_LapdmCtrlUI(p),
Harald Welte70767382018-02-21 12:16:40 +01001615 len := 0, /* overwritten */
1616 m := false,
1617 el := 1,
1618 payload := pl
1619}
1620
1621/* handle incoming downlink SACCH and respond with uplink SACCH (meas res) */
1622altstep as_l1_sacch() runs on ConnHdlr {
1623 var L1ctlDlMessage l1_dl;
Harald Weltef8df4cb2018-03-10 15:15:08 +01001624 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl {
Harald Welte70767382018-02-21 12:16:40 +01001625 log("SACCH received: ", l1_dl.payload.data_ind.payload);
Pau Espin Pedrole9571aa2018-10-22 17:13:07 +02001626 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 +01001627 var LapdmFrameAB lb := valueof(ts_LAPDm_AB(0, false, false, enc_GsmRrL3Message(meas_rep)));
Harald Welte70767382018-02-21 12:16:40 +01001628 log("LAPDm: ", lb);
Pau Espin Pedroled359cb2018-09-28 16:08:24 +02001629
Vadim Yanitskiy0a8d6da2019-05-28 22:18:28 +07001630 var template (value) SacchL1Header l1h := ts_SacchL1Header(
1631 g_pars.l1_pars.ms_power_level, false,
1632 g_pars.l1_pars.ms_actual_ta);
1633
1634 /* TODO: we can use an extension of TTCN-3 for that, i.e. PADDING('2B'O) */
1635 var octetstring l2 := f_pad_oct(enc_LapdmFrameAB(lb), 21, '2B'O);
1636
1637 log("Sending Measurement Report: ", l1h, l2);
1638 L1CTL.send(ts_L1CTL_DATA_REQ_SACCH(g_chan_nr, ts_RslLinkID_SACCH(0), l1h, l2));
Harald Welte70767382018-02-21 12:16:40 +01001639 repeat;
1640 }
1641}
1642
1643altstep as_l1_dcch() runs on ConnHdlr {
1644 var L1ctlDlMessage l1_dl;
Harald Weltef8df4cb2018-03-10 15:15:08 +01001645 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_DCCH(?))) -> value l1_dl {
Harald Welte70767382018-02-21 12:16:40 +01001646 log("DCCH received: ", l1_dl.payload.data_ind.payload);
1647 var octetstring pl := '010301'O;
Vadim Yanitskiy31e7c672018-07-27 02:23:16 +07001648 L1CTL.send(ts_L1CTL_DATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0),
1649 f_pad_oct(pl, 23, '2B'O)));
Harald Welte70767382018-02-21 12:16:40 +01001650 repeat;
1651 }
1652}
1653
1654type record MeasElem {
1655 uint6_t rxlev,
1656 uint3_t rxqual
1657}
1658
1659type record MeasElemFS {
1660 MeasElem full,
1661 MeasElem sub
1662}
1663
1664type record ConnL1Pars {
1665 boolean dtx_enabled,
Harald Welte685d5982018-02-27 20:42:05 +01001666 boolean toa256_enabled,
Harald Welte70767382018-02-21 12:16:40 +01001667 MeasElemFS meas_ul,
1668 int16_t timing_offset_256syms,
1669 uint5_t bs_power_level,
1670 uint5_t ms_power_level,
1671 uint8_t ms_actual_ta
1672}
1673
1674/* Convert tiing offset from 1/256th symbol to RSL Timing Offset */
1675private function toffs256s_to_rsl(int16_t toffs256s) return uint8_t {
1676 return 63 + (toffs256s/256);
1677}
1678
Harald Welted5684392018-03-10 18:22:04 +01001679private function f_max(integer a, integer b) return integer {
1680 if (a > b) {
1681 return a;
1682 } else {
1683 return b;
1684 }
1685}
1686
1687private function f_min(integer a, integer b) return integer {
1688 if (a < b) {
1689 return a;
1690 } else {
1691 return b;
1692 }
1693}
1694
1695/* compute negative tolerance val-tolerance, ensure >= min */
1696private function f_tolerance_neg(integer val, integer min, integer tolerance) return integer {
1697 val := val - tolerance;
1698 return f_max(val, min);
1699}
1700
1701/* compute positive tolerance val+tolerance, ensure <= max */
1702private function f_tolerance_pos(integer val, integer max, integer tolerance) return integer {
1703 val := val + tolerance;
1704 return f_min(val, max);
1705}
1706
1707/* return a template of (val-tolerance .. val+tolerance) ensuring it is within (min .. max) */
1708private function f_tolerance(integer val, integer min, integer max, integer tolerance)
1709return template integer {
1710 var template integer ret;
1711 ret := (f_tolerance_neg(val, min, tolerance) .. f_tolerance_pos(val, max, tolerance));
1712 return ret;
1713}
1714
1715
Harald Welte70767382018-02-21 12:16:40 +01001716/* build a template for matching measurement results against */
1717private function f_build_meas_res_tmpl() runs on ConnHdlr return template RSL_Message {
1718 var ConnL1Pars l1p := g_pars.l1_pars;
1719 var template RSL_IE_UplinkMeas ul_meas := {
1720 len := 3,
1721 rfu := '0'B,
1722 dtx_d := l1p.dtx_enabled,
Harald Welted5684392018-03-10 18:22:04 +01001723 rxlev_f_u := f_tolerance(l1p.meas_ul.full.rxlev, 0, 63, mp_tolerance_rxlev),
Harald Welte70767382018-02-21 12:16:40 +01001724 reserved1 := '00'B,
Harald Welted5684392018-03-10 18:22:04 +01001725 rxlev_s_u := f_tolerance(l1p.meas_ul.sub.rxlev, 0, 63, mp_tolerance_rxlev),
Harald Welte70767382018-02-21 12:16:40 +01001726 reserved2 := '00'B,
Harald Welted5684392018-03-10 18:22:04 +01001727 rxq_f_u := f_tolerance(l1p.meas_ul.full.rxqual, 0, 7, mp_tolerance_rxqual),
1728 rxq_s_u := f_tolerance(l1p.meas_ul.sub.rxqual, 0, 7, mp_tolerance_rxqual),
Harald Welte70767382018-02-21 12:16:40 +01001729 supp_meas_info := omit
1730 };
Harald Welte685d5982018-02-27 20:42:05 +01001731 if (l1p.toa256_enabled) {
Harald Welte15de8ba2018-06-29 08:51:42 +02001732 ul_meas.len := (3+8);
1733 ul_meas.supp_meas_info := {
Pau Espin Pedrol121724c2018-09-28 15:58:12 +02001734 toa256_mean := f_tolerance(l1p.timing_offset_256syms, -63*256, 192*256, mp_tolerance_timing_offset_256syms),
Harald Welte15de8ba2018-06-29 08:51:42 +02001735 toa256_min := ?,
1736 toa256_max := ?,
1737 toa256_std_dev := ?
1738 }
Harald Welte685d5982018-02-27 20:42:05 +01001739 }
Harald Welte70767382018-02-21 12:16:40 +01001740 var template RSL_IE_BS_Power bs_power := {
1741 reserved := 0,
1742 epc := false,
1743 fpc := false,
1744 power_level := l1p.bs_power_level
1745 };
1746 var template RSL_IE_L1Info l1_info := {
1747 ms_power_lvl := l1p.ms_power_level,
1748 fpc := false,
1749 reserved := 0,
Pau Espin Pedrol121724c2018-09-28 15:58:12 +02001750 actual_ta := f_tolerance(l1p.ms_actual_ta, 0, 63, mp_tolerance_timing_offset_256syms/256)
Harald Welte70767382018-02-21 12:16:40 +01001751 };
1752 var uint8_t offs := toffs256s_to_rsl(l1p.timing_offset_256syms);
Pau Espin Pedrol121724c2018-09-28 15:58:12 +02001753 var template uint8_t t_toffs := f_tolerance(offs, 0, 255, mp_tolerance_timing_offset_256syms/256);
Harald Welte70767382018-02-21 12:16:40 +01001754 return tr_RSL_MEAS_RES_OSMO(g_chan_nr, g_next_meas_res_nr, ul_meas, bs_power, l1_info,
1755 ?, t_toffs);
1756}
1757
Philipp Maierdd841d32019-12-17 14:44:54 +01001758/* build a template for matching measurement results that do not contain any
1759 * MS related measurement (l1_info, l3_info and ms timing offset). */
1760private function f_build_meas_res_tmpl_empty() runs on ConnHdlr return template RSL_Message {
1761 var ConnL1Pars l1p := g_pars.l1_pars;
1762 var template RSL_IE_UplinkMeas ul_meas := {
1763 len := 3,
1764 rfu := '0'B,
1765 dtx_d := l1p.dtx_enabled,
1766 rxlev_f_u := ?,
1767 reserved1 := '00'B,
1768 rxlev_s_u := ?,
1769 reserved2 := '00'B,
1770 rxq_f_u := ?,
1771 rxq_s_u := ?,
1772 supp_meas_info := omit
1773 };
1774 if (l1p.toa256_enabled) {
1775 ul_meas.len := (3+8);
1776 ul_meas.supp_meas_info := {
1777 toa256_mean := f_tolerance(l1p.timing_offset_256syms, -63*256, 192*256, mp_tolerance_timing_offset_256syms),
1778 toa256_min := ?,
1779 toa256_max := ?,
1780 toa256_std_dev := ?
1781 }
1782 }
1783 var template RSL_IE_BS_Power bs_power := {
1784 reserved := 0,
1785 epc := false,
1786 fpc := false,
1787 power_level := l1p.bs_power_level
1788 };
1789
1790 return tr_RSL_MEAS_RES_EMPTY(g_chan_nr, g_next_meas_res_nr, ul_meas, bs_power);
1791}
1792
Harald Welte70767382018-02-21 12:16:40 +01001793/* verify we regularly receive measurement reports with incrementing numbers */
Vadim Yanitskiy41baf002018-10-04 17:44:50 +07001794altstep as_meas_res(boolean verify_meas := true) runs on ConnHdlr {
Harald Welte70767382018-02-21 12:16:40 +01001795 var RSL_Message rsl;
Philipp Maierdd841d32019-12-17 14:44:54 +01001796 var boolean chan_est := false;
1797
Vadim Yanitskiy41baf002018-10-04 17:44:50 +07001798 [not verify_meas] RSL.receive(tr_RSL_MEAS_RES(?)) { repeat; }
Philipp Maierdd841d32019-12-17 14:44:54 +01001799
1800 /* Receive osmocom specific measurement reports. This is the normal
1801 * case. Here we verify that the measurement reports we sent are
1802 * comming back as we expect them. */
Harald Welte70767382018-02-21 12:16:40 +01001803 [] RSL.receive(f_build_meas_res_tmpl()) -> value rsl {
1804 /* increment counter of next to-be-expected meas rep */
1805 g_next_meas_res_nr := (g_next_meas_res_nr + 1) mod 256;
1806 /* Re-start the timer expecting the next MEAS RES */
Harald Weltec3a3f452018-02-26 17:37:47 +01001807 f_timer_safe_restart(g_Tmeas_exp);
Philipp Maierdd841d32019-12-17 14:44:54 +01001808
1809 /* The following two cases may only happen in the beginning
1810 * of the channel establishment phase. Once we have received
1811 * the "our" measurement report the first time, the channel
1812 * is established and empty or hardcoded TRXCON reports must
1813 * not occur anymore. */
1814 chan_est := true;
1815
1816 repeat;
1817 }
1818
1819 /* When the BTS has established the channel, the MS might need slightly
1820 * more time to establish the channel and actually start sending. The
1821 * result is then a measurement report that just lacks the measurement
1822 * information of the MS. This is normal and we tolerate this behavior. */
1823 [chan_est == false] RSL.receive(f_build_meas_res_tmpl_empty()) -> value rsl {
1824 /* increment counter of next to-be-expected meas rep */
1825 g_next_meas_res_nr := (g_next_meas_res_nr + 1) mod 256;
1826 /* Re-start the timer expecting the next MEAS RES */
1827 f_timer_safe_restart(g_Tmeas_exp);
Harald Welte70767382018-02-21 12:16:40 +01001828 repeat;
1829 }
Philipp Maierdd841d32019-12-17 14:44:54 +01001830
1831 /* Due to the TDMA nature of GSM, TRXCON implements a way to emit dummy
1832 * measurements if the TTCN3 side does not supply measurement input in
1833 * time. In those cases TRXCON will either use a cached measurement
1834 * report or a hardcoded one. If TRXCON picks the hardcoded measurement
1835 * report the templates above will not match. We tolerate this
1836 * behavior, but only once. */
1837 [chan_est == false] RSL.receive(tr_RSL_MEAS_RES(g_chan_nr, g_next_meas_res_nr)) -> value rsl {
Harald Weltefa45e9e2018-03-10 18:59:03 +01001838 /* increment counter of next to-be-expected meas rep */
1839 g_next_meas_res_nr := (g_next_meas_res_nr + 1) mod 256;
1840 if (g_first_meas_res) {
1841 g_first_meas_res := false;
1842 repeat;
1843 } else {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001844 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Received unspecific MEAS RES ", rsl));
Harald Weltefa45e9e2018-03-10 18:59:03 +01001845 }
Harald Welte70767382018-02-21 12:16:40 +01001846 }
1847 [] RSL.receive(tr_RSL_MEAS_RES(?)) -> value rsl {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001848 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Received unexpected MEAS RES ", rsl));
Harald Welte70767382018-02-21 12:16:40 +01001849 }
Pau Espin Pedrol425b62f2018-07-06 16:11:43 +02001850 [g_Tmeas_exp.running] g_Tmeas_exp.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001851 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Didn't receive expected measurement result")
Harald Welte70767382018-02-21 12:16:40 +01001852 }
1853}
1854
Harald Weltee613f962018-04-18 22:38:16 +02001855private function f_alg_id_to_l1ctl(RSL_AlgId rsl_alg_id) return uint8_t {
1856 select (rsl_alg_id) {
1857 case (RSL_ALG_ID_A5_0) { return 0; }
1858 case (RSL_ALG_ID_A5_1) { return 1; }
1859 case (RSL_ALG_ID_A5_2) { return 2; }
1860 case (RSL_ALG_ID_A5_3) { return 3; }
1861 case (RSL_ALG_ID_A5_4) { return 4; }
1862 case (RSL_ALG_ID_A5_5) { return 5; }
1863 case (RSL_ALG_ID_A5_6) { return 6; }
1864 case (RSL_ALG_ID_A5_7) { return 7; }
1865 case else {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001866 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unknwon Algorithm ID");
1867 /* Make compiler happy by calling mtc.stop here. It is already
1868 * called in f_shutdown */
Daniel Willmann17ddd852018-07-05 17:33:20 +02001869 mtc.stop;
Harald Weltee613f962018-04-18 22:38:16 +02001870 }
1871 }
1872}
1873
1874private function f_alg_id_to_l3(RSL_AlgId rsl_alg_id) return BIT3 {
1875 select (rsl_alg_id) {
1876 case (RSL_ALG_ID_A5_1) { return '000'B; }
1877 case (RSL_ALG_ID_A5_2) { return '001'B; }
1878 case (RSL_ALG_ID_A5_3) { return '010'B; }
1879 case (RSL_ALG_ID_A5_4) { return '011'B; }
1880 case (RSL_ALG_ID_A5_5) { return '100'B; }
1881 case (RSL_ALG_ID_A5_6) { return '101'B; }
1882 case (RSL_ALG_ID_A5_7) { return '110'B; }
1883 case else {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001884 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unknwon Algorithm ID");
1885 /* Make compiler happy by calling mtc.stop here. It is already
1886 * called in f_shutdown */
Daniel Willmann17ddd852018-07-05 17:33:20 +02001887 mtc.stop;
Harald Weltee613f962018-04-18 22:38:16 +02001888 }
1889 }
1890}
1891
Pau Espin Pedrol6451b042018-10-24 20:36:16 +02001892/* Send RACH request through l1CTL and wait for ChanReq on RSL BST->BSC */
1893private function f_rach_req_wait_chan_rqd(integer ra) runs on ConnHdlr return GsmFrameNumber {
1894 var GsmFrameNumber fn;
1895 timer T := 8.0;
1896
1897 /* advertise to RSL Emulation that we expect to receive confirmation from RACH */
1898 RSL.send(ts_RSLDC_ChanRqd_anyFN(int2oct(ra,1)));
1899
1900 f_L1CTL_PARAM(L1CTL, g_pars.l1_pars.ms_actual_ta, g_pars.l1_pars.ms_power_level);
1901 /* Send the actual RACH */
1902 fn := f_L1CTL_RACH(L1CTL, ra);
1903
1904 T.start;
1905 alt {
1906 [] RSL.receive(tr_RSL_CHAN_RQD(int2oct(ra,1), fn)) { setverdict(pass, "Received CHAN-RQD from RACH REQ") }
1907 [] T.timeout {
1908 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Timeout waiting for CHAN-RQD from RACH REQ <", ra, ", ", fn, ">"));
1909 }
1910 }
1911 T.stop
1912 return fn;
1913}
Harald Weltee613f962018-04-18 22:38:16 +02001914
Harald Welte70767382018-02-21 12:16:40 +01001915/* Establish dedicated channel: L1CTL + RSL side */
Harald Weltec8d363c2019-05-19 20:36:48 +02001916private function f_est_dchan(boolean encr_enable := false, RSL_IE_List more_ies := {}) runs on ConnHdlr {
Harald Welte70767382018-02-21 12:16:40 +01001917 var GsmFrameNumber fn;
1918 var ImmediateAssignment imm_ass;
1919 var integer ra := 23;
1920
Pau Espin Pedrol6451b042018-10-24 20:36:16 +02001921 /* Send RACH request and wait for ChanReq */
1922 fn := f_rach_req_wait_chan_rqd(ra);
Harald Welte70767382018-02-21 12:16:40 +01001923
1924 /* Activate channel on BTS side */
Harald Weltec8d363c2019-05-19 20:36:48 +02001925 f_rsl_chan_act(g_pars.chan_mode, encr_enable, more_ies);
Harald Welte70767382018-02-21 12:16:40 +01001926
1927 /* Send IMM.ASS via CCHAN */
1928 var ChannelDescription ch_desc := {
1929 chan_nr := g_pars.chan_nr,
1930 tsc := 7,
1931 h := false,
1932 arfcn := mp_trx0_arfcn,
1933 maio_hsn := omit
1934 };
1935 var MobileAllocation ma := {
1936 len := 0,
1937 ma := ''B
1938 };
1939 var GsmRrMessage rr_msg := valueof(ts_IMM_ASS(ra, fn, 0, ch_desc, ma));
1940 RSL.send(ts_RSL_IMM_ASSIGN(enc_GsmRrMessage(rr_msg)));
1941
1942 /* receive IMM.ASS on MS side */
1943 var ImmediateAssignment ia_um;
1944 ia_um := f_L1CTL_WAIT_IMM_ASS(L1CTL, ra, fn);
1945 /* enable dedicated mode */
1946 f_L1CTL_DM_EST_REQ_IA(L1CTL, ia_um);
Harald Weltee613f962018-04-18 22:38:16 +02001947 /* enable encryption, if requested */
1948 if (encr_enable) {
1949 var uint8_t alg_id := f_alg_id_to_l1ctl(g_pars.encr.alg_id);
1950 f_L1CTL_CRYPTO_REQ(L1CTL, g_pars.chan_nr, alg_id, g_pars.encr.key);
1951 }
Harald Weltefa45e9e2018-03-10 18:59:03 +01001952
1953 g_first_meas_res := true;
Harald Welte70767382018-02-21 12:16:40 +01001954}
1955
1956/* establish DChan, verify existance + contents of measurement reports */
1957function f_TC_meas_res_periodic(charstring id) runs on ConnHdlr {
Harald Welte68e495b2018-02-25 00:05:57 +01001958 f_l1_tune(L1CTL);
Harald Welte70767382018-02-21 12:16:40 +01001959 RSL.clear;
1960
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +07001961 if (mp_bts_trxc_port != -1) {
Pau Espin Pedrole9571aa2018-10-22 17:13:07 +02001962 f_trxc_fake_rssi(rxlev2dbm(mp_ul_rxlev_exp));
Vadim Yanitskiydc8db922019-06-04 21:58:15 +07001963 f_trxc_fake_toffs256(g_pars.l1_pars.timing_offset_256syms);
Pau Espin Pedrol121724c2018-09-28 15:58:12 +02001964 }
Harald Welte70767382018-02-21 12:16:40 +01001965
1966 f_est_dchan();
1967
1968 /* run for a number of seconds, send SACCH + FACCH from MS side and verify
1969 * RSL measurement reports on Abis side */
1970 timer T := 8.0;
1971 T.start;
1972 alt {
1973 [] as_l1_sacch();
1974 [] as_meas_res();
1975 [] as_l1_dcch();
1976 [] L1CTL.receive { repeat; }
1977 [g_Tmeas_exp.running] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001978 /* as_meas_res() would have done Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail) in case
Harald Welte70767382018-02-21 12:16:40 +01001979 * of any earlier errors, so if we reach this timeout, we're good */
1980 setverdict(pass);
1981 }
1982 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001983 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "No MEAS RES received at all");
Harald Welte70767382018-02-21 12:16:40 +01001984 }
1985 }
1986 f_rsl_chan_deact();
Harald Welte3dc20462018-03-10 23:03:38 +01001987 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
Harald Welte70767382018-02-21 12:16:40 +01001988}
Harald Welte0472ab42018-03-12 15:02:26 +01001989
Eric Wildae8f2622019-06-18 17:05:11 +02001990function f_check_meas_bs_power_level(integer level) runs on ConnHdlr {
1991 timer T := 8.0;
1992 T.start;
1993 var RSL_Message rsl;
1994 alt {
1995 [] as_l1_sacch();
1996 [] L1CTL.receive { repeat; }
1997 [] RSL.receive(tr_RSL_MEAS_RES(g_chan_nr, ?, ?, ?)) -> value rsl {
1998 if (rsl.ies[3].body.bs_power.power_level == level) {
1999 setverdict(pass)
2000 } else {
2001 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Received wrong BS power level in MEAS RES ", rsl));
2002 }
2003 }
2004 [] T.timeout {
2005 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "No MEAS RES received at all");
2006 }
2007 }
2008}
2009
2010/* see if the rsl meas res contains our expeced bs power level
2011bs power set during assignment */
2012function f_TC_rsl_bs_pwr_static_ass(charstring id) runs on ConnHdlr {
2013 f_l1_tune(L1CTL);
2014 RSL.clear;
2015
2016 if (mp_bts_trxc_port != -1) {
2017 f_trxc_fake_rssi(rxlev2dbm(mp_ul_rxlev_exp));
2018 f_trxc_fake_toffs256(g_pars.l1_pars.timing_offset_256syms);
2019 }
2020
2021 var uint5_t pwr_var := 1;
2022 var template (value) RSL_IE_BS_Power bs_power := ts_RSL_IE_BS_Power(pwr_var);
2023 var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_BS_POWER, RSL_IE_Body:{bs_power := bs_power});
2024
2025 f_est_dchan(more_ies :={valueof(pwr)});
2026
2027 f_check_meas_bs_power_level(pwr_var);
2028
2029 f_rsl_chan_deact();
2030 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
2031}
2032
2033/* see if the rsl meas res contains our expeced bs power level
2034bs power set after assignment */
2035function f_TC_rsl_bs_pwr_static_power_control(charstring id) runs on ConnHdlr {
2036 f_l1_tune(L1CTL);
2037 RSL.clear;
2038
2039 if (mp_bts_trxc_port != -1) {
2040 f_trxc_fake_rssi(rxlev2dbm(mp_ul_rxlev_exp));
2041 f_trxc_fake_toffs256(g_pars.l1_pars.timing_offset_256syms);
2042 }
2043
2044 var uint5_t pwr_var := 1;
2045 var template (value) RSL_IE_BS_Power bs_power := ts_RSL_IE_BS_Power(pwr_var);
2046
2047 f_est_dchan();
2048
2049 RSL.send(ts_RSL_BS_PWR_CTRL(g_chan_nr, bs_power));
2050
2051 f_check_meas_bs_power_level(pwr_var);
2052
2053 f_rsl_chan_deact();
2054 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
2055}
2056
2057testcase TC_rsl_bs_pwr_static_ass() runs on test_CT {
2058 var ConnHdlr vc_conn;
2059 var ConnHdlrPars pars;
2060 f_init();
2061 for (var integer tn := 1; tn <= 4; tn := tn+1) {
2062 pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN));
2063 vc_conn := f_start_handler(refers(f_TC_rsl_bs_pwr_static_ass), pars,
2064 pcu_comp := false, trxc_comp := true);
2065 vc_conn.done;
2066 }
2067 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
2068}
2069
2070testcase TC_rsl_bs_pwr_static_power_control() runs on test_CT {
2071 var ConnHdlr vc_conn;
2072 var ConnHdlrPars pars;
2073 f_init();
2074 for (var integer tn := 1; tn <= 4; tn := tn+1) {
2075 pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN));
2076 vc_conn := f_start_handler(refers(f_TC_rsl_bs_pwr_static_power_control), pars,
2077 pcu_comp := false, trxc_comp := true);
2078 vc_conn.done;
2079 }
2080 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
2081}
2082
Eric Wild61edb7e2019-06-03 12:38:31 +02002083/* target level -100, first rssi -90, ms power 7, expected increase to 7+6 within 6 seconds,
2084second rssi -110, ms power 7+6, expected decrease to 7 within 6 seconds,
2085These power levels are valid for all bands and require no special handling */
2086function f_TC_rsl_ms_pwr_dyn_ass_updown(charstring id) runs on ConnHdlr {
2087 var uint5_t pwr_var := 7;
2088 var L1ctlDlMessage l1_dl;
2089
2090 f_trxc_fake_rssi(rxlev2dbm(10));
2091 f_l1_tune(L1CTL);
2092 RSL.clear;
2093
2094 var RSL_IE_List addl_ies;
2095 var template (value) RSL_IE_MS_Power_Parameters pp := (ts_RSL_IE_MS_Power_Parameters(''O));
2096
2097 addl_ies := {
2098 valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(pwr_var)})),
2099 valueof(t_RSL_IE(RSL_IE_MS_POWER_PARAM, RSL_IE_Body:{ms_power_params := pp}))
2100 };
2101
2102 /* establish with power parameters */
2103 f_est_dchan(more_ies := addl_ies);
2104
2105 /* set a high value to ensure L1 power control level increases */
2106 f_trxc_fake_rssi(rxlev2dbm(20));
2107
2108 timer T2 := 6.0;
2109 T2.start;
2110 alt {
2111 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl {
Pau Espin Pedrola1f7d242019-12-04 16:08:09 +01002112 /* Update sent MS power to follow what BTS requests */
2113 f_L1CTL_PARAM(L1CTL, g_pars.l1_pars.ms_actual_ta, oct2int(l1_dl.payload.data_ind.payload[0]));
2114 if (oct2int(l1_dl.payload.data_ind.payload[0]) < (pwr_var + 6)) {
Eric Wild61edb7e2019-06-03 12:38:31 +02002115 repeat;
Pau Espin Pedrola1f7d242019-12-04 16:08:09 +01002116 }
Eric Wild61edb7e2019-06-03 12:38:31 +02002117 T2.stop;
2118 }
2119 [] L1CTL.receive { repeat; }
2120 [] T2.timeout {
2121 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
2122 "Power Level in L1 header has not increased sufficiently");
2123 }
2124 }
2125
2126 /* set a low value to ensure L1 power control level decreases */
2127 f_trxc_fake_rssi(rxlev2dbm(0));
2128
2129 timer T4 := 6.0;
2130 T4.start;
2131 alt {
2132 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl {
Pau Espin Pedrola1f7d242019-12-04 16:08:09 +01002133 /* Update sent MS power to follow what BTS requests */
2134 f_L1CTL_PARAM(L1CTL, g_pars.l1_pars.ms_actual_ta, oct2int(l1_dl.payload.data_ind.payload[0]));
2135 if (oct2int(l1_dl.payload.data_ind.payload[0]) > pwr_var) {
Eric Wild61edb7e2019-06-03 12:38:31 +02002136 repeat;
Pau Espin Pedrola1f7d242019-12-04 16:08:09 +01002137 }
Eric Wild61edb7e2019-06-03 12:38:31 +02002138 T4.stop;
2139 setverdict(pass, "Power level in L1 decreased/increased as expected");
2140 }
2141 [] L1CTL.receive { repeat; }
2142 [] T4.timeout {
2143 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
2144 "Power Level in L1 header has not decreased sufficiently");
2145 }
2146 }
2147
2148 f_rsl_chan_deact();
2149 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
2150
2151}
2152
2153/* check that we do not exceed the max power */
2154function f_TC_rsl_ms_pwr_dyn_max(charstring id) runs on ConnHdlr {
2155 var uint5_t pwr_var := 7;
2156 var L1ctlDlMessage l1_dl;
2157
2158 /* set a low value to ensure power increases */
2159 f_trxc_fake_rssi(rxlev2dbm(10));
2160 f_l1_tune(L1CTL);
2161 RSL.clear;
2162
2163 var RSL_IE_List addl_ies;
2164 var template (value) RSL_IE_MS_Power_Parameters pp := (ts_RSL_IE_MS_Power_Parameters(''O));
2165
2166 addl_ies := {
2167 valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(pwr_var)})),
2168 valueof(t_RSL_IE(RSL_IE_MS_POWER_PARAM, RSL_IE_Body:{ms_power_params := pp}))
2169 };
2170
2171 /* establish with power parameters */
2172 f_est_dchan(more_ies := addl_ies);
2173
2174 timer T1 := 10.0;
2175 T1.start;
2176 alt {
Pau Espin Pedrola1f7d242019-12-04 16:08:09 +01002177 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl {
2178 /* Update sent MS power to follow what BTS requests */
2179 f_L1CTL_PARAM(L1CTL, g_pars.l1_pars.ms_actual_ta, oct2int(l1_dl.payload.data_ind.payload[0]));
2180 repeat;
2181 }
Eric Wild61edb7e2019-06-03 12:38:31 +02002182 [] L1CTL.receive { repeat; }
2183 [] T1.timeout {
2184 if( oct2int(l1_dl.payload.data_ind.payload[0]) != pwr_var){
2185 setverdict(fail, "Power level in L1 header should not have changed");
2186 }
2187 }
2188 }
2189
2190 f_rsl_chan_deact();
2191 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
2192
2193}
2194
2195/* see if we reach the band max power */
2196function f_TC_rsl_ms_pwr_dyn_up(charstring id) runs on ConnHdlr {
2197 var L1ctlDlMessage l1_dl;
2198 var uint5_t pwr_var := 15;
2199 var uint5_t pwr_max_var := f_get_max_power_from_band();
2200
2201 /* set a low value to ensure power increases */
2202 f_trxc_fake_rssi(rxlev2dbm(10));
2203 f_l1_tune(L1CTL);
2204 RSL.clear;
2205
2206 var template (value) RSL_IE_MS_Power ms_power := ts_RSL_IE_MS_Power(pwr_var);
2207 var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power});
2208
2209 /* establish with fixed power level */
2210 f_est_dchan(more_ies :={valueof(pwr)});
2211
2212 /* check our initial power level */
2213 f_wait_for_l1_power_level(pwr_var);
2214
2215 /* update power param to enable power loop
2216 48.058 The maximum power to be used is indicated in the BS and MS Power elements respectively. */
2217 RSL.send(ts_RSL_MS_PWR_CTRL_with_pp(g_chan_nr, pwr_max_var));
2218
2219 /* wait, then check that our power level was reduced */
2220 timer T1 := 10.0;
2221 T1.start;
2222 alt {
Pau Espin Pedrola1f7d242019-12-04 16:08:09 +01002223 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl {
2224 /* Update sent MS power to follow what BTS requests */
2225 f_L1CTL_PARAM(L1CTL, g_pars.l1_pars.ms_actual_ta, oct2int(l1_dl.payload.data_ind.payload[0]));
2226 repeat;
2227 }
Eric Wild61edb7e2019-06-03 12:38:31 +02002228 [] L1CTL.receive { repeat; }
2229 [] T1.timeout {
2230 var int8_t rcv := oct2int(l1_dl.payload.data_ind.payload[0]);
2231 if( f_power_level_is_highest_dbm(rcv) ){
2232 setverdict(pass, "Power level in L1 header reduced as expected");
2233 } else {
2234 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
2235 log2str("Power Level in L1 header did not reach the expected value, e:",pwr_max_var," r:",rcv));
2236 }
2237 }
2238 }
2239
2240 f_rsl_chan_deact();
2241 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
2242
2243}
2244
2245/* see if we reach the band min power */
2246function f_TC_rsl_ms_pwr_dyn_down(charstring id) runs on ConnHdlr {
2247 var L1ctlDlMessage l1_dl;
2248
2249 /* set a high value to ensure power decreases */
2250 f_trxc_fake_rssi(rxlev2dbm(50));
2251 f_l1_tune(L1CTL);
2252 RSL.clear;
2253
2254 var uint5_t pwr_var := 5;
2255 var uint5_t pwr_target_val := 15;
2256
2257 var template (value) RSL_IE_MS_Power ms_power := ts_RSL_IE_MS_Power(pwr_var);
2258 var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power});
2259
2260 /* establish with fixed power level */
2261 f_est_dchan(more_ies :={valueof(pwr)});
2262
2263 /* check our initial power level */
2264 f_wait_for_l1_power_level(pwr_var);
2265
2266 /* update power param to enable power loop
2267 as per spec the supplied ms power IE should set the max allowed power...*/
Pau Espin Pedrol61122c82019-11-05 13:50:27 +01002268 RSL.send(ts_RSL_MS_PWR_CTRL_with_pp(g_chan_nr, pwr_target_val));
Eric Wild61edb7e2019-06-03 12:38:31 +02002269
2270 /* wait, then check that our power level was increased */
2271 timer T1 := 10.0;
2272 T1.start;
2273 alt {
Pau Espin Pedrola1f7d242019-12-04 16:08:09 +01002274 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl {
2275 /* Update sent MS power to follow what BTS requests */
2276 f_L1CTL_PARAM(L1CTL, g_pars.l1_pars.ms_actual_ta, oct2int(l1_dl.payload.data_ind.payload[0]));
2277 repeat;
2278 }
Eric Wild61edb7e2019-06-03 12:38:31 +02002279 [] L1CTL.receive { repeat; }
2280 [] T1.timeout {
2281 if( f_power_level_is_lowest_dbm(oct2int(l1_dl.payload.data_ind.payload[0])) ){
2282 setverdict(pass, "Power level in L1 header increased to lowest power value");
2283 } else {
2284 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
2285 "Power level in L1 header NOT increased to lowest power value");
2286 }
2287 }
2288 }
2289
2290 f_rsl_chan_deact();
2291 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
2292
2293}
2294
Eric Wild095024b2019-06-17 15:08:57 +02002295/* see if we change the power level without receiving power parameters, which should not happen
2296rsl chan act WITHOUT power parameters */
Eric Wild280ccb82019-06-17 11:11:52 +02002297function f_TC_rsl_ms_pwr_dyn_active(charstring id) runs on ConnHdlr {
2298 var L1ctlDlMessage l1_dl;
2299
2300 /* set a high value to ensure power decreases */
2301 f_trxc_fake_rssi(rxlev2dbm(50));
2302 f_l1_tune(L1CTL);
2303 RSL.clear;
2304
2305 var uint5_t pwr_var := 5;
2306
2307 var template (value) RSL_IE_MS_Power ms_power := ts_RSL_IE_MS_Power(pwr_var);
2308 var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power});
2309
2310 /* establish with fixed power level */
2311 f_est_dchan(more_ies :={valueof(pwr)});
2312
2313 /* check our initial power level */
2314 f_wait_for_l1_power_level(pwr_var);
2315
2316 /* wait, then check that our power level did not change */
2317 timer T1 := 10.0;
2318 T1.start;
2319 alt {
2320 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl {
2321 if ( oct2int(l1_dl.payload.data_ind.payload[0]) != pwr_var) {
2322 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
2323 "BS power control should not be active unless we receive a power parameters IE!");
2324 }
2325 repeat;
2326 }
2327 [] L1CTL.receive { repeat; }
2328 [] T1.timeout { setverdict(pass); }
2329 }
2330
2331 f_rsl_chan_deact();
2332 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
2333
2334}
2335
Eric Wild095024b2019-06-17 15:08:57 +02002336/* see if we change the power level without receiving power parameters, which should not happen
2337ms power control WITHOUT power parameters */
2338function f_TC_rsl_ms_pwr_dyn_active2(charstring id) runs on ConnHdlr {
2339 var L1ctlDlMessage l1_dl;
2340
2341 /* set a high value to ensure power decreases */
2342 f_trxc_fake_rssi(rxlev2dbm(50));
2343 f_l1_tune(L1CTL);
2344 RSL.clear;
2345
2346 var uint5_t pwr_var := 5;
2347
2348 var template (value) RSL_IE_MS_Power ms_power := ts_RSL_IE_MS_Power(pwr_var);
2349 var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power});
2350
2351 /* establish with fixed power level */
2352 f_est_dchan(more_ies :={valueof(pwr)});
2353
2354 /* check our initial power level */
2355 f_wait_for_l1_power_level(pwr_var);
2356
2357 /* pwr control without power params IE, should NOT activate MS power control*/
2358 RSL.send(ts_RSL_MS_PWR_CTRL(g_chan_nr, ms_power));
2359
2360 /* wait, then check that our power level did not change */
2361 timer T1 := 10.0;
2362 T1.start;
2363 alt {
2364 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl {
2365 if ( oct2int(l1_dl.payload.data_ind.payload[0]) != pwr_var) {
2366 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
2367 "BS power control should not be active unless we receive a power parameters IE!");
2368 }
2369 repeat;
2370 }
2371 [] L1CTL.receive { repeat; }
2372 [] T1.timeout { setverdict(pass); }
2373 }
2374
2375 f_rsl_chan_deact();
2376 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
2377
2378}
2379
Eric Wild61edb7e2019-06-03 12:38:31 +02002380function f_wait_for_l1_power_level(integer level) runs on ConnHdlr {
2381 var L1ctlDlMessage l1_dl;
2382 timer T0 := 10.0;
2383 T0.start;
2384 alt {
2385 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl {
2386 if (not (l1_dl.payload.data_ind.payload[0] == int2oct(level, 1))) {
2387 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
2388 "Power level in L1 header != signaled (RSL) power level.");
2389 }
2390 }
2391 [] L1CTL.receive { repeat; }
2392 [] T0.timeout {
2393 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
2394 "Timeout waiting for initial power level");
2395 }
2396 }
2397 T0.stop;
2398}
2399
2400private function f_power_level_is_lowest_dbm(integer level) runs on ConnHdlr return boolean {
2401 var IntegerRecord min_dbm_level;
2402 var IntegerRecord max_dbm_level;
2403 var IntegerRecord x := f_power_from_band(g_pars.bts0_band, min_dbm_level, max_dbm_level);
2404
2405 for (var integer i := 0; i < sizeof(min_dbm_level); i := i+1) {
2406 if (min_dbm_level[i] == level) {
2407 return true;
2408 }
2409 }
2410 return false;
2411}
2412
2413private function f_power_level_is_highest_dbm(integer level) runs on ConnHdlr return boolean {
2414 var IntegerRecord min_dbm_level;
2415 var IntegerRecord max_dbm_level;
2416 var IntegerRecord x := f_power_from_band(g_pars.bts0_band, min_dbm_level, max_dbm_level);
2417
2418 for (var integer i := 0; i < sizeof(max_dbm_level); i := i+1) {
2419 if (max_dbm_level[i] == level) {
2420 return true;
2421 }
2422 }
2423 return false;
2424}
2425
2426private function f_get_max_power_from_band() runs on ConnHdlr return integer {
2427 var IntegerRecord min_dbm_level;
2428 var IntegerRecord max_dbm_level;
2429 var IntegerRecord x := f_power_from_band(g_pars.bts0_band, min_dbm_level, max_dbm_level);
2430 return max_dbm_level[0];
2431}
2432
2433type charstring BtsBand ("GSM450","GSM480","GSM750","GSM810","GSM850","GSM900","DCS1800","PCS1900");
2434template charstring BtsBand_allGSM:= pattern "GSM???";
2435private function f_power_from_band(in BtsBand band, out IntegerRecord min_dbm_level, out IntegerRecord max_dbm_level) return IntegerRecord {
2436 // 45.005 4.1.1
2437 var IntegerRecord gsm_power :={31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19,
2438 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3,
2439 2, 1, 0};
2440 var IntegerRecord dcs_power :={28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15,
2441 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 31, 30, 29};
2442 var IntegerRecord pcs_power :={15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 31, 30};
2443 var IntegerRecord rv;
2444
2445 select(band){
2446 case (BtsBand_allGSM){
2447 rv := gsm_power;
2448 min_dbm_level := {31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19} ;
2449 max_dbm_level := {2, 1, 0};
2450 }
2451 case("DCS1800"){
2452 rv := dcs_power;
2453 min_dbm_level := {28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15};
2454 max_dbm_level := {0, 29}; // let's cheat here, assume MS_TXPWR_MAX_CCH might be being broadcast, so maybe no 29,30,31
2455 }
2456 case("PCS1900"){
2457 rv := pcs_power;
2458 min_dbm_level := {15};
2459 max_dbm_level := {30};
2460 }
2461 }
2462
2463 return rv;
2464}
2465
2466private function f_vty_get_bts0_band() runs on test_CT return BtsBand {
2467 return f_vty_transceive_match_regex(BTSVTY, "show bts 0", "BTS 0 is of \w+ type in band (\w+),*", 0);
2468}
2469
2470testcase TC_rsl_ms_pwr_dyn_ass_updown() runs on test_CT {
2471 var ConnHdlr vc_conn;
2472 var ConnHdlrPars pars;
2473 f_init();
2474 f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -100");
2475 for (var integer tn := 1; tn <= 1; tn := tn+1) {
2476 pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN));
2477 pars.bts0_band := f_vty_get_bts0_band();
2478 vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_ass_updown), pars, trxc_comp := true);
2479 vc_conn.done;
2480 }
2481 f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop");
2482 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
2483}
2484
2485testcase TC_rsl_ms_pwr_dyn_up() runs on test_CT {
2486 var ConnHdlr vc_conn;
2487 var ConnHdlrPars pars;
2488 f_init();
2489 f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -10");
2490 for (var integer tn := 1; tn <= 1; tn := tn+1) {
2491 pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN));
2492 pars.bts0_band := f_vty_get_bts0_band();
2493 vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_up), pars, trxc_comp := true);
2494 vc_conn.done;
2495 }
2496 f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop");
2497 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
2498}
2499
2500testcase TC_rsl_ms_pwr_dyn_max() runs on test_CT {
2501 var ConnHdlr vc_conn;
2502 var ConnHdlrPars pars;
2503 f_init();
2504 f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -10");
2505 for (var integer tn := 1; tn <= 1; tn := tn+1) {
2506 pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN));
2507 pars.bts0_band := f_vty_get_bts0_band();
2508 vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_max), pars, trxc_comp := true);
2509 vc_conn.done;
2510 }
2511 f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop");
2512 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
2513}
2514
2515testcase TC_rsl_ms_pwr_dyn_down() runs on test_CT {
2516 var ConnHdlr vc_conn;
2517 var ConnHdlrPars pars;
2518 f_init();
2519 f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -100");
2520 for (var integer tn := 1; tn <= 1; tn := tn+1) {
2521 pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN));
2522 pars.bts0_band := f_vty_get_bts0_band();
2523 vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_down), pars, trxc_comp := true);
2524 vc_conn.done;
2525 }
2526 f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop");
2527 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
2528}
2529
Eric Wild280ccb82019-06-17 11:11:52 +02002530testcase TC_rsl_ms_pwr_dyn_active() runs on test_CT {
2531 var ConnHdlr vc_conn;
2532 var ConnHdlrPars pars;
2533 f_init();
2534 f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -100");
2535 for (var integer tn := 1; tn <= 1; tn := tn+1) {
2536 pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN));
2537 pars.bts0_band := f_vty_get_bts0_band();
2538 vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_active), pars, trxc_comp := true);
2539 vc_conn.done;
2540 }
2541 f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop");
2542 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
2543}
2544
Eric Wild095024b2019-06-17 15:08:57 +02002545testcase TC_rsl_ms_pwr_dyn_active2() runs on test_CT {
2546 var ConnHdlr vc_conn;
2547 var ConnHdlrPars pars;
2548 f_init();
2549 f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -100");
2550 for (var integer tn := 1; tn <= 1; tn := tn+1) {
2551 pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN));
2552 pars.bts0_band := f_vty_get_bts0_band();
2553 vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_active2), pars, trxc_comp := true);
2554 vc_conn.done;
2555 }
2556 f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop");
2557 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
2558}
2559
Harald Welte70767382018-02-21 12:16:40 +01002560testcase TC_meas_res_sign_tchf() runs on test_CT {
2561 var ConnHdlr vc_conn;
2562 var ConnHdlrPars pars;
Harald Welte10474062019-05-30 16:48:17 +02002563 f_init();
Harald Welte70767382018-02-21 12:16:40 +01002564 for (var integer tn := 1; tn <= 4; tn := tn+1) {
2565 pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN));
Vadim Yanitskiyf4e997c2019-06-04 21:40:33 +07002566 vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars,
2567 pcu_comp := false, trxc_comp := true);
Harald Welte70767382018-02-21 12:16:40 +01002568 vc_conn.done;
2569 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002570 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +01002571}
2572testcase TC_meas_res_sign_tchh() runs on test_CT {
2573 var ConnHdlr vc_conn;
2574 var ConnHdlrPars pars;
Harald Welte10474062019-05-30 16:48:17 +02002575 f_init();
Harald Welte70767382018-02-21 12:16:40 +01002576 for (var integer ss := 0; ss <= 1; ss := ss+1) {
2577 pars := valueof(t_Pars(t_RslChanNr_Lm(5, ss), ts_RSL_ChanMode_SIGN));
Eric Wild5b9ef142019-07-11 19:28:02 +02002578 vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars,
2579 pcu_comp := false, trxc_comp := true);
Harald Welte70767382018-02-21 12:16:40 +01002580 vc_conn.done;
2581 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002582 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +01002583}
2584testcase TC_meas_res_sign_sdcch4() runs on test_CT {
2585 var ConnHdlr vc_conn;
2586 var ConnHdlrPars pars;
Harald Welte10474062019-05-30 16:48:17 +02002587 f_init();
Harald Welte70767382018-02-21 12:16:40 +01002588 for (var integer ss := 0; ss <= 3; ss := ss+1) {
2589 pars := valueof(t_Pars(t_RslChanNr_SDCCH4(0, ss), ts_RSL_ChanMode_SIGN));
Eric Wild5b9ef142019-07-11 19:28:02 +02002590 vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars,
2591 pcu_comp := false, trxc_comp := true);
Harald Welte70767382018-02-21 12:16:40 +01002592 vc_conn.done;
2593 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002594 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +01002595}
2596testcase TC_meas_res_sign_sdcch8() runs on test_CT {
2597 var ConnHdlr vc_conn;
2598 var ConnHdlrPars pars;
Harald Welte10474062019-05-30 16:48:17 +02002599 f_init();
Harald Welte70767382018-02-21 12:16:40 +01002600 for (var integer ss := 0; ss <= 7; ss := ss+1) {
2601 pars := valueof(t_Pars(t_RslChanNr_SDCCH8(6, ss), ts_RSL_ChanMode_SIGN));
Eric Wild5b9ef142019-07-11 19:28:02 +02002602 vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars,
2603 pcu_comp := false, trxc_comp := true);
Harald Welte70767382018-02-21 12:16:40 +01002604 vc_conn.done;
2605 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002606 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +01002607}
Harald Welte685d5982018-02-27 20:42:05 +01002608testcase TC_meas_res_sign_tchh_toa256() runs on test_CT {
2609 var ConnHdlr vc_conn;
2610 var ConnHdlrPars pars;
Harald Welte10474062019-05-30 16:48:17 +02002611 f_init();
Harald Welte685d5982018-02-27 20:42:05 +01002612 f_vty_config(BTSVTY, "bts 0", "supp-meas-info toa256");
2613 for (var integer ss := 0; ss <= 1; ss := ss+1) {
2614 pars := valueof(t_Pars(t_RslChanNr_Lm(5, ss), ts_RSL_ChanMode_SIGN));
2615 pars.l1_pars.toa256_enabled := true;
2616 vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars);
2617 vc_conn.done;
2618 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002619 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte685d5982018-02-27 20:42:05 +01002620}
2621
Philipp Maier4d1e9c92018-12-20 11:11:56 +01002622/* establish DChan, and send MS POWER CONTROL messages via RSL, verify that
2623 * the BTS is forwarding those values to the MS via the SACCH L1 header. */
2624function f_tc_rsl_ms_pwr_ctrl(charstring id) runs on ConnHdlr {
2625 var L1ctlDlMessage l1_dl;
2626 var RSL_IE_MS_Power ms_power;
2627 var RSL_Message rsl;
2628 var uint5_t power_level := 0;
2629
2630 f_l1_tune(L1CTL);
2631 RSL.clear;
2632
2633 f_est_dchan();
2634
2635 ms_power.reserved := 0;
2636 ms_power.fpc_epc := false;
2637
2638 /* Send the first power control command. This will disable any BTS/TRX
2639 * internal power control and switch the MS (which is not in scope of
2640 * this test) to a constant power level. We start with a power level
2641 * of 0 */
2642 ms_power.power_level := power_level;
2643 rsl := valueof(ts_RSL_MS_PWR_CTRL(g_chan_nr, ms_power));
2644 RSL.send(rsl);
2645
2646 alt {
2647
2648 /* Pick all SACCH blocks for checking */
2649 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl {
2650
2651 /* The first byte of the L1 header contains the power level.
2652 * The reserved bits and the fpc bit is set to 0, so we may
2653 * compare directly. */
2654 if (not (l1_dl.payload.data_ind.payload[0] == int2oct(power_level, 1))) {
2655 setverdict(fail, "Power level in L1 header does not match the signaled (RSL) power level.");
2656 }
2657
2658 /* Signal a new power level via RSL for the next turn. */
2659 if (power_level < 31) {
2660 power_level := power_level + 1;
2661 ms_power.power_level := power_level;
2662 rsl := valueof(ts_RSL_MS_PWR_CTRL(g_chan_nr, ms_power));
2663 RSL.send(rsl);
2664 repeat;
2665 }
2666
2667 }
2668
2669 /* Ignore all other blocks */
2670 [] L1CTL.receive { repeat; }
2671
2672 }
2673
2674 f_rsl_chan_deact();
2675 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
2676
2677 setverdict(pass);
2678}
2679
2680testcase TC_rsl_ms_pwr_ctrl() runs on test_CT {
2681 var ConnHdlr vc_conn;
2682 var ConnHdlrPars pars;
Harald Welte10474062019-05-30 16:48:17 +02002683 f_init();
Philipp Maier4d1e9c92018-12-20 11:11:56 +01002684
2685 for (var integer tn := 1; tn <= 4; tn := tn+1) {
2686 pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN));
2687 vc_conn := f_start_handler(refers(f_tc_rsl_ms_pwr_ctrl), pars);
2688 vc_conn.done;
2689 }
2690 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
2691}
Harald Welte70767382018-02-21 12:16:40 +01002692
Eric Wild6833cc92019-05-23 19:34:44 +02002693/* establish DChan, verify that the BTS sets the TA in the first SACCH L1 header.
2694TA for the IMM ASS messages is still controlled by g_pars.l1_pars.ms_actual_ta! */
2695function f_tc_rsl_chan_initial_ta(charstring id) runs on ConnHdlr {
2696 var L1ctlDlMessage l1_dl;
2697 var uint5_t ta_to_test := 16;
2698
2699
2700 f_l1_tune(L1CTL);
2701 RSL.clear;
2702
2703 /* tell fake_trx to use a given timing offset for all bursts */
Vadim Yanitskiydc8db922019-06-04 21:58:15 +07002704 f_trxc_fake_toffs256(ta_to_test*256);
Eric Wild6833cc92019-05-23 19:34:44 +02002705
2706 f_est_dchan(more_ies :={valueof(t_RSL_IE(RSL_IE_TIMING_ADVANCE, RSL_IE_Body:{timing_adv := ta_to_test}))} );
2707
2708
2709 alt {
2710
2711 /* Pick all SACCH blocks for checking */
2712 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl {
2713
2714 /* The second byte of the L1 header contains the TA. */
2715 if (not (l1_dl.payload.data_ind.payload[1] == int2oct(ta_to_test, 1))) {
2716 setverdict(fail, "TA in L1 header does not match the signaled (RSL) TA.");
2717 }
2718
2719 }
2720
2721 /* Ignore all other blocks */
2722 [] L1CTL.receive { repeat; }
2723
2724 }
2725
2726 f_rsl_chan_deact();
2727 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
2728
2729 setverdict(pass);
2730}
2731
2732testcase TC_rsl_chan_initial_ta() runs on test_CT {
2733 var ConnHdlr vc_conn;
2734 var ConnHdlrPars pars;
Harald Welte10474062019-05-30 16:48:17 +02002735 f_init();
Eric Wild6833cc92019-05-23 19:34:44 +02002736 pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
Vadim Yanitskiyf4e997c2019-06-04 21:40:33 +07002737 vc_conn := f_start_handler(refers(f_tc_rsl_chan_initial_ta), pars,
2738 pcu_comp := false, trxc_comp := true);
Eric Wild6833cc92019-05-23 19:34:44 +02002739 vc_conn.done;
2740 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
2741}
2742
Eric Wilde57e1a62019-05-28 13:30:55 +02002743/* establish DChan, verify that the BTS sets MS power in the first SACCH L1 header. */
2744function f_tc_rsl_chan_initial_ms_pwr(charstring id) runs on ConnHdlr {
2745 var L1ctlDlMessage l1_dl;
2746 var uint5_t ms_power_level := 7;
2747
2748 var RSL_IE_MS_Power ms_power;
2749 ms_power.reserved := 0;
2750 ms_power.fpc_epc := false;
2751 ms_power.power_level := ms_power_level;
2752
2753 f_l1_tune(L1CTL);
2754 RSL.clear;
2755
2756 f_est_dchan(more_ies :={valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power}))} );
2757
2758 timer T := 1.0;
2759 T.start;
2760 alt {
2761 /* Pick all SACCH blocks for checking */
2762 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl {
2763 /* The first byte of the L1 header contains the power level.. */
2764 if (not (l1_dl.payload.data_ind.payload[0] == int2oct(ms_power_level, 1))) {
2765 setverdict(fail, "Power Level in L1 header does not match the signaled (RSL) MS Power Level.");
2766 }
2767 }
2768 /* Ignore all other blocks */
2769 [] L1CTL.receive { repeat; }
2770 [] T.timeout {
2771 setverdict(fail, "Power Level in L1 header does not match the signaled (RSL) MS Power Level.");
2772 }
2773 }
2774
2775 f_rsl_chan_deact();
2776 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
2777 setverdict(pass);
2778}
2779
2780testcase TC_rsl_chan_initial_ms_pwr() runs on test_CT {
2781 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
2782 f_testmatrix_each_chan(pars, refers(f_tc_rsl_chan_initial_ms_pwr));
2783}
2784
Harald Welte0472ab42018-03-12 15:02:26 +01002785/* 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 +01002786private function f_TC_conn_fail_crit(charstring id) runs on ConnHdlr {
Harald Welte68e495b2018-02-25 00:05:57 +01002787 f_l1_tune(L1CTL);
Harald Welte70767382018-02-21 12:16:40 +01002788 RSL.clear;
2789
2790 f_est_dchan();
2791 f_sleep(2.0);
Harald Weltef8df4cb2018-03-10 15:15:08 +01002792 L1CTL.send(ts_L1CTL_DM_REL_REQ(g_chan_nr));
Harald Welte70767382018-02-21 12:16:40 +01002793
2794 timer T := 40.0;
2795 T.start;
2796 alt {
2797 [] RSL.receive(tr_RSL_CONN_FAIL_IND(g_chan_nr, ?)) {
2798 setverdict(pass)
2799 }
2800 [] RSL.receive { repeat };
2801 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002802 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "No CONN FAIL IND received");
Harald Welte70767382018-02-21 12:16:40 +01002803 }
2804 }
2805 f_rsl_chan_deact();
2806}
2807testcase TC_conn_fail_crit() runs on test_CT {
2808 var ConnHdlr vc_conn;
2809 var ConnHdlrPars pars;
Harald Welte10474062019-05-30 16:48:17 +02002810 f_init();
Harald Welte70767382018-02-21 12:16:40 +01002811 pars := valueof(t_Pars(t_RslChanNr_SDCCH8(6, 3), ts_RSL_ChanMode_SIGN));
2812 pars.t_guard := 60.0;
2813 vc_conn := f_start_handler(refers(f_TC_conn_fail_crit), pars);
2814 vc_conn.done;
2815}
2816
Harald Welte93640c62018-02-25 16:59:33 +01002817/***********************************************************************
2818 * Paging
2819 ***********************************************************************/
2820
Harald Welte68e495b2018-02-25 00:05:57 +01002821function tmsi_is_dummy(TMSIP_TMSI_V tmsi) return boolean {
2822 if (tmsi == 'FFFFFFFF'O) {
2823 return true;
2824 } else {
2825 return false;
2826 }
2827}
Harald Welte70767382018-02-21 12:16:40 +01002828
Philipp Maier82cb0b12018-08-31 14:41:39 +02002829type record allowedFn { integer frame_nr }
2830template allowedFn bs_ag_blks_res_0 := { frame_nr := (6, 12, 16, 22, 26, 32, 36, 42, 46) }
2831template allowedFn bs_ag_blks_res_1 := { frame_nr := (12, 16, 22, 26, 32, 36, 42, 46) }
2832template allowedFn bs_ag_blks_res_2 := { frame_nr := (16, 22, 26, 32, 36, 42, 46) }
2833template allowedFn bs_ag_blks_res_3 := { frame_nr := (22, 26, 32, 36, 42, 46) }
2834template allowedFn bs_ag_blks_res_4 := { frame_nr := (26, 32, 36, 42, 46) }
2835template allowedFn bs_ag_blks_res_5 := { frame_nr := (32, 36, 42, 46) }
2836template allowedFn bs_ag_blks_res_6 := { frame_nr := (36, 42, 46) }
2837template allowedFn bs_ag_blks_res_7 := { frame_nr := (42, 46) }
2838function check_pch_fn(integer frame_nr, integer bs_ag_blks_res) runs on test_CT
2839{
2840 var integer frame_nr_51;
2841 frame_nr_51 := frame_nr mod 51
2842
2843 var allowedFn fn_check;
2844 fn_check.frame_nr := frame_nr_51;
2845
2846 if (bs_ag_blks_res < 0 or bs_ag_blks_res > 7) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002847 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "bs_ag_blks_res out of valid range (0..7)");
Philipp Maier82cb0b12018-08-31 14:41:39 +02002848 return;
2849 }
2850
2851 if (bs_ag_blks_res == 0 and match(fn_check, bs_ag_blks_res_0)) {
2852 return;
2853 }
2854 if (bs_ag_blks_res == 1 and match(fn_check, bs_ag_blks_res_1)) {
2855 return;
2856 }
2857 if (bs_ag_blks_res == 2 and match(fn_check, bs_ag_blks_res_2)) {
2858 return;
2859 }
2860 if (bs_ag_blks_res == 3 and match(fn_check, bs_ag_blks_res_3)) {
2861 return;
2862 }
2863 if (bs_ag_blks_res == 4 and match(fn_check, bs_ag_blks_res_4)) {
2864 return;
2865 }
2866 if (bs_ag_blks_res == 5 and match(fn_check, bs_ag_blks_res_5)) {
2867 return;
2868 }
2869 if (bs_ag_blks_res == 6 and match(fn_check, bs_ag_blks_res_6)) {
2870 return;
2871 }
2872 if (bs_ag_blks_res == 7 and match(fn_check, bs_ag_blks_res_7)) {
2873 return;
2874 }
2875
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002876 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "received paging on AGCH");
Philipp Maier82cb0b12018-08-31 14:41:39 +02002877 return;
2878}
2879
2880altstep 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 +01002881runs on test_CT {
2882 var L1ctlDlMessage dl;
Harald Weltef8df4cb2018-03-10 15:15:08 +01002883 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?, c_DummyUI)) {
Harald Welte68e495b2018-02-25 00:05:57 +01002884 repeat;
2885 }
Harald Weltef8df4cb2018-03-10 15:15:08 +01002886 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0))) -> value dl {
Harald Welte68e495b2018-02-25 00:05:57 +01002887 var octetstring without_plen :=
2888 substr(dl.payload.data_ind.payload, 1, lengthof(dl.payload.data_ind.payload)-1);
2889 var PDU_ML3_NW_MS rr := dec_PDU_ML3_NW_MS(without_plen);
Philipp Maier82cb0b12018-08-31 14:41:39 +02002890
2891 check_pch_fn(dl.dl_info.frame_nr, cfg.bs_ag_blks_res);
2892
Vadim Yanitskiy36aa07c2020-03-31 14:33:43 +07002893 if (match(rr, tr_PAGING_REQ1(tr_MI_LV(t_MI_NoIdentity(?))))) {
2894 /* Ignore empty RR Paging Request (PCH filling) messages.
2895 * TODO: does it make sense to count them? */
2896 } else if (match(rr, tr_PAGING_REQ1)) {
Harald Welte68e495b2018-02-25 00:05:57 +01002897 num_paging_rcv_msgs := num_paging_rcv_msgs + 1;
2898 num_paging_rcv_ids := num_paging_rcv_ids + 1;
Vadim Yanitskiyd665c232020-03-30 14:40:41 +07002899 if (ispresent(rr.msgs.rrm.pagingReq_Type1.mobileIdentity2)) {
Harald Welte68e495b2018-02-25 00:05:57 +01002900 num_paging_rcv_ids := num_paging_rcv_ids + 1;
2901 }
2902 } else if (match(rr, tr_PAGING_REQ2)) {
2903 num_paging_rcv_msgs := num_paging_rcv_msgs + 1;
2904 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type2.mobileIdentity1)) {
2905 num_paging_rcv_ids := num_paging_rcv_ids + 1;
2906 }
2907 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type2.mobileIdentity2)) {
2908 num_paging_rcv_ids := num_paging_rcv_ids + 1;
2909 }
Vadim Yanitskiyd665c232020-03-30 14:40:41 +07002910 if (ispresent(rr.msgs.rrm.pagingReq_Type2.mobileIdentity3)) {
Harald Welte68e495b2018-02-25 00:05:57 +01002911 num_paging_rcv_ids := num_paging_rcv_ids + 1;
2912 }
2913 } else if (match(rr, tr_PAGING_REQ3)) {
2914 num_paging_rcv_msgs := num_paging_rcv_msgs + 1;
2915 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity1)) {
2916 num_paging_rcv_ids := num_paging_rcv_ids + 1;
2917 }
2918 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity2)) {
2919 num_paging_rcv_ids := num_paging_rcv_ids + 1;
2920 }
2921 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity3)) {
2922 num_paging_rcv_ids := num_paging_rcv_ids + 1;
2923 }
2924 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity4)) {
2925 num_paging_rcv_ids := num_paging_rcv_ids + 1;
2926 }
2927 }
2928 repeat;
2929 }
2930}
2931
2932type record PagingTestCfg {
2933 boolean combined_ccch,
2934 integer bs_ag_blks_res,
2935 float load_factor,
2936 boolean exp_load_ind,
2937 boolean exp_overload,
2938 boolean use_tmsi
2939}
2940
2941type record PagingTestState {
2942 integer num_paging_sent,
2943 integer num_paging_rcv_msgs,
2944 integer num_paging_rcv_ids,
2945 integer num_overload
2946}
2947
2948/* receive + ignore RSL RF RES IND */
2949altstep as_rsl_res_ind() runs on test_CT {
2950 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_RF_RES_IND)) {
2951 repeat;
2952 }
2953}
2954
2955/* Helper function for paging related testing */
2956private function f_TC_paging(PagingTestCfg cfg) runs on test_CT return PagingTestState {
Harald Welte10474062019-05-30 16:48:17 +02002957 f_init();
Harald Welte68e495b2018-02-25 00:05:57 +01002958 f_init_l1ctl();
2959 f_l1_tune(L1CTL);
2960
2961 var PagingTestState st := {
2962 num_paging_sent := 0,
2963 num_paging_rcv_msgs := 0,
2964 num_paging_rcv_ids := 0,
2965 num_overload := 0
2966 };
2967
2968 var float max_pch_blocks_per_sec := f_pch_block_rate_est(cfg.combined_ccch, cfg.bs_ag_blks_res);
2969 var float max_pch_imsi_per_sec;
2970 if (cfg.use_tmsi) {
2971 max_pch_imsi_per_sec := max_pch_blocks_per_sec * 4.0; /* Type 3 */
2972 } else {
2973 max_pch_imsi_per_sec := max_pch_blocks_per_sec * 2.0; /* Type 1 */
2974 }
2975 var float pch_blocks_per_sec := max_pch_imsi_per_sec * cfg.load_factor;
2976 var float interval := 1.0 / pch_blocks_per_sec;
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02002977 var float time_total := 20.0;
2978 var integer pkt_total := float2int(time_total * pch_blocks_per_sec);
2979 log("pch_blocks_total=", pkt_total," pch_blocks_per_sec=", pch_blocks_per_sec, " interval=", interval);
Harald Welte68e495b2018-02-25 00:05:57 +01002980
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02002981 timer T_total := 300.0; /* big value (far bigger than time_total), used to count elapsed time */
2982 T_total.start;
Harald Welte68e495b2018-02-25 00:05:57 +01002983
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02002984 timer T_itv := 0.0;
2985 T_itv.start;
2986 while (st.num_paging_sent < pkt_total) {
Harald Welte68e495b2018-02-25 00:05:57 +01002987 alt {
2988 /* check for presence of CCCH LOAD IND (paging load) */
2989 [cfg.exp_overload] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_PAGING_LOAD_IND(0))) {
2990 st.num_overload := st.num_overload + 1;
2991 repeat;
2992 }
2993 [not cfg.exp_overload] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_PAGING_LOAD_IND(0))) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002994 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected PCH Overload");
Harald Welte68e495b2018-02-25 00:05:57 +01002995 }
2996 [cfg.exp_load_ind] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_PAGING_LOAD_IND)) {
2997 log("Rx LOAD_IND");
2998 /* FIXME: analyze/verify interval + contents */
2999 repeat;
3000 }
3001 /* check if paging requests arrive on Um side */
Philipp Maier82cb0b12018-08-31 14:41:39 +02003002 [] as_l1_count_paging(st.num_paging_rcv_msgs, st.num_paging_rcv_ids, cfg);
Harald Welte68e495b2018-02-25 00:05:57 +01003003 [] L1CTL.receive { repeat; }
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02003004 [] T_itv.timeout {
3005 /* Send paging cmds based on elapsed time */
3006 var integer new_sent := f_min(pkt_total, float2int(T_total.read * pch_blocks_per_sec) + 1);
3007 while (st.num_paging_sent < new_sent) {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07003008 var MobileIdentityV mi;
3009
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02003010 /* build mobile Identity */
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02003011 if (cfg.use_tmsi) {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07003012 mi := valueof(t_MI_TMSI(f_rnd_octstring(4)));
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02003013 } else {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07003014 mi := valueof(ts_MI_IMSI(f_gen_imsi(st.num_paging_sent)));
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02003015 }
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02003016
3017 /* Send RSL PAGING COMMAND */
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07003018 RSL_CCHAN.send(ts_RSL_UD(ts_RSL_PAGING_CMD(mi, st.num_paging_sent mod 4)));
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02003019
3020 st.num_paging_sent := st.num_paging_sent + 1;
3021 }
3022 if (st.num_paging_sent < pkt_total) {
3023 /* Wait for interval to next PAGING COMMAND */
3024 var float time_now := T_total.read;
3025 var float next_sched := int2float(st.num_paging_sent)*interval;
3026 if (next_sched > time_now) {
3027 T_itv.start(next_sched - time_now);
3028 } else {
3029 T_itv.start(0.0);
3030 }
3031 } else {
3032 /* We are done, no need to keep counting */
3033 T_total.stop;
3034 }
3035 }
3036 [] T_total.timeout { }
Harald Welte68e495b2018-02-25 00:05:57 +01003037 [] as_rsl_res_ind();
3038 }
3039 }
3040
3041 /* wait for max 18s for paging queue to drain (size: 200, ~ 13 per s -> 15s) */
3042 timer T_wait := 18.0;
3043 T_wait.start;
3044 alt {
Philipp Maier82cb0b12018-08-31 14:41:39 +02003045 [] as_l1_count_paging(st.num_paging_rcv_msgs, st.num_paging_rcv_ids, cfg);
Harald Welte68e495b2018-02-25 00:05:57 +01003046 [] L1CTL.receive { repeat; }
3047 /* 65535 == empty paging queue, we can terminate*/
3048 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_PAGING_LOAD_IND(65535))) { }
3049 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_PAGING_LOAD_IND)) { repeat; }
3050 [] T_wait.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003051 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Waiting for empty paging queue");
Harald Welte68e495b2018-02-25 00:05:57 +01003052 }
3053 [] as_rsl_res_ind();
3054 }
3055
3056 log("num_paging_sent=", st.num_paging_sent, " rcvd_msgs=", st.num_paging_rcv_msgs,
3057 " rcvd_ids=", st.num_paging_rcv_ids);
3058 return st;
3059}
3060
3061/* Create ~ 80% paging load (IMSI only) sustained for about 20s, verifying that
3062 * - the number of Mobile Identities on Um PCH match the number of pages on RSL
3063 * - that CCCH LOAD IND (PCH) are being generated
3064 * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */
3065testcase TC_paging_imsi_80percent() runs on test_CT {
Philipp Maierd65d0562018-08-30 16:25:47 +02003066 var SystemInformation si3 := valueof(ts_SI3_default);
Harald Welte68e495b2018-02-25 00:05:57 +01003067 var PagingTestCfg cfg := {
3068 combined_ccch := true,
Philipp Maierd65d0562018-08-30 16:25:47 +02003069 bs_ag_blks_res := si3.payload.si3.ctrl_chan_desc.bs_ag_blks_res,
Harald Welte68e495b2018-02-25 00:05:57 +01003070 load_factor := 0.8,
3071 exp_load_ind := true,
3072 exp_overload := false,
3073 use_tmsi := false
3074 };
3075 var PagingTestState st := f_TC_paging(cfg);
3076 if (st.num_paging_sent != st.num_paging_rcv_ids) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003077 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Expected ", st.num_paging_sent, " pagings but have ",
3078 st.num_paging_rcv_ids));
Harald Welte68e495b2018-02-25 00:05:57 +01003079 } else {
3080 setverdict(pass);
3081 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003082 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte68e495b2018-02-25 00:05:57 +01003083}
3084
3085/* Create ~ 80% paging load (TMSI only) sustained for about 20s, verifying that
3086 * - the number of Mobile Identities on Um PCH match the number of pages on RSL
3087 * - that CCCH LOAD IND (PCH) are being generated
3088 * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */
3089testcase TC_paging_tmsi_80percent() runs on test_CT {
Philipp Maierd65d0562018-08-30 16:25:47 +02003090 var SystemInformation si3 := valueof(ts_SI3_default);
Harald Welte68e495b2018-02-25 00:05:57 +01003091 var PagingTestCfg cfg := {
3092 combined_ccch := true,
Philipp Maierd65d0562018-08-30 16:25:47 +02003093 bs_ag_blks_res := si3.payload.si3.ctrl_chan_desc.bs_ag_blks_res,
Harald Welte68e495b2018-02-25 00:05:57 +01003094 load_factor := 0.8,
3095 exp_load_ind := true,
3096 exp_overload := false,
3097 use_tmsi := true
3098 };
3099 var PagingTestState st := f_TC_paging(cfg);
3100 if (st.num_paging_sent != st.num_paging_rcv_ids) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003101 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Expected ", st.num_paging_sent, " pagings but have ",
3102 st.num_paging_rcv_ids));
Harald Welte68e495b2018-02-25 00:05:57 +01003103 } else {
3104 setverdict(pass);
3105 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003106 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte68e495b2018-02-25 00:05:57 +01003107}
3108
3109/* Create ~ 200% paging load (IMSI only) sustained for about 20s, verifying that
3110 * - the number of Mobile Identities on Um PCH are ~ 82% of the number of pages on RSL
3111 * - that CCCH LOAD IND (PCH) are being generated and reach 0 at some point
3112 * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */
3113testcase TC_paging_imsi_200percent() runs on test_CT {
Philipp Maierd65d0562018-08-30 16:25:47 +02003114 var SystemInformation si3 := valueof(ts_SI3_default);
Harald Welte68e495b2018-02-25 00:05:57 +01003115 var PagingTestCfg cfg := {
3116 combined_ccch := true,
Philipp Maierd65d0562018-08-30 16:25:47 +02003117 bs_ag_blks_res := si3.payload.si3.ctrl_chan_desc.bs_ag_blks_res,
Harald Welte68e495b2018-02-25 00:05:57 +01003118 load_factor := 2.0,
3119 exp_load_ind := true,
3120 exp_overload := true,
3121 use_tmsi := false
3122 };
3123 var PagingTestState st := f_TC_paging(cfg);
3124 /* We expect about 80-85% to pass, given that we can fill the paging buffer of 200
3125 * slots and will fully drain that buffer before returning */
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02003126 var template integer tpl := (st.num_paging_sent*78/100 .. st.num_paging_sent *85/100);
Harald Welte68e495b2018-02-25 00:05:57 +01003127 if (not match(st.num_paging_rcv_ids, tpl)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003128 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 +01003129 } else {
3130 setverdict(pass);
3131 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003132 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte68e495b2018-02-25 00:05:57 +01003133}
3134
3135/* Create ~ 200% paging load (TMSI only) sustained for about 20s, verifying that
3136 * - the number of Mobile Identities on Um PCH are ~ 82% of the number of pages on RSL
3137 * - that CCCH LOAD IND (PCH) are being generated and reach 0 at some point
3138 * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */
3139testcase TC_paging_tmsi_200percent() runs on test_CT {
Philipp Maierd65d0562018-08-30 16:25:47 +02003140 var SystemInformation si3 := valueof(ts_SI3_default);
Harald Welte68e495b2018-02-25 00:05:57 +01003141 var PagingTestCfg cfg := {
3142 combined_ccch := true,
Philipp Maierd65d0562018-08-30 16:25:47 +02003143 bs_ag_blks_res := si3.payload.si3.ctrl_chan_desc.bs_ag_blks_res,
Harald Welte68e495b2018-02-25 00:05:57 +01003144 load_factor := 2.0,
3145 exp_load_ind := true,
3146 exp_overload := true,
3147 use_tmsi := true
3148 };
3149 var PagingTestState st := f_TC_paging(cfg);
3150 /* We expect about 70% to pass, given that we can fill the paging buffer of 200
3151 * slots and will fully drain that buffer before returning */
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02003152 var template integer tpl := (st.num_paging_sent*64/100 .. st.num_paging_sent *72/100);
Harald Welte68e495b2018-02-25 00:05:57 +01003153 if (not match(st.num_paging_rcv_ids, tpl)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003154 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 +01003155 } else {
3156 setverdict(pass);
3157 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003158 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte68e495b2018-02-25 00:05:57 +01003159}
3160
3161
Harald Welte93640c62018-02-25 16:59:33 +01003162/***********************************************************************
3163 * Immediate Assignment / AGCH
3164 ***********************************************************************/
Harald Weltee8d750e2018-06-10 21:41:35 +02003165const MobileAllocation c_MA_null := {
3166 len := 0,
3167 ma := ''B
3168}
Harald Welte93640c62018-02-25 16:59:33 +01003169
Harald Weltee8d750e2018-06-10 21:41:35 +02003170template (value) ChannelDescription ts_ChanDesc(template (value) RslChannelNr chan_nr, uint3_t tsc := 7,
3171 uint12_t arfcn := 871) := {
3172 chan_nr := chan_nr,
3173 tsc := tsc,
3174 h := false,
3175 arfcn := arfcn,
3176 maio_hsn := omit
3177}
3178
3179private function f_fmt_ia_stats(integer num_tx, integer num_rx, integer num_del) return charstring {
3180 return int2str(num_tx) & " sent, "
3181 & int2str(num_rx) & " received, "
3182 & int2str(num_del) & " deleted";
3183}
3184
3185private function f_TC_imm_ass(integer num_total, float sleep_s, float exp_pass) runs on test_CT {
3186 var L1ctlDlMessage l1_dl;
3187 timer T := 10.0;
3188 var integer num_tx := 0;
3189 var integer num_rx := 0;
3190 var integer num_del := 0;
3191 var charstring res_str;
3192 var float rx_ratio;
3193
Harald Welte10474062019-05-30 16:48:17 +02003194 f_init();
Harald Weltee8d750e2018-06-10 21:41:35 +02003195 f_init_l1ctl();
3196 f_l1_tune(L1CTL);
3197
3198 for (var integer i := 0; i < num_total; i := i+1) {
3199 var ChannelDescription ch_desc := valueof(ts_ChanDesc(valueof(t_RslChanNr_SDCCH4(0, 0))));
3200 var GsmRrMessage ia := valueof(ts_IMM_ASS(42, i, 5, ch_desc, c_MA_null));
3201 var octetstring ia_enc := enc_GsmRrMessage(ia);
Harald Welte68e495b2018-02-25 00:05:57 +01003202 RSL_CCHAN.send(ts_RSL_UD(ts_RSL_IMM_ASSIGN(ia_enc, 0)));
Harald Weltee8d750e2018-06-10 21:41:35 +02003203 num_tx := num_tx+1;
3204 f_sleep(sleep_s);
Harald Welte68e495b2018-02-25 00:05:57 +01003205 }
3206 /* FIXME: check if imm.ass arrive on Um side */
Harald Weltee8d750e2018-06-10 21:41:35 +02003207 T.start;
3208 alt {
3209 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_DELETE_IND(?, 0))) {
3210 num_del := num_del+1;
3211 repeat;
3212 }
3213 [] RSL_CCHAN.receive {
3214 repeat;
3215 }
3216 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?)) -> value l1_dl {
3217 /* somehow dec_SystemInformation will try to decode even non-RR as SI */
3218 var GsmRrMessage rr := dec_GsmRrMessage(l1_dl.payload.data_ind.payload);
3219 if (not match(rr, tr_IMM_ASS(42, ?, 5, ?, ?))) {
3220 /* FIXME: Why are we seeing paging requests on PCH/AGCH? */
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003221 //Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Unexpected IMM-ASS values on AGCH: ", rr));
Harald Weltee8d750e2018-06-10 21:41:35 +02003222 } else {
3223 num_rx := num_rx+1;
3224 }
3225 repeat;
3226 }
3227 [] L1CTL.receive { repeat; }
3228 [] T.timeout { }
3229 }
3230 res_str := f_fmt_ia_stats(num_tx, num_rx, num_del);
3231 log("AGCH test: " & res_str);
3232 if (num_rx + num_del != num_tx) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003233 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "RX + DEL != TX ?!?: " & res_str);
Harald Weltee8d750e2018-06-10 21:41:35 +02003234 }
3235 rx_ratio := int2float(num_rx) / int2float(num_tx);
3236 if (rx_ratio < exp_pass*0.8 or rx_ratio > exp_pass*1.2) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003237 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 +02003238 } else {
3239 setverdict(pass);
3240 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003241 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte68e495b2018-02-25 00:05:57 +01003242}
3243
Harald Weltee8d750e2018-06-10 21:41:35 +02003244/* send a long burst of 1000 IMM.ASS with 20ms spacing (50 per s); expect 75% of them to be deleted */
3245testcase TC_imm_ass_1000_20ms() runs on test_CT {
3246 f_TC_imm_ass(1000, 0.02, 0.25);
3247}
3248
3249/* send a short burst of 200 IMM.ASS without any spacing; expect 95% of them to be deleted */
3250testcase TC_imm_ass_200_0ms() runs on test_CT {
3251 f_TC_imm_ass(200, 0.0, 0.05);
3252}
3253
3254/* send 150 IMM.ASS at rate of 13/s; expect none of them to be deleted */
3255testcase TC_imm_ass_200_76ms() runs on test_CT {
3256 f_TC_imm_ass(150, 0.076, 1.00);
3257}
3258
3259
3260
Harald Welte48494ca2018-02-25 16:59:50 +01003261/***********************************************************************
3262 * BCCH
3263 ***********************************************************************/
3264
3265/* tuple of Frame Number + decoded SI */
3266type record SystemInformationFn {
3267 GsmFrameNumber frame_number,
3268 SystemInformation si
3269}
3270
3271/* an arbitrary-length vector of decoded SI + gsmtap header */
3272type record of SystemInformationFn SystemInformationVector;
3273
3274/* an array of SI-vectors indexed by TC value */
3275type SystemInformationVector SystemInformationVectorPerTc[8];
3276
3277/* determine if a given SI vector contains given SI type at least once */
3278function f_si_vecslot_contains(SystemInformationVector arr, RrMessageType key, boolean bcch_ext := false) return boolean {
3279 for (var integer i:= 0; i< sizeof(arr); i := i + 1) {
3280 var integer fn_mod51 := arr[i].frame_number mod 51;
3281 if (not bcch_ext and fn_mod51 == 2 or
3282 bcch_ext and fn_mod51 == 6) {
3283 if (arr[i].si.header.message_type == key) {
3284 return true;
3285 }
3286 }
3287 }
3288 return false;
3289}
3290
3291/* ensure a given TC slot of the SI vector contains given SI type at least once at TC */
3292function f_ensure_si_vec_contains(SystemInformationVectorPerTc arr, integer tc, RrMessageType key, boolean ext_bcch := false) {
3293 if (not f_si_vecslot_contains(arr[tc], key, ext_bcch)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003294 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("No ", key, " in TC=", tc, "!"));
Harald Welte48494ca2018-02-25 16:59:50 +01003295 }
3296}
3297
3298/* check if a given SI vector contains given SI type at least once on any TC */
3299function f_si_vec_contains(SystemInformationVectorPerTc arr, RrMessageType key) return boolean {
3300 for (var integer tc:= 0; tc < sizeof(arr); tc := tc + 1) {
3301 if (f_si_vecslot_contains(arr[tc], key) or
3302 f_si_vecslot_contains(arr[tc], key, true)) {
3303 return true;
3304 }
3305 }
3306 return false;
3307}
3308
3309/* determine if a given SI vector contains given SI type at least N of M times */
3310function f_si_vecslot_contains_n_of_m(SystemInformationVector arr, RrMessageType key, boolean bcch_ext := false, integer n := 1, integer m := 4) return boolean {
3311 var integer count := 0;
3312 if (sizeof(arr) < m) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003313 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Error: Insufficient SI in array");
Harald Welte48494ca2018-02-25 16:59:50 +01003314 }
3315 for (var integer i:= 0; i < m; i := i + 1) {
3316 var integer fn_mod51 := arr[i].frame_number mod 51;
3317 if (not bcch_ext and fn_mod51 == 2 or
3318 bcch_ext and fn_mod51 == 6) {
3319 if (arr[i].si.header.message_type == key) {
3320 count := count + 1;
3321 }
3322 }
3323 }
3324 if (count >= n) {
3325 return true;
3326 } else {
3327 return false;
3328 }
3329}
3330
3331/* ensure a given TC slot of the SI vector contains given SI type at least N out of M times at TC */
3332function f_ensure_si_vec_contains_n_of_m(SystemInformationVectorPerTc arr, integer tc, RrMessageType key, boolean ext_bcch := false, integer n, integer m) {
3333 if (not f_si_vecslot_contains_n_of_m(arr[tc], key, ext_bcch, n, m)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003334 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Not ", n, "/", m, " of ", key, " in TC=", tc, "!"));
Harald Welte48494ca2018-02-25 16:59:50 +01003335 }
3336}
3337
3338/* determine if a given SI vector contains given SI type at least once */
3339function f_si_vecslot_contains_only(SystemInformationVector arr, RrMessageType key, boolean bcch_ext := false) return boolean {
3340 for (var integer i:= 0; i< sizeof(arr); i := i + 1) {
3341 var integer fn_mod51 := arr[i].frame_number mod 51;
3342 if (not bcch_ext and fn_mod51 == 2 or
3343 bcch_ext and fn_mod51 == 6) {
3344 if (arr[i].si.header.message_type != key) {
3345 return false;
3346 }
3347 }
3348 }
3349 return true;
3350}
3351
3352/* ensure a given TC slot of the SI vector contains only given SI type */
3353function f_ensure_si_vec_contains_only(SystemInformationVectorPerTc arr, integer tc, RrMessageType key, boolean ext_bcch := false) {
3354 if (not f_si_vecslot_contains_only(arr[tc], key, ext_bcch)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003355 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Not all ", key, " in TC=", tc, "!"));
Harald Welte48494ca2018-02-25 16:59:50 +01003356 }
3357}
3358
3359/* SI configuration of cell, against which we validate actual SI messages */
3360type set SystemInformationConfig {
3361 boolean bcch_extended,
3362 boolean si1_present,
3363 boolean si2bis_present,
3364 boolean si2ter_present,
3365 boolean si2quater_present,
3366 boolean si7_present,
3367 boolean si8_present,
3368 boolean si9_present,
3369 boolean si13_present,
3370 boolean si13alt_present,
3371 boolean si15_present,
3372 boolean si16_present,
3373 boolean si17_present,
3374 boolean si2n_present,
3375 boolean si21_present,
3376 boolean si22_present
3377}
3378
3379/* validate the SI scheduling according to TS 45.002 version 14.1.0 Release 14, Section 6.3.1.3 */
3380function f_validate_si_scheduling(SystemInformationConfig cfg, SystemInformationVectorPerTc si_per_tc) {
3381 var integer i;
3382 for (i := 0; i < sizeof(si_per_tc); i := i + 1) {
3383 if (sizeof(si_per_tc[i]) == 0) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003384 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("No SI messages for TC=", i));
Harald Welte48494ca2018-02-25 16:59:50 +01003385 }
3386 }
3387 if (cfg.si1_present) {
3388 /* ii) System Information Type 1 needs to be sent if frequency hopping is in use or
3389 * when the NCH is present in a cell. If the MS finds another message on BCCH Norm
3390 * when TC = 0, it can assume that System Information Type 1 is not in use. */
3391 f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_1);
3392 /* make sure *ALL* contain SI1 */
3393 f_ensure_si_vec_contains_only(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_1);
3394 }
3395 f_ensure_si_vec_contains(si_per_tc, 1, SYSTEM_INFORMATION_TYPE_2);
3396 /* iii) A SI 2 message will be sent at least every time TC = 1 */
3397 f_ensure_si_vec_contains(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_3);
3398 f_ensure_si_vec_contains(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_3);
3399 f_ensure_si_vec_contains(si_per_tc, 3, SYSTEM_INFORMATION_TYPE_4);
3400 f_ensure_si_vec_contains(si_per_tc, 7, SYSTEM_INFORMATION_TYPE_4);
3401
3402 /* iii) System information type 2 bis or 2 ter messages are sent if needed, as determined by the
3403 * system operator. If only one of them is needed, it is sent when TC = 5. If both are
3404 * needed, 2bis is sent when TC = 5 and 2ter is sent at least once within any of 4
3405 * consecutive occurrences of TC = 4. */
3406 if (cfg.si2bis_present and not cfg.si2ter_present) {
3407 f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2bis);
3408 } else if (cfg.si2ter_present and not cfg.si2bis_present) {
3409 f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2ter);
3410 } else if (cfg.si2ter_present and cfg.si2bis_present) {
3411 f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2bis);
3412 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2ter, false, 1, 4);
3413 }
3414
3415 if (cfg.si7_present or cfg.si8_present) {
3416 /* vi) Use of System Information type 7 and 8 is not always necessary. It is necessary
3417 * if System Information type 4 does not contain all information needed for cell
3418 * selection and reselection. */
3419 if (not cfg.bcch_extended) {
3420 testcase.stop("Error: SI7/SI8 require BCCH Extd.");
3421 }
3422 if (cfg.si7_present) {
3423 f_ensure_si_vec_contains(si_per_tc, 7, SYSTEM_INFORMATION_TYPE_7, true);
3424 }
3425 if (cfg.si8_present) {
3426 f_ensure_si_vec_contains(si_per_tc, 3, SYSTEM_INFORMATION_TYPE_8, true);
3427 }
3428 }
3429
3430 if (cfg.si2quater_present) {
3431 /* iii) System information type 2 quater is sent if needed, as determined by the system
3432 * operator. If sent on BCCH Norm, it shall be sent when TC = 5 if neither of 2bis
3433 * and 2ter are used, otherwise it shall be sent at least once within any of 4
3434 * consecutive occurrences of TC = 4. If sent on BCCH Ext, it is sent at least once
3435 * within any of 4 consecutive occurrences of TC = 5. */
3436 if (not (cfg.bcch_extended)) {
3437 if (not (cfg.si2bis_present or cfg.si2ter_present)) {
3438 f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2quater);
3439 } else {
3440 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2quater, false, 1, 4);
3441 }
3442 } else {
3443 f_ensure_si_vec_contains_n_of_m(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2quater, true, 1, 4);
3444 }
3445 }
3446 if (cfg.si9_present) {
3447 /* vi) System Information type 9 is sent in those blocks with TC = 4 which are specified
3448 * in system information type 3 as defined in 3GPP TS 44.018. */
3449 f_ensure_si_vec_contains(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_9); // FIXME SI3
3450 }
3451 if (cfg.si13_present) {
3452 /* vii) System Information type 13 is only related to the GPRS service. System Information
3453 * Type 13 need only be sent if GPRS support is indicated in one or more of System
3454 * Information Type 3 or 4 or 7 or 8 messages. These messages also indicate if the
3455 * message is sent on the BCCH Norm or if the message is transmitted on the BCCH Ext.
3456 * In the case that the message is sent on the BCCH Norm, it is sent at least once
3457 * within any of 4 consecutive occurrences of TC=4. */
3458 if (not cfg.bcch_extended) {
3459 log("not-bccch-extended");
3460 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_13, false, 1, 4);
3461 } else {
3462 log("bccch-extended");
3463 f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_13, true);
3464 }
3465 if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_13alt)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003466 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Cannot have SI13alt and SI13");
Harald Welte48494ca2018-02-25 16:59:50 +01003467 }
3468 }
3469 if (cfg.si16_present or cfg.si17_present) {
3470 /* viii) System Information type 16 and 17 are only related to the SoLSA service. They
3471 * should not be sent in a cell where network sharing is used (see rule xv). */
3472 if (cfg.si22_present) {
3473 testcase.stop("Error: Cannot have SI16/SI17 and SI22!");
3474 }
3475 if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_22)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003476 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Cannot have SI16/SI17 and SI22!");
Harald Welte48494ca2018-02-25 16:59:50 +01003477 }
3478 if (not cfg.bcch_extended) {
3479 testcase.stop("Error: SI16/SI17 requires BCCH Extd!");
3480 }
3481 if (cfg.si16_present) {
3482 f_ensure_si_vec_contains(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_16, true);
3483 }
3484 if (cfg.si17_present) {
3485 f_ensure_si_vec_contains(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_17, true);
3486 }
3487 }
3488
3489 /* ix) System Information type 18 and 20 are sent in order to transmit non-GSM
3490 * broadcast information. The frequency with which they are sent is determined by the
3491 * system operator. System Information type 9 identifies the scheduling of System
3492 * Information type 18 and 20 messages. */
3493
3494 /* x) System Information Type 19 is sent if COMPACT neighbours exist. If System
3495 * Information Type 19 is present, then its scheduling shall be indicated in System
3496 * Information Type 9. */
3497
3498 if (cfg.si15_present) {
3499 /* xi) System Information Type 15 is broadcast if dynamic ARFCN mapping is used in the
3500 * PLMN. If sent on BCCH Norm, it is sent at least once within any of 4 consecutive
3501 * occurrences of TC = 4. If sent on BCCH Ext, it is sent at least once within any of
3502 * 4 consecutive occurrences of TC = 1. */
3503 if (not cfg.bcch_extended) {
3504 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_15, false, 1, 4);
3505 } else {
3506 f_ensure_si_vec_contains_n_of_m(si_per_tc, 1, SYSTEM_INFORMATION_TYPE_15, true, 1, 4);
3507 }
3508 }
3509 if (cfg.si13alt_present) {
3510 /* xii) System Information type 13 alt is only related to the GERAN Iu mode. System
3511 * Information Type 13 alt need only be sent if GERAN Iu mode support is indicated in
3512 * one or more of System Information Type 3 or 4 or 7 or 8 messages and SI 13 is not
3513 * broadcast. These messages also indicate if the message is sent on the BCCH Norm or
3514 * if the message is transmitted on the BCCH Ext. In the case that the message is sent
3515 * on the BCCH Norm, it is sent at least once within any of 4 consecutive occurrences
3516 * of TC = 4. */
3517 if (cfg.si13_present) {
3518 testcase.stop("Error: Cannot have SI13alt and SI13");
3519 }
3520 if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_13)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003521 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Cannot have SI13alt and SI13");
Harald Welte48494ca2018-02-25 16:59:50 +01003522 }
3523 if (not cfg.bcch_extended) {
3524 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_13alt, false, 1, 4);
3525 } else {
3526 f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_13alt, true);
3527 }
3528 }
3529 if (cfg.si2n_present) {
3530 /* xiii) System Information Type 2n is optionally sent on BCCH Norm or BCCH Ext if needed,
3531 * as determined by the system operator. In the case that the message is sent on the
3532 * BCCH Norm, it is sent at least once within any of 4 consecutive occurrences of TC =
3533 * 4. If the message is sent on BCCH Ext, it is sent at least once within any of 2
3534 * consecutive occurrences of TC = 4. */
3535 if (not cfg.bcch_extended) {
3536 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2n, false, 1, 4);
3537 } else {
3538 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2n, true, 2, 4);
3539 }
3540 }
3541 if (cfg.si21_present) {
3542 /* xiv) System Information Type 21 is optionally sent on BCCH Norm or BCCH Ext, as
3543 * determined by the system operator. If Extended Access Barring is in use in the cell
3544 * then this message is sent at least once within any of 4 consecutive occurrences of
3545 * TC = 4 regardless if it is sent on BCCH Norm or BCCH Ext. If BCCH Ext is used in a
3546 * cell then this message shall only be sent on BCCH Ext. */
3547 if (not cfg.bcch_extended) {
3548 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_21, false, 1, 4);
3549 } else {
3550 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_21, true, 1, 4);
3551 if (f_si_vecslot_contains(si_per_tc[4], SYSTEM_INFORMATION_TYPE_21)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003552 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Cannot have SI21 on BCCH Norm if BCCH Extd enabled!");
Harald Welte48494ca2018-02-25 16:59:50 +01003553 }
3554 }
3555 }
3556 if (cfg.si22_present) {
3557 /* xv) System Information Type 22 is sent if network sharing is in use in the cell. It
3558 * should not be sent in a cell where SoLSA is used (see rule viii). System
3559 * Information Type 22 instances shall be sent on BCCH Ext within any occurrence of TC
3560 * =2 and TC=6. */
3561 if (cfg.si16_present or cfg.si17_present) {
3562 testcase.stop("Error: Cannot have SI16/SI17 and SI22!");
3563 }
3564 if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_16) or
3565 f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_17)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003566 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Cannot have SI16/SI17 and SI22!");
Harald Welte48494ca2018-02-25 16:59:50 +01003567 }
3568 if (not cfg.bcch_extended) {
3569 testcase.stop("Error: SI22 requires BCCH Extd!");
3570 } else {
3571 f_ensure_si_vec_contains_only(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_22, true);
3572 f_ensure_si_vec_contains_only(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_22, true);
3573 }
3574 }
3575}
3576
3577/* sample Systme Information for specified duration via L1CTL */
3578function f_l1_sample_si(L1CTL_PT pt, float duration := 8.0) return SystemInformationVectorPerTc {
3579 timer T := duration;
3580 var SystemInformationVectorPerTc si_per_tc;
3581 var L1ctlDlMessage l1_dl;
3582
3583 /* initialize all per-TC vectors empty */
3584 for (var integer i:= 0; i < sizeof(si_per_tc); i := i+1) {
3585 si_per_tc[i] := {};
3586 }
3587
3588 /* flush all previous L1 queued msgs */
3589 pt.clear;
3590
3591 T.start;
3592 alt {
Harald Weltef8df4cb2018-03-10 15:15:08 +01003593 [] pt.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl {
Harald Welte48494ca2018-02-25 16:59:50 +01003594 /* somehow dec_SystemInformation will try to decode even non-RR as SI */
3595 if (not (l1_dl.payload.data_ind.payload[1] == '06'O)) {
3596 log("Ignoring non-RR SI ", l1_dl);
3597 repeat;
3598 }
3599 var SystemInformationFn sig := {
3600 frame_number := l1_dl.dl_info.frame_nr,
3601 si := dec_SystemInformation(l1_dl.payload.data_ind.payload)
3602 }
3603 var integer tc := f_gsm_compute_tc(sig.frame_number);
3604 log("SI received at TC=", tc, ": ", sig.si);
3605 /* append to the per-TC bucket */
3606 si_per_tc[tc] := si_per_tc[tc] & { sig };
3607 repeat;
3608 }
3609 [] pt.receive { repeat; }
3610 [] T.timeout { }
3611 }
3612
3613 for (var integer i:= 0; i < sizeof(si_per_tc); i := i+1) {
3614 log(testcasename(), ": TC=", i, " has #of SI=", sizeof(si_per_tc[i]));
3615 }
3616 log("si_per_tc=", si_per_tc);
3617 return si_per_tc;
3618}
3619
3620/* helper function: Set given SI via RSL + validate scheduling.
3621 * CALLER MUST MAKE SURE TO CHANGE GLOBAL si_cfg! */
3622function f_TC_si_sched() runs on test_CT {
3623 var SystemInformationVectorPerTc si_per_tc;
3624 f_init_l1ctl();
3625 f_l1_tune(L1CTL);
3626
3627 /* Sample + Validate Scheduling */
3628 si_per_tc := f_l1_sample_si(L1CTL);
3629 f_validate_si_scheduling(si_cfg, si_per_tc);
3630
3631 setverdict(pass);
3632}
3633
3634testcase TC_si_sched_default() runs on test_CT {
3635 f_init();
Harald Welte0cae4552018-03-09 22:20:26 +01003636 /* 2+3+4 are mandatory and set in f_init() */
3637 f_TC_si_sched();
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003638 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte0cae4552018-03-09 22:20:26 +01003639}
3640
3641testcase TC_si_sched_1() runs on test_CT {
3642 f_init();
3643 si_cfg.si1_present := true;
3644 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_1, '5506198fb38000000000000000000000000000e504002b'O);
Harald Welte48494ca2018-02-25 16:59:50 +01003645 f_TC_si_sched();
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003646 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte48494ca2018-02-25 16:59:50 +01003647}
3648
3649testcase TC_si_sched_2bis() runs on test_CT {
3650 f_init();
3651 si_cfg.si2bis_present := true;
3652 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O);
3653 f_TC_si_sched();
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003654 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte48494ca2018-02-25 16:59:50 +01003655}
3656
3657testcase TC_si_sched_2ter() runs on test_CT {
3658 f_init();
3659 si_cfg.si2ter_present := true;
3660 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O);
3661 f_TC_si_sched();
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003662 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte48494ca2018-02-25 16:59:50 +01003663}
3664
3665testcase TC_si_sched_2ter_2bis() runs on test_CT {
3666 f_init();
3667 si_cfg.si2bis_present := true;
3668 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O);
3669 si_cfg.si2ter_present := true;
3670 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O);
3671 f_TC_si_sched();
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003672 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte48494ca2018-02-25 16:59:50 +01003673}
3674
3675testcase TC_si_sched_2quater() runs on test_CT {
3676 f_init();
3677 si_cfg.si2quater_present := true;
3678 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2quater, '050607a8a0364aa698d72ff424feee0506d5e7fff02043'O);
3679 f_TC_si_sched();
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003680 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte48494ca2018-02-25 16:59:50 +01003681}
3682
3683testcase TC_si_sched_13() runs on test_CT {
3684 f_init();
3685 si_cfg.si13_present := true;
Harald Welte5618c2a2018-04-15 16:24:46 +02003686 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_13, '0106009000185a6fc9e08410ab2b2b2b2b2b2b2b2b2b2b'O);
Harald Welte48494ca2018-02-25 16:59:50 +01003687 f_TC_si_sched();
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003688 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte48494ca2018-02-25 16:59:50 +01003689}
3690
3691testcase TC_si_sched_13_2bis_2ter_2quater() runs on test_CT {
3692 f_init();
3693 si_cfg.si2bis_present := true;
3694 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O);
3695 si_cfg.si2ter_present := true;
3696 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O);
3697 si_cfg.si2quater_present := true;
3698 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2quater, '050607a8a0364aa698d72ff424feee0506d5e7fff02043'O);
3699 si_cfg.si13_present := true;
Harald Welte5618c2a2018-04-15 16:24:46 +02003700 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_13, '0106009000185a6fc9e08410ab2b2b2b2b2b2b2b2b2b2b'O);
Harald Welte48494ca2018-02-25 16:59:50 +01003701 f_TC_si_sched();
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003702 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte48494ca2018-02-25 16:59:50 +01003703}
3704
3705
Harald Welte68e495b2018-02-25 00:05:57 +01003706testcase TC_bcch_info() runs on test_CT {
Harald Welte10474062019-05-30 16:48:17 +02003707 f_init();
Harald Welte68e495b2018-02-25 00:05:57 +01003708 /* FIXME: enable / disable individual BCCH info */
3709 //ts_RSL_BCCH_INFO(si_type, info);
3710 /* expect no ERROR REPORT after either of them *
3711 /* negative test: ensure ERROR REPORT on unsupported types */
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003712 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte68e495b2018-02-25 00:05:57 +01003713}
3714
Harald Welte93640c62018-02-25 16:59:33 +01003715/***********************************************************************
3716 * Low-Level Protocol Errors / ERROR REPORT
3717 ***********************************************************************/
3718
Harald Welte01d982c2018-02-25 01:31:40 +01003719private function f_exp_err_rep(template RSL_Cause cause) runs on test_CT {
3720 timer T := 5.0;
3721 T.start;
3722 alt {
3723 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_ERROR_REPORT(cause))) {
3724 setverdict(pass);
3725 }
3726 [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_ERROR_REPORT(?))) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003727 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Wrong cause in RSL ERR REP");
Harald Welte01d982c2018-02-25 01:31:40 +01003728 }
3729 [] RSL_CCHAN.receive {
3730 repeat;
3731 }
3732 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003733 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RSL ERR REP");
Harald Welte01d982c2018-02-25 01:31:40 +01003734 }
3735 }
3736}
3737
3738/* Provoke a protocol error (message too short) and match on ERROR REPORT */
3739testcase TC_rsl_protocol_error() runs on test_CT {
Harald Welte10474062019-05-30 16:48:17 +02003740 f_init();
Harald Welte01d982c2018-02-25 01:31:40 +01003741 var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O));
3742 rsl.ies := omit;
3743 RSL_CCHAN.send(ts_RSL_UD(rsl));
3744
3745 f_exp_err_rep(RSL_ERR_PROTO);
3746}
3747
3748/* Provoke a mandatory IE error and match on ERROR REPORT */
3749testcase TC_rsl_mand_ie_error() runs on test_CT {
Harald Welte10474062019-05-30 16:48:17 +02003750 f_init();
Harald Welte01d982c2018-02-25 01:31:40 +01003751
3752 var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O));
3753 rsl.ies := { rsl.ies[0] };
3754 RSL_CCHAN.send(ts_RSL_UD(rsl));
3755
3756 f_exp_err_rep(RSL_ERR_MAND_IE_ERROR);
3757}
3758
3759/* Provoke an IE content error and match on ERROR REPORT */
3760testcase TC_rsl_ie_content_error() runs on test_CT {
Harald Welte10474062019-05-30 16:48:17 +02003761 f_init();
Harald Welte01d982c2018-02-25 01:31:40 +01003762 var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O));
3763 rsl.ies[1].body.sysinfo_type := RSL_SYSTEM_INFO_5;
3764 RSL_CCHAN.send(ts_RSL_UD(rsl));
3765
3766 f_exp_err_rep(RSL_ERR_IE_CONTENT);
3767}
3768
Harald Welteee25aae2019-05-19 14:32:37 +02003769/* attempt to activate channel with wrong RSL Message Discriminator IE */
3770function f_TC_chan_act_wrong_mdisc(charstring id) runs on ConnHdlr {
3771 var template RSL_Message rsl := ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode);
3772 rsl.msg_disc := ts_RSL_MsgDisc(RSL_MDISC_RESERVED, false);
3773 RSL.send(rsl);
3774 f_rslem_unregister(0, g_chan_nr);
3775}
3776testcase TC_err_rep_wrong_mdisc() runs on test_CT {
3777 var ConnHdlr vc_conn;
3778 var ConnHdlrPars pars := valueof(t_Pars(ts_RslChanNr_SDCCH4(0,0), ts_RSL_ChanMode_SIGN));
3779
Harald Welte10474062019-05-30 16:48:17 +02003780 f_init();
Harald Welteee25aae2019-05-19 14:32:37 +02003781
3782 vc_conn := f_start_handler(refers(f_TC_chan_act_wrong_mdisc), pars);
3783 vc_conn.done;
3784 f_exp_err_rep(RSL_ERR_MSG_DISCR);
3785
3786 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
3787}
3788
3789/* Send messages with wrong message type */
3790function f_TC_wrong_msg_type_dchan(charstring id) runs on ConnHdlr {
3791 var template (value) RSL_Message rsl_tx;
3792 rsl_tx := ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode);
3793 rsl_tx.msg_type := RSL_MT_NOT_CMD;
3794 RSL.send(rsl_tx);
3795 f_rslem_unregister(0, g_chan_nr);
3796}
3797function f_TC_wrong_msg_type_rll(charstring id) runs on ConnHdlr {
3798 var template (value) RSL_Message rsl_tx;
3799 /* we first have to activate the dedicated channel */
3800 f_rsl_chan_act(g_pars.chan_mode);
3801 /* ... to then send an invalid RLL message */
3802 rsl_tx := ts_RSL_UNITDATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0), '0102'O);
3803 rsl_tx.msg_type := RSL_MT_CBCH_LOAD_IND;
3804 RSL.send(rsl_tx);
3805 f_rslem_unregister(0, g_chan_nr);
3806}
3807testcase TC_err_rep_wrong_msg_type() runs on test_CT {
3808 var ConnHdlr vc_conn;
3809 var ConnHdlrPars pars := valueof(t_Pars(ts_RslChanNr_SDCCH4(0,0), ts_RSL_ChanMode_SIGN));
3810 var template (value) RSL_Message rsl_tx;
3811
Harald Welte10474062019-05-30 16:48:17 +02003812 f_init();
Harald Welteee25aae2019-05-19 14:32:37 +02003813
3814 /* Common Channel with wrong message type */
3815 RSL_CCHAN.clear;
3816 rsl_tx := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O));
3817 rsl_tx.msg_type := RSL_MT_LOCATION_INFO;
3818 RSL_CCHAN.send(ts_RSL_UD(rsl_tx));
3819 f_exp_err_rep(RSL_ERR_MSG_TYPE);
3820
3821 /* TRX Management */
3822 RSL_CCHAN.clear;
3823 rsl_tx := ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, ''O);
3824 rsl_tx.msg_type := RSL_MT_UNIT_DATA_IND;
3825 RSL_CCHAN.send(ts_RSL_UD(rsl_tx));
3826 f_exp_err_rep(RSL_ERR_MSG_TYPE);
3827
3828 /* Dedicated Channel */
3829 RSL_CCHAN.clear;
3830 vc_conn := f_start_handler(refers(f_TC_wrong_msg_type_dchan), pars);
3831 vc_conn.done;
3832 f_exp_err_rep(RSL_ERR_MSG_TYPE);
3833
3834 /* RLL */
3835 RSL_CCHAN.clear;
3836 vc_conn := f_start_handler(refers(f_TC_wrong_msg_type_rll), pars);
3837 vc_conn.done;
3838 f_exp_err_rep(RSL_ERR_MSG_TYPE);
3839}
3840
3841/* Send messages in wrong sequence (RLL to an inactive lchan) */
3842function f_TC_err_rep_wrong_sequence(charstring id) runs on ConnHdlr {
3843 RSL.send(ts_RSL_UNITDATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0), '0102'O));
3844 f_rslem_unregister(0, g_chan_nr);
3845}
3846testcase TC_err_rep_wrong_sequence() runs on test_CT {
3847 var ConnHdlr vc_conn;
3848 var ConnHdlrPars pars := valueof(t_Pars(ts_RslChanNr_SDCCH4(0,0), ts_RSL_ChanMode_SIGN));
3849
Harald Welte10474062019-05-30 16:48:17 +02003850 f_init();
Harald Welteee25aae2019-05-19 14:32:37 +02003851
3852 RSL_CCHAN.clear;
3853 vc_conn := f_start_handler(refers(f_TC_err_rep_wrong_sequence), pars);
3854 vc_conn.done;
3855 f_exp_err_rep(RSL_ERR_MSG_SEQ);
3856}
3857
Harald Welte93640c62018-02-25 16:59:33 +01003858/***********************************************************************
3859 * IPA CRCX/MDCX/DLCS media stream handling
3860 ***********************************************************************/
3861
Harald Weltea871a382018-02-25 02:03:14 +01003862/* Send IPA DLCX to inactive lchan */
3863function f_TC_ipa_dlcx_not_active(charstring id) runs on ConnHdlr {
Harald Welte1eba3742018-02-25 12:48:14 +01003864 f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, 0), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?),
3865 "IPA DLCX ACK");
Harald Weltea871a382018-02-25 02:03:14 +01003866}
3867testcase TC_ipa_dlcx_not_active() runs on test_CT {
3868 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
Harald Welte10474062019-05-30 16:48:17 +02003869 f_init();
Harald Weltea871a382018-02-25 02:03:14 +01003870 var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_dlcx_not_active), pars);
3871 vc_conn.done;
3872}
Harald Welte68e495b2018-02-25 00:05:57 +01003873
Harald Weltea3f1df92018-02-25 12:49:55 +01003874/* Send IPA CRCX twice to inactive lchan */
3875function f_TC_ipa_crcx_twice_not_active(charstring id) runs on ConnHdlr {
3876 f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?),
3877 "IPA CRCX ACK");
3878 f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_NACK(g_chan_nr, RSL_ERR_RES_UNAVAIL),
3879 "IPA CRCX NACK");
3880}
3881testcase TC_ipa_crcx_twice_not_active() runs on test_CT {
3882 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
Harald Welte10474062019-05-30 16:48:17 +02003883 f_init();
Harald Weltea3f1df92018-02-25 12:49:55 +01003884 var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_twice_not_active), pars);
3885 vc_conn.done;
3886}
3887
3888/* Regular sequence of CRCX/MDCX/DLCX */
3889function f_TC_ipa_crcx_mdcx_dlcx_not_active(charstring id) runs on ConnHdlr {
3890 f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?),
3891 "IPA CRCX ACK");
3892 var uint32_t remote_ip := f_rnd_int(c_UINT32_MAX);
3893 var uint16_t remote_port := f_rnd_int(c_UINT16_MAX);
3894 var uint7_t rtp_pt2 := f_rnd_int(127);
3895 var uint16_t fake_conn_id := 23; /* we're too lazy to read it out from the CRCX ACK above */
3896 f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2),
3897 tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2),
3898 "IPA MDCX ACK");
3899 f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, fake_conn_id), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?),
3900 "IPA DLCX ACK");
3901}
3902testcase TC_ipa_crcx_mdcx_dlcx_not_active() runs on test_CT {
3903 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
Harald Welte10474062019-05-30 16:48:17 +02003904 f_init();
Harald Weltea3f1df92018-02-25 12:49:55 +01003905 var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_mdcx_dlcx_not_active), pars);
3906 vc_conn.done;
3907}
3908
Harald Welte3ae11da2018-02-25 13:36:06 +01003909/* Sequence of CRCX, 2x MDCX, DLCX */
3910function f_TC_ipa_crcx_mdcx_mdcx_dlcx_not_active(charstring id) runs on ConnHdlr {
3911 f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?),
3912 "IPA CRCX ACK");
3913 var uint32_t remote_ip := f_rnd_int(c_UINT32_MAX);
3914 var uint16_t remote_port := f_rnd_int(c_UINT16_MAX);
3915 var uint7_t rtp_pt2 := f_rnd_int(127);
3916 var uint16_t fake_conn_id := 23; /* we're too lazy to read it out from the CRCX ACK above */
3917 f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2),
3918 tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2),
3919 "IPA MDCX ACK");
3920 /* Second MDCX */
3921 remote_ip := f_rnd_int(c_UINT32_MAX);
3922 remote_port := f_rnd_int(c_UINT16_MAX);
3923 f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2),
3924 tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2),
3925 "IPA MDCX ACK");
3926 f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, fake_conn_id), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?),
3927 "IPA DLCX ACK");
3928}
3929testcase TC_ipa_crcx_mdcx_mdcx_dlcx_not_active() runs on test_CT {
3930 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
Harald Welte10474062019-05-30 16:48:17 +02003931 f_init();
Harald Welte3ae11da2018-02-25 13:36:06 +01003932 var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_mdcx_mdcx_dlcx_not_active), pars);
3933 vc_conn.done;
3934}
3935
Harald Welte9912eb52018-02-25 13:30:15 +01003936/* IPA CRCX on SDCCH/4 and SDCCH/8 (doesn't make sense) */
3937function f_TC_ipa_crcx_sdcch_not_active(charstring id) runs on ConnHdlr {
3938 f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_NACK(g_chan_nr, ?),
3939 "IPA CRCX NACK");
3940}
3941testcase TC_ipa_crcx_sdcch_not_active() runs on test_CT {
3942 var ConnHdlrPars pars;
3943 var ConnHdlr vc_conn;
Harald Welte10474062019-05-30 16:48:17 +02003944 f_init();
Harald Welte9912eb52018-02-25 13:30:15 +01003945
3946 pars := valueof(t_Pars(t_RslChanNr_SDCCH4(0,1), ts_RSL_ChanMode_SIGN));
3947 vc_conn := f_start_handler(refers(f_TC_ipa_crcx_sdcch_not_active), pars);
3948 vc_conn.done;
3949
3950 pars := valueof(t_Pars(t_RslChanNr_SDCCH8(6,5), ts_RSL_ChanMode_SIGN));
3951 vc_conn := f_start_handler(refers(f_TC_ipa_crcx_sdcch_not_active), pars);
3952 vc_conn.done;
3953}
3954
Harald Weltea3f1df92018-02-25 12:49:55 +01003955
Harald Welte883340c2018-02-28 18:59:29 +01003956/***********************************************************************
3957 * PCU Socket related tests
3958 ***********************************************************************/
3959
Harald Welte07bd2d22019-05-25 11:03:30 +02003960/* Verify no RTS before ACT_REQ; verify RTS after ACT_REQ */
Harald Weltead033dc2019-05-25 17:28:16 +02003961friend function f_TC_pcu_act_req(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr, boolean exp_success)
Harald Welte883340c2018-02-28 18:59:29 +01003962runs on test_CT {
3963 timer T := 3.0;
3964
3965 /* we don't expect any RTS.req before PDCH are active */
3966 T.start;
3967 alt {
3968 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(bts_nr))) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003969 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "PCU RTS.req before PDCH active?");
Harald Welte883340c2018-02-28 18:59:29 +01003970 }
3971 [] PCU.receive { repeat; }
3972 [] T.timeout { }
3973 }
3974
3975 /* Send PDCH activate request for known PDCH timeslot */
3976 PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, ts_nr)));
3977
3978 /* we now expect RTS.req for this timeslot (only) */
3979 T.start;
3980 alt {
3981 [exp_success] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr))) {
3982 setverdict(pass);
3983 }
3984 [not exp_success] PCU.receive(t_SD_PCUIF(g_pcu_conn_id,
3985 tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr))) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003986 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RTS.req for supposedly failing activation");
Harald Welte883340c2018-02-28 18:59:29 +01003987 }
3988 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003989 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "RTS.req for wrong TRX/TS");
Harald Welte883340c2018-02-28 18:59:29 +01003990 }
3991 [] PCU.receive { repeat; }
3992 [exp_success] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003993 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PCU RTS.req");
Harald Welte883340c2018-02-28 18:59:29 +01003994 }
3995 [not exp_success] T.timeout {
3996 setverdict(pass);
3997 }
3998 }
3999}
4000
Harald Welte07bd2d22019-05-25 11:03:30 +02004001/* verify no more RTS after DEACT_REQ */
Harald Weltead033dc2019-05-25 17:28:16 +02004002friend function f_TC_pcu_deact_req(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr)
Harald Welte883340c2018-02-28 18:59:29 +01004003runs on test_CT {
4004 timer T := 3.0;
4005
4006 /* Send PDCH activate request for known PDCH timeslot */
4007 PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_DEACT_REQ(bts_nr, trx_nr, ts_nr)));
4008
4009 PCU.clear;
4010 /* we now expect no RTS.req for this timeslot */
4011 T.start;
4012 alt {
4013 [] 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 +02004014 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received unexpected PCU RTS.req");
Harald Welte883340c2018-02-28 18:59:29 +01004015 }
4016 [] PCU.receive { repeat; }
4017 [] T.timeout {
4018 setverdict(pass);
4019 }
4020 }
4021}
4022
Harald Weltead033dc2019-05-25 17:28:16 +02004023friend function f_init_pcu_test() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01004024 f_init();
4025 PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_TXT_IND(0, PCU_VERSION, testcasename())));
4026}
4027
Harald Welte883340c2018-02-28 18:59:29 +01004028/* PDCH activation via PCU socket; check for presence of RTS.req */
4029testcase TC_pcu_act_req() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01004030 f_init_pcu_test();
4031
Harald Welte883340c2018-02-28 18:59:29 +01004032 f_TC_pcu_act_req(0, 0, 7, true);
4033}
4034
4035/* PDCH activation via PCU socket on non-PDCU timeslot */
4036testcase TC_pcu_act_req_wrong_ts() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01004037 f_init_pcu_test();
4038
Harald Welte883340c2018-02-28 18:59:29 +01004039 f_TC_pcu_act_req(0, 0, 1, false);
4040}
4041
4042/* PDCH activation via PCU socket on wrong BTS */
4043testcase TC_pcu_act_req_wrong_bts() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01004044 f_init_pcu_test();
4045
Harald Welte883340c2018-02-28 18:59:29 +01004046 f_TC_pcu_act_req(23, 0, 7, false);
4047}
4048
4049/* PDCH activation via PCU socket on wrong TRX */
4050testcase TC_pcu_act_req_wrong_trx() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01004051 f_init_pcu_test();
4052
Harald Welte883340c2018-02-28 18:59:29 +01004053 f_TC_pcu_act_req(0, 23, 7, false);
4054}
4055
4056/* PDCH deactivation via PCU socket; check for absence of RTS.req */
4057testcase TC_pcu_deact_req() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01004058 f_init_pcu_test();
4059
Harald Welte883340c2018-02-28 18:59:29 +01004060 /* Activate PDCH */
4061 f_TC_pcu_act_req(0, 0, 7, true);
4062 f_sleep(1.0);
4063 /* and De-Activate again */
4064 f_TC_pcu_deact_req(0, 0, 7);
4065}
4066
4067/* Attempt to deactivate a PDCH on a non-PDCH timeslot */
4068testcase TC_pcu_deact_req_wrong_ts() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01004069 f_init_pcu_test();
4070
Harald Welte883340c2018-02-28 18:59:29 +01004071 f_TC_pcu_deact_req(0, 0, 1);
4072}
4073
4074/* Test the PCU->BTS Version and BTS->PCU SI13 handshake */
4075testcase TC_pcu_ver_si13() runs on test_CT {
4076 const octetstring si13 := '00010203040506070909'O;
4077 var PCUIF_send_data sd;
4078 timer T:= 3.0;
Max2c6f5632019-03-18 17:25:17 +01004079 f_init_pcu_test();
Harald Welte883340c2018-02-28 18:59:29 +01004080
4081 /* Set SI13 via RSL */
4082 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_13, si13);
Max2c6f5632019-03-18 17:25:17 +01004083
Harald Welte883340c2018-02-28 18:59:29 +01004084 T.start;
4085 alt {
4086 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_DATA_IND(0, 0, 0, ?, PCU_IF_SAPI_BCCH))) -> value sd {
4087 if (substr(sd.data.u.data_ind.data, 0, lengthof(si13)) == si13) {
4088 setverdict(pass);
4089 } else {
4090 repeat;
4091 }
4092 }
4093 [] PCU.receive { repeat; }
4094 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004095 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for SI13");
Harald Welte883340c2018-02-28 18:59:29 +01004096 }
4097 }
4098}
4099
4100private const octetstring c_PCU_DATA := '000102030405060708090a0b0c0d0e0f10111213141516'O;
4101
4102/* helper function to send a PCU DATA.req */
Harald Weltead033dc2019-05-25 17:28:16 +02004103friend function f_pcu_data_req(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr,
Harald Welte883340c2018-02-28 18:59:29 +01004104 uint8_t block_nr, uint32_t fn, PCUIF_Sapi sapi, octetstring data)
4105runs on test_CT
4106{
4107 PCU.send(t_SD_PCUIF(g_pcu_conn_id,
4108 ts_PCUIF_DATA_REQ(bts_nr, trx_nr, ts_nr, block_nr, fn, sapi, data)));
4109}
4110
4111/* helper function to wait for RTS.ind for given SAPI on given BTS/TRX/TS and then send */
Harald Weltead033dc2019-05-25 17:28:16 +02004112friend function f_pcu_wait_rts_and_data_req(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr,
4113 PCUIF_Sapi sapi, octetstring data)
Harald Welte883340c2018-02-28 18:59:29 +01004114runs on test_CT
4115{
4116 var PCUIF_send_data sd;
4117
4118 timer T := 3.0;
4119 T.start;
4120 alt {
4121 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id,
4122 tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr, sapi))) -> value sd {
4123 f_pcu_data_req(bts_nr, trx_nr, ts_nr, sd.data.u.rts_req.block_nr,
4124 sd.data.u.rts_req.fn, sapi, data);
4125 }
4126 [] PCU.receive { repeat; }
4127 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004128 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RTS.ind");
Harald Welte883340c2018-02-28 18:59:29 +01004129 }
4130 }
4131}
4132
4133/* Send DATA.req on invalid BTS */
4134testcase TC_pcu_data_req_wrong_bts() runs on test_CT {
Harald Welte7162a612019-05-26 12:56:09 +02004135 var TfiUsfArr tua := f_TfiUsfArrInit();
4136 var octetstring data := '0000'O & f_rnd_octstring(21);
4137
4138 f_virtphy_common();
Max2c6f5632019-03-18 17:25:17 +01004139
Harald Welte883340c2018-02-28 18:59:29 +01004140 f_TC_pcu_act_req(0, 0, 7, true);
Harald Welte7162a612019-05-26 12:56:09 +02004141 f_TfiUsfArrSet(tua, 7, 0);
4142 f_L1CTL_TBF_CFG(L1CTL, false, tua);
4143 f_sleep(1.0);
4144
4145 f_pcu_to_l1(23, 0, 7, PCU_IF_SAPI_PDTCH, data, false, false);
Harald Welte883340c2018-02-28 18:59:29 +01004146}
4147
4148/* Send DATA.req on invalid TRX */
4149testcase TC_pcu_data_req_wrong_trx() runs on test_CT {
Harald Welte7162a612019-05-26 12:56:09 +02004150 var TfiUsfArr tua := f_TfiUsfArrInit();
4151 var octetstring data := '0000'O & f_rnd_octstring(21);
4152
4153 f_virtphy_common();
Max2c6f5632019-03-18 17:25:17 +01004154
Harald Welte883340c2018-02-28 18:59:29 +01004155 f_TC_pcu_act_req(0, 0, 7, true);
Harald Welte7162a612019-05-26 12:56:09 +02004156 f_TfiUsfArrSet(tua, 7, 0);
4157 f_L1CTL_TBF_CFG(L1CTL, false, tua);
4158 f_sleep(1.0);
4159
4160 f_pcu_to_l1(0, 100, 7, PCU_IF_SAPI_PDTCH, data, false, false);
Harald Welte883340c2018-02-28 18:59:29 +01004161}
4162
4163/* Send DATA.req on invalid timeslot */
4164testcase TC_pcu_data_req_wrong_ts() runs on test_CT {
Harald Welte7162a612019-05-26 12:56:09 +02004165 var TfiUsfArr tua := f_TfiUsfArrInit();
4166 var octetstring data := '0000'O & f_rnd_octstring(21);
4167
4168 f_virtphy_common();
Max2c6f5632019-03-18 17:25:17 +01004169
Harald Welte883340c2018-02-28 18:59:29 +01004170 f_TC_pcu_act_req(0, 0, 7, true);
Harald Welte7162a612019-05-26 12:56:09 +02004171 f_TfiUsfArrSet(tua, 7, 0);
4172 f_L1CTL_TBF_CFG(L1CTL, false, tua);
4173 f_sleep(1.0);
4174
4175 f_pcu_to_l1(0, 0, 70, PCU_IF_SAPI_PDTCH, data, false, false);
Harald Welte883340c2018-02-28 18:59:29 +01004176}
4177
4178/* Send DATA.req on timeslot that hasn't been activated */
4179testcase TC_pcu_data_req_ts_inactive() runs on test_CT {
Harald Welte7162a612019-05-26 12:56:09 +02004180 var TfiUsfArr tua := f_TfiUsfArrInit();
4181 var octetstring data := '0000'O & f_rnd_octstring(21);
Max2c6f5632019-03-18 17:25:17 +01004182
Harald Welte7162a612019-05-26 12:56:09 +02004183 f_virtphy_common();
4184
4185 f_TfiUsfArrSet(tua, 7, 0);
4186 f_L1CTL_TBF_CFG(L1CTL, false, tua);
4187 f_sleep(1.0);
4188
4189 f_pcu_to_l1(0, 0, 7, PCU_IF_SAPI_PDTCH, data, false, false);
Harald Welte883340c2018-02-28 18:59:29 +01004190}
4191
Harald Weltead033dc2019-05-25 17:28:16 +02004192private function f_pcu_to_l1(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr,
Harald Welte7162a612019-05-26 12:56:09 +02004193 PCUIF_Sapi sapi, octetstring data, boolean expect_data := true,
4194 boolean wait_rts := true)
4195runs on test_CT {
Harald Weltead033dc2019-05-25 17:28:16 +02004196 timer T := 5.0;
Harald Welte7162a612019-05-26 12:56:09 +02004197 var L1ctlDlMessage rx_dl;
Harald Weltead033dc2019-05-25 17:28:16 +02004198
4199 PCU.clear;
Harald Welte7162a612019-05-26 12:56:09 +02004200 if (wait_rts) {
4201 f_pcu_wait_rts_and_data_req(bts_nr, trx_nr, ts_nr, sapi, data);
4202 } else {
4203 f_pcu_data_req(bts_nr, trx_nr, ts_nr, 0, 0, sapi, data);
4204 }
Harald Weltead033dc2019-05-25 17:28:16 +02004205
4206 T.start;
4207 alt {
Harald Welte7162a612019-05-26 12:56:09 +02004208 [expect_data] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PDCH(ts_nr), ?, data)) {
Harald Weltead033dc2019-05-25 17:28:16 +02004209 /* FIXME: why is fn of DATA_IND different to fn of RTS / DATA_REQ above? */
4210 setverdict(pass);
4211 }
Harald Welte7162a612019-05-26 12:56:09 +02004212 [not expect_data] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PDCH(ts_nr), ?, data)) -> value rx_dl {
4213 setverdict(fail, "Received unexpected ", rx_dl);
4214 }
Harald Weltead033dc2019-05-25 17:28:16 +02004215 [] L1CTL.receive {
4216 repeat;
4217 }
Harald Welte7162a612019-05-26 12:56:09 +02004218 [expect_data] T.timeout {
Harald Weltead033dc2019-05-25 17:28:16 +02004219 setverdict(fail, "Timeout waiting for ", data);
4220 }
Harald Welte7162a612019-05-26 12:56:09 +02004221 [not expect_data] T.timeout {
4222 setverdict(pass);
4223 }
Harald Weltead033dc2019-05-25 17:28:16 +02004224 }
4225}
4226
4227private function f_disable_dynamic_ts() runs on test_CT
4228{
4229 f_init_vty_bsc();
4230 /* I'm not quite sure why we need this with osmo-bts-virtual. Somehow it deosn't seem to
4231 * support dynamic timeslots? But it uses the same scheduler as osmo-bts-trx ?!? */
4232 f_vty_config2(BSCVTY, {"network", "bts 0", "trx 0", "timeslot 3"}, "phys_chan_config TCH/F");
4233 f_vty_config2(BSCVTY, {"network", "bts 0", "trx 0", "timeslot 4"}, "phys_chan_config TCH/F");
Max2c6f5632019-03-18 17:25:17 +01004234 f_init_pcu_test();
Harald Weltead033dc2019-05-25 17:28:16 +02004235}
4236
4237private function f_virtphy_common() runs on test_CT {
4238 f_disable_dynamic_ts();
4239 f_init_l1ctl();
4240 f_l1_tune(L1CTL);
4241}
4242
4243testcase TC_pcu_data_req_pdtch() runs on test_CT {
4244 var TfiUsfArr tua := f_TfiUsfArrInit();
4245 var octetstring data := '0000'O & f_rnd_octstring(21);
4246
4247 f_virtphy_common();
Max2c6f5632019-03-18 17:25:17 +01004248
Harald Welte883340c2018-02-28 18:59:29 +01004249 f_TC_pcu_act_req(0, 0, 7, true);
Harald Weltead033dc2019-05-25 17:28:16 +02004250 f_TfiUsfArrSet(tua, 7, 0);
4251 f_L1CTL_TBF_CFG(L1CTL, false, tua);
4252 f_sleep(1.0);
4253
4254 f_pcu_to_l1(0, 0, 7, PCU_IF_SAPI_PDTCH, data); //c_PCU_DATA);
Harald Welte883340c2018-02-28 18:59:29 +01004255}
4256
Vadim Yanitskiy8c242f02019-10-13 15:25:54 +07004257/* FIXME: PTTCH has nothing to do with TBFs */
Harald Welte883340c2018-02-28 18:59:29 +01004258testcase TC_pcu_data_req_ptcch() runs on test_CT {
Harald Weltead033dc2019-05-25 17:28:16 +02004259 var TfiUsfArr tua := f_TfiUsfArrInit();
4260 var octetstring data := '0000'O & f_rnd_octstring(21);
4261
4262 f_virtphy_common();
Max2c6f5632019-03-18 17:25:17 +01004263
Harald Welte883340c2018-02-28 18:59:29 +01004264 f_TC_pcu_act_req(0, 0, 7, true);
Harald Weltead033dc2019-05-25 17:28:16 +02004265 f_TfiUsfArrSet(tua, 7, 0);
4266 f_L1CTL_TBF_CFG(L1CTL, false, tua);
4267 f_sleep(1.0);
4268
4269 f_pcu_to_l1(0, 0, 7, PCU_IF_SAPI_PTCCH, data);
Harald Welte883340c2018-02-28 18:59:29 +01004270}
4271
Vadim Yanitskiy8c242f02019-10-13 15:25:54 +07004272private function f_TC_pcu_ptcch_ul(uint16_t ra)
4273runs on test_CT {
4274 var template PCUIF_Message pcu_rach_ind;
4275 var PCUIF_send_data sd;
4276 var GsmFrameNumber fn;
4277 timer T;
4278
4279 /* Send an Access Burst on PTCCH/U over the Um-interface */
4280 fn := f_L1CTL_RACH(L1CTL, ra := ra, combined := 0, offset := 0,
4281 chan_nr := ts_RslChanNr_PDCH(7),
4282 link_id := ts_RslLinkID_OSMO_PTCCH(0));
4283
Vadim Yanitskiy36558d92019-11-17 02:23:51 +07004284 pcu_rach_ind := tr_PCUIF_RACH_IND(bts_nr := 0, trx_nr := 0, ts_nr := 7,
4285 ra := ra, fn := fn, sapi := PCU_IF_SAPI_PTCCH);
Vadim Yanitskiy8c242f02019-10-13 15:25:54 +07004286
4287 /* Expect a RACH.ind on the PCU interface (timeout is one multi-frame) */
4288 T.start(52.0 * 4.615 / 1000.0);
4289 alt {
4290 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, pcu_rach_ind)) -> value sd {
4291 log("Rx an Access Burst on the PCU interface: ", sd.data);
4292 setverdict(pass);
4293 T.stop;
4294 }
4295 [] PCU.receive { repeat; }
4296 [] T.timeout {
4297 setverdict(fail, "Timeout waiting for RACH.ind on the PCU interface");
4298 /* Keep going, that's not the end of the world */
4299 }
4300 }
4301}
4302
4303testcase TC_pcu_ptcch() runs on test_CT {
4304 var L1ctlDlMessage dl;
4305 var octetstring data;
4306 timer T;
4307
4308 f_init_pcu_test();
4309 f_init_l1ctl();
4310 f_l1_tune(L1CTL);
4311
4312 /* Activate PDCH channel on TS7 */
4313 f_TC_pcu_act_req(0, 0, 7, true);
4314
4315 /* Tune trxcon to that PDCH channel */
4316 L1CTL.send(ts_L1CTL_DM_EST_REQ(arfcn := { false, mp_trx0_arfcn },
4317 chan_nr := valueof(ts_RslChanNr_PDCH(7)),
4318 tsc := 7));
4319
4320 /* Verify PTCCH/U: send several access bursts, make sure they're received */
4321 for (var integer i := 0; i < 16; i := i + 1) {
4322 log("Sending an Access Burst towards the L1CTL interface");
4323 f_TC_pcu_ptcch_ul(oct2int(f_rnd_ra_ps()));
4324 }
4325
4326 /* Generate a random payload for PTCCH/D (23 octets, CS-1) */
4327 data := f_rnd_octstring(23);
4328
4329 /* Verify PTCCH/D: send a random data block, make sure it's received */
4330 log("Sending a PTCCH/D block towards the PCU interface: ", data);
4331 f_pcu_wait_rts_and_data_req(0, 0, 7, PCU_IF_SAPI_PTCCH, data);
4332
4333 /* PTCCH/D period is 2 multi-frames (2 * 52 * 4.615 ms), but
4334 * let's give it more time in case if we miss the beginning. */
4335 T.start(2.0 * 2.0 * 52.0 * 4.615 / 1000.0);
4336 alt {
4337 /* PDCH is considered as traffic in trxcon => expect TRAFFIC.ind */
4338 [] L1CTL.receive(tr_L1CTL_TRAFFIC_IND(chan_nr := t_RslChanNr_PDCH(7),
4339 link_id := tr_RslLinkID_OSMO_PTCCH(?),
4340 frame := data)) -> value dl {
4341 log("Rx PTCCH/D data (traffic) block on L1CTL: ", dl);
4342 setverdict(pass);
4343 T.stop;
4344 }
4345 /* Other PHYs (e.g. virt_phy) may consider PDCH as data => expect DATA.ind */
4346 [] L1CTL.receive(tr_L1CTL_DATA_IND(chan_nr := t_RslChanNr_PDCH(7),
4347 link_id := tr_RslLinkID_OSMO_PTCCH(?),
4348 l2_data := data)) -> value dl {
4349 log("Rx PTCCH/D data block on L1CTL: ", dl);
4350 setverdict(pass);
4351 T.stop;
4352 }
4353 [] L1CTL.receive { repeat; }
4354 [] T.timeout {
4355 setverdict(fail, "Timeout waiting for DATA.ind on L1CTL");
4356 }
4357 }
4358}
4359
Harald Welte883340c2018-02-28 18:59:29 +01004360/* Send AGCH from PCU; check it appears on Um side */
4361testcase TC_pcu_data_req_agch() runs on test_CT {
4362 timer T := 3.0;
Max2c6f5632019-03-18 17:25:17 +01004363 f_init_pcu_test();
Harald Welte883340c2018-02-28 18:59:29 +01004364 f_init_l1ctl();
4365 f_l1_tune(L1CTL);
4366
4367 f_TC_pcu_act_req(0, 0, 7, true);
4368 f_pcu_data_req(0, 0, 7, 0, 0, PCU_IF_SAPI_AGCH, c_PCU_DATA);
4369
4370 T.start;
4371 alt {
Harald Weltef8df4cb2018-03-10 15:15:08 +01004372 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?, c_PCU_DATA)) {
Harald Welte883340c2018-02-28 18:59:29 +01004373 setverdict(pass);
4374 }
4375 [] L1CTL.receive { repeat; }
4376 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004377 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PCU-originated AGCH block on Um");
Harald Welte883340c2018-02-28 18:59:29 +01004378 }
4379 }
4380}
4381
Harald Welte928622b2019-05-26 13:22:59 +02004382/* Send AGCH from PCU; check it appears on Um side */
4383testcase TC_pcu_data_req_pch() runs on test_CT {
4384 timer T := 3.0;
4385 f_init_pcu_test();
4386 f_init_l1ctl();
4387 f_l1_tune(L1CTL);
4388
4389 f_TC_pcu_act_req(0, 0, 7, true);
4390 /* three characters prefix: last 3 digits of IMSI as ASCII */
4391 f_pcu_data_req(0, 0, 7, 0, 0, PCU_IF_SAPI_PCH, '313233'O & c_PCU_DATA);
4392
4393 T.start;
4394 alt {
4395 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?, c_PCU_DATA)) {
4396 setverdict(pass);
4397 }
4398 [] L1CTL.receive { repeat; }
4399 [] T.timeout {
4400 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PCU-originated PCH block on Um");
4401 }
4402 }
4403}
4404
Harald Welte883340c2018-02-28 18:59:29 +01004405/* Send IMM.ASS from PCU for PCH; check it appears on Um side */
4406testcase TC_pcu_data_req_imm_ass_pch() runs on test_CT {
4407 var octetstring imm_ass := f_rnd_octstring(23);
Max2c6f5632019-03-18 17:25:17 +01004408 f_init_pcu_test();
Harald Welte883340c2018-02-28 18:59:29 +01004409 f_init_l1ctl();
4410 f_l1_tune(L1CTL);
4411
4412 /* append 3 last imsi digits so BTS can compute pagng group */
4413 var uint32_t fn := f_PCUIF_tx_imm_ass_pch(PCU, g_pcu_conn_id, imm_ass, '123459987'H);
4414
4415 timer T := 0.5;
4416 T.start;
4417 alt {
Harald Weltef8df4cb2018-03-10 15:15:08 +01004418 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?, imm_ass)) {
Harald Welte883340c2018-02-28 18:59:29 +01004419 /* TODO: verify paging group */
4420 setverdict(pass);
4421 }
4422 [] L1CTL.receive { repeat; }
4423 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004424 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PCU-originated AGCH block on Um");
Harald Welte883340c2018-02-28 18:59:29 +01004425 }
4426 }
4427}
4428
4429/* Send RACH from Um side, expect it to show up on PCU socket */
4430testcase TC_pcu_rach_content() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01004431 f_init_pcu_test();
Harald Welte883340c2018-02-28 18:59:29 +01004432 f_init_l1ctl();
4433 f_l1_tune(L1CTL);
4434
4435 var GsmFrameNumber fn_last := 0;
4436 for (var integer i := 0; i < 1000; i := i+1) {
4437 var OCT1 ra := f_rnd_ra_ps();
4438 var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra));
4439 if (fn == fn_last) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004440 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?");
Harald Welte883340c2018-02-28 18:59:29 +01004441 }
4442 fn_last := fn;
4443
4444 timer T := 2.0;
4445 T.start;
4446 alt {
Vadim Yanitskiy36558d92019-11-17 02:23:51 +07004447 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RACH_IND(0, 0, 0, oct2int(ra), 0, ?, fn))) {
Harald Welte883340c2018-02-28 18:59:29 +01004448 T.stop;
4449 }
4450 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RACH_IND)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004451 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RACH IND");
Harald Welte883340c2018-02-28 18:59:29 +01004452 }
4453 [] PCU.receive { repeat; }
4454 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004455 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RACH IND");
Harald Welte883340c2018-02-28 18:59:29 +01004456 }
4457 }
4458 }
4459 setverdict(pass);
4460}
4461
Vadim Yanitskiy51cbc102019-04-22 06:37:30 +07004462/* Send extended (11-bit, TS1 & TS2) RACH bursts from the Um side,
4463 * expect them to show up on PCU socket (with proper BURST_TYPE_*). */
4464testcase TC_pcu_ext_rach_content() runs on test_CT {
4465 var template PCUIF_Message pcu_rach_ind;
4466 var GsmFrameNumber fn_last := 0;
4467 var L1ctlRachSynchSeq synch_seq;
4468 var PCUIF_BurstType pcu_bt;
4469 var GsmFrameNumber fn;
4470 var BIT11 ra11;
4471
4472 f_init_pcu_test();
4473 f_init_l1ctl();
4474 f_l1_tune(L1CTL);
4475
4476 for (var integer i := 0; i < 1000; i := i+1) {
4477 /* We need to test both TS1 & TS2 */
4478 if (i rem 2 == 0) {
4479 synch_seq := RACH_SYNCH_SEQ_TS1;
4480 pcu_bt := BURST_TYPE_1;
4481 } else {
4482 synch_seq := RACH_SYNCH_SEQ_TS2;
4483 pcu_bt := BURST_TYPE_2;
4484 }
4485
4486 ra11 := f_rnd_ra11_ps();
4487 fn := f_L1CTL_EXT_RACH(L1CTL, bit2int(ra11), synch_seq);
4488 if (fn == fn_last) {
4489 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
4490 "Two RACH in same FN?!?");
4491 }
4492 fn_last := fn;
4493
4494 /* Compose the expected message */
4495 pcu_rach_ind := tr_PCUIF_RACH_IND(
Vadim Yanitskiy36558d92019-11-17 02:23:51 +07004496 bts_nr := 0, trx_nr := 0, ts_nr := 0,
Vadim Yanitskiy51cbc102019-04-22 06:37:30 +07004497 ra := bit2int(ra11),
4498 is_11bit := 1,
4499 burst_type := pcu_bt,
4500 fn := fn);
4501
4502 timer T := 2.0;
4503 T.start;
4504 alt {
4505 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, pcu_rach_ind)) {
4506 T.stop;
4507 }
4508 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RACH_IND)) {
4509 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RACH IND");
4510 }
4511 [] PCU.receive { repeat; }
4512 [] T.timeout {
4513 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RACH IND");
4514 }
4515 }
4516 }
4517 setverdict(pass);
4518}
4519
Vadim Yanitskiya2c68e82019-07-03 13:07:20 +07004520private function f_TC_pcu_data_ind_lqual_cb(int16_t lqual_cb_exp, int16_t thresh)
4521runs on test_CT {
4522 var template PCUIF_send_data sdt;
4523 var PCUIF_send_data sd;
4524 var int16_t lqual_cb;
4525 timer T := 1.0;
4526
4527 /* PCUIF_DATA.ind is encapsulated into a supplementary record */
4528 sdt := t_SD_PCUIF_MSGT(g_pcu_conn_id, PCU_IF_MSG_DATA_IND);
4529
4530 /* Send a random PDTCH frame over Um */
4531 L1CTL.send(ts_L1CTL_TRAFFIC_REQ(ts_RslChanNr_PDCH(7), ts_RslLinkID_DCCH(0),
4532 '0000'O & f_rnd_octstring(21)));
4533
4534 T.start;
4535 alt {
4536 /* If expected link quality is above the threshold */
4537 [lqual_cb_exp >= thresh] PCU.receive(sdt) -> value sd {
4538 lqual_cb := sd.data.u.data_ind.lqual_cb;
4539 log("Rx PCUIF_DATA.ind (lqual_cb=", lqual_cb, ")");
4540
4541 /* Make sure the actual link quality matches the expected value */
4542 if (not match(lqual_cb, lqual_cb_exp)) {
4543 setverdict(fail, log2str("Link quality ", lqual_cb, " does not match ",
4544 "expected value ", lqual_cb_exp));
4545 } else {
4546 setverdict(pass);
4547 }
4548 }
4549 /* If expected link quality is below the threshold */
4550 [lqual_cb_exp < thresh] PCU.receive(sdt) -> value sd {
4551 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
4552 log2str("Rx unexpected PCUIF_DATA.ind: ", sd.data));
4553 }
4554 /* Ignore PCUIF_RTS.req and PCUIF_TIME.ind */
4555 [] PCU.receive { repeat; }
4556 [lqual_cb_exp < thresh] T.timeout {
4557 log("Rx nothing, as expected");
4558 setverdict(pass);
4559 }
4560 [lqual_cb_exp >= thresh] T.timeout {
4561 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
4562 "Timeout waiting for PCUIF_DATA.ind");
4563 }
4564 }
4565}
4566
4567/* Verify C/I (Carrier-to-Interference ratio) processing of PDTCH frames */
4568testcase TC_pcu_data_ind_lqual_cb() runs on test_CT {
4569 f_init_pcu_test();
4570 PCU.clear;
4571
4572 f_init_l1ctl();
4573 f_l1_tune(L1CTL);
4574
4575 /* Activate a PDCH channel on TS7 */
4576 f_TC_pcu_act_req(0, 0, 7, true);
4577
4578 /* Tune trxcon to that PDCH channel on TS7 */
4579 f_L1CTL_DM_EST_REQ(L1CTL, { false, mp_trx0_arfcn },
4580 valueof(ts_RslChanNr_PDCH(7)), 7);
4581
4582 /* C/I in centiBels, test range: -256 .. +1280, step 128 */
4583 for (var int16_t i := -256; i <= 1280; i := i + 128) {
4584 var TrxcMessage ret;
4585
4586 ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id,
4587 valueof(ts_TRXC_FAKE_CI(i)));
4588
4589 /* FIXME: OsmoBTS may have different threshold (see MIN_QUAL_NORM) */
4590 f_TC_pcu_data_ind_lqual_cb(i, thresh := 0);
4591 }
4592}
4593
Harald Welte883340c2018-02-28 18:59:29 +01004594/* Send PAGING via RSL, expect it to shw up on PCU socket */
4595testcase TC_pcu_paging_from_rsl() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01004596 f_init_pcu_test();
Harald Welte883340c2018-02-28 18:59:29 +01004597
4598 for (var integer i := 0; i < 100; i := i+1) {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07004599 var MobileIdentityLV mi_lv;
4600 var octetstring mi_lv_enc;
4601 var MobileIdentityV mi;
Harald Welte883340c2018-02-28 18:59:29 +01004602 timer T := 3.0;
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07004603
Harald Welte883340c2018-02-28 18:59:29 +01004604 if (i < 50) {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07004605 mi := valueof(t_MI_TMSI(f_rnd_octstring(4)));
Harald Welte883340c2018-02-28 18:59:29 +01004606 } else {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07004607 mi := valueof(ts_MI_IMSI(f_gen_imsi(i)));
Harald Welte883340c2018-02-28 18:59:29 +01004608 }
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07004609
4610 /* Fancy encoding for PCUIF */
4611 mi_lv := valueof(ts_MI_LV(mi));
4612 mi_lv_enc := enc_MobileIdentityLV(mi_lv);
4613 mi_lv_enc := f_pad_oct(mi_lv_enc, 9, '00'O);
Harald Welte883340c2018-02-28 18:59:29 +01004614
4615 /* Send RSL PAGING COMMAND */
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07004616 RSL_CCHAN.send(ts_RSL_UD(ts_RSL_PAGING_CMD(mi, i mod 4)));
Harald Welte883340c2018-02-28 18:59:29 +01004617 T.start;
4618 alt {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07004619 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_PAG_REQ(0, mi_lv_enc))) {
Harald Welte883340c2018-02-28 18:59:29 +01004620 }
4621 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_PAG_REQ)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004622 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected PAGING REQ");
Harald Welte883340c2018-02-28 18:59:29 +01004623 }
4624 [] PCU.receive { repeat; }
4625 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004626 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PAGING REQ");
Harald Welte883340c2018-02-28 18:59:29 +01004627 }
4628 }
4629 }
4630 setverdict(pass);
4631}
4632
Harald Welted66c9b82019-05-25 09:03:15 +02004633/* test for periodic TIME_IND; check number of FN expired and number of TIME_IND within frames */
4634testcase TC_pcu_time_ind() runs on test_CT {
4635 var PCUIF_send_data pcu_sd;
4636 var integer num_time_ind := 0;
4637 var integer first_fn, last_fn;
4638 var float test_duration := 5.0;
4639 timer T;
4640
4641 f_init_pcu_test();
4642 f_TC_pcu_act_req(0, 0, 7, true);
4643
4644 PCU.clear;
4645 T.start(test_duration);
4646 alt {
4647 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_TIME_IND(0, ?))) -> value pcu_sd {
4648 num_time_ind := num_time_ind + 1;
4649 if (not isbound(first_fn)) {
4650 first_fn := pcu_sd.data.u.time_ind.fn;
4651 }
4652 last_fn := pcu_sd.data.u.time_ind.fn;
4653 repeat;
4654 }
4655 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_TIME_IND(?, ?))) -> value pcu_sd {
4656 setverdict(fail, "Received unexpected PCUIF_TIME_IND: ", pcu_sd.data);
4657 repeat;
4658 }
4659 [] PCU.receive {
4660 repeat;
4661 }
4662 [] T.timeout {}
4663 }
4664 var integer fn_expired := last_fn - first_fn;
4665 log(fn_expired, " fn expired with ", num_time_ind, " PCU_TIME.ind");
4666
4667 /* verify the number of frames expired matches our expectation */
4668 const float c_GSM_FN_DURATION_MS := 4.61538;
4669 var float fn_expected := test_duration * 1000.0 / c_GSM_FN_DURATION_MS;
Harald Weltec761c542019-05-28 11:59:57 +02004670 var template integer t_fn_expected := f_tolerance(float2int(fn_expected), 1, 100000, 20);
Harald Welted66c9b82019-05-25 09:03:15 +02004671 if (not match(fn_expired, t_fn_expected)) {
4672 setverdict(fail, "Number of TDMA Frames (", fn_expired, ") not matching ", t_fn_expected);
4673 }
4674
4675 /* There are three TIME.ind in every fn MOD 13 */
4676 var float time_ind_expected := int2float(fn_expired) * 3.0 / 13.0;
4677 /* Add some tolerance */
4678 var template integer t_time_ind_exp := f_tolerance(float2int(time_ind_expected), 1, 100000, 5);
4679 if (not match(num_time_ind, t_time_ind_exp)) {
4680 setverdict(fail, "Number of TIME.ind (", num_time_ind, ") not matching ", t_time_ind_exp);
4681 }
4682
4683 setverdict(pass);
4684}
4685
Harald Welte4832c862019-05-25 14:57:18 +02004686/* test for periodic RTS_REQ; check number of FN expired and number of RTS_IND per SAPI */
4687testcase TC_pcu_rts_req() runs on test_CT {
4688 var PCUIF_send_data pcu_sd;
4689 var integer first_fn, last_fn;
4690 var integer num_rts_pdtch := 0;
4691 var integer num_rts_ptcch := 0;
4692 var float test_duration := 5.0;
4693 timer T;
4694
4695 f_init_pcu_test();
4696 f_TC_pcu_act_req(0, 0, 7, true);
4697
4698 PCU.clear;
4699 T.start(test_duration);
4700 alt {
4701 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(0, 0, 7, PCU_IF_SAPI_PDTCH, ?, ?)))
4702 -> value pcu_sd {
4703 num_rts_pdtch := num_rts_pdtch + 1;
4704 if (not isbound(first_fn)) {
4705 first_fn := pcu_sd.data.u.rts_req.fn;
4706 }
4707 last_fn := pcu_sd.data.u.rts_req.fn;
4708 repeat;
4709 }
4710 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(0, 0, 7, PCU_IF_SAPI_PTCCH, ?, ?)))
4711 -> value pcu_sd {
4712 num_rts_ptcch := num_rts_ptcch + 1;
4713 if (not isbound(first_fn)) {
4714 first_fn := pcu_sd.data.u.rts_req.fn;
4715 }
4716 last_fn := pcu_sd.data.u.rts_req.fn;
4717 repeat;
4718 }
4719 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ)) -> value pcu_sd {
4720 setverdict(fail, "Received unexpected PCUIF_RTS_REQ: ", pcu_sd.data);
4721 repeat;
4722 }
4723 [] PCU.receive {
4724 repeat;
4725 }
4726 [] T.timeout {}
4727 }
4728 var integer fn_expired := last_fn - first_fn;
4729 log(fn_expired, " fn expired with num_rts_pdtch=", num_rts_pdtch,
4730 ", num_rts_ptcch=", num_rts_ptcch);
4731
4732 /* verify the number of frames expired matches our expectation */
4733 const float c_GSM_FN_DURATION_MS := 4.61538;
4734 var float fn_expected := test_duration * 1000.0 / c_GSM_FN_DURATION_MS;
Harald Weltec761c542019-05-28 11:59:57 +02004735 var template integer t_fn_expected := f_tolerance(float2int(fn_expected), 1, 100000, 20);
Harald Welte4832c862019-05-25 14:57:18 +02004736 if (not match(fn_expired, t_fn_expected)) {
4737 setverdict(fail, "Number of TDMA Frames (", fn_expired, ") not matching ", t_fn_expected);
4738 }
4739
4740 /* PTCCH is in pos. 12 + 38 of 52-multiframe, but four slots/bursts required per block */
4741 var float ptcch_expected := int2float(fn_expired) / 52.0 * 0.5;
4742 var template integer t_ptcch_exp := f_tolerance(float2int(ptcch_expected), 1, 100000, 1);
4743 if (not match(num_rts_ptcch, t_ptcch_exp)) {
4744 setverdict(fail, "Number of RTS.ind for PTCCH (", num_rts_ptcch, ") not matching ",
4745 t_ptcch_exp);
4746 }
4747
4748 /* We have 12 PDTCH blocks every 52-multiframe */
4749 var float pdtch_expected := int2float(fn_expired) / 52.0 * 12.0;
4750 var template integer t_pdtch_exp := f_tolerance(float2int(pdtch_expected), 1, 100000, 2);
4751 if (not match(num_rts_pdtch, t_pdtch_exp)) {
4752 setverdict(fail, "Number of RTS.ind for PDTCH (", num_rts_pdtch, ") not matching ",
4753 t_pdtch_exp);
4754 }
4755
4756 setverdict(pass);
4757}
4758
Harald Welte07bd2d22019-05-25 11:03:30 +02004759/* test for generating Abis side OML ALERT from the PCU */
4760testcase TC_pcu_oml_alert() runs on test_CT {
4761 var PCUIF_send_data pcu_sd;
4762 var integer num_time_ind := 0;
4763 var integer first_fn, last_fn;
4764 var float test_duration := 5.0;
4765 timer T;
4766
4767 f_init_pcu_test();
4768 f_TC_pcu_act_req(0, 0, 7, true);
4769
4770 /* re-connect CTRL port from BTS to BSC */
4771 f_ipa_ctrl_stop();
4772 f_ipa_ctrl_start(mp_bsc_ctrl_ip, mp_bsc_ctrl_port);
4773
4774 /* Send that OML Alert */
4775 PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_TXT_IND(0, PCU_OML_ALERT, testcasename())));
4776
4777 /* This requires https://gerrit.osmocom.org/#/c/osmo-bsc/+/14177 to be merged */
4778 f_ctrl_exp_trap(IPA_CTRL, "bts.0.oml_failure_report", ?);
4779 setverdict(pass);
4780}
4781
Harald Welteeaa9a862019-05-26 23:01:08 +02004782template (value) PDU_ML3_MS_NW ts_RRM_GprsSuspReq(template (value) OCT4 tlli,
4783 template (value) RoutingAreaIdentificationV rai,
4784 template (value) OCT1 cause) := {
4785 discriminator := '0000'B, /* overwritten */
4786 tiOrSkip := {
4787 skipIndicator := '0000'B
4788 },
4789 msgs := {
4790 rrm := {
4791 gPRS_suspensionRequest := {
4792 messageType := '00110100'B,
4793 tLLI := tlli,
4794 routingAreaIdentification := rai,
4795 suspensionCause := cause,
4796 service_Support := omit
4797 }
4798 }
4799 }
4800}
4801
4802/* test for forwarding of RR SUSPEND from CS lchan to PCU via PCU socket */
4803private function f_TC_rr_suspend_req(charstring id) runs on ConnHdlr {
4804 var PCUIF_Message first_info;
4805 var integer pcu_conn_id := -1;
4806 var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0));
4807 var RoutingAreaIdentificationV rai := f_RAI('262'H, '42F'H, '2342'O, '55'O);
4808 var OCT4 tlli := '01020304'O;
4809 var OCT1 cause := '23'O;
4810 timer T := 5.0;
4811
4812 f_init_pcu(PCU, id, pcu_conn_id, first_info);
4813
4814 f_l1_tune(L1CTL);
4815 RSL.clear;
4816
4817 f_est_dchan();
4818 L1CTL.clear;
4819
4820 f_est_rll_mo(link_id.sapi, link_id, '23420815'O);
4821
4822 var PDU_ML3_MS_NW susp_req := valueof(ts_RRM_GprsSuspReq(tlli, rai, cause));
4823 var octetstring l3 := enc_PDU_ML3_MS_NW(susp_req);
4824 f_tx_lapdm(ts_LAPDm_I(link_id.sapi, cr_MO_CMD, true, 1, 0, l3), link_id);
4825
4826 /* ConnHdlr has terminated after sending the RR SUSP REQ over a dedicaed channel */
4827 T.start;
4828 alt {
4829 [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_SUSP_REQ(0, tlli, ?, oct2int(cause)))) {
4830 setverdict(pass);
4831 }
4832 [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_SUSP_REQ(?, ?, ?, ?))) {
4833 setverdict(fail, "Received unexpected PCUIF SUSPE REQ: ");
4834 }
4835 [] PCU.receive {
4836 repeat;
4837 }
4838 [] T.timeout {
4839 setverdict(fail, "Timeout waiting for SUSP REQ on PCUIF");
4840 }
4841 }
Alexander Couzensa0634832019-06-07 00:28:56 +02004842
4843 /* release the channel */
4844 f_rsl_chan_deact();
4845 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
4846 f_rslem_unregister(0, g_chan_nr);
Harald Welteeaa9a862019-05-26 23:01:08 +02004847}
4848testcase TC_pcu_rr_suspend() runs on test_CT {
4849 var ConnHdlrPars pars;
4850 var ConnHdlr vc_conn;
4851
4852 f_init();
4853
4854 pars := valueof(t_Pars(t_RslChanNr_SDCCH4(0,3), ts_RSL_ChanMode_SIGN));
4855 vc_conn := f_start_handler(refers(f_TC_rr_suspend_req), pars, true);
4856 vc_conn.done;
4857}
Harald Welte07bd2d22019-05-25 11:03:30 +02004858
Harald Weltea2e0e942019-05-27 18:12:53 +02004859/* Ensure that PCUIF socket can accept only a single connection */
4860testcase TC_pcu_socket_connect_multi() runs on test_CT {
4861 timer T := 5.0;
4862
4863 /* this (among other things) establishes the first connection to the PCUIF socket */
4864 f_init();
4865
4866 /* try to establish a second connection, expect it to fail */
4867 PCU.send(UD_connect:{mp_pcu_socket, -1});
4868 T.start;
4869 alt {
4870 [] PCU.receive(UD_connect_result:{id := ?, result := { result_code := ERROR, err := ? }}) {
4871 setverdict(pass);
4872 }
4873 [] PCU.receive(UD_connect_result:?) {
4874 setverdict(fail, "Unexpected unix domain connect result");
4875 }
4876 [] T.timeout {
4877 setverdict(pass);
4878 }
4879 }
4880 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
4881}
4882
Harald Weltec8effb72019-05-27 18:23:04 +02004883/* Ensure that PCUIF socket can disconnect + reconnect */
4884testcase TC_pcu_socket_reconnect() runs on test_CT {
4885 /* this (among other things) establishes the first connection to the PCUIF socket */
4886 f_init();
4887
4888 f_sleep(1.0);
4889
4890 f_pcuif_close(PCU, g_pcu_conn_id);
4891 g_pcu_conn_id := -1;
4892
4893 f_sleep(1.0);
4894
4895 /* re-connect */
4896 PCU.clear;
4897 f_init_pcu(PCU, testcasename(), g_pcu_conn_id, g_pcu_last_info);
4898 setverdict(pass);
4899
4900 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
4901}
4902
Harald Weltebe030482019-05-27 22:29:35 +02004903/* Ensure that GPRS capability is not advertised before PCU socket conncet */
Vadim Yanitskiy3c185382020-05-04 14:55:02 +07004904private function f_get_si(L1CTL_PT pt, RrMessageType si_type)
4905runs on test_CT return SystemInformation {
Harald Weltebe030482019-05-27 22:29:35 +02004906 var L1ctlDlMessage l1_dl;
4907 var SystemInformation si;
4908 timer T := 5.0;
4909 T.start;
4910 alt {
4911 [] pt.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl {
4912 /* somehow dec_SystemInformation will try to decode even non-RR as SI */
4913 if (not (l1_dl.payload.data_ind.payload[1] == '06'O)) {
4914 log("Ignoring non-RR SI ", l1_dl);
4915 repeat;
4916 }
4917 si := dec_SystemInformation(l1_dl.payload.data_ind.payload)
Vadim Yanitskiy3c185382020-05-04 14:55:02 +07004918 if (si.header.message_type != si_type) {
Harald Weltebe030482019-05-27 22:29:35 +02004919 repeat;
4920 }
4921 }
4922 [] pt.receive {
4923 repeat;
4924 }
4925 [] T.timeout {
Vadim Yanitskiy3c185382020-05-04 14:55:02 +07004926 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
4927 log2str("Timeout waiting for ", si_type));
Harald Weltebe030482019-05-27 22:29:35 +02004928 }
4929 }
Vadim Yanitskiy3c185382020-05-04 14:55:02 +07004930 return si;
Harald Weltebe030482019-05-27 22:29:35 +02004931}
4932
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07004933/* Check if GPRS Indicator is present in RR System Information of a given type */
4934private function f_si_has_gprs_indicator(RrMessageType si_type)
4935runs on test_CT return boolean {
4936 var SystemInformation si := f_get_si(L1CTL, si_type);
4937
4938 if (si_type == SYSTEM_INFORMATION_TYPE_3) {
4939 var RestOctets ro := si.payload.si3.rest_octets;
4940 var SI3RestOctets rest := dec_SI3RestOctets(ro);
4941 return rest.gprs_ind.presence == '1'B;
4942 } else if (si_type == SYSTEM_INFORMATION_TYPE_4) {
4943 var RestOctets ro := si.payload.si4.rest_octets;
4944 var SI4RestOctets rest := dec_SI4RestOctets(ro);
4945 return rest.gprs_ind.presence == '1'B;
4946 }
4947
4948 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unhandled SI type");
4949 return false;
Harald Weltebe030482019-05-27 22:29:35 +02004950}
4951
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07004952/* Make sure that GPRS Indicator is absent when the PCU is not connected */
4953private function f_TC_pcu_socket_noconnect(RrMessageType si_type)
4954runs on test_CT {
Harald Weltebe030482019-05-27 22:29:35 +02004955 /* don't call f_init() as this would connect PCU socket */
4956 f_init_rsl(testcasename());
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07004957
4958 /* Send both System Information Type 3 and 4 (with GPRS Indicator) */
Harald Weltebe030482019-05-27 22:29:35 +02004959 f_rsl_bcch_fill(RSL_SYSTEM_INFO_3, ts_SI3_default);
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07004960 f_rsl_bcch_fill(RSL_SYSTEM_INFO_4, ts_SI4_default);
Harald Weltebe030482019-05-27 22:29:35 +02004961
4962 f_init_l1ctl();
4963 f_l1_tune(L1CTL);
Harald Weltebe030482019-05-27 22:29:35 +02004964 f_sleep(2.0);
4965 L1CTL.clear;
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07004966
4967 if (f_si_has_gprs_indicator(si_type)) {
4968 setverdict(fail, si_type, " indicates GPRS even before PCU socket connected");
Harald Weltebe030482019-05-27 22:29:35 +02004969 } else {
4970 setverdict(pass);
4971 }
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07004972
Harald Weltebe030482019-05-27 22:29:35 +02004973 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
4974}
4975
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07004976testcase TC_pcu_socket_noconnect_nosi3gprs() runs on test_CT {
4977 f_TC_pcu_socket_noconnect(SYSTEM_INFORMATION_TYPE_3);
4978}
Harald Weltebe030482019-05-27 22:29:35 +02004979
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07004980testcase TC_pcu_socket_noconnect_nosi4gprs() runs on test_CT {
4981 f_TC_pcu_socket_noconnect(SYSTEM_INFORMATION_TYPE_4);
4982}
4983
4984/* Ensure that GPRS capability is advertised after PCU socket connect */
4985private function f_TC_pcu_socket_connect(RrMessageType si_type)
4986runs on test_CT {
Harald Weltebe030482019-05-27 22:29:35 +02004987 /* this (among other things) establishes the first connection to the PCUIF socket */
4988 f_init();
4989 f_init_l1ctl();
4990 f_l1_tune(L1CTL);
4991
4992 f_sleep(2.0);
4993 L1CTL.clear;
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07004994
4995 if (not f_si_has_gprs_indicator(si_type)) {
4996 setverdict(fail, si_type, " indicates no GPRS despite PCU socket connected");
Harald Weltebe030482019-05-27 22:29:35 +02004997 } else {
4998 setverdict(pass);
4999 }
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07005000
Harald Weltebe030482019-05-27 22:29:35 +02005001 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
5002}
5003
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07005004testcase TC_pcu_socket_connect_si3gprs() runs on test_CT {
5005 f_TC_pcu_socket_connect(SYSTEM_INFORMATION_TYPE_3);
5006}
Harald Weltebe030482019-05-27 22:29:35 +02005007
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07005008testcase TC_pcu_socket_connect_si4gprs() runs on test_CT {
5009 f_TC_pcu_socket_connect(SYSTEM_INFORMATION_TYPE_4);
5010}
5011
5012/* Ensure that GPRS capability is no longer advertised after PCU socket disconnect */
5013private function f_TC_pcu_socket_disconnect(RrMessageType si_type)
5014runs on test_CT {
Harald Weltebe030482019-05-27 22:29:35 +02005015 /* this (among other things) establishes the first connection to the PCUIF socket */
5016 f_init();
5017 f_init_l1ctl();
5018 f_l1_tune(L1CTL);
5019
5020 f_pcuif_close(PCU, g_pcu_conn_id);
5021 g_pcu_conn_id := -1;
5022
5023 f_sleep(1.0);
5024
5025 /* re-connect */
5026 PCU.clear;
5027 f_init_pcu(PCU, testcasename(), g_pcu_conn_id, g_pcu_last_info);
5028
5029 f_sleep(2.0);
5030 L1CTL.clear;
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07005031
5032 if (f_si_has_gprs_indicator(si_type)) {
5033 setverdict(fail, si_type, " indicates GPRS after PCU socket disconnected");
Harald Weltebe030482019-05-27 22:29:35 +02005034 } else {
5035 setverdict(pass);
5036 }
5037
5038 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
5039}
5040
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07005041testcase TC_pcu_socket_disconnect_nosi3gprs() runs on test_CT {
5042 f_TC_pcu_socket_disconnect(SYSTEM_INFORMATION_TYPE_3);
5043}
5044
5045testcase TC_pcu_socket_disconnect_nosi4gprs() runs on test_CT {
5046 f_TC_pcu_socket_disconnect(SYSTEM_INFORMATION_TYPE_4);
5047}
5048
Oliver Smithf5239c72019-08-28 10:01:25 +02005049/* Verify that the cell_id of SI3 (TS 04.08 9.1.35) and other values are passed properly to the PCU socket (OS#3854) */
5050testcase TC_pcu_socket_verify_info_ind() runs on test_CT {
5051 var SystemInformation si3 := valueof(ts_SI3_default);
5052
5053 f_init();
5054
5055 /* Verify cell_id */
5056 var uint16_t cell_id_si3 := si3.payload.si3.cell_id;
5057 var uint16_t cell_id_pcu := g_pcu_last_info.u.info_ind.cell_id;
5058 if (cell_id_si3 != cell_id_pcu) {
Oliver Smithe1c00f02019-09-04 11:35:56 +02005059 setverdict(fail, "Expected cell_id '", cell_id_si3, "' and got '", cell_id_pcu, "'. This either means,",
5060 " that the BTS is sending the wrong cell_id, or that the BTS sent it too early",
5061 " (OS#4179)");
Oliver Smithf5239c72019-08-28 10:01:25 +02005062 }
5063
5064 /* Verify LAC */
5065 var uint16_t lac_si3 := si3.payload.si3.lai.lac;
5066 var uint16_t lac_pcu := g_pcu_last_info.u.info_ind.lac;
5067 if (lac_si3 != lac_pcu) {
5068 setverdict(fail, "Expected LAC ", lac_si3, " got: ", lac_pcu);
5069 }
5070
5071 setverdict(pass);
5072}
Harald Welted66c9b82019-05-25 09:03:15 +02005073
Harald Welte3d04ae62018-04-04 20:29:05 +02005074/***********************************************************************
Harald Welte9bbbfb52018-04-05 09:33:19 +02005075 * Osmocom Style Dynamic Timeslot Support
Harald Welte3d04ae62018-04-04 20:29:05 +02005076 ***********************************************************************/
5077
5078private function f_dyn_osmo_pdch_act(integer pcu_conn_id, integer bts_nr, integer trx_nr)
5079runs on ConnHdlr {
5080 var PCUIF_send_data sd;
5081 /* Expect BTS to immediately acknowledge activation as PDCH */
5082 PCU.clear;
5083 f_rsl_chan_act(g_pars.chan_mode);
5084 /* expect INFO_IND on PCU interface listing TS as PDCH */
Pau Espin Pedrol202c2f72019-10-08 13:11:05 +02005085 timer T_wait := 2.0;
5086 T_wait.start;
Harald Welte3d04ae62018-04-04 20:29:05 +02005087 alt {
5088 [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(bts_nr, ?))) -> value sd {
5089 if (substr(sd.data.u.info_ind.trx[trx_nr].pdch_mask, g_chan_nr.tn, 1) != '1'B) {
Pau Espin Pedrol202c2f72019-10-08 13:11:05 +02005090 log("PCUIF_INFO_IND PDCH_MASK not yet '1' after PDCH ACT on TS", g_chan_nr.tn,
5091 " mask:", sd.data.u.info_ind.trx[trx_nr].pdch_mask);
5092 repeat;
Harald Welte3d04ae62018-04-04 20:29:05 +02005093 }
5094 }
5095 [] PCU.receive { repeat; }
Pau Espin Pedrol202c2f72019-10-08 13:11:05 +02005096 [] T_wait.timeout {
5097 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
5098 log2str("Timeout waiting for PCUIF_INFO_IND PDCH_MASK to be '1' on TS", g_chan_nr.tn));
5099 }
Harald Welte3d04ae62018-04-04 20:29:05 +02005100 }
5101 /* try to activate this PDCH from the PCU point of view */
5102 PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, g_chan_nr.tn)));
5103 /* FIXME: is there a response? */
5104}
5105
5106private function f_dyn_osmo_pdch_deact(integer pcu_conn_id, integer bts_nr, integer trx_nr)
5107runs on ConnHdlr {
5108 var PCUIF_send_data sd;
5109 /* Send RSL CHAN REL (deactivate) */
5110 PCU.clear;
5111 RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr));
5112 /* expect BTS to ask PCU to deactivate the channel */
Pau Espin Pedrol202c2f72019-10-08 13:11:05 +02005113 timer T_wait := 2.0;
5114 T_wait.start;
Harald Welte3d04ae62018-04-04 20:29:05 +02005115 alt {
5116 [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(bts_nr, ?))) -> value sd {
5117 if (substr(sd.data.u.info_ind.trx[trx_nr].pdch_mask, g_chan_nr.tn, 1) != '0'B) {
Pau Espin Pedrol202c2f72019-10-08 13:11:05 +02005118 log("PCUIF_INFO_IND PDCH_MASK not yet '0' after PDCH DEACT on TS", g_chan_nr.tn,
5119 " mask:", sd.data.u.info_ind.trx[trx_nr].pdch_mask);
5120 repeat;
Harald Welte3d04ae62018-04-04 20:29:05 +02005121 }
5122 }
5123 [] PCU.receive { repeat; }
Pau Espin Pedrol202c2f72019-10-08 13:11:05 +02005124 [] T_wait.timeout {
5125 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
5126 log2str("Timeout waiting for PCUIF_INFO_IND PDCH_MASK to be '0' on TS", g_chan_nr.tn));
5127 }
Harald Welte3d04ae62018-04-04 20:29:05 +02005128 }
5129 /* Emulate PCU asking BTS to deactivate PDCH */
5130 PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_DEACT_REQ(bts_nr, trx_nr, g_chan_nr.tn)));
5131 alt {
5132 [] RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr)) {
5133 setverdict(pass);
5134 }
5135 [] RSL.receive { repeat; }
5136 }
5137}
5138
5139/* Activate Osmocom-style dynamic PDCH from BSC side */
5140function f_TC_dyn_osmo_pdch_act_deact(charstring id) runs on ConnHdlr {
5141 var PCUIF_Message first_info;
5142 var integer ts_nr := g_chan_nr.tn;
5143 var integer trx_nr := 0;
5144 var integer bts_nr := 0;
5145 var integer pcu_conn_id := -1;
5146
5147 f_init_pcu(PCU, id, pcu_conn_id, first_info);
5148
5149 f_dyn_osmo_pdch_act(pcu_conn_id, bts_nr, trx_nr);
5150 f_sleep(3.0);
5151 f_dyn_osmo_pdch_deact(pcu_conn_id, bts_nr, trx_nr);
5152 setverdict(pass);
5153}
5154testcase TC_dyn_osmo_pdch_act_deact() runs on test_CT {
5155 var ConnHdlrPars pars;
5156 var ConnHdlr vc_conn;
Harald Welte10474062019-05-30 16:48:17 +02005157 f_init();
Harald Welte3d04ae62018-04-04 20:29:05 +02005158
5159 pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN));
5160 vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_act_deact), pars, true);
5161 vc_conn.done;
5162}
5163
5164/* send a RF CHAN REL for PDCH on an osmocom dynamci PDCH that's already inactive */
5165function f_TC_dyn_osmo_pdch_unsol_deact(charstring id) runs on ConnHdlr {
5166 var PCUIF_Message first_info;
Harald Welte3d04ae62018-04-04 20:29:05 +02005167 var integer pcu_conn_id := -1;
5168
5169 f_init_pcu(PCU, id, pcu_conn_id, first_info);
5170
Neels Hofmeyr9c50ca52018-05-08 20:37:54 +02005171 RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr));
5172 /* since the lchan is already released, we don't expect any PCU changes, just a rel ack. */
5173 RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr));
Harald Welte3d04ae62018-04-04 20:29:05 +02005174 setverdict(pass);
5175}
5176testcase TC_dyn_osmo_pdch_unsol_deact() runs on test_CT {
5177 var ConnHdlrPars pars;
5178 var ConnHdlr vc_conn;
Harald Welte10474062019-05-30 16:48:17 +02005179 f_init();
Harald Welte3d04ae62018-04-04 20:29:05 +02005180
5181 pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN));
5182 vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_unsol_deact), pars, true);
5183 vc_conn.done;
5184}
5185
5186/* try to RSL CHAN ACT a PDCH on an osmocom-style PDCH that's already active */
5187function f_TC_dyn_osmo_pdch_double_act(charstring id) runs on ConnHdlr {
5188 var PCUIF_Message first_info;
5189 var integer ts_nr := g_chan_nr.tn;
5190 var integer trx_nr := 0;
5191 var integer bts_nr := 0;
5192 var integer pcu_conn_id := -1;
5193
5194 f_init_pcu(PCU, id, pcu_conn_id, first_info);
5195
5196 f_dyn_osmo_pdch_act(pcu_conn_id, bts_nr, trx_nr);
Neels Hofmeyrdf936a22018-05-08 22:07:57 +02005197 /* Send a second Chan Activ and expect it to be NACKed */
5198 f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_NACK(g_chan_nr),
5199 "RSL CHAN ACT NACK");
Harald Welte3d04ae62018-04-04 20:29:05 +02005200 setverdict(pass);
5201}
5202testcase TC_dyn_osmo_pdch_double_act() runs on test_CT {
5203 var ConnHdlrPars pars;
5204 var ConnHdlr vc_conn;
Harald Welte10474062019-05-30 16:48:17 +02005205 f_init();
Harald Welte3d04ae62018-04-04 20:29:05 +02005206
5207 pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN));
5208 vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_double_act), pars, true);
5209 vc_conn.done;
5210}
5211
5212/* try to RSL CHAN ACT a TCH/F on an osmocom-style PDCH */
5213function f_TC_dyn_osmo_pdch_tchf_act(charstring id) runs on ConnHdlr {
5214 var PCUIF_Message first_info;
5215 var integer ts_nr := g_chan_nr.tn;
5216 var integer trx_nr := 0;
5217 var integer bts_nr := 0;
5218 var integer pcu_conn_id := -1;
5219 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(g_chan_nr.tn));
5220
5221 /* register for the TCH/F channel number */
5222 f_rslem_register(0, chan_nr);
5223
5224 f_init_pcu(PCU, id, pcu_conn_id, first_info);
5225
5226 f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_ACK(chan_nr),
5227 "RSL CHAN ACT");
5228 setverdict(pass);
5229}
5230testcase TC_dyn_osmo_pdch_tchf_act() runs on test_CT {
5231 var ConnHdlrPars pars;
5232 var ConnHdlr vc_conn;
Harald Welte10474062019-05-30 16:48:17 +02005233 f_init();
Harald Welte3d04ae62018-04-04 20:29:05 +02005234
5235 pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN));
5236 vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_tchf_act), pars, true);
5237 vc_conn.done;
5238}
5239
5240/* try to RSL CHAN ACT the TCH/H on an osmocom-style PDCH */
5241function f_TC_dyn_osmo_pdch_tchh_act(charstring id) runs on ConnHdlr {
5242 var PCUIF_Message first_info;
5243 var integer ts_nr := g_chan_nr.tn;
5244 var integer trx_nr := 0;
5245 var integer bts_nr := 0;
5246 var integer pcu_conn_id := -1;
5247 var RslChannelNr chan_nr[2] := { valueof(t_RslChanNr_Lm(g_chan_nr.tn, 0)),
5248 valueof(t_RslChanNr_Lm(g_chan_nr.tn, 1)) };
5249
5250 /* register for the TCH/H channel numbers */
5251 f_rslem_register(0, chan_nr[0]);
5252 f_rslem_register(0, chan_nr[1]);
5253
5254 f_init_pcu(PCU, id, pcu_conn_id, first_info);
5255
5256 f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr[1], g_pars.chan_mode),
5257 tr_RSL_CHAN_ACT_ACK(chan_nr[1]), "RSL CHAN ACT [1]");
5258 f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr[0], g_pars.chan_mode),
5259 tr_RSL_CHAN_ACT_ACK(chan_nr[0]), "RSL CHAN ACT [0]");
5260 setverdict(pass);
5261}
5262testcase TC_dyn_osmo_pdch_tchh_act() runs on test_CT {
5263 var ConnHdlrPars pars;
5264 var ConnHdlr vc_conn;
Harald Welte10474062019-05-30 16:48:17 +02005265 f_init();
Harald Welte3d04ae62018-04-04 20:29:05 +02005266
5267 pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN));
5268 vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_tchh_act), pars, true);
5269 vc_conn.done;
5270}
5271
Harald Welte9bbbfb52018-04-05 09:33:19 +02005272/***********************************************************************
5273 * IPA Style Dynamic Timeslot Support
5274 ***********************************************************************/
5275
5276private function f_dyn_ipa_pdch_act(integer pcu_conn_id, integer bts_nr, integer trx_nr)
5277runs on ConnHdlr {
5278 var PCUIF_send_data sd;
5279 /* Expect BTS to immediately acknowledge activation as PDCH */
5280 PCU.clear;
5281 RSL.send(ts_RSL_IPA_PDCH_ACT(g_chan_nr));
5282 /* expect INFO_IND on PCU interface listing TS as PDCH */
Pau Espin Pedrol446e07b2019-02-18 21:18:36 +01005283 timer T_wait := 2.0;
5284 T_wait.start;
Harald Welte9bbbfb52018-04-05 09:33:19 +02005285 alt {
5286 [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(bts_nr, ?))) -> value sd {
5287 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 +01005288 log("PCUIF_INFO_IND PDCH_MASK not yet '1' after PDCH ACT on TS", g_chan_nr.tn,
5289 " mask:", sd.data.u.info_ind.trx[trx_nr].pdch_mask);
5290 repeat;
Harald Welte9bbbfb52018-04-05 09:33:19 +02005291 }
5292 }
5293 [] PCU.receive { repeat; }
Pau Espin Pedrol446e07b2019-02-18 21:18:36 +01005294 [] T_wait.timeout {
5295 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
5296 log2str("Timeout waiting for PCUIF_INFO_IND PDCH_MASK to be '1' on TS", g_chan_nr.tn));
5297 }
Harald Welte9bbbfb52018-04-05 09:33:19 +02005298 }
5299 /* try to activate this PDCH from the PCU point of view */
5300 PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, g_chan_nr.tn)));
5301 /* FIXME: is there a response? */
5302
5303 RSL.receive(tr_RSL_IPA_PDCH_ACT_ACK(g_chan_nr, ?));
5304}
5305
5306private function f_dyn_ipa_pdch_deact(integer pcu_conn_id, integer bts_nr, integer trx_nr)
5307runs on ConnHdlr {
5308 var PCUIF_send_data sd;
5309 /* Send RSL CHAN REL (deactivate) */
5310 RSL.send(ts_RSL_IPA_PDCH_DEACT(g_chan_nr));
5311 PCU.clear;
5312 /* expect BTS to ask PCU to deactivate the channel */
Pau Espin Pedrol446e07b2019-02-18 21:18:36 +01005313 timer T_wait := 2.0;
5314 T_wait.start;
Harald Welte9bbbfb52018-04-05 09:33:19 +02005315 alt {
5316 [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(bts_nr, ?))) -> value sd {
5317 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 +01005318 log("PCUIF_INFO_IND PDCH_MASK not yet '0' after PDCH DEACT on TS", g_chan_nr.tn,
5319 " mask:", sd.data.u.info_ind.trx[trx_nr].pdch_mask);
5320 repeat;
Harald Welte9bbbfb52018-04-05 09:33:19 +02005321 }
5322 }
5323 [] PCU.receive { repeat; }
Pau Espin Pedrol446e07b2019-02-18 21:18:36 +01005324 [] T_wait.timeout {
5325 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
5326 log2str("Timeout waiting for PCUIF_INFO_IND PDCH_MASK to be '0' on TS", g_chan_nr.tn));
5327 }
Harald Welte9bbbfb52018-04-05 09:33:19 +02005328 }
5329 /* Emulate PCU asking BTS to deactivate PDCH */
5330 PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_DEACT_REQ(bts_nr, trx_nr, g_chan_nr.tn)));
5331 alt {
5332 [] RSL.receive(tr_RSL_IPA_PDCH_DEACT_ACK(g_chan_nr)) {
5333 setverdict(pass);
5334 }
5335 [] RSL.receive { repeat; }
5336 }
5337}
5338
5339/* Activate and de-activate an IPA-style dynamic TCH/F + PDCH */
5340function f_TC_dyn_ipa_pdch_act_deact(charstring id) runs on ConnHdlr {
5341 var PCUIF_Message first_info;
5342 var integer ts_nr := g_chan_nr.tn;
5343 var integer trx_nr := 0;
5344 var integer bts_nr := 0;
5345 var integer pcu_conn_id := -1;
5346
5347 f_init_pcu(PCU, id, pcu_conn_id, first_info);
5348
5349 f_dyn_ipa_pdch_act(pcu_conn_id, bts_nr, trx_nr);
5350 f_sleep(3.0);
5351 f_dyn_ipa_pdch_deact(pcu_conn_id, bts_nr, trx_nr);
5352
5353 setverdict(pass);
5354
5355}
5356testcase TC_dyn_ipa_pdch_act_deact() runs on test_CT {
5357 var ConnHdlrPars pars;
5358 var ConnHdlr vc_conn;
5359 f_init();
5360
5361 pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN));
5362 vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_act_deact), pars, true);
5363 vc_conn.done;
5364}
5365
5366/* try to RSL CHAN ACT a TCH/F on an IPA-style PDCH */
5367function f_TC_dyn_ipa_pdch_tchf_act(charstring id) runs on ConnHdlr {
5368 var PCUIF_Message first_info;
5369 var integer ts_nr := g_chan_nr.tn;
5370 var integer trx_nr := 0;
5371 var integer bts_nr := 0;
5372 var integer pcu_conn_id := -1;
5373
5374 f_init_pcu(PCU, id, pcu_conn_id, first_info);
5375
5376 f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_ACK(g_chan_nr),
5377 "RSL CHAN ACT");
5378 f_rsl_transceive(ts_RSL_RF_CHAN_REL(g_chan_nr), tr_RSL_RF_CHAN_REL_ACK(g_chan_nr),
5379 "RF CHAN REL", true);
5380 setverdict(pass);
5381}
5382testcase TC_dyn_ipa_pdch_tchf_act() runs on test_CT {
5383 var ConnHdlrPars pars;
5384 var ConnHdlr vc_conn;
Harald Welte10474062019-05-30 16:48:17 +02005385 f_init();
Harald Welte9bbbfb52018-04-05 09:33:19 +02005386
5387 pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN));
5388 vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_tchf_act), pars, true);
5389 vc_conn.done;
5390}
5391
5392/* Activate IPA style dyn PDCH as TCH/F and then illegally try to activate it as PDCH, too */
5393function f_TC_dyn_ipa_pdch_tchf_act_pdch_act_nack(charstring id) runs on ConnHdlr {
5394 var PCUIF_Message first_info;
5395 var integer ts_nr := g_chan_nr.tn;
5396 var integer trx_nr := 0;
5397 var integer bts_nr := 0;
5398 var integer pcu_conn_id := -1;
5399
5400 f_init_pcu(PCU, id, pcu_conn_id, first_info);
5401
5402 f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_ACK(g_chan_nr),
5403 "RSL CHAN ACT");
5404
5405 RSL.send(ts_RSL_IPA_PDCH_ACT(g_chan_nr));
5406 alt {
5407 [] RSL.receive(tr_RSL_IPA_PDCH_ACT_NACK(g_chan_nr, ?));
5408 [] RSL.receive(tr_RSL_IPA_PDCH_ACT_ACK(g_chan_nr, ?)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02005409 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected PDCH ACT ACK");
Harald Welte9bbbfb52018-04-05 09:33:19 +02005410 }
5411 [] RSL.receive { repeat; }
5412 }
5413
5414 f_rsl_transceive(ts_RSL_RF_CHAN_REL(g_chan_nr), tr_RSL_RF_CHAN_REL_ACK(g_chan_nr),
5415 "RF CHAN REL", true);
5416 setverdict(pass);
5417}
5418testcase TC_dyn_ipa_pdch_tchf_act_pdch_act_nack() runs on test_CT {
5419 var ConnHdlrPars pars;
5420 var ConnHdlr vc_conn;
Harald Welte10474062019-05-30 16:48:17 +02005421 f_init();
Harald Welte9bbbfb52018-04-05 09:33:19 +02005422
5423 pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN));
5424 vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_tchf_act_pdch_act_nack), pars, true);
5425 vc_conn.done;
5426}
5427
5428/* try to RSL CHAN ACT a TCH/F on an IPA-style PDCH that's already in PDCH mode; expect NACK */
5429function f_TC_dyn_ipa_pdch_act_tchf_act_nack(charstring id) runs on ConnHdlr {
5430 var PCUIF_Message first_info;
5431 var integer ts_nr := g_chan_nr.tn;
5432 var integer trx_nr := 0;
5433 var integer bts_nr := 0;
5434 var integer pcu_conn_id := -1;
5435
5436 /* register for the TCH/F channel number */
5437 f_rslem_register(0, g_chan_nr);
5438
5439 f_init_pcu(PCU, id, pcu_conn_id, first_info);
5440
5441 f_dyn_ipa_pdch_act(pcu_conn_id, bts_nr, trx_nr);
5442
5443 f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_NACK(g_chan_nr),
5444 "RSL CHAN ACT");
5445
5446 f_dyn_ipa_pdch_deact(pcu_conn_id, bts_nr, trx_nr);
5447
5448 setverdict(pass);
5449}
5450testcase TC_dyn_ipa_pdch_act_tchf_act_nack() runs on test_CT {
5451 var ConnHdlrPars pars;
5452 var ConnHdlr vc_conn;
Harald Welte10474062019-05-30 16:48:17 +02005453 f_init();
Harald Welte9bbbfb52018-04-05 09:33:19 +02005454
5455 pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN));
5456 vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_act_tchf_act_nack), pars, true);
5457 vc_conn.done;
5458}
5459
5460
Harald Welte0472ab42018-03-12 15:02:26 +01005461/***********************************************************************
5462 * LAPDm / RLL related
5463 ***********************************************************************/
5464
5465private function f_tx_lapdm(template (value) LapdmFrame l,
5466 template (value) RslLinkId link_id) runs on ConnHdlr {
5467 var octetstring l2 := enc_LapdmFrame(valueof(l));
Vadim Yanitskiy0a8d6da2019-05-28 22:18:28 +07005468 var template (value) SacchL1Header l1h;
5469
5470 /* TODO: we can use an extension of TTCN-3 for padding, i.e. PADDING('2B'O) */
Harald Welte0472ab42018-03-12 15:02:26 +01005471 if (valueof(link_id.c) == SACCH) {
Vadim Yanitskiy0a8d6da2019-05-28 22:18:28 +07005472 /* Compose dummy L1 header */
5473 l1h := ts_SacchL1Header(g_pars.l1_pars.ms_power_level, false, g_pars.l1_pars.ms_actual_ta);
5474 L1CTL.send(ts_L1CTL_DATA_REQ_SACCH(g_chan_nr, link_id, l1h, f_pad_oct(l2, 21, '2B'O)));
Pau Espin Pedrola0fb42a2018-10-10 15:56:39 +02005475 } else {
5476 /* If required, pad L2 frame with constant 0x2b filling */
Vadim Yanitskiy0a8d6da2019-05-28 22:18:28 +07005477 L1CTL.send(ts_L1CTL_DATA_REQ(g_chan_nr, link_id, f_pad_oct(l2, 23, '2B'O)));
Harald Welte0472ab42018-03-12 15:02:26 +01005478 }
Harald Welte0472ab42018-03-12 15:02:26 +01005479}
5480
5481type record RllTestCase {
5482 uint3_t sapi,
5483 RslLinkId link_id,
5484 octetstring l3,
5485 boolean exp
5486}
5487type record of RllTestCase RllTestCases;
5488template RllTestCase t_EITC(uint3_t sapi, RslLinkId id, octetstring l3, boolean exp) := {
5489 sapi := sapi,
5490 link_id := id,
5491 l3 := l3,
5492 exp := exp
5493}
5494
5495/* execute the same callback function with a set of different parameters (tcs) on a
5496 * variety of logical channels */
5497private function f_rll_testmatrix(RllTestCases tcs, void_fn fn) runs on test_CT {
5498 var ConnHdlrPars pars;
5499 var ConnHdlr vc_conn;
Harald Welte10474062019-05-30 16:48:17 +02005500 f_init();
Harald Welte0472ab42018-03-12 15:02:26 +01005501
5502 /* test on each of the channels we have */
5503 for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i+1) {
5504 pars := valueof(t_Pars(g_AllChanTypes[i], ts_RSL_ChanMode_SIGN));
5505
5506 /* test each of the test cases on the current channel */
5507 for (var integer j := 0; j < sizeof(tcs); j := j+1) {
5508 pars.spec.rll := tcs[j];
5509 log(testcasename(), ": XXX Starting ", tcs[j] , " on ", g_AllChanTypes[i]);
5510 vc_conn := f_start_handler(fn, pars);
5511 vc_conn.done;
5512 }
5513 }
5514
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02005515 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte0472ab42018-03-12 15:02:26 +01005516}
5517
5518/* test if SABM on Um triggers EST IND (TS 48.058 3.1) */
5519private function f_TC_rll_est_ind(charstring id) runs on ConnHdlr {
5520 var RllTestCase tc := g_pars.spec.rll;
5521 timer T := 3.0;
5522
5523 f_l1_tune(L1CTL);
5524 RSL.clear;
5525
5526 /* activate the logical channel */
5527 f_est_dchan();
5528 L1CTL.clear;
5529
5530 f_tx_lapdm(ts_LAPDm_SABM(tc.sapi, cr_MO_CMD, true, tc.l3), tc.link_id);
5531 T.start;
5532 alt {
5533 [tc.l3 != ''O] RSL.receive(tr_RSL_EST_IND(g_chan_nr, tc.link_id, tc.l3)) {
5534 if (tc.exp) {
5535 setverdict(pass);
5536 } else {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02005537 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Unexpected EST IND with L3 in ", tc));
Harald Welte0472ab42018-03-12 15:02:26 +01005538 }
5539 }
5540 [tc.l3 == ''O] RSL.receive(tr_RSL_EST_IND_NOL3(g_chan_nr, tc.link_id)) {
5541 if (tc.exp) {
5542 setverdict(pass);
5543 } else {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02005544 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Unexpected EST IND without L3 in ", tc));
Harald Welte0472ab42018-03-12 15:02:26 +01005545 }
5546 }
Vadim Yanitskiy35677872018-10-04 17:30:21 +07005547 /* We also expect to receive the measurements */
5548 [] as_meas_res(verify_meas := false);
Harald Welte0472ab42018-03-12 15:02:26 +01005549 [tc.exp] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02005550 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for EST IND");
Harald Welte0472ab42018-03-12 15:02:26 +01005551 }
5552 [not tc.exp] T.timeout {
5553 setverdict(pass);
5554 }
5555 }
5556
5557 f_rsl_chan_deact();
5558 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
5559 f_rslem_unregister(0, g_chan_nr);
5560}
5561testcase TC_rll_est_ind() runs on test_CT {
5562 var RllTestCases tcs := {
Harald Welte7aacbbf2018-05-09 16:56:41 +02005563 /* SAPI0 establishment (contention resolution) */
Harald Welte0472ab42018-03-12 15:02:26 +01005564 valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), '01020304'O, true)),
Harald Welte7aacbbf2018-05-09 16:56:41 +02005565 /* normal SAPI0 establishment */
5566 valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), ''O, true)),
Harald Welte0472ab42018-03-12 15:02:26 +01005567 /* SAPI 3 doesn't support contention resolution */
5568 valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), '01020304'O, false)),
5569 valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), '01020304'O, false)),
5570 /* normal SAPI3 establishment on main DCCH */
5571 valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), ''O, true)),
5572 /* normal SAPI3 establishment on SACCH */
5573 valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), ''O, true))
5574 };
5575 f_rll_testmatrix(tcs, refers(f_TC_rll_est_ind));
5576}
5577
5578/* test if RLL EST REQ trigeres SABM on Um; UA on Um triggers EST CONF (TS 48.058 3.2) */
5579private function f_TC_rll_est_req(charstring id) runs on ConnHdlr {
5580 var RllTestCase tc := g_pars.spec.rll;
5581 var L1ctlDlMessage dl;
5582 timer T := 3.0;
5583
5584 f_l1_tune(L1CTL);
5585 RSL.clear;
5586
5587 /* activate the logical channel */
5588 f_est_dchan();
5589 L1CTL.clear;
5590
5591 /* Send a RSL EST REQ for SAPI3 on main DCCH */
5592 RSL.send(ts_RSL_EST_REQ(g_chan_nr, tc.link_id));
5593 T.start;
5594 alt {
5595 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, ?)) -> value dl {
5596 var LapdmFrame lapdm;
5597 var octetstring l2 := dl.payload.data_ind.payload;
5598 if (dl.dl_info.link_id.c == SACCH) {
5599 /* remove L1 header */
5600 l2 := substr(l2, 2, lengthof(l2)-2);
5601 }
5602 lapdm.ab := dec_LapdmFrameAB(l2);
5603 if (match(lapdm, tr_LAPDm_SABM(tc.sapi, cr_MT_CMD, true, ''O))) {
5604 setverdict(pass);
5605 } else {
5606 repeat;
5607 }
5608 }
5609 [] L1CTL.receive { repeat; }
5610 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02005611 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for SABM");
Harald Welte0472ab42018-03-12 15:02:26 +01005612 }
5613 }
5614
5615 f_rsl_chan_deact();
5616 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
5617 f_rslem_unregister(0, g_chan_nr);
5618}
5619testcase TC_rll_est_req_DCCH_3() runs on test_CT {
5620 var RllTestCases tcs := {
5621 /* normal SAPI3 establishment on main DCCH */
5622 valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), ''O, true))//,
5623 };
5624 f_rll_testmatrix(tcs, refers(f_TC_rll_est_req));
5625}
5626testcase TC_rll_est_req_ACCH_3() runs on test_CT {
5627 var RllTestCases tcs := {
5628 /* normal SAPI3 establishment on SACCH */
5629 valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), ''O, true))
5630 }
5631 f_rll_testmatrix(tcs, refers(f_TC_rll_est_req));
5632}
5633
5634/* altstep to receive a LAPDm frame matching the given template */
5635private altstep as_l1_exp_lapdm(template LapdmFrame exp) runs on ConnHdlr {
5636 var L1ctlDlMessage dl;
5637 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, ?)) -> value dl {
5638 var LapdmFrame lapdm;
5639 var octetstring l2 := dl.payload.data_ind.payload;
5640 if (dl.dl_info.link_id.c == SACCH) {
5641 /* remove L1 header */
5642 l2 := substr(l2, 2, lengthof(l2)-2);
5643 }
5644 if (ischosen(exp.ab)) {
5645 lapdm.ab := dec_LapdmFrameAB(l2);
5646 } else if (ischosen(exp.b4)) {
5647 lapdm.b4 := dec_LapdmFrameB4(l2);
5648 } else if (ischosen(exp.bbis)) {
5649 lapdm.bbis := dec_LapdmFrameBbis(l2);
5650 }
5651 log("Rx LAPDm ", lapdm);
5652 if (match(lapdm, exp)) {
5653 setverdict(pass);
5654 } else {
5655 repeat;
5656 }
5657 }
5658 [] L1CTL.receive { repeat; }
5659}
5660private function f_l1_exp_lapdm(template LapdmFrame exp, float t := 3.0) runs on ConnHdlr {
5661 timer T := t;
5662 T.start;
5663 alt {
5664 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02005665 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Timeout waiting for LAPDm ", exp));
Harald Welte0472ab42018-03-12 15:02:26 +01005666 }
5667 [] as_l1_exp_lapdm(exp);
5668 }
5669}
5670
5671/* establish one Radio Link Layer via SABM -> UA. Use l3 for contention resolution */
5672private function f_est_rll_mo(uint3_t sapi, RslLinkId link_id, octetstring l3) runs on ConnHdlr {
5673 /* send SABM from MS -> BTS */
5674 f_tx_lapdm(ts_LAPDm_SABM(sapi, cr_MO_CMD, true, l3), link_id);
5675 /* expect RLL EST IND on Abis */
5676 alt {
5677 [l3 != ''O] RSL.receive(tr_RSL_EST_IND(g_chan_nr, link_id, l3));
5678 [l3 == ''O] RSL.receive(tr_RSL_EST_IND_NOL3(g_chan_nr, link_id));
5679 [] RSL.receive(tr_RSL_ERROR_IND(g_chan_nr, link_id, ?)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02005680 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Failing due to RSL_ERROR_IND");
Harald Welte0472ab42018-03-12 15:02:26 +01005681 }
5682 [] RSL.receive { repeat; }
5683 }
5684 /* expect UA from BTS -> MS */
5685 f_l1_exp_lapdm(tr_LAPDm_UA(sapi, cr_MT_RSP, true, l3));
5686}
5687
5688/* test if DISC on Um triggers RLL REL IND (TS 48.058 3.3) */
5689private function f_TC_rll_rel_ind(charstring id) runs on ConnHdlr {
5690 var RllTestCase tc := g_pars.spec.rll;
5691
5692 f_l1_tune(L1CTL);
5693 RSL.clear;
5694
5695 /* activate the logical channel */
5696 f_est_dchan();
5697 L1CTL.clear;
5698
5699 /* first establish the link-layer */
5700 f_est_rll_mo(tc.sapi, tc.link_id, tc.l3);
5701
5702 /* then send the DISC */
5703 f_tx_lapdm(ts_LAPDm_DISC(tc.sapi, cr_MO_CMD, true), tc.link_id);
5704 /* ... and expect the REL IND on the RSL side */
5705 alt {
5706 [] RSL.receive(tr_RSL_REL_IND(g_chan_nr, tc.link_id)) {
5707 setverdict(pass);
5708 }
Vadim Yanitskiy35677872018-10-04 17:30:21 +07005709 /* We also expect to receive the measurements */
5710 [] as_meas_res(verify_meas := false);
Harald Welte0472ab42018-03-12 15:02:26 +01005711 }
5712
5713 /* release the channel */
5714 f_rsl_chan_deact();
5715 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
5716 f_rslem_unregister(0, g_chan_nr);
5717}
5718testcase TC_rll_rel_ind_DCCH_0() runs on test_CT {
5719 var RllTestCases tcs := {
5720 valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), '01020304'O, true))
5721 };
5722 f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind));
5723}
5724
5725testcase TC_rll_rel_ind_ACCH_0() runs on test_CT {
5726 var RllTestCases tcs := {
5727 valueof(t_EITC(0, valueof(ts_RslLinkID_SACCH(0)), ''O, true))
5728 };
5729 f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind));
5730}
5731testcase TC_rll_rel_ind_DCCH_3() runs on test_CT {
5732 var RllTestCases tcs := {
5733 valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), ''O, true))
5734 };
5735 f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind));
5736}
5737testcase TC_rll_rel_ind_ACCH_3() runs on test_CT {
5738 var RllTestCases tcs := {
5739 valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), ''O, true))
5740 };
5741 f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind));
5742}
5743
5744/* test if RLL REL REQ triggers DISC on Um; UA/DM triggers RLL REL CONF (TS 48.058 3.4) */
5745private function f_TC_rll_rel_req(charstring id) runs on ConnHdlr {
5746 var RllTestCase tc := g_pars.spec.rll;
5747 f_l1_tune(L1CTL);
5748 RSL.clear;
5749
5750 /* activate the logical channel */
5751 f_est_dchan();
5752 L1CTL.clear;
5753
5754 /* first establish the link-layer */
5755 f_est_rll_mo(tc.sapi, tc.link_id, tc.l3);
5756
5757 /* then send the REL REQ via RSL */
5758 RSL.send(ts_RSL_REL_REQ(g_chan_nr, tc.link_id, RSL_REL_MODE_NORMAL));
5759 /* ... and expect the DISC on the Um side */
5760 alt {
Harald Weltebc6199f2018-05-10 19:38:18 +02005761 [] as_l1_exp_lapdm(tr_LAPDm_DISC(tc.sapi, cr_MT_CMD, true)) {
Harald Welte0472ab42018-03-12 15:02:26 +01005762 /* FIXME: send a UA in resposne to the DISC */
5763 }
5764 }
5765
5766 /* release the channel */
5767 f_rsl_chan_deact();
5768 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
5769 f_rslem_unregister(0, g_chan_nr);
5770}
5771testcase TC_rll_rel_req() runs on test_CT {
5772 var RllTestCases tcs := {
5773 valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), '01020304'O, true)),
5774 valueof(t_EITC(0, valueof(ts_RslLinkID_SACCH(0)), ''O, true)),
5775 valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), ''O, true)),
5776 valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), ''O, true))
5777 };
5778 f_rll_testmatrix(tcs, refers(f_TC_rll_rel_req));
5779}
5780
5781/* test if RLL DATA REQ triggers I-frames on Um (TS 48.058 3.5) */
5782testcase TC_rll_data_req() runs on test_CT {
5783}
5784
5785/* test if I-frames on Um trigger RLL DATA IND (TS 48.058 3.6) */
5786testcase TC_rll_data_ind() runs on test_CT {
5787}
5788
5789/* test if RLL UNIT DATA REQ triggers UI-frame on Um (TS 48.058 3.7) */
5790private function f_TC_rll_ud_req(charstring id) runs on ConnHdlr {
5791 var RllTestCase tc := g_pars.spec.rll;
5792
5793 f_l1_tune(L1CTL);
5794 RSL.clear;
5795
5796 f_est_dchan();
5797 L1CTL.clear;
5798
5799 /* Send UNITDATA REQ on RSL side */
5800 RSL.send(ts_RSL_UNITDATA_REQ(g_chan_nr, tc.link_id, tc.l3));
5801 /* Expect it to arrive on the other side */
5802 if (tc.link_id.c == SACCH) {
Harald Weltee613f962018-04-18 22:38:16 +02005803 f_l1_exp_lapdm(tr_LAPDm_B4_UI(tc.sapi, cr_MT_CMD, tc.l3));
Harald Welte0472ab42018-03-12 15:02:26 +01005804 } else {
Harald Weltee613f962018-04-18 22:38:16 +02005805 f_l1_exp_lapdm(tr_LAPDm_UI(tc.sapi, cr_MT_CMD, tc.l3));
Harald Welte0472ab42018-03-12 15:02:26 +01005806 }
5807
5808 /* release the channel */
5809 f_rsl_chan_deact();
5810 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
5811 f_rslem_unregister(0, g_chan_nr);
5812}
5813testcase TC_rll_unit_data_req_DCCH() runs on test_CT {
5814 var octetstring l3 := f_rnd_octstring(15);
5815 var RllTestCases tcs := {
5816 valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), l3, true)),
5817 valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), l3, true))
5818 };
5819 f_rll_testmatrix(tcs, refers(f_TC_rll_ud_req));
5820}
5821testcase TC_rll_unit_data_req_ACCH() runs on test_CT {
5822 var octetstring l3 := f_rnd_octstring(19);
5823 var RllTestCases tcs := {
5824 valueof(t_EITC(0, valueof(ts_RslLinkID_SACCH(0)), l3, true)),
5825 valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), l3, true))
5826 };
5827 f_rll_testmatrix(tcs, refers(f_TC_rll_ud_req));
5828}
5829
5830/* test if UI-frames on Um trigger RLL UNIT DATA IND (TS 48.058 3.8) */
5831private function f_TC_rll_ud_ind(charstring id) runs on ConnHdlr {
5832 var RllTestCase tc := g_pars.spec.rll;
5833
5834 f_l1_tune(L1CTL);
5835 RSL.clear;
5836
5837 f_est_dchan();
5838 L1CTL.clear;
5839
5840 /* Send LAPDm UI frame. There is no B4 format in uplink! */
Harald Weltee613f962018-04-18 22:38:16 +02005841 f_tx_lapdm(ts_LAPDm_UI(tc.sapi, cr_MO_CMD, tc.l3), tc.link_id);
Harald Welte0472ab42018-03-12 15:02:26 +01005842 /* Expdct RLL UNITDATA IND on RSL side */
5843 alt {
5844 [] RSL.receive(tr_RSL_UNITDATA_IND(g_chan_nr, tc.link_id, tc.l3)) {
5845 setverdict(pass);
5846 }
5847 [] RSL.receive { repeat; }
5848 }
5849
5850 /* release the channel */
5851 f_rsl_chan_deact();
5852 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
5853 f_rslem_unregister(0, g_chan_nr);
5854}
5855testcase TC_rll_unit_data_ind_DCCH() runs on test_CT {
Stefan Sperlingc4181912018-07-25 17:03:08 +02005856 var octetstring l3 := f_rnd_octstring(20);
Harald Welte0472ab42018-03-12 15:02:26 +01005857 var RllTestCases tcs := {
5858 valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), l3, true)),
5859 valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), l3, true))
5860 };
5861 f_rll_testmatrix(tcs, refers(f_TC_rll_ud_ind));
5862}
5863testcase TC_rll_unit_data_ind_ACCH() runs on test_CT {
5864 var octetstring l3 := f_rnd_octstring(18);
5865 var RllTestCases tcs := {
5866 valueof(t_EITC(0, valueof(ts_RslLinkID_SACCH(0)), l3, true)),
5867 valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), l3, true))
5868 };
5869 f_rll_testmatrix(tcs, refers(f_TC_rll_ud_ind));
5870}
5871
Harald Weltee613f962018-04-18 22:38:16 +02005872/***********************************************************************
5873 * Encryption Related
5874 ***********************************************************************/
5875
5876/* send UNITDATA_REQ from BTS to MS and expect it to arrive */
5877function f_unitdata_mt(RslLinkId link_id, octetstring l3) runs on ConnHdlr {
5878 RSL.send(ts_RSL_UNITDATA_REQ(g_chan_nr, link_id, l3));
5879 if (link_id.c == SACCH) {
5880 f_l1_exp_lapdm(tr_LAPDm_B4_UI(link_id.sapi, cr_MT_CMD, l3));
5881 } else {
5882 f_l1_exp_lapdm(tr_LAPDm_UI(link_id.sapi, cr_MT_CMD, l3));
5883 }
5884}
5885
Vadim Yanitskiyad131c82018-10-04 06:18:59 +07005886/* Expect (or not expect) other kinds of messages */
5887private altstep as_rsl_any_ind(boolean exp_any) runs on ConnHdlr {
5888 [exp_any] RSL.receive { repeat; }
5889 [not exp_any] RSL.receive {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02005890 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RSL message!");
Vadim Yanitskiyad131c82018-10-04 06:18:59 +07005891 }
5892}
5893
Harald Weltee613f962018-04-18 22:38:16 +02005894/* Send UI frame from MS and expect it to arrive as RLL UNITDATA IND on Abis */
Vadim Yanitskiy8d8f91c2018-10-04 06:19:45 +07005895private function f_unitdata_mo(
Vadim Yanitskiy98e03152018-10-03 18:06:06 +07005896 RslLinkId link_id,
5897 octetstring l3,
5898 boolean exp_sacch := true, /* Should tolerate SACCH messages? */
Vadim Yanitskiyb9920502018-10-03 18:29:51 +07005899 boolean exp_any := false /* Should tolerate any other RSL messages? */
Vadim Yanitskiy98e03152018-10-03 18:06:06 +07005900) runs on ConnHdlr {
Harald Weltee613f962018-04-18 22:38:16 +02005901 timer T := 3.0;
5902 f_tx_lapdm(ts_LAPDm_UI(link_id.sapi, cr_MO_CMD, l3), link_id);
5903 T.start;
5904 /* Expect RLL UNITDATA IND on RSL side */
5905 alt {
5906 [] RSL.receive(tr_RSL_UNITDATA_IND(g_chan_nr, link_id, l3)) {
5907 setverdict(pass);
5908 }
Vadim Yanitskiye0b91a72018-10-04 15:44:40 +07005909 [exp_sacch] as_meas_res(verify_meas := false);
Vadim Yanitskiyad131c82018-10-04 06:18:59 +07005910 [] as_rsl_any_ind(exp_any);
Harald Weltee613f962018-04-18 22:38:16 +02005911 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02005912 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for UNIT_DATA_IND");
Harald Weltee613f962018-04-18 22:38:16 +02005913 }
Harald Weltee613f962018-04-18 22:38:16 +02005914 }
5915}
5916
Vadim Yanitskiy4d78a702018-10-03 03:59:34 +07005917/* Send I-frame from MS and expect it to arrive as RLL DATA IND on Abis */
5918private function f_data_mo(
5919 RslLinkId link_id,
5920 boolean p, uint3_t nr, uint3_t ns,
5921 octetstring l3,
5922 boolean exp_sacch := true, /* Should tolerate SACCH messages? */
Vadim Yanitskiyb9920502018-10-03 18:29:51 +07005923 boolean exp_any := false /* Should tolerate any other RSL messages? */
Vadim Yanitskiy4d78a702018-10-03 03:59:34 +07005924) runs on ConnHdlr {
5925 timer T := 3.0;
5926 f_tx_lapdm(ts_LAPDm_I(link_id.sapi, cr_MO_CMD, p, nr, ns, l3), link_id);
5927 T.start;
5928 /* Expect RLL DATA IND on RSL side */
5929 alt {
5930 [] RSL.receive(tr_RSL_DATA_IND(g_chan_nr, link_id, l3)) {
5931 setverdict(pass);
5932 }
Vadim Yanitskiye0b91a72018-10-04 15:44:40 +07005933 [exp_sacch] as_meas_res(verify_meas := false);
Vadim Yanitskiy4d78a702018-10-03 03:59:34 +07005934 [] as_rsl_any_ind(exp_any);
5935 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02005936 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for DATA_IND");
Vadim Yanitskiy4d78a702018-10-03 03:59:34 +07005937 }
5938 }
5939}
5940
Harald Weltee613f962018-04-18 22:38:16 +02005941/* Test channel activation with A5/n right from the beginning (like in assignment + hand-over) */
5942function f_TC_chan_act_encr(charstring id) runs on ConnHdlr {
5943 f_l1_tune(L1CTL);
5944 f_est_dchan(true);
5945
5946 /* now we actually need to transmit some data both ways to check if the encryption works */
5947 var L1ctlDlMessage dl;
5948
Stefan Sperling603d98e2018-07-25 16:47:28 +02005949 var octetstring l3 := f_rnd_octstring(20);
Harald Weltee613f962018-04-18 22:38:16 +02005950 var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0));
5951
5952 /* send UNITDATA_REQ from BTS to MS and expect it to arrive */
5953 f_unitdata_mt(link_id, l3);
5954
5955 /* Send UI frame from MS and expect it to arrive as RLL UNITDATA IND on Abis */
5956 f_unitdata_mo(link_id, l3);
5957
5958 /* release the channel */
5959 f_rsl_chan_deact();
5960 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
5961 f_rslem_unregister(0, g_chan_nr);
5962}
5963testcase TC_chan_act_a51() runs on test_CT {
5964 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
5965 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_1, f_rnd_octstring(8)));
5966 f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr));
5967}
5968testcase TC_chan_act_a52() runs on test_CT {
5969 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
5970 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_2, f_rnd_octstring(8)));
5971 f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr));
5972}
5973testcase TC_chan_act_a53() runs on test_CT {
5974 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
5975 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_3, f_rnd_octstring(8)));
5976 f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr));
5977}
5978
Eric Wildf1827a72019-05-28 17:37:35 +02005979/* Test channel activation with A5/n right from the beginning and RSL MODE MODIFY
5980 which should break the en/decryption on purpose by supplying a new key that is unknown to the MS*/
5981function f_TC_rsl_modify_encr(charstring id) runs on ConnHdlr {
5982 f_l1_tune(L1CTL);
5983 f_est_dchan(true);
5984
5985 /* now we actually need to transmit some data both ways to check if the encryption works */
5986 var L1ctlDlMessage dl;
5987
5988 var octetstring l3 := f_rnd_octstring(20);
5989 var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0));
5990
5991 /* send UNITDATA_REQ from BTS to MS and expect it to arrive */
5992 f_unitdata_mt(link_id, l3);
5993
5994 /* Send UI frame from MS and expect it to arrive as RLL UNITDATA IND on Abis */
5995 f_unitdata_mo(link_id, l3);
5996
5997 var RSL_Message rsl;
5998 rsl := valueof(ts_RSL_MODE_MODIFY_REQ(g_chan_nr, valueof(ts_RSL_ChanMode_SIGN(false))));
5999
6000 /* modify key to break proper encryption */
6001 g_pars.encr.key := f_rnd_octstring(8);
6002 var RSL_IE ei := valueof(t_RSL_IE(RSL_IE_ENCR_INFO, RSL_IE_Body:{encr_info := g_pars.encr}));
6003 rsl.ies := rsl.ies & { ei };
6004 RSL.send(rsl);
6005
6006 timer T0 := 1.0;
6007 T0.start;
6008 /* Expect RSL MODIFY ACK */
6009 alt {
6010 [] RSL.receive(tr_RSL_MODE_MODIFY_ACK(g_chan_nr)) {}
6011 [] RSL.receive(tr_RSL_MODE_MODIFY_NACK(g_chan_nr, ?)) {
6012 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,"MODE MODIFY NACK");
6013 }
6014 [] T0.timeout {
6015 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for MODE MODIFY (N)ACK");
6016 }
6017 }
6018
6019 var octetstring l3msg := f_rnd_octstring(15);
6020 timer T1 := 3.0;
6021 /* Send UI frame from MS, do not expect it to arrive as RLL UNITDATA IND on Abis
6022 due to broken encryption */
6023 f_tx_lapdm(ts_LAPDm_UI(link_id.sapi, cr_MO_CMD, l3msg), link_id);
6024 T1.start;
6025 alt {
6026 [] RSL.receive(tr_RSL_UNITDATA_IND(g_chan_nr, link_id, l3msg)) {
6027 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "BTS shouldn't be able to decrypt after key change")
6028 }
6029 [] T1.timeout {
6030 setverdict(pass);
6031 }
6032 }
6033
6034 /* release the channel */
6035 f_rsl_chan_deact();
6036 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
6037 f_rslem_unregister(0, g_chan_nr);
6038}
6039testcase TC_rsl_modify_encr() runs on test_CT {
6040 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
6041 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_1, f_rnd_octstring(8)));
6042 f_testmatrix_each_chan(pars, refers(f_TC_rsl_modify_encr));
6043}
Harald Weltee613f962018-04-18 22:38:16 +02006044
6045/* Test unencrypted channel activation followed by explicit ENCR CMD later */
6046function f_TC_encr_cmd(charstring id) runs on ConnHdlr {
6047 /* L3 payload doesn't matter, as it is passed transparently */
6048 var BIT3 l3_alg_id := f_alg_id_to_l3(g_pars.encr.alg_id);
6049 var octetstring l3 := enc_PDU_ML3_NW_MS(valueof(ts_RRM_CiphModeCmd(l3_alg_id)));
6050 var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0));
6051
6052 f_l1_tune(L1CTL);
6053
6054 /* first establish a dedicated channel in the clear */
6055 f_est_dchan(false);
6056
6057 /* Establish ABM */
6058 f_est_rll_mo(link_id.sapi, link_id, '23420815'O);
6059
6060 /* then send the RSL ENCR CMD with an actual RR CIPH MOD CMD inside */
6061 RSL.send(ts_RSL_ENCR_CMD(g_chan_nr, link_id, g_pars.encr.alg_id, g_pars.encr.key, l3));
6062 /* expect the L3 to arrive still unencrypted on the MS side */
6063 f_l1_exp_lapdm(tr_LAPDm_I(link_id.sapi, cr_MT_CMD, ?, ?, ?, l3));
6064
6065 /* configure L1 to apply ciphering */
6066 var uint8_t alg_id := f_alg_id_to_l1ctl(g_pars.encr.alg_id);
6067 f_L1CTL_CRYPTO_REQ(L1CTL, g_pars.chan_nr, alg_id, g_pars.encr.key);
6068
Vadim Yanitskiy4d78a702018-10-03 03:59:34 +07006069 /* send first ciphered I-frame in response and expect it on RSL */
6070 f_data_mo(link_id, true, 1, 0, '0a0b0c0d'O, exp_sacch := true);
Harald Weltee613f962018-04-18 22:38:16 +02006071
6072 /* now the BTS code should have detected the first properly encrypted uplink I-frame,
6073 * and hence enable encryption also on the downlink */
6074
6075 /* expect bi-directional communication work in encrypted mode */
6076 f_unitdata_mo(link_id, f_rnd_octstring(15));
6077 f_unitdata_mt(link_id, f_rnd_octstring(15));
6078
6079 /* release the channel */
6080 f_rsl_chan_deact();
6081 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
6082 f_rslem_unregister(0, g_chan_nr);
6083}
6084testcase TC_encr_cmd_a51() runs on test_CT {
6085 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
6086 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_1, f_rnd_octstring(8)));
6087 f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd));
6088}
6089testcase TC_encr_cmd_a52() runs on test_CT {
6090 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
6091 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_2, f_rnd_octstring(8)));
6092 f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd));
6093}
6094testcase TC_encr_cmd_a53() runs on test_CT {
6095 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
6096 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_3, f_rnd_octstring(8)));
6097 f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd));
6098}
6099
6100private function f_assert_lapdm(octetstring enc, template LapdmFrame exp_match, charstring name := "") {
6101 var LapdmFrame lf;
6102 var octetstring reenc;
6103
6104 /* decode the LAPDm frame */
6105 if (ischosen(exp_match.ab)) {
6106 lf.ab := dec_LapdmFrameAB(enc);
6107 } else {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02006108 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "unsupported frame type");
Harald Weltee613f962018-04-18 22:38:16 +02006109 }
6110
6111 /* check if decoder result matches expectation */
6112 if (not match(lf, exp_match)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02006113 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str(name, ": decoded LAPDm doesn't match"));
Harald Weltee613f962018-04-18 22:38:16 +02006114 } else {
6115 log(name, ": matched");
6116 setverdict(pass);
6117 }
6118
6119 /* test if re-encoded frame equals original input */
6120 reenc := enc_LapdmFrame(lf);
6121 if (enc != reenc) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02006122 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str(name, ": re-encoded LAPDm frame doesn't match"));
Harald Weltee613f962018-04-18 22:38:16 +02006123 } else {
6124 setverdict(pass);
6125 }
6126}
6127
6128testcase TC_lapdm_selftest() runs on test_CT {
6129 f_assert_lapdm('030301'O, tr_LAPDm_UI(0, true, ''O), "ui_s0_empty");
6130 f_assert_lapdm('0F0301'O, tr_LAPDm_UI(3, true, ''O), "ui_s3_empty");
6131 f_assert_lapdm('013F01'O, tr_LAPDm_SABM(0, false, true, ''O), "sabm_s0_empty");
6132 f_assert_lapdm('013F1123420815'O, tr_LAPDm_SABM(0, false, true, '23420815'O), "sabm_s0_l3");
6133 f_assert_lapdm('03E101'O, tr_LAPDm_RR(0, true, false, 7), "rr_s0_7");
6134 f_assert_lapdm('03000d063505'O, tr_LAPDm_I(0, true, false, 0, 0, '063505'O), "I/0/0");
6135 f_assert_lapdm('03e00d063505'O, tr_LAPDm_I(0, true, false, 7, 0, '063505'O), "I/7/0");
6136}
6137
Stefan Sperling4880be42018-08-07 18:12:59 +02006138/***********************************************************************
6139 * DTX Related (see GSM 05.08, section 8.3)
6140 ***********************************************************************/
6141
6142/* XXX These functions must be kept in sync with g_AllChannels defined on test_CT. */
6143function f_g_chan_is_tchf() runs on ConnHdlr return boolean {
6144 return (g_chan_nr == valueof(ts_RslChanNr_Bm(1)) or
6145 g_chan_nr == valueof(ts_RslChanNr_Bm(2)) or
6146 g_chan_nr == valueof(ts_RslChanNr_Bm(3)) or
6147 g_chan_nr == valueof(ts_RslChanNr_Bm(4)));
6148}
6149function f_g_chan_is_tchh() runs on ConnHdlr return boolean {
6150 return (g_chan_nr == valueof(ts_RslChanNr_Lm(5,0)) or
6151 g_chan_nr == valueof(ts_RslChanNr_Lm(5,1)));
6152}
6153function f_g_chan_is_sdcch4() runs on ConnHdlr return boolean {
6154 return (g_chan_nr == valueof(ts_RslChanNr_SDCCH4(0,0)) or
6155 g_chan_nr == valueof(ts_RslChanNr_SDCCH4(0,1)) or
6156 g_chan_nr == valueof(ts_RslChanNr_SDCCH4(0,2)) or
6157 g_chan_nr == valueof(ts_RslChanNr_SDCCH4(0,3)));
6158}
6159function f_g_chan_is_sdcch8() runs on ConnHdlr return boolean {
6160 return (g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,0)) or
6161 g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,1)) or
6162 g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,2)) or
6163 g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,3)) or
6164 g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,4)) or
6165 g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,5)) or
6166 g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,6)) or
6167 g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,7)));
6168}
6169
6170function f_test_l2_fill_frames(boolean dtxd) runs on ConnHdlr {
6171 var L1ctlDlMessage dl;
6172 var octetstring l2_fill_frame := '0303012B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B'O;
6173 var octetstring l2_fill_frame_sacch := substr(l2_fill_frame, 0, lengthof(l2_fill_frame) - 2);
6174 var GsmFrameNumber first_fn;
6175 var boolean is_first_frame := true;
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02006176 var integer nfill_frames_sacch := 0;
6177 var integer nfill_frames_nonsacch := 0;
6178 var integer expected_fill_frames := 10000; /* initial value causes test failure if not overridden */
Stefan Sperling4880be42018-08-07 18:12:59 +02006179 /* Frames numbers (mod 104) for which a fill frame is expected on TCHF if DTX is enabled. */
6180 var Integers required_tdma_frames_dtx_tchf := { 52, 53, 54, 55, 56, 57, 58, 59 };
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02006181 const integer frame_dtx_tchf_mod := 104;
6182 /* Frame numbers (mod 104) for which a fill frame is expected at the L1SAP level,
6183 * which operates in terms of blocks rather than frames. */
6184 var Integers required_tdma_blocks_dtx_tchf := { 52, 56 };
6185 const integer block_dtx_tchf_mod := 26;
Stefan Sperling4880be42018-08-07 18:12:59 +02006186 timer T := 5.0;
6187
6188 f_l1_tune(L1CTL);
6189 RSL.clear;
6190 L1CTL.clear;
6191
6192 /* activate TCHF signalling channel */
6193 f_est_dchan(false);
6194
6195 T.start;
6196 alt {
6197 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, ?)) -> value dl {
6198 var GsmFrameNumber fn := dl.dl_info.frame_nr;
6199 var octetstring l2 := dl.payload.data_ind.payload;
6200
6201 if (is_first_frame) {
6202 is_first_frame := false;
6203 first_fn := dl.dl_info.frame_nr;
6204 }
6205
6206 if (dl.dl_info.link_id.c == SACCH) {
6207 l2 := substr(l2, 2, lengthof(l2) - 2); /* remove L1 header */
6208 if (not match(l2_fill_frame_sacch, l2)) {
6209 repeat;
6210 }
6211 } else if (not match(l2_fill_frame, l2)) {
6212 repeat;
6213 }
6214
6215 if (dtxd) {
6216 if (not f_g_chan_is_tchf()) {
6217 T.stop;
6218 f_rsl_chan_deact();
6219 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02006220 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 +02006221 }
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02006222 if (fn > first_fn + frame_dtx_tchf_mod) {
Stefan Sperling4880be42018-08-07 18:12:59 +02006223 T.stop;
6224 f_rsl_chan_deact();
6225 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02006226
6227 /* With DTX enabled we can expect at least 3 fill frames for every 104 frames.
6228 * 2 SACCH, 1 TCH/F */
6229 expected_fill_frames := 3;
6230
6231 if (nfill_frames_sacch + nfill_frames_nonsacch < expected_fill_frames) {
6232 log("received only ", nfill_frames_sacch, "+", nfill_frames_nonsacch,
6233 " (SACCH+other) out of ", expected_fill_frames, " expected fill frames");
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02006234 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Not enough fill frames received");
Stefan Sperling4880be42018-08-07 18:12:59 +02006235 } else {
6236 setverdict(pass);
6237 }
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02006238 } else {
6239 if (dl.dl_info.link_id.c == SACCH) {
6240 nfill_frames_sacch := nfill_frames_sacch + 1;
Stefan Sperling4880be42018-08-07 18:12:59 +02006241 repeat;
6242 }
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02006243 /* On DTX TCH/F channels, fill frames occur only for specific frame numbers mod 104.
6244 * Furthermore, the L1SAP layer gives us frame numbers for the start of a block so
6245 * we should only see the subset of frames numbers which correspond to a block boundary.
6246 * TCH/F blocks are defined to start at 0,4,8,13,17,21 (modulo 26) */
6247 for (var integer i := 0; i < lengthof(required_tdma_blocks_dtx_tchf); i := i + 1) {
6248 if (fn mod frame_dtx_tchf_mod == required_tdma_blocks_dtx_tchf[i]) {
6249 nfill_frames_nonsacch := nfill_frames_nonsacch + 1;
6250 repeat;
6251 }
6252 }
6253 log("Received DTX TCH fill frame with bad frame number: ", fn,
6254 " (mod ", frame_dtx_tchf_mod, ": ", fn mod frame_dtx_tchf_mod, ")",
6255 " (mod ", block_dtx_tchf_mod, ": ", fn mod block_dtx_tchf_mod, ")");
6256 f_rsl_chan_deact();
6257 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02006258 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected L2 fill frame received on Um");
Stefan Sperling4880be42018-08-07 18:12:59 +02006259 }
Stefan Sperling4880be42018-08-07 18:12:59 +02006260 } else {
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02006261 if (dl.dl_info.link_id.c == SACCH) {
6262 nfill_frames_sacch := nfill_frames_sacch + 1;
6263 } else {
6264 nfill_frames_nonsacch := nfill_frames_nonsacch + 1;
6265 }
6266 if (fn > first_fn + frame_dtx_tchf_mod) {
Stefan Sperling4880be42018-08-07 18:12:59 +02006267 T.stop;
6268 if (f_g_chan_is_tchf()) {
6269 /* Without DTX we can expect 25 fill frames for every 104 frames.
6270 * (24 FACCH + 1 SACCH filling) */
6271 expected_fill_frames := 25;
6272 } else if (f_g_chan_is_tchh()) {
6273 /* We can expect 2 fill frames for every 104 frames. */
6274 expected_fill_frames := 2;
6275 } else if (f_g_chan_is_sdcch4() or f_g_chan_is_sdcch8()) {
6276 /* We can expect 5 fill frames for every 104 frames. */
6277 expected_fill_frames := 5;
6278 } else {
6279 f_rsl_chan_deact();
6280 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02006281 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unknown channel type");
Stefan Sperling4880be42018-08-07 18:12:59 +02006282 }
6283
6284 f_rsl_chan_deact();
6285 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02006286
6287 if (nfill_frames_sacch + nfill_frames_nonsacch >= expected_fill_frames) {
Stefan Sperling4880be42018-08-07 18:12:59 +02006288 setverdict(pass);
6289 } else {
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02006290 log("received only ", nfill_frames_sacch, "+", nfill_frames_nonsacch,
6291 " (SACCH+other) out of ", expected_fill_frames, " expected fill frames");
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02006292 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Not enough fill frames received");
Stefan Sperling4880be42018-08-07 18:12:59 +02006293 }
6294 } else {
6295 repeat;
6296 }
6297 }
6298 }
6299 [] L1CTL.receive { repeat; }
6300 [] T.timeout {
6301 f_rsl_chan_deact();
6302 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02006303 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for L2 fill frames on Um");
Stefan Sperling4880be42018-08-07 18:12:59 +02006304 }
6305 }
6306}
6307
6308function f_TC_tch_sign_l2_fill_frame(charstring id) runs on ConnHdlr {
6309 f_test_l2_fill_frames(false);
6310}
6311
6312function f_TC_tch_sign_l2_fill_frame_dtxd(charstring id) runs on ConnHdlr {
6313 f_test_l2_fill_frames(true);
6314}
6315
6316function f_tch_sign_l2_fill_frame(boolean dtxd) runs on test_CT {
6317 var ConnHdlr vc_conn;
6318 var ConnHdlrPars pars;
6319 pars.t_guard := 60.0;
Harald Welte10474062019-05-30 16:48:17 +02006320 f_init();
Stefan Sperling4880be42018-08-07 18:12:59 +02006321 for (var integer i := 0; i < sizeof(g_AllChannels); i := i + 1) {
6322 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN(dtxd)));
6323 if (dtxd) {
6324 if (i >= 4) { /* DTX is only allowed on TCH/F */
6325 break;
6326 }
6327 vc_conn := f_start_handler(refers(f_TC_tch_sign_l2_fill_frame_dtxd), pars);
6328 } else {
6329 vc_conn := f_start_handler(refers(f_TC_tch_sign_l2_fill_frame), pars);
6330 }
6331 vc_conn.done;
6332 }
6333}
6334
6335/* Verify that L2 fill frames are sent on TCH in signaling mode if
6336 * there is nothing to transmit while DTX is disabled on downlink. */
6337testcase TC_tch_sign_l2_fill_frame() runs on test_CT {
6338 f_tch_sign_l2_fill_frame(false);
6339}
6340
6341/* Verify that particular L2 fill frames are sent on TCH in signaling mode if
6342 * there is nothing to transmit while DTX is enabled on downlink. */
6343testcase TC_tch_sign_l2_fill_frame_dtxd() runs on test_CT {
6344 f_tch_sign_l2_fill_frame(true);
6345}
Harald Welte0472ab42018-03-12 15:02:26 +01006346
Stefan Sperling0ec1c262018-10-15 15:12:52 +02006347testcase TC_chopped_ipa_ping() runs on test_CT {
6348 IPA_Testing.f_run_TC_chopped_ipa_ping(mp_rsl_ip, mp_rsl_port, LISTEN_FOR_CLIENT);
6349}
6350
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02006351testcase TC_chopped_ipa_payload() runs on test_CT {
6352 IPA_Testing.f_run_TC_chopped_ipa_payload(mp_rsl_ip, mp_rsl_port, LISTEN_FOR_CLIENT);
6353}
6354
Harald Welte0472ab42018-03-12 15:02:26 +01006355/* test generation of RLL ERR IND based on Um errors (TS 48.058 3.9) */
6356/* protocol error as per 44.006 */
6357/* link layer failure (repetition of I-frame N200 times without ACK */
6358/* repetition of SABM or DISC N200 times without ACK */
6359/* receptiom of SABM in multi-frame established state */
6360
6361
Harald Welte68e495b2018-02-25 00:05:57 +01006362/* TODO Areas:
6363
6364* channel activation
6365** with BS_Power / MS_Power, bypassing power control loop
6366** on primary vs. secondary TRX
Harald Welte68e495b2018-02-25 00:05:57 +01006367** with timing advance from initial activation on
6368* mode modify
6369** encryption
6370** multirate
6371* check DEACTIVATE SACCH
Harald Welte68e495b2018-02-25 00:05:57 +01006372** unsupported algorithm
6373* handover detection
Harald Welte68e495b2018-02-25 00:05:57 +01006374* BS Power Control
6375* Physical Context
Harald Welte68e495b2018-02-25 00:05:57 +01006376* RF resource ind
Harald Welte68e495b2018-02-25 00:05:57 +01006377* error handling
Harald Welte68e495b2018-02-25 00:05:57 +01006378** IE duplicated?
Harald Welte883340c2018-02-28 18:59:29 +01006379* PCU interface
Harald Welte883340c2018-02-28 18:59:29 +01006380** DATA_IND from BTS->PCU
6381** verification of PCU-originated DATA_REQ arrival on Um/MS side
Harald Welte68e495b2018-02-25 00:05:57 +01006382
6383*/
Harald Welte70767382018-02-21 12:16:40 +01006384
6385control {
6386 execute( TC_chan_act_stress() );
6387 execute( TC_chan_act_react() );
6388 execute( TC_chan_deact_not_active() );
6389 execute( TC_chan_act_wrong_nr() );
Harald Welte629cc6b2018-03-11 17:19:05 +01006390 execute( TC_deact_sacch() );
Harald Welteea17b912018-03-11 22:29:31 +01006391 execute( TC_sacch_filling() );
6392 execute( TC_sacch_info_mod() );
Harald Welte075d84c2018-03-12 13:07:24 +01006393 execute( TC_sacch_multi() );
Harald Welte55700662018-03-12 13:15:43 +01006394 execute( TC_sacch_multi_chg() );
Harald Weltec8d363c2019-05-19 20:36:48 +02006395 execute( TC_sacch_chan_act() );
Harald Welte8b01c792019-05-19 22:51:25 +02006396 execute( TC_sacch_chan_act_ho_async() );
6397 execute( TC_sacch_chan_act_ho_sync() );
Harald Welte8c24c2b2018-02-26 08:31:31 +01006398 execute( TC_rach_content() );
6399 execute( TC_rach_count() );
Harald Welte54a2a2d2018-02-26 09:14:05 +01006400 execute( TC_rach_max_ta() );
Vadim Yanitskiy7c2c10c2019-05-31 20:42:01 +07006401 execute( TC_ho_rach() );
Harald Welte3453ab42019-05-24 21:19:58 +02006402 execute( TC_rach_load_idle_thresh0() );
6403 execute( TC_rach_load_idle_below_thresh() );
6404 execute( TC_rach_load_count() );
Harald Welte70767382018-02-21 12:16:40 +01006405 execute( TC_meas_res_sign_tchf() );
6406 execute( TC_meas_res_sign_tchh() );
6407 execute( TC_meas_res_sign_sdcch4() );
6408 execute( TC_meas_res_sign_sdcch8() );
Harald Welte685d5982018-02-27 20:42:05 +01006409 execute( TC_meas_res_sign_tchh_toa256() );
Eric Wildae8f2622019-06-18 17:05:11 +02006410 execute( TC_rsl_bs_pwr_static_ass() );
6411 execute( TC_rsl_bs_pwr_static_power_control() );
Philipp Maier4d1e9c92018-12-20 11:11:56 +01006412 execute( TC_rsl_ms_pwr_ctrl() );
Eric Wild280ccb82019-06-17 11:11:52 +02006413 execute( TC_rsl_ms_pwr_dyn_active() );
Eric Wild095024b2019-06-17 15:08:57 +02006414 execute( TC_rsl_ms_pwr_dyn_active2() );
Eric Wild61edb7e2019-06-03 12:38:31 +02006415 execute( TC_rsl_ms_pwr_dyn_up() );
6416 execute( TC_rsl_ms_pwr_dyn_down() );
6417 execute( TC_rsl_ms_pwr_dyn_ass_updown() );
6418 execute( TC_rsl_ms_pwr_dyn_max() );
Eric Wilde57e1a62019-05-28 13:30:55 +02006419 execute( TC_rsl_chan_initial_ms_pwr() );
Eric Wild6833cc92019-05-23 19:34:44 +02006420 execute( TC_rsl_chan_initial_ta() );
Eric Wildf1827a72019-05-28 17:37:35 +02006421 execute( TC_rsl_modify_encr() );
Harald Welte70767382018-02-21 12:16:40 +01006422 execute( TC_conn_fail_crit() );
Harald Welte68e495b2018-02-25 00:05:57 +01006423 execute( TC_paging_imsi_80percent() );
6424 execute( TC_paging_tmsi_80percent() );
6425 execute( TC_paging_imsi_200percent() );
6426 execute( TC_paging_tmsi_200percent() );
Harald Welte01d982c2018-02-25 01:31:40 +01006427 execute( TC_rsl_protocol_error() );
6428 execute( TC_rsl_mand_ie_error() );
6429 execute( TC_rsl_ie_content_error() );
Harald Welte48494ca2018-02-25 16:59:50 +01006430 execute( TC_si_sched_default() );
Harald Welte0cae4552018-03-09 22:20:26 +01006431 execute( TC_si_sched_1() );
Harald Welte48494ca2018-02-25 16:59:50 +01006432 execute( TC_si_sched_2bis() );
6433 execute( TC_si_sched_2ter() );
6434 execute( TC_si_sched_2ter_2bis() );
6435 execute( TC_si_sched_2quater() );
6436 execute( TC_si_sched_13() );
6437 execute( TC_si_sched_13_2bis_2ter_2quater() );
Harald Weltea871a382018-02-25 02:03:14 +01006438 execute( TC_ipa_dlcx_not_active() );
Harald Weltea3f1df92018-02-25 12:49:55 +01006439 execute( TC_ipa_crcx_twice_not_active() );
6440 execute( TC_ipa_crcx_mdcx_dlcx_not_active() );
Harald Welte3ae11da2018-02-25 13:36:06 +01006441 execute( TC_ipa_crcx_mdcx_mdcx_dlcx_not_active() );
Harald Welte9912eb52018-02-25 13:30:15 +01006442 execute( TC_ipa_crcx_sdcch_not_active() );
Harald Welte883340c2018-02-28 18:59:29 +01006443
Pau Espin Pedrola14a8af2018-11-20 13:12:22 +01006444 if (mp_pcu_socket != "") {
6445 execute( TC_pcu_act_req() );
6446 execute( TC_pcu_act_req_wrong_ts() );
6447 execute( TC_pcu_act_req_wrong_bts() );
6448 execute( TC_pcu_act_req_wrong_trx() );
6449 execute( TC_pcu_deact_req() );
6450 execute( TC_pcu_deact_req_wrong_ts() );
6451 execute( TC_pcu_ver_si13() );
Harald Weltead033dc2019-05-25 17:28:16 +02006452 if (mp_l1_supports_gprs) {
6453 execute( TC_pcu_data_req_pdtch() );
6454 execute( TC_pcu_data_req_ptcch() );
Harald Welte7162a612019-05-26 12:56:09 +02006455 execute( TC_pcu_data_req_wrong_bts() );
6456 execute( TC_pcu_data_req_wrong_trx() );
6457 execute( TC_pcu_data_req_wrong_ts() );
6458 execute( TC_pcu_data_req_ts_inactive() );
Harald Weltead033dc2019-05-25 17:28:16 +02006459 }
Vadim Yanitskiy970b1532019-10-24 15:22:19 +07006460 execute( TC_pcu_ptcch() );
Pau Espin Pedrola14a8af2018-11-20 13:12:22 +01006461 execute( TC_pcu_data_req_agch() );
Harald Welte928622b2019-05-26 13:22:59 +02006462 execute( TC_pcu_data_req_pch() );
Pau Espin Pedrola14a8af2018-11-20 13:12:22 +01006463 execute( TC_pcu_data_req_imm_ass_pch() );
6464 execute( TC_pcu_rach_content() );
Vadim Yanitskiy51cbc102019-04-22 06:37:30 +07006465 execute( TC_pcu_ext_rach_content() );
Vadim Yanitskiya2c68e82019-07-03 13:07:20 +07006466 execute( TC_pcu_data_ind_lqual_cb() );
Pau Espin Pedrola14a8af2018-11-20 13:12:22 +01006467 execute( TC_pcu_paging_from_rsl() );
Harald Welted66c9b82019-05-25 09:03:15 +02006468 execute( TC_pcu_time_ind() );
Harald Welte4832c862019-05-25 14:57:18 +02006469 execute( TC_pcu_rts_req() );
Harald Welte07bd2d22019-05-25 11:03:30 +02006470 execute( TC_pcu_oml_alert() );
Harald Welteeaa9a862019-05-26 23:01:08 +02006471 execute( TC_pcu_rr_suspend() );
Harald Weltea2e0e942019-05-27 18:12:53 +02006472 execute( TC_pcu_socket_connect_multi() );
Harald Weltec8effb72019-05-27 18:23:04 +02006473 execute( TC_pcu_socket_reconnect() );
Harald Weltebe030482019-05-27 22:29:35 +02006474 execute( TC_pcu_socket_noconnect_nosi3gprs() );
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07006475 execute( TC_pcu_socket_noconnect_nosi4gprs() );
Harald Weltebe030482019-05-27 22:29:35 +02006476 execute( TC_pcu_socket_connect_si3gprs() );
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07006477 execute( TC_pcu_socket_connect_si4gprs() );
Harald Weltebe030482019-05-27 22:29:35 +02006478 execute( TC_pcu_socket_disconnect_nosi3gprs() );
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07006479 execute( TC_pcu_socket_disconnect_nosi4gprs() );
Oliver Smithf5239c72019-08-28 10:01:25 +02006480 execute( TC_pcu_socket_verify_info_ind() );
Philipp Maier15cd6872020-01-08 13:41:41 +01006481 execute( TC_dyn_osmo_pdch_act_deact() );
6482 execute( TC_dyn_osmo_pdch_double_act() );
6483 execute( TC_dyn_ipa_pdch_act_deact() );
6484 execute( TC_dyn_ipa_pdch_act_tchf_act_nack() );
6485
Pau Espin Pedrola14a8af2018-11-20 13:12:22 +01006486 } else {
6487 log("PCU socket path not available, skipping PCU tests");
6488 }
Harald Welte3d04ae62018-04-04 20:29:05 +02006489
Harald Welte3d04ae62018-04-04 20:29:05 +02006490 execute( TC_dyn_osmo_pdch_unsol_deact() );
Harald Welte3d04ae62018-04-04 20:29:05 +02006491 execute( TC_dyn_osmo_pdch_tchf_act() );
6492 execute( TC_dyn_osmo_pdch_tchh_act() );
Harald Welte9bbbfb52018-04-05 09:33:19 +02006493 execute( TC_dyn_ipa_pdch_tchf_act() );
6494 execute( TC_dyn_ipa_pdch_tchf_act_pdch_act_nack() );
Harald Welte0472ab42018-03-12 15:02:26 +01006495
6496 execute( TC_rll_est_ind() );
6497 execute( TC_rll_est_req_DCCH_3() );
6498 execute( TC_rll_est_req_ACCH_3() );
6499 execute( TC_rll_rel_ind_DCCH_0() );
6500 execute( TC_rll_rel_ind_DCCH_3() );
6501 execute( TC_rll_rel_ind_ACCH_0() );
6502 execute( TC_rll_rel_ind_ACCH_3() );
6503 execute( TC_rll_rel_req() );
6504 execute( TC_rll_unit_data_req_DCCH() );
6505 execute( TC_rll_unit_data_req_ACCH() );
6506 execute( TC_rll_unit_data_ind_DCCH() );
6507 execute( TC_rll_unit_data_ind_ACCH() );
Harald Weltee613f962018-04-18 22:38:16 +02006508
6509 execute( TC_chan_act_a51() );
6510 execute( TC_chan_act_a52() );
6511 execute( TC_chan_act_a53() );
6512 execute( TC_encr_cmd_a51() );
6513 execute( TC_encr_cmd_a52() );
6514 execute( TC_encr_cmd_a53() );
6515
Harald Welteee25aae2019-05-19 14:32:37 +02006516 execute( TC_err_rep_wrong_mdisc() );
6517 execute( TC_err_rep_wrong_msg_type() );
6518 execute( TC_err_rep_wrong_sequence() );
6519
Harald Weltee613f962018-04-18 22:38:16 +02006520 execute( TC_lapdm_selftest() );
Stefan Sperling4880be42018-08-07 18:12:59 +02006521
6522 execute( TC_tch_sign_l2_fill_frame() );
6523 execute( TC_tch_sign_l2_fill_frame_dtxd() );
Stefan Sperling0ec1c262018-10-15 15:12:52 +02006524
6525 execute( TC_chopped_ipa_ping() );
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02006526 execute( TC_chopped_ipa_payload() );
Harald Welte70767382018-02-21 12:16:40 +01006527}
6528
6529
6530}