blob: 99a8ef9e5a7f7364d65bccbd2bac413b68990335 [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);
Vadim Yanitskiy493abe72020-05-25 22:03:48 +0700318 RSL_CCHAN.send(ts_ASP_RSL_UD(ts_RSL_BCCH_INFO(rsl_si_type, si_enc)));
Harald Weltef10153f2018-02-25 16:34:05 +0100319}
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 Welte70767382018-02-21 12:16:40 +0100496private altstep as_Tguard() runs on ConnHdlr {
497 [] g_Tguard.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200498 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Tguard timeout");
Harald Welte70767382018-02-21 12:16:40 +0100499 }
500}
501
Harald Welte990a3612019-05-27 14:02:13 +0200502friend function f_l1_tune(L1CTL_PT L1CTL, L1ctlCcchMode ccch_mode := CCCH_MODE_COMBINED) {
503 f_L1CTL_FBSB(L1CTL, { false, mp_trx0_arfcn }, ccch_mode, mp_rxlev_exp);
Harald Welte70767382018-02-21 12:16:40 +0100504}
505
Vadim Yanitskiy2f01fbd2019-06-01 01:32:48 +0700506private function f_trxc_fake_rssi(TRXC_RSSI rssi) runs on ConnHdlr {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100507 var TrxcMessage ret;
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +0700508 ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, valueof(ts_TRXC_FAKE_RSSI(rssi)));
Harald Welte70767382018-02-21 12:16:40 +0100509}
510
Vadim Yanitskiydc8db922019-06-04 21:58:15 +0700511private function f_trxc_fake_toffs256(int16_t toffs256) runs on ConnHdlr {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100512 var TrxcMessage ret;
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +0700513 ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, valueof(ts_TRXC_FAKE_TIMING(toffs256)));
Harald Welte70767382018-02-21 12:16:40 +0100514}
515
516/* first function started in ConnHdlr component */
517private function f_handler_init(void_fn fn, charstring id, ConnHdlrPars pars)
518runs on ConnHdlr {
519 g_pars := pars;
520 g_chan_nr := pars.chan_nr;
521
522 map(self:L1CTL, system:L1CTL);
523 f_connect_reset(L1CTL);
524
Harald Welted48c0c72019-06-05 10:01:15 +0200525 if (mp_bts_trxc_port != -1 and BTS_TRXC.checkstate("Mapped")) {
Vadim Yanitskiyf4e997c2019-06-04 21:40:33 +0700526 f_init_trxc(BTS_TRXC, id, g_bts_trxc_conn_id);
Harald Welte84271622018-03-10 17:21:03 +0100527 }
Harald Welte70767382018-02-21 12:16:40 +0100528
529 g_Tguard.start(pars.t_guard);
530 activate(as_Tguard());
531
532 f_rslem_register(0, pars.chan_nr);
533
534 /* call the user-supplied test case function */
535 fn.apply(id);
536}
537
Harald Welteb1726c92018-03-30 11:56:38 +0200538function f_rsl_transceive_ret(template RSL_Message tx, template RSL_Message exp_rx, charstring id,
539 boolean ignore_other := false)
540runs on ConnHdlr return RSL_Message {
541 var RSL_Message rx;
Harald Welte1eba3742018-02-25 12:48:14 +0100542 timer T := 3.0;
543 RSL.send(tx);
544 T.start;
Harald Welte70767382018-02-21 12:16:40 +0100545 alt {
Harald Welteb1726c92018-03-30 11:56:38 +0200546 [] RSL.receive(exp_rx) -> value rx {
Harald Welte1eba3742018-02-25 12:48:14 +0100547 T.stop;
548 setverdict(pass);
Harald Welte70767382018-02-21 12:16:40 +0100549 }
Harald Welte1eba3742018-02-25 12:48:14 +0100550 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200551 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout expecting " & id);
Harald Welte1eba3742018-02-25 12:48:14 +0100552 }
Harald Welte21240e62018-03-11 21:43:35 +0100553 [not ignore_other] as_l1_sacch();
554 [not ignore_other] as_meas_res();
555 [not ignore_other] as_l1_dcch();
556 [not ignore_other] RSL.receive {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200557 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RSL message received");
Harald Welte70767382018-02-21 12:16:40 +0100558 }
Harald Welte21240e62018-03-11 21:43:35 +0100559 [ignore_other] RSL.receive { repeat; }
Harald Welte70767382018-02-21 12:16:40 +0100560 }
Harald Welteb1726c92018-03-30 11:56:38 +0200561 return rx;
562}
563
564function f_rsl_transceive(template RSL_Message tx, template RSL_Message exp_rx, charstring id,
565 boolean ignore_other := false)
566runs on ConnHdlr {
567 var RSL_Message rx := f_rsl_transceive_ret(tx, exp_rx, id, ignore_other);
Harald Welte70767382018-02-21 12:16:40 +0100568}
569
Harald Welte8b01c792019-05-19 22:51:25 +0200570function f_rsl_chan_act(RSL_IE_ChannelMode mode, boolean encr_enable := false, RSL_IE_List more_ies := {},
571 RSL_IE_ActivationType act_type := t_RSL_IE_ActType_IA) runs on ConnHdlr {
572 var RSL_Message ch_act := valueof(ts_RSL_CHAN_ACT(g_chan_nr, mode, act_type));
Harald Weltee613f962018-04-18 22:38:16 +0200573 if (encr_enable) {
574 /* append encryption related IEs, if requested */
575 var RSL_IE_EncryptionInfo encr_info;
576 encr_info := valueof(ts_RSL_IE_EncrInfo(g_pars.encr.alg_id, g_pars.encr.key));
577 ch_act.ies := ch_act.ies & { valueof(t_RSL_IE(RSL_IE_ENCR_INFO, RSL_IE_Body:{encr_info :=
578encr_info})) };
579 }
Harald Weltec8d363c2019-05-19 20:36:48 +0200580 ch_act.ies := ch_act.ies & more_ies;
Harald Weltee613f962018-04-18 22:38:16 +0200581 f_rsl_transceive(ch_act, tr_RSL_CHAN_ACT_ACK(g_chan_nr), "RSL CHAN ACT");
Harald Welte1eba3742018-02-25 12:48:14 +0100582}
583
Harald Welte70767382018-02-21 12:16:40 +0100584function f_rsl_chan_deact() runs on ConnHdlr {
Harald Welte1eba3742018-02-25 12:48:14 +0100585 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 +0100586 "RF CHAN REL", true);
Harald Welte70767382018-02-21 12:16:40 +0100587}
588
Harald Welte2f2b2b72019-05-31 22:24:57 +0200589friend template ConnHdlrPars t_Pars(template RslChannelNr chan_nr,
Harald Welte70767382018-02-21 12:16:40 +0100590 template RSL_IE_ChannelMode chan_mode,
591 float t_guard := 20.0) := {
592 chan_nr := valueof(chan_nr),
593 chan_mode := valueof(chan_mode),
594 t_guard := t_guard,
595 l1_pars := {
596 dtx_enabled := false,
Harald Welte685d5982018-02-27 20:42:05 +0100597 toa256_enabled := false,
Harald Welte70767382018-02-21 12:16:40 +0100598 meas_ul := {
599 full := {
Pau Espin Pedrole9571aa2018-10-22 17:13:07 +0200600 rxlev := mp_ul_rxlev_exp,
Harald Welte70767382018-02-21 12:16:40 +0100601 rxqual := 0
602 },
603 sub := {
Pau Espin Pedrole9571aa2018-10-22 17:13:07 +0200604 rxlev := mp_ul_rxlev_exp,
Harald Welte70767382018-02-21 12:16:40 +0100605 rxqual := 0
606 }
607 },
Pau Espin Pedrol121724c2018-09-28 15:58:12 +0200608 timing_offset_256syms := mp_timing_offset_256syms_exp,
Harald Welte70767382018-02-21 12:16:40 +0100609 bs_power_level := 0,
Pau Espin Pedroled359cb2018-09-28 16:08:24 +0200610 ms_power_level := mp_ms_power_level_exp,
Pau Espin Pedrol121724c2018-09-28 15:58:12 +0200611 ms_actual_ta := mp_ms_actual_ta_exp
Harald Welte0472ab42018-03-12 15:02:26 +0100612 },
Harald Weltee613f962018-04-18 22:38:16 +0200613 spec := omit,
Eric Wild61edb7e2019-06-03 12:38:31 +0200614 encr := omit,
615 bts0_band := omit
Harald Welte70767382018-02-21 12:16:40 +0100616}
617
Harald Welte93640c62018-02-25 16:59:33 +0100618/***********************************************************************
619 * Channel Activation / Deactivation
620 ***********************************************************************/
621
Harald Welte70767382018-02-21 12:16:40 +0100622/* Stress test: Do 500 channel activations/deactivations in rapid succession */
623function f_TC_chan_act_stress(charstring id) runs on ConnHdlr {
624 for (var integer i := 0; i < 500; i := i+1) {
625 f_rsl_chan_act(g_pars.chan_mode);
626 f_rsl_chan_deact();
627 }
628 setverdict(pass);
629}
630testcase TC_chan_act_stress() runs on test_CT {
631 var ConnHdlr vc_conn;
632 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
Harald Welte10474062019-05-30 16:48:17 +0200633 f_init();
Harald Welte70767382018-02-21 12:16:40 +0100634 vc_conn := f_start_handler(refers(f_TC_chan_act_stress), pars);
635 vc_conn.done;
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200636 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +0100637}
638
639/* Test if re-activation of an already active channel fails as expected */
640function f_TC_chan_act_react(charstring id) runs on ConnHdlr {
641 f_rsl_chan_act(g_pars.chan_mode);
642 /* attempt to activate the same lchan again -> expect reject */
643 RSL.send(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode));
644 alt {
645 [] RSL.receive(tr_RSL_CHAN_ACT_ACK(g_chan_nr)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200646 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected CHAN ACT ACK on double activation");
Harald Welte70767382018-02-21 12:16:40 +0100647 }
648 [] RSL.receive(tr_RSL_CHAN_ACT_NACK(g_chan_nr)) {
649 setverdict(pass);
650 }
651 }
652 f_rsl_chan_deact();
653}
654testcase TC_chan_act_react() runs on test_CT {
655 var ConnHdlr vc_conn;
656 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
Harald Welte294b0a22018-03-10 23:26:48 +0100657 f_init();
Harald Welte70767382018-02-21 12:16:40 +0100658 vc_conn := f_start_handler(refers(f_TC_chan_act_react), pars);
659 vc_conn.done;
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200660 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +0100661}
662
663/* Attempt to de-activate a channel that's not active */
664function f_TC_chan_deact_not_active(charstring id) runs on ConnHdlr {
665 timer T := 3.0;
666 RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr));
667 T.start;
668 alt {
669 [] RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr)) {
670 setverdict(pass);
671 }
672 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200673 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout expecting RF_CHAN_REL_ACK");
Harald Welte70767382018-02-21 12:16:40 +0100674 }
675 }
676}
677testcase TC_chan_deact_not_active() runs on test_CT {
678 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
Harald Welte294b0a22018-03-10 23:26:48 +0100679 f_init();
Harald Welte70767382018-02-21 12:16:40 +0100680 var ConnHdlr vc_conn := f_start_handler(refers(f_TC_chan_deact_not_active), pars);
681 vc_conn.done;
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200682 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +0100683}
684
685/* attempt to activate channel with wrong RSL Channel Nr IE; expect NACK */
686function f_TC_chan_act_wrong_nr(charstring id) runs on ConnHdlr {
687 RSL.send(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode));
688 alt {
689 [] RSL.receive(tr_RSL_CHAN_ACT_ACK(g_chan_nr)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200690 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected CHAN ACT ACK");
Harald Welte70767382018-02-21 12:16:40 +0100691 }
692 [] RSL.receive(tr_RSL_CHAN_ACT_NACK(g_chan_nr)) {
693 setverdict(pass);
694 }
695 }
696}
697private type record WrongChanNrCase {
698 RslChannelNr chan_nr,
699 charstring description
700}
701private type record of WrongChanNrCase WrongChanNrCases;
702private template WrongChanNrCase t_WCN(template RslChannelNr chan_nr, charstring desc) := {
703 chan_nr := chan_nr,
704 description := desc
705}
706
707testcase TC_chan_act_wrong_nr() runs on test_CT {
708 var ConnHdlr vc_conn;
709 var ConnHdlrPars pars;
710
Harald Welte294b0a22018-03-10 23:26:48 +0100711 f_init();
Harald Welte70767382018-02-21 12:16:40 +0100712
713 var WrongChanNrCases wrong := {
714 valueof(t_WCN(t_RslChanNr_RACH(0), "RACH is not a dedicated channel")),
715 valueof(t_WCN(t_RslChanNr_RACH(1), "RACH doesn't exist on timeslot")),
716 valueof(t_WCN(t_RslChanNr_BCCH(0), "BCCH is not a dedicated channel")),
717 valueof(t_WCN(t_RslChanNr_PCH_AGCH(0), "PCH/AGCH is not a dedicated channel")),
718 valueof(t_WCN(t_RslChanNr_Bm(0), "TS0 cannot be TCH/F")),
719 valueof(t_WCN(t_RslChanNr_Lm(0, 0), "TS0 cannot be TCH/H")),
720 valueof(t_WCN(t_RslChanNr_Lm(0, 1), "TS0 cannot be TCH/H")),
721 valueof(t_WCN(t_RslChanNr_PDCH(0), "TS0 cannot be PDCH")),
722 valueof(t_WCN(t_RslChanNr_SDCCH8(0, 0), "TS0 cannot be SDCCH/8")),
723 valueof(t_WCN(t_RslChanNr_SDCCH8(0, 7), "TS0 cannot be SDCCH/8")),
724 valueof(t_WCN(t_RslChanNr_SDCCH4(7, 0), "TS7 cannot be SDCCH/4")),
725 valueof(t_WCN(t_RslChanNr_SDCCH4(7, 3), "TS7 cannot be SDCCH/4")),
726 valueof(t_WCN(t_RslChanNr_Lm(1, 0), "TS1 cannot be TCH/H"))
727 };
728
729 for (var integer i := 0; i < sizeof(wrong); i := i+1) {
730 pars := valueof(t_Pars(wrong[i].chan_nr, ts_RSL_ChanMode_SIGN));
731 vc_conn := f_start_handler(refers(f_TC_chan_act_wrong_nr), pars);
732 vc_conn.done;
733 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200734 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +0100735}
736
Harald Weltee613f962018-04-18 22:38:16 +0200737/* execute the same callback function on a variety of logical channels */
Harald Welte2f2b2b72019-05-31 22:24:57 +0200738friend function f_testmatrix_each_chan(ConnHdlrPars pars, void_fn fn) runs on test_CT {
Harald Weltee613f962018-04-18 22:38:16 +0200739 var ConnHdlr vc_conn;
Harald Welte10474062019-05-30 16:48:17 +0200740 f_init();
Harald Weltee613f962018-04-18 22:38:16 +0200741
742 /* test on each of the channels we have */
743 for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i+1) {
744 pars.chan_nr := valueof(g_AllChanTypes[i]);
745
746 log(testcasename(), ": XXX Starting on ", g_AllChanTypes[i]);
747 vc_conn := f_start_handler(fn, pars);
748 vc_conn.done;
749 }
750
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200751 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Weltee613f962018-04-18 22:38:16 +0200752}
753
Harald Welte93640c62018-02-25 16:59:33 +0100754/***********************************************************************
Harald Welte629cc6b2018-03-11 17:19:05 +0100755 * SACCH handling
756 ***********************************************************************/
757
758private function f_exp_sacch(boolean exp) runs on ConnHdlr {
759 timer T_sacch := 3.0;
760 T_sacch.start;
761 alt {
762 [not exp] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200763 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received SACCH when not expecting it");
Harald Welte629cc6b2018-03-11 17:19:05 +0100764 }
765 [not exp] T_sacch.timeout {
766 setverdict(pass);
767 }
768 [exp] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) {
769 setverdict(pass);
770 }
771 [exp] T_sacch.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200772 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Timeout waiting for SACCH on ", g_chan_nr));
Harald Welte629cc6b2018-03-11 17:19:05 +0100773 }
774 [] L1CTL.receive { repeat; }
775 [] RSL.receive { repeat; }
776 }
777}
778
779/* Test if DEACTIVATE SACCH actualy deactivates its transmission (TS 48.058 4.6) */
780private function f_TC_deact_sacch(charstring id) runs on ConnHdlr {
781 f_l1_tune(L1CTL);
782 RSL.clear;
783
784 /* activate the logical channel */
785 f_est_dchan();
786 L1CTL.clear;
787
788 /* check that SACCH actually are received as expected */
789 f_exp_sacch(true);
790
791 /* deactivate SACCH on the logical channel */
792 RSL.send(ts_RSL_DEACT_SACCH(g_chan_nr));
793 f_sleep(1.0);
794 L1CTL.clear;
795
796 /* check that no SACCH are received anymore */
797 f_exp_sacch(false);
798
799 /* release the channel */
800 f_rsl_chan_deact();
801 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
802}
803testcase TC_deact_sacch() runs on test_CT {
804 var ConnHdlr vc_conn;
805 var ConnHdlrPars pars;
806 f_init();
807 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
808 //for (var integer i := 0; i < 1; i := i+1) {
809 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
810 log(testcasename(), ": Starting for ", g_AllChannels[i]);
811 vc_conn := f_start_handler(refers(f_TC_deact_sacch), pars);
812 vc_conn.done;
813 }
814 /* TODO: do the above in parallel, rather than sequentially? */
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200815 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte629cc6b2018-03-11 17:19:05 +0100816}
817
Harald Welte55700662018-03-12 13:15:43 +0100818/* verify that given SACCH payload is present */
Harald Welteea17b912018-03-11 22:29:31 +0100819private function f_sacch_present(template octetstring l3_exp) runs on ConnHdlr {
820 var L1ctlDlMessage dl;
821 /* check that the specified SI5 value is actually sent */
822 timer T_sacch := 3.0;
823 L1CTL.clear;
824 T_sacch.start;
825 alt {
826 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) -> value dl {
827 var octetstring l3 := substr(dl.payload.data_ind.payload, 4, 19);
828 if (match(l3, l3_exp)) {
829 setverdict(pass);
830 } else {
831 repeat;
832 }
833 }
834 [] L1CTL.receive { repeat; }
835 [] T_sacch.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200836 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Timeout waiting for SACCH ", l3_exp));
Harald Welteea17b912018-03-11 22:29:31 +0100837 }
838 }
839}
840
Harald Welte55700662018-03-12 13:15:43 +0100841/* verify that given SACCH payload is not present */
842private function f_sacch_missing(template octetstring l3_exp) runs on ConnHdlr {
843 var L1ctlDlMessage dl;
844 /* check that the specified SI5 value is actually sent */
845 timer T_sacch := 3.0;
846 L1CTL.clear;
847 T_sacch.start;
848 alt {
849 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) -> value dl {
850 var octetstring l3 := substr(dl.payload.data_ind.payload, 4, 19);
851 if (match(l3, l3_exp)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200852 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Received unexpected SACCH ", dl));
Harald Welte55700662018-03-12 13:15:43 +0100853 } else {
854 repeat;
855 }
856 }
857 [] L1CTL.receive { repeat; }
858 [] T_sacch.timeout {
859 setverdict(pass);
860 }
861 }
862}
863
Harald Welte629cc6b2018-03-11 17:19:05 +0100864/* Test for default SACCH FILL transmitted in DL SACCH (all channel types) */
Harald Welteea17b912018-03-11 22:29:31 +0100865private function f_TC_sacch_filling(charstring id) runs on ConnHdlr {
866 /* Set a known default SACCH filling for SI5 */
867 var octetstring si5 := f_rnd_octstring(19);
868 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5));
869
870 f_l1_tune(L1CTL);
871 RSL.clear;
872
873 /* activate the logical channel */
874 f_est_dchan();
875
876 /* check that the specified SI5 value is actually sent */
877 f_sacch_present(si5);
878
879 /* release the channel */
880 RSL.clear;
881 f_rsl_chan_deact();
882 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
883}
884testcase TC_sacch_filling() runs on test_CT {
885 var ConnHdlr vc_conn;
886 var ConnHdlrPars pars;
887 f_init();
888 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
889 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
890 log(testcasename(), ": Starting for ", g_AllChannels[i]);
891 vc_conn := f_start_handler(refers(f_TC_sacch_filling), pars);
892 vc_conn.done;
893 }
894 /* TODO: do the above in parallel, rather than sequentially? */
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200895 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welteea17b912018-03-11 22:29:31 +0100896}
897
Harald Welte629cc6b2018-03-11 17:19:05 +0100898/* Test for lchan-specific SACCH INFO MODIFY (TS 48.058 4.12) */
Harald Welteea17b912018-03-11 22:29:31 +0100899private function f_TC_sacch_info_mod(charstring id) runs on ConnHdlr {
900 /* Set a known default SACCH filling for SI5 */
901 var octetstring si5 := f_rnd_octstring(19);
902 var octetstring si5_diff := f_rnd_octstring(19);
903 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5));
904
905 f_l1_tune(L1CTL);
906 RSL.clear;
907
908 log("Activating channel, expecting standard SI5");
909 /* activate the logical channel */
910 f_est_dchan();
911 /* check that the specified SI5 value is actually sent */
912 f_sacch_present(si5);
913
914 /* set channel-specific different SI5 */
915 log("Setting channel specific SACCH INFO, expecting it");
916 RSL.send(ts_RSL_SACCH_INF_MOD(g_chan_nr, RSL_SYSTEM_INFO_5, si5_diff))
917 /* check that the specified lchan-specific value is now used */
918 f_sacch_present(si5_diff);
919
920 /* deactivate the channel and re-activate it, this should result in default SI5 */
921 log("De-activating and re-activating channel, expecting standard SI5");
922 f_rsl_chan_deact();
923 f_rsl_chan_act(valueof(ts_RSL_ChanMode_SIGN));
924 /* Verify that the TRX-wide default SACCH filling is present again */
925 f_sacch_present(si5);
926
927 /* release the channel */
928 RSL.clear;
929 f_rsl_chan_deact();
930 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
931}
932testcase TC_sacch_info_mod() runs on test_CT {
933 var ConnHdlr vc_conn;
934 var ConnHdlrPars pars;
935 f_init();
936 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
937 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
938 log(testcasename(), ": Starting for ", g_AllChannels[i]);
939 vc_conn := f_start_handler(refers(f_TC_sacch_info_mod), pars);
940 vc_conn.done;
941 }
942 /* TODO: do the above in parallel, rather than sequentially? */
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200943 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welteea17b912018-03-11 22:29:31 +0100944}
945
Harald Welte075d84c2018-03-12 13:07:24 +0100946/* Test SACCH scheduling of multiple different SI message types */
947private function f_TC_sacch_multi(charstring id) runs on ConnHdlr {
948 var octetstring si5 := f_rnd_octstring(19);
949 var octetstring si5bis := f_rnd_octstring(19);
950 var octetstring si5ter := f_rnd_octstring(19);
951 var octetstring si6 := f_rnd_octstring(19);
952
953 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5));
954 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5bis, si5bis));
955 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5ter, si5ter));
956 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, si6));
957
958 f_l1_tune(L1CTL);
959 RSL.clear;
960
961 /* activate the logical channel */
962 f_est_dchan();
963 L1CTL.clear;
964
965 /* check that SACCH actually are received as expected */
966 f_sacch_present(si5);
967 f_sacch_present(si5bis);
968 f_sacch_present(si5ter);
969 f_sacch_present(si6);
970
971 /* release the channel */
972 f_rsl_chan_deact();
973 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
974}
975testcase TC_sacch_multi() runs on test_CT {
976 var ConnHdlr vc_conn;
977 var ConnHdlrPars pars;
978 f_init();
979 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
980 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
981 log(testcasename(), ": Starting for ", g_AllChannels[i]);
982 vc_conn := f_start_handler(refers(f_TC_sacch_multi), pars);
983 vc_conn.done;
984 }
985 /* TODO: do the above in parallel, rather than sequentially? */
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200986 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte075d84c2018-03-12 13:07:24 +0100987}
988
Harald Welte55700662018-03-12 13:15:43 +0100989/* Test if SACH information is modified as expected */
990private function f_TC_sacch_multi_chg(charstring id) runs on ConnHdlr {
991 var octetstring si5 := f_rnd_octstring(19);
992 var octetstring si6 := f_rnd_octstring(19);
993
994 /* First, configure both SI5 and SI6 to be transmitted */
995 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5));
996 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, si6));
997
998 f_l1_tune(L1CTL);
999 RSL.clear;
1000
1001 /* activate the logical channel */
1002 f_est_dchan();
1003 L1CTL.clear;
1004
1005 /* check that SACCH actually are received as expected */
1006 f_sacch_present(si5);
1007 f_sacch_present(si6);
1008
1009 /* disable SI6 */
1010 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, ''O));
1011
1012 /* check that SI5 is still transmitted */
1013 f_sacch_present(si5);
1014 /* check if SI6 is now gone */
1015 f_sacch_missing(si6);
1016
1017 /* release the channel */
1018 f_rsl_chan_deact();
1019 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1020}
1021testcase TC_sacch_multi_chg() runs on test_CT {
1022 var ConnHdlr vc_conn;
1023 var ConnHdlrPars pars;
1024 f_init();
1025 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
1026 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
1027 log(testcasename(), ": Starting for ", g_AllChannels[i]);
1028 vc_conn := f_start_handler(refers(f_TC_sacch_multi_chg), pars);
1029 vc_conn.done;
1030 }
1031 /* TODO: do the above in parallel, rather than sequentially? */
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001032 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte55700662018-03-12 13:15:43 +01001033}
1034
Harald Weltec8d363c2019-05-19 20:36:48 +02001035/* Test for SACCH information present in RSL CHAN ACT (overrides FILLING) */
1036private function f_TC_sacch_chan_act(charstring id) runs on ConnHdlr {
1037 var octetstring si5 := f_rnd_octstring(19);
1038 var octetstring si6 := f_rnd_octstring(19);
1039 var octetstring si5_specific := f_rnd_octstring(19);
1040 var octetstring si6_specific := f_rnd_octstring(19);
1041
1042 /* First, configure both SI5 and SI6 to be transmitted */
1043 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5));
1044 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, si6));
1045
1046 f_l1_tune(L1CTL);
1047 RSL.clear;
1048
1049 /* activate channel with different SACCH filling */
1050 var RSL_SacchInfo sacch_info := valueof(ts_RSL_SacchInfo({
1051 ts_RSL_SacchInfoElem(RSL_SYSTEM_INFO_5, si5_specific),
1052 ts_RSL_SacchInfoElem(RSL_SYSTEM_INFO_6, si6_specific)
1053 }));
1054 var RSL_IE_List addl_ies := { valueof(t_RSL_IE(RSL_IE_SACCH_INFO,
1055 RSL_IE_Body:{sacch_info := sacch_info})) };
1056 f_est_dchan(more_ies := addl_ies);
1057
1058 /* check that SACCH actually are received as expected */
1059 f_sacch_present(si5_specific);
1060 f_sacch_present(si6_specific);
1061
1062 /* release the channel */
1063 f_rsl_chan_deact();
1064 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1065}
1066testcase TC_sacch_chan_act() runs on test_CT {
1067 var ConnHdlr vc_conn;
1068 var ConnHdlrPars pars;
1069 f_init();
1070
1071 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
1072 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
1073 log(testcasename(), ": Starting for ", g_AllChannels[i]);
1074 vc_conn := f_start_handler(refers(f_TC_sacch_chan_act), pars);
1075 vc_conn.done;
1076 }
1077 /* TODO: do the above in parallel, rather than sequentially? */
1078 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
1079}
1080
Harald Welte8b01c792019-05-19 22:51:25 +02001081/* verify that SACCH DL transmission is started only if MS power IE present
1082 * see section 4.1.3 of 3GPP TS 48.058 */
1083private function f_TC_sacch_chan_act_ho_async(charstring id) runs on ConnHdlr {
1084 var octetstring si5 := f_rnd_octstring(19);
1085
1086 f_l1_tune(L1CTL);
1087 RSL.clear;
1088
1089 /* Step 1: Activate ASYNC HO channel without MS power IE */
1090
1091 /* Activate channel on BTS side */
1092 f_rsl_chan_act(g_pars.chan_mode, act_type := t_RSL_IE_ActType_HO_ASYNC);
1093 /* don't perform immediate assignment here, as we're testing non-IA case */
1094 /* enable dedicated mode */
1095 f_L1CTL_DM_EST_REQ(L1CTL, {false, mp_trx0_arfcn }, g_pars.chan_nr, 7);
1096
1097 /* Verify that no DL SACCH is being received */
1098 f_sacch_missing(?);
1099
1100 f_rsl_chan_deact();
1101 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1102
1103
1104 /* Step 2: Activate ASYNC HO channel with MS power IE */
1105
1106 /* Activate channel on BTS side */
1107 var RSL_IE_List addl_ies := {
1108 valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(0)}))
1109 };
1110 f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_ASYNC);
1111 /* don't perform immediate assignment here, as we're testing non-IA case */
1112 /* enable dedicated mode */
1113 f_L1CTL_DM_EST_REQ(L1CTL, {false, mp_trx0_arfcn }, g_pars.chan_nr, 7);
1114
1115 /* Verify that DL SACCH is being received */
1116 f_sacch_present(si5);
1117
1118 f_rsl_chan_deact();
1119 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1120}
1121testcase TC_sacch_chan_act_ho_async() runs on test_CT {
1122 var ConnHdlr vc_conn;
1123 var ConnHdlrPars pars;
1124 f_init();
1125
1126 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
1127 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
1128 log(testcasename(), ": Starting for ", g_AllChannels[i]);
1129 vc_conn := f_start_handler(refers(f_TC_sacch_chan_act_ho_async), pars);
1130 vc_conn.done;
1131 }
1132 /* TODO: do the above in parallel, rather than sequentially? */
1133 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
1134}
1135
1136/* verify that SACCH DL transmission is started only if TA + MS power IEs present,
1137 * see section 4.1.4 of 3GPP TS 48.058 */
1138private function f_TC_sacch_chan_act_ho_sync(charstring id) runs on ConnHdlr {
1139 var octetstring si5 := f_rnd_octstring(19);
1140 var RSL_IE_List addl_ies;
1141
1142 f_l1_tune(L1CTL);
1143 RSL.clear;
1144
1145 /* Step 1: Activate SYNC HO channel without MS power IE */
1146
1147 /* Activate channel on BTS side */
1148 f_rsl_chan_act(g_pars.chan_mode, act_type := t_RSL_IE_ActType_HO_SYNC);
1149 /* don't perform immediate assignment here, as we're testing non-IA case */
1150 /* enable dedicated mode */
1151 f_L1CTL_DM_EST_REQ(L1CTL, {false, mp_trx0_arfcn }, g_pars.chan_nr, 7);
1152
1153 /* Verify that no DL SACCH is being received */
1154 f_sacch_missing(?);
1155
1156 f_rsl_chan_deact();
1157 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1158
1159
1160 /* Step 2a: Activate SYNC HO channel with only MS power IE */
1161
1162 /* Activate channel on BTS side */
1163 addl_ies := {
1164 valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(0)}))
1165 };
1166 f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_SYNC);
1167 /* don't perform immediate assignment here, as we're testing non-IA case */
1168 /* enable dedicated mode */
1169 f_L1CTL_DM_EST_REQ(L1CTL, {false, mp_trx0_arfcn }, g_pars.chan_nr, 7);
1170
1171 /* Verify that no DL SACCH is being received */
1172 f_sacch_missing(?);
1173
1174 f_rsl_chan_deact();
1175 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1176
1177
1178 /* Step 2b: Activate SYNC HO channel with TA IE */
1179
1180 /* Activate channel on BTS side */
1181 addl_ies := {
1182 valueof(t_RSL_IE(RSL_IE_TIMING_ADVANCE, RSL_IE_Body:{timing_adv := 0}))
1183 };
1184 f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_SYNC);
1185 /* don't perform immediate assignment here, as we're testing non-IA case */
1186 /* enable dedicated mode */
1187 f_L1CTL_DM_EST_REQ(L1CTL, {false, mp_trx0_arfcn }, g_pars.chan_nr, 7);
1188
1189 /* Verify that no DL SACCH is being received */
1190 f_sacch_missing(?);
1191
1192 f_rsl_chan_deact();
1193 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1194
1195
1196 /* Step 3: Activate SYNC HO channel with MS power IE and TA IE */
1197
1198 /* Activate channel on BTS side */
1199 addl_ies := {
1200 valueof(t_RSL_IE(RSL_IE_TIMING_ADVANCE, RSL_IE_Body:{timing_adv := 0})),
1201 valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(0)}))
1202 };
1203 f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_SYNC);
1204 /* don't perform immediate assignment here, as we're testing non-IA case */
1205 /* enable dedicated mode */
1206 f_L1CTL_DM_EST_REQ(L1CTL, {false, mp_trx0_arfcn }, g_pars.chan_nr, 7);
1207
1208 /* Verify that DL SACCH is being received */
1209 f_sacch_present(si5);
1210
1211 f_rsl_chan_deact();
1212 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1213}
1214testcase TC_sacch_chan_act_ho_sync() runs on test_CT {
1215 var ConnHdlr vc_conn;
1216 var ConnHdlrPars pars;
1217 f_init();
1218
1219 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
1220 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
1221 log(testcasename(), ": Starting for ", g_AllChannels[i]);
1222 vc_conn := f_start_handler(refers(f_TC_sacch_chan_act_ho_sync), pars);
1223 vc_conn.done;
1224 }
1225 /* TODO: do the above in parallel, rather than sequentially? */
1226 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
1227}
Harald Welte629cc6b2018-03-11 17:19:05 +01001228
1229
1230/***********************************************************************
Harald Welte93640c62018-02-25 16:59:33 +01001231 * RACH Handling
1232 ***********************************************************************/
1233
Harald Welte8c24c2b2018-02-26 08:31:31 +01001234/* like L1SAP_IS_PACKET_RACH */
1235private function ra_is_ps(OCT1 ra) return boolean {
Harald Welte56c05802018-02-28 21:39:35 +01001236 if ((ra and4b 'F0'O == '70'O) and (ra and4b '0F'O != '0F'O)) {
Harald Welte8c24c2b2018-02-26 08:31:31 +01001237 return true;
1238 }
1239 return false;
1240}
1241
1242/* generate a random RACH for circuit-switched */
1243private function f_rnd_ra_cs() return OCT1 {
1244 var OCT1 ra;
1245 do {
1246 ra := f_rnd_octstring(1);
1247 } while (ra_is_ps(ra));
1248 return ra;
1249}
1250
Harald Welte883340c2018-02-28 18:59:29 +01001251/* generate a random RACH for packet-switched */
1252private function f_rnd_ra_ps() return OCT1 {
1253 var OCT1 ra;
1254 do {
1255 ra := f_rnd_octstring(1);
1256 } while (not ra_is_ps(ra));
1257 return ra;
1258}
1259
Vadim Yanitskiy51cbc102019-04-22 06:37:30 +07001260/* generate a random 11-bit RA (packet-switched only) */
1261private function f_rnd_ra11_ps() return BIT11 {
1262 var integer ra11 := f_rnd_int(bit2int('11111111111'B));
1263 return int2bit(ra11, 11);
1264}
1265
Harald Welte8c24c2b2018-02-26 08:31:31 +01001266/* Send 1000 RACH requests and check their RA+FN on the RSL side */
1267testcase TC_rach_content() runs on test_CT {
Harald Welte10474062019-05-30 16:48:17 +02001268 f_init();
Harald Welte8c24c2b2018-02-26 08:31:31 +01001269 f_init_l1ctl();
Harald Welte68e495b2018-02-25 00:05:57 +01001270 f_l1_tune(L1CTL);
Harald Welte70767382018-02-21 12:16:40 +01001271
Harald Welte8c24c2b2018-02-26 08:31:31 +01001272 var GsmFrameNumber fn_last := 0;
Maxa199a2e2019-02-25 16:31:11 +01001273 var boolean test_failed := false;
Harald Welte8c24c2b2018-02-26 08:31:31 +01001274 for (var integer i := 0; i < 1000; i := i+1) {
1275 var OCT1 ra := f_rnd_ra_cs();
1276 var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra));
1277 if (fn == fn_last) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001278 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?");
Harald Welte8c24c2b2018-02-26 08:31:31 +01001279 }
1280 fn_last := fn;
1281
1282 timer T := 5.0;
Harald Welte56c05802018-02-28 21:39:35 +01001283 T.start;
Harald Welte8c24c2b2018-02-26 08:31:31 +01001284 alt {
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07001285 [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_CHAN_RQD(ra, fn, t_RslChanNr_RACH(0)))) {
Harald Welte8c24c2b2018-02-26 08:31:31 +01001286 T.stop;
1287 }
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07001288 [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_CHAN_RQD(?, ?, ?, ?))) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001289 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected CHAN RQD");
Harald Welte8c24c2b2018-02-26 08:31:31 +01001290 }
1291 [] RSL_CCHAN.receive { repeat; }
1292 [] T.timeout {
Maxa199a2e2019-02-25 16:31:11 +01001293 test_failed := true;
1294 log("[", i, "] Timeout waiting for CHAN RQD FN=", fn, " RA=", ra);
Harald Welte8c24c2b2018-02-26 08:31:31 +01001295 }
1296 }
1297 }
Maxba06feb2019-03-05 10:52:46 +01001298 if (test_failed) {
1299 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Some out of 1000 RACH requests timed out"));
Maxa199a2e2019-02-25 16:31:11 +01001300 }
Maxba06feb2019-03-05 10:52:46 +01001301 setverdict(pass);
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001302 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +01001303}
Harald Welte8c24c2b2018-02-26 08:31:31 +01001304
1305/* Send 1000 RACH Requests (flood ~ 89/s) and count if count(Abis) == count(Um) */
1306testcase TC_rach_count() runs on test_CT {
Harald Welte294b0a22018-03-10 23:26:48 +01001307 f_init();
Harald Welte8c24c2b2018-02-26 08:31:31 +01001308 f_init_l1ctl();
Harald Welte294b0a22018-03-10 23:26:48 +01001309 f_sleep(1.0);
Harald Welte8c24c2b2018-02-26 08:31:31 +01001310 f_l1_tune(L1CTL);
1311
1312 var GsmFrameNumber fn_last := 0;
1313 for (var integer i := 0; i < 1000; i := i+1) {
1314 var OCT1 ra := f_rnd_ra_cs();
1315 var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra));
1316 if (fn == fn_last) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001317 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?");
Harald Welte8c24c2b2018-02-26 08:31:31 +01001318 }
1319 fn_last := fn;
1320 }
1321 var integer rsl_chrqd := 0;
1322 timer T := 3.0;
Harald Welte56c05802018-02-28 21:39:35 +01001323 T.start;
Harald Welte8c24c2b2018-02-26 08:31:31 +01001324 alt {
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07001325 [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_CHAN_RQD(?,?))) {
Harald Welte8c24c2b2018-02-26 08:31:31 +01001326 rsl_chrqd := rsl_chrqd + 1;
Harald Weltec3a3f452018-02-26 17:37:47 +01001327 f_timer_safe_restart(T);
Harald Welte8c24c2b2018-02-26 08:31:31 +01001328 repeat;
1329 }
1330 [] RSL_CCHAN.receive { repeat; }
1331 [] T.timeout { }
1332 }
1333 if (rsl_chrqd == 1000) {
1334 setverdict(pass);
1335 } else {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001336 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Received only ", rsl_chrqd, " out of 1000 RACH"));
Harald Welte8c24c2b2018-02-26 08:31:31 +01001337 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001338 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +01001339}
1340
Harald Welte3453ab42019-05-24 21:19:58 +02001341private function f_vty_load_ind_thresh(integer period := 10, integer bts_nr := 0) runs on test_CT {
1342 var charstring bts_str := "bts " & int2str(bts_nr);
1343 f_vty_config2(BSCVTY, {"network", bts_str}, "ccch load-indication-threshold " & int2str(period));
1344}
1345
1346/* empirical value: Number of RACH slots per reporting interval (1s) on combined CCCH */
1347private template integer tr_rach_slots_per_interval := (90 .. 130);
1348
1349/* Expect 0 RACH load on an idle BTS that has just started up */
1350testcase TC_rach_load_idle_thresh0() runs on test_CT {
1351 var ASP_RSL_Unitdata rx_ud;
1352
1353 f_init_vty_bsc();
1354 /* send load indications even at 0% load */
1355 f_vty_load_ind_thresh(0);
1356 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
1357 f_sleep(2.0);
1358
1359 f_init();
1360
1361 timer T := 5.0;
1362 T.start;
1363 alt {
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07001364 [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RACH_LOAD_IND(tr_rach_slots_per_interval, 0, 0))) {
Harald Welte3453ab42019-05-24 21:19:58 +02001365 setverdict(pass);
1366 repeat;
1367 }
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07001368 [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RACH_LOAD_IND(?, ?, ?))) -> value rx_ud {
Harald Welte3453ab42019-05-24 21:19:58 +02001369 setverdict(fail, "Unexpected RACH LOAD IND: ", rx_ud);
1370 repeat;
1371 }
1372 [] RSL_CCHAN.receive {
1373 repeat;
1374 }
1375 [] T.timeout { }
1376 }
1377
1378 f_vty_load_ind_thresh(10);
1379 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
1380}
1381
1382/* Expect no RACH load indications on an idle BTS that has just started up (default threshold 10%) */
1383testcase TC_rach_load_idle_below_thresh() runs on test_CT {
1384 var ASP_RSL_Unitdata rx_ud;
1385
1386 f_init_vty_bsc();
1387 f_init();
1388
1389 timer T := 5.0;
1390 T.start;
1391 alt {
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07001392 [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RACH_LOAD_IND(?, ?, ?))) -> value rx_ud {
Harald Welte3453ab42019-05-24 21:19:58 +02001393 setverdict(fail, "Unexpected RACH LOAD IND: ", rx_ud);
1394 repeat;
1395 }
1396 [] RSL_CCHAN.receive {
1397 repeat;
1398 }
1399 [] T.timeout {
1400 setverdict(pass);
1401 }
1402 }
1403
1404 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
1405}
1406
1407/* Expect 0 RACH load on an idle BTS that has just started up */
1408testcase TC_rach_load_count() runs on test_CT {
1409 var ASP_RSL_Unitdata rx_ud;
1410 var integer load_access_count := 0;
1411
1412 f_init_vty_bsc();
1413 /* send load indications even at 0% load */
1414 f_vty_load_ind_thresh(0);
1415 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
1416 f_sleep(2.0);
1417 f_init();
1418
1419 f_init_l1ctl();
1420 f_sleep(1.0);
1421 f_l1_tune(L1CTL);
1422
1423 var GsmFrameNumber fn_last := 0;
1424 for (var integer i := 0; i < 1000; i := i+1) {
1425 var OCT1 ra := f_rnd_ra_cs();
1426 var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra));
1427 if (fn == fn_last) {
1428 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?");
1429 }
1430 fn_last := fn;
1431 }
1432
1433 timer T := 5.0;
1434 T.start;
1435 alt {
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07001436 [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RACH_LOAD_IND(tr_rach_slots_per_interval, ?, ?)))
Harald Welte3453ab42019-05-24 21:19:58 +02001437 -> value rx_ud {
1438 var RSL_IE_Body ie;
1439 f_rsl_find_ie(rx_ud.rsl, RSL_IE_RACH_LOAD, ie);
1440 load_access_count := load_access_count + ie.rach_load.access_count;
1441 if (ie.rach_load.busy_count < ie.rach_load.access_count) {
1442 setverdict(fail, "Access count cannot be < Busy count");
1443 }
1444 repeat;
1445 }
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07001446 [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RACH_LOAD_IND(?, ?, ?))) -> value rx_ud {
Harald Welte3453ab42019-05-24 21:19:58 +02001447 setverdict(fail, "Unexpected RACH LOAD IND: ", rx_ud);
1448 repeat;
1449 }
1450 [] RSL_CCHAN.receive {
1451 repeat;
1452 }
1453 [] T.timeout { }
1454 }
1455 if (load_access_count == 1000) {
1456 setverdict(pass);
1457 } else {
1458 setverdict(fail, "Load reports state ", load_access_count, " RACH, but we sent 1000");
1459 }
1460
1461 f_vty_load_ind_thresh(10);
1462 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
1463}
1464
Harald Welte54a2a2d2018-02-26 09:14:05 +01001465private function f_rach_toffs(int16_t toffs256, boolean expect_pass) runs on test_CT {
Harald Weltef8df4cb2018-03-10 15:15:08 +01001466 var TrxcMessage ret;
Harald Welte54a2a2d2018-02-26 09:14:05 +01001467 /* tell fake_trx to use a given timing offset for all bursts */
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +07001468 ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, valueof(ts_TRXC_FAKE_TIMING(toffs256)));
Harald Welte54a2a2d2018-02-26 09:14:05 +01001469 f_sleep(0.5);
1470
1471 /* Transmit RACH request + wait for confirmation */
1472 var OCT1 ra := f_rnd_ra_cs();
1473 var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra));
1474
1475 /* Check for expected result */
1476 timer T := 1.5;
1477 T.start;
1478 alt {
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07001479 [expect_pass] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_CHAN_RQD(ra, fn))) {
Harald Welte54a2a2d2018-02-26 09:14:05 +01001480 setverdict(pass);
1481 }
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07001482 [not expect_pass] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_CHAN_RQD(ra, fn))) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001483 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("RACH passed but was expected to be dropped: ", toffs256));
Harald Welte54a2a2d2018-02-26 09:14:05 +01001484 }
1485 [] RSL_CCHAN.receive { repeat; }
1486 [not expect_pass] T.timeout {
1487 setverdict(pass);
1488 }
1489 [expect_pass] T.timeout {
Max6e053042019-03-14 16:34:22 +01001490 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Timeout waiting for CHAN RQD: FN=", fn, " RA=", ra));
Harald Welte54a2a2d2018-02-26 09:14:05 +01001491 }
1492 }
1493}
1494
1495/* Test if dropping of RACH Based on NM_ATT_MAX_TA works */
1496testcase TC_rach_max_ta() runs on test_CT {
Harald Welte10474062019-05-30 16:48:17 +02001497 f_init();
Harald Welte54a2a2d2018-02-26 09:14:05 +01001498 f_init_l1ctl();
1499 f_l1_tune(L1CTL);
Harald Welte54a2a2d2018-02-26 09:14:05 +01001500 f_sleep(1.0);
1501
1502 /* default max-ta is 63 (full range of GSM timing advance */
1503
Vadim Yanitskiyc81d6e42018-03-05 22:39:01 +07001504 /* We allow early arrival up to 2 symbols */
1505 f_rach_toffs(-1*256, true);
1506 f_rach_toffs(-2*256, true);
Harald Welte54a2a2d2018-02-26 09:14:05 +01001507 f_rach_toffs(-10*256, false);
1508
1509 /* 0 / 32 / 63 bits is legal / permitted */
1510 f_rach_toffs(0, true);
1511 f_rach_toffs(32*256, true);
1512 f_rach_toffs(63*256, true);
1513
1514 /* more than 63 bits is not legal / permitted */
1515 f_rach_toffs(64*256, false);
1516 f_rach_toffs(127*256, false);
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001517 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte54a2a2d2018-02-26 09:14:05 +01001518}
Harald Welte8c24c2b2018-02-26 08:31:31 +01001519
Vadim Yanitskiy7c2c10c2019-05-31 20:42:01 +07001520function f_TC_ho_rach(charstring id) runs on ConnHdlr {
1521 var GsmFrameNumber fn;
1522 var RSL_Message rm;
1523
1524 f_l1_tune(L1CTL);
1525 RSL.clear;
1526
1527 /* Generate a random Handover Reference */
1528 var integer ho_ref := oct2int(f_rnd_octstring(1));
1529
1530 /* Handover Reference IE (see 3GPP TS 48.058, 9.3.9) */
1531 var RSL_IE ho_ref_ie := valueof(t_RSL_IE(RSL_IE_HANDO_REF,
1532 RSL_IE_Body:{ handover_ref := ho_ref }));
1533
1534 /* Activate a channel on the BTS side (no encryption) */
1535 f_rsl_chan_act(g_pars.chan_mode, more_ies := { ho_ref_ie },
1536 act_type := t_RSL_IE_ActType_HO_SYNC);
1537
1538 /* Switch the MS side (e.g. trxcon) to a dedicated channel without
1539 * waiting for Immediate Assignment and sending Access Burst */
1540 f_L1CTL_DM_EST_REQ(L1CTL, { false, mp_trx0_arfcn }, g_pars.chan_nr, 7);
1541
1542 /* Send handover Access Burst */
1543 fn := f_L1CTL_RACH(L1CTL, ho_ref, chan_nr := g_pars.chan_nr);
1544
1545 /* TODO: test mismatching Handover Reference, and missing IE */
1546
1547 /* Wait for handover detection */
1548 timer T := 3.0;
1549 T.start;
1550 alt {
1551 [] RSL.receive(tr_RSL_HANDO_DET(g_pars.chan_nr)) -> value rm {
1552 log("Handover RACH has been detected: ", rm);
1553 setverdict(pass);
1554 }
1555 [] RSL.receive(tr_RSL_CHAN_RQD(?, ?, ?, ?)) -> value rm {
1556 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
1557 log2str("RSL_CHAN_RQD was not expected: ", rm));
1558 }
1559 [] RSL.receive { repeat; }
1560 [] T.timeout {
1561 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
1562 log2str("Timeout waiting for handover RACH: FN=", fn, " RA=", ho_ref));
1563 }
1564 }
1565
1566 /* Release the channel */
1567 f_rsl_chan_deact();
1568 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1569}
1570
1571/* Test handover RACH detection */
1572testcase TC_ho_rach() runs on test_CT {
1573 var ConnHdlrPars pars;
1574 var ConnHdlr vc_conn;
1575
1576 f_init();
1577
1578 for (var integer i := 0; i < sizeof(g_AllChannels); i := i + 1) {
1579 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
1580 log(testcasename(), ": Starting for ", g_AllChannels[i]);
1581 vc_conn := f_start_handler(refers(f_TC_ho_rach), pars);
1582 vc_conn.done;
1583 }
1584
1585 /* TODO: do the above in parallel, rather than sequentially? */
1586 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
1587}
1588
Harald Welte93640c62018-02-25 16:59:33 +01001589/***********************************************************************
1590 * Measurement Processing / Reporting
1591 ***********************************************************************/
1592
Harald Welte70767382018-02-21 12:16:40 +01001593template LapdmAddressField ts_LapdmAddr(LapdmSapi sapi, boolean c_r) := {
1594 spare := '0'B,
1595 lpd := 0,
1596 sapi := sapi,
1597 c_r := c_r,
1598 ea := true
1599}
1600
Harald Welted879bd92018-03-12 15:01:23 +01001601template LapdmFrameAB ts_LAPDm_AB(LapdmSapi sapi, boolean c_r, boolean p, octetstring pl) := {
Harald Welte70767382018-02-21 12:16:40 +01001602 addr := ts_LapdmAddr(sapi, c_r),
Harald Welted879bd92018-03-12 15:01:23 +01001603 ctrl := ts_LapdmCtrlUI(p),
Harald Welte70767382018-02-21 12:16:40 +01001604 len := 0, /* overwritten */
1605 m := false,
1606 el := 1,
1607 payload := pl
1608}
1609
1610/* handle incoming downlink SACCH and respond with uplink SACCH (meas res) */
1611altstep as_l1_sacch() runs on ConnHdlr {
1612 var L1ctlDlMessage l1_dl;
Harald Weltef8df4cb2018-03-10 15:15:08 +01001613 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl {
Harald Welte70767382018-02-21 12:16:40 +01001614 log("SACCH received: ", l1_dl.payload.data_ind.payload);
Pau Espin Pedrole9571aa2018-10-22 17:13:07 +02001615 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 +01001616 var LapdmFrameAB lb := valueof(ts_LAPDm_AB(0, false, false, enc_GsmRrL3Message(meas_rep)));
Harald Welte70767382018-02-21 12:16:40 +01001617 log("LAPDm: ", lb);
Pau Espin Pedroled359cb2018-09-28 16:08:24 +02001618
Vadim Yanitskiy0a8d6da2019-05-28 22:18:28 +07001619 var template (value) SacchL1Header l1h := ts_SacchL1Header(
1620 g_pars.l1_pars.ms_power_level, false,
1621 g_pars.l1_pars.ms_actual_ta);
1622
1623 /* TODO: we can use an extension of TTCN-3 for that, i.e. PADDING('2B'O) */
1624 var octetstring l2 := f_pad_oct(enc_LapdmFrameAB(lb), 21, '2B'O);
1625
1626 log("Sending Measurement Report: ", l1h, l2);
1627 L1CTL.send(ts_L1CTL_DATA_REQ_SACCH(g_chan_nr, ts_RslLinkID_SACCH(0), l1h, l2));
Harald Welte70767382018-02-21 12:16:40 +01001628 repeat;
1629 }
1630}
1631
1632altstep as_l1_dcch() runs on ConnHdlr {
1633 var L1ctlDlMessage l1_dl;
Harald Weltef8df4cb2018-03-10 15:15:08 +01001634 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_DCCH(?))) -> value l1_dl {
Harald Welte70767382018-02-21 12:16:40 +01001635 log("DCCH received: ", l1_dl.payload.data_ind.payload);
1636 var octetstring pl := '010301'O;
Vadim Yanitskiy31e7c672018-07-27 02:23:16 +07001637 L1CTL.send(ts_L1CTL_DATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0),
1638 f_pad_oct(pl, 23, '2B'O)));
Harald Welte70767382018-02-21 12:16:40 +01001639 repeat;
1640 }
1641}
1642
1643type record MeasElem {
1644 uint6_t rxlev,
1645 uint3_t rxqual
1646}
1647
1648type record MeasElemFS {
1649 MeasElem full,
1650 MeasElem sub
1651}
1652
1653type record ConnL1Pars {
1654 boolean dtx_enabled,
Harald Welte685d5982018-02-27 20:42:05 +01001655 boolean toa256_enabled,
Harald Welte70767382018-02-21 12:16:40 +01001656 MeasElemFS meas_ul,
1657 int16_t timing_offset_256syms,
1658 uint5_t bs_power_level,
1659 uint5_t ms_power_level,
1660 uint8_t ms_actual_ta
1661}
1662
1663/* Convert tiing offset from 1/256th symbol to RSL Timing Offset */
1664private function toffs256s_to_rsl(int16_t toffs256s) return uint8_t {
1665 return 63 + (toffs256s/256);
1666}
1667
Harald Welted5684392018-03-10 18:22:04 +01001668private function f_max(integer a, integer b) return integer {
1669 if (a > b) {
1670 return a;
1671 } else {
1672 return b;
1673 }
1674}
1675
1676private function f_min(integer a, integer b) return integer {
1677 if (a < b) {
1678 return a;
1679 } else {
1680 return b;
1681 }
1682}
1683
1684/* compute negative tolerance val-tolerance, ensure >= min */
1685private function f_tolerance_neg(integer val, integer min, integer tolerance) return integer {
1686 val := val - tolerance;
1687 return f_max(val, min);
1688}
1689
1690/* compute positive tolerance val+tolerance, ensure <= max */
1691private function f_tolerance_pos(integer val, integer max, integer tolerance) return integer {
1692 val := val + tolerance;
1693 return f_min(val, max);
1694}
1695
1696/* return a template of (val-tolerance .. val+tolerance) ensuring it is within (min .. max) */
1697private function f_tolerance(integer val, integer min, integer max, integer tolerance)
1698return template integer {
1699 var template integer ret;
1700 ret := (f_tolerance_neg(val, min, tolerance) .. f_tolerance_pos(val, max, tolerance));
1701 return ret;
1702}
1703
1704
Harald Welte70767382018-02-21 12:16:40 +01001705/* build a template for matching measurement results against */
1706private function f_build_meas_res_tmpl() runs on ConnHdlr return template RSL_Message {
1707 var ConnL1Pars l1p := g_pars.l1_pars;
1708 var template RSL_IE_UplinkMeas ul_meas := {
1709 len := 3,
1710 rfu := '0'B,
1711 dtx_d := l1p.dtx_enabled,
Harald Welted5684392018-03-10 18:22:04 +01001712 rxlev_f_u := f_tolerance(l1p.meas_ul.full.rxlev, 0, 63, mp_tolerance_rxlev),
Harald Welte70767382018-02-21 12:16:40 +01001713 reserved1 := '00'B,
Harald Welted5684392018-03-10 18:22:04 +01001714 rxlev_s_u := f_tolerance(l1p.meas_ul.sub.rxlev, 0, 63, mp_tolerance_rxlev),
Harald Welte70767382018-02-21 12:16:40 +01001715 reserved2 := '00'B,
Harald Welted5684392018-03-10 18:22:04 +01001716 rxq_f_u := f_tolerance(l1p.meas_ul.full.rxqual, 0, 7, mp_tolerance_rxqual),
1717 rxq_s_u := f_tolerance(l1p.meas_ul.sub.rxqual, 0, 7, mp_tolerance_rxqual),
Harald Welte70767382018-02-21 12:16:40 +01001718 supp_meas_info := omit
1719 };
Harald Welte685d5982018-02-27 20:42:05 +01001720 if (l1p.toa256_enabled) {
Harald Welte15de8ba2018-06-29 08:51:42 +02001721 ul_meas.len := (3+8);
1722 ul_meas.supp_meas_info := {
Pau Espin Pedrol121724c2018-09-28 15:58:12 +02001723 toa256_mean := f_tolerance(l1p.timing_offset_256syms, -63*256, 192*256, mp_tolerance_timing_offset_256syms),
Harald Welte15de8ba2018-06-29 08:51:42 +02001724 toa256_min := ?,
1725 toa256_max := ?,
1726 toa256_std_dev := ?
1727 }
Harald Welte685d5982018-02-27 20:42:05 +01001728 }
Harald Welte70767382018-02-21 12:16:40 +01001729 var template RSL_IE_BS_Power bs_power := {
1730 reserved := 0,
1731 epc := false,
1732 fpc := false,
1733 power_level := l1p.bs_power_level
1734 };
1735 var template RSL_IE_L1Info l1_info := {
1736 ms_power_lvl := l1p.ms_power_level,
1737 fpc := false,
1738 reserved := 0,
Pau Espin Pedrol121724c2018-09-28 15:58:12 +02001739 actual_ta := f_tolerance(l1p.ms_actual_ta, 0, 63, mp_tolerance_timing_offset_256syms/256)
Harald Welte70767382018-02-21 12:16:40 +01001740 };
1741 var uint8_t offs := toffs256s_to_rsl(l1p.timing_offset_256syms);
Pau Espin Pedrol121724c2018-09-28 15:58:12 +02001742 var template uint8_t t_toffs := f_tolerance(offs, 0, 255, mp_tolerance_timing_offset_256syms/256);
Harald Welte70767382018-02-21 12:16:40 +01001743 return tr_RSL_MEAS_RES_OSMO(g_chan_nr, g_next_meas_res_nr, ul_meas, bs_power, l1_info,
1744 ?, t_toffs);
1745}
1746
Philipp Maierdd841d32019-12-17 14:44:54 +01001747/* build a template for matching measurement results that do not contain any
1748 * MS related measurement (l1_info, l3_info and ms timing offset). */
1749private function f_build_meas_res_tmpl_empty() runs on ConnHdlr return template RSL_Message {
1750 var ConnL1Pars l1p := g_pars.l1_pars;
1751 var template RSL_IE_UplinkMeas ul_meas := {
1752 len := 3,
1753 rfu := '0'B,
1754 dtx_d := l1p.dtx_enabled,
1755 rxlev_f_u := ?,
1756 reserved1 := '00'B,
1757 rxlev_s_u := ?,
1758 reserved2 := '00'B,
1759 rxq_f_u := ?,
1760 rxq_s_u := ?,
1761 supp_meas_info := omit
1762 };
1763 if (l1p.toa256_enabled) {
1764 ul_meas.len := (3+8);
1765 ul_meas.supp_meas_info := {
1766 toa256_mean := f_tolerance(l1p.timing_offset_256syms, -63*256, 192*256, mp_tolerance_timing_offset_256syms),
1767 toa256_min := ?,
1768 toa256_max := ?,
1769 toa256_std_dev := ?
1770 }
1771 }
1772 var template RSL_IE_BS_Power bs_power := {
1773 reserved := 0,
1774 epc := false,
1775 fpc := false,
1776 power_level := l1p.bs_power_level
1777 };
1778
1779 return tr_RSL_MEAS_RES_EMPTY(g_chan_nr, g_next_meas_res_nr, ul_meas, bs_power);
1780}
1781
Harald Welte70767382018-02-21 12:16:40 +01001782/* verify we regularly receive measurement reports with incrementing numbers */
Vadim Yanitskiy41baf002018-10-04 17:44:50 +07001783altstep as_meas_res(boolean verify_meas := true) runs on ConnHdlr {
Harald Welte70767382018-02-21 12:16:40 +01001784 var RSL_Message rsl;
Philipp Maierdd841d32019-12-17 14:44:54 +01001785 var boolean chan_est := false;
1786
Vadim Yanitskiy41baf002018-10-04 17:44:50 +07001787 [not verify_meas] RSL.receive(tr_RSL_MEAS_RES(?)) { repeat; }
Philipp Maierdd841d32019-12-17 14:44:54 +01001788
1789 /* Receive osmocom specific measurement reports. This is the normal
1790 * case. Here we verify that the measurement reports we sent are
1791 * comming back as we expect them. */
Harald Welte70767382018-02-21 12:16:40 +01001792 [] RSL.receive(f_build_meas_res_tmpl()) -> value rsl {
1793 /* increment counter of next to-be-expected meas rep */
1794 g_next_meas_res_nr := (g_next_meas_res_nr + 1) mod 256;
1795 /* Re-start the timer expecting the next MEAS RES */
Harald Weltec3a3f452018-02-26 17:37:47 +01001796 f_timer_safe_restart(g_Tmeas_exp);
Philipp Maierdd841d32019-12-17 14:44:54 +01001797
1798 /* The following two cases may only happen in the beginning
1799 * of the channel establishment phase. Once we have received
1800 * the "our" measurement report the first time, the channel
1801 * is established and empty or hardcoded TRXCON reports must
1802 * not occur anymore. */
1803 chan_est := true;
1804
1805 repeat;
1806 }
1807
1808 /* When the BTS has established the channel, the MS might need slightly
1809 * more time to establish the channel and actually start sending. The
1810 * result is then a measurement report that just lacks the measurement
1811 * information of the MS. This is normal and we tolerate this behavior. */
1812 [chan_est == false] RSL.receive(f_build_meas_res_tmpl_empty()) -> value rsl {
1813 /* increment counter of next to-be-expected meas rep */
1814 g_next_meas_res_nr := (g_next_meas_res_nr + 1) mod 256;
1815 /* Re-start the timer expecting the next MEAS RES */
1816 f_timer_safe_restart(g_Tmeas_exp);
Harald Welte70767382018-02-21 12:16:40 +01001817 repeat;
1818 }
Philipp Maierdd841d32019-12-17 14:44:54 +01001819
1820 /* Due to the TDMA nature of GSM, TRXCON implements a way to emit dummy
1821 * measurements if the TTCN3 side does not supply measurement input in
1822 * time. In those cases TRXCON will either use a cached measurement
1823 * report or a hardcoded one. If TRXCON picks the hardcoded measurement
1824 * report the templates above will not match. We tolerate this
1825 * behavior, but only once. */
1826 [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 +01001827 /* increment counter of next to-be-expected meas rep */
1828 g_next_meas_res_nr := (g_next_meas_res_nr + 1) mod 256;
1829 if (g_first_meas_res) {
1830 g_first_meas_res := false;
1831 repeat;
1832 } else {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001833 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Received unspecific MEAS RES ", rsl));
Harald Weltefa45e9e2018-03-10 18:59:03 +01001834 }
Harald Welte70767382018-02-21 12:16:40 +01001835 }
1836 [] RSL.receive(tr_RSL_MEAS_RES(?)) -> value rsl {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001837 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Received unexpected MEAS RES ", rsl));
Harald Welte70767382018-02-21 12:16:40 +01001838 }
Pau Espin Pedrol425b62f2018-07-06 16:11:43 +02001839 [g_Tmeas_exp.running] g_Tmeas_exp.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001840 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Didn't receive expected measurement result")
Harald Welte70767382018-02-21 12:16:40 +01001841 }
1842}
1843
Harald Weltee613f962018-04-18 22:38:16 +02001844private function f_alg_id_to_l1ctl(RSL_AlgId rsl_alg_id) return uint8_t {
1845 select (rsl_alg_id) {
1846 case (RSL_ALG_ID_A5_0) { return 0; }
1847 case (RSL_ALG_ID_A5_1) { return 1; }
1848 case (RSL_ALG_ID_A5_2) { return 2; }
1849 case (RSL_ALG_ID_A5_3) { return 3; }
1850 case (RSL_ALG_ID_A5_4) { return 4; }
1851 case (RSL_ALG_ID_A5_5) { return 5; }
1852 case (RSL_ALG_ID_A5_6) { return 6; }
1853 case (RSL_ALG_ID_A5_7) { return 7; }
1854 case else {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001855 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unknwon Algorithm ID");
1856 /* Make compiler happy by calling mtc.stop here. It is already
1857 * called in f_shutdown */
Daniel Willmann17ddd852018-07-05 17:33:20 +02001858 mtc.stop;
Harald Weltee613f962018-04-18 22:38:16 +02001859 }
1860 }
1861}
1862
1863private function f_alg_id_to_l3(RSL_AlgId rsl_alg_id) return BIT3 {
1864 select (rsl_alg_id) {
1865 case (RSL_ALG_ID_A5_1) { return '000'B; }
1866 case (RSL_ALG_ID_A5_2) { return '001'B; }
1867 case (RSL_ALG_ID_A5_3) { return '010'B; }
1868 case (RSL_ALG_ID_A5_4) { return '011'B; }
1869 case (RSL_ALG_ID_A5_5) { return '100'B; }
1870 case (RSL_ALG_ID_A5_6) { return '101'B; }
1871 case (RSL_ALG_ID_A5_7) { return '110'B; }
1872 case else {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001873 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unknwon Algorithm ID");
1874 /* Make compiler happy by calling mtc.stop here. It is already
1875 * called in f_shutdown */
Daniel Willmann17ddd852018-07-05 17:33:20 +02001876 mtc.stop;
Harald Weltee613f962018-04-18 22:38:16 +02001877 }
1878 }
1879}
1880
Pau Espin Pedrol6451b042018-10-24 20:36:16 +02001881/* Send RACH request through l1CTL and wait for ChanReq on RSL BST->BSC */
1882private function f_rach_req_wait_chan_rqd(integer ra) runs on ConnHdlr return GsmFrameNumber {
1883 var GsmFrameNumber fn;
1884 timer T := 8.0;
1885
1886 /* advertise to RSL Emulation that we expect to receive confirmation from RACH */
1887 RSL.send(ts_RSLDC_ChanRqd_anyFN(int2oct(ra,1)));
1888
1889 f_L1CTL_PARAM(L1CTL, g_pars.l1_pars.ms_actual_ta, g_pars.l1_pars.ms_power_level);
1890 /* Send the actual RACH */
1891 fn := f_L1CTL_RACH(L1CTL, ra);
1892
1893 T.start;
1894 alt {
1895 [] RSL.receive(tr_RSL_CHAN_RQD(int2oct(ra,1), fn)) { setverdict(pass, "Received CHAN-RQD from RACH REQ") }
1896 [] T.timeout {
1897 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Timeout waiting for CHAN-RQD from RACH REQ <", ra, ", ", fn, ">"));
1898 }
1899 }
1900 T.stop
1901 return fn;
1902}
Harald Weltee613f962018-04-18 22:38:16 +02001903
Harald Welte70767382018-02-21 12:16:40 +01001904/* Establish dedicated channel: L1CTL + RSL side */
Harald Weltec8d363c2019-05-19 20:36:48 +02001905private function f_est_dchan(boolean encr_enable := false, RSL_IE_List more_ies := {}) runs on ConnHdlr {
Harald Welte70767382018-02-21 12:16:40 +01001906 var GsmFrameNumber fn;
1907 var ImmediateAssignment imm_ass;
1908 var integer ra := 23;
1909
Pau Espin Pedrol6451b042018-10-24 20:36:16 +02001910 /* Send RACH request and wait for ChanReq */
1911 fn := f_rach_req_wait_chan_rqd(ra);
Harald Welte70767382018-02-21 12:16:40 +01001912
1913 /* Activate channel on BTS side */
Harald Weltec8d363c2019-05-19 20:36:48 +02001914 f_rsl_chan_act(g_pars.chan_mode, encr_enable, more_ies);
Harald Welte70767382018-02-21 12:16:40 +01001915
1916 /* Send IMM.ASS via CCHAN */
1917 var ChannelDescription ch_desc := {
1918 chan_nr := g_pars.chan_nr,
1919 tsc := 7,
1920 h := false,
1921 arfcn := mp_trx0_arfcn,
1922 maio_hsn := omit
1923 };
1924 var MobileAllocation ma := {
1925 len := 0,
1926 ma := ''B
1927 };
1928 var GsmRrMessage rr_msg := valueof(ts_IMM_ASS(ra, fn, 0, ch_desc, ma));
1929 RSL.send(ts_RSL_IMM_ASSIGN(enc_GsmRrMessage(rr_msg)));
1930
1931 /* receive IMM.ASS on MS side */
1932 var ImmediateAssignment ia_um;
1933 ia_um := f_L1CTL_WAIT_IMM_ASS(L1CTL, ra, fn);
1934 /* enable dedicated mode */
1935 f_L1CTL_DM_EST_REQ_IA(L1CTL, ia_um);
Harald Weltee613f962018-04-18 22:38:16 +02001936 /* enable encryption, if requested */
1937 if (encr_enable) {
1938 var uint8_t alg_id := f_alg_id_to_l1ctl(g_pars.encr.alg_id);
1939 f_L1CTL_CRYPTO_REQ(L1CTL, g_pars.chan_nr, alg_id, g_pars.encr.key);
1940 }
Harald Weltefa45e9e2018-03-10 18:59:03 +01001941
1942 g_first_meas_res := true;
Harald Welte70767382018-02-21 12:16:40 +01001943}
1944
1945/* establish DChan, verify existance + contents of measurement reports */
1946function f_TC_meas_res_periodic(charstring id) runs on ConnHdlr {
Harald Welte68e495b2018-02-25 00:05:57 +01001947 f_l1_tune(L1CTL);
Harald Welte70767382018-02-21 12:16:40 +01001948 RSL.clear;
1949
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +07001950 if (mp_bts_trxc_port != -1) {
Pau Espin Pedrole9571aa2018-10-22 17:13:07 +02001951 f_trxc_fake_rssi(rxlev2dbm(mp_ul_rxlev_exp));
Vadim Yanitskiydc8db922019-06-04 21:58:15 +07001952 f_trxc_fake_toffs256(g_pars.l1_pars.timing_offset_256syms);
Pau Espin Pedrol121724c2018-09-28 15:58:12 +02001953 }
Harald Welte70767382018-02-21 12:16:40 +01001954
1955 f_est_dchan();
1956
1957 /* run for a number of seconds, send SACCH + FACCH from MS side and verify
1958 * RSL measurement reports on Abis side */
1959 timer T := 8.0;
1960 T.start;
1961 alt {
1962 [] as_l1_sacch();
1963 [] as_meas_res();
1964 [] as_l1_dcch();
1965 [] L1CTL.receive { repeat; }
1966 [g_Tmeas_exp.running] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001967 /* as_meas_res() would have done Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail) in case
Harald Welte70767382018-02-21 12:16:40 +01001968 * of any earlier errors, so if we reach this timeout, we're good */
1969 setverdict(pass);
1970 }
1971 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001972 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "No MEAS RES received at all");
Harald Welte70767382018-02-21 12:16:40 +01001973 }
1974 }
1975 f_rsl_chan_deact();
Harald Welte3dc20462018-03-10 23:03:38 +01001976 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
Harald Welte70767382018-02-21 12:16:40 +01001977}
Harald Welte0472ab42018-03-12 15:02:26 +01001978
Eric Wildae8f2622019-06-18 17:05:11 +02001979function f_check_meas_bs_power_level(integer level) runs on ConnHdlr {
1980 timer T := 8.0;
1981 T.start;
1982 var RSL_Message rsl;
1983 alt {
1984 [] as_l1_sacch();
1985 [] L1CTL.receive { repeat; }
1986 [] RSL.receive(tr_RSL_MEAS_RES(g_chan_nr, ?, ?, ?)) -> value rsl {
1987 if (rsl.ies[3].body.bs_power.power_level == level) {
1988 setverdict(pass)
1989 } else {
1990 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Received wrong BS power level in MEAS RES ", rsl));
1991 }
1992 }
1993 [] T.timeout {
1994 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "No MEAS RES received at all");
1995 }
1996 }
1997}
1998
1999/* see if the rsl meas res contains our expeced bs power level
2000bs power set during assignment */
2001function f_TC_rsl_bs_pwr_static_ass(charstring id) runs on ConnHdlr {
2002 f_l1_tune(L1CTL);
2003 RSL.clear;
2004
2005 if (mp_bts_trxc_port != -1) {
2006 f_trxc_fake_rssi(rxlev2dbm(mp_ul_rxlev_exp));
2007 f_trxc_fake_toffs256(g_pars.l1_pars.timing_offset_256syms);
2008 }
2009
2010 var uint5_t pwr_var := 1;
2011 var template (value) RSL_IE_BS_Power bs_power := ts_RSL_IE_BS_Power(pwr_var);
2012 var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_BS_POWER, RSL_IE_Body:{bs_power := bs_power});
2013
2014 f_est_dchan(more_ies :={valueof(pwr)});
2015
2016 f_check_meas_bs_power_level(pwr_var);
2017
2018 f_rsl_chan_deact();
2019 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
2020}
2021
2022/* see if the rsl meas res contains our expeced bs power level
2023bs power set after assignment */
2024function f_TC_rsl_bs_pwr_static_power_control(charstring id) runs on ConnHdlr {
2025 f_l1_tune(L1CTL);
2026 RSL.clear;
2027
2028 if (mp_bts_trxc_port != -1) {
2029 f_trxc_fake_rssi(rxlev2dbm(mp_ul_rxlev_exp));
2030 f_trxc_fake_toffs256(g_pars.l1_pars.timing_offset_256syms);
2031 }
2032
2033 var uint5_t pwr_var := 1;
2034 var template (value) RSL_IE_BS_Power bs_power := ts_RSL_IE_BS_Power(pwr_var);
2035
2036 f_est_dchan();
2037
2038 RSL.send(ts_RSL_BS_PWR_CTRL(g_chan_nr, bs_power));
2039
2040 f_check_meas_bs_power_level(pwr_var);
2041
2042 f_rsl_chan_deact();
2043 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
2044}
2045
2046testcase TC_rsl_bs_pwr_static_ass() runs on test_CT {
2047 var ConnHdlr vc_conn;
2048 var ConnHdlrPars pars;
2049 f_init();
2050 for (var integer tn := 1; tn <= 4; tn := tn+1) {
2051 pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN));
2052 vc_conn := f_start_handler(refers(f_TC_rsl_bs_pwr_static_ass), pars,
2053 pcu_comp := false, trxc_comp := true);
2054 vc_conn.done;
2055 }
2056 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
2057}
2058
2059testcase TC_rsl_bs_pwr_static_power_control() runs on test_CT {
2060 var ConnHdlr vc_conn;
2061 var ConnHdlrPars pars;
2062 f_init();
2063 for (var integer tn := 1; tn <= 4; tn := tn+1) {
2064 pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN));
2065 vc_conn := f_start_handler(refers(f_TC_rsl_bs_pwr_static_power_control), pars,
2066 pcu_comp := false, trxc_comp := true);
2067 vc_conn.done;
2068 }
2069 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
2070}
2071
Eric Wild61edb7e2019-06-03 12:38:31 +02002072/* target level -100, first rssi -90, ms power 7, expected increase to 7+6 within 6 seconds,
2073second rssi -110, ms power 7+6, expected decrease to 7 within 6 seconds,
2074These power levels are valid for all bands and require no special handling */
2075function f_TC_rsl_ms_pwr_dyn_ass_updown(charstring id) runs on ConnHdlr {
2076 var uint5_t pwr_var := 7;
2077 var L1ctlDlMessage l1_dl;
2078
2079 f_trxc_fake_rssi(rxlev2dbm(10));
2080 f_l1_tune(L1CTL);
2081 RSL.clear;
2082
2083 var RSL_IE_List addl_ies;
2084 var template (value) RSL_IE_MS_Power_Parameters pp := (ts_RSL_IE_MS_Power_Parameters(''O));
2085
2086 addl_ies := {
2087 valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(pwr_var)})),
2088 valueof(t_RSL_IE(RSL_IE_MS_POWER_PARAM, RSL_IE_Body:{ms_power_params := pp}))
2089 };
2090
2091 /* establish with power parameters */
2092 f_est_dchan(more_ies := addl_ies);
2093
2094 /* set a high value to ensure L1 power control level increases */
2095 f_trxc_fake_rssi(rxlev2dbm(20));
2096
2097 timer T2 := 6.0;
2098 T2.start;
2099 alt {
2100 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl {
Pau Espin Pedrola1f7d242019-12-04 16:08:09 +01002101 /* Update sent MS power to follow what BTS requests */
2102 f_L1CTL_PARAM(L1CTL, g_pars.l1_pars.ms_actual_ta, oct2int(l1_dl.payload.data_ind.payload[0]));
2103 if (oct2int(l1_dl.payload.data_ind.payload[0]) < (pwr_var + 6)) {
Eric Wild61edb7e2019-06-03 12:38:31 +02002104 repeat;
Pau Espin Pedrola1f7d242019-12-04 16:08:09 +01002105 }
Eric Wild61edb7e2019-06-03 12:38:31 +02002106 T2.stop;
2107 }
2108 [] L1CTL.receive { repeat; }
2109 [] T2.timeout {
2110 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
2111 "Power Level in L1 header has not increased sufficiently");
2112 }
2113 }
2114
2115 /* set a low value to ensure L1 power control level decreases */
2116 f_trxc_fake_rssi(rxlev2dbm(0));
2117
2118 timer T4 := 6.0;
2119 T4.start;
2120 alt {
2121 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl {
Pau Espin Pedrola1f7d242019-12-04 16:08:09 +01002122 /* Update sent MS power to follow what BTS requests */
2123 f_L1CTL_PARAM(L1CTL, g_pars.l1_pars.ms_actual_ta, oct2int(l1_dl.payload.data_ind.payload[0]));
2124 if (oct2int(l1_dl.payload.data_ind.payload[0]) > pwr_var) {
Eric Wild61edb7e2019-06-03 12:38:31 +02002125 repeat;
Pau Espin Pedrola1f7d242019-12-04 16:08:09 +01002126 }
Eric Wild61edb7e2019-06-03 12:38:31 +02002127 T4.stop;
2128 setverdict(pass, "Power level in L1 decreased/increased as expected");
2129 }
2130 [] L1CTL.receive { repeat; }
2131 [] T4.timeout {
2132 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
2133 "Power Level in L1 header has not decreased sufficiently");
2134 }
2135 }
2136
2137 f_rsl_chan_deact();
2138 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
2139
2140}
2141
2142/* check that we do not exceed the max power */
2143function f_TC_rsl_ms_pwr_dyn_max(charstring id) runs on ConnHdlr {
2144 var uint5_t pwr_var := 7;
2145 var L1ctlDlMessage l1_dl;
2146
2147 /* set a low value to ensure power increases */
2148 f_trxc_fake_rssi(rxlev2dbm(10));
2149 f_l1_tune(L1CTL);
2150 RSL.clear;
2151
2152 var RSL_IE_List addl_ies;
2153 var template (value) RSL_IE_MS_Power_Parameters pp := (ts_RSL_IE_MS_Power_Parameters(''O));
2154
2155 addl_ies := {
2156 valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(pwr_var)})),
2157 valueof(t_RSL_IE(RSL_IE_MS_POWER_PARAM, RSL_IE_Body:{ms_power_params := pp}))
2158 };
2159
2160 /* establish with power parameters */
2161 f_est_dchan(more_ies := addl_ies);
2162
2163 timer T1 := 10.0;
2164 T1.start;
2165 alt {
Pau Espin Pedrola1f7d242019-12-04 16:08:09 +01002166 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl {
2167 /* Update sent MS power to follow what BTS requests */
2168 f_L1CTL_PARAM(L1CTL, g_pars.l1_pars.ms_actual_ta, oct2int(l1_dl.payload.data_ind.payload[0]));
2169 repeat;
2170 }
Eric Wild61edb7e2019-06-03 12:38:31 +02002171 [] L1CTL.receive { repeat; }
2172 [] T1.timeout {
2173 if( oct2int(l1_dl.payload.data_ind.payload[0]) != pwr_var){
2174 setverdict(fail, "Power level in L1 header should not have changed");
2175 }
2176 }
2177 }
2178
2179 f_rsl_chan_deact();
2180 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
2181
2182}
2183
2184/* see if we reach the band max power */
2185function f_TC_rsl_ms_pwr_dyn_up(charstring id) runs on ConnHdlr {
2186 var L1ctlDlMessage l1_dl;
2187 var uint5_t pwr_var := 15;
2188 var uint5_t pwr_max_var := f_get_max_power_from_band();
2189
2190 /* set a low value to ensure power increases */
2191 f_trxc_fake_rssi(rxlev2dbm(10));
2192 f_l1_tune(L1CTL);
2193 RSL.clear;
2194
2195 var template (value) RSL_IE_MS_Power ms_power := ts_RSL_IE_MS_Power(pwr_var);
2196 var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power});
2197
2198 /* establish with fixed power level */
2199 f_est_dchan(more_ies :={valueof(pwr)});
2200
2201 /* check our initial power level */
2202 f_wait_for_l1_power_level(pwr_var);
2203
2204 /* update power param to enable power loop
2205 48.058 The maximum power to be used is indicated in the BS and MS Power elements respectively. */
2206 RSL.send(ts_RSL_MS_PWR_CTRL_with_pp(g_chan_nr, pwr_max_var));
2207
2208 /* wait, then check that our power level was reduced */
2209 timer T1 := 10.0;
2210 T1.start;
2211 alt {
Pau Espin Pedrola1f7d242019-12-04 16:08:09 +01002212 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl {
2213 /* Update sent MS power to follow what BTS requests */
2214 f_L1CTL_PARAM(L1CTL, g_pars.l1_pars.ms_actual_ta, oct2int(l1_dl.payload.data_ind.payload[0]));
2215 repeat;
2216 }
Eric Wild61edb7e2019-06-03 12:38:31 +02002217 [] L1CTL.receive { repeat; }
2218 [] T1.timeout {
2219 var int8_t rcv := oct2int(l1_dl.payload.data_ind.payload[0]);
2220 if( f_power_level_is_highest_dbm(rcv) ){
2221 setverdict(pass, "Power level in L1 header reduced as expected");
2222 } else {
2223 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
2224 log2str("Power Level in L1 header did not reach the expected value, e:",pwr_max_var," r:",rcv));
2225 }
2226 }
2227 }
2228
2229 f_rsl_chan_deact();
2230 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
2231
2232}
2233
2234/* see if we reach the band min power */
2235function f_TC_rsl_ms_pwr_dyn_down(charstring id) runs on ConnHdlr {
2236 var L1ctlDlMessage l1_dl;
2237
2238 /* set a high value to ensure power decreases */
2239 f_trxc_fake_rssi(rxlev2dbm(50));
2240 f_l1_tune(L1CTL);
2241 RSL.clear;
2242
2243 var uint5_t pwr_var := 5;
2244 var uint5_t pwr_target_val := 15;
2245
2246 var template (value) RSL_IE_MS_Power ms_power := ts_RSL_IE_MS_Power(pwr_var);
2247 var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power});
2248
2249 /* establish with fixed power level */
2250 f_est_dchan(more_ies :={valueof(pwr)});
2251
2252 /* check our initial power level */
2253 f_wait_for_l1_power_level(pwr_var);
2254
2255 /* update power param to enable power loop
2256 as per spec the supplied ms power IE should set the max allowed power...*/
Pau Espin Pedrol61122c82019-11-05 13:50:27 +01002257 RSL.send(ts_RSL_MS_PWR_CTRL_with_pp(g_chan_nr, pwr_target_val));
Eric Wild61edb7e2019-06-03 12:38:31 +02002258
2259 /* wait, then check that our power level was increased */
2260 timer T1 := 10.0;
2261 T1.start;
2262 alt {
Pau Espin Pedrola1f7d242019-12-04 16:08:09 +01002263 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl {
2264 /* Update sent MS power to follow what BTS requests */
2265 f_L1CTL_PARAM(L1CTL, g_pars.l1_pars.ms_actual_ta, oct2int(l1_dl.payload.data_ind.payload[0]));
2266 repeat;
2267 }
Eric Wild61edb7e2019-06-03 12:38:31 +02002268 [] L1CTL.receive { repeat; }
2269 [] T1.timeout {
2270 if( f_power_level_is_lowest_dbm(oct2int(l1_dl.payload.data_ind.payload[0])) ){
2271 setverdict(pass, "Power level in L1 header increased to lowest power value");
2272 } else {
2273 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
2274 "Power level in L1 header NOT increased to lowest power value");
2275 }
2276 }
2277 }
2278
2279 f_rsl_chan_deact();
2280 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
2281
2282}
2283
Eric Wild095024b2019-06-17 15:08:57 +02002284/* see if we change the power level without receiving power parameters, which should not happen
2285rsl chan act WITHOUT power parameters */
Eric Wild280ccb82019-06-17 11:11:52 +02002286function f_TC_rsl_ms_pwr_dyn_active(charstring id) runs on ConnHdlr {
2287 var L1ctlDlMessage l1_dl;
2288
2289 /* set a high value to ensure power decreases */
2290 f_trxc_fake_rssi(rxlev2dbm(50));
2291 f_l1_tune(L1CTL);
2292 RSL.clear;
2293
2294 var uint5_t pwr_var := 5;
2295
2296 var template (value) RSL_IE_MS_Power ms_power := ts_RSL_IE_MS_Power(pwr_var);
2297 var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power});
2298
2299 /* establish with fixed power level */
2300 f_est_dchan(more_ies :={valueof(pwr)});
2301
2302 /* check our initial power level */
2303 f_wait_for_l1_power_level(pwr_var);
2304
2305 /* wait, then check that our power level did not change */
2306 timer T1 := 10.0;
2307 T1.start;
2308 alt {
2309 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl {
2310 if ( oct2int(l1_dl.payload.data_ind.payload[0]) != pwr_var) {
2311 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
2312 "BS power control should not be active unless we receive a power parameters IE!");
2313 }
2314 repeat;
2315 }
2316 [] L1CTL.receive { repeat; }
2317 [] T1.timeout { setverdict(pass); }
2318 }
2319
2320 f_rsl_chan_deact();
2321 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
2322
2323}
2324
Eric Wild095024b2019-06-17 15:08:57 +02002325/* see if we change the power level without receiving power parameters, which should not happen
2326ms power control WITHOUT power parameters */
2327function f_TC_rsl_ms_pwr_dyn_active2(charstring id) runs on ConnHdlr {
2328 var L1ctlDlMessage l1_dl;
2329
2330 /* set a high value to ensure power decreases */
2331 f_trxc_fake_rssi(rxlev2dbm(50));
2332 f_l1_tune(L1CTL);
2333 RSL.clear;
2334
2335 var uint5_t pwr_var := 5;
2336
2337 var template (value) RSL_IE_MS_Power ms_power := ts_RSL_IE_MS_Power(pwr_var);
2338 var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power});
2339
2340 /* establish with fixed power level */
2341 f_est_dchan(more_ies :={valueof(pwr)});
2342
2343 /* check our initial power level */
2344 f_wait_for_l1_power_level(pwr_var);
2345
2346 /* pwr control without power params IE, should NOT activate MS power control*/
2347 RSL.send(ts_RSL_MS_PWR_CTRL(g_chan_nr, ms_power));
2348
2349 /* wait, then check that our power level did not change */
2350 timer T1 := 10.0;
2351 T1.start;
2352 alt {
2353 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl {
2354 if ( oct2int(l1_dl.payload.data_ind.payload[0]) != pwr_var) {
2355 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
2356 "BS power control should not be active unless we receive a power parameters IE!");
2357 }
2358 repeat;
2359 }
2360 [] L1CTL.receive { repeat; }
2361 [] T1.timeout { setverdict(pass); }
2362 }
2363
2364 f_rsl_chan_deact();
2365 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
2366
2367}
2368
Eric Wild61edb7e2019-06-03 12:38:31 +02002369function f_wait_for_l1_power_level(integer level) runs on ConnHdlr {
2370 var L1ctlDlMessage l1_dl;
2371 timer T0 := 10.0;
2372 T0.start;
2373 alt {
2374 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl {
2375 if (not (l1_dl.payload.data_ind.payload[0] == int2oct(level, 1))) {
2376 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
2377 "Power level in L1 header != signaled (RSL) power level.");
2378 }
2379 }
2380 [] L1CTL.receive { repeat; }
2381 [] T0.timeout {
2382 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
2383 "Timeout waiting for initial power level");
2384 }
2385 }
2386 T0.stop;
2387}
2388
2389private function f_power_level_is_lowest_dbm(integer level) runs on ConnHdlr return boolean {
2390 var IntegerRecord min_dbm_level;
2391 var IntegerRecord max_dbm_level;
2392 var IntegerRecord x := f_power_from_band(g_pars.bts0_band, min_dbm_level, max_dbm_level);
2393
2394 for (var integer i := 0; i < sizeof(min_dbm_level); i := i+1) {
2395 if (min_dbm_level[i] == level) {
2396 return true;
2397 }
2398 }
2399 return false;
2400}
2401
2402private function f_power_level_is_highest_dbm(integer level) runs on ConnHdlr return boolean {
2403 var IntegerRecord min_dbm_level;
2404 var IntegerRecord max_dbm_level;
2405 var IntegerRecord x := f_power_from_band(g_pars.bts0_band, min_dbm_level, max_dbm_level);
2406
2407 for (var integer i := 0; i < sizeof(max_dbm_level); i := i+1) {
2408 if (max_dbm_level[i] == level) {
2409 return true;
2410 }
2411 }
2412 return false;
2413}
2414
2415private function f_get_max_power_from_band() runs on ConnHdlr return integer {
2416 var IntegerRecord min_dbm_level;
2417 var IntegerRecord max_dbm_level;
2418 var IntegerRecord x := f_power_from_band(g_pars.bts0_band, min_dbm_level, max_dbm_level);
2419 return max_dbm_level[0];
2420}
2421
2422type charstring BtsBand ("GSM450","GSM480","GSM750","GSM810","GSM850","GSM900","DCS1800","PCS1900");
2423template charstring BtsBand_allGSM:= pattern "GSM???";
2424private function f_power_from_band(in BtsBand band, out IntegerRecord min_dbm_level, out IntegerRecord max_dbm_level) return IntegerRecord {
2425 // 45.005 4.1.1
2426 var IntegerRecord gsm_power :={31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19,
2427 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3,
2428 2, 1, 0};
2429 var IntegerRecord dcs_power :={28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15,
2430 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 31, 30, 29};
2431 var IntegerRecord pcs_power :={15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 31, 30};
2432 var IntegerRecord rv;
2433
2434 select(band){
2435 case (BtsBand_allGSM){
2436 rv := gsm_power;
2437 min_dbm_level := {31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19} ;
2438 max_dbm_level := {2, 1, 0};
2439 }
2440 case("DCS1800"){
2441 rv := dcs_power;
2442 min_dbm_level := {28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15};
2443 max_dbm_level := {0, 29}; // let's cheat here, assume MS_TXPWR_MAX_CCH might be being broadcast, so maybe no 29,30,31
2444 }
2445 case("PCS1900"){
2446 rv := pcs_power;
2447 min_dbm_level := {15};
2448 max_dbm_level := {30};
2449 }
2450 }
2451
2452 return rv;
2453}
2454
2455private function f_vty_get_bts0_band() runs on test_CT return BtsBand {
2456 return f_vty_transceive_match_regex(BTSVTY, "show bts 0", "BTS 0 is of \w+ type in band (\w+),*", 0);
2457}
2458
2459testcase TC_rsl_ms_pwr_dyn_ass_updown() runs on test_CT {
2460 var ConnHdlr vc_conn;
2461 var ConnHdlrPars pars;
2462 f_init();
2463 f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -100");
2464 for (var integer tn := 1; tn <= 1; tn := tn+1) {
2465 pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN));
2466 pars.bts0_band := f_vty_get_bts0_band();
2467 vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_ass_updown), pars, trxc_comp := true);
2468 vc_conn.done;
2469 }
2470 f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop");
2471 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
2472}
2473
2474testcase TC_rsl_ms_pwr_dyn_up() runs on test_CT {
2475 var ConnHdlr vc_conn;
2476 var ConnHdlrPars pars;
2477 f_init();
2478 f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -10");
2479 for (var integer tn := 1; tn <= 1; tn := tn+1) {
2480 pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN));
2481 pars.bts0_band := f_vty_get_bts0_band();
2482 vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_up), pars, trxc_comp := true);
2483 vc_conn.done;
2484 }
2485 f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop");
2486 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
2487}
2488
2489testcase TC_rsl_ms_pwr_dyn_max() runs on test_CT {
2490 var ConnHdlr vc_conn;
2491 var ConnHdlrPars pars;
2492 f_init();
2493 f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -10");
2494 for (var integer tn := 1; tn <= 1; tn := tn+1) {
2495 pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN));
2496 pars.bts0_band := f_vty_get_bts0_band();
2497 vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_max), pars, trxc_comp := true);
2498 vc_conn.done;
2499 }
2500 f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop");
2501 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
2502}
2503
2504testcase TC_rsl_ms_pwr_dyn_down() runs on test_CT {
2505 var ConnHdlr vc_conn;
2506 var ConnHdlrPars pars;
2507 f_init();
2508 f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -100");
2509 for (var integer tn := 1; tn <= 1; tn := tn+1) {
2510 pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN));
2511 pars.bts0_band := f_vty_get_bts0_band();
2512 vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_down), pars, trxc_comp := true);
2513 vc_conn.done;
2514 }
2515 f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop");
2516 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
2517}
2518
Eric Wild280ccb82019-06-17 11:11:52 +02002519testcase TC_rsl_ms_pwr_dyn_active() runs on test_CT {
2520 var ConnHdlr vc_conn;
2521 var ConnHdlrPars pars;
2522 f_init();
2523 f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -100");
2524 for (var integer tn := 1; tn <= 1; tn := tn+1) {
2525 pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN));
2526 pars.bts0_band := f_vty_get_bts0_band();
2527 vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_active), pars, trxc_comp := true);
2528 vc_conn.done;
2529 }
2530 f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop");
2531 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
2532}
2533
Eric Wild095024b2019-06-17 15:08:57 +02002534testcase TC_rsl_ms_pwr_dyn_active2() runs on test_CT {
2535 var ConnHdlr vc_conn;
2536 var ConnHdlrPars pars;
2537 f_init();
2538 f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -100");
2539 for (var integer tn := 1; tn <= 1; tn := tn+1) {
2540 pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN));
2541 pars.bts0_band := f_vty_get_bts0_band();
2542 vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_active2), pars, trxc_comp := true);
2543 vc_conn.done;
2544 }
2545 f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop");
2546 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
2547}
2548
Harald Welte70767382018-02-21 12:16:40 +01002549testcase TC_meas_res_sign_tchf() runs on test_CT {
2550 var ConnHdlr vc_conn;
2551 var ConnHdlrPars pars;
Harald Welte10474062019-05-30 16:48:17 +02002552 f_init();
Harald Welte70767382018-02-21 12:16:40 +01002553 for (var integer tn := 1; tn <= 4; tn := tn+1) {
2554 pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN));
Vadim Yanitskiyf4e997c2019-06-04 21:40:33 +07002555 vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars,
2556 pcu_comp := false, trxc_comp := true);
Harald Welte70767382018-02-21 12:16:40 +01002557 vc_conn.done;
2558 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002559 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +01002560}
2561testcase TC_meas_res_sign_tchh() runs on test_CT {
2562 var ConnHdlr vc_conn;
2563 var ConnHdlrPars pars;
Harald Welte10474062019-05-30 16:48:17 +02002564 f_init();
Harald Welte70767382018-02-21 12:16:40 +01002565 for (var integer ss := 0; ss <= 1; ss := ss+1) {
2566 pars := valueof(t_Pars(t_RslChanNr_Lm(5, ss), ts_RSL_ChanMode_SIGN));
Eric Wild5b9ef142019-07-11 19:28:02 +02002567 vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars,
2568 pcu_comp := false, trxc_comp := true);
Harald Welte70767382018-02-21 12:16:40 +01002569 vc_conn.done;
2570 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002571 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +01002572}
2573testcase TC_meas_res_sign_sdcch4() runs on test_CT {
2574 var ConnHdlr vc_conn;
2575 var ConnHdlrPars pars;
Harald Welte10474062019-05-30 16:48:17 +02002576 f_init();
Harald Welte70767382018-02-21 12:16:40 +01002577 for (var integer ss := 0; ss <= 3; ss := ss+1) {
2578 pars := valueof(t_Pars(t_RslChanNr_SDCCH4(0, ss), ts_RSL_ChanMode_SIGN));
Eric Wild5b9ef142019-07-11 19:28:02 +02002579 vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars,
2580 pcu_comp := false, trxc_comp := true);
Harald Welte70767382018-02-21 12:16:40 +01002581 vc_conn.done;
2582 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002583 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +01002584}
2585testcase TC_meas_res_sign_sdcch8() runs on test_CT {
2586 var ConnHdlr vc_conn;
2587 var ConnHdlrPars pars;
Harald Welte10474062019-05-30 16:48:17 +02002588 f_init();
Harald Welte70767382018-02-21 12:16:40 +01002589 for (var integer ss := 0; ss <= 7; ss := ss+1) {
2590 pars := valueof(t_Pars(t_RslChanNr_SDCCH8(6, ss), ts_RSL_ChanMode_SIGN));
Eric Wild5b9ef142019-07-11 19:28:02 +02002591 vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars,
2592 pcu_comp := false, trxc_comp := true);
Harald Welte70767382018-02-21 12:16:40 +01002593 vc_conn.done;
2594 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002595 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +01002596}
Harald Welte685d5982018-02-27 20:42:05 +01002597testcase TC_meas_res_sign_tchh_toa256() runs on test_CT {
2598 var ConnHdlr vc_conn;
2599 var ConnHdlrPars pars;
Harald Welte10474062019-05-30 16:48:17 +02002600 f_init();
Harald Welte685d5982018-02-27 20:42:05 +01002601 f_vty_config(BTSVTY, "bts 0", "supp-meas-info toa256");
2602 for (var integer ss := 0; ss <= 1; ss := ss+1) {
2603 pars := valueof(t_Pars(t_RslChanNr_Lm(5, ss), ts_RSL_ChanMode_SIGN));
2604 pars.l1_pars.toa256_enabled := true;
2605 vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars);
2606 vc_conn.done;
2607 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002608 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte685d5982018-02-27 20:42:05 +01002609}
2610
Philipp Maier4d1e9c92018-12-20 11:11:56 +01002611/* establish DChan, and send MS POWER CONTROL messages via RSL, verify that
2612 * the BTS is forwarding those values to the MS via the SACCH L1 header. */
2613function f_tc_rsl_ms_pwr_ctrl(charstring id) runs on ConnHdlr {
2614 var L1ctlDlMessage l1_dl;
2615 var RSL_IE_MS_Power ms_power;
2616 var RSL_Message rsl;
2617 var uint5_t power_level := 0;
2618
2619 f_l1_tune(L1CTL);
2620 RSL.clear;
2621
2622 f_est_dchan();
2623
2624 ms_power.reserved := 0;
2625 ms_power.fpc_epc := false;
2626
2627 /* Send the first power control command. This will disable any BTS/TRX
2628 * internal power control and switch the MS (which is not in scope of
2629 * this test) to a constant power level. We start with a power level
2630 * of 0 */
2631 ms_power.power_level := power_level;
2632 rsl := valueof(ts_RSL_MS_PWR_CTRL(g_chan_nr, ms_power));
2633 RSL.send(rsl);
2634
2635 alt {
2636
2637 /* Pick all SACCH blocks for checking */
2638 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl {
2639
2640 /* The first byte of the L1 header contains the power level.
2641 * The reserved bits and the fpc bit is set to 0, so we may
2642 * compare directly. */
2643 if (not (l1_dl.payload.data_ind.payload[0] == int2oct(power_level, 1))) {
2644 setverdict(fail, "Power level in L1 header does not match the signaled (RSL) power level.");
2645 }
2646
2647 /* Signal a new power level via RSL for the next turn. */
2648 if (power_level < 31) {
2649 power_level := power_level + 1;
2650 ms_power.power_level := power_level;
2651 rsl := valueof(ts_RSL_MS_PWR_CTRL(g_chan_nr, ms_power));
2652 RSL.send(rsl);
2653 repeat;
2654 }
2655
2656 }
2657
2658 /* Ignore all other blocks */
2659 [] L1CTL.receive { repeat; }
2660
2661 }
2662
2663 f_rsl_chan_deact();
2664 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
2665
2666 setverdict(pass);
2667}
2668
2669testcase TC_rsl_ms_pwr_ctrl() runs on test_CT {
2670 var ConnHdlr vc_conn;
2671 var ConnHdlrPars pars;
Harald Welte10474062019-05-30 16:48:17 +02002672 f_init();
Philipp Maier4d1e9c92018-12-20 11:11:56 +01002673
2674 for (var integer tn := 1; tn <= 4; tn := tn+1) {
2675 pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN));
2676 vc_conn := f_start_handler(refers(f_tc_rsl_ms_pwr_ctrl), pars);
2677 vc_conn.done;
2678 }
2679 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
2680}
Harald Welte70767382018-02-21 12:16:40 +01002681
Eric Wild6833cc92019-05-23 19:34:44 +02002682/* establish DChan, verify that the BTS sets the TA in the first SACCH L1 header.
2683TA for the IMM ASS messages is still controlled by g_pars.l1_pars.ms_actual_ta! */
2684function f_tc_rsl_chan_initial_ta(charstring id) runs on ConnHdlr {
2685 var L1ctlDlMessage l1_dl;
2686 var uint5_t ta_to_test := 16;
2687
2688
2689 f_l1_tune(L1CTL);
2690 RSL.clear;
2691
2692 /* tell fake_trx to use a given timing offset for all bursts */
Vadim Yanitskiydc8db922019-06-04 21:58:15 +07002693 f_trxc_fake_toffs256(ta_to_test*256);
Eric Wild6833cc92019-05-23 19:34:44 +02002694
2695 f_est_dchan(more_ies :={valueof(t_RSL_IE(RSL_IE_TIMING_ADVANCE, RSL_IE_Body:{timing_adv := ta_to_test}))} );
2696
2697
2698 alt {
2699
2700 /* Pick all SACCH blocks for checking */
2701 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl {
2702
2703 /* The second byte of the L1 header contains the TA. */
2704 if (not (l1_dl.payload.data_ind.payload[1] == int2oct(ta_to_test, 1))) {
2705 setverdict(fail, "TA in L1 header does not match the signaled (RSL) TA.");
2706 }
2707
2708 }
2709
2710 /* Ignore all other blocks */
2711 [] L1CTL.receive { repeat; }
2712
2713 }
2714
2715 f_rsl_chan_deact();
2716 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
2717
2718 setverdict(pass);
2719}
2720
2721testcase TC_rsl_chan_initial_ta() runs on test_CT {
2722 var ConnHdlr vc_conn;
2723 var ConnHdlrPars pars;
Harald Welte10474062019-05-30 16:48:17 +02002724 f_init();
Eric Wild6833cc92019-05-23 19:34:44 +02002725 pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
Vadim Yanitskiyf4e997c2019-06-04 21:40:33 +07002726 vc_conn := f_start_handler(refers(f_tc_rsl_chan_initial_ta), pars,
2727 pcu_comp := false, trxc_comp := true);
Eric Wild6833cc92019-05-23 19:34:44 +02002728 vc_conn.done;
2729 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
2730}
2731
Eric Wilde57e1a62019-05-28 13:30:55 +02002732/* establish DChan, verify that the BTS sets MS power in the first SACCH L1 header. */
2733function f_tc_rsl_chan_initial_ms_pwr(charstring id) runs on ConnHdlr {
2734 var L1ctlDlMessage l1_dl;
2735 var uint5_t ms_power_level := 7;
2736
2737 var RSL_IE_MS_Power ms_power;
2738 ms_power.reserved := 0;
2739 ms_power.fpc_epc := false;
2740 ms_power.power_level := ms_power_level;
2741
2742 f_l1_tune(L1CTL);
2743 RSL.clear;
2744
2745 f_est_dchan(more_ies :={valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power}))} );
2746
2747 timer T := 1.0;
2748 T.start;
2749 alt {
2750 /* Pick all SACCH blocks for checking */
2751 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl {
2752 /* The first byte of the L1 header contains the power level.. */
2753 if (not (l1_dl.payload.data_ind.payload[0] == int2oct(ms_power_level, 1))) {
2754 setverdict(fail, "Power Level in L1 header does not match the signaled (RSL) MS Power Level.");
2755 }
2756 }
2757 /* Ignore all other blocks */
2758 [] L1CTL.receive { repeat; }
2759 [] T.timeout {
2760 setverdict(fail, "Power Level in L1 header does not match the signaled (RSL) MS Power Level.");
2761 }
2762 }
2763
2764 f_rsl_chan_deact();
2765 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
2766 setverdict(pass);
2767}
2768
2769testcase TC_rsl_chan_initial_ms_pwr() runs on test_CT {
2770 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
2771 f_testmatrix_each_chan(pars, refers(f_tc_rsl_chan_initial_ms_pwr));
2772}
2773
Harald Welte0472ab42018-03-12 15:02:26 +01002774/* 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 +01002775private function f_TC_conn_fail_crit(charstring id) runs on ConnHdlr {
Harald Welte68e495b2018-02-25 00:05:57 +01002776 f_l1_tune(L1CTL);
Harald Welte70767382018-02-21 12:16:40 +01002777 RSL.clear;
2778
2779 f_est_dchan();
2780 f_sleep(2.0);
Harald Weltef8df4cb2018-03-10 15:15:08 +01002781 L1CTL.send(ts_L1CTL_DM_REL_REQ(g_chan_nr));
Harald Welte70767382018-02-21 12:16:40 +01002782
2783 timer T := 40.0;
2784 T.start;
2785 alt {
2786 [] RSL.receive(tr_RSL_CONN_FAIL_IND(g_chan_nr, ?)) {
2787 setverdict(pass)
2788 }
2789 [] RSL.receive { repeat };
2790 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002791 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "No CONN FAIL IND received");
Harald Welte70767382018-02-21 12:16:40 +01002792 }
2793 }
2794 f_rsl_chan_deact();
2795}
2796testcase TC_conn_fail_crit() runs on test_CT {
2797 var ConnHdlr vc_conn;
2798 var ConnHdlrPars pars;
Harald Welte10474062019-05-30 16:48:17 +02002799 f_init();
Harald Welte70767382018-02-21 12:16:40 +01002800 pars := valueof(t_Pars(t_RslChanNr_SDCCH8(6, 3), ts_RSL_ChanMode_SIGN));
2801 pars.t_guard := 60.0;
2802 vc_conn := f_start_handler(refers(f_TC_conn_fail_crit), pars);
2803 vc_conn.done;
2804}
2805
Harald Welte93640c62018-02-25 16:59:33 +01002806/***********************************************************************
2807 * Paging
2808 ***********************************************************************/
2809
Harald Welte68e495b2018-02-25 00:05:57 +01002810function tmsi_is_dummy(TMSIP_TMSI_V tmsi) return boolean {
2811 if (tmsi == 'FFFFFFFF'O) {
2812 return true;
2813 } else {
2814 return false;
2815 }
2816}
Harald Welte70767382018-02-21 12:16:40 +01002817
Philipp Maier82cb0b12018-08-31 14:41:39 +02002818type record allowedFn { integer frame_nr }
2819template allowedFn bs_ag_blks_res_0 := { frame_nr := (6, 12, 16, 22, 26, 32, 36, 42, 46) }
2820template allowedFn bs_ag_blks_res_1 := { frame_nr := (12, 16, 22, 26, 32, 36, 42, 46) }
2821template allowedFn bs_ag_blks_res_2 := { frame_nr := (16, 22, 26, 32, 36, 42, 46) }
2822template allowedFn bs_ag_blks_res_3 := { frame_nr := (22, 26, 32, 36, 42, 46) }
2823template allowedFn bs_ag_blks_res_4 := { frame_nr := (26, 32, 36, 42, 46) }
2824template allowedFn bs_ag_blks_res_5 := { frame_nr := (32, 36, 42, 46) }
2825template allowedFn bs_ag_blks_res_6 := { frame_nr := (36, 42, 46) }
2826template allowedFn bs_ag_blks_res_7 := { frame_nr := (42, 46) }
2827function check_pch_fn(integer frame_nr, integer bs_ag_blks_res) runs on test_CT
2828{
2829 var integer frame_nr_51;
2830 frame_nr_51 := frame_nr mod 51
2831
2832 var allowedFn fn_check;
2833 fn_check.frame_nr := frame_nr_51;
2834
2835 if (bs_ag_blks_res < 0 or bs_ag_blks_res > 7) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002836 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "bs_ag_blks_res out of valid range (0..7)");
Philipp Maier82cb0b12018-08-31 14:41:39 +02002837 return;
2838 }
2839
2840 if (bs_ag_blks_res == 0 and match(fn_check, bs_ag_blks_res_0)) {
2841 return;
2842 }
2843 if (bs_ag_blks_res == 1 and match(fn_check, bs_ag_blks_res_1)) {
2844 return;
2845 }
2846 if (bs_ag_blks_res == 2 and match(fn_check, bs_ag_blks_res_2)) {
2847 return;
2848 }
2849 if (bs_ag_blks_res == 3 and match(fn_check, bs_ag_blks_res_3)) {
2850 return;
2851 }
2852 if (bs_ag_blks_res == 4 and match(fn_check, bs_ag_blks_res_4)) {
2853 return;
2854 }
2855 if (bs_ag_blks_res == 5 and match(fn_check, bs_ag_blks_res_5)) {
2856 return;
2857 }
2858 if (bs_ag_blks_res == 6 and match(fn_check, bs_ag_blks_res_6)) {
2859 return;
2860 }
2861 if (bs_ag_blks_res == 7 and match(fn_check, bs_ag_blks_res_7)) {
2862 return;
2863 }
2864
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002865 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "received paging on AGCH");
Philipp Maier82cb0b12018-08-31 14:41:39 +02002866 return;
2867}
2868
2869altstep 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 +01002870runs on test_CT {
2871 var L1ctlDlMessage dl;
Harald Weltef8df4cb2018-03-10 15:15:08 +01002872 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?, c_DummyUI)) {
Harald Welte68e495b2018-02-25 00:05:57 +01002873 repeat;
2874 }
Harald Weltef8df4cb2018-03-10 15:15:08 +01002875 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0))) -> value dl {
Harald Welte68e495b2018-02-25 00:05:57 +01002876 var octetstring without_plen :=
2877 substr(dl.payload.data_ind.payload, 1, lengthof(dl.payload.data_ind.payload)-1);
2878 var PDU_ML3_NW_MS rr := dec_PDU_ML3_NW_MS(without_plen);
Philipp Maier82cb0b12018-08-31 14:41:39 +02002879
2880 check_pch_fn(dl.dl_info.frame_nr, cfg.bs_ag_blks_res);
2881
Vadim Yanitskiy36aa07c2020-03-31 14:33:43 +07002882 if (match(rr, tr_PAGING_REQ1(tr_MI_LV(t_MI_NoIdentity(?))))) {
2883 /* Ignore empty RR Paging Request (PCH filling) messages.
2884 * TODO: does it make sense to count them? */
2885 } else if (match(rr, tr_PAGING_REQ1)) {
Harald Welte68e495b2018-02-25 00:05:57 +01002886 num_paging_rcv_msgs := num_paging_rcv_msgs + 1;
2887 num_paging_rcv_ids := num_paging_rcv_ids + 1;
Vadim Yanitskiyd665c232020-03-30 14:40:41 +07002888 if (ispresent(rr.msgs.rrm.pagingReq_Type1.mobileIdentity2)) {
Harald Welte68e495b2018-02-25 00:05:57 +01002889 num_paging_rcv_ids := num_paging_rcv_ids + 1;
2890 }
2891 } else if (match(rr, tr_PAGING_REQ2)) {
2892 num_paging_rcv_msgs := num_paging_rcv_msgs + 1;
2893 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type2.mobileIdentity1)) {
2894 num_paging_rcv_ids := num_paging_rcv_ids + 1;
2895 }
2896 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type2.mobileIdentity2)) {
2897 num_paging_rcv_ids := num_paging_rcv_ids + 1;
2898 }
Vadim Yanitskiyd665c232020-03-30 14:40:41 +07002899 if (ispresent(rr.msgs.rrm.pagingReq_Type2.mobileIdentity3)) {
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_REQ3)) {
2903 num_paging_rcv_msgs := num_paging_rcv_msgs + 1;
2904 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity1)) {
2905 num_paging_rcv_ids := num_paging_rcv_ids + 1;
2906 }
2907 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity2)) {
2908 num_paging_rcv_ids := num_paging_rcv_ids + 1;
2909 }
2910 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity3)) {
2911 num_paging_rcv_ids := num_paging_rcv_ids + 1;
2912 }
2913 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity4)) {
2914 num_paging_rcv_ids := num_paging_rcv_ids + 1;
2915 }
2916 }
2917 repeat;
2918 }
2919}
2920
2921type record PagingTestCfg {
2922 boolean combined_ccch,
2923 integer bs_ag_blks_res,
2924 float load_factor,
2925 boolean exp_load_ind,
2926 boolean exp_overload,
2927 boolean use_tmsi
2928}
2929
2930type record PagingTestState {
2931 integer num_paging_sent,
2932 integer num_paging_rcv_msgs,
2933 integer num_paging_rcv_ids,
2934 integer num_overload
2935}
2936
2937/* receive + ignore RSL RF RES IND */
2938altstep as_rsl_res_ind() runs on test_CT {
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07002939 [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RF_RES_IND)) {
Harald Welte68e495b2018-02-25 00:05:57 +01002940 repeat;
2941 }
2942}
2943
2944/* Helper function for paging related testing */
2945private function f_TC_paging(PagingTestCfg cfg) runs on test_CT return PagingTestState {
Harald Welte10474062019-05-30 16:48:17 +02002946 f_init();
Harald Welte68e495b2018-02-25 00:05:57 +01002947 f_init_l1ctl();
2948 f_l1_tune(L1CTL);
2949
2950 var PagingTestState st := {
2951 num_paging_sent := 0,
2952 num_paging_rcv_msgs := 0,
2953 num_paging_rcv_ids := 0,
2954 num_overload := 0
2955 };
2956
2957 var float max_pch_blocks_per_sec := f_pch_block_rate_est(cfg.combined_ccch, cfg.bs_ag_blks_res);
2958 var float max_pch_imsi_per_sec;
2959 if (cfg.use_tmsi) {
2960 max_pch_imsi_per_sec := max_pch_blocks_per_sec * 4.0; /* Type 3 */
2961 } else {
2962 max_pch_imsi_per_sec := max_pch_blocks_per_sec * 2.0; /* Type 1 */
2963 }
2964 var float pch_blocks_per_sec := max_pch_imsi_per_sec * cfg.load_factor;
2965 var float interval := 1.0 / pch_blocks_per_sec;
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02002966 var float time_total := 20.0;
2967 var integer pkt_total := float2int(time_total * pch_blocks_per_sec);
2968 log("pch_blocks_total=", pkt_total," pch_blocks_per_sec=", pch_blocks_per_sec, " interval=", interval);
Harald Welte68e495b2018-02-25 00:05:57 +01002969
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02002970 timer T_total := 300.0; /* big value (far bigger than time_total), used to count elapsed time */
2971 T_total.start;
Harald Welte68e495b2018-02-25 00:05:57 +01002972
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02002973 timer T_itv := 0.0;
2974 T_itv.start;
2975 while (st.num_paging_sent < pkt_total) {
Harald Welte68e495b2018-02-25 00:05:57 +01002976 alt {
2977 /* check for presence of CCCH LOAD IND (paging load) */
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07002978 [cfg.exp_overload] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_LOAD_IND(0))) {
Harald Welte68e495b2018-02-25 00:05:57 +01002979 st.num_overload := st.num_overload + 1;
2980 repeat;
2981 }
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07002982 [not cfg.exp_overload] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_LOAD_IND(0))) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002983 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected PCH Overload");
Harald Welte68e495b2018-02-25 00:05:57 +01002984 }
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07002985 [cfg.exp_load_ind] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_LOAD_IND)) {
Harald Welte68e495b2018-02-25 00:05:57 +01002986 log("Rx LOAD_IND");
2987 /* FIXME: analyze/verify interval + contents */
2988 repeat;
2989 }
2990 /* check if paging requests arrive on Um side */
Philipp Maier82cb0b12018-08-31 14:41:39 +02002991 [] as_l1_count_paging(st.num_paging_rcv_msgs, st.num_paging_rcv_ids, cfg);
Harald Welte68e495b2018-02-25 00:05:57 +01002992 [] L1CTL.receive { repeat; }
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02002993 [] T_itv.timeout {
2994 /* Send paging cmds based on elapsed time */
2995 var integer new_sent := f_min(pkt_total, float2int(T_total.read * pch_blocks_per_sec) + 1);
2996 while (st.num_paging_sent < new_sent) {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002997 var MobileIdentityV mi;
2998
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02002999 /* build mobile Identity */
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02003000 if (cfg.use_tmsi) {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07003001 mi := valueof(t_MI_TMSI(f_rnd_octstring(4)));
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02003002 } else {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07003003 mi := valueof(ts_MI_IMSI(f_gen_imsi(st.num_paging_sent)));
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02003004 }
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02003005
3006 /* Send RSL PAGING COMMAND */
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07003007 RSL_CCHAN.send(ts_ASP_RSL_UD(ts_RSL_PAGING_CMD(mi, st.num_paging_sent mod 4)));
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02003008
3009 st.num_paging_sent := st.num_paging_sent + 1;
3010 }
3011 if (st.num_paging_sent < pkt_total) {
3012 /* Wait for interval to next PAGING COMMAND */
3013 var float time_now := T_total.read;
3014 var float next_sched := int2float(st.num_paging_sent)*interval;
3015 if (next_sched > time_now) {
3016 T_itv.start(next_sched - time_now);
3017 } else {
3018 T_itv.start(0.0);
3019 }
3020 } else {
3021 /* We are done, no need to keep counting */
3022 T_total.stop;
3023 }
3024 }
3025 [] T_total.timeout { }
Harald Welte68e495b2018-02-25 00:05:57 +01003026 [] as_rsl_res_ind();
3027 }
3028 }
3029
3030 /* wait for max 18s for paging queue to drain (size: 200, ~ 13 per s -> 15s) */
3031 timer T_wait := 18.0;
3032 T_wait.start;
3033 alt {
Philipp Maier82cb0b12018-08-31 14:41:39 +02003034 [] as_l1_count_paging(st.num_paging_rcv_msgs, st.num_paging_rcv_ids, cfg);
Harald Welte68e495b2018-02-25 00:05:57 +01003035 [] L1CTL.receive { repeat; }
3036 /* 65535 == empty paging queue, we can terminate*/
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07003037 [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_LOAD_IND(65535))) { }
3038 [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_LOAD_IND)) { repeat; }
Harald Welte68e495b2018-02-25 00:05:57 +01003039 [] T_wait.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003040 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Waiting for empty paging queue");
Harald Welte68e495b2018-02-25 00:05:57 +01003041 }
3042 [] as_rsl_res_ind();
3043 }
3044
3045 log("num_paging_sent=", st.num_paging_sent, " rcvd_msgs=", st.num_paging_rcv_msgs,
3046 " rcvd_ids=", st.num_paging_rcv_ids);
3047 return st;
3048}
3049
3050/* Create ~ 80% paging load (IMSI only) sustained for about 20s, verifying that
3051 * - the number of Mobile Identities on Um PCH match the number of pages on RSL
3052 * - that CCCH LOAD IND (PCH) are being generated
3053 * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */
3054testcase TC_paging_imsi_80percent() runs on test_CT {
Philipp Maierd65d0562018-08-30 16:25:47 +02003055 var SystemInformation si3 := valueof(ts_SI3_default);
Harald Welte68e495b2018-02-25 00:05:57 +01003056 var PagingTestCfg cfg := {
3057 combined_ccch := true,
Philipp Maierd65d0562018-08-30 16:25:47 +02003058 bs_ag_blks_res := si3.payload.si3.ctrl_chan_desc.bs_ag_blks_res,
Harald Welte68e495b2018-02-25 00:05:57 +01003059 load_factor := 0.8,
3060 exp_load_ind := true,
3061 exp_overload := false,
3062 use_tmsi := false
3063 };
3064 var PagingTestState st := f_TC_paging(cfg);
3065 if (st.num_paging_sent != st.num_paging_rcv_ids) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003066 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Expected ", st.num_paging_sent, " pagings but have ",
3067 st.num_paging_rcv_ids));
Harald Welte68e495b2018-02-25 00:05:57 +01003068 } else {
3069 setverdict(pass);
3070 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003071 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte68e495b2018-02-25 00:05:57 +01003072}
3073
3074/* Create ~ 80% paging load (TMSI only) sustained for about 20s, verifying that
3075 * - the number of Mobile Identities on Um PCH match the number of pages on RSL
3076 * - that CCCH LOAD IND (PCH) are being generated
3077 * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */
3078testcase TC_paging_tmsi_80percent() runs on test_CT {
Philipp Maierd65d0562018-08-30 16:25:47 +02003079 var SystemInformation si3 := valueof(ts_SI3_default);
Harald Welte68e495b2018-02-25 00:05:57 +01003080 var PagingTestCfg cfg := {
3081 combined_ccch := true,
Philipp Maierd65d0562018-08-30 16:25:47 +02003082 bs_ag_blks_res := si3.payload.si3.ctrl_chan_desc.bs_ag_blks_res,
Harald Welte68e495b2018-02-25 00:05:57 +01003083 load_factor := 0.8,
3084 exp_load_ind := true,
3085 exp_overload := false,
3086 use_tmsi := true
3087 };
3088 var PagingTestState st := f_TC_paging(cfg);
3089 if (st.num_paging_sent != st.num_paging_rcv_ids) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003090 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Expected ", st.num_paging_sent, " pagings but have ",
3091 st.num_paging_rcv_ids));
Harald Welte68e495b2018-02-25 00:05:57 +01003092 } else {
3093 setverdict(pass);
3094 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003095 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte68e495b2018-02-25 00:05:57 +01003096}
3097
3098/* Create ~ 200% paging load (IMSI only) sustained for about 20s, verifying that
3099 * - the number of Mobile Identities on Um PCH are ~ 82% of the number of pages on RSL
3100 * - that CCCH LOAD IND (PCH) are being generated and reach 0 at some point
3101 * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */
3102testcase TC_paging_imsi_200percent() runs on test_CT {
Philipp Maierd65d0562018-08-30 16:25:47 +02003103 var SystemInformation si3 := valueof(ts_SI3_default);
Harald Welte68e495b2018-02-25 00:05:57 +01003104 var PagingTestCfg cfg := {
3105 combined_ccch := true,
Philipp Maierd65d0562018-08-30 16:25:47 +02003106 bs_ag_blks_res := si3.payload.si3.ctrl_chan_desc.bs_ag_blks_res,
Harald Welte68e495b2018-02-25 00:05:57 +01003107 load_factor := 2.0,
3108 exp_load_ind := true,
3109 exp_overload := true,
3110 use_tmsi := false
3111 };
3112 var PagingTestState st := f_TC_paging(cfg);
3113 /* We expect about 80-85% to pass, given that we can fill the paging buffer of 200
3114 * slots and will fully drain that buffer before returning */
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02003115 var template integer tpl := (st.num_paging_sent*78/100 .. st.num_paging_sent *85/100);
Harald Welte68e495b2018-02-25 00:05:57 +01003116 if (not match(st.num_paging_rcv_ids, tpl)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003117 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 +01003118 } else {
3119 setverdict(pass);
3120 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003121 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte68e495b2018-02-25 00:05:57 +01003122}
3123
3124/* Create ~ 200% paging load (TMSI only) sustained for about 20s, verifying that
3125 * - the number of Mobile Identities on Um PCH are ~ 82% of the number of pages on RSL
3126 * - that CCCH LOAD IND (PCH) are being generated and reach 0 at some point
3127 * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */
3128testcase TC_paging_tmsi_200percent() runs on test_CT {
Philipp Maierd65d0562018-08-30 16:25:47 +02003129 var SystemInformation si3 := valueof(ts_SI3_default);
Harald Welte68e495b2018-02-25 00:05:57 +01003130 var PagingTestCfg cfg := {
3131 combined_ccch := true,
Philipp Maierd65d0562018-08-30 16:25:47 +02003132 bs_ag_blks_res := si3.payload.si3.ctrl_chan_desc.bs_ag_blks_res,
Harald Welte68e495b2018-02-25 00:05:57 +01003133 load_factor := 2.0,
3134 exp_load_ind := true,
3135 exp_overload := true,
3136 use_tmsi := true
3137 };
3138 var PagingTestState st := f_TC_paging(cfg);
3139 /* We expect about 70% to pass, given that we can fill the paging buffer of 200
3140 * slots and will fully drain that buffer before returning */
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02003141 var template integer tpl := (st.num_paging_sent*64/100 .. st.num_paging_sent *72/100);
Harald Welte68e495b2018-02-25 00:05:57 +01003142 if (not match(st.num_paging_rcv_ids, tpl)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003143 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 +01003144 } else {
3145 setverdict(pass);
3146 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003147 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte68e495b2018-02-25 00:05:57 +01003148}
3149
3150
Harald Welte93640c62018-02-25 16:59:33 +01003151/***********************************************************************
3152 * Immediate Assignment / AGCH
3153 ***********************************************************************/
Harald Weltee8d750e2018-06-10 21:41:35 +02003154const MobileAllocation c_MA_null := {
3155 len := 0,
3156 ma := ''B
3157}
Harald Welte93640c62018-02-25 16:59:33 +01003158
Harald Weltee8d750e2018-06-10 21:41:35 +02003159template (value) ChannelDescription ts_ChanDesc(template (value) RslChannelNr chan_nr, uint3_t tsc := 7,
3160 uint12_t arfcn := 871) := {
3161 chan_nr := chan_nr,
3162 tsc := tsc,
3163 h := false,
3164 arfcn := arfcn,
3165 maio_hsn := omit
3166}
3167
3168private function f_fmt_ia_stats(integer num_tx, integer num_rx, integer num_del) return charstring {
3169 return int2str(num_tx) & " sent, "
3170 & int2str(num_rx) & " received, "
3171 & int2str(num_del) & " deleted";
3172}
3173
3174private function f_TC_imm_ass(integer num_total, float sleep_s, float exp_pass) runs on test_CT {
3175 var L1ctlDlMessage l1_dl;
3176 timer T := 10.0;
3177 var integer num_tx := 0;
3178 var integer num_rx := 0;
3179 var integer num_del := 0;
3180 var charstring res_str;
3181 var float rx_ratio;
3182
Harald Welte10474062019-05-30 16:48:17 +02003183 f_init();
Harald Weltee8d750e2018-06-10 21:41:35 +02003184 f_init_l1ctl();
3185 f_l1_tune(L1CTL);
3186
3187 for (var integer i := 0; i < num_total; i := i+1) {
3188 var ChannelDescription ch_desc := valueof(ts_ChanDesc(valueof(t_RslChanNr_SDCCH4(0, 0))));
3189 var GsmRrMessage ia := valueof(ts_IMM_ASS(42, i, 5, ch_desc, c_MA_null));
3190 var octetstring ia_enc := enc_GsmRrMessage(ia);
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07003191 RSL_CCHAN.send(ts_ASP_RSL_UD(ts_RSL_IMM_ASSIGN(ia_enc, 0)));
Harald Weltee8d750e2018-06-10 21:41:35 +02003192 num_tx := num_tx+1;
3193 f_sleep(sleep_s);
Harald Welte68e495b2018-02-25 00:05:57 +01003194 }
3195 /* FIXME: check if imm.ass arrive on Um side */
Harald Weltee8d750e2018-06-10 21:41:35 +02003196 T.start;
3197 alt {
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07003198 [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_DELETE_IND(?, 0))) {
Harald Weltee8d750e2018-06-10 21:41:35 +02003199 num_del := num_del+1;
3200 repeat;
3201 }
3202 [] RSL_CCHAN.receive {
3203 repeat;
3204 }
3205 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?)) -> value l1_dl {
3206 /* somehow dec_SystemInformation will try to decode even non-RR as SI */
3207 var GsmRrMessage rr := dec_GsmRrMessage(l1_dl.payload.data_ind.payload);
3208 if (not match(rr, tr_IMM_ASS(42, ?, 5, ?, ?))) {
3209 /* FIXME: Why are we seeing paging requests on PCH/AGCH? */
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003210 //Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Unexpected IMM-ASS values on AGCH: ", rr));
Harald Weltee8d750e2018-06-10 21:41:35 +02003211 } else {
3212 num_rx := num_rx+1;
3213 }
3214 repeat;
3215 }
3216 [] L1CTL.receive { repeat; }
3217 [] T.timeout { }
3218 }
3219 res_str := f_fmt_ia_stats(num_tx, num_rx, num_del);
3220 log("AGCH test: " & res_str);
3221 if (num_rx + num_del != num_tx) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003222 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "RX + DEL != TX ?!?: " & res_str);
Harald Weltee8d750e2018-06-10 21:41:35 +02003223 }
3224 rx_ratio := int2float(num_rx) / int2float(num_tx);
3225 if (rx_ratio < exp_pass*0.8 or rx_ratio > exp_pass*1.2) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003226 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 +02003227 } else {
3228 setverdict(pass);
3229 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003230 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte68e495b2018-02-25 00:05:57 +01003231}
3232
Harald Weltee8d750e2018-06-10 21:41:35 +02003233/* send a long burst of 1000 IMM.ASS with 20ms spacing (50 per s); expect 75% of them to be deleted */
3234testcase TC_imm_ass_1000_20ms() runs on test_CT {
3235 f_TC_imm_ass(1000, 0.02, 0.25);
3236}
3237
3238/* send a short burst of 200 IMM.ASS without any spacing; expect 95% of them to be deleted */
3239testcase TC_imm_ass_200_0ms() runs on test_CT {
3240 f_TC_imm_ass(200, 0.0, 0.05);
3241}
3242
3243/* send 150 IMM.ASS at rate of 13/s; expect none of them to be deleted */
3244testcase TC_imm_ass_200_76ms() runs on test_CT {
3245 f_TC_imm_ass(150, 0.076, 1.00);
3246}
3247
3248
3249
Harald Welte48494ca2018-02-25 16:59:50 +01003250/***********************************************************************
3251 * BCCH
3252 ***********************************************************************/
3253
3254/* tuple of Frame Number + decoded SI */
3255type record SystemInformationFn {
3256 GsmFrameNumber frame_number,
3257 SystemInformation si
3258}
3259
3260/* an arbitrary-length vector of decoded SI + gsmtap header */
3261type record of SystemInformationFn SystemInformationVector;
3262
3263/* an array of SI-vectors indexed by TC value */
3264type SystemInformationVector SystemInformationVectorPerTc[8];
3265
3266/* determine if a given SI vector contains given SI type at least once */
3267function f_si_vecslot_contains(SystemInformationVector arr, RrMessageType key, boolean bcch_ext := false) return boolean {
3268 for (var integer i:= 0; i< sizeof(arr); i := i + 1) {
3269 var integer fn_mod51 := arr[i].frame_number mod 51;
3270 if (not bcch_ext and fn_mod51 == 2 or
3271 bcch_ext and fn_mod51 == 6) {
3272 if (arr[i].si.header.message_type == key) {
3273 return true;
3274 }
3275 }
3276 }
3277 return false;
3278}
3279
3280/* ensure a given TC slot of the SI vector contains given SI type at least once at TC */
3281function f_ensure_si_vec_contains(SystemInformationVectorPerTc arr, integer tc, RrMessageType key, boolean ext_bcch := false) {
3282 if (not f_si_vecslot_contains(arr[tc], key, ext_bcch)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003283 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("No ", key, " in TC=", tc, "!"));
Harald Welte48494ca2018-02-25 16:59:50 +01003284 }
3285}
3286
3287/* check if a given SI vector contains given SI type at least once on any TC */
3288function f_si_vec_contains(SystemInformationVectorPerTc arr, RrMessageType key) return boolean {
3289 for (var integer tc:= 0; tc < sizeof(arr); tc := tc + 1) {
3290 if (f_si_vecslot_contains(arr[tc], key) or
3291 f_si_vecslot_contains(arr[tc], key, true)) {
3292 return true;
3293 }
3294 }
3295 return false;
3296}
3297
3298/* determine if a given SI vector contains given SI type at least N of M times */
3299function f_si_vecslot_contains_n_of_m(SystemInformationVector arr, RrMessageType key, boolean bcch_ext := false, integer n := 1, integer m := 4) return boolean {
3300 var integer count := 0;
3301 if (sizeof(arr) < m) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003302 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Error: Insufficient SI in array");
Harald Welte48494ca2018-02-25 16:59:50 +01003303 }
3304 for (var integer i:= 0; i < m; i := i + 1) {
3305 var integer fn_mod51 := arr[i].frame_number mod 51;
3306 if (not bcch_ext and fn_mod51 == 2 or
3307 bcch_ext and fn_mod51 == 6) {
3308 if (arr[i].si.header.message_type == key) {
3309 count := count + 1;
3310 }
3311 }
3312 }
3313 if (count >= n) {
3314 return true;
3315 } else {
3316 return false;
3317 }
3318}
3319
3320/* ensure a given TC slot of the SI vector contains given SI type at least N out of M times at TC */
3321function f_ensure_si_vec_contains_n_of_m(SystemInformationVectorPerTc arr, integer tc, RrMessageType key, boolean ext_bcch := false, integer n, integer m) {
3322 if (not f_si_vecslot_contains_n_of_m(arr[tc], key, ext_bcch, n, m)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003323 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Not ", n, "/", m, " of ", key, " in TC=", tc, "!"));
Harald Welte48494ca2018-02-25 16:59:50 +01003324 }
3325}
3326
3327/* determine if a given SI vector contains given SI type at least once */
3328function f_si_vecslot_contains_only(SystemInformationVector arr, RrMessageType key, boolean bcch_ext := false) return boolean {
3329 for (var integer i:= 0; i< sizeof(arr); i := i + 1) {
3330 var integer fn_mod51 := arr[i].frame_number mod 51;
3331 if (not bcch_ext and fn_mod51 == 2 or
3332 bcch_ext and fn_mod51 == 6) {
3333 if (arr[i].si.header.message_type != key) {
3334 return false;
3335 }
3336 }
3337 }
3338 return true;
3339}
3340
3341/* ensure a given TC slot of the SI vector contains only given SI type */
3342function f_ensure_si_vec_contains_only(SystemInformationVectorPerTc arr, integer tc, RrMessageType key, boolean ext_bcch := false) {
3343 if (not f_si_vecslot_contains_only(arr[tc], key, ext_bcch)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003344 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Not all ", key, " in TC=", tc, "!"));
Harald Welte48494ca2018-02-25 16:59:50 +01003345 }
3346}
3347
3348/* SI configuration of cell, against which we validate actual SI messages */
3349type set SystemInformationConfig {
3350 boolean bcch_extended,
3351 boolean si1_present,
3352 boolean si2bis_present,
3353 boolean si2ter_present,
3354 boolean si2quater_present,
3355 boolean si7_present,
3356 boolean si8_present,
3357 boolean si9_present,
3358 boolean si13_present,
3359 boolean si13alt_present,
3360 boolean si15_present,
3361 boolean si16_present,
3362 boolean si17_present,
3363 boolean si2n_present,
3364 boolean si21_present,
3365 boolean si22_present
3366}
3367
3368/* validate the SI scheduling according to TS 45.002 version 14.1.0 Release 14, Section 6.3.1.3 */
3369function f_validate_si_scheduling(SystemInformationConfig cfg, SystemInformationVectorPerTc si_per_tc) {
3370 var integer i;
3371 for (i := 0; i < sizeof(si_per_tc); i := i + 1) {
3372 if (sizeof(si_per_tc[i]) == 0) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003373 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("No SI messages for TC=", i));
Harald Welte48494ca2018-02-25 16:59:50 +01003374 }
3375 }
3376 if (cfg.si1_present) {
3377 /* ii) System Information Type 1 needs to be sent if frequency hopping is in use or
3378 * when the NCH is present in a cell. If the MS finds another message on BCCH Norm
3379 * when TC = 0, it can assume that System Information Type 1 is not in use. */
3380 f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_1);
3381 /* make sure *ALL* contain SI1 */
3382 f_ensure_si_vec_contains_only(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_1);
3383 }
3384 f_ensure_si_vec_contains(si_per_tc, 1, SYSTEM_INFORMATION_TYPE_2);
3385 /* iii) A SI 2 message will be sent at least every time TC = 1 */
3386 f_ensure_si_vec_contains(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_3);
3387 f_ensure_si_vec_contains(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_3);
3388 f_ensure_si_vec_contains(si_per_tc, 3, SYSTEM_INFORMATION_TYPE_4);
3389 f_ensure_si_vec_contains(si_per_tc, 7, SYSTEM_INFORMATION_TYPE_4);
3390
3391 /* iii) System information type 2 bis or 2 ter messages are sent if needed, as determined by the
3392 * system operator. If only one of them is needed, it is sent when TC = 5. If both are
3393 * needed, 2bis is sent when TC = 5 and 2ter is sent at least once within any of 4
3394 * consecutive occurrences of TC = 4. */
3395 if (cfg.si2bis_present and not cfg.si2ter_present) {
3396 f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2bis);
3397 } else if (cfg.si2ter_present and not cfg.si2bis_present) {
3398 f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2ter);
3399 } else if (cfg.si2ter_present and cfg.si2bis_present) {
3400 f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2bis);
3401 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2ter, false, 1, 4);
3402 }
3403
3404 if (cfg.si7_present or cfg.si8_present) {
3405 /* vi) Use of System Information type 7 and 8 is not always necessary. It is necessary
3406 * if System Information type 4 does not contain all information needed for cell
3407 * selection and reselection. */
3408 if (not cfg.bcch_extended) {
3409 testcase.stop("Error: SI7/SI8 require BCCH Extd.");
3410 }
3411 if (cfg.si7_present) {
3412 f_ensure_si_vec_contains(si_per_tc, 7, SYSTEM_INFORMATION_TYPE_7, true);
3413 }
3414 if (cfg.si8_present) {
3415 f_ensure_si_vec_contains(si_per_tc, 3, SYSTEM_INFORMATION_TYPE_8, true);
3416 }
3417 }
3418
3419 if (cfg.si2quater_present) {
3420 /* iii) System information type 2 quater is sent if needed, as determined by the system
3421 * operator. If sent on BCCH Norm, it shall be sent when TC = 5 if neither of 2bis
3422 * and 2ter are used, otherwise it shall be sent at least once within any of 4
3423 * consecutive occurrences of TC = 4. If sent on BCCH Ext, it is sent at least once
3424 * within any of 4 consecutive occurrences of TC = 5. */
3425 if (not (cfg.bcch_extended)) {
3426 if (not (cfg.si2bis_present or cfg.si2ter_present)) {
3427 f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2quater);
3428 } else {
3429 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2quater, false, 1, 4);
3430 }
3431 } else {
3432 f_ensure_si_vec_contains_n_of_m(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2quater, true, 1, 4);
3433 }
3434 }
3435 if (cfg.si9_present) {
3436 /* vi) System Information type 9 is sent in those blocks with TC = 4 which are specified
3437 * in system information type 3 as defined in 3GPP TS 44.018. */
3438 f_ensure_si_vec_contains(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_9); // FIXME SI3
3439 }
3440 if (cfg.si13_present) {
3441 /* vii) System Information type 13 is only related to the GPRS service. System Information
3442 * Type 13 need only be sent if GPRS support is indicated in one or more of System
3443 * Information Type 3 or 4 or 7 or 8 messages. These messages also indicate if the
3444 * message is sent on the BCCH Norm or if the message is transmitted on the BCCH Ext.
3445 * In the case that the message is sent on the BCCH Norm, it is sent at least once
3446 * within any of 4 consecutive occurrences of TC=4. */
3447 if (not cfg.bcch_extended) {
3448 log("not-bccch-extended");
3449 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_13, false, 1, 4);
3450 } else {
3451 log("bccch-extended");
3452 f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_13, true);
3453 }
3454 if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_13alt)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003455 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Cannot have SI13alt and SI13");
Harald Welte48494ca2018-02-25 16:59:50 +01003456 }
3457 }
3458 if (cfg.si16_present or cfg.si17_present) {
3459 /* viii) System Information type 16 and 17 are only related to the SoLSA service. They
3460 * should not be sent in a cell where network sharing is used (see rule xv). */
3461 if (cfg.si22_present) {
3462 testcase.stop("Error: Cannot have SI16/SI17 and SI22!");
3463 }
3464 if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_22)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003465 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Cannot have SI16/SI17 and SI22!");
Harald Welte48494ca2018-02-25 16:59:50 +01003466 }
3467 if (not cfg.bcch_extended) {
3468 testcase.stop("Error: SI16/SI17 requires BCCH Extd!");
3469 }
3470 if (cfg.si16_present) {
3471 f_ensure_si_vec_contains(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_16, true);
3472 }
3473 if (cfg.si17_present) {
3474 f_ensure_si_vec_contains(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_17, true);
3475 }
3476 }
3477
3478 /* ix) System Information type 18 and 20 are sent in order to transmit non-GSM
3479 * broadcast information. The frequency with which they are sent is determined by the
3480 * system operator. System Information type 9 identifies the scheduling of System
3481 * Information type 18 and 20 messages. */
3482
3483 /* x) System Information Type 19 is sent if COMPACT neighbours exist. If System
3484 * Information Type 19 is present, then its scheduling shall be indicated in System
3485 * Information Type 9. */
3486
3487 if (cfg.si15_present) {
3488 /* xi) System Information Type 15 is broadcast if dynamic ARFCN mapping is used in the
3489 * PLMN. If sent on BCCH Norm, it is sent at least once within any of 4 consecutive
3490 * occurrences of TC = 4. If sent on BCCH Ext, it is sent at least once within any of
3491 * 4 consecutive occurrences of TC = 1. */
3492 if (not cfg.bcch_extended) {
3493 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_15, false, 1, 4);
3494 } else {
3495 f_ensure_si_vec_contains_n_of_m(si_per_tc, 1, SYSTEM_INFORMATION_TYPE_15, true, 1, 4);
3496 }
3497 }
3498 if (cfg.si13alt_present) {
3499 /* xii) System Information type 13 alt is only related to the GERAN Iu mode. System
3500 * Information Type 13 alt need only be sent if GERAN Iu mode support is indicated in
3501 * one or more of System Information Type 3 or 4 or 7 or 8 messages and SI 13 is not
3502 * broadcast. These messages also indicate if the message is sent on the BCCH Norm or
3503 * if the message is transmitted on the BCCH Ext. In the case that the message is sent
3504 * on the BCCH Norm, it is sent at least once within any of 4 consecutive occurrences
3505 * of TC = 4. */
3506 if (cfg.si13_present) {
3507 testcase.stop("Error: Cannot have SI13alt and SI13");
3508 }
3509 if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_13)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003510 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Cannot have SI13alt and SI13");
Harald Welte48494ca2018-02-25 16:59:50 +01003511 }
3512 if (not cfg.bcch_extended) {
3513 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_13alt, false, 1, 4);
3514 } else {
3515 f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_13alt, true);
3516 }
3517 }
3518 if (cfg.si2n_present) {
3519 /* xiii) System Information Type 2n is optionally sent on BCCH Norm or BCCH Ext if needed,
3520 * as determined by the system operator. In the case that the message is sent on the
3521 * BCCH Norm, it is sent at least once within any of 4 consecutive occurrences of TC =
3522 * 4. If the message is sent on BCCH Ext, it is sent at least once within any of 2
3523 * consecutive occurrences of TC = 4. */
3524 if (not cfg.bcch_extended) {
3525 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2n, false, 1, 4);
3526 } else {
3527 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2n, true, 2, 4);
3528 }
3529 }
3530 if (cfg.si21_present) {
3531 /* xiv) System Information Type 21 is optionally sent on BCCH Norm or BCCH Ext, as
3532 * determined by the system operator. If Extended Access Barring is in use in the cell
3533 * then this message is sent at least once within any of 4 consecutive occurrences of
3534 * TC = 4 regardless if it is sent on BCCH Norm or BCCH Ext. If BCCH Ext is used in a
3535 * cell then this message shall only be sent on BCCH Ext. */
3536 if (not cfg.bcch_extended) {
3537 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_21, false, 1, 4);
3538 } else {
3539 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_21, true, 1, 4);
3540 if (f_si_vecslot_contains(si_per_tc[4], SYSTEM_INFORMATION_TYPE_21)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003541 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Cannot have SI21 on BCCH Norm if BCCH Extd enabled!");
Harald Welte48494ca2018-02-25 16:59:50 +01003542 }
3543 }
3544 }
3545 if (cfg.si22_present) {
3546 /* xv) System Information Type 22 is sent if network sharing is in use in the cell. It
3547 * should not be sent in a cell where SoLSA is used (see rule viii). System
3548 * Information Type 22 instances shall be sent on BCCH Ext within any occurrence of TC
3549 * =2 and TC=6. */
3550 if (cfg.si16_present or cfg.si17_present) {
3551 testcase.stop("Error: Cannot have SI16/SI17 and SI22!");
3552 }
3553 if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_16) or
3554 f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_17)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003555 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Cannot have SI16/SI17 and SI22!");
Harald Welte48494ca2018-02-25 16:59:50 +01003556 }
3557 if (not cfg.bcch_extended) {
3558 testcase.stop("Error: SI22 requires BCCH Extd!");
3559 } else {
3560 f_ensure_si_vec_contains_only(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_22, true);
3561 f_ensure_si_vec_contains_only(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_22, true);
3562 }
3563 }
3564}
3565
3566/* sample Systme Information for specified duration via L1CTL */
3567function f_l1_sample_si(L1CTL_PT pt, float duration := 8.0) return SystemInformationVectorPerTc {
3568 timer T := duration;
3569 var SystemInformationVectorPerTc si_per_tc;
3570 var L1ctlDlMessage l1_dl;
3571
3572 /* initialize all per-TC vectors empty */
3573 for (var integer i:= 0; i < sizeof(si_per_tc); i := i+1) {
3574 si_per_tc[i] := {};
3575 }
3576
3577 /* flush all previous L1 queued msgs */
3578 pt.clear;
3579
3580 T.start;
3581 alt {
Harald Weltef8df4cb2018-03-10 15:15:08 +01003582 [] pt.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl {
Harald Welte48494ca2018-02-25 16:59:50 +01003583 /* somehow dec_SystemInformation will try to decode even non-RR as SI */
3584 if (not (l1_dl.payload.data_ind.payload[1] == '06'O)) {
3585 log("Ignoring non-RR SI ", l1_dl);
3586 repeat;
3587 }
3588 var SystemInformationFn sig := {
3589 frame_number := l1_dl.dl_info.frame_nr,
3590 si := dec_SystemInformation(l1_dl.payload.data_ind.payload)
3591 }
3592 var integer tc := f_gsm_compute_tc(sig.frame_number);
3593 log("SI received at TC=", tc, ": ", sig.si);
3594 /* append to the per-TC bucket */
3595 si_per_tc[tc] := si_per_tc[tc] & { sig };
3596 repeat;
3597 }
3598 [] pt.receive { repeat; }
3599 [] T.timeout { }
3600 }
3601
3602 for (var integer i:= 0; i < sizeof(si_per_tc); i := i+1) {
3603 log(testcasename(), ": TC=", i, " has #of SI=", sizeof(si_per_tc[i]));
3604 }
3605 log("si_per_tc=", si_per_tc);
3606 return si_per_tc;
3607}
3608
3609/* helper function: Set given SI via RSL + validate scheduling.
3610 * CALLER MUST MAKE SURE TO CHANGE GLOBAL si_cfg! */
3611function f_TC_si_sched() runs on test_CT {
3612 var SystemInformationVectorPerTc si_per_tc;
3613 f_init_l1ctl();
3614 f_l1_tune(L1CTL);
3615
3616 /* Sample + Validate Scheduling */
3617 si_per_tc := f_l1_sample_si(L1CTL);
3618 f_validate_si_scheduling(si_cfg, si_per_tc);
3619
3620 setverdict(pass);
3621}
3622
3623testcase TC_si_sched_default() runs on test_CT {
3624 f_init();
Harald Welte0cae4552018-03-09 22:20:26 +01003625 /* 2+3+4 are mandatory and set in f_init() */
3626 f_TC_si_sched();
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003627 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte0cae4552018-03-09 22:20:26 +01003628}
3629
3630testcase TC_si_sched_1() runs on test_CT {
3631 f_init();
3632 si_cfg.si1_present := true;
3633 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_1, '5506198fb38000000000000000000000000000e504002b'O);
Harald Welte48494ca2018-02-25 16:59:50 +01003634 f_TC_si_sched();
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003635 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte48494ca2018-02-25 16:59:50 +01003636}
3637
3638testcase TC_si_sched_2bis() runs on test_CT {
3639 f_init();
3640 si_cfg.si2bis_present := true;
3641 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O);
3642 f_TC_si_sched();
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003643 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte48494ca2018-02-25 16:59:50 +01003644}
3645
3646testcase TC_si_sched_2ter() runs on test_CT {
3647 f_init();
3648 si_cfg.si2ter_present := true;
3649 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O);
3650 f_TC_si_sched();
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003651 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte48494ca2018-02-25 16:59:50 +01003652}
3653
3654testcase TC_si_sched_2ter_2bis() runs on test_CT {
3655 f_init();
3656 si_cfg.si2bis_present := true;
3657 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O);
3658 si_cfg.si2ter_present := true;
3659 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O);
3660 f_TC_si_sched();
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003661 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte48494ca2018-02-25 16:59:50 +01003662}
3663
3664testcase TC_si_sched_2quater() runs on test_CT {
3665 f_init();
3666 si_cfg.si2quater_present := true;
3667 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2quater, '050607a8a0364aa698d72ff424feee0506d5e7fff02043'O);
3668 f_TC_si_sched();
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003669 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte48494ca2018-02-25 16:59:50 +01003670}
3671
3672testcase TC_si_sched_13() runs on test_CT {
3673 f_init();
3674 si_cfg.si13_present := true;
Harald Welte5618c2a2018-04-15 16:24:46 +02003675 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_13, '0106009000185a6fc9e08410ab2b2b2b2b2b2b2b2b2b2b'O);
Harald Welte48494ca2018-02-25 16:59:50 +01003676 f_TC_si_sched();
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003677 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte48494ca2018-02-25 16:59:50 +01003678}
3679
3680testcase TC_si_sched_13_2bis_2ter_2quater() runs on test_CT {
3681 f_init();
3682 si_cfg.si2bis_present := true;
3683 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O);
3684 si_cfg.si2ter_present := true;
3685 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O);
3686 si_cfg.si2quater_present := true;
3687 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2quater, '050607a8a0364aa698d72ff424feee0506d5e7fff02043'O);
3688 si_cfg.si13_present := true;
Harald Welte5618c2a2018-04-15 16:24:46 +02003689 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_13, '0106009000185a6fc9e08410ab2b2b2b2b2b2b2b2b2b2b'O);
Harald Welte48494ca2018-02-25 16:59:50 +01003690 f_TC_si_sched();
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003691 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte48494ca2018-02-25 16:59:50 +01003692}
3693
3694
Harald Welte68e495b2018-02-25 00:05:57 +01003695testcase TC_bcch_info() runs on test_CT {
Harald Welte10474062019-05-30 16:48:17 +02003696 f_init();
Harald Welte68e495b2018-02-25 00:05:57 +01003697 /* FIXME: enable / disable individual BCCH info */
3698 //ts_RSL_BCCH_INFO(si_type, info);
3699 /* expect no ERROR REPORT after either of them *
3700 /* negative test: ensure ERROR REPORT on unsupported types */
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003701 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte68e495b2018-02-25 00:05:57 +01003702}
3703
Harald Welte93640c62018-02-25 16:59:33 +01003704/***********************************************************************
3705 * Low-Level Protocol Errors / ERROR REPORT
3706 ***********************************************************************/
3707
Harald Welte01d982c2018-02-25 01:31:40 +01003708private function f_exp_err_rep(template RSL_Cause cause) runs on test_CT {
3709 timer T := 5.0;
3710 T.start;
3711 alt {
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07003712 [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_ERROR_REPORT(cause))) {
Harald Welte01d982c2018-02-25 01:31:40 +01003713 setverdict(pass);
3714 }
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07003715 [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_ERROR_REPORT(?))) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003716 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Wrong cause in RSL ERR REP");
Harald Welte01d982c2018-02-25 01:31:40 +01003717 }
3718 [] RSL_CCHAN.receive {
3719 repeat;
3720 }
3721 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003722 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RSL ERR REP");
Harald Welte01d982c2018-02-25 01:31:40 +01003723 }
3724 }
3725}
3726
3727/* Provoke a protocol error (message too short) and match on ERROR REPORT */
3728testcase TC_rsl_protocol_error() runs on test_CT {
Harald Welte10474062019-05-30 16:48:17 +02003729 f_init();
Harald Welte01d982c2018-02-25 01:31:40 +01003730 var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O));
3731 rsl.ies := omit;
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07003732 RSL_CCHAN.send(ts_ASP_RSL_UD(rsl));
Harald Welte01d982c2018-02-25 01:31:40 +01003733
3734 f_exp_err_rep(RSL_ERR_PROTO);
3735}
3736
3737/* Provoke a mandatory IE error and match on ERROR REPORT */
3738testcase TC_rsl_mand_ie_error() runs on test_CT {
Harald Welte10474062019-05-30 16:48:17 +02003739 f_init();
Harald Welte01d982c2018-02-25 01:31:40 +01003740
3741 var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O));
3742 rsl.ies := { rsl.ies[0] };
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07003743 RSL_CCHAN.send(ts_ASP_RSL_UD(rsl));
Harald Welte01d982c2018-02-25 01:31:40 +01003744
3745 f_exp_err_rep(RSL_ERR_MAND_IE_ERROR);
3746}
3747
3748/* Provoke an IE content error and match on ERROR REPORT */
3749testcase TC_rsl_ie_content_error() runs on test_CT {
Harald Welte10474062019-05-30 16:48:17 +02003750 f_init();
Harald Welte01d982c2018-02-25 01:31:40 +01003751 var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O));
3752 rsl.ies[1].body.sysinfo_type := RSL_SYSTEM_INFO_5;
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07003753 RSL_CCHAN.send(ts_ASP_RSL_UD(rsl));
Harald Welte01d982c2018-02-25 01:31:40 +01003754
3755 f_exp_err_rep(RSL_ERR_IE_CONTENT);
3756}
3757
Harald Welteee25aae2019-05-19 14:32:37 +02003758/* attempt to activate channel with wrong RSL Message Discriminator IE */
3759function f_TC_chan_act_wrong_mdisc(charstring id) runs on ConnHdlr {
3760 var template RSL_Message rsl := ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode);
3761 rsl.msg_disc := ts_RSL_MsgDisc(RSL_MDISC_RESERVED, false);
3762 RSL.send(rsl);
3763 f_rslem_unregister(0, g_chan_nr);
3764}
3765testcase TC_err_rep_wrong_mdisc() runs on test_CT {
3766 var ConnHdlr vc_conn;
3767 var ConnHdlrPars pars := valueof(t_Pars(ts_RslChanNr_SDCCH4(0,0), ts_RSL_ChanMode_SIGN));
3768
Harald Welte10474062019-05-30 16:48:17 +02003769 f_init();
Harald Welteee25aae2019-05-19 14:32:37 +02003770
3771 vc_conn := f_start_handler(refers(f_TC_chan_act_wrong_mdisc), pars);
3772 vc_conn.done;
3773 f_exp_err_rep(RSL_ERR_MSG_DISCR);
3774
3775 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
3776}
3777
3778/* Send messages with wrong message type */
3779function f_TC_wrong_msg_type_dchan(charstring id) runs on ConnHdlr {
3780 var template (value) RSL_Message rsl_tx;
3781 rsl_tx := ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode);
3782 rsl_tx.msg_type := RSL_MT_NOT_CMD;
3783 RSL.send(rsl_tx);
3784 f_rslem_unregister(0, g_chan_nr);
3785}
3786function f_TC_wrong_msg_type_rll(charstring id) runs on ConnHdlr {
3787 var template (value) RSL_Message rsl_tx;
3788 /* we first have to activate the dedicated channel */
3789 f_rsl_chan_act(g_pars.chan_mode);
3790 /* ... to then send an invalid RLL message */
3791 rsl_tx := ts_RSL_UNITDATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0), '0102'O);
3792 rsl_tx.msg_type := RSL_MT_CBCH_LOAD_IND;
3793 RSL.send(rsl_tx);
3794 f_rslem_unregister(0, g_chan_nr);
3795}
3796testcase TC_err_rep_wrong_msg_type() runs on test_CT {
3797 var ConnHdlr vc_conn;
3798 var ConnHdlrPars pars := valueof(t_Pars(ts_RslChanNr_SDCCH4(0,0), ts_RSL_ChanMode_SIGN));
3799 var template (value) RSL_Message rsl_tx;
3800
Harald Welte10474062019-05-30 16:48:17 +02003801 f_init();
Harald Welteee25aae2019-05-19 14:32:37 +02003802
3803 /* Common Channel with wrong message type */
3804 RSL_CCHAN.clear;
3805 rsl_tx := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O));
3806 rsl_tx.msg_type := RSL_MT_LOCATION_INFO;
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07003807 RSL_CCHAN.send(ts_ASP_RSL_UD(rsl_tx));
Harald Welteee25aae2019-05-19 14:32:37 +02003808 f_exp_err_rep(RSL_ERR_MSG_TYPE);
3809
3810 /* TRX Management */
3811 RSL_CCHAN.clear;
3812 rsl_tx := ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, ''O);
3813 rsl_tx.msg_type := RSL_MT_UNIT_DATA_IND;
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07003814 RSL_CCHAN.send(ts_ASP_RSL_UD(rsl_tx));
Harald Welteee25aae2019-05-19 14:32:37 +02003815 f_exp_err_rep(RSL_ERR_MSG_TYPE);
3816
3817 /* Dedicated Channel */
3818 RSL_CCHAN.clear;
3819 vc_conn := f_start_handler(refers(f_TC_wrong_msg_type_dchan), pars);
3820 vc_conn.done;
3821 f_exp_err_rep(RSL_ERR_MSG_TYPE);
3822
3823 /* RLL */
3824 RSL_CCHAN.clear;
3825 vc_conn := f_start_handler(refers(f_TC_wrong_msg_type_rll), pars);
3826 vc_conn.done;
3827 f_exp_err_rep(RSL_ERR_MSG_TYPE);
3828}
3829
3830/* Send messages in wrong sequence (RLL to an inactive lchan) */
3831function f_TC_err_rep_wrong_sequence(charstring id) runs on ConnHdlr {
3832 RSL.send(ts_RSL_UNITDATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0), '0102'O));
3833 f_rslem_unregister(0, g_chan_nr);
3834}
3835testcase TC_err_rep_wrong_sequence() runs on test_CT {
3836 var ConnHdlr vc_conn;
3837 var ConnHdlrPars pars := valueof(t_Pars(ts_RslChanNr_SDCCH4(0,0), ts_RSL_ChanMode_SIGN));
3838
Harald Welte10474062019-05-30 16:48:17 +02003839 f_init();
Harald Welteee25aae2019-05-19 14:32:37 +02003840
3841 RSL_CCHAN.clear;
3842 vc_conn := f_start_handler(refers(f_TC_err_rep_wrong_sequence), pars);
3843 vc_conn.done;
3844 f_exp_err_rep(RSL_ERR_MSG_SEQ);
3845}
3846
Harald Welte93640c62018-02-25 16:59:33 +01003847/***********************************************************************
3848 * IPA CRCX/MDCX/DLCS media stream handling
3849 ***********************************************************************/
3850
Harald Weltea871a382018-02-25 02:03:14 +01003851/* Send IPA DLCX to inactive lchan */
3852function f_TC_ipa_dlcx_not_active(charstring id) runs on ConnHdlr {
Harald Welte1eba3742018-02-25 12:48:14 +01003853 f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, 0), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?),
3854 "IPA DLCX ACK");
Harald Weltea871a382018-02-25 02:03:14 +01003855}
3856testcase TC_ipa_dlcx_not_active() runs on test_CT {
3857 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
Harald Welte10474062019-05-30 16:48:17 +02003858 f_init();
Harald Weltea871a382018-02-25 02:03:14 +01003859 var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_dlcx_not_active), pars);
3860 vc_conn.done;
3861}
Harald Welte68e495b2018-02-25 00:05:57 +01003862
Harald Weltea3f1df92018-02-25 12:49:55 +01003863/* Send IPA CRCX twice to inactive lchan */
3864function f_TC_ipa_crcx_twice_not_active(charstring id) runs on ConnHdlr {
3865 f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?),
3866 "IPA CRCX ACK");
3867 f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_NACK(g_chan_nr, RSL_ERR_RES_UNAVAIL),
3868 "IPA CRCX NACK");
3869}
3870testcase TC_ipa_crcx_twice_not_active() runs on test_CT {
3871 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
Harald Welte10474062019-05-30 16:48:17 +02003872 f_init();
Harald Weltea3f1df92018-02-25 12:49:55 +01003873 var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_twice_not_active), pars);
3874 vc_conn.done;
3875}
3876
3877/* Regular sequence of CRCX/MDCX/DLCX */
3878function f_TC_ipa_crcx_mdcx_dlcx_not_active(charstring id) runs on ConnHdlr {
3879 f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?),
3880 "IPA CRCX ACK");
3881 var uint32_t remote_ip := f_rnd_int(c_UINT32_MAX);
3882 var uint16_t remote_port := f_rnd_int(c_UINT16_MAX);
3883 var uint7_t rtp_pt2 := f_rnd_int(127);
3884 var uint16_t fake_conn_id := 23; /* we're too lazy to read it out from the CRCX ACK above */
3885 f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2),
3886 tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2),
3887 "IPA MDCX ACK");
3888 f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, fake_conn_id), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?),
3889 "IPA DLCX ACK");
3890}
3891testcase TC_ipa_crcx_mdcx_dlcx_not_active() runs on test_CT {
3892 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
Harald Welte10474062019-05-30 16:48:17 +02003893 f_init();
Harald Weltea3f1df92018-02-25 12:49:55 +01003894 var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_mdcx_dlcx_not_active), pars);
3895 vc_conn.done;
3896}
3897
Harald Welte3ae11da2018-02-25 13:36:06 +01003898/* Sequence of CRCX, 2x MDCX, DLCX */
3899function f_TC_ipa_crcx_mdcx_mdcx_dlcx_not_active(charstring id) runs on ConnHdlr {
3900 f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?),
3901 "IPA CRCX ACK");
3902 var uint32_t remote_ip := f_rnd_int(c_UINT32_MAX);
3903 var uint16_t remote_port := f_rnd_int(c_UINT16_MAX);
3904 var uint7_t rtp_pt2 := f_rnd_int(127);
3905 var uint16_t fake_conn_id := 23; /* we're too lazy to read it out from the CRCX ACK above */
3906 f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2),
3907 tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2),
3908 "IPA MDCX ACK");
3909 /* Second MDCX */
3910 remote_ip := f_rnd_int(c_UINT32_MAX);
3911 remote_port := f_rnd_int(c_UINT16_MAX);
3912 f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2),
3913 tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2),
3914 "IPA MDCX ACK");
3915 f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, fake_conn_id), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?),
3916 "IPA DLCX ACK");
3917}
3918testcase TC_ipa_crcx_mdcx_mdcx_dlcx_not_active() runs on test_CT {
3919 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
Harald Welte10474062019-05-30 16:48:17 +02003920 f_init();
Harald Welte3ae11da2018-02-25 13:36:06 +01003921 var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_mdcx_mdcx_dlcx_not_active), pars);
3922 vc_conn.done;
3923}
3924
Harald Welte9912eb52018-02-25 13:30:15 +01003925/* IPA CRCX on SDCCH/4 and SDCCH/8 (doesn't make sense) */
3926function f_TC_ipa_crcx_sdcch_not_active(charstring id) runs on ConnHdlr {
3927 f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_NACK(g_chan_nr, ?),
3928 "IPA CRCX NACK");
3929}
3930testcase TC_ipa_crcx_sdcch_not_active() runs on test_CT {
3931 var ConnHdlrPars pars;
3932 var ConnHdlr vc_conn;
Harald Welte10474062019-05-30 16:48:17 +02003933 f_init();
Harald Welte9912eb52018-02-25 13:30:15 +01003934
3935 pars := valueof(t_Pars(t_RslChanNr_SDCCH4(0,1), ts_RSL_ChanMode_SIGN));
3936 vc_conn := f_start_handler(refers(f_TC_ipa_crcx_sdcch_not_active), pars);
3937 vc_conn.done;
3938
3939 pars := valueof(t_Pars(t_RslChanNr_SDCCH8(6,5), ts_RSL_ChanMode_SIGN));
3940 vc_conn := f_start_handler(refers(f_TC_ipa_crcx_sdcch_not_active), pars);
3941 vc_conn.done;
3942}
3943
Harald Weltea3f1df92018-02-25 12:49:55 +01003944
Harald Welte883340c2018-02-28 18:59:29 +01003945/***********************************************************************
3946 * PCU Socket related tests
3947 ***********************************************************************/
3948
Harald Welte07bd2d22019-05-25 11:03:30 +02003949/* Verify no RTS before ACT_REQ; verify RTS after ACT_REQ */
Harald Weltead033dc2019-05-25 17:28:16 +02003950friend 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 +01003951runs on test_CT {
3952 timer T := 3.0;
3953
3954 /* we don't expect any RTS.req before PDCH are active */
3955 T.start;
3956 alt {
3957 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(bts_nr))) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003958 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "PCU RTS.req before PDCH active?");
Harald Welte883340c2018-02-28 18:59:29 +01003959 }
3960 [] PCU.receive { repeat; }
3961 [] T.timeout { }
3962 }
3963
3964 /* Send PDCH activate request for known PDCH timeslot */
3965 PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, ts_nr)));
3966
3967 /* we now expect RTS.req for this timeslot (only) */
3968 T.start;
3969 alt {
3970 [exp_success] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr))) {
3971 setverdict(pass);
3972 }
3973 [not exp_success] PCU.receive(t_SD_PCUIF(g_pcu_conn_id,
3974 tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr))) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003975 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RTS.req for supposedly failing activation");
Harald Welte883340c2018-02-28 18:59:29 +01003976 }
3977 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003978 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "RTS.req for wrong TRX/TS");
Harald Welte883340c2018-02-28 18:59:29 +01003979 }
3980 [] PCU.receive { repeat; }
3981 [exp_success] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003982 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PCU RTS.req");
Harald Welte883340c2018-02-28 18:59:29 +01003983 }
3984 [not exp_success] T.timeout {
3985 setverdict(pass);
3986 }
3987 }
3988}
3989
Harald Welte07bd2d22019-05-25 11:03:30 +02003990/* verify no more RTS after DEACT_REQ */
Harald Weltead033dc2019-05-25 17:28:16 +02003991friend 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 +01003992runs on test_CT {
3993 timer T := 3.0;
3994
3995 /* Send PDCH activate request for known PDCH timeslot */
3996 PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_DEACT_REQ(bts_nr, trx_nr, ts_nr)));
3997
3998 PCU.clear;
3999 /* we now expect no RTS.req for this timeslot */
4000 T.start;
4001 alt {
4002 [] 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 +02004003 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received unexpected PCU RTS.req");
Harald Welte883340c2018-02-28 18:59:29 +01004004 }
4005 [] PCU.receive { repeat; }
4006 [] T.timeout {
4007 setverdict(pass);
4008 }
4009 }
4010}
4011
Harald Weltead033dc2019-05-25 17:28:16 +02004012friend function f_init_pcu_test() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01004013 f_init();
4014 PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_TXT_IND(0, PCU_VERSION, testcasename())));
4015}
4016
Harald Welte883340c2018-02-28 18:59:29 +01004017/* PDCH activation via PCU socket; check for presence of RTS.req */
4018testcase TC_pcu_act_req() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01004019 f_init_pcu_test();
4020
Harald Welte883340c2018-02-28 18:59:29 +01004021 f_TC_pcu_act_req(0, 0, 7, true);
4022}
4023
4024/* PDCH activation via PCU socket on non-PDCU timeslot */
4025testcase TC_pcu_act_req_wrong_ts() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01004026 f_init_pcu_test();
4027
Harald Welte883340c2018-02-28 18:59:29 +01004028 f_TC_pcu_act_req(0, 0, 1, false);
4029}
4030
4031/* PDCH activation via PCU socket on wrong BTS */
4032testcase TC_pcu_act_req_wrong_bts() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01004033 f_init_pcu_test();
4034
Harald Welte883340c2018-02-28 18:59:29 +01004035 f_TC_pcu_act_req(23, 0, 7, false);
4036}
4037
4038/* PDCH activation via PCU socket on wrong TRX */
4039testcase TC_pcu_act_req_wrong_trx() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01004040 f_init_pcu_test();
4041
Harald Welte883340c2018-02-28 18:59:29 +01004042 f_TC_pcu_act_req(0, 23, 7, false);
4043}
4044
4045/* PDCH deactivation via PCU socket; check for absence of RTS.req */
4046testcase TC_pcu_deact_req() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01004047 f_init_pcu_test();
4048
Harald Welte883340c2018-02-28 18:59:29 +01004049 /* Activate PDCH */
4050 f_TC_pcu_act_req(0, 0, 7, true);
4051 f_sleep(1.0);
4052 /* and De-Activate again */
4053 f_TC_pcu_deact_req(0, 0, 7);
4054}
4055
4056/* Attempt to deactivate a PDCH on a non-PDCH timeslot */
4057testcase TC_pcu_deact_req_wrong_ts() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01004058 f_init_pcu_test();
4059
Harald Welte883340c2018-02-28 18:59:29 +01004060 f_TC_pcu_deact_req(0, 0, 1);
4061}
4062
4063/* Test the PCU->BTS Version and BTS->PCU SI13 handshake */
4064testcase TC_pcu_ver_si13() runs on test_CT {
4065 const octetstring si13 := '00010203040506070909'O;
4066 var PCUIF_send_data sd;
4067 timer T:= 3.0;
Max2c6f5632019-03-18 17:25:17 +01004068 f_init_pcu_test();
Harald Welte883340c2018-02-28 18:59:29 +01004069
4070 /* Set SI13 via RSL */
4071 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_13, si13);
Max2c6f5632019-03-18 17:25:17 +01004072
Harald Welte883340c2018-02-28 18:59:29 +01004073 T.start;
4074 alt {
4075 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_DATA_IND(0, 0, 0, ?, PCU_IF_SAPI_BCCH))) -> value sd {
4076 if (substr(sd.data.u.data_ind.data, 0, lengthof(si13)) == si13) {
4077 setverdict(pass);
4078 } else {
4079 repeat;
4080 }
4081 }
4082 [] PCU.receive { repeat; }
4083 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004084 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for SI13");
Harald Welte883340c2018-02-28 18:59:29 +01004085 }
4086 }
4087}
4088
4089private const octetstring c_PCU_DATA := '000102030405060708090a0b0c0d0e0f10111213141516'O;
4090
4091/* helper function to send a PCU DATA.req */
Harald Weltead033dc2019-05-25 17:28:16 +02004092friend function f_pcu_data_req(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr,
Harald Welte883340c2018-02-28 18:59:29 +01004093 uint8_t block_nr, uint32_t fn, PCUIF_Sapi sapi, octetstring data)
4094runs on test_CT
4095{
4096 PCU.send(t_SD_PCUIF(g_pcu_conn_id,
4097 ts_PCUIF_DATA_REQ(bts_nr, trx_nr, ts_nr, block_nr, fn, sapi, data)));
4098}
4099
4100/* 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 +02004101friend function f_pcu_wait_rts_and_data_req(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr,
4102 PCUIF_Sapi sapi, octetstring data)
Harald Welte883340c2018-02-28 18:59:29 +01004103runs on test_CT
4104{
4105 var PCUIF_send_data sd;
4106
4107 timer T := 3.0;
4108 T.start;
4109 alt {
4110 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id,
4111 tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr, sapi))) -> value sd {
4112 f_pcu_data_req(bts_nr, trx_nr, ts_nr, sd.data.u.rts_req.block_nr,
4113 sd.data.u.rts_req.fn, sapi, data);
4114 }
4115 [] PCU.receive { repeat; }
4116 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004117 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RTS.ind");
Harald Welte883340c2018-02-28 18:59:29 +01004118 }
4119 }
4120}
4121
4122/* Send DATA.req on invalid BTS */
4123testcase TC_pcu_data_req_wrong_bts() runs on test_CT {
Harald Welte7162a612019-05-26 12:56:09 +02004124 var TfiUsfArr tua := f_TfiUsfArrInit();
4125 var octetstring data := '0000'O & f_rnd_octstring(21);
4126
4127 f_virtphy_common();
Max2c6f5632019-03-18 17:25:17 +01004128
Harald Welte883340c2018-02-28 18:59:29 +01004129 f_TC_pcu_act_req(0, 0, 7, true);
Harald Welte7162a612019-05-26 12:56:09 +02004130 f_TfiUsfArrSet(tua, 7, 0);
4131 f_L1CTL_TBF_CFG(L1CTL, false, tua);
4132 f_sleep(1.0);
4133
4134 f_pcu_to_l1(23, 0, 7, PCU_IF_SAPI_PDTCH, data, false, false);
Harald Welte883340c2018-02-28 18:59:29 +01004135}
4136
4137/* Send DATA.req on invalid TRX */
4138testcase TC_pcu_data_req_wrong_trx() runs on test_CT {
Harald Welte7162a612019-05-26 12:56:09 +02004139 var TfiUsfArr tua := f_TfiUsfArrInit();
4140 var octetstring data := '0000'O & f_rnd_octstring(21);
4141
4142 f_virtphy_common();
Max2c6f5632019-03-18 17:25:17 +01004143
Harald Welte883340c2018-02-28 18:59:29 +01004144 f_TC_pcu_act_req(0, 0, 7, true);
Harald Welte7162a612019-05-26 12:56:09 +02004145 f_TfiUsfArrSet(tua, 7, 0);
4146 f_L1CTL_TBF_CFG(L1CTL, false, tua);
4147 f_sleep(1.0);
4148
4149 f_pcu_to_l1(0, 100, 7, PCU_IF_SAPI_PDTCH, data, false, false);
Harald Welte883340c2018-02-28 18:59:29 +01004150}
4151
4152/* Send DATA.req on invalid timeslot */
4153testcase TC_pcu_data_req_wrong_ts() runs on test_CT {
Harald Welte7162a612019-05-26 12:56:09 +02004154 var TfiUsfArr tua := f_TfiUsfArrInit();
4155 var octetstring data := '0000'O & f_rnd_octstring(21);
4156
4157 f_virtphy_common();
Max2c6f5632019-03-18 17:25:17 +01004158
Harald Welte883340c2018-02-28 18:59:29 +01004159 f_TC_pcu_act_req(0, 0, 7, true);
Harald Welte7162a612019-05-26 12:56:09 +02004160 f_TfiUsfArrSet(tua, 7, 0);
4161 f_L1CTL_TBF_CFG(L1CTL, false, tua);
4162 f_sleep(1.0);
4163
4164 f_pcu_to_l1(0, 0, 70, PCU_IF_SAPI_PDTCH, data, false, false);
Harald Welte883340c2018-02-28 18:59:29 +01004165}
4166
4167/* Send DATA.req on timeslot that hasn't been activated */
4168testcase TC_pcu_data_req_ts_inactive() runs on test_CT {
Harald Welte7162a612019-05-26 12:56:09 +02004169 var TfiUsfArr tua := f_TfiUsfArrInit();
4170 var octetstring data := '0000'O & f_rnd_octstring(21);
Max2c6f5632019-03-18 17:25:17 +01004171
Harald Welte7162a612019-05-26 12:56:09 +02004172 f_virtphy_common();
4173
4174 f_TfiUsfArrSet(tua, 7, 0);
4175 f_L1CTL_TBF_CFG(L1CTL, false, tua);
4176 f_sleep(1.0);
4177
4178 f_pcu_to_l1(0, 0, 7, PCU_IF_SAPI_PDTCH, data, false, false);
Harald Welte883340c2018-02-28 18:59:29 +01004179}
4180
Harald Weltead033dc2019-05-25 17:28:16 +02004181private function f_pcu_to_l1(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr,
Harald Welte7162a612019-05-26 12:56:09 +02004182 PCUIF_Sapi sapi, octetstring data, boolean expect_data := true,
4183 boolean wait_rts := true)
4184runs on test_CT {
Harald Weltead033dc2019-05-25 17:28:16 +02004185 timer T := 5.0;
Harald Welte7162a612019-05-26 12:56:09 +02004186 var L1ctlDlMessage rx_dl;
Harald Weltead033dc2019-05-25 17:28:16 +02004187
4188 PCU.clear;
Harald Welte7162a612019-05-26 12:56:09 +02004189 if (wait_rts) {
4190 f_pcu_wait_rts_and_data_req(bts_nr, trx_nr, ts_nr, sapi, data);
4191 } else {
4192 f_pcu_data_req(bts_nr, trx_nr, ts_nr, 0, 0, sapi, data);
4193 }
Harald Weltead033dc2019-05-25 17:28:16 +02004194
4195 T.start;
4196 alt {
Harald Welte7162a612019-05-26 12:56:09 +02004197 [expect_data] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PDCH(ts_nr), ?, data)) {
Harald Weltead033dc2019-05-25 17:28:16 +02004198 /* FIXME: why is fn of DATA_IND different to fn of RTS / DATA_REQ above? */
4199 setverdict(pass);
4200 }
Harald Welte7162a612019-05-26 12:56:09 +02004201 [not expect_data] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PDCH(ts_nr), ?, data)) -> value rx_dl {
4202 setverdict(fail, "Received unexpected ", rx_dl);
4203 }
Harald Weltead033dc2019-05-25 17:28:16 +02004204 [] L1CTL.receive {
4205 repeat;
4206 }
Harald Welte7162a612019-05-26 12:56:09 +02004207 [expect_data] T.timeout {
Harald Weltead033dc2019-05-25 17:28:16 +02004208 setverdict(fail, "Timeout waiting for ", data);
4209 }
Harald Welte7162a612019-05-26 12:56:09 +02004210 [not expect_data] T.timeout {
4211 setverdict(pass);
4212 }
Harald Weltead033dc2019-05-25 17:28:16 +02004213 }
4214}
4215
4216private function f_disable_dynamic_ts() runs on test_CT
4217{
4218 f_init_vty_bsc();
4219 /* I'm not quite sure why we need this with osmo-bts-virtual. Somehow it deosn't seem to
4220 * support dynamic timeslots? But it uses the same scheduler as osmo-bts-trx ?!? */
4221 f_vty_config2(BSCVTY, {"network", "bts 0", "trx 0", "timeslot 3"}, "phys_chan_config TCH/F");
4222 f_vty_config2(BSCVTY, {"network", "bts 0", "trx 0", "timeslot 4"}, "phys_chan_config TCH/F");
Max2c6f5632019-03-18 17:25:17 +01004223 f_init_pcu_test();
Harald Weltead033dc2019-05-25 17:28:16 +02004224}
4225
4226private function f_virtphy_common() runs on test_CT {
4227 f_disable_dynamic_ts();
4228 f_init_l1ctl();
4229 f_l1_tune(L1CTL);
4230}
4231
4232testcase TC_pcu_data_req_pdtch() runs on test_CT {
4233 var TfiUsfArr tua := f_TfiUsfArrInit();
4234 var octetstring data := '0000'O & f_rnd_octstring(21);
4235
4236 f_virtphy_common();
Max2c6f5632019-03-18 17:25:17 +01004237
Harald Welte883340c2018-02-28 18:59:29 +01004238 f_TC_pcu_act_req(0, 0, 7, true);
Harald Weltead033dc2019-05-25 17:28:16 +02004239 f_TfiUsfArrSet(tua, 7, 0);
4240 f_L1CTL_TBF_CFG(L1CTL, false, tua);
4241 f_sleep(1.0);
4242
4243 f_pcu_to_l1(0, 0, 7, PCU_IF_SAPI_PDTCH, data); //c_PCU_DATA);
Harald Welte883340c2018-02-28 18:59:29 +01004244}
4245
Vadim Yanitskiy8c242f02019-10-13 15:25:54 +07004246/* FIXME: PTTCH has nothing to do with TBFs */
Harald Welte883340c2018-02-28 18:59:29 +01004247testcase TC_pcu_data_req_ptcch() runs on test_CT {
Harald Weltead033dc2019-05-25 17:28:16 +02004248 var TfiUsfArr tua := f_TfiUsfArrInit();
4249 var octetstring data := '0000'O & f_rnd_octstring(21);
4250
4251 f_virtphy_common();
Max2c6f5632019-03-18 17:25:17 +01004252
Harald Welte883340c2018-02-28 18:59:29 +01004253 f_TC_pcu_act_req(0, 0, 7, true);
Harald Weltead033dc2019-05-25 17:28:16 +02004254 f_TfiUsfArrSet(tua, 7, 0);
4255 f_L1CTL_TBF_CFG(L1CTL, false, tua);
4256 f_sleep(1.0);
4257
4258 f_pcu_to_l1(0, 0, 7, PCU_IF_SAPI_PTCCH, data);
Harald Welte883340c2018-02-28 18:59:29 +01004259}
4260
Vadim Yanitskiy8c242f02019-10-13 15:25:54 +07004261private function f_TC_pcu_ptcch_ul(uint16_t ra)
4262runs on test_CT {
4263 var template PCUIF_Message pcu_rach_ind;
4264 var PCUIF_send_data sd;
4265 var GsmFrameNumber fn;
4266 timer T;
4267
4268 /* Send an Access Burst on PTCCH/U over the Um-interface */
4269 fn := f_L1CTL_RACH(L1CTL, ra := ra, combined := 0, offset := 0,
4270 chan_nr := ts_RslChanNr_PDCH(7),
4271 link_id := ts_RslLinkID_OSMO_PTCCH(0));
4272
Vadim Yanitskiy36558d92019-11-17 02:23:51 +07004273 pcu_rach_ind := tr_PCUIF_RACH_IND(bts_nr := 0, trx_nr := 0, ts_nr := 7,
4274 ra := ra, fn := fn, sapi := PCU_IF_SAPI_PTCCH);
Vadim Yanitskiy8c242f02019-10-13 15:25:54 +07004275
4276 /* Expect a RACH.ind on the PCU interface (timeout is one multi-frame) */
4277 T.start(52.0 * 4.615 / 1000.0);
4278 alt {
4279 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, pcu_rach_ind)) -> value sd {
4280 log("Rx an Access Burst on the PCU interface: ", sd.data);
4281 setverdict(pass);
4282 T.stop;
4283 }
4284 [] PCU.receive { repeat; }
4285 [] T.timeout {
4286 setverdict(fail, "Timeout waiting for RACH.ind on the PCU interface");
4287 /* Keep going, that's not the end of the world */
4288 }
4289 }
4290}
4291
4292testcase TC_pcu_ptcch() runs on test_CT {
4293 var L1ctlDlMessage dl;
4294 var octetstring data;
4295 timer T;
4296
4297 f_init_pcu_test();
4298 f_init_l1ctl();
4299 f_l1_tune(L1CTL);
4300
4301 /* Activate PDCH channel on TS7 */
4302 f_TC_pcu_act_req(0, 0, 7, true);
4303
4304 /* Tune trxcon to that PDCH channel */
4305 L1CTL.send(ts_L1CTL_DM_EST_REQ(arfcn := { false, mp_trx0_arfcn },
4306 chan_nr := valueof(ts_RslChanNr_PDCH(7)),
4307 tsc := 7));
4308
4309 /* Verify PTCCH/U: send several access bursts, make sure they're received */
4310 for (var integer i := 0; i < 16; i := i + 1) {
4311 log("Sending an Access Burst towards the L1CTL interface");
4312 f_TC_pcu_ptcch_ul(oct2int(f_rnd_ra_ps()));
4313 }
4314
4315 /* Generate a random payload for PTCCH/D (23 octets, CS-1) */
4316 data := f_rnd_octstring(23);
4317
4318 /* Verify PTCCH/D: send a random data block, make sure it's received */
4319 log("Sending a PTCCH/D block towards the PCU interface: ", data);
4320 f_pcu_wait_rts_and_data_req(0, 0, 7, PCU_IF_SAPI_PTCCH, data);
4321
4322 /* PTCCH/D period is 2 multi-frames (2 * 52 * 4.615 ms), but
4323 * let's give it more time in case if we miss the beginning. */
4324 T.start(2.0 * 2.0 * 52.0 * 4.615 / 1000.0);
4325 alt {
4326 /* PDCH is considered as traffic in trxcon => expect TRAFFIC.ind */
4327 [] L1CTL.receive(tr_L1CTL_TRAFFIC_IND(chan_nr := t_RslChanNr_PDCH(7),
4328 link_id := tr_RslLinkID_OSMO_PTCCH(?),
4329 frame := data)) -> value dl {
4330 log("Rx PTCCH/D data (traffic) block on L1CTL: ", dl);
4331 setverdict(pass);
4332 T.stop;
4333 }
4334 /* Other PHYs (e.g. virt_phy) may consider PDCH as data => expect DATA.ind */
4335 [] L1CTL.receive(tr_L1CTL_DATA_IND(chan_nr := t_RslChanNr_PDCH(7),
4336 link_id := tr_RslLinkID_OSMO_PTCCH(?),
4337 l2_data := data)) -> value dl {
4338 log("Rx PTCCH/D data block on L1CTL: ", dl);
4339 setverdict(pass);
4340 T.stop;
4341 }
4342 [] L1CTL.receive { repeat; }
4343 [] T.timeout {
4344 setverdict(fail, "Timeout waiting for DATA.ind on L1CTL");
4345 }
4346 }
4347}
4348
Harald Welte883340c2018-02-28 18:59:29 +01004349/* Send AGCH from PCU; check it appears on Um side */
4350testcase TC_pcu_data_req_agch() runs on test_CT {
4351 timer T := 3.0;
Max2c6f5632019-03-18 17:25:17 +01004352 f_init_pcu_test();
Harald Welte883340c2018-02-28 18:59:29 +01004353 f_init_l1ctl();
4354 f_l1_tune(L1CTL);
4355
4356 f_TC_pcu_act_req(0, 0, 7, true);
4357 f_pcu_data_req(0, 0, 7, 0, 0, PCU_IF_SAPI_AGCH, c_PCU_DATA);
4358
4359 T.start;
4360 alt {
Harald Weltef8df4cb2018-03-10 15:15:08 +01004361 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?, c_PCU_DATA)) {
Harald Welte883340c2018-02-28 18:59:29 +01004362 setverdict(pass);
4363 }
4364 [] L1CTL.receive { repeat; }
4365 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004366 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PCU-originated AGCH block on Um");
Harald Welte883340c2018-02-28 18:59:29 +01004367 }
4368 }
4369}
4370
Harald Welte928622b2019-05-26 13:22:59 +02004371/* Send AGCH from PCU; check it appears on Um side */
4372testcase TC_pcu_data_req_pch() runs on test_CT {
4373 timer T := 3.0;
4374 f_init_pcu_test();
4375 f_init_l1ctl();
4376 f_l1_tune(L1CTL);
4377
4378 f_TC_pcu_act_req(0, 0, 7, true);
4379 /* three characters prefix: last 3 digits of IMSI as ASCII */
4380 f_pcu_data_req(0, 0, 7, 0, 0, PCU_IF_SAPI_PCH, '313233'O & c_PCU_DATA);
4381
4382 T.start;
4383 alt {
4384 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?, c_PCU_DATA)) {
4385 setverdict(pass);
4386 }
4387 [] L1CTL.receive { repeat; }
4388 [] T.timeout {
4389 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PCU-originated PCH block on Um");
4390 }
4391 }
4392}
4393
Harald Welte883340c2018-02-28 18:59:29 +01004394/* Send IMM.ASS from PCU for PCH; check it appears on Um side */
4395testcase TC_pcu_data_req_imm_ass_pch() runs on test_CT {
4396 var octetstring imm_ass := f_rnd_octstring(23);
Max2c6f5632019-03-18 17:25:17 +01004397 f_init_pcu_test();
Harald Welte883340c2018-02-28 18:59:29 +01004398 f_init_l1ctl();
4399 f_l1_tune(L1CTL);
4400
4401 /* append 3 last imsi digits so BTS can compute pagng group */
4402 var uint32_t fn := f_PCUIF_tx_imm_ass_pch(PCU, g_pcu_conn_id, imm_ass, '123459987'H);
4403
4404 timer T := 0.5;
4405 T.start;
4406 alt {
Harald Weltef8df4cb2018-03-10 15:15:08 +01004407 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?, imm_ass)) {
Harald Welte883340c2018-02-28 18:59:29 +01004408 /* TODO: verify paging group */
4409 setverdict(pass);
4410 }
4411 [] L1CTL.receive { repeat; }
4412 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004413 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PCU-originated AGCH block on Um");
Harald Welte883340c2018-02-28 18:59:29 +01004414 }
4415 }
4416}
4417
4418/* Send RACH from Um side, expect it to show up on PCU socket */
4419testcase TC_pcu_rach_content() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01004420 f_init_pcu_test();
Harald Welte883340c2018-02-28 18:59:29 +01004421 f_init_l1ctl();
4422 f_l1_tune(L1CTL);
4423
4424 var GsmFrameNumber fn_last := 0;
4425 for (var integer i := 0; i < 1000; i := i+1) {
4426 var OCT1 ra := f_rnd_ra_ps();
4427 var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra));
4428 if (fn == fn_last) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004429 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?");
Harald Welte883340c2018-02-28 18:59:29 +01004430 }
4431 fn_last := fn;
4432
4433 timer T := 2.0;
4434 T.start;
4435 alt {
Vadim Yanitskiy36558d92019-11-17 02:23:51 +07004436 [] 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 +01004437 T.stop;
4438 }
4439 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RACH_IND)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004440 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RACH IND");
Harald Welte883340c2018-02-28 18:59:29 +01004441 }
4442 [] PCU.receive { repeat; }
4443 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004444 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RACH IND");
Harald Welte883340c2018-02-28 18:59:29 +01004445 }
4446 }
4447 }
4448 setverdict(pass);
4449}
4450
Vadim Yanitskiy51cbc102019-04-22 06:37:30 +07004451/* Send extended (11-bit, TS1 & TS2) RACH bursts from the Um side,
4452 * expect them to show up on PCU socket (with proper BURST_TYPE_*). */
4453testcase TC_pcu_ext_rach_content() runs on test_CT {
4454 var template PCUIF_Message pcu_rach_ind;
4455 var GsmFrameNumber fn_last := 0;
4456 var L1ctlRachSynchSeq synch_seq;
4457 var PCUIF_BurstType pcu_bt;
4458 var GsmFrameNumber fn;
4459 var BIT11 ra11;
4460
4461 f_init_pcu_test();
4462 f_init_l1ctl();
4463 f_l1_tune(L1CTL);
4464
4465 for (var integer i := 0; i < 1000; i := i+1) {
4466 /* We need to test both TS1 & TS2 */
4467 if (i rem 2 == 0) {
4468 synch_seq := RACH_SYNCH_SEQ_TS1;
4469 pcu_bt := BURST_TYPE_1;
4470 } else {
4471 synch_seq := RACH_SYNCH_SEQ_TS2;
4472 pcu_bt := BURST_TYPE_2;
4473 }
4474
4475 ra11 := f_rnd_ra11_ps();
4476 fn := f_L1CTL_EXT_RACH(L1CTL, bit2int(ra11), synch_seq);
4477 if (fn == fn_last) {
4478 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
4479 "Two RACH in same FN?!?");
4480 }
4481 fn_last := fn;
4482
4483 /* Compose the expected message */
4484 pcu_rach_ind := tr_PCUIF_RACH_IND(
Vadim Yanitskiy36558d92019-11-17 02:23:51 +07004485 bts_nr := 0, trx_nr := 0, ts_nr := 0,
Vadim Yanitskiy51cbc102019-04-22 06:37:30 +07004486 ra := bit2int(ra11),
4487 is_11bit := 1,
4488 burst_type := pcu_bt,
4489 fn := fn);
4490
4491 timer T := 2.0;
4492 T.start;
4493 alt {
4494 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, pcu_rach_ind)) {
4495 T.stop;
4496 }
4497 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RACH_IND)) {
4498 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RACH IND");
4499 }
4500 [] PCU.receive { repeat; }
4501 [] T.timeout {
4502 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RACH IND");
4503 }
4504 }
4505 }
4506 setverdict(pass);
4507}
4508
Vadim Yanitskiya2c68e82019-07-03 13:07:20 +07004509private function f_TC_pcu_data_ind_lqual_cb(int16_t lqual_cb_exp, int16_t thresh)
4510runs on test_CT {
4511 var template PCUIF_send_data sdt;
4512 var PCUIF_send_data sd;
4513 var int16_t lqual_cb;
4514 timer T := 1.0;
4515
4516 /* PCUIF_DATA.ind is encapsulated into a supplementary record */
4517 sdt := t_SD_PCUIF_MSGT(g_pcu_conn_id, PCU_IF_MSG_DATA_IND);
4518
4519 /* Send a random PDTCH frame over Um */
4520 L1CTL.send(ts_L1CTL_TRAFFIC_REQ(ts_RslChanNr_PDCH(7), ts_RslLinkID_DCCH(0),
4521 '0000'O & f_rnd_octstring(21)));
4522
4523 T.start;
4524 alt {
4525 /* If expected link quality is above the threshold */
4526 [lqual_cb_exp >= thresh] PCU.receive(sdt) -> value sd {
4527 lqual_cb := sd.data.u.data_ind.lqual_cb;
4528 log("Rx PCUIF_DATA.ind (lqual_cb=", lqual_cb, ")");
4529
4530 /* Make sure the actual link quality matches the expected value */
4531 if (not match(lqual_cb, lqual_cb_exp)) {
4532 setverdict(fail, log2str("Link quality ", lqual_cb, " does not match ",
4533 "expected value ", lqual_cb_exp));
4534 } else {
4535 setverdict(pass);
4536 }
4537 }
4538 /* If expected link quality is below the threshold */
4539 [lqual_cb_exp < thresh] PCU.receive(sdt) -> value sd {
4540 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
4541 log2str("Rx unexpected PCUIF_DATA.ind: ", sd.data));
4542 }
4543 /* Ignore PCUIF_RTS.req and PCUIF_TIME.ind */
4544 [] PCU.receive { repeat; }
4545 [lqual_cb_exp < thresh] T.timeout {
4546 log("Rx nothing, as expected");
4547 setverdict(pass);
4548 }
4549 [lqual_cb_exp >= thresh] T.timeout {
4550 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
4551 "Timeout waiting for PCUIF_DATA.ind");
4552 }
4553 }
4554}
4555
4556/* Verify C/I (Carrier-to-Interference ratio) processing of PDTCH frames */
4557testcase TC_pcu_data_ind_lqual_cb() runs on test_CT {
4558 f_init_pcu_test();
4559 PCU.clear;
4560
4561 f_init_l1ctl();
4562 f_l1_tune(L1CTL);
4563
4564 /* Activate a PDCH channel on TS7 */
4565 f_TC_pcu_act_req(0, 0, 7, true);
4566
4567 /* Tune trxcon to that PDCH channel on TS7 */
4568 f_L1CTL_DM_EST_REQ(L1CTL, { false, mp_trx0_arfcn },
4569 valueof(ts_RslChanNr_PDCH(7)), 7);
4570
4571 /* C/I in centiBels, test range: -256 .. +1280, step 128 */
4572 for (var int16_t i := -256; i <= 1280; i := i + 128) {
4573 var TrxcMessage ret;
4574
4575 ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id,
4576 valueof(ts_TRXC_FAKE_CI(i)));
4577
4578 /* FIXME: OsmoBTS may have different threshold (see MIN_QUAL_NORM) */
4579 f_TC_pcu_data_ind_lqual_cb(i, thresh := 0);
4580 }
4581}
4582
Harald Welte883340c2018-02-28 18:59:29 +01004583/* Send PAGING via RSL, expect it to shw up on PCU socket */
4584testcase TC_pcu_paging_from_rsl() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01004585 f_init_pcu_test();
Harald Welte883340c2018-02-28 18:59:29 +01004586
4587 for (var integer i := 0; i < 100; i := i+1) {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07004588 var MobileIdentityLV mi_lv;
4589 var octetstring mi_lv_enc;
4590 var MobileIdentityV mi;
Harald Welte883340c2018-02-28 18:59:29 +01004591 timer T := 3.0;
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07004592
Harald Welte883340c2018-02-28 18:59:29 +01004593 if (i < 50) {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07004594 mi := valueof(t_MI_TMSI(f_rnd_octstring(4)));
Harald Welte883340c2018-02-28 18:59:29 +01004595 } else {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07004596 mi := valueof(ts_MI_IMSI(f_gen_imsi(i)));
Harald Welte883340c2018-02-28 18:59:29 +01004597 }
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07004598
4599 /* Fancy encoding for PCUIF */
4600 mi_lv := valueof(ts_MI_LV(mi));
4601 mi_lv_enc := enc_MobileIdentityLV(mi_lv);
4602 mi_lv_enc := f_pad_oct(mi_lv_enc, 9, '00'O);
Harald Welte883340c2018-02-28 18:59:29 +01004603
4604 /* Send RSL PAGING COMMAND */
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07004605 RSL_CCHAN.send(ts_ASP_RSL_UD(ts_RSL_PAGING_CMD(mi, i mod 4)));
Harald Welte883340c2018-02-28 18:59:29 +01004606 T.start;
4607 alt {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07004608 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_PAG_REQ(0, mi_lv_enc))) {
Harald Welte883340c2018-02-28 18:59:29 +01004609 }
4610 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_PAG_REQ)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004611 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected PAGING REQ");
Harald Welte883340c2018-02-28 18:59:29 +01004612 }
4613 [] PCU.receive { repeat; }
4614 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004615 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PAGING REQ");
Harald Welte883340c2018-02-28 18:59:29 +01004616 }
4617 }
4618 }
4619 setverdict(pass);
4620}
4621
Harald Welted66c9b82019-05-25 09:03:15 +02004622/* test for periodic TIME_IND; check number of FN expired and number of TIME_IND within frames */
4623testcase TC_pcu_time_ind() runs on test_CT {
4624 var PCUIF_send_data pcu_sd;
4625 var integer num_time_ind := 0;
4626 var integer first_fn, last_fn;
4627 var float test_duration := 5.0;
4628 timer T;
4629
4630 f_init_pcu_test();
4631 f_TC_pcu_act_req(0, 0, 7, true);
4632
4633 PCU.clear;
4634 T.start(test_duration);
4635 alt {
4636 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_TIME_IND(0, ?))) -> value pcu_sd {
4637 num_time_ind := num_time_ind + 1;
4638 if (not isbound(first_fn)) {
4639 first_fn := pcu_sd.data.u.time_ind.fn;
4640 }
4641 last_fn := pcu_sd.data.u.time_ind.fn;
4642 repeat;
4643 }
4644 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_TIME_IND(?, ?))) -> value pcu_sd {
4645 setverdict(fail, "Received unexpected PCUIF_TIME_IND: ", pcu_sd.data);
4646 repeat;
4647 }
4648 [] PCU.receive {
4649 repeat;
4650 }
4651 [] T.timeout {}
4652 }
4653 var integer fn_expired := last_fn - first_fn;
4654 log(fn_expired, " fn expired with ", num_time_ind, " PCU_TIME.ind");
4655
4656 /* verify the number of frames expired matches our expectation */
4657 const float c_GSM_FN_DURATION_MS := 4.61538;
4658 var float fn_expected := test_duration * 1000.0 / c_GSM_FN_DURATION_MS;
Harald Weltec761c542019-05-28 11:59:57 +02004659 var template integer t_fn_expected := f_tolerance(float2int(fn_expected), 1, 100000, 20);
Harald Welted66c9b82019-05-25 09:03:15 +02004660 if (not match(fn_expired, t_fn_expected)) {
4661 setverdict(fail, "Number of TDMA Frames (", fn_expired, ") not matching ", t_fn_expected);
4662 }
4663
4664 /* There are three TIME.ind in every fn MOD 13 */
4665 var float time_ind_expected := int2float(fn_expired) * 3.0 / 13.0;
4666 /* Add some tolerance */
4667 var template integer t_time_ind_exp := f_tolerance(float2int(time_ind_expected), 1, 100000, 5);
4668 if (not match(num_time_ind, t_time_ind_exp)) {
4669 setverdict(fail, "Number of TIME.ind (", num_time_ind, ") not matching ", t_time_ind_exp);
4670 }
4671
4672 setverdict(pass);
4673}
4674
Harald Welte4832c862019-05-25 14:57:18 +02004675/* test for periodic RTS_REQ; check number of FN expired and number of RTS_IND per SAPI */
4676testcase TC_pcu_rts_req() runs on test_CT {
4677 var PCUIF_send_data pcu_sd;
4678 var integer first_fn, last_fn;
4679 var integer num_rts_pdtch := 0;
4680 var integer num_rts_ptcch := 0;
4681 var float test_duration := 5.0;
4682 timer T;
4683
4684 f_init_pcu_test();
4685 f_TC_pcu_act_req(0, 0, 7, true);
4686
4687 PCU.clear;
4688 T.start(test_duration);
4689 alt {
4690 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(0, 0, 7, PCU_IF_SAPI_PDTCH, ?, ?)))
4691 -> value pcu_sd {
4692 num_rts_pdtch := num_rts_pdtch + 1;
4693 if (not isbound(first_fn)) {
4694 first_fn := pcu_sd.data.u.rts_req.fn;
4695 }
4696 last_fn := pcu_sd.data.u.rts_req.fn;
4697 repeat;
4698 }
4699 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(0, 0, 7, PCU_IF_SAPI_PTCCH, ?, ?)))
4700 -> value pcu_sd {
4701 num_rts_ptcch := num_rts_ptcch + 1;
4702 if (not isbound(first_fn)) {
4703 first_fn := pcu_sd.data.u.rts_req.fn;
4704 }
4705 last_fn := pcu_sd.data.u.rts_req.fn;
4706 repeat;
4707 }
4708 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ)) -> value pcu_sd {
4709 setverdict(fail, "Received unexpected PCUIF_RTS_REQ: ", pcu_sd.data);
4710 repeat;
4711 }
4712 [] PCU.receive {
4713 repeat;
4714 }
4715 [] T.timeout {}
4716 }
4717 var integer fn_expired := last_fn - first_fn;
4718 log(fn_expired, " fn expired with num_rts_pdtch=", num_rts_pdtch,
4719 ", num_rts_ptcch=", num_rts_ptcch);
4720
4721 /* verify the number of frames expired matches our expectation */
4722 const float c_GSM_FN_DURATION_MS := 4.61538;
4723 var float fn_expected := test_duration * 1000.0 / c_GSM_FN_DURATION_MS;
Harald Weltec761c542019-05-28 11:59:57 +02004724 var template integer t_fn_expected := f_tolerance(float2int(fn_expected), 1, 100000, 20);
Harald Welte4832c862019-05-25 14:57:18 +02004725 if (not match(fn_expired, t_fn_expected)) {
4726 setverdict(fail, "Number of TDMA Frames (", fn_expired, ") not matching ", t_fn_expected);
4727 }
4728
4729 /* PTCCH is in pos. 12 + 38 of 52-multiframe, but four slots/bursts required per block */
4730 var float ptcch_expected := int2float(fn_expired) / 52.0 * 0.5;
4731 var template integer t_ptcch_exp := f_tolerance(float2int(ptcch_expected), 1, 100000, 1);
4732 if (not match(num_rts_ptcch, t_ptcch_exp)) {
4733 setverdict(fail, "Number of RTS.ind for PTCCH (", num_rts_ptcch, ") not matching ",
4734 t_ptcch_exp);
4735 }
4736
4737 /* We have 12 PDTCH blocks every 52-multiframe */
4738 var float pdtch_expected := int2float(fn_expired) / 52.0 * 12.0;
4739 var template integer t_pdtch_exp := f_tolerance(float2int(pdtch_expected), 1, 100000, 2);
4740 if (not match(num_rts_pdtch, t_pdtch_exp)) {
4741 setverdict(fail, "Number of RTS.ind for PDTCH (", num_rts_pdtch, ") not matching ",
4742 t_pdtch_exp);
4743 }
4744
4745 setverdict(pass);
4746}
4747
Harald Welte07bd2d22019-05-25 11:03:30 +02004748/* test for generating Abis side OML ALERT from the PCU */
4749testcase TC_pcu_oml_alert() runs on test_CT {
4750 var PCUIF_send_data pcu_sd;
4751 var integer num_time_ind := 0;
4752 var integer first_fn, last_fn;
4753 var float test_duration := 5.0;
4754 timer T;
4755
4756 f_init_pcu_test();
4757 f_TC_pcu_act_req(0, 0, 7, true);
4758
4759 /* re-connect CTRL port from BTS to BSC */
4760 f_ipa_ctrl_stop();
4761 f_ipa_ctrl_start(mp_bsc_ctrl_ip, mp_bsc_ctrl_port);
4762
4763 /* Send that OML Alert */
4764 PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_TXT_IND(0, PCU_OML_ALERT, testcasename())));
4765
4766 /* This requires https://gerrit.osmocom.org/#/c/osmo-bsc/+/14177 to be merged */
4767 f_ctrl_exp_trap(IPA_CTRL, "bts.0.oml_failure_report", ?);
4768 setverdict(pass);
4769}
4770
Harald Welteeaa9a862019-05-26 23:01:08 +02004771template (value) PDU_ML3_MS_NW ts_RRM_GprsSuspReq(template (value) OCT4 tlli,
4772 template (value) RoutingAreaIdentificationV rai,
4773 template (value) OCT1 cause) := {
4774 discriminator := '0000'B, /* overwritten */
4775 tiOrSkip := {
4776 skipIndicator := '0000'B
4777 },
4778 msgs := {
4779 rrm := {
4780 gPRS_suspensionRequest := {
4781 messageType := '00110100'B,
4782 tLLI := tlli,
4783 routingAreaIdentification := rai,
4784 suspensionCause := cause,
4785 service_Support := omit
4786 }
4787 }
4788 }
4789}
4790
4791/* test for forwarding of RR SUSPEND from CS lchan to PCU via PCU socket */
4792private function f_TC_rr_suspend_req(charstring id) runs on ConnHdlr {
4793 var PCUIF_Message first_info;
4794 var integer pcu_conn_id := -1;
4795 var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0));
4796 var RoutingAreaIdentificationV rai := f_RAI('262'H, '42F'H, '2342'O, '55'O);
4797 var OCT4 tlli := '01020304'O;
4798 var OCT1 cause := '23'O;
4799 timer T := 5.0;
4800
4801 f_init_pcu(PCU, id, pcu_conn_id, first_info);
4802
4803 f_l1_tune(L1CTL);
4804 RSL.clear;
4805
4806 f_est_dchan();
4807 L1CTL.clear;
4808
4809 f_est_rll_mo(link_id.sapi, link_id, '23420815'O);
4810
4811 var PDU_ML3_MS_NW susp_req := valueof(ts_RRM_GprsSuspReq(tlli, rai, cause));
4812 var octetstring l3 := enc_PDU_ML3_MS_NW(susp_req);
4813 f_tx_lapdm(ts_LAPDm_I(link_id.sapi, cr_MO_CMD, true, 1, 0, l3), link_id);
4814
4815 /* ConnHdlr has terminated after sending the RR SUSP REQ over a dedicaed channel */
4816 T.start;
4817 alt {
4818 [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_SUSP_REQ(0, tlli, ?, oct2int(cause)))) {
4819 setverdict(pass);
4820 }
4821 [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_SUSP_REQ(?, ?, ?, ?))) {
4822 setverdict(fail, "Received unexpected PCUIF SUSPE REQ: ");
4823 }
4824 [] PCU.receive {
4825 repeat;
4826 }
4827 [] T.timeout {
4828 setverdict(fail, "Timeout waiting for SUSP REQ on PCUIF");
4829 }
4830 }
Alexander Couzensa0634832019-06-07 00:28:56 +02004831
4832 /* release the channel */
4833 f_rsl_chan_deact();
4834 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
4835 f_rslem_unregister(0, g_chan_nr);
Harald Welteeaa9a862019-05-26 23:01:08 +02004836}
4837testcase TC_pcu_rr_suspend() runs on test_CT {
4838 var ConnHdlrPars pars;
4839 var ConnHdlr vc_conn;
4840
4841 f_init();
4842
4843 pars := valueof(t_Pars(t_RslChanNr_SDCCH4(0,3), ts_RSL_ChanMode_SIGN));
4844 vc_conn := f_start_handler(refers(f_TC_rr_suspend_req), pars, true);
4845 vc_conn.done;
4846}
Harald Welte07bd2d22019-05-25 11:03:30 +02004847
Harald Weltea2e0e942019-05-27 18:12:53 +02004848/* Ensure that PCUIF socket can accept only a single connection */
4849testcase TC_pcu_socket_connect_multi() runs on test_CT {
4850 timer T := 5.0;
4851
4852 /* this (among other things) establishes the first connection to the PCUIF socket */
4853 f_init();
4854
4855 /* try to establish a second connection, expect it to fail */
4856 PCU.send(UD_connect:{mp_pcu_socket, -1});
4857 T.start;
4858 alt {
4859 [] PCU.receive(UD_connect_result:{id := ?, result := { result_code := ERROR, err := ? }}) {
4860 setverdict(pass);
4861 }
4862 [] PCU.receive(UD_connect_result:?) {
4863 setverdict(fail, "Unexpected unix domain connect result");
4864 }
4865 [] T.timeout {
4866 setverdict(pass);
4867 }
4868 }
4869 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
4870}
4871
Harald Weltec8effb72019-05-27 18:23:04 +02004872/* Ensure that PCUIF socket can disconnect + reconnect */
4873testcase TC_pcu_socket_reconnect() runs on test_CT {
4874 /* this (among other things) establishes the first connection to the PCUIF socket */
4875 f_init();
4876
4877 f_sleep(1.0);
4878
4879 f_pcuif_close(PCU, g_pcu_conn_id);
4880 g_pcu_conn_id := -1;
4881
4882 f_sleep(1.0);
4883
4884 /* re-connect */
4885 PCU.clear;
4886 f_init_pcu(PCU, testcasename(), g_pcu_conn_id, g_pcu_last_info);
4887 setverdict(pass);
4888
4889 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
4890}
4891
Harald Weltebe030482019-05-27 22:29:35 +02004892/* Ensure that GPRS capability is not advertised before PCU socket conncet */
Vadim Yanitskiy3c185382020-05-04 14:55:02 +07004893private function f_get_si(L1CTL_PT pt, RrMessageType si_type)
4894runs on test_CT return SystemInformation {
Harald Weltebe030482019-05-27 22:29:35 +02004895 var L1ctlDlMessage l1_dl;
4896 var SystemInformation si;
4897 timer T := 5.0;
4898 T.start;
4899 alt {
4900 [] pt.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl {
4901 /* somehow dec_SystemInformation will try to decode even non-RR as SI */
4902 if (not (l1_dl.payload.data_ind.payload[1] == '06'O)) {
4903 log("Ignoring non-RR SI ", l1_dl);
4904 repeat;
4905 }
4906 si := dec_SystemInformation(l1_dl.payload.data_ind.payload)
Vadim Yanitskiy3c185382020-05-04 14:55:02 +07004907 if (si.header.message_type != si_type) {
Harald Weltebe030482019-05-27 22:29:35 +02004908 repeat;
4909 }
4910 }
4911 [] pt.receive {
4912 repeat;
4913 }
4914 [] T.timeout {
Vadim Yanitskiy3c185382020-05-04 14:55:02 +07004915 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
4916 log2str("Timeout waiting for ", si_type));
Harald Weltebe030482019-05-27 22:29:35 +02004917 }
4918 }
Vadim Yanitskiy3c185382020-05-04 14:55:02 +07004919 return si;
Harald Weltebe030482019-05-27 22:29:35 +02004920}
4921
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07004922/* Check if GPRS Indicator is present in RR System Information of a given type */
4923private function f_si_has_gprs_indicator(RrMessageType si_type)
4924runs on test_CT return boolean {
4925 var SystemInformation si := f_get_si(L1CTL, si_type);
4926
4927 if (si_type == SYSTEM_INFORMATION_TYPE_3) {
4928 var RestOctets ro := si.payload.si3.rest_octets;
4929 var SI3RestOctets rest := dec_SI3RestOctets(ro);
4930 return rest.gprs_ind.presence == '1'B;
4931 } else if (si_type == SYSTEM_INFORMATION_TYPE_4) {
4932 var RestOctets ro := si.payload.si4.rest_octets;
4933 var SI4RestOctets rest := dec_SI4RestOctets(ro);
4934 return rest.gprs_ind.presence == '1'B;
4935 }
4936
4937 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unhandled SI type");
4938 return false;
Harald Weltebe030482019-05-27 22:29:35 +02004939}
4940
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07004941/* Make sure that GPRS Indicator is absent when the PCU is not connected */
4942private function f_TC_pcu_socket_noconnect(RrMessageType si_type)
4943runs on test_CT {
Harald Weltebe030482019-05-27 22:29:35 +02004944 /* don't call f_init() as this would connect PCU socket */
4945 f_init_rsl(testcasename());
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07004946
4947 /* Send both System Information Type 3 and 4 (with GPRS Indicator) */
Harald Weltebe030482019-05-27 22:29:35 +02004948 f_rsl_bcch_fill(RSL_SYSTEM_INFO_3, ts_SI3_default);
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07004949 f_rsl_bcch_fill(RSL_SYSTEM_INFO_4, ts_SI4_default);
Harald Weltebe030482019-05-27 22:29:35 +02004950
4951 f_init_l1ctl();
4952 f_l1_tune(L1CTL);
Harald Weltebe030482019-05-27 22:29:35 +02004953 f_sleep(2.0);
4954 L1CTL.clear;
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07004955
4956 if (f_si_has_gprs_indicator(si_type)) {
4957 setverdict(fail, si_type, " indicates GPRS even before PCU socket connected");
Harald Weltebe030482019-05-27 22:29:35 +02004958 } else {
4959 setverdict(pass);
4960 }
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07004961
Harald Weltebe030482019-05-27 22:29:35 +02004962 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
4963}
4964
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07004965testcase TC_pcu_socket_noconnect_nosi3gprs() runs on test_CT {
4966 f_TC_pcu_socket_noconnect(SYSTEM_INFORMATION_TYPE_3);
4967}
Harald Weltebe030482019-05-27 22:29:35 +02004968
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07004969testcase TC_pcu_socket_noconnect_nosi4gprs() runs on test_CT {
4970 f_TC_pcu_socket_noconnect(SYSTEM_INFORMATION_TYPE_4);
4971}
4972
4973/* Ensure that GPRS capability is advertised after PCU socket connect */
4974private function f_TC_pcu_socket_connect(RrMessageType si_type)
4975runs on test_CT {
Harald Weltebe030482019-05-27 22:29:35 +02004976 /* this (among other things) establishes the first connection to the PCUIF socket */
4977 f_init();
4978 f_init_l1ctl();
4979 f_l1_tune(L1CTL);
4980
4981 f_sleep(2.0);
4982 L1CTL.clear;
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07004983
4984 if (not f_si_has_gprs_indicator(si_type)) {
4985 setverdict(fail, si_type, " indicates no GPRS despite PCU socket connected");
Harald Weltebe030482019-05-27 22:29:35 +02004986 } else {
4987 setverdict(pass);
4988 }
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07004989
Harald Weltebe030482019-05-27 22:29:35 +02004990 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
4991}
4992
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07004993testcase TC_pcu_socket_connect_si3gprs() runs on test_CT {
4994 f_TC_pcu_socket_connect(SYSTEM_INFORMATION_TYPE_3);
4995}
Harald Weltebe030482019-05-27 22:29:35 +02004996
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07004997testcase TC_pcu_socket_connect_si4gprs() runs on test_CT {
4998 f_TC_pcu_socket_connect(SYSTEM_INFORMATION_TYPE_4);
4999}
5000
5001/* Ensure that GPRS capability is no longer advertised after PCU socket disconnect */
5002private function f_TC_pcu_socket_disconnect(RrMessageType si_type)
5003runs on test_CT {
Harald Weltebe030482019-05-27 22:29:35 +02005004 /* this (among other things) establishes the first connection to the PCUIF socket */
5005 f_init();
5006 f_init_l1ctl();
5007 f_l1_tune(L1CTL);
5008
5009 f_pcuif_close(PCU, g_pcu_conn_id);
5010 g_pcu_conn_id := -1;
5011
5012 f_sleep(1.0);
5013
5014 /* re-connect */
5015 PCU.clear;
5016 f_init_pcu(PCU, testcasename(), g_pcu_conn_id, g_pcu_last_info);
5017
5018 f_sleep(2.0);
5019 L1CTL.clear;
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07005020
5021 if (f_si_has_gprs_indicator(si_type)) {
5022 setverdict(fail, si_type, " indicates GPRS after PCU socket disconnected");
Harald Weltebe030482019-05-27 22:29:35 +02005023 } else {
5024 setverdict(pass);
5025 }
5026
5027 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
5028}
5029
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07005030testcase TC_pcu_socket_disconnect_nosi3gprs() runs on test_CT {
5031 f_TC_pcu_socket_disconnect(SYSTEM_INFORMATION_TYPE_3);
5032}
5033
5034testcase TC_pcu_socket_disconnect_nosi4gprs() runs on test_CT {
5035 f_TC_pcu_socket_disconnect(SYSTEM_INFORMATION_TYPE_4);
5036}
5037
Oliver Smithf5239c72019-08-28 10:01:25 +02005038/* 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) */
5039testcase TC_pcu_socket_verify_info_ind() runs on test_CT {
5040 var SystemInformation si3 := valueof(ts_SI3_default);
5041
5042 f_init();
5043
5044 /* Verify cell_id */
5045 var uint16_t cell_id_si3 := si3.payload.si3.cell_id;
5046 var uint16_t cell_id_pcu := g_pcu_last_info.u.info_ind.cell_id;
5047 if (cell_id_si3 != cell_id_pcu) {
Oliver Smithe1c00f02019-09-04 11:35:56 +02005048 setverdict(fail, "Expected cell_id '", cell_id_si3, "' and got '", cell_id_pcu, "'. This either means,",
5049 " that the BTS is sending the wrong cell_id, or that the BTS sent it too early",
5050 " (OS#4179)");
Oliver Smithf5239c72019-08-28 10:01:25 +02005051 }
5052
5053 /* Verify LAC */
5054 var uint16_t lac_si3 := si3.payload.si3.lai.lac;
5055 var uint16_t lac_pcu := g_pcu_last_info.u.info_ind.lac;
5056 if (lac_si3 != lac_pcu) {
5057 setverdict(fail, "Expected LAC ", lac_si3, " got: ", lac_pcu);
5058 }
5059
5060 setverdict(pass);
5061}
Harald Welted66c9b82019-05-25 09:03:15 +02005062
Harald Welte3d04ae62018-04-04 20:29:05 +02005063/***********************************************************************
Harald Welte9bbbfb52018-04-05 09:33:19 +02005064 * Osmocom Style Dynamic Timeslot Support
Harald Welte3d04ae62018-04-04 20:29:05 +02005065 ***********************************************************************/
5066
5067private function f_dyn_osmo_pdch_act(integer pcu_conn_id, integer bts_nr, integer trx_nr)
5068runs on ConnHdlr {
5069 var PCUIF_send_data sd;
5070 /* Expect BTS to immediately acknowledge activation as PDCH */
5071 PCU.clear;
5072 f_rsl_chan_act(g_pars.chan_mode);
5073 /* expect INFO_IND on PCU interface listing TS as PDCH */
Pau Espin Pedrol202c2f72019-10-08 13:11:05 +02005074 timer T_wait := 2.0;
5075 T_wait.start;
Harald Welte3d04ae62018-04-04 20:29:05 +02005076 alt {
5077 [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(bts_nr, ?))) -> value sd {
5078 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 +02005079 log("PCUIF_INFO_IND PDCH_MASK not yet '1' after PDCH ACT on TS", g_chan_nr.tn,
5080 " mask:", sd.data.u.info_ind.trx[trx_nr].pdch_mask);
5081 repeat;
Harald Welte3d04ae62018-04-04 20:29:05 +02005082 }
5083 }
5084 [] PCU.receive { repeat; }
Pau Espin Pedrol202c2f72019-10-08 13:11:05 +02005085 [] T_wait.timeout {
5086 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
5087 log2str("Timeout waiting for PCUIF_INFO_IND PDCH_MASK to be '1' on TS", g_chan_nr.tn));
5088 }
Harald Welte3d04ae62018-04-04 20:29:05 +02005089 }
5090 /* try to activate this PDCH from the PCU point of view */
5091 PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, g_chan_nr.tn)));
5092 /* FIXME: is there a response? */
5093}
5094
5095private function f_dyn_osmo_pdch_deact(integer pcu_conn_id, integer bts_nr, integer trx_nr)
5096runs on ConnHdlr {
5097 var PCUIF_send_data sd;
5098 /* Send RSL CHAN REL (deactivate) */
5099 PCU.clear;
5100 RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr));
5101 /* expect BTS to ask PCU to deactivate the channel */
Pau Espin Pedrol202c2f72019-10-08 13:11:05 +02005102 timer T_wait := 2.0;
5103 T_wait.start;
Harald Welte3d04ae62018-04-04 20:29:05 +02005104 alt {
5105 [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(bts_nr, ?))) -> value sd {
5106 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 +02005107 log("PCUIF_INFO_IND PDCH_MASK not yet '0' after PDCH DEACT on TS", g_chan_nr.tn,
5108 " mask:", sd.data.u.info_ind.trx[trx_nr].pdch_mask);
5109 repeat;
Harald Welte3d04ae62018-04-04 20:29:05 +02005110 }
5111 }
5112 [] PCU.receive { repeat; }
Pau Espin Pedrol202c2f72019-10-08 13:11:05 +02005113 [] T_wait.timeout {
5114 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
5115 log2str("Timeout waiting for PCUIF_INFO_IND PDCH_MASK to be '0' on TS", g_chan_nr.tn));
5116 }
Harald Welte3d04ae62018-04-04 20:29:05 +02005117 }
5118 /* Emulate PCU asking BTS to deactivate PDCH */
5119 PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_DEACT_REQ(bts_nr, trx_nr, g_chan_nr.tn)));
5120 alt {
5121 [] RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr)) {
5122 setverdict(pass);
5123 }
5124 [] RSL.receive { repeat; }
5125 }
5126}
5127
5128/* Activate Osmocom-style dynamic PDCH from BSC side */
5129function f_TC_dyn_osmo_pdch_act_deact(charstring id) runs on ConnHdlr {
5130 var PCUIF_Message first_info;
5131 var integer ts_nr := g_chan_nr.tn;
5132 var integer trx_nr := 0;
5133 var integer bts_nr := 0;
5134 var integer pcu_conn_id := -1;
5135
5136 f_init_pcu(PCU, id, pcu_conn_id, first_info);
5137
5138 f_dyn_osmo_pdch_act(pcu_conn_id, bts_nr, trx_nr);
5139 f_sleep(3.0);
5140 f_dyn_osmo_pdch_deact(pcu_conn_id, bts_nr, trx_nr);
5141 setverdict(pass);
5142}
5143testcase TC_dyn_osmo_pdch_act_deact() runs on test_CT {
5144 var ConnHdlrPars pars;
5145 var ConnHdlr vc_conn;
Harald Welte10474062019-05-30 16:48:17 +02005146 f_init();
Harald Welte3d04ae62018-04-04 20:29:05 +02005147
5148 pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN));
5149 vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_act_deact), pars, true);
5150 vc_conn.done;
5151}
5152
5153/* send a RF CHAN REL for PDCH on an osmocom dynamci PDCH that's already inactive */
5154function f_TC_dyn_osmo_pdch_unsol_deact(charstring id) runs on ConnHdlr {
5155 var PCUIF_Message first_info;
Harald Welte3d04ae62018-04-04 20:29:05 +02005156 var integer pcu_conn_id := -1;
5157
5158 f_init_pcu(PCU, id, pcu_conn_id, first_info);
5159
Neels Hofmeyr9c50ca52018-05-08 20:37:54 +02005160 RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr));
5161 /* since the lchan is already released, we don't expect any PCU changes, just a rel ack. */
5162 RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr));
Harald Welte3d04ae62018-04-04 20:29:05 +02005163 setverdict(pass);
5164}
5165testcase TC_dyn_osmo_pdch_unsol_deact() runs on test_CT {
5166 var ConnHdlrPars pars;
5167 var ConnHdlr vc_conn;
Harald Welte10474062019-05-30 16:48:17 +02005168 f_init();
Harald Welte3d04ae62018-04-04 20:29:05 +02005169
5170 pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN));
5171 vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_unsol_deact), pars, true);
5172 vc_conn.done;
5173}
5174
5175/* try to RSL CHAN ACT a PDCH on an osmocom-style PDCH that's already active */
5176function f_TC_dyn_osmo_pdch_double_act(charstring id) runs on ConnHdlr {
5177 var PCUIF_Message first_info;
5178 var integer ts_nr := g_chan_nr.tn;
5179 var integer trx_nr := 0;
5180 var integer bts_nr := 0;
5181 var integer pcu_conn_id := -1;
5182
5183 f_init_pcu(PCU, id, pcu_conn_id, first_info);
5184
5185 f_dyn_osmo_pdch_act(pcu_conn_id, bts_nr, trx_nr);
Neels Hofmeyrdf936a22018-05-08 22:07:57 +02005186 /* Send a second Chan Activ and expect it to be NACKed */
5187 f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_NACK(g_chan_nr),
5188 "RSL CHAN ACT NACK");
Harald Welte3d04ae62018-04-04 20:29:05 +02005189 setverdict(pass);
5190}
5191testcase TC_dyn_osmo_pdch_double_act() runs on test_CT {
5192 var ConnHdlrPars pars;
5193 var ConnHdlr vc_conn;
Harald Welte10474062019-05-30 16:48:17 +02005194 f_init();
Harald Welte3d04ae62018-04-04 20:29:05 +02005195
5196 pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN));
5197 vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_double_act), pars, true);
5198 vc_conn.done;
5199}
5200
5201/* try to RSL CHAN ACT a TCH/F on an osmocom-style PDCH */
5202function f_TC_dyn_osmo_pdch_tchf_act(charstring id) runs on ConnHdlr {
5203 var PCUIF_Message first_info;
5204 var integer ts_nr := g_chan_nr.tn;
5205 var integer trx_nr := 0;
5206 var integer bts_nr := 0;
5207 var integer pcu_conn_id := -1;
5208 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(g_chan_nr.tn));
5209
5210 /* register for the TCH/F channel number */
5211 f_rslem_register(0, chan_nr);
5212
5213 f_init_pcu(PCU, id, pcu_conn_id, first_info);
5214
5215 f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_ACK(chan_nr),
5216 "RSL CHAN ACT");
5217 setverdict(pass);
5218}
5219testcase TC_dyn_osmo_pdch_tchf_act() runs on test_CT {
5220 var ConnHdlrPars pars;
5221 var ConnHdlr vc_conn;
Harald Welte10474062019-05-30 16:48:17 +02005222 f_init();
Harald Welte3d04ae62018-04-04 20:29:05 +02005223
5224 pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN));
5225 vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_tchf_act), pars, true);
5226 vc_conn.done;
5227}
5228
5229/* try to RSL CHAN ACT the TCH/H on an osmocom-style PDCH */
5230function f_TC_dyn_osmo_pdch_tchh_act(charstring id) runs on ConnHdlr {
5231 var PCUIF_Message first_info;
5232 var integer ts_nr := g_chan_nr.tn;
5233 var integer trx_nr := 0;
5234 var integer bts_nr := 0;
5235 var integer pcu_conn_id := -1;
5236 var RslChannelNr chan_nr[2] := { valueof(t_RslChanNr_Lm(g_chan_nr.tn, 0)),
5237 valueof(t_RslChanNr_Lm(g_chan_nr.tn, 1)) };
5238
5239 /* register for the TCH/H channel numbers */
5240 f_rslem_register(0, chan_nr[0]);
5241 f_rslem_register(0, chan_nr[1]);
5242
5243 f_init_pcu(PCU, id, pcu_conn_id, first_info);
5244
5245 f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr[1], g_pars.chan_mode),
5246 tr_RSL_CHAN_ACT_ACK(chan_nr[1]), "RSL CHAN ACT [1]");
5247 f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr[0], g_pars.chan_mode),
5248 tr_RSL_CHAN_ACT_ACK(chan_nr[0]), "RSL CHAN ACT [0]");
5249 setverdict(pass);
5250}
5251testcase TC_dyn_osmo_pdch_tchh_act() runs on test_CT {
5252 var ConnHdlrPars pars;
5253 var ConnHdlr vc_conn;
Harald Welte10474062019-05-30 16:48:17 +02005254 f_init();
Harald Welte3d04ae62018-04-04 20:29:05 +02005255
5256 pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN));
5257 vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_tchh_act), pars, true);
5258 vc_conn.done;
5259}
5260
Harald Welte9bbbfb52018-04-05 09:33:19 +02005261/***********************************************************************
5262 * IPA Style Dynamic Timeslot Support
5263 ***********************************************************************/
5264
5265private function f_dyn_ipa_pdch_act(integer pcu_conn_id, integer bts_nr, integer trx_nr)
5266runs on ConnHdlr {
5267 var PCUIF_send_data sd;
5268 /* Expect BTS to immediately acknowledge activation as PDCH */
5269 PCU.clear;
5270 RSL.send(ts_RSL_IPA_PDCH_ACT(g_chan_nr));
5271 /* expect INFO_IND on PCU interface listing TS as PDCH */
Pau Espin Pedrol446e07b2019-02-18 21:18:36 +01005272 timer T_wait := 2.0;
5273 T_wait.start;
Harald Welte9bbbfb52018-04-05 09:33:19 +02005274 alt {
5275 [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(bts_nr, ?))) -> value sd {
5276 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 +01005277 log("PCUIF_INFO_IND PDCH_MASK not yet '1' after PDCH ACT on TS", g_chan_nr.tn,
5278 " mask:", sd.data.u.info_ind.trx[trx_nr].pdch_mask);
5279 repeat;
Harald Welte9bbbfb52018-04-05 09:33:19 +02005280 }
5281 }
5282 [] PCU.receive { repeat; }
Pau Espin Pedrol446e07b2019-02-18 21:18:36 +01005283 [] T_wait.timeout {
5284 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
5285 log2str("Timeout waiting for PCUIF_INFO_IND PDCH_MASK to be '1' on TS", g_chan_nr.tn));
5286 }
Harald Welte9bbbfb52018-04-05 09:33:19 +02005287 }
5288 /* try to activate this PDCH from the PCU point of view */
5289 PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, g_chan_nr.tn)));
5290 /* FIXME: is there a response? */
5291
5292 RSL.receive(tr_RSL_IPA_PDCH_ACT_ACK(g_chan_nr, ?));
5293}
5294
5295private function f_dyn_ipa_pdch_deact(integer pcu_conn_id, integer bts_nr, integer trx_nr)
5296runs on ConnHdlr {
5297 var PCUIF_send_data sd;
5298 /* Send RSL CHAN REL (deactivate) */
5299 RSL.send(ts_RSL_IPA_PDCH_DEACT(g_chan_nr));
5300 PCU.clear;
5301 /* expect BTS to ask PCU to deactivate the channel */
Pau Espin Pedrol446e07b2019-02-18 21:18:36 +01005302 timer T_wait := 2.0;
5303 T_wait.start;
Harald Welte9bbbfb52018-04-05 09:33:19 +02005304 alt {
5305 [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(bts_nr, ?))) -> value sd {
5306 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 +01005307 log("PCUIF_INFO_IND PDCH_MASK not yet '0' after PDCH DEACT on TS", g_chan_nr.tn,
5308 " mask:", sd.data.u.info_ind.trx[trx_nr].pdch_mask);
5309 repeat;
Harald Welte9bbbfb52018-04-05 09:33:19 +02005310 }
5311 }
5312 [] PCU.receive { repeat; }
Pau Espin Pedrol446e07b2019-02-18 21:18:36 +01005313 [] T_wait.timeout {
5314 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
5315 log2str("Timeout waiting for PCUIF_INFO_IND PDCH_MASK to be '0' on TS", g_chan_nr.tn));
5316 }
Harald Welte9bbbfb52018-04-05 09:33:19 +02005317 }
5318 /* Emulate PCU asking BTS to deactivate PDCH */
5319 PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_DEACT_REQ(bts_nr, trx_nr, g_chan_nr.tn)));
5320 alt {
5321 [] RSL.receive(tr_RSL_IPA_PDCH_DEACT_ACK(g_chan_nr)) {
5322 setverdict(pass);
5323 }
5324 [] RSL.receive { repeat; }
5325 }
5326}
5327
5328/* Activate and de-activate an IPA-style dynamic TCH/F + PDCH */
5329function f_TC_dyn_ipa_pdch_act_deact(charstring id) runs on ConnHdlr {
5330 var PCUIF_Message first_info;
5331 var integer ts_nr := g_chan_nr.tn;
5332 var integer trx_nr := 0;
5333 var integer bts_nr := 0;
5334 var integer pcu_conn_id := -1;
5335
5336 f_init_pcu(PCU, id, pcu_conn_id, first_info);
5337
5338 f_dyn_ipa_pdch_act(pcu_conn_id, bts_nr, trx_nr);
5339 f_sleep(3.0);
5340 f_dyn_ipa_pdch_deact(pcu_conn_id, bts_nr, trx_nr);
5341
5342 setverdict(pass);
5343
5344}
5345testcase TC_dyn_ipa_pdch_act_deact() runs on test_CT {
5346 var ConnHdlrPars pars;
5347 var ConnHdlr vc_conn;
5348 f_init();
5349
5350 pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN));
5351 vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_act_deact), pars, true);
5352 vc_conn.done;
5353}
5354
5355/* try to RSL CHAN ACT a TCH/F on an IPA-style PDCH */
5356function f_TC_dyn_ipa_pdch_tchf_act(charstring id) runs on ConnHdlr {
5357 var PCUIF_Message first_info;
5358 var integer ts_nr := g_chan_nr.tn;
5359 var integer trx_nr := 0;
5360 var integer bts_nr := 0;
5361 var integer pcu_conn_id := -1;
5362
5363 f_init_pcu(PCU, id, pcu_conn_id, first_info);
5364
5365 f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_ACK(g_chan_nr),
5366 "RSL CHAN ACT");
5367 f_rsl_transceive(ts_RSL_RF_CHAN_REL(g_chan_nr), tr_RSL_RF_CHAN_REL_ACK(g_chan_nr),
5368 "RF CHAN REL", true);
5369 setverdict(pass);
5370}
5371testcase TC_dyn_ipa_pdch_tchf_act() runs on test_CT {
5372 var ConnHdlrPars pars;
5373 var ConnHdlr vc_conn;
Harald Welte10474062019-05-30 16:48:17 +02005374 f_init();
Harald Welte9bbbfb52018-04-05 09:33:19 +02005375
5376 pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN));
5377 vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_tchf_act), pars, true);
5378 vc_conn.done;
5379}
5380
5381/* Activate IPA style dyn PDCH as TCH/F and then illegally try to activate it as PDCH, too */
5382function f_TC_dyn_ipa_pdch_tchf_act_pdch_act_nack(charstring id) runs on ConnHdlr {
5383 var PCUIF_Message first_info;
5384 var integer ts_nr := g_chan_nr.tn;
5385 var integer trx_nr := 0;
5386 var integer bts_nr := 0;
5387 var integer pcu_conn_id := -1;
5388
5389 f_init_pcu(PCU, id, pcu_conn_id, first_info);
5390
5391 f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_ACK(g_chan_nr),
5392 "RSL CHAN ACT");
5393
5394 RSL.send(ts_RSL_IPA_PDCH_ACT(g_chan_nr));
5395 alt {
5396 [] RSL.receive(tr_RSL_IPA_PDCH_ACT_NACK(g_chan_nr, ?));
5397 [] RSL.receive(tr_RSL_IPA_PDCH_ACT_ACK(g_chan_nr, ?)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02005398 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected PDCH ACT ACK");
Harald Welte9bbbfb52018-04-05 09:33:19 +02005399 }
5400 [] RSL.receive { repeat; }
5401 }
5402
5403 f_rsl_transceive(ts_RSL_RF_CHAN_REL(g_chan_nr), tr_RSL_RF_CHAN_REL_ACK(g_chan_nr),
5404 "RF CHAN REL", true);
5405 setverdict(pass);
5406}
5407testcase TC_dyn_ipa_pdch_tchf_act_pdch_act_nack() runs on test_CT {
5408 var ConnHdlrPars pars;
5409 var ConnHdlr vc_conn;
Harald Welte10474062019-05-30 16:48:17 +02005410 f_init();
Harald Welte9bbbfb52018-04-05 09:33:19 +02005411
5412 pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN));
5413 vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_tchf_act_pdch_act_nack), pars, true);
5414 vc_conn.done;
5415}
5416
5417/* try to RSL CHAN ACT a TCH/F on an IPA-style PDCH that's already in PDCH mode; expect NACK */
5418function f_TC_dyn_ipa_pdch_act_tchf_act_nack(charstring id) runs on ConnHdlr {
5419 var PCUIF_Message first_info;
5420 var integer ts_nr := g_chan_nr.tn;
5421 var integer trx_nr := 0;
5422 var integer bts_nr := 0;
5423 var integer pcu_conn_id := -1;
5424
5425 /* register for the TCH/F channel number */
5426 f_rslem_register(0, g_chan_nr);
5427
5428 f_init_pcu(PCU, id, pcu_conn_id, first_info);
5429
5430 f_dyn_ipa_pdch_act(pcu_conn_id, bts_nr, trx_nr);
5431
5432 f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_NACK(g_chan_nr),
5433 "RSL CHAN ACT");
5434
5435 f_dyn_ipa_pdch_deact(pcu_conn_id, bts_nr, trx_nr);
5436
5437 setverdict(pass);
5438}
5439testcase TC_dyn_ipa_pdch_act_tchf_act_nack() runs on test_CT {
5440 var ConnHdlrPars pars;
5441 var ConnHdlr vc_conn;
Harald Welte10474062019-05-30 16:48:17 +02005442 f_init();
Harald Welte9bbbfb52018-04-05 09:33:19 +02005443
5444 pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN));
5445 vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_act_tchf_act_nack), pars, true);
5446 vc_conn.done;
5447}
5448
5449
Harald Welte0472ab42018-03-12 15:02:26 +01005450/***********************************************************************
5451 * LAPDm / RLL related
5452 ***********************************************************************/
5453
5454private function f_tx_lapdm(template (value) LapdmFrame l,
5455 template (value) RslLinkId link_id) runs on ConnHdlr {
5456 var octetstring l2 := enc_LapdmFrame(valueof(l));
Vadim Yanitskiy0a8d6da2019-05-28 22:18:28 +07005457 var template (value) SacchL1Header l1h;
5458
5459 /* TODO: we can use an extension of TTCN-3 for padding, i.e. PADDING('2B'O) */
Harald Welte0472ab42018-03-12 15:02:26 +01005460 if (valueof(link_id.c) == SACCH) {
Vadim Yanitskiy0a8d6da2019-05-28 22:18:28 +07005461 /* Compose dummy L1 header */
5462 l1h := ts_SacchL1Header(g_pars.l1_pars.ms_power_level, false, g_pars.l1_pars.ms_actual_ta);
5463 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 +02005464 } else {
5465 /* If required, pad L2 frame with constant 0x2b filling */
Vadim Yanitskiy0a8d6da2019-05-28 22:18:28 +07005466 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 +01005467 }
Harald Welte0472ab42018-03-12 15:02:26 +01005468}
5469
5470type record RllTestCase {
5471 uint3_t sapi,
5472 RslLinkId link_id,
5473 octetstring l3,
5474 boolean exp
5475}
5476type record of RllTestCase RllTestCases;
5477template RllTestCase t_EITC(uint3_t sapi, RslLinkId id, octetstring l3, boolean exp) := {
5478 sapi := sapi,
5479 link_id := id,
5480 l3 := l3,
5481 exp := exp
5482}
5483
5484/* execute the same callback function with a set of different parameters (tcs) on a
5485 * variety of logical channels */
5486private function f_rll_testmatrix(RllTestCases tcs, void_fn fn) runs on test_CT {
5487 var ConnHdlrPars pars;
5488 var ConnHdlr vc_conn;
Harald Welte10474062019-05-30 16:48:17 +02005489 f_init();
Harald Welte0472ab42018-03-12 15:02:26 +01005490
5491 /* test on each of the channels we have */
5492 for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i+1) {
5493 pars := valueof(t_Pars(g_AllChanTypes[i], ts_RSL_ChanMode_SIGN));
5494
5495 /* test each of the test cases on the current channel */
5496 for (var integer j := 0; j < sizeof(tcs); j := j+1) {
5497 pars.spec.rll := tcs[j];
5498 log(testcasename(), ": XXX Starting ", tcs[j] , " on ", g_AllChanTypes[i]);
5499 vc_conn := f_start_handler(fn, pars);
5500 vc_conn.done;
5501 }
5502 }
5503
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02005504 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte0472ab42018-03-12 15:02:26 +01005505}
5506
5507/* test if SABM on Um triggers EST IND (TS 48.058 3.1) */
5508private function f_TC_rll_est_ind(charstring id) runs on ConnHdlr {
5509 var RllTestCase tc := g_pars.spec.rll;
5510 timer T := 3.0;
5511
5512 f_l1_tune(L1CTL);
5513 RSL.clear;
5514
5515 /* activate the logical channel */
5516 f_est_dchan();
5517 L1CTL.clear;
5518
5519 f_tx_lapdm(ts_LAPDm_SABM(tc.sapi, cr_MO_CMD, true, tc.l3), tc.link_id);
5520 T.start;
5521 alt {
5522 [tc.l3 != ''O] RSL.receive(tr_RSL_EST_IND(g_chan_nr, tc.link_id, tc.l3)) {
5523 if (tc.exp) {
5524 setverdict(pass);
5525 } else {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02005526 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Unexpected EST IND with L3 in ", tc));
Harald Welte0472ab42018-03-12 15:02:26 +01005527 }
5528 }
5529 [tc.l3 == ''O] RSL.receive(tr_RSL_EST_IND_NOL3(g_chan_nr, tc.link_id)) {
5530 if (tc.exp) {
5531 setverdict(pass);
5532 } else {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02005533 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Unexpected EST IND without L3 in ", tc));
Harald Welte0472ab42018-03-12 15:02:26 +01005534 }
5535 }
Vadim Yanitskiy35677872018-10-04 17:30:21 +07005536 /* We also expect to receive the measurements */
5537 [] as_meas_res(verify_meas := false);
Harald Welte0472ab42018-03-12 15:02:26 +01005538 [tc.exp] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02005539 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for EST IND");
Harald Welte0472ab42018-03-12 15:02:26 +01005540 }
5541 [not tc.exp] T.timeout {
5542 setverdict(pass);
5543 }
5544 }
5545
5546 f_rsl_chan_deact();
5547 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
5548 f_rslem_unregister(0, g_chan_nr);
5549}
5550testcase TC_rll_est_ind() runs on test_CT {
5551 var RllTestCases tcs := {
Harald Welte7aacbbf2018-05-09 16:56:41 +02005552 /* SAPI0 establishment (contention resolution) */
Harald Welte0472ab42018-03-12 15:02:26 +01005553 valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), '01020304'O, true)),
Harald Welte7aacbbf2018-05-09 16:56:41 +02005554 /* normal SAPI0 establishment */
5555 valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), ''O, true)),
Harald Welte0472ab42018-03-12 15:02:26 +01005556 /* SAPI 3 doesn't support contention resolution */
5557 valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), '01020304'O, false)),
5558 valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), '01020304'O, false)),
5559 /* normal SAPI3 establishment on main DCCH */
5560 valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), ''O, true)),
5561 /* normal SAPI3 establishment on SACCH */
5562 valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), ''O, true))
5563 };
5564 f_rll_testmatrix(tcs, refers(f_TC_rll_est_ind));
5565}
5566
5567/* test if RLL EST REQ trigeres SABM on Um; UA on Um triggers EST CONF (TS 48.058 3.2) */
5568private function f_TC_rll_est_req(charstring id) runs on ConnHdlr {
5569 var RllTestCase tc := g_pars.spec.rll;
5570 var L1ctlDlMessage dl;
5571 timer T := 3.0;
5572
5573 f_l1_tune(L1CTL);
5574 RSL.clear;
5575
5576 /* activate the logical channel */
5577 f_est_dchan();
5578 L1CTL.clear;
5579
5580 /* Send a RSL EST REQ for SAPI3 on main DCCH */
5581 RSL.send(ts_RSL_EST_REQ(g_chan_nr, tc.link_id));
5582 T.start;
5583 alt {
5584 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, ?)) -> value dl {
5585 var LapdmFrame lapdm;
5586 var octetstring l2 := dl.payload.data_ind.payload;
5587 if (dl.dl_info.link_id.c == SACCH) {
5588 /* remove L1 header */
5589 l2 := substr(l2, 2, lengthof(l2)-2);
5590 }
5591 lapdm.ab := dec_LapdmFrameAB(l2);
5592 if (match(lapdm, tr_LAPDm_SABM(tc.sapi, cr_MT_CMD, true, ''O))) {
5593 setverdict(pass);
5594 } else {
5595 repeat;
5596 }
5597 }
5598 [] L1CTL.receive { repeat; }
5599 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02005600 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for SABM");
Harald Welte0472ab42018-03-12 15:02:26 +01005601 }
5602 }
5603
5604 f_rsl_chan_deact();
5605 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
5606 f_rslem_unregister(0, g_chan_nr);
5607}
5608testcase TC_rll_est_req_DCCH_3() runs on test_CT {
5609 var RllTestCases tcs := {
5610 /* normal SAPI3 establishment on main DCCH */
5611 valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), ''O, true))//,
5612 };
5613 f_rll_testmatrix(tcs, refers(f_TC_rll_est_req));
5614}
5615testcase TC_rll_est_req_ACCH_3() runs on test_CT {
5616 var RllTestCases tcs := {
5617 /* normal SAPI3 establishment on SACCH */
5618 valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), ''O, true))
5619 }
5620 f_rll_testmatrix(tcs, refers(f_TC_rll_est_req));
5621}
5622
5623/* altstep to receive a LAPDm frame matching the given template */
5624private altstep as_l1_exp_lapdm(template LapdmFrame exp) runs on ConnHdlr {
5625 var L1ctlDlMessage dl;
5626 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, ?)) -> value dl {
5627 var LapdmFrame lapdm;
5628 var octetstring l2 := dl.payload.data_ind.payload;
5629 if (dl.dl_info.link_id.c == SACCH) {
5630 /* remove L1 header */
5631 l2 := substr(l2, 2, lengthof(l2)-2);
5632 }
5633 if (ischosen(exp.ab)) {
5634 lapdm.ab := dec_LapdmFrameAB(l2);
5635 } else if (ischosen(exp.b4)) {
5636 lapdm.b4 := dec_LapdmFrameB4(l2);
5637 } else if (ischosen(exp.bbis)) {
5638 lapdm.bbis := dec_LapdmFrameBbis(l2);
5639 }
5640 log("Rx LAPDm ", lapdm);
5641 if (match(lapdm, exp)) {
5642 setverdict(pass);
5643 } else {
5644 repeat;
5645 }
5646 }
5647 [] L1CTL.receive { repeat; }
5648}
5649private function f_l1_exp_lapdm(template LapdmFrame exp, float t := 3.0) runs on ConnHdlr {
5650 timer T := t;
5651 T.start;
5652 alt {
5653 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02005654 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Timeout waiting for LAPDm ", exp));
Harald Welte0472ab42018-03-12 15:02:26 +01005655 }
5656 [] as_l1_exp_lapdm(exp);
5657 }
5658}
5659
5660/* establish one Radio Link Layer via SABM -> UA. Use l3 for contention resolution */
5661private function f_est_rll_mo(uint3_t sapi, RslLinkId link_id, octetstring l3) runs on ConnHdlr {
5662 /* send SABM from MS -> BTS */
5663 f_tx_lapdm(ts_LAPDm_SABM(sapi, cr_MO_CMD, true, l3), link_id);
5664 /* expect RLL EST IND on Abis */
5665 alt {
5666 [l3 != ''O] RSL.receive(tr_RSL_EST_IND(g_chan_nr, link_id, l3));
5667 [l3 == ''O] RSL.receive(tr_RSL_EST_IND_NOL3(g_chan_nr, link_id));
5668 [] RSL.receive(tr_RSL_ERROR_IND(g_chan_nr, link_id, ?)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02005669 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Failing due to RSL_ERROR_IND");
Harald Welte0472ab42018-03-12 15:02:26 +01005670 }
5671 [] RSL.receive { repeat; }
5672 }
5673 /* expect UA from BTS -> MS */
5674 f_l1_exp_lapdm(tr_LAPDm_UA(sapi, cr_MT_RSP, true, l3));
5675}
5676
5677/* test if DISC on Um triggers RLL REL IND (TS 48.058 3.3) */
5678private function f_TC_rll_rel_ind(charstring id) runs on ConnHdlr {
5679 var RllTestCase tc := g_pars.spec.rll;
5680
5681 f_l1_tune(L1CTL);
5682 RSL.clear;
5683
5684 /* activate the logical channel */
5685 f_est_dchan();
5686 L1CTL.clear;
5687
5688 /* first establish the link-layer */
5689 f_est_rll_mo(tc.sapi, tc.link_id, tc.l3);
5690
5691 /* then send the DISC */
5692 f_tx_lapdm(ts_LAPDm_DISC(tc.sapi, cr_MO_CMD, true), tc.link_id);
5693 /* ... and expect the REL IND on the RSL side */
5694 alt {
5695 [] RSL.receive(tr_RSL_REL_IND(g_chan_nr, tc.link_id)) {
5696 setverdict(pass);
5697 }
Vadim Yanitskiy35677872018-10-04 17:30:21 +07005698 /* We also expect to receive the measurements */
5699 [] as_meas_res(verify_meas := false);
Harald Welte0472ab42018-03-12 15:02:26 +01005700 }
5701
5702 /* release the channel */
5703 f_rsl_chan_deact();
5704 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
5705 f_rslem_unregister(0, g_chan_nr);
5706}
5707testcase TC_rll_rel_ind_DCCH_0() runs on test_CT {
5708 var RllTestCases tcs := {
5709 valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), '01020304'O, true))
5710 };
5711 f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind));
5712}
5713
5714testcase TC_rll_rel_ind_ACCH_0() runs on test_CT {
5715 var RllTestCases tcs := {
5716 valueof(t_EITC(0, valueof(ts_RslLinkID_SACCH(0)), ''O, true))
5717 };
5718 f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind));
5719}
5720testcase TC_rll_rel_ind_DCCH_3() runs on test_CT {
5721 var RllTestCases tcs := {
5722 valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), ''O, true))
5723 };
5724 f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind));
5725}
5726testcase TC_rll_rel_ind_ACCH_3() runs on test_CT {
5727 var RllTestCases tcs := {
5728 valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), ''O, true))
5729 };
5730 f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind));
5731}
5732
5733/* test if RLL REL REQ triggers DISC on Um; UA/DM triggers RLL REL CONF (TS 48.058 3.4) */
5734private function f_TC_rll_rel_req(charstring id) runs on ConnHdlr {
5735 var RllTestCase tc := g_pars.spec.rll;
5736 f_l1_tune(L1CTL);
5737 RSL.clear;
5738
5739 /* activate the logical channel */
5740 f_est_dchan();
5741 L1CTL.clear;
5742
5743 /* first establish the link-layer */
5744 f_est_rll_mo(tc.sapi, tc.link_id, tc.l3);
5745
5746 /* then send the REL REQ via RSL */
5747 RSL.send(ts_RSL_REL_REQ(g_chan_nr, tc.link_id, RSL_REL_MODE_NORMAL));
5748 /* ... and expect the DISC on the Um side */
5749 alt {
Harald Weltebc6199f2018-05-10 19:38:18 +02005750 [] as_l1_exp_lapdm(tr_LAPDm_DISC(tc.sapi, cr_MT_CMD, true)) {
Harald Welte0472ab42018-03-12 15:02:26 +01005751 /* FIXME: send a UA in resposne to the DISC */
5752 }
5753 }
5754
5755 /* release the channel */
5756 f_rsl_chan_deact();
5757 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
5758 f_rslem_unregister(0, g_chan_nr);
5759}
5760testcase TC_rll_rel_req() runs on test_CT {
5761 var RllTestCases tcs := {
5762 valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), '01020304'O, true)),
5763 valueof(t_EITC(0, valueof(ts_RslLinkID_SACCH(0)), ''O, true)),
5764 valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), ''O, true)),
5765 valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), ''O, true))
5766 };
5767 f_rll_testmatrix(tcs, refers(f_TC_rll_rel_req));
5768}
5769
5770/* test if RLL DATA REQ triggers I-frames on Um (TS 48.058 3.5) */
5771testcase TC_rll_data_req() runs on test_CT {
5772}
5773
5774/* test if I-frames on Um trigger RLL DATA IND (TS 48.058 3.6) */
5775testcase TC_rll_data_ind() runs on test_CT {
5776}
5777
5778/* test if RLL UNIT DATA REQ triggers UI-frame on Um (TS 48.058 3.7) */
5779private function f_TC_rll_ud_req(charstring id) runs on ConnHdlr {
5780 var RllTestCase tc := g_pars.spec.rll;
5781
5782 f_l1_tune(L1CTL);
5783 RSL.clear;
5784
5785 f_est_dchan();
5786 L1CTL.clear;
5787
5788 /* Send UNITDATA REQ on RSL side */
5789 RSL.send(ts_RSL_UNITDATA_REQ(g_chan_nr, tc.link_id, tc.l3));
5790 /* Expect it to arrive on the other side */
5791 if (tc.link_id.c == SACCH) {
Harald Weltee613f962018-04-18 22:38:16 +02005792 f_l1_exp_lapdm(tr_LAPDm_B4_UI(tc.sapi, cr_MT_CMD, tc.l3));
Harald Welte0472ab42018-03-12 15:02:26 +01005793 } else {
Harald Weltee613f962018-04-18 22:38:16 +02005794 f_l1_exp_lapdm(tr_LAPDm_UI(tc.sapi, cr_MT_CMD, tc.l3));
Harald Welte0472ab42018-03-12 15:02:26 +01005795 }
5796
5797 /* release the channel */
5798 f_rsl_chan_deact();
5799 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
5800 f_rslem_unregister(0, g_chan_nr);
5801}
5802testcase TC_rll_unit_data_req_DCCH() runs on test_CT {
5803 var octetstring l3 := f_rnd_octstring(15);
5804 var RllTestCases tcs := {
5805 valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), l3, true)),
5806 valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), l3, true))
5807 };
5808 f_rll_testmatrix(tcs, refers(f_TC_rll_ud_req));
5809}
5810testcase TC_rll_unit_data_req_ACCH() runs on test_CT {
5811 var octetstring l3 := f_rnd_octstring(19);
5812 var RllTestCases tcs := {
5813 valueof(t_EITC(0, valueof(ts_RslLinkID_SACCH(0)), l3, true)),
5814 valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), l3, true))
5815 };
5816 f_rll_testmatrix(tcs, refers(f_TC_rll_ud_req));
5817}
5818
5819/* test if UI-frames on Um trigger RLL UNIT DATA IND (TS 48.058 3.8) */
5820private function f_TC_rll_ud_ind(charstring id) runs on ConnHdlr {
5821 var RllTestCase tc := g_pars.spec.rll;
5822
5823 f_l1_tune(L1CTL);
5824 RSL.clear;
5825
5826 f_est_dchan();
5827 L1CTL.clear;
5828
5829 /* Send LAPDm UI frame. There is no B4 format in uplink! */
Harald Weltee613f962018-04-18 22:38:16 +02005830 f_tx_lapdm(ts_LAPDm_UI(tc.sapi, cr_MO_CMD, tc.l3), tc.link_id);
Harald Welte0472ab42018-03-12 15:02:26 +01005831 /* Expdct RLL UNITDATA IND on RSL side */
5832 alt {
5833 [] RSL.receive(tr_RSL_UNITDATA_IND(g_chan_nr, tc.link_id, tc.l3)) {
5834 setverdict(pass);
5835 }
5836 [] RSL.receive { repeat; }
5837 }
5838
5839 /* release the channel */
5840 f_rsl_chan_deact();
5841 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
5842 f_rslem_unregister(0, g_chan_nr);
5843}
5844testcase TC_rll_unit_data_ind_DCCH() runs on test_CT {
Stefan Sperlingc4181912018-07-25 17:03:08 +02005845 var octetstring l3 := f_rnd_octstring(20);
Harald Welte0472ab42018-03-12 15:02:26 +01005846 var RllTestCases tcs := {
5847 valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), l3, true)),
5848 valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), l3, true))
5849 };
5850 f_rll_testmatrix(tcs, refers(f_TC_rll_ud_ind));
5851}
5852testcase TC_rll_unit_data_ind_ACCH() runs on test_CT {
5853 var octetstring l3 := f_rnd_octstring(18);
5854 var RllTestCases tcs := {
5855 valueof(t_EITC(0, valueof(ts_RslLinkID_SACCH(0)), l3, true)),
5856 valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), l3, true))
5857 };
5858 f_rll_testmatrix(tcs, refers(f_TC_rll_ud_ind));
5859}
5860
Harald Weltee613f962018-04-18 22:38:16 +02005861/***********************************************************************
5862 * Encryption Related
5863 ***********************************************************************/
5864
5865/* send UNITDATA_REQ from BTS to MS and expect it to arrive */
5866function f_unitdata_mt(RslLinkId link_id, octetstring l3) runs on ConnHdlr {
5867 RSL.send(ts_RSL_UNITDATA_REQ(g_chan_nr, link_id, l3));
5868 if (link_id.c == SACCH) {
5869 f_l1_exp_lapdm(tr_LAPDm_B4_UI(link_id.sapi, cr_MT_CMD, l3));
5870 } else {
5871 f_l1_exp_lapdm(tr_LAPDm_UI(link_id.sapi, cr_MT_CMD, l3));
5872 }
5873}
5874
Vadim Yanitskiyad131c82018-10-04 06:18:59 +07005875/* Expect (or not expect) other kinds of messages */
5876private altstep as_rsl_any_ind(boolean exp_any) runs on ConnHdlr {
5877 [exp_any] RSL.receive { repeat; }
5878 [not exp_any] RSL.receive {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02005879 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RSL message!");
Vadim Yanitskiyad131c82018-10-04 06:18:59 +07005880 }
5881}
5882
Harald Weltee613f962018-04-18 22:38:16 +02005883/* Send UI frame from MS and expect it to arrive as RLL UNITDATA IND on Abis */
Vadim Yanitskiy8d8f91c2018-10-04 06:19:45 +07005884private function f_unitdata_mo(
Vadim Yanitskiy98e03152018-10-03 18:06:06 +07005885 RslLinkId link_id,
5886 octetstring l3,
5887 boolean exp_sacch := true, /* Should tolerate SACCH messages? */
Vadim Yanitskiyb9920502018-10-03 18:29:51 +07005888 boolean exp_any := false /* Should tolerate any other RSL messages? */
Vadim Yanitskiy98e03152018-10-03 18:06:06 +07005889) runs on ConnHdlr {
Harald Weltee613f962018-04-18 22:38:16 +02005890 timer T := 3.0;
5891 f_tx_lapdm(ts_LAPDm_UI(link_id.sapi, cr_MO_CMD, l3), link_id);
5892 T.start;
5893 /* Expect RLL UNITDATA IND on RSL side */
5894 alt {
5895 [] RSL.receive(tr_RSL_UNITDATA_IND(g_chan_nr, link_id, l3)) {
5896 setverdict(pass);
5897 }
Vadim Yanitskiye0b91a72018-10-04 15:44:40 +07005898 [exp_sacch] as_meas_res(verify_meas := false);
Vadim Yanitskiyad131c82018-10-04 06:18:59 +07005899 [] as_rsl_any_ind(exp_any);
Harald Weltee613f962018-04-18 22:38:16 +02005900 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02005901 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for UNIT_DATA_IND");
Harald Weltee613f962018-04-18 22:38:16 +02005902 }
Harald Weltee613f962018-04-18 22:38:16 +02005903 }
5904}
5905
Vadim Yanitskiy4d78a702018-10-03 03:59:34 +07005906/* Send I-frame from MS and expect it to arrive as RLL DATA IND on Abis */
5907private function f_data_mo(
5908 RslLinkId link_id,
5909 boolean p, uint3_t nr, uint3_t ns,
5910 octetstring l3,
5911 boolean exp_sacch := true, /* Should tolerate SACCH messages? */
Vadim Yanitskiyb9920502018-10-03 18:29:51 +07005912 boolean exp_any := false /* Should tolerate any other RSL messages? */
Vadim Yanitskiy4d78a702018-10-03 03:59:34 +07005913) runs on ConnHdlr {
5914 timer T := 3.0;
5915 f_tx_lapdm(ts_LAPDm_I(link_id.sapi, cr_MO_CMD, p, nr, ns, l3), link_id);
5916 T.start;
5917 /* Expect RLL DATA IND on RSL side */
5918 alt {
5919 [] RSL.receive(tr_RSL_DATA_IND(g_chan_nr, link_id, l3)) {
5920 setverdict(pass);
5921 }
Vadim Yanitskiye0b91a72018-10-04 15:44:40 +07005922 [exp_sacch] as_meas_res(verify_meas := false);
Vadim Yanitskiy4d78a702018-10-03 03:59:34 +07005923 [] as_rsl_any_ind(exp_any);
5924 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02005925 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for DATA_IND");
Vadim Yanitskiy4d78a702018-10-03 03:59:34 +07005926 }
5927 }
5928}
5929
Harald Weltee613f962018-04-18 22:38:16 +02005930/* Test channel activation with A5/n right from the beginning (like in assignment + hand-over) */
5931function f_TC_chan_act_encr(charstring id) runs on ConnHdlr {
5932 f_l1_tune(L1CTL);
5933 f_est_dchan(true);
5934
5935 /* now we actually need to transmit some data both ways to check if the encryption works */
5936 var L1ctlDlMessage dl;
5937
Stefan Sperling603d98e2018-07-25 16:47:28 +02005938 var octetstring l3 := f_rnd_octstring(20);
Harald Weltee613f962018-04-18 22:38:16 +02005939 var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0));
5940
5941 /* send UNITDATA_REQ from BTS to MS and expect it to arrive */
5942 f_unitdata_mt(link_id, l3);
5943
5944 /* Send UI frame from MS and expect it to arrive as RLL UNITDATA IND on Abis */
5945 f_unitdata_mo(link_id, l3);
5946
5947 /* release the channel */
5948 f_rsl_chan_deact();
5949 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
5950 f_rslem_unregister(0, g_chan_nr);
5951}
5952testcase TC_chan_act_a51() runs on test_CT {
5953 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
5954 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_1, f_rnd_octstring(8)));
5955 f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr));
5956}
5957testcase TC_chan_act_a52() runs on test_CT {
5958 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
5959 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_2, f_rnd_octstring(8)));
5960 f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr));
5961}
5962testcase TC_chan_act_a53() runs on test_CT {
5963 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
5964 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_3, f_rnd_octstring(8)));
5965 f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr));
5966}
5967
Eric Wildf1827a72019-05-28 17:37:35 +02005968/* Test channel activation with A5/n right from the beginning and RSL MODE MODIFY
5969 which should break the en/decryption on purpose by supplying a new key that is unknown to the MS*/
5970function f_TC_rsl_modify_encr(charstring id) runs on ConnHdlr {
5971 f_l1_tune(L1CTL);
5972 f_est_dchan(true);
5973
5974 /* now we actually need to transmit some data both ways to check if the encryption works */
5975 var L1ctlDlMessage dl;
5976
5977 var octetstring l3 := f_rnd_octstring(20);
5978 var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0));
5979
5980 /* send UNITDATA_REQ from BTS to MS and expect it to arrive */
5981 f_unitdata_mt(link_id, l3);
5982
5983 /* Send UI frame from MS and expect it to arrive as RLL UNITDATA IND on Abis */
5984 f_unitdata_mo(link_id, l3);
5985
5986 var RSL_Message rsl;
5987 rsl := valueof(ts_RSL_MODE_MODIFY_REQ(g_chan_nr, valueof(ts_RSL_ChanMode_SIGN(false))));
5988
5989 /* modify key to break proper encryption */
5990 g_pars.encr.key := f_rnd_octstring(8);
5991 var RSL_IE ei := valueof(t_RSL_IE(RSL_IE_ENCR_INFO, RSL_IE_Body:{encr_info := g_pars.encr}));
5992 rsl.ies := rsl.ies & { ei };
5993 RSL.send(rsl);
5994
5995 timer T0 := 1.0;
5996 T0.start;
5997 /* Expect RSL MODIFY ACK */
5998 alt {
5999 [] RSL.receive(tr_RSL_MODE_MODIFY_ACK(g_chan_nr)) {}
6000 [] RSL.receive(tr_RSL_MODE_MODIFY_NACK(g_chan_nr, ?)) {
6001 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,"MODE MODIFY NACK");
6002 }
6003 [] T0.timeout {
6004 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for MODE MODIFY (N)ACK");
6005 }
6006 }
6007
6008 var octetstring l3msg := f_rnd_octstring(15);
6009 timer T1 := 3.0;
6010 /* Send UI frame from MS, do not expect it to arrive as RLL UNITDATA IND on Abis
6011 due to broken encryption */
6012 f_tx_lapdm(ts_LAPDm_UI(link_id.sapi, cr_MO_CMD, l3msg), link_id);
6013 T1.start;
6014 alt {
6015 [] RSL.receive(tr_RSL_UNITDATA_IND(g_chan_nr, link_id, l3msg)) {
6016 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "BTS shouldn't be able to decrypt after key change")
6017 }
6018 [] T1.timeout {
6019 setverdict(pass);
6020 }
6021 }
6022
6023 /* release the channel */
6024 f_rsl_chan_deact();
6025 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
6026 f_rslem_unregister(0, g_chan_nr);
6027}
6028testcase TC_rsl_modify_encr() runs on test_CT {
6029 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
6030 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_1, f_rnd_octstring(8)));
6031 f_testmatrix_each_chan(pars, refers(f_TC_rsl_modify_encr));
6032}
Harald Weltee613f962018-04-18 22:38:16 +02006033
6034/* Test unencrypted channel activation followed by explicit ENCR CMD later */
6035function f_TC_encr_cmd(charstring id) runs on ConnHdlr {
6036 /* L3 payload doesn't matter, as it is passed transparently */
6037 var BIT3 l3_alg_id := f_alg_id_to_l3(g_pars.encr.alg_id);
6038 var octetstring l3 := enc_PDU_ML3_NW_MS(valueof(ts_RRM_CiphModeCmd(l3_alg_id)));
6039 var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0));
6040
6041 f_l1_tune(L1CTL);
6042
6043 /* first establish a dedicated channel in the clear */
6044 f_est_dchan(false);
6045
6046 /* Establish ABM */
6047 f_est_rll_mo(link_id.sapi, link_id, '23420815'O);
6048
6049 /* then send the RSL ENCR CMD with an actual RR CIPH MOD CMD inside */
6050 RSL.send(ts_RSL_ENCR_CMD(g_chan_nr, link_id, g_pars.encr.alg_id, g_pars.encr.key, l3));
6051 /* expect the L3 to arrive still unencrypted on the MS side */
6052 f_l1_exp_lapdm(tr_LAPDm_I(link_id.sapi, cr_MT_CMD, ?, ?, ?, l3));
6053
6054 /* configure L1 to apply ciphering */
6055 var uint8_t alg_id := f_alg_id_to_l1ctl(g_pars.encr.alg_id);
6056 f_L1CTL_CRYPTO_REQ(L1CTL, g_pars.chan_nr, alg_id, g_pars.encr.key);
6057
Vadim Yanitskiy4d78a702018-10-03 03:59:34 +07006058 /* send first ciphered I-frame in response and expect it on RSL */
6059 f_data_mo(link_id, true, 1, 0, '0a0b0c0d'O, exp_sacch := true);
Harald Weltee613f962018-04-18 22:38:16 +02006060
6061 /* now the BTS code should have detected the first properly encrypted uplink I-frame,
6062 * and hence enable encryption also on the downlink */
6063
6064 /* expect bi-directional communication work in encrypted mode */
6065 f_unitdata_mo(link_id, f_rnd_octstring(15));
6066 f_unitdata_mt(link_id, f_rnd_octstring(15));
6067
6068 /* release the channel */
6069 f_rsl_chan_deact();
6070 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
6071 f_rslem_unregister(0, g_chan_nr);
6072}
6073testcase TC_encr_cmd_a51() runs on test_CT {
6074 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
6075 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_1, f_rnd_octstring(8)));
6076 f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd));
6077}
6078testcase TC_encr_cmd_a52() runs on test_CT {
6079 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
6080 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_2, f_rnd_octstring(8)));
6081 f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd));
6082}
6083testcase TC_encr_cmd_a53() runs on test_CT {
6084 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
6085 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_3, f_rnd_octstring(8)));
6086 f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd));
6087}
6088
6089private function f_assert_lapdm(octetstring enc, template LapdmFrame exp_match, charstring name := "") {
6090 var LapdmFrame lf;
6091 var octetstring reenc;
6092
6093 /* decode the LAPDm frame */
6094 if (ischosen(exp_match.ab)) {
6095 lf.ab := dec_LapdmFrameAB(enc);
6096 } else {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02006097 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "unsupported frame type");
Harald Weltee613f962018-04-18 22:38:16 +02006098 }
6099
6100 /* check if decoder result matches expectation */
6101 if (not match(lf, exp_match)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02006102 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str(name, ": decoded LAPDm doesn't match"));
Harald Weltee613f962018-04-18 22:38:16 +02006103 } else {
6104 log(name, ": matched");
6105 setverdict(pass);
6106 }
6107
6108 /* test if re-encoded frame equals original input */
6109 reenc := enc_LapdmFrame(lf);
6110 if (enc != reenc) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02006111 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str(name, ": re-encoded LAPDm frame doesn't match"));
Harald Weltee613f962018-04-18 22:38:16 +02006112 } else {
6113 setverdict(pass);
6114 }
6115}
6116
6117testcase TC_lapdm_selftest() runs on test_CT {
6118 f_assert_lapdm('030301'O, tr_LAPDm_UI(0, true, ''O), "ui_s0_empty");
6119 f_assert_lapdm('0F0301'O, tr_LAPDm_UI(3, true, ''O), "ui_s3_empty");
6120 f_assert_lapdm('013F01'O, tr_LAPDm_SABM(0, false, true, ''O), "sabm_s0_empty");
6121 f_assert_lapdm('013F1123420815'O, tr_LAPDm_SABM(0, false, true, '23420815'O), "sabm_s0_l3");
6122 f_assert_lapdm('03E101'O, tr_LAPDm_RR(0, true, false, 7), "rr_s0_7");
6123 f_assert_lapdm('03000d063505'O, tr_LAPDm_I(0, true, false, 0, 0, '063505'O), "I/0/0");
6124 f_assert_lapdm('03e00d063505'O, tr_LAPDm_I(0, true, false, 7, 0, '063505'O), "I/7/0");
6125}
6126
Stefan Sperling4880be42018-08-07 18:12:59 +02006127/***********************************************************************
6128 * DTX Related (see GSM 05.08, section 8.3)
6129 ***********************************************************************/
6130
6131/* XXX These functions must be kept in sync with g_AllChannels defined on test_CT. */
6132function f_g_chan_is_tchf() runs on ConnHdlr return boolean {
6133 return (g_chan_nr == valueof(ts_RslChanNr_Bm(1)) or
6134 g_chan_nr == valueof(ts_RslChanNr_Bm(2)) or
6135 g_chan_nr == valueof(ts_RslChanNr_Bm(3)) or
6136 g_chan_nr == valueof(ts_RslChanNr_Bm(4)));
6137}
6138function f_g_chan_is_tchh() runs on ConnHdlr return boolean {
6139 return (g_chan_nr == valueof(ts_RslChanNr_Lm(5,0)) or
6140 g_chan_nr == valueof(ts_RslChanNr_Lm(5,1)));
6141}
6142function f_g_chan_is_sdcch4() runs on ConnHdlr return boolean {
6143 return (g_chan_nr == valueof(ts_RslChanNr_SDCCH4(0,0)) or
6144 g_chan_nr == valueof(ts_RslChanNr_SDCCH4(0,1)) or
6145 g_chan_nr == valueof(ts_RslChanNr_SDCCH4(0,2)) or
6146 g_chan_nr == valueof(ts_RslChanNr_SDCCH4(0,3)));
6147}
6148function f_g_chan_is_sdcch8() runs on ConnHdlr return boolean {
6149 return (g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,0)) or
6150 g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,1)) or
6151 g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,2)) or
6152 g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,3)) or
6153 g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,4)) or
6154 g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,5)) or
6155 g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,6)) or
6156 g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,7)));
6157}
6158
6159function f_test_l2_fill_frames(boolean dtxd) runs on ConnHdlr {
6160 var L1ctlDlMessage dl;
6161 var octetstring l2_fill_frame := '0303012B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B'O;
6162 var octetstring l2_fill_frame_sacch := substr(l2_fill_frame, 0, lengthof(l2_fill_frame) - 2);
6163 var GsmFrameNumber first_fn;
6164 var boolean is_first_frame := true;
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02006165 var integer nfill_frames_sacch := 0;
6166 var integer nfill_frames_nonsacch := 0;
6167 var integer expected_fill_frames := 10000; /* initial value causes test failure if not overridden */
Stefan Sperling4880be42018-08-07 18:12:59 +02006168 /* Frames numbers (mod 104) for which a fill frame is expected on TCHF if DTX is enabled. */
6169 var Integers required_tdma_frames_dtx_tchf := { 52, 53, 54, 55, 56, 57, 58, 59 };
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02006170 const integer frame_dtx_tchf_mod := 104;
6171 /* Frame numbers (mod 104) for which a fill frame is expected at the L1SAP level,
6172 * which operates in terms of blocks rather than frames. */
6173 var Integers required_tdma_blocks_dtx_tchf := { 52, 56 };
6174 const integer block_dtx_tchf_mod := 26;
Stefan Sperling4880be42018-08-07 18:12:59 +02006175 timer T := 5.0;
6176
6177 f_l1_tune(L1CTL);
6178 RSL.clear;
6179 L1CTL.clear;
6180
6181 /* activate TCHF signalling channel */
6182 f_est_dchan(false);
6183
6184 T.start;
6185 alt {
6186 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, ?)) -> value dl {
6187 var GsmFrameNumber fn := dl.dl_info.frame_nr;
6188 var octetstring l2 := dl.payload.data_ind.payload;
6189
6190 if (is_first_frame) {
6191 is_first_frame := false;
6192 first_fn := dl.dl_info.frame_nr;
6193 }
6194
6195 if (dl.dl_info.link_id.c == SACCH) {
6196 l2 := substr(l2, 2, lengthof(l2) - 2); /* remove L1 header */
6197 if (not match(l2_fill_frame_sacch, l2)) {
6198 repeat;
6199 }
6200 } else if (not match(l2_fill_frame, l2)) {
6201 repeat;
6202 }
6203
6204 if (dtxd) {
6205 if (not f_g_chan_is_tchf()) {
6206 T.stop;
6207 f_rsl_chan_deact();
6208 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02006209 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 +02006210 }
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02006211 if (fn > first_fn + frame_dtx_tchf_mod) {
Stefan Sperling4880be42018-08-07 18:12:59 +02006212 T.stop;
6213 f_rsl_chan_deact();
6214 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02006215
6216 /* With DTX enabled we can expect at least 3 fill frames for every 104 frames.
6217 * 2 SACCH, 1 TCH/F */
6218 expected_fill_frames := 3;
6219
6220 if (nfill_frames_sacch + nfill_frames_nonsacch < expected_fill_frames) {
6221 log("received only ", nfill_frames_sacch, "+", nfill_frames_nonsacch,
6222 " (SACCH+other) out of ", expected_fill_frames, " expected fill frames");
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02006223 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Not enough fill frames received");
Stefan Sperling4880be42018-08-07 18:12:59 +02006224 } else {
6225 setverdict(pass);
6226 }
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02006227 } else {
6228 if (dl.dl_info.link_id.c == SACCH) {
6229 nfill_frames_sacch := nfill_frames_sacch + 1;
Stefan Sperling4880be42018-08-07 18:12:59 +02006230 repeat;
6231 }
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02006232 /* On DTX TCH/F channels, fill frames occur only for specific frame numbers mod 104.
6233 * Furthermore, the L1SAP layer gives us frame numbers for the start of a block so
6234 * we should only see the subset of frames numbers which correspond to a block boundary.
6235 * TCH/F blocks are defined to start at 0,4,8,13,17,21 (modulo 26) */
6236 for (var integer i := 0; i < lengthof(required_tdma_blocks_dtx_tchf); i := i + 1) {
6237 if (fn mod frame_dtx_tchf_mod == required_tdma_blocks_dtx_tchf[i]) {
6238 nfill_frames_nonsacch := nfill_frames_nonsacch + 1;
6239 repeat;
6240 }
6241 }
6242 log("Received DTX TCH fill frame with bad frame number: ", fn,
6243 " (mod ", frame_dtx_tchf_mod, ": ", fn mod frame_dtx_tchf_mod, ")",
6244 " (mod ", block_dtx_tchf_mod, ": ", fn mod block_dtx_tchf_mod, ")");
6245 f_rsl_chan_deact();
6246 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02006247 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected L2 fill frame received on Um");
Stefan Sperling4880be42018-08-07 18:12:59 +02006248 }
Stefan Sperling4880be42018-08-07 18:12:59 +02006249 } else {
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02006250 if (dl.dl_info.link_id.c == SACCH) {
6251 nfill_frames_sacch := nfill_frames_sacch + 1;
6252 } else {
6253 nfill_frames_nonsacch := nfill_frames_nonsacch + 1;
6254 }
6255 if (fn > first_fn + frame_dtx_tchf_mod) {
Stefan Sperling4880be42018-08-07 18:12:59 +02006256 T.stop;
6257 if (f_g_chan_is_tchf()) {
6258 /* Without DTX we can expect 25 fill frames for every 104 frames.
6259 * (24 FACCH + 1 SACCH filling) */
6260 expected_fill_frames := 25;
6261 } else if (f_g_chan_is_tchh()) {
6262 /* We can expect 2 fill frames for every 104 frames. */
6263 expected_fill_frames := 2;
6264 } else if (f_g_chan_is_sdcch4() or f_g_chan_is_sdcch8()) {
6265 /* We can expect 5 fill frames for every 104 frames. */
6266 expected_fill_frames := 5;
6267 } else {
6268 f_rsl_chan_deact();
6269 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02006270 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unknown channel type");
Stefan Sperling4880be42018-08-07 18:12:59 +02006271 }
6272
6273 f_rsl_chan_deact();
6274 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02006275
6276 if (nfill_frames_sacch + nfill_frames_nonsacch >= expected_fill_frames) {
Stefan Sperling4880be42018-08-07 18:12:59 +02006277 setverdict(pass);
6278 } else {
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02006279 log("received only ", nfill_frames_sacch, "+", nfill_frames_nonsacch,
6280 " (SACCH+other) out of ", expected_fill_frames, " expected fill frames");
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02006281 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Not enough fill frames received");
Stefan Sperling4880be42018-08-07 18:12:59 +02006282 }
6283 } else {
6284 repeat;
6285 }
6286 }
6287 }
6288 [] L1CTL.receive { repeat; }
6289 [] T.timeout {
6290 f_rsl_chan_deact();
6291 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02006292 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for L2 fill frames on Um");
Stefan Sperling4880be42018-08-07 18:12:59 +02006293 }
6294 }
6295}
6296
6297function f_TC_tch_sign_l2_fill_frame(charstring id) runs on ConnHdlr {
6298 f_test_l2_fill_frames(false);
6299}
6300
6301function f_TC_tch_sign_l2_fill_frame_dtxd(charstring id) runs on ConnHdlr {
6302 f_test_l2_fill_frames(true);
6303}
6304
6305function f_tch_sign_l2_fill_frame(boolean dtxd) runs on test_CT {
6306 var ConnHdlr vc_conn;
6307 var ConnHdlrPars pars;
6308 pars.t_guard := 60.0;
Harald Welte10474062019-05-30 16:48:17 +02006309 f_init();
Stefan Sperling4880be42018-08-07 18:12:59 +02006310 for (var integer i := 0; i < sizeof(g_AllChannels); i := i + 1) {
6311 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN(dtxd)));
6312 if (dtxd) {
6313 if (i >= 4) { /* DTX is only allowed on TCH/F */
6314 break;
6315 }
6316 vc_conn := f_start_handler(refers(f_TC_tch_sign_l2_fill_frame_dtxd), pars);
6317 } else {
6318 vc_conn := f_start_handler(refers(f_TC_tch_sign_l2_fill_frame), pars);
6319 }
6320 vc_conn.done;
6321 }
6322}
6323
6324/* Verify that L2 fill frames are sent on TCH in signaling mode if
6325 * there is nothing to transmit while DTX is disabled on downlink. */
6326testcase TC_tch_sign_l2_fill_frame() runs on test_CT {
6327 f_tch_sign_l2_fill_frame(false);
6328}
6329
6330/* Verify that particular L2 fill frames are sent on TCH in signaling mode if
6331 * there is nothing to transmit while DTX is enabled on downlink. */
6332testcase TC_tch_sign_l2_fill_frame_dtxd() runs on test_CT {
6333 f_tch_sign_l2_fill_frame(true);
6334}
Harald Welte0472ab42018-03-12 15:02:26 +01006335
Stefan Sperling0ec1c262018-10-15 15:12:52 +02006336testcase TC_chopped_ipa_ping() runs on test_CT {
6337 IPA_Testing.f_run_TC_chopped_ipa_ping(mp_rsl_ip, mp_rsl_port, LISTEN_FOR_CLIENT);
6338}
6339
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02006340testcase TC_chopped_ipa_payload() runs on test_CT {
6341 IPA_Testing.f_run_TC_chopped_ipa_payload(mp_rsl_ip, mp_rsl_port, LISTEN_FOR_CLIENT);
6342}
6343
Harald Welte0472ab42018-03-12 15:02:26 +01006344/* test generation of RLL ERR IND based on Um errors (TS 48.058 3.9) */
6345/* protocol error as per 44.006 */
6346/* link layer failure (repetition of I-frame N200 times without ACK */
6347/* repetition of SABM or DISC N200 times without ACK */
6348/* receptiom of SABM in multi-frame established state */
6349
6350
Harald Welte68e495b2018-02-25 00:05:57 +01006351/* TODO Areas:
6352
6353* channel activation
6354** with BS_Power / MS_Power, bypassing power control loop
6355** on primary vs. secondary TRX
Harald Welte68e495b2018-02-25 00:05:57 +01006356** with timing advance from initial activation on
6357* mode modify
6358** encryption
6359** multirate
6360* check DEACTIVATE SACCH
Harald Welte68e495b2018-02-25 00:05:57 +01006361** unsupported algorithm
6362* handover detection
Harald Welte68e495b2018-02-25 00:05:57 +01006363* BS Power Control
6364* Physical Context
Harald Welte68e495b2018-02-25 00:05:57 +01006365* RF resource ind
Harald Welte68e495b2018-02-25 00:05:57 +01006366* error handling
Harald Welte68e495b2018-02-25 00:05:57 +01006367** IE duplicated?
Harald Welte883340c2018-02-28 18:59:29 +01006368* PCU interface
Harald Welte883340c2018-02-28 18:59:29 +01006369** DATA_IND from BTS->PCU
6370** verification of PCU-originated DATA_REQ arrival on Um/MS side
Harald Welte68e495b2018-02-25 00:05:57 +01006371
6372*/
Harald Welte70767382018-02-21 12:16:40 +01006373
6374control {
6375 execute( TC_chan_act_stress() );
6376 execute( TC_chan_act_react() );
6377 execute( TC_chan_deact_not_active() );
6378 execute( TC_chan_act_wrong_nr() );
Harald Welte629cc6b2018-03-11 17:19:05 +01006379 execute( TC_deact_sacch() );
Harald Welteea17b912018-03-11 22:29:31 +01006380 execute( TC_sacch_filling() );
6381 execute( TC_sacch_info_mod() );
Harald Welte075d84c2018-03-12 13:07:24 +01006382 execute( TC_sacch_multi() );
Harald Welte55700662018-03-12 13:15:43 +01006383 execute( TC_sacch_multi_chg() );
Harald Weltec8d363c2019-05-19 20:36:48 +02006384 execute( TC_sacch_chan_act() );
Harald Welte8b01c792019-05-19 22:51:25 +02006385 execute( TC_sacch_chan_act_ho_async() );
6386 execute( TC_sacch_chan_act_ho_sync() );
Harald Welte8c24c2b2018-02-26 08:31:31 +01006387 execute( TC_rach_content() );
6388 execute( TC_rach_count() );
Harald Welte54a2a2d2018-02-26 09:14:05 +01006389 execute( TC_rach_max_ta() );
Vadim Yanitskiy7c2c10c2019-05-31 20:42:01 +07006390 execute( TC_ho_rach() );
Harald Welte3453ab42019-05-24 21:19:58 +02006391 execute( TC_rach_load_idle_thresh0() );
6392 execute( TC_rach_load_idle_below_thresh() );
6393 execute( TC_rach_load_count() );
Harald Welte70767382018-02-21 12:16:40 +01006394 execute( TC_meas_res_sign_tchf() );
6395 execute( TC_meas_res_sign_tchh() );
6396 execute( TC_meas_res_sign_sdcch4() );
6397 execute( TC_meas_res_sign_sdcch8() );
Harald Welte685d5982018-02-27 20:42:05 +01006398 execute( TC_meas_res_sign_tchh_toa256() );
Eric Wildae8f2622019-06-18 17:05:11 +02006399 execute( TC_rsl_bs_pwr_static_ass() );
6400 execute( TC_rsl_bs_pwr_static_power_control() );
Philipp Maier4d1e9c92018-12-20 11:11:56 +01006401 execute( TC_rsl_ms_pwr_ctrl() );
Eric Wild280ccb82019-06-17 11:11:52 +02006402 execute( TC_rsl_ms_pwr_dyn_active() );
Eric Wild095024b2019-06-17 15:08:57 +02006403 execute( TC_rsl_ms_pwr_dyn_active2() );
Eric Wild61edb7e2019-06-03 12:38:31 +02006404 execute( TC_rsl_ms_pwr_dyn_up() );
6405 execute( TC_rsl_ms_pwr_dyn_down() );
6406 execute( TC_rsl_ms_pwr_dyn_ass_updown() );
6407 execute( TC_rsl_ms_pwr_dyn_max() );
Eric Wilde57e1a62019-05-28 13:30:55 +02006408 execute( TC_rsl_chan_initial_ms_pwr() );
Eric Wild6833cc92019-05-23 19:34:44 +02006409 execute( TC_rsl_chan_initial_ta() );
Eric Wildf1827a72019-05-28 17:37:35 +02006410 execute( TC_rsl_modify_encr() );
Harald Welte70767382018-02-21 12:16:40 +01006411 execute( TC_conn_fail_crit() );
Harald Welte68e495b2018-02-25 00:05:57 +01006412 execute( TC_paging_imsi_80percent() );
6413 execute( TC_paging_tmsi_80percent() );
6414 execute( TC_paging_imsi_200percent() );
6415 execute( TC_paging_tmsi_200percent() );
Harald Welte01d982c2018-02-25 01:31:40 +01006416 execute( TC_rsl_protocol_error() );
6417 execute( TC_rsl_mand_ie_error() );
6418 execute( TC_rsl_ie_content_error() );
Harald Welte48494ca2018-02-25 16:59:50 +01006419 execute( TC_si_sched_default() );
Harald Welte0cae4552018-03-09 22:20:26 +01006420 execute( TC_si_sched_1() );
Harald Welte48494ca2018-02-25 16:59:50 +01006421 execute( TC_si_sched_2bis() );
6422 execute( TC_si_sched_2ter() );
6423 execute( TC_si_sched_2ter_2bis() );
6424 execute( TC_si_sched_2quater() );
6425 execute( TC_si_sched_13() );
6426 execute( TC_si_sched_13_2bis_2ter_2quater() );
Harald Weltea871a382018-02-25 02:03:14 +01006427 execute( TC_ipa_dlcx_not_active() );
Harald Weltea3f1df92018-02-25 12:49:55 +01006428 execute( TC_ipa_crcx_twice_not_active() );
6429 execute( TC_ipa_crcx_mdcx_dlcx_not_active() );
Harald Welte3ae11da2018-02-25 13:36:06 +01006430 execute( TC_ipa_crcx_mdcx_mdcx_dlcx_not_active() );
Harald Welte9912eb52018-02-25 13:30:15 +01006431 execute( TC_ipa_crcx_sdcch_not_active() );
Harald Welte883340c2018-02-28 18:59:29 +01006432
Pau Espin Pedrola14a8af2018-11-20 13:12:22 +01006433 if (mp_pcu_socket != "") {
6434 execute( TC_pcu_act_req() );
6435 execute( TC_pcu_act_req_wrong_ts() );
6436 execute( TC_pcu_act_req_wrong_bts() );
6437 execute( TC_pcu_act_req_wrong_trx() );
6438 execute( TC_pcu_deact_req() );
6439 execute( TC_pcu_deact_req_wrong_ts() );
6440 execute( TC_pcu_ver_si13() );
Harald Weltead033dc2019-05-25 17:28:16 +02006441 if (mp_l1_supports_gprs) {
6442 execute( TC_pcu_data_req_pdtch() );
6443 execute( TC_pcu_data_req_ptcch() );
Harald Welte7162a612019-05-26 12:56:09 +02006444 execute( TC_pcu_data_req_wrong_bts() );
6445 execute( TC_pcu_data_req_wrong_trx() );
6446 execute( TC_pcu_data_req_wrong_ts() );
6447 execute( TC_pcu_data_req_ts_inactive() );
Harald Weltead033dc2019-05-25 17:28:16 +02006448 }
Vadim Yanitskiy970b1532019-10-24 15:22:19 +07006449 execute( TC_pcu_ptcch() );
Pau Espin Pedrola14a8af2018-11-20 13:12:22 +01006450 execute( TC_pcu_data_req_agch() );
Harald Welte928622b2019-05-26 13:22:59 +02006451 execute( TC_pcu_data_req_pch() );
Pau Espin Pedrola14a8af2018-11-20 13:12:22 +01006452 execute( TC_pcu_data_req_imm_ass_pch() );
6453 execute( TC_pcu_rach_content() );
Vadim Yanitskiy51cbc102019-04-22 06:37:30 +07006454 execute( TC_pcu_ext_rach_content() );
Vadim Yanitskiya2c68e82019-07-03 13:07:20 +07006455 execute( TC_pcu_data_ind_lqual_cb() );
Pau Espin Pedrola14a8af2018-11-20 13:12:22 +01006456 execute( TC_pcu_paging_from_rsl() );
Harald Welted66c9b82019-05-25 09:03:15 +02006457 execute( TC_pcu_time_ind() );
Harald Welte4832c862019-05-25 14:57:18 +02006458 execute( TC_pcu_rts_req() );
Harald Welte07bd2d22019-05-25 11:03:30 +02006459 execute( TC_pcu_oml_alert() );
Harald Welteeaa9a862019-05-26 23:01:08 +02006460 execute( TC_pcu_rr_suspend() );
Harald Weltea2e0e942019-05-27 18:12:53 +02006461 execute( TC_pcu_socket_connect_multi() );
Harald Weltec8effb72019-05-27 18:23:04 +02006462 execute( TC_pcu_socket_reconnect() );
Harald Weltebe030482019-05-27 22:29:35 +02006463 execute( TC_pcu_socket_noconnect_nosi3gprs() );
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07006464 execute( TC_pcu_socket_noconnect_nosi4gprs() );
Harald Weltebe030482019-05-27 22:29:35 +02006465 execute( TC_pcu_socket_connect_si3gprs() );
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07006466 execute( TC_pcu_socket_connect_si4gprs() );
Harald Weltebe030482019-05-27 22:29:35 +02006467 execute( TC_pcu_socket_disconnect_nosi3gprs() );
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07006468 execute( TC_pcu_socket_disconnect_nosi4gprs() );
Oliver Smithf5239c72019-08-28 10:01:25 +02006469 execute( TC_pcu_socket_verify_info_ind() );
Philipp Maier15cd6872020-01-08 13:41:41 +01006470 execute( TC_dyn_osmo_pdch_act_deact() );
6471 execute( TC_dyn_osmo_pdch_double_act() );
6472 execute( TC_dyn_ipa_pdch_act_deact() );
6473 execute( TC_dyn_ipa_pdch_act_tchf_act_nack() );
6474
Pau Espin Pedrola14a8af2018-11-20 13:12:22 +01006475 } else {
6476 log("PCU socket path not available, skipping PCU tests");
6477 }
Harald Welte3d04ae62018-04-04 20:29:05 +02006478
Harald Welte3d04ae62018-04-04 20:29:05 +02006479 execute( TC_dyn_osmo_pdch_unsol_deact() );
Harald Welte3d04ae62018-04-04 20:29:05 +02006480 execute( TC_dyn_osmo_pdch_tchf_act() );
6481 execute( TC_dyn_osmo_pdch_tchh_act() );
Harald Welte9bbbfb52018-04-05 09:33:19 +02006482 execute( TC_dyn_ipa_pdch_tchf_act() );
6483 execute( TC_dyn_ipa_pdch_tchf_act_pdch_act_nack() );
Harald Welte0472ab42018-03-12 15:02:26 +01006484
6485 execute( TC_rll_est_ind() );
6486 execute( TC_rll_est_req_DCCH_3() );
6487 execute( TC_rll_est_req_ACCH_3() );
6488 execute( TC_rll_rel_ind_DCCH_0() );
6489 execute( TC_rll_rel_ind_DCCH_3() );
6490 execute( TC_rll_rel_ind_ACCH_0() );
6491 execute( TC_rll_rel_ind_ACCH_3() );
6492 execute( TC_rll_rel_req() );
6493 execute( TC_rll_unit_data_req_DCCH() );
6494 execute( TC_rll_unit_data_req_ACCH() );
6495 execute( TC_rll_unit_data_ind_DCCH() );
6496 execute( TC_rll_unit_data_ind_ACCH() );
Harald Weltee613f962018-04-18 22:38:16 +02006497
6498 execute( TC_chan_act_a51() );
6499 execute( TC_chan_act_a52() );
6500 execute( TC_chan_act_a53() );
6501 execute( TC_encr_cmd_a51() );
6502 execute( TC_encr_cmd_a52() );
6503 execute( TC_encr_cmd_a53() );
6504
Harald Welteee25aae2019-05-19 14:32:37 +02006505 execute( TC_err_rep_wrong_mdisc() );
6506 execute( TC_err_rep_wrong_msg_type() );
6507 execute( TC_err_rep_wrong_sequence() );
6508
Harald Weltee613f962018-04-18 22:38:16 +02006509 execute( TC_lapdm_selftest() );
Stefan Sperling4880be42018-08-07 18:12:59 +02006510
6511 execute( TC_tch_sign_l2_fill_frame() );
6512 execute( TC_tch_sign_l2_fill_frame_dtxd() );
Stefan Sperling0ec1c262018-10-15 15:12:52 +02006513
6514 execute( TC_chopped_ipa_ping() );
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02006515 execute( TC_chopped_ipa_payload() );
Harald Welte70767382018-02-21 12:16:40 +01006516}
6517
6518
6519}