blob: 1b6c9b21aef902bdc8e65ff99331aef6d7867e44 [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 Yanitskiy28cabc42020-05-27 19:44:44 +070087 integer mp_trx1_arfcn := 873;
88 integer mp_trx2_arfcn := 875;
89 integer mp_trx3_arfcn := 877;
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +070090 charstring mp_bts_trxc_ip := "127.0.0.1";
91 integer mp_bts_trxc_port := 5701;
Harald Welte883340c2018-02-28 18:59:29 +010092 charstring mp_pcu_socket := PCU_SOCK_DEFAULT;
Neels Hofmeyr6a84b232018-04-03 19:12:36 +020093 charstring mp_ctrl_ip := "127.0.0.1";
94 integer mp_ctrl_port := 4238;
Harald Welte07bd2d22019-05-25 11:03:30 +020095 charstring mp_bsc_ctrl_ip := "127.0.0.1";
96 integer mp_bsc_ctrl_port := 4249;
Pau Espin Pedrol121724c2018-09-28 15:58:12 +020097 integer mp_tolerance_rxqual := 1;
98 integer mp_tolerance_rxlev := 3;
99 integer mp_tolerance_timing_offset_256syms := 0;
Pau Espin Pedrol752ffd52018-06-07 13:55:45 +0200100 integer mp_rxlev_exp := 57;
Pau Espin Pedrole9571aa2018-10-22 17:13:07 +0200101 integer mp_ul_rxlev_exp := 10;
Pau Espin Pedroled359cb2018-09-28 16:08:24 +0200102 integer mp_ms_power_level_exp := 7;
Pau Espin Pedrola2e079c2020-06-03 17:31:04 +0200103 integer mp_bts_tx_nom_pwr_exp := 50; /* Expected Tx Nominal Output Power of the BTS, in dBm */
104 integer mp_bts_tx_pwr_att_exp := 20; /* Expected Tx Power attenuation wrt to Tx Nominal Output Power, in dB */
Pau Espin Pedrol121724c2018-09-28 15:58:12 +0200105 integer mp_ms_actual_ta_exp := 0;
106 integer mp_timing_offset_256syms_exp := 512;
Pau Espin Pedrol315e4712018-11-01 16:27:07 +0100107 /* Time to wait for RSL conn from BTS during startup of test */
Philipp Maier12567e42019-04-17 14:10:05 +0200108 float mp_ipa_up_timeout := 15.0;
Philipp Maiere63229e2019-04-26 12:21:37 +0200109 float mp_ipa_up_delay := 0.0;
Harald Weltead033dc2019-05-25 17:28:16 +0200110 /* false for now, as only virtphy supports it, not calypso-l1 nor trxcon */
111 boolean mp_l1_supports_gprs := false;
Vadim Yanitskiy89db3e02020-06-22 17:49:39 +0700112 /* how many transceivers do we expect to connect */
113 integer mp_transceiver_num := 1;
Harald Welte70767382018-02-21 12:16:40 +0100114}
115
Harald Welte629cc6b2018-03-11 17:19:05 +0100116type record of RslChannelNr ChannelNrs;
117
Harald Welte70767382018-02-21 12:16:40 +0100118type component test_CT extends CTRL_Adapter_CT {
Harald Welte68e495b2018-02-25 00:05:57 +0100119 /* IPA Emulation component underneath RSL */
Harald Welte70767382018-02-21 12:16:40 +0100120 var IPA_Emulation_CT vc_IPA;
Harald Welte68e495b2018-02-25 00:05:57 +0100121 /* RSL Emulation component (for ConnHdlr tests) */
Harald Welte70767382018-02-21 12:16:40 +0100122 var RSL_Emulation_CT vc_RSL;
Harald Welte68e495b2018-02-25 00:05:57 +0100123 /* Direct RSL_CCHAN_PT */
Harald Welte70767382018-02-21 12:16:40 +0100124 port RSL_CCHAN_PT RSL_CCHAN;
Harald Welte68e495b2018-02-25 00:05:57 +0100125
126 /* L1CTL port (for classic tests) */
127 port L1CTL_PT L1CTL;
Harald Welte48494ca2018-02-25 16:59:50 +0100128
Vadim Yanitskiyf4e997c2019-06-04 21:40:33 +0700129 /* Optional TRXC connection to FakeTRX (BTS side) */
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +0700130 port TRXC_CODEC_PT BTS_TRXC;
131 var integer g_bts_trxc_conn_id;
Harald Welte54a2a2d2018-02-26 09:14:05 +0100132
Harald Weltef50e3ae2018-09-10 10:27:56 +0200133 /* VTY connections to both BTS and BSC */
Harald Welte8da48242018-02-27 20:41:32 +0100134 port TELNETasp_PT BTSVTY;
Harald Weltef50e3ae2018-09-10 10:27:56 +0200135 port TELNETasp_PT BSCVTY;
Harald Welte8da48242018-02-27 20:41:32 +0100136
Harald Welte883340c2018-02-28 18:59:29 +0100137 /* PCU Interface of BTS */
138 port PCUIF_CODEC_PT PCU;
139 var integer g_pcu_conn_id;
140 /* Last PCU INFO IND we received */
141 var PCUIF_Message g_pcu_last_info;
142
Harald Welte48494ca2018-02-25 16:59:50 +0100143 /* SI configuration */
144 var SystemInformationConfig si_cfg := {
145 bcch_extended := false,
146 si1_present := false,
147 si2bis_present := false,
148 si2ter_present := false,
149 si2quater_present := false,
150 si7_present := false,
151 si8_present := false,
152 si9_present := false,
153 si13_present := false,
154 si13alt_present := false,
155 si15_present := false,
156 si16_present := false,
157 si17_present := false,
158 si2n_present := false,
159 si21_present := false,
160 si22_present := false
161 };
Harald Welte629cc6b2018-03-11 17:19:05 +0100162
163 /* all logical channels available on the BTS */
164 var ChannelNrs g_AllChannels;
Harald Welte0472ab42018-03-12 15:02:26 +0100165 var ChannelNrs g_AllChanTypes;
Harald Welte70767382018-02-21 12:16:40 +0100166}
167
168/* an individual call / channel */
Harald Welte2f2b2b72019-05-31 22:24:57 +0200169type component ConnHdlr extends RSL_DchanHdlr, lapdm_test_CT {
Harald Welte70767382018-02-21 12:16:40 +0100170 port L1CTL_PT L1CTL;
171
Vadim Yanitskiyf4e997c2019-06-04 21:40:33 +0700172 /* Optional TRXC connection to FakeTRX (BTS side) */
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +0700173 port TRXC_CODEC_PT BTS_TRXC;
174 var integer g_bts_trxc_conn_id;
Harald Welte70767382018-02-21 12:16:40 +0100175
Pau Espin Pedrolb6985f92020-06-23 14:01:02 +0200176 /* port to be initialized optionally to access BSC VTY */
177 port TELNETasp_PT BSCVTY;
178
Harald Welte70767382018-02-21 12:16:40 +0100179 timer g_Tguard;
180 timer g_Tmeas_exp := 2.0; /* >= 103 SACCH multiframe ~ 500ms */
181
182 var ConnHdlrPars g_pars;
183 var uint8_t g_next_meas_res_nr := 0;
Harald Weltefa45e9e2018-03-10 18:59:03 +0100184 var boolean g_first_meas_res := true;
Harald Weltef26de0b2018-04-04 20:28:05 +0200185
186 /* PCU Interface of BTS */
187 port PCUIF_CODEC_PT PCU;
Harald Welte70767382018-02-21 12:16:40 +0100188}
189
Vadim Yanitskiyfc631d12020-06-02 23:48:49 +0700190function f_init_rsl(charstring id) runs on test_CT {
Vadim Yanitskiy89db3e02020-06-22 17:49:39 +0700191 var bitstring trx_mask := '00000000'B;
192 var integer trx_count := 0;
193 var RSLEm_Event ev;
194 timer T;
195
Harald Welte70767382018-02-21 12:16:40 +0100196 vc_IPA := IPA_Emulation_CT.create(id & "-RSL-IPA");
197 vc_RSL := RSL_Emulation_CT.create(id & "-RSL");
198
199 map(vc_IPA:IPA_PORT, system:IPA_CODEC_PT);
200 connect(vc_IPA:IPA_RSL_PORT, vc_RSL:IPA_PT);
201 connect(self:RSL_CCHAN, vc_RSL:CCHAN_PT);
202
203 vc_IPA.start(IPA_Emulation.main_server(mp_rsl_ip, mp_rsl_port));
204 vc_RSL.start(RSL_Emulation.main(false));
Vadim Yanitskiyc9c9e292020-05-18 23:31:40 +0700205
Vadim Yanitskiy89db3e02020-06-22 17:49:39 +0700206 /* We expect (N = mp_transceiver_num) IPA/RSL transceiver connections here.
Vadim Yanitskiyfc631d12020-06-02 23:48:49 +0700207 * See https://gerrit.osmocom.org/q/Ib5ad31388ae25399ad09739aac3fdcb0b3a1f78b. */
Vadim Yanitskiy89db3e02020-06-22 17:49:39 +0700208 T.start(mp_ipa_up_timeout);
209 alt {
Vadim Yanitskiyfc631d12020-06-02 23:48:49 +0700210 /* These events are sent by the RSL_Emulation_CT */
Vadim Yanitskiy89db3e02020-06-22 17:49:39 +0700211 [] RSL_CCHAN.receive(tr_RSLEm_EV(RSLEM_EV_TRX_UP, ?)) -> value ev {
212 /* Make sure that all transceivers use unique stream ID */
213 if (trx_mask[enum2int(ev.sid)] == '1'B) {
214 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
215 log2str("Duplicate RSL stream ID (", ev.sid, ")"));
216 }
Vadim Yanitskiyfc631d12020-06-02 23:48:49 +0700217
Vadim Yanitskiy89db3e02020-06-22 17:49:39 +0700218 /* This message (RF RESource INDication) is sent by the IUT itself */
219 RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RF_RES_IND, ev.sid));
220 trx_mask[enum2int(ev.sid)] := '1'B;
221 trx_count := trx_count + 1;
222
223 log(trx_count, "/", mp_transceiver_num, " transceiver(s) connected");
224 if (trx_count < mp_transceiver_num) { repeat; }
225 }
226 /* osmo-bts may send us CCCH LOAD INDication or whatever else */
227 [] RSL_CCHAN.receive(ASP_RSL_Unitdata:?) { repeat; }
228 [] T.timeout {
229 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
230 "Timeout waiting for RSL bring up");
231 }
232 }
Harald Welte70767382018-02-21 12:16:40 +0100233}
234
235type record ConnHdlrPars {
236 RslChannelNr chan_nr,
237 RSL_IE_ChannelMode chan_mode,
238 float t_guard,
Harald Welte0472ab42018-03-12 15:02:26 +0100239 ConnL1Pars l1_pars,
Harald Weltee613f962018-04-18 22:38:16 +0200240 TestSpecUnion spec optional,
Eric Wild61edb7e2019-06-03 12:38:31 +0200241 RSL_IE_EncryptionInfo encr optional,
Vadim Yanitskiy28cabc42020-05-27 19:44:44 +0700242 BtsBand bts0_band optional,
243
244 /* Frequency hopping parameters (disabled if absent) */
245 MaioHsn maio_hsn optional,
246 /* MA bitmap to be indicated in RR Immediate Assignment */
247 MobileAllocation ma_map,
248 /* The actual Mobile Allocation (ARFCN list) to be used */
249 L1ctlMA ma
Harald Welte0472ab42018-03-12 15:02:26 +0100250}
251
252/* Test-specific parameters */
253type union TestSpecUnion {
254 RllTestCase rll
Harald Welte70767382018-02-21 12:16:40 +0100255}
256
Harald Welte82ccef72018-02-25 16:17:33 +0100257template (value) RachControlParameters ts_RachCtrl_default := {
Harald Welte0fd1fb02018-03-10 17:19:50 +0100258 max_retrans := RACH_MAX_RETRANS_7,
259 tx_integer := '1001'B, /* 12 slots */
Harald Welte82ccef72018-02-25 16:17:33 +0100260 cell_barr_access := false,
261 re_not_allowed := true,
Harald Welteb9585f82018-03-10 17:18:47 +0100262 acc := '0000010000000000'B
Harald Welte82ccef72018-02-25 16:17:33 +0100263};
264
Harald Weltef10153f2018-02-25 16:34:05 +0100265template (value) CellSelectionParameters ts_CellSelPar_default := {
Harald Welte0fd1fb02018-03-10 17:19:50 +0100266 cell_resel_hyst_2dB := 2,
Pau Espin Pedroled359cb2018-09-28 16:08:24 +0200267 ms_txpwr_max_cch := mp_ms_power_level_exp,
Harald Weltef10153f2018-02-25 16:34:05 +0100268 acs := '0'B,
269 neci := true,
270 rxlev_access_min := 0
271}
272
273template (value) LocationAreaIdentification ts_LAI_default := {
274 mcc_mnc := '262F42'H,
275 lac := 42
276}
277
Vadim Yanitskiy12cf3d92020-05-05 00:19:50 +0700278private template (value) GPRSIndicator ts_GPRSIndicator_def := {
279 ra_colour := 0,
280 si13_pos := '0'B
281}
282
283private template (value) SI3RestOctets ts_SI3RestOctets_def
284modifies ts_SI3RestOctets := {
285 gprs_ind := {
286 presence := CSN1_H,
287 ind := ts_GPRSIndicator_def
288 }
289}
290
291private template (value) SI4RestOctets ts_SI4RestOctets_def
292modifies ts_SI4RestOctets := {
293 gprs_ind := {
Vadim Yanitskiyab5363f2020-05-05 00:30:22 +0700294 presence := CSN1_H,
295 ind := ts_GPRSIndicator_def
Vadim Yanitskiy12cf3d92020-05-05 00:19:50 +0700296 }
297}
298
Harald Welte7484fc42018-02-24 14:09:45 +0100299/* Default SYSTEM INFORMATION 3 */
Harald Weltef8df4cb2018-03-10 15:15:08 +0100300template (value) SystemInformation ts_SI3_default := {
301 header := ts_RrHeader(SYSTEM_INFORMATION_TYPE_3, 18),
Harald Welte7484fc42018-02-24 14:09:45 +0100302 payload := {
303 si3 := {
304 cell_id := 23,
Harald Weltef10153f2018-02-25 16:34:05 +0100305 lai := ts_LAI_default,
Harald Welte7484fc42018-02-24 14:09:45 +0100306 ctrl_chan_desc := {
307 msc_r99 := true,
308 att := true,
309 bs_ag_blks_res := 1,
310 ccch_conf := CCHAN_DESC_1CCCH_COMBINED,
Harald Welte82ccef72018-02-25 16:17:33 +0100311 si22ind := false,
Harald Welte7484fc42018-02-24 14:09:45 +0100312 cbq3 := CBQ3_IU_MODE_NOT_SUPPORTED,
313 spare := '00'B,
314 bs_pa_mfrms := 0, /* 2 multiframes */
315 t3212 := 1 /* 6 minutes */
316 },
Harald Welte82ccef72018-02-25 16:17:33 +0100317 cell_options := {
Harald Welte7484fc42018-02-24 14:09:45 +0100318 dn_ind := false,
319 pwrc := false,
320 dtx := MS_MAY_USE_UL_DTX,
Harald Welte0fd1fb02018-03-10 17:19:50 +0100321 radio_link_tout_div4 := (32/4)-1
Harald Welte7484fc42018-02-24 14:09:45 +0100322 },
Harald Weltef10153f2018-02-25 16:34:05 +0100323 cell_sel_par := ts_CellSelPar_default,
Harald Welte82ccef72018-02-25 16:17:33 +0100324 rach_control := ts_RachCtrl_default,
Vadim Yanitskiy12cf3d92020-05-05 00:19:50 +0700325 rest_octets := enc_SI3RestOctets(valueof(ts_SI3RestOctets_def))
Harald Welte7484fc42018-02-24 14:09:45 +0100326 }
327 }
328}
Harald Welte70767382018-02-21 12:16:40 +0100329
Harald Weltef8df4cb2018-03-10 15:15:08 +0100330template (value) SystemInformation ts_SI2_default := {
331 header := ts_RrHeader(SYSTEM_INFORMATION_TYPE_2, 22),
Harald Weltef10153f2018-02-25 16:34:05 +0100332 payload := {
333 si2 := {
334 bcch_freq_list := '00000000000000000000000000000000'O,
335 ncc_permitted := '11111111'B,
336 rach_control := ts_RachCtrl_default
337 }
338 }
339}
340
Harald Weltef8df4cb2018-03-10 15:15:08 +0100341template (value) SystemInformation ts_SI4_default := {
342 header := ts_RrHeader(SYSTEM_INFORMATION_TYPE_4, 12), /* no CBCH / restoct */
Harald Weltef10153f2018-02-25 16:34:05 +0100343 payload := {
344 si4 := {
345 lai := ts_LAI_default,
346 cell_sel_par := ts_CellSelPar_default,
347 rach_control := ts_RachCtrl_default,
348 cbch_chan_desc := omit,
349 cbch_mobile_alloc := omit,
Vadim Yanitskiy12cf3d92020-05-05 00:19:50 +0700350 rest_octets := enc_SI4RestOctets(valueof(ts_SI4RestOctets_def))
Harald Weltef10153f2018-02-25 16:34:05 +0100351 }
352 }
353}
354
355function f_rsl_bcch_fill_raw(RSL_IE_SysinfoType rsl_si_type, octetstring si_enc)
356runs on test_CT {
357 log("Setting ", rsl_si_type, ": ", si_enc);
Vadim Yanitskiy493abe72020-05-25 22:03:48 +0700358 RSL_CCHAN.send(ts_ASP_RSL_UD(ts_RSL_BCCH_INFO(rsl_si_type, si_enc)));
Harald Weltef10153f2018-02-25 16:34:05 +0100359}
360
361function f_rsl_bcch_fill(RSL_IE_SysinfoType rsl_si_type, template (value) SystemInformation si_dec)
362runs on test_CT {
363 var octetstring si_enc := enc_SystemInformation(valueof(si_dec));
364 log("Setting ", rsl_si_type, ": ", si_dec);
365 f_rsl_bcch_fill_raw(rsl_si_type, si_enc);
366}
367
Harald Welte505cf9b2018-09-15 17:47:23 +0300368friend function f_init_vty(charstring id) runs on test_CT {
Harald Welte8da48242018-02-27 20:41:32 +0100369 map(self:BTSVTY, system:BTSVTY);
370 f_vty_set_prompts(BTSVTY);
371 f_vty_transceive(BTSVTY, "enable");
372}
373
Harald Welte505cf9b2018-09-15 17:47:23 +0300374friend function f_init_vty_bsc() runs on test_CT {
Harald Weltef50e3ae2018-09-10 10:27:56 +0200375 map(self:BSCVTY, system:BSCVTY);
376 f_vty_set_prompts(BSCVTY, "OsmoBSC");
377 f_vty_transceive(BSCVTY, "enable");
378}
379
Pau Espin Pedrolb6985f92020-06-23 14:01:02 +0200380friend function f_connhdlr_init_vty_bsc() runs on ConnHdlr {
381 map(self:BSCVTY, system:BSCVTY);
382 f_vty_set_prompts(BSCVTY, "OsmoBSC");
383 f_vty_transceive(BSCVTY, "enable");
384}
385
Harald Welte883340c2018-02-28 18:59:29 +0100386/* PCU socket may at any time receive a new INFO.ind */
Harald Weltef26de0b2018-04-04 20:28:05 +0200387private altstep as_pcu_info_ind(PCUIF_CODEC_PT pt, integer pcu_conn_id,
388 out PCUIF_Message pcu_last_info) {
Harald Welte883340c2018-02-28 18:59:29 +0100389 var PCUIF_send_data sd;
Harald Weltef26de0b2018-04-04 20:28:05 +0200390 [] pt.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(0, ?))) -> value sd {
391 pcu_last_info := sd.data;
Harald Welted378a252018-03-13 17:02:14 +0100392 }
Harald Weltef26de0b2018-04-04 20:28:05 +0200393 [] pt.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(?, ?, ?))) -> value sd {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200394 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Invalid PCU Version/BTS Number received");
Harald Welte883340c2018-02-28 18:59:29 +0100395 }
396}
397
Harald Weltef26de0b2018-04-04 20:28:05 +0200398private function f_init_pcu(PCUIF_CODEC_PT pt, charstring id,
399 out integer pcu_conn_id, out PCUIF_Message pcu_last_info) {
Harald Welte883340c2018-02-28 18:59:29 +0100400 timer T := 2.0;
401 var PCUIF_send_data sd;
Harald Welte84271622018-03-10 17:21:03 +0100402 if (mp_pcu_socket == "") {
Harald Weltef26de0b2018-04-04 20:28:05 +0200403 pcu_conn_id := -1;
Harald Welte84271622018-03-10 17:21:03 +0100404 return;
405 }
Harald Weltef26de0b2018-04-04 20:28:05 +0200406 pcu_conn_id := f_pcuif_connect(pt, mp_pcu_socket);
Harald Welte883340c2018-02-28 18:59:29 +0100407
408 T.start;
409 alt {
Harald Weltef26de0b2018-04-04 20:28:05 +0200410 [] as_pcu_info_ind(pt, pcu_conn_id, pcu_last_info);
Harald Welte883340c2018-02-28 18:59:29 +0100411 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200412 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PCU INFO_IND");
Harald Welte883340c2018-02-28 18:59:29 +0100413 }
414 }
415}
416
Vadim Yanitskiyf4e997c2019-06-04 21:40:33 +0700417private function f_init_trxc(TRXC_CODEC_PT pt, charstring id,
418 out integer trxc_conn_id) {
419 var Result res;
420
421 res := TRXC_CodecPort_CtrlFunct.f_IPL4_connect(pt, mp_bts_trxc_ip, mp_bts_trxc_port,
422 "", -1, -1, { udp := {} }, {});
423 if (not ispresent(res.connId)) {
424 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
425 "Could not connect to the control (TRXC) interface " &
426 "of FakeTRX, check your configuration");
427 }
428 trxc_conn_id := res.connId;
429}
430
Harald Welte70767382018-02-21 12:16:40 +0100431/* global init function */
Harald Welte10474062019-05-30 16:48:17 +0200432function f_init() runs on test_CT {
433 var charstring id := testcasename();
Harald Welte629cc6b2018-03-11 17:19:05 +0100434 g_AllChannels := {
435 /* TS 1..4: TCH/F */
436 valueof(ts_RslChanNr_Bm(1)), valueof(ts_RslChanNr_Bm(2)),
437 valueof(ts_RslChanNr_Bm(3)), valueof(ts_RslChanNr_Bm(4)),
438 /* TS 5: TCH/H */
439 valueof(ts_RslChanNr_Lm(5,0)), valueof(ts_RslChanNr_Lm(5,1)),
440 /* TS 0: SDCCH/4 */
441 valueof(ts_RslChanNr_SDCCH4(0,0)), valueof(ts_RslChanNr_SDCCH4(0,1)),
442 valueof(ts_RslChanNr_SDCCH4(0,2)), valueof(ts_RslChanNr_SDCCH4(0,3)),
443 /* TS 6: SDCCH/8 */
444 valueof(ts_RslChanNr_SDCCH8(6,0)), valueof(ts_RslChanNr_SDCCH8(6,1)),
445 valueof(ts_RslChanNr_SDCCH8(6,2)), valueof(ts_RslChanNr_SDCCH8(6,3)),
446 valueof(ts_RslChanNr_SDCCH8(6,4)), valueof(ts_RslChanNr_SDCCH8(6,5)),
447 valueof(ts_RslChanNr_SDCCH8(6,6)), valueof(ts_RslChanNr_SDCCH8(6,7))
448 };
449
Pau Espin Pedrol3dcf38f2018-10-22 14:07:54 +0200450 /* FIXME: FACCH/H is unreliable with calypso firmware, see OS#3653 */
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +0700451 if (mp_bts_trxc_port != -1) {
Pau Espin Pedrol3dcf38f2018-10-22 14:07:54 +0200452 g_AllChanTypes := {
453 /* TS 1..4: TCH/F */
454 valueof(ts_RslChanNr_Bm(1)),
455 /* TS 5: TCH/H */
456 valueof(ts_RslChanNr_Lm(5,1)),
457 /* TS 0: SDCCH/4 */
458 valueof(ts_RslChanNr_SDCCH4(0,2)),
459 /* TS 6: SDCCH/8 */
460 valueof(ts_RslChanNr_SDCCH8(6,4))
461 };
462 } else {
463 g_AllChanTypes := {
464 /* TS 1..4: TCH/F */
465 valueof(ts_RslChanNr_Bm(1)),
466 /* TS 0: SDCCH/4 */
467 valueof(ts_RslChanNr_SDCCH4(0,2)),
468 /* TS 6: SDCCH/8 */
469 valueof(ts_RslChanNr_SDCCH8(6,4))
470 };
471 }
Harald Welte70767382018-02-21 12:16:40 +0100472 f_init_rsl(id);
Harald Welte2d142592018-02-25 13:19:44 +0100473 f_sleep(0.5); /* workaround for OS#3000 */
Harald Welte8da48242018-02-27 20:41:32 +0100474 f_init_vty(id);
Neels Hofmeyr6a84b232018-04-03 19:12:36 +0200475 f_ipa_ctrl_start(mp_ctrl_ip, mp_ctrl_port);
Harald Welte7484fc42018-02-24 14:09:45 +0100476
477 /* Send SI3 to the BTS, it is needed for various computations */
Harald Weltef10153f2018-02-25 16:34:05 +0100478 f_rsl_bcch_fill(RSL_SYSTEM_INFO_3, ts_SI3_default);
479 /* SI2 + SI4 are required for SI testing as they are mandatory defaults */
480 f_rsl_bcch_fill(RSL_SYSTEM_INFO_2, ts_SI2_default);
481 f_rsl_bcch_fill(RSL_SYSTEM_INFO_4, ts_SI4_default);
Harald Welte57fe8232018-02-26 17:52:50 +0100482
Harald Weltef26de0b2018-04-04 20:28:05 +0200483 map(self:PCU, system:PCU);
484 f_init_pcu(PCU, id, g_pcu_conn_id, g_pcu_last_info);
Harald Welte883340c2018-02-28 18:59:29 +0100485
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +0700486 if (mp_bts_trxc_port != -1) {
Harald Welte84271622018-03-10 17:21:03 +0100487 var TrxcMessage ret;
Vadim Yanitskiyf4e997c2019-06-04 21:40:33 +0700488
489 /* Init TRXC interface to FakeTRX */
490 map(self:BTS_TRXC, system:BTS_TRXC);
491 f_init_trxc(BTS_TRXC, id, g_bts_trxc_conn_id);
492
Vadim Yanitskiy10d72462019-06-04 22:27:52 +0700493 /* Start with a default moderate timing offset equalling TA=2, and RSSI=-60 */
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +0700494 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 +0700495 ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, valueof(ts_TRXC_FAKE_RSSI(-60)));
Vadim Yanitskiyde535e02019-07-26 16:29:27 +0700496 /* OsmoBTS may have different AB / NB threshold (see MIN_QUAL_NORM, MIN_QUAL_RACH) */
497 ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, valueof(ts_TRXC_FAKE_CI(60)));
Harald Welte84271622018-03-10 17:21:03 +0100498 }
Philipp Maierd95f3402019-04-18 17:50:52 +0200499
500 /* Wait some extra time to make sure the BTS emits a stable carrier.
501 * (this is only relevant when running the tests with a physical BTS.) */
502 f_sleep(mp_ipa_up_delay);
Harald Welte70767382018-02-21 12:16:40 +0100503}
504
Harald Welte68e495b2018-02-25 00:05:57 +0100505/* Attach L1CTL to master test_CT (classic tests, non-handler mode) */
506function f_init_l1ctl() runs on test_CT {
507 map(self:L1CTL, system:L1CTL);
508 f_connect_reset(L1CTL);
509}
510
Harald Welte70767382018-02-21 12:16:40 +0100511type function void_fn(charstring id) runs on ConnHdlr;
512
513/* create a new test component */
Vadim Yanitskiyf4e997c2019-06-04 21:40:33 +0700514function f_start_handler(void_fn fn, ConnHdlrPars pars,
515 boolean pcu_comp := false,
516 boolean trxc_comp := false)
Harald Welte70767382018-02-21 12:16:40 +0100517runs on test_CT return ConnHdlr {
518 var charstring id := testcasename();
519 var ConnHdlr vc_conn;
520
521 vc_conn := ConnHdlr.create(id);
522 /* connect to RSL Emulation main component */
523 connect(vc_conn:RSL, vc_RSL:CLIENT_PT);
524 connect(vc_conn:RSL_PROC, vc_RSL:RSL_PROC);
Vadim Yanitskiyf4e997c2019-06-04 21:40:33 +0700525
526 /* The ConnHdlr component may want to talk to some ports directly,
527 * so we disconnect it from the test_CT and connect it to the component.
528 * This obviously only works for one component, i.e. no concurrency. */
Harald Weltef26de0b2018-04-04 20:28:05 +0200529 if (pcu_comp) {
Harald Weltef26de0b2018-04-04 20:28:05 +0200530 unmap(self:PCU, system:PCU);
531 map(vc_conn:PCU, system:PCU);
532 }
Vadim Yanitskiyf4e997c2019-06-04 21:40:33 +0700533 if (trxc_comp) {
534 unmap(self:BTS_TRXC, system:BTS_TRXC);
535 map(vc_conn:BTS_TRXC, system:BTS_TRXC);
536 }
Harald Welte70767382018-02-21 12:16:40 +0100537
538 vc_conn.start(f_handler_init(fn, id, pars));
539 return vc_conn;
540}
541
Harald Welte70767382018-02-21 12:16:40 +0100542private altstep as_Tguard() runs on ConnHdlr {
543 [] g_Tguard.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200544 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Tguard timeout");
Harald Welte70767382018-02-21 12:16:40 +0100545 }
546}
547
Harald Welte990a3612019-05-27 14:02:13 +0200548friend function f_l1_tune(L1CTL_PT L1CTL, L1ctlCcchMode ccch_mode := CCCH_MODE_COMBINED) {
549 f_L1CTL_FBSB(L1CTL, { false, mp_trx0_arfcn }, ccch_mode, mp_rxlev_exp);
Harald Welte70767382018-02-21 12:16:40 +0100550}
551
Vadim Yanitskiy2f01fbd2019-06-01 01:32:48 +0700552private function f_trxc_fake_rssi(TRXC_RSSI rssi) runs on ConnHdlr {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100553 var TrxcMessage ret;
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +0700554 ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, valueof(ts_TRXC_FAKE_RSSI(rssi)));
Harald Welte70767382018-02-21 12:16:40 +0100555}
556
Vadim Yanitskiydc8db922019-06-04 21:58:15 +0700557private function f_trxc_fake_toffs256(int16_t toffs256) runs on ConnHdlr {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100558 var TrxcMessage ret;
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +0700559 ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, valueof(ts_TRXC_FAKE_TIMING(toffs256)));
Harald Welte70767382018-02-21 12:16:40 +0100560}
561
562/* first function started in ConnHdlr component */
563private function f_handler_init(void_fn fn, charstring id, ConnHdlrPars pars)
564runs on ConnHdlr {
565 g_pars := pars;
566 g_chan_nr := pars.chan_nr;
567
568 map(self:L1CTL, system:L1CTL);
569 f_connect_reset(L1CTL);
570
Harald Welted48c0c72019-06-05 10:01:15 +0200571 if (mp_bts_trxc_port != -1 and BTS_TRXC.checkstate("Mapped")) {
Vadim Yanitskiyf4e997c2019-06-04 21:40:33 +0700572 f_init_trxc(BTS_TRXC, id, g_bts_trxc_conn_id);
Harald Welte84271622018-03-10 17:21:03 +0100573 }
Harald Welte70767382018-02-21 12:16:40 +0100574
575 g_Tguard.start(pars.t_guard);
576 activate(as_Tguard());
577
578 f_rslem_register(0, pars.chan_nr);
579
580 /* call the user-supplied test case function */
581 fn.apply(id);
582}
583
Harald Welteb1726c92018-03-30 11:56:38 +0200584function f_rsl_transceive_ret(template RSL_Message tx, template RSL_Message exp_rx, charstring id,
585 boolean ignore_other := false)
586runs on ConnHdlr return RSL_Message {
587 var RSL_Message rx;
Harald Welte1eba3742018-02-25 12:48:14 +0100588 timer T := 3.0;
589 RSL.send(tx);
590 T.start;
Harald Welte70767382018-02-21 12:16:40 +0100591 alt {
Harald Welteb1726c92018-03-30 11:56:38 +0200592 [] RSL.receive(exp_rx) -> value rx {
Harald Welte1eba3742018-02-25 12:48:14 +0100593 T.stop;
594 setverdict(pass);
Harald Welte70767382018-02-21 12:16:40 +0100595 }
Harald Welte1eba3742018-02-25 12:48:14 +0100596 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200597 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout expecting " & id);
Harald Welte1eba3742018-02-25 12:48:14 +0100598 }
Harald Welte21240e62018-03-11 21:43:35 +0100599 [not ignore_other] as_l1_sacch();
600 [not ignore_other] as_meas_res();
601 [not ignore_other] as_l1_dcch();
602 [not ignore_other] RSL.receive {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200603 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RSL message received");
Harald Welte70767382018-02-21 12:16:40 +0100604 }
Harald Welte21240e62018-03-11 21:43:35 +0100605 [ignore_other] RSL.receive { repeat; }
Harald Welte70767382018-02-21 12:16:40 +0100606 }
Harald Welteb1726c92018-03-30 11:56:38 +0200607 return rx;
608}
609
610function f_rsl_transceive(template RSL_Message tx, template RSL_Message exp_rx, charstring id,
611 boolean ignore_other := false)
612runs on ConnHdlr {
613 var RSL_Message rx := f_rsl_transceive_ret(tx, exp_rx, id, ignore_other);
Harald Welte70767382018-02-21 12:16:40 +0100614}
615
Harald Welte8b01c792019-05-19 22:51:25 +0200616function f_rsl_chan_act(RSL_IE_ChannelMode mode, boolean encr_enable := false, RSL_IE_List more_ies := {},
617 RSL_IE_ActivationType act_type := t_RSL_IE_ActType_IA) runs on ConnHdlr {
618 var RSL_Message ch_act := valueof(ts_RSL_CHAN_ACT(g_chan_nr, mode, act_type));
Harald Weltee613f962018-04-18 22:38:16 +0200619 if (encr_enable) {
620 /* append encryption related IEs, if requested */
621 var RSL_IE_EncryptionInfo encr_info;
622 encr_info := valueof(ts_RSL_IE_EncrInfo(g_pars.encr.alg_id, g_pars.encr.key));
623 ch_act.ies := ch_act.ies & { valueof(t_RSL_IE(RSL_IE_ENCR_INFO, RSL_IE_Body:{encr_info :=
624encr_info})) };
625 }
Harald Weltec8d363c2019-05-19 20:36:48 +0200626 ch_act.ies := ch_act.ies & more_ies;
Harald Weltee613f962018-04-18 22:38:16 +0200627 f_rsl_transceive(ch_act, tr_RSL_CHAN_ACT_ACK(g_chan_nr), "RSL CHAN ACT");
Harald Welte1eba3742018-02-25 12:48:14 +0100628}
629
Harald Welte70767382018-02-21 12:16:40 +0100630function f_rsl_chan_deact() runs on ConnHdlr {
Harald Welte1eba3742018-02-25 12:48:14 +0100631 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 +0100632 "RF CHAN REL", true);
Harald Welte70767382018-02-21 12:16:40 +0100633}
634
Vadim Yanitskiy28cabc42020-05-27 19:44:44 +0700635/* Default Mobile Allocation to be used for frequency hopping */
636private const L1ctlMA l1ctl_ma_def := { { false, mp_trx0_arfcn }, { false, mp_trx1_arfcn },
637 { false, mp_trx2_arfcn }, { false, mp_trx3_arfcn } };
638
Harald Welte2f2b2b72019-05-31 22:24:57 +0200639friend template ConnHdlrPars t_Pars(template RslChannelNr chan_nr,
Harald Welte70767382018-02-21 12:16:40 +0100640 template RSL_IE_ChannelMode chan_mode,
Vadim Yanitskiy28cabc42020-05-27 19:44:44 +0700641 template (omit) MaioHsn maio_hsn := omit,
Harald Welte70767382018-02-21 12:16:40 +0100642 float t_guard := 20.0) := {
643 chan_nr := valueof(chan_nr),
644 chan_mode := valueof(chan_mode),
645 t_guard := t_guard,
646 l1_pars := {
647 dtx_enabled := false,
Harald Welte685d5982018-02-27 20:42:05 +0100648 toa256_enabled := false,
Harald Welte70767382018-02-21 12:16:40 +0100649 meas_ul := {
650 full := {
Pau Espin Pedrole9571aa2018-10-22 17:13:07 +0200651 rxlev := mp_ul_rxlev_exp,
Harald Welte70767382018-02-21 12:16:40 +0100652 rxqual := 0
653 },
654 sub := {
Pau Espin Pedrole9571aa2018-10-22 17:13:07 +0200655 rxlev := mp_ul_rxlev_exp,
Harald Welte70767382018-02-21 12:16:40 +0100656 rxqual := 0
657 }
658 },
Pau Espin Pedrol121724c2018-09-28 15:58:12 +0200659 timing_offset_256syms := mp_timing_offset_256syms_exp,
Harald Welte70767382018-02-21 12:16:40 +0100660 bs_power_level := 0,
Pau Espin Pedroled359cb2018-09-28 16:08:24 +0200661 ms_power_level := mp_ms_power_level_exp,
Pau Espin Pedrol121724c2018-09-28 15:58:12 +0200662 ms_actual_ta := mp_ms_actual_ta_exp
Harald Welte0472ab42018-03-12 15:02:26 +0100663 },
Harald Weltee613f962018-04-18 22:38:16 +0200664 spec := omit,
Eric Wild61edb7e2019-06-03 12:38:31 +0200665 encr := omit,
Vadim Yanitskiy28cabc42020-05-27 19:44:44 +0700666 bts0_band := omit,
667 maio_hsn := maio_hsn,
668 ma_map := c_MA_null,
669 ma := l1ctl_ma_def
Harald Welte70767382018-02-21 12:16:40 +0100670}
671
Harald Welte93640c62018-02-25 16:59:33 +0100672/***********************************************************************
673 * Channel Activation / Deactivation
674 ***********************************************************************/
675
Harald Welte70767382018-02-21 12:16:40 +0100676/* Stress test: Do 500 channel activations/deactivations in rapid succession */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +0700677private function f_TC_chan_act_stress(charstring id) runs on ConnHdlr {
Harald Welte70767382018-02-21 12:16:40 +0100678 for (var integer i := 0; i < 500; i := i+1) {
679 f_rsl_chan_act(g_pars.chan_mode);
680 f_rsl_chan_deact();
681 }
682 setverdict(pass);
683}
684testcase TC_chan_act_stress() runs on test_CT {
685 var ConnHdlr vc_conn;
686 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
Harald Welte10474062019-05-30 16:48:17 +0200687 f_init();
Harald Welte70767382018-02-21 12:16:40 +0100688 vc_conn := f_start_handler(refers(f_TC_chan_act_stress), pars);
689 vc_conn.done;
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200690 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +0100691}
692
693/* Test if re-activation of an already active channel fails as expected */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +0700694private function f_TC_chan_act_react(charstring id) runs on ConnHdlr {
Harald Welte70767382018-02-21 12:16:40 +0100695 f_rsl_chan_act(g_pars.chan_mode);
696 /* attempt to activate the same lchan again -> expect reject */
697 RSL.send(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode));
698 alt {
699 [] RSL.receive(tr_RSL_CHAN_ACT_ACK(g_chan_nr)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200700 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected CHAN ACT ACK on double activation");
Harald Welte70767382018-02-21 12:16:40 +0100701 }
702 [] RSL.receive(tr_RSL_CHAN_ACT_NACK(g_chan_nr)) {
703 setverdict(pass);
704 }
705 }
706 f_rsl_chan_deact();
707}
708testcase TC_chan_act_react() runs on test_CT {
709 var ConnHdlr vc_conn;
710 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
Harald Welte294b0a22018-03-10 23:26:48 +0100711 f_init();
Harald Welte70767382018-02-21 12:16:40 +0100712 vc_conn := f_start_handler(refers(f_TC_chan_act_react), pars);
713 vc_conn.done;
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200714 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +0100715}
716
717/* Attempt to de-activate a channel that's not active */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +0700718private function f_TC_chan_deact_not_active(charstring id) runs on ConnHdlr {
Harald Welte70767382018-02-21 12:16:40 +0100719 timer T := 3.0;
720 RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr));
721 T.start;
722 alt {
723 [] RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr)) {
724 setverdict(pass);
725 }
726 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200727 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout expecting RF_CHAN_REL_ACK");
Harald Welte70767382018-02-21 12:16:40 +0100728 }
729 }
730}
731testcase TC_chan_deact_not_active() runs on test_CT {
732 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
Harald Welte294b0a22018-03-10 23:26:48 +0100733 f_init();
Harald Welte70767382018-02-21 12:16:40 +0100734 var ConnHdlr vc_conn := f_start_handler(refers(f_TC_chan_deact_not_active), pars);
735 vc_conn.done;
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200736 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +0100737}
738
739/* attempt to activate channel with wrong RSL Channel Nr IE; expect NACK */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +0700740private function f_TC_chan_act_wrong_nr(charstring id) runs on ConnHdlr {
Harald Welte70767382018-02-21 12:16:40 +0100741 RSL.send(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode));
742 alt {
743 [] RSL.receive(tr_RSL_CHAN_ACT_ACK(g_chan_nr)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200744 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected CHAN ACT ACK");
Harald Welte70767382018-02-21 12:16:40 +0100745 }
746 [] RSL.receive(tr_RSL_CHAN_ACT_NACK(g_chan_nr)) {
747 setverdict(pass);
748 }
749 }
750}
751private type record WrongChanNrCase {
752 RslChannelNr chan_nr,
753 charstring description
754}
755private type record of WrongChanNrCase WrongChanNrCases;
756private template WrongChanNrCase t_WCN(template RslChannelNr chan_nr, charstring desc) := {
757 chan_nr := chan_nr,
758 description := desc
759}
760
761testcase TC_chan_act_wrong_nr() runs on test_CT {
762 var ConnHdlr vc_conn;
763 var ConnHdlrPars pars;
764
Harald Welte294b0a22018-03-10 23:26:48 +0100765 f_init();
Harald Welte70767382018-02-21 12:16:40 +0100766
767 var WrongChanNrCases wrong := {
768 valueof(t_WCN(t_RslChanNr_RACH(0), "RACH is not a dedicated channel")),
769 valueof(t_WCN(t_RslChanNr_RACH(1), "RACH doesn't exist on timeslot")),
770 valueof(t_WCN(t_RslChanNr_BCCH(0), "BCCH is not a dedicated channel")),
771 valueof(t_WCN(t_RslChanNr_PCH_AGCH(0), "PCH/AGCH is not a dedicated channel")),
772 valueof(t_WCN(t_RslChanNr_Bm(0), "TS0 cannot be TCH/F")),
773 valueof(t_WCN(t_RslChanNr_Lm(0, 0), "TS0 cannot be TCH/H")),
774 valueof(t_WCN(t_RslChanNr_Lm(0, 1), "TS0 cannot be TCH/H")),
775 valueof(t_WCN(t_RslChanNr_PDCH(0), "TS0 cannot be PDCH")),
776 valueof(t_WCN(t_RslChanNr_SDCCH8(0, 0), "TS0 cannot be SDCCH/8")),
777 valueof(t_WCN(t_RslChanNr_SDCCH8(0, 7), "TS0 cannot be SDCCH/8")),
778 valueof(t_WCN(t_RslChanNr_SDCCH4(7, 0), "TS7 cannot be SDCCH/4")),
779 valueof(t_WCN(t_RslChanNr_SDCCH4(7, 3), "TS7 cannot be SDCCH/4")),
780 valueof(t_WCN(t_RslChanNr_Lm(1, 0), "TS1 cannot be TCH/H"))
781 };
782
783 for (var integer i := 0; i < sizeof(wrong); i := i+1) {
784 pars := valueof(t_Pars(wrong[i].chan_nr, ts_RSL_ChanMode_SIGN));
785 vc_conn := f_start_handler(refers(f_TC_chan_act_wrong_nr), pars);
786 vc_conn.done;
787 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200788 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +0100789}
790
Harald Weltee613f962018-04-18 22:38:16 +0200791/* execute the same callback function on a variety of logical channels */
Harald Welte2f2b2b72019-05-31 22:24:57 +0200792friend function f_testmatrix_each_chan(ConnHdlrPars pars, void_fn fn) runs on test_CT {
Harald Weltee613f962018-04-18 22:38:16 +0200793 var ConnHdlr vc_conn;
Harald Welte10474062019-05-30 16:48:17 +0200794 f_init();
Harald Weltee613f962018-04-18 22:38:16 +0200795
796 /* test on each of the channels we have */
797 for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i+1) {
798 pars.chan_nr := valueof(g_AllChanTypes[i]);
799
800 log(testcasename(), ": XXX Starting on ", g_AllChanTypes[i]);
801 vc_conn := f_start_handler(fn, pars);
802 vc_conn.done;
803 }
804
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200805 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Weltee613f962018-04-18 22:38:16 +0200806}
807
Harald Welte93640c62018-02-25 16:59:33 +0100808/***********************************************************************
Harald Welte629cc6b2018-03-11 17:19:05 +0100809 * SACCH handling
810 ***********************************************************************/
811
812private function f_exp_sacch(boolean exp) runs on ConnHdlr {
813 timer T_sacch := 3.0;
814 T_sacch.start;
815 alt {
816 [not exp] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200817 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received SACCH when not expecting it");
Harald Welte629cc6b2018-03-11 17:19:05 +0100818 }
819 [not exp] T_sacch.timeout {
820 setverdict(pass);
821 }
822 [exp] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) {
823 setverdict(pass);
824 }
825 [exp] T_sacch.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200826 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Timeout waiting for SACCH on ", g_chan_nr));
Harald Welte629cc6b2018-03-11 17:19:05 +0100827 }
828 [] L1CTL.receive { repeat; }
829 [] RSL.receive { repeat; }
830 }
831}
832
833/* Test if DEACTIVATE SACCH actualy deactivates its transmission (TS 48.058 4.6) */
834private function f_TC_deact_sacch(charstring id) runs on ConnHdlr {
835 f_l1_tune(L1CTL);
836 RSL.clear;
837
838 /* activate the logical channel */
839 f_est_dchan();
840 L1CTL.clear;
841
842 /* check that SACCH actually are received as expected */
843 f_exp_sacch(true);
844
845 /* deactivate SACCH on the logical channel */
846 RSL.send(ts_RSL_DEACT_SACCH(g_chan_nr));
847 f_sleep(1.0);
848 L1CTL.clear;
849
850 /* check that no SACCH are received anymore */
851 f_exp_sacch(false);
852
853 /* release the channel */
854 f_rsl_chan_deact();
855 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
856}
857testcase TC_deact_sacch() runs on test_CT {
858 var ConnHdlr vc_conn;
859 var ConnHdlrPars pars;
860 f_init();
861 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
862 //for (var integer i := 0; i < 1; i := i+1) {
863 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
864 log(testcasename(), ": Starting for ", g_AllChannels[i]);
865 vc_conn := f_start_handler(refers(f_TC_deact_sacch), pars);
866 vc_conn.done;
867 }
868 /* TODO: do the above in parallel, rather than sequentially? */
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200869 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte629cc6b2018-03-11 17:19:05 +0100870}
871
Harald Welte55700662018-03-12 13:15:43 +0100872/* verify that given SACCH payload is present */
Harald Welteea17b912018-03-11 22:29:31 +0100873private function f_sacch_present(template octetstring l3_exp) runs on ConnHdlr {
874 var L1ctlDlMessage dl;
875 /* check that the specified SI5 value is actually sent */
876 timer T_sacch := 3.0;
877 L1CTL.clear;
878 T_sacch.start;
879 alt {
880 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) -> value dl {
881 var octetstring l3 := substr(dl.payload.data_ind.payload, 4, 19);
882 if (match(l3, l3_exp)) {
883 setverdict(pass);
884 } else {
885 repeat;
886 }
887 }
888 [] L1CTL.receive { repeat; }
889 [] T_sacch.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200890 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Timeout waiting for SACCH ", l3_exp));
Harald Welteea17b912018-03-11 22:29:31 +0100891 }
892 }
893}
894
Harald Welte55700662018-03-12 13:15:43 +0100895/* verify that given SACCH payload is not present */
896private function f_sacch_missing(template octetstring l3_exp) runs on ConnHdlr {
897 var L1ctlDlMessage dl;
898 /* check that the specified SI5 value is actually sent */
899 timer T_sacch := 3.0;
900 L1CTL.clear;
901 T_sacch.start;
902 alt {
903 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) -> value dl {
904 var octetstring l3 := substr(dl.payload.data_ind.payload, 4, 19);
905 if (match(l3, l3_exp)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200906 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Received unexpected SACCH ", dl));
Harald Welte55700662018-03-12 13:15:43 +0100907 } else {
908 repeat;
909 }
910 }
911 [] L1CTL.receive { repeat; }
912 [] T_sacch.timeout {
913 setverdict(pass);
914 }
915 }
916}
917
Harald Welte629cc6b2018-03-11 17:19:05 +0100918/* Test for default SACCH FILL transmitted in DL SACCH (all channel types) */
Harald Welteea17b912018-03-11 22:29:31 +0100919private function f_TC_sacch_filling(charstring id) runs on ConnHdlr {
920 /* Set a known default SACCH filling for SI5 */
921 var octetstring si5 := f_rnd_octstring(19);
922 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5));
923
924 f_l1_tune(L1CTL);
925 RSL.clear;
926
927 /* activate the logical channel */
928 f_est_dchan();
929
930 /* check that the specified SI5 value is actually sent */
931 f_sacch_present(si5);
932
933 /* release the channel */
934 RSL.clear;
935 f_rsl_chan_deact();
936 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
937}
938testcase TC_sacch_filling() runs on test_CT {
939 var ConnHdlr vc_conn;
940 var ConnHdlrPars pars;
941 f_init();
942 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
943 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
944 log(testcasename(), ": Starting for ", g_AllChannels[i]);
945 vc_conn := f_start_handler(refers(f_TC_sacch_filling), pars);
946 vc_conn.done;
947 }
948 /* TODO: do the above in parallel, rather than sequentially? */
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200949 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welteea17b912018-03-11 22:29:31 +0100950}
951
Harald Welte629cc6b2018-03-11 17:19:05 +0100952/* Test for lchan-specific SACCH INFO MODIFY (TS 48.058 4.12) */
Harald Welteea17b912018-03-11 22:29:31 +0100953private function f_TC_sacch_info_mod(charstring id) runs on ConnHdlr {
954 /* Set a known default SACCH filling for SI5 */
955 var octetstring si5 := f_rnd_octstring(19);
956 var octetstring si5_diff := f_rnd_octstring(19);
957 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5));
958
959 f_l1_tune(L1CTL);
960 RSL.clear;
961
962 log("Activating channel, expecting standard SI5");
963 /* activate the logical channel */
964 f_est_dchan();
965 /* check that the specified SI5 value is actually sent */
966 f_sacch_present(si5);
967
968 /* set channel-specific different SI5 */
969 log("Setting channel specific SACCH INFO, expecting it");
970 RSL.send(ts_RSL_SACCH_INF_MOD(g_chan_nr, RSL_SYSTEM_INFO_5, si5_diff))
971 /* check that the specified lchan-specific value is now used */
972 f_sacch_present(si5_diff);
973
974 /* deactivate the channel and re-activate it, this should result in default SI5 */
975 log("De-activating and re-activating channel, expecting standard SI5");
976 f_rsl_chan_deact();
977 f_rsl_chan_act(valueof(ts_RSL_ChanMode_SIGN));
978 /* Verify that the TRX-wide default SACCH filling is present again */
979 f_sacch_present(si5);
980
981 /* release the channel */
982 RSL.clear;
983 f_rsl_chan_deact();
984 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
985}
986testcase TC_sacch_info_mod() runs on test_CT {
987 var ConnHdlr vc_conn;
988 var ConnHdlrPars pars;
989 f_init();
990 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
991 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
992 log(testcasename(), ": Starting for ", g_AllChannels[i]);
993 vc_conn := f_start_handler(refers(f_TC_sacch_info_mod), pars);
994 vc_conn.done;
995 }
996 /* TODO: do the above in parallel, rather than sequentially? */
Daniel Willmann0fcc4d32018-10-23 20:32:19 +0200997 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welteea17b912018-03-11 22:29:31 +0100998}
999
Harald Welte075d84c2018-03-12 13:07:24 +01001000/* Test SACCH scheduling of multiple different SI message types */
1001private function f_TC_sacch_multi(charstring id) runs on ConnHdlr {
1002 var octetstring si5 := f_rnd_octstring(19);
1003 var octetstring si5bis := f_rnd_octstring(19);
1004 var octetstring si5ter := f_rnd_octstring(19);
1005 var octetstring si6 := f_rnd_octstring(19);
1006
1007 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5));
1008 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5bis, si5bis));
1009 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5ter, si5ter));
1010 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, si6));
1011
1012 f_l1_tune(L1CTL);
1013 RSL.clear;
1014
1015 /* activate the logical channel */
1016 f_est_dchan();
1017 L1CTL.clear;
1018
1019 /* check that SACCH actually are received as expected */
1020 f_sacch_present(si5);
1021 f_sacch_present(si5bis);
1022 f_sacch_present(si5ter);
1023 f_sacch_present(si6);
1024
1025 /* release the channel */
1026 f_rsl_chan_deact();
1027 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1028}
1029testcase TC_sacch_multi() runs on test_CT {
1030 var ConnHdlr vc_conn;
1031 var ConnHdlrPars pars;
1032 f_init();
1033 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
1034 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
1035 log(testcasename(), ": Starting for ", g_AllChannels[i]);
1036 vc_conn := f_start_handler(refers(f_TC_sacch_multi), pars);
1037 vc_conn.done;
1038 }
1039 /* TODO: do the above in parallel, rather than sequentially? */
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001040 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte075d84c2018-03-12 13:07:24 +01001041}
1042
Harald Welte55700662018-03-12 13:15:43 +01001043/* Test if SACH information is modified as expected */
1044private function f_TC_sacch_multi_chg(charstring id) runs on ConnHdlr {
1045 var octetstring si5 := f_rnd_octstring(19);
1046 var octetstring si6 := f_rnd_octstring(19);
1047
1048 /* First, configure both SI5 and SI6 to be transmitted */
1049 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5));
1050 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, si6));
1051
1052 f_l1_tune(L1CTL);
1053 RSL.clear;
1054
1055 /* activate the logical channel */
1056 f_est_dchan();
1057 L1CTL.clear;
1058
1059 /* check that SACCH actually are received as expected */
1060 f_sacch_present(si5);
1061 f_sacch_present(si6);
1062
1063 /* disable SI6 */
1064 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, ''O));
1065
1066 /* check that SI5 is still transmitted */
1067 f_sacch_present(si5);
1068 /* check if SI6 is now gone */
1069 f_sacch_missing(si6);
1070
1071 /* release the channel */
1072 f_rsl_chan_deact();
1073 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1074}
1075testcase TC_sacch_multi_chg() runs on test_CT {
1076 var ConnHdlr vc_conn;
1077 var ConnHdlrPars pars;
1078 f_init();
1079 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
1080 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
1081 log(testcasename(), ": Starting for ", g_AllChannels[i]);
1082 vc_conn := f_start_handler(refers(f_TC_sacch_multi_chg), pars);
1083 vc_conn.done;
1084 }
1085 /* TODO: do the above in parallel, rather than sequentially? */
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001086 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte55700662018-03-12 13:15:43 +01001087}
1088
Harald Weltec8d363c2019-05-19 20:36:48 +02001089/* Test for SACCH information present in RSL CHAN ACT (overrides FILLING) */
1090private function f_TC_sacch_chan_act(charstring id) runs on ConnHdlr {
1091 var octetstring si5 := f_rnd_octstring(19);
1092 var octetstring si6 := f_rnd_octstring(19);
1093 var octetstring si5_specific := f_rnd_octstring(19);
1094 var octetstring si6_specific := f_rnd_octstring(19);
1095
1096 /* First, configure both SI5 and SI6 to be transmitted */
1097 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5));
1098 RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, si6));
1099
1100 f_l1_tune(L1CTL);
1101 RSL.clear;
1102
1103 /* activate channel with different SACCH filling */
1104 var RSL_SacchInfo sacch_info := valueof(ts_RSL_SacchInfo({
1105 ts_RSL_SacchInfoElem(RSL_SYSTEM_INFO_5, si5_specific),
1106 ts_RSL_SacchInfoElem(RSL_SYSTEM_INFO_6, si6_specific)
1107 }));
1108 var RSL_IE_List addl_ies := { valueof(t_RSL_IE(RSL_IE_SACCH_INFO,
1109 RSL_IE_Body:{sacch_info := sacch_info})) };
1110 f_est_dchan(more_ies := addl_ies);
1111
1112 /* check that SACCH actually are received as expected */
1113 f_sacch_present(si5_specific);
1114 f_sacch_present(si6_specific);
1115
1116 /* release the channel */
1117 f_rsl_chan_deact();
1118 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1119}
1120testcase TC_sacch_chan_act() runs on test_CT {
1121 var ConnHdlr vc_conn;
1122 var ConnHdlrPars pars;
1123 f_init();
1124
1125 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
1126 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
1127 log(testcasename(), ": Starting for ", g_AllChannels[i]);
1128 vc_conn := f_start_handler(refers(f_TC_sacch_chan_act), pars);
1129 vc_conn.done;
1130 }
1131 /* TODO: do the above in parallel, rather than sequentially? */
1132 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
1133}
1134
Harald Welte8b01c792019-05-19 22:51:25 +02001135/* verify that SACCH DL transmission is started only if MS power IE present
1136 * see section 4.1.3 of 3GPP TS 48.058 */
1137private function f_TC_sacch_chan_act_ho_async(charstring id) runs on ConnHdlr {
1138 var octetstring si5 := f_rnd_octstring(19);
1139
1140 f_l1_tune(L1CTL);
1141 RSL.clear;
1142
1143 /* Step 1: Activate ASYNC HO channel without MS power IE */
1144
1145 /* Activate channel on BTS side */
1146 f_rsl_chan_act(g_pars.chan_mode, act_type := t_RSL_IE_ActType_HO_ASYNC);
1147 /* don't perform immediate assignment here, as we're testing non-IA case */
1148 /* enable dedicated mode */
Vadim Yanitskiy5afe8852020-05-27 14:40:51 +07001149 L1CTL.send(ts_L1CTL_DM_EST_REQ_H0(g_pars.chan_nr, 7, mp_trx0_arfcn));
Harald Welte8b01c792019-05-19 22:51:25 +02001150
1151 /* Verify that no DL SACCH is being received */
1152 f_sacch_missing(?);
1153
1154 f_rsl_chan_deact();
1155 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1156
1157
1158 /* Step 2: Activate ASYNC HO channel with MS power IE */
1159
1160 /* Activate channel on BTS side */
1161 var RSL_IE_List addl_ies := {
1162 valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(0)}))
1163 };
1164 f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_ASYNC);
1165 /* don't perform immediate assignment here, as we're testing non-IA case */
1166 /* enable dedicated mode */
Vadim Yanitskiy5afe8852020-05-27 14:40:51 +07001167 L1CTL.send(ts_L1CTL_DM_EST_REQ_H0(g_pars.chan_nr, 7, mp_trx0_arfcn));
Harald Welte8b01c792019-05-19 22:51:25 +02001168
1169 /* Verify that DL SACCH is being received */
1170 f_sacch_present(si5);
1171
1172 f_rsl_chan_deact();
1173 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1174}
1175testcase TC_sacch_chan_act_ho_async() runs on test_CT {
1176 var ConnHdlr vc_conn;
1177 var ConnHdlrPars pars;
1178 f_init();
1179
1180 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
1181 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
1182 log(testcasename(), ": Starting for ", g_AllChannels[i]);
1183 vc_conn := f_start_handler(refers(f_TC_sacch_chan_act_ho_async), pars);
1184 vc_conn.done;
1185 }
1186 /* TODO: do the above in parallel, rather than sequentially? */
1187 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
1188}
1189
1190/* verify that SACCH DL transmission is started only if TA + MS power IEs present,
1191 * see section 4.1.4 of 3GPP TS 48.058 */
1192private function f_TC_sacch_chan_act_ho_sync(charstring id) runs on ConnHdlr {
1193 var octetstring si5 := f_rnd_octstring(19);
1194 var RSL_IE_List addl_ies;
1195
1196 f_l1_tune(L1CTL);
1197 RSL.clear;
1198
1199 /* Step 1: Activate SYNC HO channel without MS power IE */
1200
1201 /* Activate channel on BTS side */
1202 f_rsl_chan_act(g_pars.chan_mode, act_type := t_RSL_IE_ActType_HO_SYNC);
1203 /* don't perform immediate assignment here, as we're testing non-IA case */
1204 /* enable dedicated mode */
Vadim Yanitskiy5afe8852020-05-27 14:40:51 +07001205 L1CTL.send(ts_L1CTL_DM_EST_REQ_H0(g_pars.chan_nr, 7, mp_trx0_arfcn));
Harald Welte8b01c792019-05-19 22:51:25 +02001206
1207 /* Verify that no DL SACCH is being received */
1208 f_sacch_missing(?);
1209
1210 f_rsl_chan_deact();
1211 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1212
1213
1214 /* Step 2a: Activate SYNC HO channel with only MS power IE */
1215
1216 /* Activate channel on BTS side */
1217 addl_ies := {
1218 valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(0)}))
1219 };
1220 f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_SYNC);
1221 /* don't perform immediate assignment here, as we're testing non-IA case */
1222 /* enable dedicated mode */
Vadim Yanitskiy5afe8852020-05-27 14:40:51 +07001223 L1CTL.send(ts_L1CTL_DM_EST_REQ_H0(g_pars.chan_nr, 7, mp_trx0_arfcn));
Harald Welte8b01c792019-05-19 22:51:25 +02001224
1225 /* Verify that no DL SACCH is being received */
1226 f_sacch_missing(?);
1227
1228 f_rsl_chan_deact();
1229 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1230
1231
1232 /* Step 2b: Activate SYNC HO channel with TA IE */
1233
1234 /* Activate channel on BTS side */
1235 addl_ies := {
1236 valueof(t_RSL_IE(RSL_IE_TIMING_ADVANCE, RSL_IE_Body:{timing_adv := 0}))
1237 };
1238 f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_SYNC);
1239 /* don't perform immediate assignment here, as we're testing non-IA case */
1240 /* enable dedicated mode */
Vadim Yanitskiy5afe8852020-05-27 14:40:51 +07001241 L1CTL.send(ts_L1CTL_DM_EST_REQ_H0(g_pars.chan_nr, 7, mp_trx0_arfcn));
Harald Welte8b01c792019-05-19 22:51:25 +02001242
1243 /* Verify that no DL SACCH is being received */
1244 f_sacch_missing(?);
1245
1246 f_rsl_chan_deact();
1247 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1248
1249
1250 /* Step 3: Activate SYNC HO channel with MS power IE and TA IE */
1251
1252 /* Activate channel on BTS side */
1253 addl_ies := {
1254 valueof(t_RSL_IE(RSL_IE_TIMING_ADVANCE, RSL_IE_Body:{timing_adv := 0})),
1255 valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(0)}))
1256 };
1257 f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_SYNC);
1258 /* don't perform immediate assignment here, as we're testing non-IA case */
1259 /* enable dedicated mode */
Vadim Yanitskiy5afe8852020-05-27 14:40:51 +07001260 L1CTL.send(ts_L1CTL_DM_EST_REQ_H0(g_pars.chan_nr, 7, mp_trx0_arfcn));
Harald Welte8b01c792019-05-19 22:51:25 +02001261
1262 /* Verify that DL SACCH is being received */
1263 f_sacch_present(si5);
1264
1265 f_rsl_chan_deact();
1266 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1267}
1268testcase TC_sacch_chan_act_ho_sync() runs on test_CT {
1269 var ConnHdlr vc_conn;
1270 var ConnHdlrPars pars;
1271 f_init();
1272
1273 for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
1274 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
1275 log(testcasename(), ": Starting for ", g_AllChannels[i]);
1276 vc_conn := f_start_handler(refers(f_TC_sacch_chan_act_ho_sync), pars);
1277 vc_conn.done;
1278 }
1279 /* TODO: do the above in parallel, rather than sequentially? */
1280 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
1281}
Harald Welte629cc6b2018-03-11 17:19:05 +01001282
1283
1284/***********************************************************************
Harald Welte93640c62018-02-25 16:59:33 +01001285 * RACH Handling
1286 ***********************************************************************/
1287
Harald Welte8c24c2b2018-02-26 08:31:31 +01001288/* like L1SAP_IS_PACKET_RACH */
1289private function ra_is_ps(OCT1 ra) return boolean {
Harald Welte56c05802018-02-28 21:39:35 +01001290 if ((ra and4b 'F0'O == '70'O) and (ra and4b '0F'O != '0F'O)) {
Harald Welte8c24c2b2018-02-26 08:31:31 +01001291 return true;
1292 }
1293 return false;
1294}
1295
1296/* generate a random RACH for circuit-switched */
1297private function f_rnd_ra_cs() return OCT1 {
1298 var OCT1 ra;
1299 do {
1300 ra := f_rnd_octstring(1);
1301 } while (ra_is_ps(ra));
1302 return ra;
1303}
1304
Harald Welte883340c2018-02-28 18:59:29 +01001305/* generate a random RACH for packet-switched */
1306private function f_rnd_ra_ps() return OCT1 {
1307 var OCT1 ra;
1308 do {
1309 ra := f_rnd_octstring(1);
1310 } while (not ra_is_ps(ra));
1311 return ra;
1312}
1313
Vadim Yanitskiy51cbc102019-04-22 06:37:30 +07001314/* generate a random 11-bit RA (packet-switched only) */
1315private function f_rnd_ra11_ps() return BIT11 {
1316 var integer ra11 := f_rnd_int(bit2int('11111111111'B));
1317 return int2bit(ra11, 11);
1318}
1319
Harald Welte8c24c2b2018-02-26 08:31:31 +01001320/* Send 1000 RACH requests and check their RA+FN on the RSL side */
1321testcase TC_rach_content() runs on test_CT {
Harald Welte10474062019-05-30 16:48:17 +02001322 f_init();
Harald Welte8c24c2b2018-02-26 08:31:31 +01001323 f_init_l1ctl();
Harald Welte68e495b2018-02-25 00:05:57 +01001324 f_l1_tune(L1CTL);
Harald Welte70767382018-02-21 12:16:40 +01001325
Harald Welte8c24c2b2018-02-26 08:31:31 +01001326 var GsmFrameNumber fn_last := 0;
Maxa199a2e2019-02-25 16:31:11 +01001327 var boolean test_failed := false;
Harald Welte8c24c2b2018-02-26 08:31:31 +01001328 for (var integer i := 0; i < 1000; i := i+1) {
1329 var OCT1 ra := f_rnd_ra_cs();
1330 var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra));
1331 if (fn == fn_last) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001332 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?");
Harald Welte8c24c2b2018-02-26 08:31:31 +01001333 }
1334 fn_last := fn;
1335
1336 timer T := 5.0;
Harald Welte56c05802018-02-28 21:39:35 +01001337 T.start;
Harald Welte8c24c2b2018-02-26 08:31:31 +01001338 alt {
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07001339 [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_CHAN_RQD(ra, fn, t_RslChanNr_RACH(0)))) {
Harald Welte8c24c2b2018-02-26 08:31:31 +01001340 T.stop;
1341 }
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07001342 [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_CHAN_RQD(?, ?, ?, ?))) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001343 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected CHAN RQD");
Harald Welte8c24c2b2018-02-26 08:31:31 +01001344 }
1345 [] RSL_CCHAN.receive { repeat; }
1346 [] T.timeout {
Maxa199a2e2019-02-25 16:31:11 +01001347 test_failed := true;
1348 log("[", i, "] Timeout waiting for CHAN RQD FN=", fn, " RA=", ra);
Harald Welte8c24c2b2018-02-26 08:31:31 +01001349 }
1350 }
1351 }
Maxba06feb2019-03-05 10:52:46 +01001352 if (test_failed) {
1353 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Some out of 1000 RACH requests timed out"));
Maxa199a2e2019-02-25 16:31:11 +01001354 }
Maxba06feb2019-03-05 10:52:46 +01001355 setverdict(pass);
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001356 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +01001357}
Harald Welte8c24c2b2018-02-26 08:31:31 +01001358
1359/* Send 1000 RACH Requests (flood ~ 89/s) and count if count(Abis) == count(Um) */
1360testcase TC_rach_count() runs on test_CT {
Harald Welte294b0a22018-03-10 23:26:48 +01001361 f_init();
Harald Welte8c24c2b2018-02-26 08:31:31 +01001362 f_init_l1ctl();
Harald Welte294b0a22018-03-10 23:26:48 +01001363 f_sleep(1.0);
Harald Welte8c24c2b2018-02-26 08:31:31 +01001364 f_l1_tune(L1CTL);
1365
1366 var GsmFrameNumber fn_last := 0;
1367 for (var integer i := 0; i < 1000; i := i+1) {
1368 var OCT1 ra := f_rnd_ra_cs();
1369 var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra));
1370 if (fn == fn_last) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001371 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?");
Harald Welte8c24c2b2018-02-26 08:31:31 +01001372 }
1373 fn_last := fn;
1374 }
1375 var integer rsl_chrqd := 0;
1376 timer T := 3.0;
Harald Welte56c05802018-02-28 21:39:35 +01001377 T.start;
Harald Welte8c24c2b2018-02-26 08:31:31 +01001378 alt {
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07001379 [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_CHAN_RQD(?,?))) {
Harald Welte8c24c2b2018-02-26 08:31:31 +01001380 rsl_chrqd := rsl_chrqd + 1;
Harald Weltec3a3f452018-02-26 17:37:47 +01001381 f_timer_safe_restart(T);
Harald Welte8c24c2b2018-02-26 08:31:31 +01001382 repeat;
1383 }
1384 [] RSL_CCHAN.receive { repeat; }
1385 [] T.timeout { }
1386 }
1387 if (rsl_chrqd == 1000) {
1388 setverdict(pass);
1389 } else {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001390 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Received only ", rsl_chrqd, " out of 1000 RACH"));
Harald Welte8c24c2b2018-02-26 08:31:31 +01001391 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001392 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +01001393}
1394
Harald Welte3453ab42019-05-24 21:19:58 +02001395private function f_vty_load_ind_thresh(integer period := 10, integer bts_nr := 0) runs on test_CT {
1396 var charstring bts_str := "bts " & int2str(bts_nr);
1397 f_vty_config2(BSCVTY, {"network", bts_str}, "ccch load-indication-threshold " & int2str(period));
1398}
1399
1400/* empirical value: Number of RACH slots per reporting interval (1s) on combined CCCH */
1401private template integer tr_rach_slots_per_interval := (90 .. 130);
1402
1403/* Expect 0 RACH load on an idle BTS that has just started up */
1404testcase TC_rach_load_idle_thresh0() runs on test_CT {
1405 var ASP_RSL_Unitdata rx_ud;
1406
1407 f_init_vty_bsc();
1408 /* send load indications even at 0% load */
1409 f_vty_load_ind_thresh(0);
1410 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
1411 f_sleep(2.0);
1412
1413 f_init();
1414
1415 timer T := 5.0;
1416 T.start;
1417 alt {
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07001418 [] 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 +02001419 setverdict(pass);
1420 repeat;
1421 }
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07001422 [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RACH_LOAD_IND(?, ?, ?))) -> value rx_ud {
Harald Welte3453ab42019-05-24 21:19:58 +02001423 setverdict(fail, "Unexpected RACH LOAD IND: ", rx_ud);
1424 repeat;
1425 }
1426 [] RSL_CCHAN.receive {
1427 repeat;
1428 }
1429 [] T.timeout { }
1430 }
1431
1432 f_vty_load_ind_thresh(10);
1433 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
1434}
1435
1436/* Expect no RACH load indications on an idle BTS that has just started up (default threshold 10%) */
1437testcase TC_rach_load_idle_below_thresh() runs on test_CT {
1438 var ASP_RSL_Unitdata rx_ud;
1439
1440 f_init_vty_bsc();
1441 f_init();
1442
1443 timer T := 5.0;
1444 T.start;
1445 alt {
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 setverdict(pass);
1455 }
1456 }
1457
1458 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
1459}
1460
1461/* Expect 0 RACH load on an idle BTS that has just started up */
1462testcase TC_rach_load_count() runs on test_CT {
1463 var ASP_RSL_Unitdata rx_ud;
1464 var integer load_access_count := 0;
1465
1466 f_init_vty_bsc();
1467 /* send load indications even at 0% load */
1468 f_vty_load_ind_thresh(0);
1469 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
1470 f_sleep(2.0);
1471 f_init();
1472
1473 f_init_l1ctl();
1474 f_sleep(1.0);
1475 f_l1_tune(L1CTL);
1476
1477 var GsmFrameNumber fn_last := 0;
1478 for (var integer i := 0; i < 1000; i := i+1) {
1479 var OCT1 ra := f_rnd_ra_cs();
1480 var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra));
1481 if (fn == fn_last) {
1482 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?");
1483 }
1484 fn_last := fn;
1485 }
1486
1487 timer T := 5.0;
1488 T.start;
1489 alt {
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07001490 [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RACH_LOAD_IND(tr_rach_slots_per_interval, ?, ?)))
Harald Welte3453ab42019-05-24 21:19:58 +02001491 -> value rx_ud {
1492 var RSL_IE_Body ie;
1493 f_rsl_find_ie(rx_ud.rsl, RSL_IE_RACH_LOAD, ie);
1494 load_access_count := load_access_count + ie.rach_load.access_count;
1495 if (ie.rach_load.busy_count < ie.rach_load.access_count) {
1496 setverdict(fail, "Access count cannot be < Busy count");
1497 }
1498 repeat;
1499 }
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07001500 [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RACH_LOAD_IND(?, ?, ?))) -> value rx_ud {
Harald Welte3453ab42019-05-24 21:19:58 +02001501 setverdict(fail, "Unexpected RACH LOAD IND: ", rx_ud);
1502 repeat;
1503 }
1504 [] RSL_CCHAN.receive {
1505 repeat;
1506 }
1507 [] T.timeout { }
1508 }
1509 if (load_access_count == 1000) {
1510 setverdict(pass);
1511 } else {
1512 setverdict(fail, "Load reports state ", load_access_count, " RACH, but we sent 1000");
1513 }
1514
1515 f_vty_load_ind_thresh(10);
1516 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
1517}
1518
Harald Welte54a2a2d2018-02-26 09:14:05 +01001519private function f_rach_toffs(int16_t toffs256, boolean expect_pass) runs on test_CT {
Harald Weltef8df4cb2018-03-10 15:15:08 +01001520 var TrxcMessage ret;
Harald Welte54a2a2d2018-02-26 09:14:05 +01001521 /* tell fake_trx to use a given timing offset for all bursts */
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +07001522 ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, valueof(ts_TRXC_FAKE_TIMING(toffs256)));
Harald Welte54a2a2d2018-02-26 09:14:05 +01001523 f_sleep(0.5);
1524
1525 /* Transmit RACH request + wait for confirmation */
1526 var OCT1 ra := f_rnd_ra_cs();
1527 var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra));
1528
1529 /* Check for expected result */
1530 timer T := 1.5;
1531 T.start;
1532 alt {
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07001533 [expect_pass] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_CHAN_RQD(ra, fn))) {
Harald Welte54a2a2d2018-02-26 09:14:05 +01001534 setverdict(pass);
1535 }
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07001536 [not expect_pass] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_CHAN_RQD(ra, fn))) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001537 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("RACH passed but was expected to be dropped: ", toffs256));
Harald Welte54a2a2d2018-02-26 09:14:05 +01001538 }
1539 [] RSL_CCHAN.receive { repeat; }
1540 [not expect_pass] T.timeout {
1541 setverdict(pass);
1542 }
1543 [expect_pass] T.timeout {
Max6e053042019-03-14 16:34:22 +01001544 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Timeout waiting for CHAN RQD: FN=", fn, " RA=", ra));
Harald Welte54a2a2d2018-02-26 09:14:05 +01001545 }
1546 }
1547}
1548
1549/* Test if dropping of RACH Based on NM_ATT_MAX_TA works */
1550testcase TC_rach_max_ta() runs on test_CT {
Harald Welte10474062019-05-30 16:48:17 +02001551 f_init();
Harald Welte54a2a2d2018-02-26 09:14:05 +01001552 f_init_l1ctl();
1553 f_l1_tune(L1CTL);
Harald Welte54a2a2d2018-02-26 09:14:05 +01001554 f_sleep(1.0);
1555
1556 /* default max-ta is 63 (full range of GSM timing advance */
1557
Vadim Yanitskiyc81d6e42018-03-05 22:39:01 +07001558 /* We allow early arrival up to 2 symbols */
1559 f_rach_toffs(-1*256, true);
1560 f_rach_toffs(-2*256, true);
Harald Welte54a2a2d2018-02-26 09:14:05 +01001561 f_rach_toffs(-10*256, false);
1562
1563 /* 0 / 32 / 63 bits is legal / permitted */
1564 f_rach_toffs(0, true);
1565 f_rach_toffs(32*256, true);
1566 f_rach_toffs(63*256, true);
1567
1568 /* more than 63 bits is not legal / permitted */
1569 f_rach_toffs(64*256, false);
1570 f_rach_toffs(127*256, false);
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001571 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte54a2a2d2018-02-26 09:14:05 +01001572}
Harald Welte8c24c2b2018-02-26 08:31:31 +01001573
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07001574private function f_TC_ho_rach(charstring id) runs on ConnHdlr {
Vadim Yanitskiy7c2c10c2019-05-31 20:42:01 +07001575 var GsmFrameNumber fn;
1576 var RSL_Message rm;
1577
1578 f_l1_tune(L1CTL);
1579 RSL.clear;
1580
1581 /* Generate a random Handover Reference */
1582 var integer ho_ref := oct2int(f_rnd_octstring(1));
1583
1584 /* Handover Reference IE (see 3GPP TS 48.058, 9.3.9) */
1585 var RSL_IE ho_ref_ie := valueof(t_RSL_IE(RSL_IE_HANDO_REF,
1586 RSL_IE_Body:{ handover_ref := ho_ref }));
1587
1588 /* Activate a channel on the BTS side (no encryption) */
1589 f_rsl_chan_act(g_pars.chan_mode, more_ies := { ho_ref_ie },
1590 act_type := t_RSL_IE_ActType_HO_SYNC);
1591
1592 /* Switch the MS side (e.g. trxcon) to a dedicated channel without
1593 * waiting for Immediate Assignment and sending Access Burst */
Vadim Yanitskiy5afe8852020-05-27 14:40:51 +07001594 L1CTL.send(ts_L1CTL_DM_EST_REQ_H0(g_pars.chan_nr, 7, mp_trx0_arfcn));
Vadim Yanitskiy7c2c10c2019-05-31 20:42:01 +07001595
1596 /* Send handover Access Burst */
1597 fn := f_L1CTL_RACH(L1CTL, ho_ref, chan_nr := g_pars.chan_nr);
1598
1599 /* TODO: test mismatching Handover Reference, and missing IE */
1600
1601 /* Wait for handover detection */
1602 timer T := 3.0;
1603 T.start;
1604 alt {
1605 [] RSL.receive(tr_RSL_HANDO_DET(g_pars.chan_nr)) -> value rm {
1606 log("Handover RACH has been detected: ", rm);
1607 setverdict(pass);
1608 }
1609 [] RSL.receive(tr_RSL_CHAN_RQD(?, ?, ?, ?)) -> value rm {
1610 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
1611 log2str("RSL_CHAN_RQD was not expected: ", rm));
1612 }
1613 [] RSL.receive { repeat; }
1614 [] T.timeout {
1615 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
1616 log2str("Timeout waiting for handover RACH: FN=", fn, " RA=", ho_ref));
1617 }
1618 }
1619
1620 /* Release the channel */
1621 f_rsl_chan_deact();
1622 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
1623}
1624
1625/* Test handover RACH detection */
1626testcase TC_ho_rach() runs on test_CT {
1627 var ConnHdlrPars pars;
1628 var ConnHdlr vc_conn;
1629
1630 f_init();
1631
1632 for (var integer i := 0; i < sizeof(g_AllChannels); i := i + 1) {
1633 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
1634 log(testcasename(), ": Starting for ", g_AllChannels[i]);
1635 vc_conn := f_start_handler(refers(f_TC_ho_rach), pars);
1636 vc_conn.done;
1637 }
1638
1639 /* TODO: do the above in parallel, rather than sequentially? */
1640 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
1641}
1642
Harald Welte93640c62018-02-25 16:59:33 +01001643/***********************************************************************
1644 * Measurement Processing / Reporting
1645 ***********************************************************************/
1646
Harald Welte70767382018-02-21 12:16:40 +01001647template LapdmAddressField ts_LapdmAddr(LapdmSapi sapi, boolean c_r) := {
1648 spare := '0'B,
1649 lpd := 0,
1650 sapi := sapi,
1651 c_r := c_r,
1652 ea := true
1653}
1654
Harald Welted879bd92018-03-12 15:01:23 +01001655template LapdmFrameAB ts_LAPDm_AB(LapdmSapi sapi, boolean c_r, boolean p, octetstring pl) := {
Harald Welte70767382018-02-21 12:16:40 +01001656 addr := ts_LapdmAddr(sapi, c_r),
Harald Welted879bd92018-03-12 15:01:23 +01001657 ctrl := ts_LapdmCtrlUI(p),
Harald Welte70767382018-02-21 12:16:40 +01001658 len := 0, /* overwritten */
1659 m := false,
1660 el := 1,
1661 payload := pl
1662}
1663
1664/* handle incoming downlink SACCH and respond with uplink SACCH (meas res) */
1665altstep as_l1_sacch() runs on ConnHdlr {
1666 var L1ctlDlMessage l1_dl;
Harald Weltef8df4cb2018-03-10 15:15:08 +01001667 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl {
Harald Welte70767382018-02-21 12:16:40 +01001668 log("SACCH received: ", l1_dl.payload.data_ind.payload);
Pau Espin Pedrole9571aa2018-10-22 17:13:07 +02001669 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 +01001670 var LapdmFrameAB lb := valueof(ts_LAPDm_AB(0, false, false, enc_GsmRrL3Message(meas_rep)));
Harald Welte70767382018-02-21 12:16:40 +01001671 log("LAPDm: ", lb);
Pau Espin Pedroled359cb2018-09-28 16:08:24 +02001672
Vadim Yanitskiy0a8d6da2019-05-28 22:18:28 +07001673 var template (value) SacchL1Header l1h := ts_SacchL1Header(
1674 g_pars.l1_pars.ms_power_level, false,
1675 g_pars.l1_pars.ms_actual_ta);
1676
1677 /* TODO: we can use an extension of TTCN-3 for that, i.e. PADDING('2B'O) */
1678 var octetstring l2 := f_pad_oct(enc_LapdmFrameAB(lb), 21, '2B'O);
1679
1680 log("Sending Measurement Report: ", l1h, l2);
1681 L1CTL.send(ts_L1CTL_DATA_REQ_SACCH(g_chan_nr, ts_RslLinkID_SACCH(0), l1h, l2));
Harald Welte70767382018-02-21 12:16:40 +01001682 repeat;
1683 }
1684}
1685
1686altstep as_l1_dcch() runs on ConnHdlr {
1687 var L1ctlDlMessage l1_dl;
Harald Weltef8df4cb2018-03-10 15:15:08 +01001688 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_DCCH(?))) -> value l1_dl {
Harald Welte70767382018-02-21 12:16:40 +01001689 log("DCCH received: ", l1_dl.payload.data_ind.payload);
1690 var octetstring pl := '010301'O;
Vadim Yanitskiy31e7c672018-07-27 02:23:16 +07001691 L1CTL.send(ts_L1CTL_DATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0),
1692 f_pad_oct(pl, 23, '2B'O)));
Harald Welte70767382018-02-21 12:16:40 +01001693 repeat;
1694 }
1695}
1696
1697type record MeasElem {
1698 uint6_t rxlev,
1699 uint3_t rxqual
1700}
1701
1702type record MeasElemFS {
1703 MeasElem full,
1704 MeasElem sub
1705}
1706
1707type record ConnL1Pars {
1708 boolean dtx_enabled,
Harald Welte685d5982018-02-27 20:42:05 +01001709 boolean toa256_enabled,
Harald Welte70767382018-02-21 12:16:40 +01001710 MeasElemFS meas_ul,
1711 int16_t timing_offset_256syms,
Vadim Yanitskiy117c1762020-06-16 01:40:10 +07001712 uint4_t bs_power_level,
Harald Welte70767382018-02-21 12:16:40 +01001713 uint5_t ms_power_level,
1714 uint8_t ms_actual_ta
1715}
1716
1717/* Convert tiing offset from 1/256th symbol to RSL Timing Offset */
1718private function toffs256s_to_rsl(int16_t toffs256s) return uint8_t {
1719 return 63 + (toffs256s/256);
1720}
1721
Harald Welted5684392018-03-10 18:22:04 +01001722private function f_max(integer a, integer b) return integer {
1723 if (a > b) {
1724 return a;
1725 } else {
1726 return b;
1727 }
1728}
1729
1730private function f_min(integer a, integer b) return integer {
1731 if (a < b) {
1732 return a;
1733 } else {
1734 return b;
1735 }
1736}
1737
1738/* compute negative tolerance val-tolerance, ensure >= min */
1739private function f_tolerance_neg(integer val, integer min, integer tolerance) return integer {
1740 val := val - tolerance;
1741 return f_max(val, min);
1742}
1743
1744/* compute positive tolerance val+tolerance, ensure <= max */
1745private function f_tolerance_pos(integer val, integer max, integer tolerance) return integer {
1746 val := val + tolerance;
1747 return f_min(val, max);
1748}
1749
1750/* return a template of (val-tolerance .. val+tolerance) ensuring it is within (min .. max) */
1751private function f_tolerance(integer val, integer min, integer max, integer tolerance)
1752return template integer {
1753 var template integer ret;
1754 ret := (f_tolerance_neg(val, min, tolerance) .. f_tolerance_pos(val, max, tolerance));
1755 return ret;
1756}
1757
1758
Harald Welte70767382018-02-21 12:16:40 +01001759/* build a template for matching measurement results against */
1760private function f_build_meas_res_tmpl() runs on ConnHdlr return template RSL_Message {
1761 var ConnL1Pars l1p := g_pars.l1_pars;
1762 var template RSL_IE_UplinkMeas ul_meas := {
1763 len := 3,
1764 rfu := '0'B,
1765 dtx_d := l1p.dtx_enabled,
Harald Welted5684392018-03-10 18:22:04 +01001766 rxlev_f_u := f_tolerance(l1p.meas_ul.full.rxlev, 0, 63, mp_tolerance_rxlev),
Harald Welte70767382018-02-21 12:16:40 +01001767 reserved1 := '00'B,
Harald Welted5684392018-03-10 18:22:04 +01001768 rxlev_s_u := f_tolerance(l1p.meas_ul.sub.rxlev, 0, 63, mp_tolerance_rxlev),
Harald Welte70767382018-02-21 12:16:40 +01001769 reserved2 := '00'B,
Harald Welted5684392018-03-10 18:22:04 +01001770 rxq_f_u := f_tolerance(l1p.meas_ul.full.rxqual, 0, 7, mp_tolerance_rxqual),
1771 rxq_s_u := f_tolerance(l1p.meas_ul.sub.rxqual, 0, 7, mp_tolerance_rxqual),
Harald Welte70767382018-02-21 12:16:40 +01001772 supp_meas_info := omit
1773 };
Harald Welte685d5982018-02-27 20:42:05 +01001774 if (l1p.toa256_enabled) {
Harald Welte15de8ba2018-06-29 08:51:42 +02001775 ul_meas.len := (3+8);
1776 ul_meas.supp_meas_info := {
Pau Espin Pedrol121724c2018-09-28 15:58:12 +02001777 toa256_mean := f_tolerance(l1p.timing_offset_256syms, -63*256, 192*256, mp_tolerance_timing_offset_256syms),
Harald Welte15de8ba2018-06-29 08:51:42 +02001778 toa256_min := ?,
1779 toa256_max := ?,
1780 toa256_std_dev := ?
1781 }
Harald Welte685d5982018-02-27 20:42:05 +01001782 }
Harald Welte70767382018-02-21 12:16:40 +01001783 var template RSL_IE_BS_Power bs_power := {
1784 reserved := 0,
1785 epc := false,
1786 fpc := false,
1787 power_level := l1p.bs_power_level
1788 };
1789 var template RSL_IE_L1Info l1_info := {
1790 ms_power_lvl := l1p.ms_power_level,
1791 fpc := false,
1792 reserved := 0,
Pau Espin Pedrol121724c2018-09-28 15:58:12 +02001793 actual_ta := f_tolerance(l1p.ms_actual_ta, 0, 63, mp_tolerance_timing_offset_256syms/256)
Harald Welte70767382018-02-21 12:16:40 +01001794 };
1795 var uint8_t offs := toffs256s_to_rsl(l1p.timing_offset_256syms);
Pau Espin Pedrol121724c2018-09-28 15:58:12 +02001796 var template uint8_t t_toffs := f_tolerance(offs, 0, 255, mp_tolerance_timing_offset_256syms/256);
Harald Welte70767382018-02-21 12:16:40 +01001797 return tr_RSL_MEAS_RES_OSMO(g_chan_nr, g_next_meas_res_nr, ul_meas, bs_power, l1_info,
1798 ?, t_toffs);
1799}
1800
Philipp Maierdd841d32019-12-17 14:44:54 +01001801/* build a template for matching measurement results that do not contain any
1802 * MS related measurement (l1_info, l3_info and ms timing offset). */
1803private function f_build_meas_res_tmpl_empty() runs on ConnHdlr return template RSL_Message {
1804 var ConnL1Pars l1p := g_pars.l1_pars;
1805 var template RSL_IE_UplinkMeas ul_meas := {
1806 len := 3,
1807 rfu := '0'B,
1808 dtx_d := l1p.dtx_enabled,
1809 rxlev_f_u := ?,
1810 reserved1 := '00'B,
1811 rxlev_s_u := ?,
1812 reserved2 := '00'B,
1813 rxq_f_u := ?,
1814 rxq_s_u := ?,
1815 supp_meas_info := omit
1816 };
1817 if (l1p.toa256_enabled) {
1818 ul_meas.len := (3+8);
1819 ul_meas.supp_meas_info := {
1820 toa256_mean := f_tolerance(l1p.timing_offset_256syms, -63*256, 192*256, mp_tolerance_timing_offset_256syms),
1821 toa256_min := ?,
1822 toa256_max := ?,
1823 toa256_std_dev := ?
1824 }
1825 }
1826 var template RSL_IE_BS_Power bs_power := {
1827 reserved := 0,
1828 epc := false,
1829 fpc := false,
1830 power_level := l1p.bs_power_level
1831 };
1832
1833 return tr_RSL_MEAS_RES_EMPTY(g_chan_nr, g_next_meas_res_nr, ul_meas, bs_power);
1834}
1835
Harald Welte70767382018-02-21 12:16:40 +01001836/* verify we regularly receive measurement reports with incrementing numbers */
Vadim Yanitskiy41baf002018-10-04 17:44:50 +07001837altstep as_meas_res(boolean verify_meas := true) runs on ConnHdlr {
Harald Welte70767382018-02-21 12:16:40 +01001838 var RSL_Message rsl;
Philipp Maierdd841d32019-12-17 14:44:54 +01001839 var boolean chan_est := false;
1840
Vadim Yanitskiy41baf002018-10-04 17:44:50 +07001841 [not verify_meas] RSL.receive(tr_RSL_MEAS_RES(?)) { repeat; }
Philipp Maierdd841d32019-12-17 14:44:54 +01001842
1843 /* Receive osmocom specific measurement reports. This is the normal
1844 * case. Here we verify that the measurement reports we sent are
1845 * comming back as we expect them. */
Harald Welte70767382018-02-21 12:16:40 +01001846 [] RSL.receive(f_build_meas_res_tmpl()) -> value rsl {
1847 /* increment counter of next to-be-expected meas rep */
1848 g_next_meas_res_nr := (g_next_meas_res_nr + 1) mod 256;
1849 /* Re-start the timer expecting the next MEAS RES */
Harald Weltec3a3f452018-02-26 17:37:47 +01001850 f_timer_safe_restart(g_Tmeas_exp);
Philipp Maierdd841d32019-12-17 14:44:54 +01001851
1852 /* The following two cases may only happen in the beginning
1853 * of the channel establishment phase. Once we have received
1854 * the "our" measurement report the first time, the channel
1855 * is established and empty or hardcoded TRXCON reports must
1856 * not occur anymore. */
1857 chan_est := true;
1858
1859 repeat;
1860 }
1861
1862 /* When the BTS has established the channel, the MS might need slightly
1863 * more time to establish the channel and actually start sending. The
1864 * result is then a measurement report that just lacks the measurement
1865 * information of the MS. This is normal and we tolerate this behavior. */
1866 [chan_est == false] RSL.receive(f_build_meas_res_tmpl_empty()) -> value rsl {
1867 /* increment counter of next to-be-expected meas rep */
1868 g_next_meas_res_nr := (g_next_meas_res_nr + 1) mod 256;
1869 /* Re-start the timer expecting the next MEAS RES */
1870 f_timer_safe_restart(g_Tmeas_exp);
Harald Welte70767382018-02-21 12:16:40 +01001871 repeat;
1872 }
Philipp Maierdd841d32019-12-17 14:44:54 +01001873
1874 /* Due to the TDMA nature of GSM, TRXCON implements a way to emit dummy
1875 * measurements if the TTCN3 side does not supply measurement input in
1876 * time. In those cases TRXCON will either use a cached measurement
1877 * report or a hardcoded one. If TRXCON picks the hardcoded measurement
1878 * report the templates above will not match. We tolerate this
1879 * behavior, but only once. */
1880 [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 +01001881 /* increment counter of next to-be-expected meas rep */
1882 g_next_meas_res_nr := (g_next_meas_res_nr + 1) mod 256;
1883 if (g_first_meas_res) {
1884 g_first_meas_res := false;
1885 repeat;
1886 } else {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001887 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Received unspecific MEAS RES ", rsl));
Harald Weltefa45e9e2018-03-10 18:59:03 +01001888 }
Harald Welte70767382018-02-21 12:16:40 +01001889 }
1890 [] RSL.receive(tr_RSL_MEAS_RES(?)) -> value rsl {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001891 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Received unexpected MEAS RES ", rsl));
Harald Welte70767382018-02-21 12:16:40 +01001892 }
Pau Espin Pedrol425b62f2018-07-06 16:11:43 +02001893 [g_Tmeas_exp.running] g_Tmeas_exp.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001894 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Didn't receive expected measurement result")
Harald Welte70767382018-02-21 12:16:40 +01001895 }
1896}
1897
Harald Weltee613f962018-04-18 22:38:16 +02001898private function f_alg_id_to_l1ctl(RSL_AlgId rsl_alg_id) return uint8_t {
1899 select (rsl_alg_id) {
1900 case (RSL_ALG_ID_A5_0) { return 0; }
1901 case (RSL_ALG_ID_A5_1) { return 1; }
1902 case (RSL_ALG_ID_A5_2) { return 2; }
1903 case (RSL_ALG_ID_A5_3) { return 3; }
1904 case (RSL_ALG_ID_A5_4) { return 4; }
1905 case (RSL_ALG_ID_A5_5) { return 5; }
1906 case (RSL_ALG_ID_A5_6) { return 6; }
1907 case (RSL_ALG_ID_A5_7) { return 7; }
1908 case else {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001909 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unknwon Algorithm ID");
1910 /* Make compiler happy by calling mtc.stop here. It is already
1911 * called in f_shutdown */
Daniel Willmann17ddd852018-07-05 17:33:20 +02001912 mtc.stop;
Harald Weltee613f962018-04-18 22:38:16 +02001913 }
1914 }
1915}
1916
1917private function f_alg_id_to_l3(RSL_AlgId rsl_alg_id) return BIT3 {
1918 select (rsl_alg_id) {
1919 case (RSL_ALG_ID_A5_1) { return '000'B; }
1920 case (RSL_ALG_ID_A5_2) { return '001'B; }
1921 case (RSL_ALG_ID_A5_3) { return '010'B; }
1922 case (RSL_ALG_ID_A5_4) { return '011'B; }
1923 case (RSL_ALG_ID_A5_5) { return '100'B; }
1924 case (RSL_ALG_ID_A5_6) { return '101'B; }
1925 case (RSL_ALG_ID_A5_7) { return '110'B; }
1926 case else {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02001927 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unknwon Algorithm ID");
1928 /* Make compiler happy by calling mtc.stop here. It is already
1929 * called in f_shutdown */
Daniel Willmann17ddd852018-07-05 17:33:20 +02001930 mtc.stop;
Harald Weltee613f962018-04-18 22:38:16 +02001931 }
1932 }
1933}
1934
Pau Espin Pedrol6451b042018-10-24 20:36:16 +02001935/* Send RACH request through l1CTL and wait for ChanReq on RSL BST->BSC */
1936private function f_rach_req_wait_chan_rqd(integer ra) runs on ConnHdlr return GsmFrameNumber {
1937 var GsmFrameNumber fn;
1938 timer T := 8.0;
1939
1940 /* advertise to RSL Emulation that we expect to receive confirmation from RACH */
1941 RSL.send(ts_RSLDC_ChanRqd_anyFN(int2oct(ra,1)));
1942
1943 f_L1CTL_PARAM(L1CTL, g_pars.l1_pars.ms_actual_ta, g_pars.l1_pars.ms_power_level);
1944 /* Send the actual RACH */
1945 fn := f_L1CTL_RACH(L1CTL, ra);
1946
1947 T.start;
1948 alt {
1949 [] RSL.receive(tr_RSL_CHAN_RQD(int2oct(ra,1), fn)) { setverdict(pass, "Received CHAN-RQD from RACH REQ") }
1950 [] T.timeout {
1951 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Timeout waiting for CHAN-RQD from RACH REQ <", ra, ", ", fn, ">"));
1952 }
1953 }
1954 T.stop
1955 return fn;
1956}
Harald Weltee613f962018-04-18 22:38:16 +02001957
Harald Welte70767382018-02-21 12:16:40 +01001958/* Establish dedicated channel: L1CTL + RSL side */
Harald Weltec8d363c2019-05-19 20:36:48 +02001959private function f_est_dchan(boolean encr_enable := false, RSL_IE_List more_ies := {}) runs on ConnHdlr {
Harald Welte70767382018-02-21 12:16:40 +01001960 var GsmFrameNumber fn;
1961 var ImmediateAssignment imm_ass;
Vadim Yanitskiy28cabc42020-05-27 19:44:44 +07001962 var ChannelDescription ch_desc;
Harald Welte70767382018-02-21 12:16:40 +01001963 var integer ra := 23;
1964
Pau Espin Pedrol6451b042018-10-24 20:36:16 +02001965 /* Send RACH request and wait for ChanReq */
1966 fn := f_rach_req_wait_chan_rqd(ra);
Harald Welte70767382018-02-21 12:16:40 +01001967
1968 /* Activate channel on BTS side */
Harald Weltec8d363c2019-05-19 20:36:48 +02001969 f_rsl_chan_act(g_pars.chan_mode, encr_enable, more_ies);
Harald Welte70767382018-02-21 12:16:40 +01001970
Vadim Yanitskiy28cabc42020-05-27 19:44:44 +07001971 /* Craft channel description (with or without frequency hopping parameters) */
1972 if (ispresent(g_pars.maio_hsn)) {
1973 ch_desc := valueof(ts_ChanDescH1(g_pars.chan_nr, maio_hsn := g_pars.maio_hsn));
1974 } else {
1975 ch_desc := valueof(ts_ChanDescH0(g_pars.chan_nr));
1976 }
1977
Harald Welte70767382018-02-21 12:16:40 +01001978 /* Send IMM.ASS via CCHAN */
Vadim Yanitskiy28cabc42020-05-27 19:44:44 +07001979 var GsmRrMessage rr_msg := valueof(ts_IMM_ASS(ra, fn, 0, ch_desc, g_pars.ma_map));
Harald Welte70767382018-02-21 12:16:40 +01001980 RSL.send(ts_RSL_IMM_ASSIGN(enc_GsmRrMessage(rr_msg)));
1981
1982 /* receive IMM.ASS on MS side */
1983 var ImmediateAssignment ia_um;
1984 ia_um := f_L1CTL_WAIT_IMM_ASS(L1CTL, ra, fn);
Vadim Yanitskiy28cabc42020-05-27 19:44:44 +07001985
1986 /* Make sure that IMM.ASS contains hopping parameters (if enabled) */
1987 if (ch_desc.h != ia_um.chan_desc.h) {
1988 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Hopping parameters mismatch");
1989 }
1990
Harald Welte70767382018-02-21 12:16:40 +01001991 /* enable dedicated mode */
Vadim Yanitskiy28cabc42020-05-27 19:44:44 +07001992 f_L1CTL_DM_EST_REQ_IA(L1CTL, ia_um, ma := g_pars.ma);
Harald Weltee613f962018-04-18 22:38:16 +02001993 /* enable encryption, if requested */
1994 if (encr_enable) {
1995 var uint8_t alg_id := f_alg_id_to_l1ctl(g_pars.encr.alg_id);
1996 f_L1CTL_CRYPTO_REQ(L1CTL, g_pars.chan_nr, alg_id, g_pars.encr.key);
1997 }
Harald Weltefa45e9e2018-03-10 18:59:03 +01001998
1999 g_first_meas_res := true;
Harald Welte70767382018-02-21 12:16:40 +01002000}
2001
2002/* establish DChan, verify existance + contents of measurement reports */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07002003private function f_TC_meas_res_periodic(charstring id) runs on ConnHdlr {
Harald Welte68e495b2018-02-25 00:05:57 +01002004 f_l1_tune(L1CTL);
Harald Welte70767382018-02-21 12:16:40 +01002005 RSL.clear;
2006
Vadim Yanitskiy44ff2142019-01-12 07:04:58 +07002007 if (mp_bts_trxc_port != -1) {
Pau Espin Pedrole9571aa2018-10-22 17:13:07 +02002008 f_trxc_fake_rssi(rxlev2dbm(mp_ul_rxlev_exp));
Vadim Yanitskiydc8db922019-06-04 21:58:15 +07002009 f_trxc_fake_toffs256(g_pars.l1_pars.timing_offset_256syms);
Pau Espin Pedrol121724c2018-09-28 15:58:12 +02002010 }
Harald Welte70767382018-02-21 12:16:40 +01002011
2012 f_est_dchan();
2013
2014 /* run for a number of seconds, send SACCH + FACCH from MS side and verify
2015 * RSL measurement reports on Abis side */
2016 timer T := 8.0;
2017 T.start;
2018 alt {
2019 [] as_l1_sacch();
2020 [] as_meas_res();
2021 [] as_l1_dcch();
2022 [] L1CTL.receive { repeat; }
2023 [g_Tmeas_exp.running] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002024 /* as_meas_res() would have done Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail) in case
Harald Welte70767382018-02-21 12:16:40 +01002025 * of any earlier errors, so if we reach this timeout, we're good */
2026 setverdict(pass);
2027 }
2028 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002029 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "No MEAS RES received at all");
Harald Welte70767382018-02-21 12:16:40 +01002030 }
2031 }
2032 f_rsl_chan_deact();
Harald Welte3dc20462018-03-10 23:03:38 +01002033 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
Harald Welte70767382018-02-21 12:16:40 +01002034}
Harald Welte0472ab42018-03-12 15:02:26 +01002035
Pau Espin Pedrolb6985f92020-06-23 14:01:02 +02002036/* Wait until the BTS has reached full tx power (nominal tx power minus configured attenuation) */
2037private function f_wait_ramp_up() runs on ConnHdlr return integer {
Pau Espin Pedrola2e079c2020-06-03 17:31:04 +02002038 var L1ctlDlMessage l1_dl;
Pau Espin Pedrolb6985f92020-06-23 14:01:02 +02002039 var integer max_rx_lvl := mp_bts_tx_nom_pwr_exp - mp_bts_tx_pwr_att_exp;
2040 timer Tup := 10.0;
2041 Tup.start;
2042 alt {
2043 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl {
2044 var GsmRxLev rx_lvl := l1_dl.dl_info.rx_level;
2045 log("Received rx_level=", rx_lvl);
Pau Espin Pedrola2e079c2020-06-03 17:31:04 +02002046
Pau Espin Pedrolb6985f92020-06-23 14:01:02 +02002047 if (rx_lvl != max_rx_lvl) {
2048 repeat;
2049 }
2050 Tup.stop;
2051 }
2052 [] L1CTL.receive { repeat; }
2053 [] Tup.timeout {
2054 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
2055 log2str("Didn't reach full power ", max_rx_lvl));
2056 }
2057 }
2058 return max_rx_lvl;
2059}
2060
2061/* verify BTS ramps power up to full tx power (nominal tx power minus configured attenuation) */
2062private function f_verify_ramp_up() runs on ConnHdlr {
2063 var L1ctlDlMessage l1_dl;
Pau Espin Pedrola2e079c2020-06-03 17:31:04 +02002064 var integer initial_rx_lvl := -1;
2065 var integer last_rx_lvl := -1;
2066 var integer max_rx_lvl := mp_bts_tx_nom_pwr_exp - mp_bts_tx_pwr_att_exp;
2067
2068 timer T := 2.0;
2069 alt {
2070 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl {
2071 var GsmRxLev rx_lvl := l1_dl.dl_info.rx_level;
2072 log("Received rx_level=", rx_lvl);
2073 if (initial_rx_lvl == -1) {
2074 initial_rx_lvl := rx_lvl;
2075 last_rx_lvl := rx_lvl;
2076
2077 /* Expect a somehow low value during first received messages */
2078 if (initial_rx_lvl >= max_rx_lvl / 2) {
2079 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
2080 log2str("Detected high initial tx power during ramp up: ",
2081 initial_rx_lvl , ", full power is", max_rx_lvl));
2082 }
2083 }
2084
2085 /* received Rx level bigger than maximum allowed power by CN */
2086 if (rx_lvl > max_rx_lvl) {
2087 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
2088 log2str("Detected Tx power higher than full power: ",
2089 rx_lvl , " > ", max_rx_lvl));
2090 }
2091
2092 /* Make sure it never decreases, since we are rumping up */
2093 if (last_rx_lvl > rx_lvl) {
2094 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
2095 log2str("Detected Tx power decrease during ramp up: ",
2096 last_rx_lvl , " -> ", rx_lvl));
2097 }
2098
2099 if (rx_lvl == max_rx_lvl and not T.running) {
2100 /* We reached the maximum power, start timer and receive
2101 /* a few more to make sure we don't surpass it */
2102 log("Reached full power, wating a bit more until success");
2103 T.start;
2104 }
2105
2106 last_rx_lvl := rx_lvl;
2107 repeat;
2108 }
2109 [] L1CTL.receive { repeat; }
2110 [] T.timeout { }
2111 }
2112
2113 /* We didn't increase tx power during ramp up */
2114 if (initial_rx_lvl < last_rx_lvl) {
2115 log("Tx power increased during ramp up: ", initial_rx_lvl , " -> ", last_rx_lvl);
2116 } else {
2117 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
2118 log2str("No Tx power increase during whole ramp up: ",
2119 initial_rx_lvl , " -> ", last_rx_lvl));
2120 }
Pau Espin Pedrolb6985f92020-06-23 14:01:02 +02002121}
2122
2123/* verify BTS ramps power down to rx_level 0 */
2124private function f_verify_ramp_down(integer max_rx_lvl) runs on ConnHdlr {
2125 var L1ctlDlMessage l1_dl;
2126 var integer last_rx_lvl := max_rx_lvl;
2127
2128 timer Tdown := 5.0;
2129 Tdown.start;
2130 alt {
2131 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl {
2132 var GsmRxLev rx_lvl := l1_dl.dl_info.rx_level;
2133 log("Received rx_level=", rx_lvl);
2134
2135 /* received Rx level bigger than maximum allowed power by CN */
2136 if (rx_lvl > max_rx_lvl) {
2137 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
2138 log2str("Detected Tx power higher than full power: ",
2139 rx_lvl , " > ", max_rx_lvl));
2140 }
2141
2142 /* Make sure it never increases, since we are rumping down */
2143 if (last_rx_lvl < rx_lvl) {
2144 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
2145 log2str("Detected Tx power increase during ramp up: ",
2146 last_rx_lvl , " -> ", rx_lvl));
2147 }
2148
2149 last_rx_lvl := rx_lvl;
2150 if (last_rx_lvl != 0) {
2151 repeat;
2152 }
2153 /* we reached power level 0, we are done */
2154 Tdown.stop;
2155 }
2156 [] L1CTL.receive { repeat; }
2157 [] Tdown.timeout { }
2158 }
2159
2160 /* We didn't increase tx power during ramp down */
2161 if (max_rx_lvl > last_rx_lvl) {
2162 log("Tx power decreased during ramp down: ", max_rx_lvl , " -> ", last_rx_lvl);
2163 } else {
2164 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
2165 log2str("No Tx power decrease during whole ramp down: ",
2166 max_rx_lvl , " -> ", last_rx_lvl));
2167 }
2168}
2169
2170/* Verify Tx power reduction and ramping up during BTS bring up */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07002171private function f_TC_tx_power_start_ramp_up_bcch(charstring id) runs on ConnHdlr {
Pau Espin Pedrolb6985f92020-06-23 14:01:02 +02002172 f_l1_tune(L1CTL);
2173 RSL.clear;
2174
2175 f_verify_ramp_up();
Pau Espin Pedrola2e079c2020-06-03 17:31:04 +02002176
2177 setverdict(pass);
2178}
2179testcase TC_tx_power_start_ramp_up_bcch() runs on test_CT {
2180 var ConnHdlr vc_conn;
2181 var ConnHdlrPars pars;
2182 f_init();
2183 pars := valueof(t_Pars(t_RslChanNr_Bm(0), ts_RSL_ChanMode_SIGN));
2184 vc_conn := f_start_handler(refers(f_TC_tx_power_start_ramp_up_bcch), pars,
2185 pcu_comp := false, trxc_comp := true);
2186 vc_conn.done;
2187 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
2188}
2189
Pau Espin Pedrolb6985f92020-06-23 14:01:02 +02002190/* Verify Tx power reduction and ramping downd uring BTS bring shutdown due to Abis link failure */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07002191private function f_TC_tx_power_start_ramp_down_bcch(charstring id) runs on ConnHdlr {
Pau Espin Pedrolb6985f92020-06-23 14:01:02 +02002192 f_connhdlr_init_vty_bsc();
2193
2194 f_l1_tune(L1CTL);
2195 RSL.clear;
2196
2197 /* Wait until BTS is started and at full power */
2198 var integer max_rx_lvl := f_wait_ramp_up();
2199 log("Reached nominal level ", max_rx_lvl, ", shutting down OML link");
2200
2201 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
2202 f_verify_ramp_down(max_rx_lvl);
2203
2204 setverdict(pass);
2205}
2206testcase TC_tx_power_start_ramp_down_bcch() runs on test_CT {
2207 var ConnHdlr vc_conn;
2208 var ConnHdlrPars pars;
2209 f_init();
2210 pars := valueof(t_Pars(t_RslChanNr_Bm(0), ts_RSL_ChanMode_SIGN));
2211 vc_conn := f_start_handler(refers(f_TC_tx_power_start_ramp_down_bcch), pars,
2212 pcu_comp := false, trxc_comp := true);
2213 vc_conn.done;
2214 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
2215}
2216
Pau Espin Pedrol45fe5e02020-06-23 19:00:00 +02002217/* Verify Tx power:
2218 * + ramping down during ADM state UNLOCKED->LOCKED
2219 * + ramping up during ADM state LOCKED->UNLOCKED
2220 */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07002221private function f_TC_tx_power_ramp_adm_state_change(charstring id) runs on ConnHdlr {
Pau Espin Pedrol45fe5e02020-06-23 19:00:00 +02002222 var L1ctlDlMessage l1_dl;
2223 var integer last_rx_lvl;
2224
2225 f_connhdlr_init_vty_bsc();
2226
2227 f_l1_tune(L1CTL);
2228 RSL.clear;
2229
2230 /* Wait until BTS is started and at full power */
2231 var integer max_rx_lvl := f_wait_ramp_up();
2232 log("Reached nominal level ", max_rx_lvl, ", changing ADM state to LOCKED");
2233
2234 log("ADM STATE UNLOCKED->LOCKED");
2235 f_vty_enter_cfg_trx(BSCVTY);
2236 f_vty_transceive(BSCVTY, "rf_locked 1");
2237 last_rx_lvl := max_rx_lvl;
2238 f_verify_ramp_down(max_rx_lvl);
2239
2240 /* Let some time after we received 0dBm, then check we don't receive BCCH
2241 * anymore because scheduler has stopped after ramping down */
2242 f_sleep(2.0);
2243 L1CTL.clear;
2244 timer Tlocked := 2.0;
2245 Tlocked.start;
2246 alt {
2247 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl {
2248 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
2249 log2str("Received data_ind during rf_locked: ", l1_dl));
2250 }
2251 [] L1CTL.receive { repeat; }
2252 [] Tlocked.timeout { setverdict(pass, "Didn't receive data_ind while in rf_locked state."); }
2253 }
2254
2255 log("ADM STATE LOCKED->UNLOCKED");
2256 f_vty_transceive(BSCVTY, "rf_locked 0");
2257 f_verify_ramp_up();
2258 setverdict(pass);
2259}
2260testcase TC_tx_power_ramp_adm_state_change() runs on test_CT {
2261 var ConnHdlr vc_conn;
2262 var ConnHdlrPars pars;
2263 f_init();
2264 pars := valueof(t_Pars(t_RslChanNr_Bm(0), ts_RSL_ChanMode_SIGN));
2265 vc_conn := f_start_handler(refers(f_TC_tx_power_ramp_adm_state_change), pars,
2266 pcu_comp := false, trxc_comp := true);
2267 vc_conn.done;
2268 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
2269}
2270
Eric Wildae8f2622019-06-18 17:05:11 +02002271function f_check_meas_bs_power_level(integer level) runs on ConnHdlr {
2272 timer T := 8.0;
2273 T.start;
2274 var RSL_Message rsl;
2275 alt {
2276 [] as_l1_sacch();
2277 [] L1CTL.receive { repeat; }
2278 [] RSL.receive(tr_RSL_MEAS_RES(g_chan_nr, ?, ?, ?)) -> value rsl {
2279 if (rsl.ies[3].body.bs_power.power_level == level) {
2280 setverdict(pass)
2281 } else {
2282 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Received wrong BS power level in MEAS RES ", rsl));
2283 }
2284 }
2285 [] T.timeout {
2286 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "No MEAS RES received at all");
2287 }
2288 }
2289}
2290
2291/* see if the rsl meas res contains our expeced bs power level
2292bs power set during assignment */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07002293private function f_TC_rsl_bs_pwr_static_ass(charstring id) runs on ConnHdlr {
Eric Wildae8f2622019-06-18 17:05:11 +02002294 f_l1_tune(L1CTL);
2295 RSL.clear;
2296
2297 if (mp_bts_trxc_port != -1) {
2298 f_trxc_fake_rssi(rxlev2dbm(mp_ul_rxlev_exp));
2299 f_trxc_fake_toffs256(g_pars.l1_pars.timing_offset_256syms);
2300 }
2301
Vadim Yanitskiy117c1762020-06-16 01:40:10 +07002302 var uint4_t pwr_var := 1;
Eric Wildae8f2622019-06-18 17:05:11 +02002303 var template (value) RSL_IE_BS_Power bs_power := ts_RSL_IE_BS_Power(pwr_var);
2304 var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_BS_POWER, RSL_IE_Body:{bs_power := bs_power});
2305
2306 f_est_dchan(more_ies :={valueof(pwr)});
2307
2308 f_check_meas_bs_power_level(pwr_var);
2309
2310 f_rsl_chan_deact();
2311 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
2312}
2313
2314/* see if the rsl meas res contains our expeced bs power level
2315bs power set after assignment */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07002316private function f_TC_rsl_bs_pwr_static_power_control(charstring id) runs on ConnHdlr {
Eric Wildae8f2622019-06-18 17:05:11 +02002317 f_l1_tune(L1CTL);
2318 RSL.clear;
2319
2320 if (mp_bts_trxc_port != -1) {
2321 f_trxc_fake_rssi(rxlev2dbm(mp_ul_rxlev_exp));
2322 f_trxc_fake_toffs256(g_pars.l1_pars.timing_offset_256syms);
2323 }
2324
Vadim Yanitskiy117c1762020-06-16 01:40:10 +07002325 var uint4_t pwr_var := 1;
Eric Wildae8f2622019-06-18 17:05:11 +02002326 var template (value) RSL_IE_BS_Power bs_power := ts_RSL_IE_BS_Power(pwr_var);
2327
2328 f_est_dchan();
2329
2330 RSL.send(ts_RSL_BS_PWR_CTRL(g_chan_nr, bs_power));
2331
2332 f_check_meas_bs_power_level(pwr_var);
2333
2334 f_rsl_chan_deact();
2335 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
2336}
2337
2338testcase TC_rsl_bs_pwr_static_ass() runs on test_CT {
2339 var ConnHdlr vc_conn;
2340 var ConnHdlrPars pars;
2341 f_init();
2342 for (var integer tn := 1; tn <= 4; tn := tn+1) {
2343 pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN));
2344 vc_conn := f_start_handler(refers(f_TC_rsl_bs_pwr_static_ass), pars,
2345 pcu_comp := false, trxc_comp := true);
2346 vc_conn.done;
2347 }
2348 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
2349}
2350
2351testcase TC_rsl_bs_pwr_static_power_control() runs on test_CT {
2352 var ConnHdlr vc_conn;
2353 var ConnHdlrPars pars;
2354 f_init();
2355 for (var integer tn := 1; tn <= 4; tn := tn+1) {
2356 pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN));
2357 vc_conn := f_start_handler(refers(f_TC_rsl_bs_pwr_static_power_control), pars,
2358 pcu_comp := false, trxc_comp := true);
2359 vc_conn.done;
2360 }
2361 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
2362}
2363
Eric Wild61edb7e2019-06-03 12:38:31 +02002364/* target level -100, first rssi -90, ms power 7, expected increase to 7+6 within 6 seconds,
2365second rssi -110, ms power 7+6, expected decrease to 7 within 6 seconds,
2366These power levels are valid for all bands and require no special handling */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07002367private function f_TC_rsl_ms_pwr_dyn_ass_updown(charstring id) runs on ConnHdlr {
Eric Wild61edb7e2019-06-03 12:38:31 +02002368 var uint5_t pwr_var := 7;
2369 var L1ctlDlMessage l1_dl;
2370
2371 f_trxc_fake_rssi(rxlev2dbm(10));
2372 f_l1_tune(L1CTL);
2373 RSL.clear;
2374
2375 var RSL_IE_List addl_ies;
2376 var template (value) RSL_IE_MS_Power_Parameters pp := (ts_RSL_IE_MS_Power_Parameters(''O));
2377
2378 addl_ies := {
2379 valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(pwr_var)})),
2380 valueof(t_RSL_IE(RSL_IE_MS_POWER_PARAM, RSL_IE_Body:{ms_power_params := pp}))
2381 };
2382
2383 /* establish with power parameters */
2384 f_est_dchan(more_ies := addl_ies);
2385
2386 /* set a high value to ensure L1 power control level increases */
2387 f_trxc_fake_rssi(rxlev2dbm(20));
2388
2389 timer T2 := 6.0;
2390 T2.start;
2391 alt {
2392 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl {
Pau Espin Pedrola1f7d242019-12-04 16:08:09 +01002393 /* Update sent MS power to follow what BTS requests */
2394 f_L1CTL_PARAM(L1CTL, g_pars.l1_pars.ms_actual_ta, oct2int(l1_dl.payload.data_ind.payload[0]));
2395 if (oct2int(l1_dl.payload.data_ind.payload[0]) < (pwr_var + 6)) {
Eric Wild61edb7e2019-06-03 12:38:31 +02002396 repeat;
Pau Espin Pedrola1f7d242019-12-04 16:08:09 +01002397 }
Eric Wild61edb7e2019-06-03 12:38:31 +02002398 T2.stop;
2399 }
2400 [] L1CTL.receive { repeat; }
2401 [] T2.timeout {
2402 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
2403 "Power Level in L1 header has not increased sufficiently");
2404 }
2405 }
2406
2407 /* set a low value to ensure L1 power control level decreases */
2408 f_trxc_fake_rssi(rxlev2dbm(0));
2409
2410 timer T4 := 6.0;
2411 T4.start;
2412 alt {
2413 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl {
Pau Espin Pedrola1f7d242019-12-04 16:08:09 +01002414 /* Update sent MS power to follow what BTS requests */
2415 f_L1CTL_PARAM(L1CTL, g_pars.l1_pars.ms_actual_ta, oct2int(l1_dl.payload.data_ind.payload[0]));
2416 if (oct2int(l1_dl.payload.data_ind.payload[0]) > pwr_var) {
Eric Wild61edb7e2019-06-03 12:38:31 +02002417 repeat;
Pau Espin Pedrola1f7d242019-12-04 16:08:09 +01002418 }
Eric Wild61edb7e2019-06-03 12:38:31 +02002419 T4.stop;
2420 setverdict(pass, "Power level in L1 decreased/increased as expected");
2421 }
2422 [] L1CTL.receive { repeat; }
2423 [] T4.timeout {
2424 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
2425 "Power Level in L1 header has not decreased sufficiently");
2426 }
2427 }
2428
2429 f_rsl_chan_deact();
2430 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
2431
2432}
2433
2434/* check that we do not exceed the max power */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07002435private function f_TC_rsl_ms_pwr_dyn_max(charstring id) runs on ConnHdlr {
Eric Wild61edb7e2019-06-03 12:38:31 +02002436 var uint5_t pwr_var := 7;
2437 var L1ctlDlMessage l1_dl;
2438
2439 /* set a low value to ensure power increases */
2440 f_trxc_fake_rssi(rxlev2dbm(10));
2441 f_l1_tune(L1CTL);
2442 RSL.clear;
2443
2444 var RSL_IE_List addl_ies;
2445 var template (value) RSL_IE_MS_Power_Parameters pp := (ts_RSL_IE_MS_Power_Parameters(''O));
2446
2447 addl_ies := {
2448 valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(pwr_var)})),
2449 valueof(t_RSL_IE(RSL_IE_MS_POWER_PARAM, RSL_IE_Body:{ms_power_params := pp}))
2450 };
2451
2452 /* establish with power parameters */
2453 f_est_dchan(more_ies := addl_ies);
2454
2455 timer T1 := 10.0;
2456 T1.start;
2457 alt {
Pau Espin Pedrola1f7d242019-12-04 16:08:09 +01002458 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl {
2459 /* Update sent MS power to follow what BTS requests */
2460 f_L1CTL_PARAM(L1CTL, g_pars.l1_pars.ms_actual_ta, oct2int(l1_dl.payload.data_ind.payload[0]));
2461 repeat;
2462 }
Eric Wild61edb7e2019-06-03 12:38:31 +02002463 [] L1CTL.receive { repeat; }
2464 [] T1.timeout {
2465 if( oct2int(l1_dl.payload.data_ind.payload[0]) != pwr_var){
2466 setverdict(fail, "Power level in L1 header should not have changed");
2467 }
2468 }
2469 }
2470
2471 f_rsl_chan_deact();
2472 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
2473
2474}
2475
2476/* see if we reach the band max power */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07002477private function f_TC_rsl_ms_pwr_dyn_up(charstring id) runs on ConnHdlr {
Eric Wild61edb7e2019-06-03 12:38:31 +02002478 var L1ctlDlMessage l1_dl;
2479 var uint5_t pwr_var := 15;
2480 var uint5_t pwr_max_var := f_get_max_power_from_band();
2481
2482 /* set a low value to ensure power increases */
2483 f_trxc_fake_rssi(rxlev2dbm(10));
2484 f_l1_tune(L1CTL);
2485 RSL.clear;
2486
2487 var template (value) RSL_IE_MS_Power ms_power := ts_RSL_IE_MS_Power(pwr_var);
2488 var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power});
2489
2490 /* establish with fixed power level */
2491 f_est_dchan(more_ies :={valueof(pwr)});
2492
2493 /* check our initial power level */
2494 f_wait_for_l1_power_level(pwr_var);
2495
2496 /* update power param to enable power loop
2497 48.058 The maximum power to be used is indicated in the BS and MS Power elements respectively. */
2498 RSL.send(ts_RSL_MS_PWR_CTRL_with_pp(g_chan_nr, pwr_max_var));
2499
2500 /* wait, then check that our power level was reduced */
2501 timer T1 := 10.0;
2502 T1.start;
2503 alt {
Pau Espin Pedrola1f7d242019-12-04 16:08:09 +01002504 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl {
2505 /* Update sent MS power to follow what BTS requests */
2506 f_L1CTL_PARAM(L1CTL, g_pars.l1_pars.ms_actual_ta, oct2int(l1_dl.payload.data_ind.payload[0]));
2507 repeat;
2508 }
Eric Wild61edb7e2019-06-03 12:38:31 +02002509 [] L1CTL.receive { repeat; }
2510 [] T1.timeout {
2511 var int8_t rcv := oct2int(l1_dl.payload.data_ind.payload[0]);
2512 if( f_power_level_is_highest_dbm(rcv) ){
2513 setverdict(pass, "Power level in L1 header reduced as expected");
2514 } else {
2515 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
2516 log2str("Power Level in L1 header did not reach the expected value, e:",pwr_max_var," r:",rcv));
2517 }
2518 }
2519 }
2520
2521 f_rsl_chan_deact();
2522 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
2523
2524}
2525
2526/* see if we reach the band min power */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07002527private function f_TC_rsl_ms_pwr_dyn_down(charstring id) runs on ConnHdlr {
Eric Wild61edb7e2019-06-03 12:38:31 +02002528 var L1ctlDlMessage l1_dl;
2529
2530 /* set a high value to ensure power decreases */
2531 f_trxc_fake_rssi(rxlev2dbm(50));
2532 f_l1_tune(L1CTL);
2533 RSL.clear;
2534
2535 var uint5_t pwr_var := 5;
2536 var uint5_t pwr_target_val := 15;
2537
2538 var template (value) RSL_IE_MS_Power ms_power := ts_RSL_IE_MS_Power(pwr_var);
2539 var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power});
2540
2541 /* establish with fixed power level */
2542 f_est_dchan(more_ies :={valueof(pwr)});
2543
2544 /* check our initial power level */
2545 f_wait_for_l1_power_level(pwr_var);
2546
2547 /* update power param to enable power loop
2548 as per spec the supplied ms power IE should set the max allowed power...*/
Pau Espin Pedrol61122c82019-11-05 13:50:27 +01002549 RSL.send(ts_RSL_MS_PWR_CTRL_with_pp(g_chan_nr, pwr_target_val));
Eric Wild61edb7e2019-06-03 12:38:31 +02002550
2551 /* wait, then check that our power level was increased */
2552 timer T1 := 10.0;
2553 T1.start;
2554 alt {
Pau Espin Pedrola1f7d242019-12-04 16:08:09 +01002555 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl {
2556 /* Update sent MS power to follow what BTS requests */
2557 f_L1CTL_PARAM(L1CTL, g_pars.l1_pars.ms_actual_ta, oct2int(l1_dl.payload.data_ind.payload[0]));
2558 repeat;
2559 }
Eric Wild61edb7e2019-06-03 12:38:31 +02002560 [] L1CTL.receive { repeat; }
2561 [] T1.timeout {
2562 if( f_power_level_is_lowest_dbm(oct2int(l1_dl.payload.data_ind.payload[0])) ){
2563 setverdict(pass, "Power level in L1 header increased to lowest power value");
2564 } else {
2565 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
2566 "Power level in L1 header NOT increased to lowest power value");
2567 }
2568 }
2569 }
2570
2571 f_rsl_chan_deact();
2572 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
2573
2574}
2575
Eric Wild095024b2019-06-17 15:08:57 +02002576/* see if we change the power level without receiving power parameters, which should not happen
2577rsl chan act WITHOUT power parameters */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07002578private function f_TC_rsl_ms_pwr_dyn_active(charstring id) runs on ConnHdlr {
Eric Wild280ccb82019-06-17 11:11:52 +02002579 var L1ctlDlMessage l1_dl;
2580
2581 /* set a high value to ensure power decreases */
2582 f_trxc_fake_rssi(rxlev2dbm(50));
2583 f_l1_tune(L1CTL);
2584 RSL.clear;
2585
2586 var uint5_t pwr_var := 5;
2587
2588 var template (value) RSL_IE_MS_Power ms_power := ts_RSL_IE_MS_Power(pwr_var);
2589 var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power});
2590
2591 /* establish with fixed power level */
2592 f_est_dchan(more_ies :={valueof(pwr)});
2593
2594 /* check our initial power level */
2595 f_wait_for_l1_power_level(pwr_var);
2596
2597 /* wait, then check that our power level did not change */
2598 timer T1 := 10.0;
2599 T1.start;
2600 alt {
2601 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl {
2602 if ( oct2int(l1_dl.payload.data_ind.payload[0]) != pwr_var) {
2603 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
2604 "BS power control should not be active unless we receive a power parameters IE!");
2605 }
2606 repeat;
2607 }
2608 [] L1CTL.receive { repeat; }
2609 [] T1.timeout { setverdict(pass); }
2610 }
2611
2612 f_rsl_chan_deact();
2613 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
2614
2615}
2616
Eric Wild095024b2019-06-17 15:08:57 +02002617/* see if we change the power level without receiving power parameters, which should not happen
2618ms power control WITHOUT power parameters */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07002619private function f_TC_rsl_ms_pwr_dyn_active2(charstring id) runs on ConnHdlr {
Eric Wild095024b2019-06-17 15:08:57 +02002620 var L1ctlDlMessage l1_dl;
2621
2622 /* set a high value to ensure power decreases */
2623 f_trxc_fake_rssi(rxlev2dbm(50));
2624 f_l1_tune(L1CTL);
2625 RSL.clear;
2626
2627 var uint5_t pwr_var := 5;
2628
2629 var template (value) RSL_IE_MS_Power ms_power := ts_RSL_IE_MS_Power(pwr_var);
2630 var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power});
2631
2632 /* establish with fixed power level */
2633 f_est_dchan(more_ies :={valueof(pwr)});
2634
2635 /* check our initial power level */
2636 f_wait_for_l1_power_level(pwr_var);
2637
2638 /* pwr control without power params IE, should NOT activate MS power control*/
2639 RSL.send(ts_RSL_MS_PWR_CTRL(g_chan_nr, ms_power));
2640
2641 /* wait, then check that our power level did not change */
2642 timer T1 := 10.0;
2643 T1.start;
2644 alt {
2645 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl {
2646 if ( oct2int(l1_dl.payload.data_ind.payload[0]) != pwr_var) {
2647 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
2648 "BS power control should not be active unless we receive a power parameters IE!");
2649 }
2650 repeat;
2651 }
2652 [] L1CTL.receive { repeat; }
2653 [] T1.timeout { setverdict(pass); }
2654 }
2655
2656 f_rsl_chan_deact();
2657 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
2658
2659}
2660
Eric Wild61edb7e2019-06-03 12:38:31 +02002661function f_wait_for_l1_power_level(integer level) runs on ConnHdlr {
2662 var L1ctlDlMessage l1_dl;
2663 timer T0 := 10.0;
2664 T0.start;
2665 alt {
2666 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl {
2667 if (not (l1_dl.payload.data_ind.payload[0] == int2oct(level, 1))) {
2668 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
2669 "Power level in L1 header != signaled (RSL) power level.");
2670 }
2671 }
2672 [] L1CTL.receive { repeat; }
2673 [] T0.timeout {
2674 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
2675 "Timeout waiting for initial power level");
2676 }
2677 }
2678 T0.stop;
2679}
2680
2681private function f_power_level_is_lowest_dbm(integer level) runs on ConnHdlr return boolean {
2682 var IntegerRecord min_dbm_level;
2683 var IntegerRecord max_dbm_level;
2684 var IntegerRecord x := f_power_from_band(g_pars.bts0_band, min_dbm_level, max_dbm_level);
2685
2686 for (var integer i := 0; i < sizeof(min_dbm_level); i := i+1) {
2687 if (min_dbm_level[i] == level) {
2688 return true;
2689 }
2690 }
2691 return false;
2692}
2693
2694private function f_power_level_is_highest_dbm(integer level) runs on ConnHdlr return boolean {
2695 var IntegerRecord min_dbm_level;
2696 var IntegerRecord max_dbm_level;
2697 var IntegerRecord x := f_power_from_band(g_pars.bts0_band, min_dbm_level, max_dbm_level);
2698
2699 for (var integer i := 0; i < sizeof(max_dbm_level); i := i+1) {
2700 if (max_dbm_level[i] == level) {
2701 return true;
2702 }
2703 }
2704 return false;
2705}
2706
2707private function f_get_max_power_from_band() runs on ConnHdlr return integer {
2708 var IntegerRecord min_dbm_level;
2709 var IntegerRecord max_dbm_level;
2710 var IntegerRecord x := f_power_from_band(g_pars.bts0_band, min_dbm_level, max_dbm_level);
2711 return max_dbm_level[0];
2712}
2713
2714type charstring BtsBand ("GSM450","GSM480","GSM750","GSM810","GSM850","GSM900","DCS1800","PCS1900");
2715template charstring BtsBand_allGSM:= pattern "GSM???";
2716private function f_power_from_band(in BtsBand band, out IntegerRecord min_dbm_level, out IntegerRecord max_dbm_level) return IntegerRecord {
2717 // 45.005 4.1.1
2718 var IntegerRecord gsm_power :={31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19,
2719 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3,
2720 2, 1, 0};
2721 var IntegerRecord dcs_power :={28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15,
2722 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 31, 30, 29};
2723 var IntegerRecord pcs_power :={15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 31, 30};
2724 var IntegerRecord rv;
2725
2726 select(band){
2727 case (BtsBand_allGSM){
2728 rv := gsm_power;
2729 min_dbm_level := {31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19} ;
2730 max_dbm_level := {2, 1, 0};
2731 }
2732 case("DCS1800"){
2733 rv := dcs_power;
2734 min_dbm_level := {28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15};
2735 max_dbm_level := {0, 29}; // let's cheat here, assume MS_TXPWR_MAX_CCH might be being broadcast, so maybe no 29,30,31
2736 }
2737 case("PCS1900"){
2738 rv := pcs_power;
2739 min_dbm_level := {15};
2740 max_dbm_level := {30};
2741 }
2742 }
2743
2744 return rv;
2745}
2746
2747private function f_vty_get_bts0_band() runs on test_CT return BtsBand {
2748 return f_vty_transceive_match_regex(BTSVTY, "show bts 0", "BTS 0 is of \w+ type in band (\w+),*", 0);
2749}
2750
2751testcase TC_rsl_ms_pwr_dyn_ass_updown() runs on test_CT {
2752 var ConnHdlr vc_conn;
2753 var ConnHdlrPars pars;
2754 f_init();
2755 f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -100");
2756 for (var integer tn := 1; tn <= 1; tn := tn+1) {
2757 pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN));
2758 pars.bts0_band := f_vty_get_bts0_band();
2759 vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_ass_updown), pars, trxc_comp := true);
2760 vc_conn.done;
2761 }
2762 f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop");
2763 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
2764}
2765
2766testcase TC_rsl_ms_pwr_dyn_up() runs on test_CT {
2767 var ConnHdlr vc_conn;
2768 var ConnHdlrPars pars;
2769 f_init();
2770 f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -10");
2771 for (var integer tn := 1; tn <= 1; tn := tn+1) {
2772 pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN));
2773 pars.bts0_band := f_vty_get_bts0_band();
2774 vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_up), pars, trxc_comp := true);
2775 vc_conn.done;
2776 }
2777 f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop");
2778 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
2779}
2780
2781testcase TC_rsl_ms_pwr_dyn_max() runs on test_CT {
2782 var ConnHdlr vc_conn;
2783 var ConnHdlrPars pars;
2784 f_init();
2785 f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -10");
2786 for (var integer tn := 1; tn <= 1; tn := tn+1) {
2787 pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN));
2788 pars.bts0_band := f_vty_get_bts0_band();
2789 vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_max), pars, trxc_comp := true);
2790 vc_conn.done;
2791 }
2792 f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop");
2793 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
2794}
2795
2796testcase TC_rsl_ms_pwr_dyn_down() runs on test_CT {
2797 var ConnHdlr vc_conn;
2798 var ConnHdlrPars pars;
2799 f_init();
2800 f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -100");
2801 for (var integer tn := 1; tn <= 1; tn := tn+1) {
2802 pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN));
2803 pars.bts0_band := f_vty_get_bts0_band();
2804 vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_down), pars, trxc_comp := true);
2805 vc_conn.done;
2806 }
2807 f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop");
2808 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
2809}
2810
Eric Wild280ccb82019-06-17 11:11:52 +02002811testcase TC_rsl_ms_pwr_dyn_active() runs on test_CT {
2812 var ConnHdlr vc_conn;
2813 var ConnHdlrPars pars;
2814 f_init();
2815 f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -100");
2816 for (var integer tn := 1; tn <= 1; tn := tn+1) {
2817 pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN));
2818 pars.bts0_band := f_vty_get_bts0_band();
2819 vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_active), pars, trxc_comp := true);
2820 vc_conn.done;
2821 }
2822 f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop");
2823 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
2824}
2825
Eric Wild095024b2019-06-17 15:08:57 +02002826testcase TC_rsl_ms_pwr_dyn_active2() runs on test_CT {
2827 var ConnHdlr vc_conn;
2828 var ConnHdlrPars pars;
2829 f_init();
2830 f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -100");
2831 for (var integer tn := 1; tn <= 1; tn := tn+1) {
2832 pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN));
2833 pars.bts0_band := f_vty_get_bts0_band();
2834 vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_active2), pars, trxc_comp := true);
2835 vc_conn.done;
2836 }
2837 f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop");
2838 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
2839}
2840
Harald Welte70767382018-02-21 12:16:40 +01002841testcase TC_meas_res_sign_tchf() runs on test_CT {
2842 var ConnHdlr vc_conn;
2843 var ConnHdlrPars pars;
Harald Welte10474062019-05-30 16:48:17 +02002844 f_init();
Harald Welte70767382018-02-21 12:16:40 +01002845 for (var integer tn := 1; tn <= 4; tn := tn+1) {
2846 pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN));
Vadim Yanitskiyf4e997c2019-06-04 21:40:33 +07002847 vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars,
2848 pcu_comp := false, trxc_comp := true);
Harald Welte70767382018-02-21 12:16:40 +01002849 vc_conn.done;
2850 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002851 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +01002852}
2853testcase TC_meas_res_sign_tchh() runs on test_CT {
2854 var ConnHdlr vc_conn;
2855 var ConnHdlrPars pars;
Harald Welte10474062019-05-30 16:48:17 +02002856 f_init();
Harald Welte70767382018-02-21 12:16:40 +01002857 for (var integer ss := 0; ss <= 1; ss := ss+1) {
2858 pars := valueof(t_Pars(t_RslChanNr_Lm(5, ss), ts_RSL_ChanMode_SIGN));
Eric Wild5b9ef142019-07-11 19:28:02 +02002859 vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars,
2860 pcu_comp := false, trxc_comp := true);
Harald Welte70767382018-02-21 12:16:40 +01002861 vc_conn.done;
2862 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002863 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +01002864}
2865testcase TC_meas_res_sign_sdcch4() runs on test_CT {
2866 var ConnHdlr vc_conn;
2867 var ConnHdlrPars pars;
Harald Welte10474062019-05-30 16:48:17 +02002868 f_init();
Harald Welte70767382018-02-21 12:16:40 +01002869 for (var integer ss := 0; ss <= 3; ss := ss+1) {
2870 pars := valueof(t_Pars(t_RslChanNr_SDCCH4(0, ss), ts_RSL_ChanMode_SIGN));
Eric Wild5b9ef142019-07-11 19:28:02 +02002871 vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars,
2872 pcu_comp := false, trxc_comp := true);
Harald Welte70767382018-02-21 12:16:40 +01002873 vc_conn.done;
2874 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002875 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +01002876}
2877testcase TC_meas_res_sign_sdcch8() runs on test_CT {
2878 var ConnHdlr vc_conn;
2879 var ConnHdlrPars pars;
Harald Welte10474062019-05-30 16:48:17 +02002880 f_init();
Harald Welte70767382018-02-21 12:16:40 +01002881 for (var integer ss := 0; ss <= 7; ss := ss+1) {
2882 pars := valueof(t_Pars(t_RslChanNr_SDCCH8(6, ss), ts_RSL_ChanMode_SIGN));
Eric Wild5b9ef142019-07-11 19:28:02 +02002883 vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars,
2884 pcu_comp := false, trxc_comp := true);
Harald Welte70767382018-02-21 12:16:40 +01002885 vc_conn.done;
2886 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002887 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte70767382018-02-21 12:16:40 +01002888}
Harald Welte685d5982018-02-27 20:42:05 +01002889testcase TC_meas_res_sign_tchh_toa256() runs on test_CT {
2890 var ConnHdlr vc_conn;
2891 var ConnHdlrPars pars;
Harald Welte10474062019-05-30 16:48:17 +02002892 f_init();
Harald Welte685d5982018-02-27 20:42:05 +01002893 f_vty_config(BTSVTY, "bts 0", "supp-meas-info toa256");
2894 for (var integer ss := 0; ss <= 1; ss := ss+1) {
2895 pars := valueof(t_Pars(t_RslChanNr_Lm(5, ss), ts_RSL_ChanMode_SIGN));
2896 pars.l1_pars.toa256_enabled := true;
2897 vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars);
2898 vc_conn.done;
2899 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02002900 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte685d5982018-02-27 20:42:05 +01002901}
2902
Philipp Maier4d1e9c92018-12-20 11:11:56 +01002903/* establish DChan, and send MS POWER CONTROL messages via RSL, verify that
2904 * the BTS is forwarding those values to the MS via the SACCH L1 header. */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07002905private function f_tc_rsl_ms_pwr_ctrl(charstring id) runs on ConnHdlr {
Philipp Maier4d1e9c92018-12-20 11:11:56 +01002906 var L1ctlDlMessage l1_dl;
2907 var RSL_IE_MS_Power ms_power;
2908 var RSL_Message rsl;
2909 var uint5_t power_level := 0;
2910
2911 f_l1_tune(L1CTL);
2912 RSL.clear;
2913
2914 f_est_dchan();
2915
2916 ms_power.reserved := 0;
2917 ms_power.fpc_epc := false;
2918
2919 /* Send the first power control command. This will disable any BTS/TRX
2920 * internal power control and switch the MS (which is not in scope of
2921 * this test) to a constant power level. We start with a power level
2922 * of 0 */
2923 ms_power.power_level := power_level;
2924 rsl := valueof(ts_RSL_MS_PWR_CTRL(g_chan_nr, ms_power));
2925 RSL.send(rsl);
2926
2927 alt {
2928
2929 /* Pick all SACCH blocks for checking */
2930 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl {
2931
2932 /* The first byte of the L1 header contains the power level.
2933 * The reserved bits and the fpc bit is set to 0, so we may
2934 * compare directly. */
2935 if (not (l1_dl.payload.data_ind.payload[0] == int2oct(power_level, 1))) {
2936 setverdict(fail, "Power level in L1 header does not match the signaled (RSL) power level.");
2937 }
2938
2939 /* Signal a new power level via RSL for the next turn. */
2940 if (power_level < 31) {
2941 power_level := power_level + 1;
2942 ms_power.power_level := power_level;
2943 rsl := valueof(ts_RSL_MS_PWR_CTRL(g_chan_nr, ms_power));
2944 RSL.send(rsl);
2945 repeat;
2946 }
2947
2948 }
2949
2950 /* Ignore all other blocks */
2951 [] L1CTL.receive { repeat; }
2952
2953 }
2954
2955 f_rsl_chan_deact();
2956 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
2957
2958 setverdict(pass);
2959}
2960
2961testcase TC_rsl_ms_pwr_ctrl() runs on test_CT {
2962 var ConnHdlr vc_conn;
2963 var ConnHdlrPars pars;
Harald Welte10474062019-05-30 16:48:17 +02002964 f_init();
Philipp Maier4d1e9c92018-12-20 11:11:56 +01002965
2966 for (var integer tn := 1; tn <= 4; tn := tn+1) {
2967 pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN));
2968 vc_conn := f_start_handler(refers(f_tc_rsl_ms_pwr_ctrl), pars);
2969 vc_conn.done;
2970 }
2971 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
2972}
Harald Welte70767382018-02-21 12:16:40 +01002973
Pau Espin Pedrol188bfd22020-06-03 20:32:45 +02002974/* establish DChan, verify that the BTS sets the TA in the first SACCH L1 header.
Eric Wild6833cc92019-05-23 19:34:44 +02002975TA for the IMM ASS messages is still controlled by g_pars.l1_pars.ms_actual_ta! */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07002976private function f_tc_rsl_chan_initial_ta(charstring id) runs on ConnHdlr {
Eric Wild6833cc92019-05-23 19:34:44 +02002977 var L1ctlDlMessage l1_dl;
2978 var uint5_t ta_to_test := 16;
2979
2980
2981 f_l1_tune(L1CTL);
2982 RSL.clear;
2983
2984 /* tell fake_trx to use a given timing offset for all bursts */
Vadim Yanitskiydc8db922019-06-04 21:58:15 +07002985 f_trxc_fake_toffs256(ta_to_test*256);
Eric Wild6833cc92019-05-23 19:34:44 +02002986
2987 f_est_dchan(more_ies :={valueof(t_RSL_IE(RSL_IE_TIMING_ADVANCE, RSL_IE_Body:{timing_adv := ta_to_test}))} );
2988
2989
2990 alt {
2991
2992 /* Pick all SACCH blocks for checking */
2993 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl {
2994
2995 /* The second byte of the L1 header contains the TA. */
2996 if (not (l1_dl.payload.data_ind.payload[1] == int2oct(ta_to_test, 1))) {
2997 setverdict(fail, "TA in L1 header does not match the signaled (RSL) TA.");
2998 }
2999
3000 }
3001
3002 /* Ignore all other blocks */
3003 [] L1CTL.receive { repeat; }
3004
3005 }
3006
3007 f_rsl_chan_deact();
3008 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
3009
3010 setverdict(pass);
3011}
3012
3013testcase TC_rsl_chan_initial_ta() runs on test_CT {
3014 var ConnHdlr vc_conn;
3015 var ConnHdlrPars pars;
Harald Welte10474062019-05-30 16:48:17 +02003016 f_init();
Eric Wild6833cc92019-05-23 19:34:44 +02003017 pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
Vadim Yanitskiyf4e997c2019-06-04 21:40:33 +07003018 vc_conn := f_start_handler(refers(f_tc_rsl_chan_initial_ta), pars,
3019 pcu_comp := false, trxc_comp := true);
Eric Wild6833cc92019-05-23 19:34:44 +02003020 vc_conn.done;
3021 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
3022}
3023
Eric Wilde57e1a62019-05-28 13:30:55 +02003024/* establish DChan, verify that the BTS sets MS power in the first SACCH L1 header. */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07003025private function f_tc_rsl_chan_initial_ms_pwr(charstring id) runs on ConnHdlr {
Eric Wilde57e1a62019-05-28 13:30:55 +02003026 var L1ctlDlMessage l1_dl;
3027 var uint5_t ms_power_level := 7;
3028
3029 var RSL_IE_MS_Power ms_power;
3030 ms_power.reserved := 0;
3031 ms_power.fpc_epc := false;
3032 ms_power.power_level := ms_power_level;
3033
3034 f_l1_tune(L1CTL);
3035 RSL.clear;
3036
3037 f_est_dchan(more_ies :={valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power}))} );
3038
3039 timer T := 1.0;
3040 T.start;
3041 alt {
3042 /* Pick all SACCH blocks for checking */
3043 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl {
3044 /* The first byte of the L1 header contains the power level.. */
3045 if (not (l1_dl.payload.data_ind.payload[0] == int2oct(ms_power_level, 1))) {
3046 setverdict(fail, "Power Level in L1 header does not match the signaled (RSL) MS Power Level.");
3047 }
3048 }
3049 /* Ignore all other blocks */
3050 [] L1CTL.receive { repeat; }
3051 [] T.timeout {
3052 setverdict(fail, "Power Level in L1 header does not match the signaled (RSL) MS Power Level.");
3053 }
3054 }
3055
3056 f_rsl_chan_deact();
3057 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
3058 setverdict(pass);
3059}
3060
3061testcase TC_rsl_chan_initial_ms_pwr() runs on test_CT {
3062 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
3063 f_testmatrix_each_chan(pars, refers(f_tc_rsl_chan_initial_ms_pwr));
3064}
3065
Harald Welte0472ab42018-03-12 15:02:26 +01003066/* 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 +01003067private function f_TC_conn_fail_crit(charstring id) runs on ConnHdlr {
Harald Welte68e495b2018-02-25 00:05:57 +01003068 f_l1_tune(L1CTL);
Harald Welte70767382018-02-21 12:16:40 +01003069 RSL.clear;
3070
3071 f_est_dchan();
3072 f_sleep(2.0);
Harald Weltef8df4cb2018-03-10 15:15:08 +01003073 L1CTL.send(ts_L1CTL_DM_REL_REQ(g_chan_nr));
Harald Welte70767382018-02-21 12:16:40 +01003074
3075 timer T := 40.0;
3076 T.start;
3077 alt {
3078 [] RSL.receive(tr_RSL_CONN_FAIL_IND(g_chan_nr, ?)) {
3079 setverdict(pass)
3080 }
3081 [] RSL.receive { repeat };
3082 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003083 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "No CONN FAIL IND received");
Harald Welte70767382018-02-21 12:16:40 +01003084 }
3085 }
3086 f_rsl_chan_deact();
3087}
3088testcase TC_conn_fail_crit() runs on test_CT {
3089 var ConnHdlr vc_conn;
3090 var ConnHdlrPars pars;
Harald Welte10474062019-05-30 16:48:17 +02003091 f_init();
Harald Welte70767382018-02-21 12:16:40 +01003092 pars := valueof(t_Pars(t_RslChanNr_SDCCH8(6, 3), ts_RSL_ChanMode_SIGN));
3093 pars.t_guard := 60.0;
3094 vc_conn := f_start_handler(refers(f_TC_conn_fail_crit), pars);
3095 vc_conn.done;
3096}
3097
Harald Welte93640c62018-02-25 16:59:33 +01003098/***********************************************************************
3099 * Paging
3100 ***********************************************************************/
3101
Harald Welte68e495b2018-02-25 00:05:57 +01003102function tmsi_is_dummy(TMSIP_TMSI_V tmsi) return boolean {
3103 if (tmsi == 'FFFFFFFF'O) {
3104 return true;
3105 } else {
3106 return false;
3107 }
3108}
Harald Welte70767382018-02-21 12:16:40 +01003109
Philipp Maier82cb0b12018-08-31 14:41:39 +02003110type record allowedFn { integer frame_nr }
3111template allowedFn bs_ag_blks_res_0 := { frame_nr := (6, 12, 16, 22, 26, 32, 36, 42, 46) }
3112template allowedFn bs_ag_blks_res_1 := { frame_nr := (12, 16, 22, 26, 32, 36, 42, 46) }
3113template allowedFn bs_ag_blks_res_2 := { frame_nr := (16, 22, 26, 32, 36, 42, 46) }
3114template allowedFn bs_ag_blks_res_3 := { frame_nr := (22, 26, 32, 36, 42, 46) }
3115template allowedFn bs_ag_blks_res_4 := { frame_nr := (26, 32, 36, 42, 46) }
3116template allowedFn bs_ag_blks_res_5 := { frame_nr := (32, 36, 42, 46) }
3117template allowedFn bs_ag_blks_res_6 := { frame_nr := (36, 42, 46) }
3118template allowedFn bs_ag_blks_res_7 := { frame_nr := (42, 46) }
3119function check_pch_fn(integer frame_nr, integer bs_ag_blks_res) runs on test_CT
3120{
3121 var integer frame_nr_51;
3122 frame_nr_51 := frame_nr mod 51
3123
3124 var allowedFn fn_check;
3125 fn_check.frame_nr := frame_nr_51;
3126
3127 if (bs_ag_blks_res < 0 or bs_ag_blks_res > 7) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003128 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "bs_ag_blks_res out of valid range (0..7)");
Philipp Maier82cb0b12018-08-31 14:41:39 +02003129 return;
3130 }
3131
3132 if (bs_ag_blks_res == 0 and match(fn_check, bs_ag_blks_res_0)) {
3133 return;
3134 }
3135 if (bs_ag_blks_res == 1 and match(fn_check, bs_ag_blks_res_1)) {
3136 return;
3137 }
3138 if (bs_ag_blks_res == 2 and match(fn_check, bs_ag_blks_res_2)) {
3139 return;
3140 }
3141 if (bs_ag_blks_res == 3 and match(fn_check, bs_ag_blks_res_3)) {
3142 return;
3143 }
3144 if (bs_ag_blks_res == 4 and match(fn_check, bs_ag_blks_res_4)) {
3145 return;
3146 }
3147 if (bs_ag_blks_res == 5 and match(fn_check, bs_ag_blks_res_5)) {
3148 return;
3149 }
3150 if (bs_ag_blks_res == 6 and match(fn_check, bs_ag_blks_res_6)) {
3151 return;
3152 }
3153 if (bs_ag_blks_res == 7 and match(fn_check, bs_ag_blks_res_7)) {
3154 return;
3155 }
3156
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003157 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "received paging on AGCH");
Philipp Maier82cb0b12018-08-31 14:41:39 +02003158 return;
3159}
3160
3161altstep 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 +01003162runs on test_CT {
3163 var L1ctlDlMessage dl;
Harald Weltef8df4cb2018-03-10 15:15:08 +01003164 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?, c_DummyUI)) {
Harald Welte68e495b2018-02-25 00:05:57 +01003165 repeat;
3166 }
Harald Weltef8df4cb2018-03-10 15:15:08 +01003167 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0))) -> value dl {
Harald Welte68e495b2018-02-25 00:05:57 +01003168 var octetstring without_plen :=
3169 substr(dl.payload.data_ind.payload, 1, lengthof(dl.payload.data_ind.payload)-1);
3170 var PDU_ML3_NW_MS rr := dec_PDU_ML3_NW_MS(without_plen);
Philipp Maier82cb0b12018-08-31 14:41:39 +02003171
3172 check_pch_fn(dl.dl_info.frame_nr, cfg.bs_ag_blks_res);
3173
Vadim Yanitskiy36aa07c2020-03-31 14:33:43 +07003174 if (match(rr, tr_PAGING_REQ1(tr_MI_LV(t_MI_NoIdentity(?))))) {
3175 /* Ignore empty RR Paging Request (PCH filling) messages.
3176 * TODO: does it make sense to count them? */
3177 } else if (match(rr, tr_PAGING_REQ1)) {
Harald Welte68e495b2018-02-25 00:05:57 +01003178 num_paging_rcv_msgs := num_paging_rcv_msgs + 1;
3179 num_paging_rcv_ids := num_paging_rcv_ids + 1;
Vadim Yanitskiyd665c232020-03-30 14:40:41 +07003180 if (ispresent(rr.msgs.rrm.pagingReq_Type1.mobileIdentity2)) {
Harald Welte68e495b2018-02-25 00:05:57 +01003181 num_paging_rcv_ids := num_paging_rcv_ids + 1;
3182 }
3183 } else if (match(rr, tr_PAGING_REQ2)) {
3184 num_paging_rcv_msgs := num_paging_rcv_msgs + 1;
3185 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type2.mobileIdentity1)) {
3186 num_paging_rcv_ids := num_paging_rcv_ids + 1;
3187 }
3188 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type2.mobileIdentity2)) {
3189 num_paging_rcv_ids := num_paging_rcv_ids + 1;
3190 }
Vadim Yanitskiyd665c232020-03-30 14:40:41 +07003191 if (ispresent(rr.msgs.rrm.pagingReq_Type2.mobileIdentity3)) {
Harald Welte68e495b2018-02-25 00:05:57 +01003192 num_paging_rcv_ids := num_paging_rcv_ids + 1;
3193 }
3194 } else if (match(rr, tr_PAGING_REQ3)) {
3195 num_paging_rcv_msgs := num_paging_rcv_msgs + 1;
3196 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity1)) {
3197 num_paging_rcv_ids := num_paging_rcv_ids + 1;
3198 }
3199 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity2)) {
3200 num_paging_rcv_ids := num_paging_rcv_ids + 1;
3201 }
3202 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity3)) {
3203 num_paging_rcv_ids := num_paging_rcv_ids + 1;
3204 }
3205 if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity4)) {
3206 num_paging_rcv_ids := num_paging_rcv_ids + 1;
3207 }
3208 }
3209 repeat;
3210 }
3211}
3212
3213type record PagingTestCfg {
3214 boolean combined_ccch,
3215 integer bs_ag_blks_res,
3216 float load_factor,
3217 boolean exp_load_ind,
3218 boolean exp_overload,
3219 boolean use_tmsi
3220}
3221
3222type record PagingTestState {
3223 integer num_paging_sent,
3224 integer num_paging_rcv_msgs,
3225 integer num_paging_rcv_ids,
3226 integer num_overload
3227}
3228
Harald Welte68e495b2018-02-25 00:05:57 +01003229/* Helper function for paging related testing */
3230private function f_TC_paging(PagingTestCfg cfg) runs on test_CT return PagingTestState {
Harald Welte10474062019-05-30 16:48:17 +02003231 f_init();
Harald Welte68e495b2018-02-25 00:05:57 +01003232 f_init_l1ctl();
3233 f_l1_tune(L1CTL);
3234
3235 var PagingTestState st := {
3236 num_paging_sent := 0,
3237 num_paging_rcv_msgs := 0,
3238 num_paging_rcv_ids := 0,
3239 num_overload := 0
3240 };
3241
3242 var float max_pch_blocks_per_sec := f_pch_block_rate_est(cfg.combined_ccch, cfg.bs_ag_blks_res);
3243 var float max_pch_imsi_per_sec;
3244 if (cfg.use_tmsi) {
3245 max_pch_imsi_per_sec := max_pch_blocks_per_sec * 4.0; /* Type 3 */
3246 } else {
3247 max_pch_imsi_per_sec := max_pch_blocks_per_sec * 2.0; /* Type 1 */
3248 }
3249 var float pch_blocks_per_sec := max_pch_imsi_per_sec * cfg.load_factor;
3250 var float interval := 1.0 / pch_blocks_per_sec;
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02003251 var float time_total := 20.0;
3252 var integer pkt_total := float2int(time_total * pch_blocks_per_sec);
3253 log("pch_blocks_total=", pkt_total," pch_blocks_per_sec=", pch_blocks_per_sec, " interval=", interval);
Harald Welte68e495b2018-02-25 00:05:57 +01003254
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02003255 timer T_total := 300.0; /* big value (far bigger than time_total), used to count elapsed time */
3256 T_total.start;
Harald Welte68e495b2018-02-25 00:05:57 +01003257
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02003258 timer T_itv := 0.0;
3259 T_itv.start;
3260 while (st.num_paging_sent < pkt_total) {
Harald Welte68e495b2018-02-25 00:05:57 +01003261 alt {
3262 /* check for presence of CCCH LOAD IND (paging load) */
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07003263 [cfg.exp_overload] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_LOAD_IND(0))) {
Harald Welte68e495b2018-02-25 00:05:57 +01003264 st.num_overload := st.num_overload + 1;
3265 repeat;
3266 }
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07003267 [not cfg.exp_overload] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_LOAD_IND(0))) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003268 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected PCH Overload");
Harald Welte68e495b2018-02-25 00:05:57 +01003269 }
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07003270 [cfg.exp_load_ind] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_LOAD_IND)) {
Harald Welte68e495b2018-02-25 00:05:57 +01003271 log("Rx LOAD_IND");
3272 /* FIXME: analyze/verify interval + contents */
3273 repeat;
3274 }
3275 /* check if paging requests arrive on Um side */
Philipp Maier82cb0b12018-08-31 14:41:39 +02003276 [] as_l1_count_paging(st.num_paging_rcv_msgs, st.num_paging_rcv_ids, cfg);
Harald Welte68e495b2018-02-25 00:05:57 +01003277 [] L1CTL.receive { repeat; }
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02003278 [] T_itv.timeout {
3279 /* Send paging cmds based on elapsed time */
3280 var integer new_sent := f_min(pkt_total, float2int(T_total.read * pch_blocks_per_sec) + 1);
3281 while (st.num_paging_sent < new_sent) {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07003282 var MobileIdentityV mi;
3283
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02003284 /* build mobile Identity */
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02003285 if (cfg.use_tmsi) {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07003286 mi := valueof(t_MI_TMSI(f_rnd_octstring(4)));
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02003287 } else {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07003288 mi := valueof(ts_MI_IMSI(f_gen_imsi(st.num_paging_sent)));
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02003289 }
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02003290
3291 /* Send RSL PAGING COMMAND */
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07003292 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 +02003293
3294 st.num_paging_sent := st.num_paging_sent + 1;
3295 }
3296 if (st.num_paging_sent < pkt_total) {
3297 /* Wait for interval to next PAGING COMMAND */
3298 var float time_now := T_total.read;
3299 var float next_sched := int2float(st.num_paging_sent)*interval;
3300 if (next_sched > time_now) {
3301 T_itv.start(next_sched - time_now);
3302 } else {
3303 T_itv.start(0.0);
3304 }
3305 } else {
3306 /* We are done, no need to keep counting */
3307 T_total.stop;
3308 }
3309 }
3310 [] T_total.timeout { }
Harald Welte68e495b2018-02-25 00:05:57 +01003311 }
3312 }
3313
3314 /* wait for max 18s for paging queue to drain (size: 200, ~ 13 per s -> 15s) */
3315 timer T_wait := 18.0;
3316 T_wait.start;
3317 alt {
Philipp Maier82cb0b12018-08-31 14:41:39 +02003318 [] as_l1_count_paging(st.num_paging_rcv_msgs, st.num_paging_rcv_ids, cfg);
Harald Welte68e495b2018-02-25 00:05:57 +01003319 [] L1CTL.receive { repeat; }
3320 /* 65535 == empty paging queue, we can terminate*/
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07003321 [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_LOAD_IND(65535))) { }
3322 [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_LOAD_IND)) { repeat; }
Harald Welte68e495b2018-02-25 00:05:57 +01003323 [] T_wait.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003324 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Waiting for empty paging queue");
Harald Welte68e495b2018-02-25 00:05:57 +01003325 }
Harald Welte68e495b2018-02-25 00:05:57 +01003326 }
3327
3328 log("num_paging_sent=", st.num_paging_sent, " rcvd_msgs=", st.num_paging_rcv_msgs,
3329 " rcvd_ids=", st.num_paging_rcv_ids);
3330 return st;
3331}
3332
3333/* Create ~ 80% paging load (IMSI only) sustained for about 20s, verifying that
3334 * - the number of Mobile Identities on Um PCH match the number of pages on RSL
3335 * - that CCCH LOAD IND (PCH) are being generated
3336 * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */
3337testcase TC_paging_imsi_80percent() runs on test_CT {
Philipp Maierd65d0562018-08-30 16:25:47 +02003338 var SystemInformation si3 := valueof(ts_SI3_default);
Harald Welte68e495b2018-02-25 00:05:57 +01003339 var PagingTestCfg cfg := {
3340 combined_ccch := true,
Philipp Maierd65d0562018-08-30 16:25:47 +02003341 bs_ag_blks_res := si3.payload.si3.ctrl_chan_desc.bs_ag_blks_res,
Harald Welte68e495b2018-02-25 00:05:57 +01003342 load_factor := 0.8,
3343 exp_load_ind := true,
3344 exp_overload := false,
3345 use_tmsi := false
3346 };
3347 var PagingTestState st := f_TC_paging(cfg);
3348 if (st.num_paging_sent != st.num_paging_rcv_ids) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003349 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Expected ", st.num_paging_sent, " pagings but have ",
3350 st.num_paging_rcv_ids));
Harald Welte68e495b2018-02-25 00:05:57 +01003351 } else {
3352 setverdict(pass);
3353 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003354 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte68e495b2018-02-25 00:05:57 +01003355}
3356
3357/* Create ~ 80% paging load (TMSI only) sustained for about 20s, verifying that
3358 * - the number of Mobile Identities on Um PCH match the number of pages on RSL
3359 * - that CCCH LOAD IND (PCH) are being generated
3360 * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */
3361testcase TC_paging_tmsi_80percent() runs on test_CT {
Philipp Maierd65d0562018-08-30 16:25:47 +02003362 var SystemInformation si3 := valueof(ts_SI3_default);
Harald Welte68e495b2018-02-25 00:05:57 +01003363 var PagingTestCfg cfg := {
3364 combined_ccch := true,
Philipp Maierd65d0562018-08-30 16:25:47 +02003365 bs_ag_blks_res := si3.payload.si3.ctrl_chan_desc.bs_ag_blks_res,
Harald Welte68e495b2018-02-25 00:05:57 +01003366 load_factor := 0.8,
3367 exp_load_ind := true,
3368 exp_overload := false,
3369 use_tmsi := true
3370 };
3371 var PagingTestState st := f_TC_paging(cfg);
3372 if (st.num_paging_sent != st.num_paging_rcv_ids) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003373 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Expected ", st.num_paging_sent, " pagings but have ",
3374 st.num_paging_rcv_ids));
Harald Welte68e495b2018-02-25 00:05:57 +01003375 } else {
3376 setverdict(pass);
3377 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003378 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte68e495b2018-02-25 00:05:57 +01003379}
3380
3381/* Create ~ 200% paging load (IMSI only) sustained for about 20s, verifying that
3382 * - the number of Mobile Identities on Um PCH are ~ 82% of the number of pages on RSL
3383 * - that CCCH LOAD IND (PCH) are being generated and reach 0 at some point
3384 * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */
3385testcase TC_paging_imsi_200percent() runs on test_CT {
Philipp Maierd65d0562018-08-30 16:25:47 +02003386 var SystemInformation si3 := valueof(ts_SI3_default);
Harald Welte68e495b2018-02-25 00:05:57 +01003387 var PagingTestCfg cfg := {
3388 combined_ccch := true,
Philipp Maierd65d0562018-08-30 16:25:47 +02003389 bs_ag_blks_res := si3.payload.si3.ctrl_chan_desc.bs_ag_blks_res,
Harald Welte68e495b2018-02-25 00:05:57 +01003390 load_factor := 2.0,
3391 exp_load_ind := true,
3392 exp_overload := true,
3393 use_tmsi := false
3394 };
3395 var PagingTestState st := f_TC_paging(cfg);
3396 /* We expect about 80-85% to pass, given that we can fill the paging buffer of 200
3397 * slots and will fully drain that buffer before returning */
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02003398 var template integer tpl := (st.num_paging_sent*78/100 .. st.num_paging_sent *85/100);
Harald Welte68e495b2018-02-25 00:05:57 +01003399 if (not match(st.num_paging_rcv_ids, tpl)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003400 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 +01003401 } else {
3402 setverdict(pass);
3403 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003404 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte68e495b2018-02-25 00:05:57 +01003405}
3406
3407/* Create ~ 200% paging load (TMSI only) sustained for about 20s, verifying that
3408 * - the number of Mobile Identities on Um PCH are ~ 82% of the number of pages on RSL
3409 * - that CCCH LOAD IND (PCH) are being generated and reach 0 at some point
3410 * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */
3411testcase TC_paging_tmsi_200percent() runs on test_CT {
Philipp Maierd65d0562018-08-30 16:25:47 +02003412 var SystemInformation si3 := valueof(ts_SI3_default);
Harald Welte68e495b2018-02-25 00:05:57 +01003413 var PagingTestCfg cfg := {
3414 combined_ccch := true,
Philipp Maierd65d0562018-08-30 16:25:47 +02003415 bs_ag_blks_res := si3.payload.si3.ctrl_chan_desc.bs_ag_blks_res,
Harald Welte68e495b2018-02-25 00:05:57 +01003416 load_factor := 2.0,
3417 exp_load_ind := true,
3418 exp_overload := true,
3419 use_tmsi := true
3420 };
3421 var PagingTestState st := f_TC_paging(cfg);
3422 /* We expect about 70% to pass, given that we can fill the paging buffer of 200
3423 * slots and will fully drain that buffer before returning */
Pau Espin Pedrol9c3ff4e2018-09-26 18:30:16 +02003424 var template integer tpl := (st.num_paging_sent*64/100 .. st.num_paging_sent *72/100);
Harald Welte68e495b2018-02-25 00:05:57 +01003425 if (not match(st.num_paging_rcv_ids, tpl)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003426 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 +01003427 } else {
3428 setverdict(pass);
3429 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003430 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte68e495b2018-02-25 00:05:57 +01003431}
3432
3433
Harald Welte93640c62018-02-25 16:59:33 +01003434/***********************************************************************
3435 * Immediate Assignment / AGCH
3436 ***********************************************************************/
Vadim Yanitskiya9eeb7b2020-05-27 01:42:49 +07003437private const MobileAllocation c_MA_null := {
Harald Weltee8d750e2018-06-10 21:41:35 +02003438 len := 0,
3439 ma := ''B
3440}
Harald Welte93640c62018-02-25 16:59:33 +01003441
Vadim Yanitskiy92484562020-05-27 02:05:04 +07003442template (value) ChannelDescription ts_ChanDescH0(template (value) RslChannelNr chan_nr, uint3_t tsc := 7,
Vadim Yanitskiye9f68be2020-05-27 02:08:35 +07003443 uint12_t arfcn := mp_trx0_arfcn) := {
Harald Weltee8d750e2018-06-10 21:41:35 +02003444 chan_nr := chan_nr,
3445 tsc := tsc,
3446 h := false,
3447 arfcn := arfcn,
3448 maio_hsn := omit
3449}
3450
Vadim Yanitskiy92484562020-05-27 02:05:04 +07003451template (value) ChannelDescription ts_ChanDescH1(template (value) RslChannelNr chan_nr, uint3_t tsc := 7,
3452 template (value) MaioHsn maio_hsn) := {
3453 chan_nr := chan_nr,
3454 tsc := tsc,
3455 h := true,
3456 arfcn := omit,
3457 maio_hsn := maio_hsn
3458}
3459
Harald Weltee8d750e2018-06-10 21:41:35 +02003460private function f_fmt_ia_stats(integer num_tx, integer num_rx, integer num_del) return charstring {
3461 return int2str(num_tx) & " sent, "
3462 & int2str(num_rx) & " received, "
3463 & int2str(num_del) & " deleted";
3464}
3465
3466private function f_TC_imm_ass(integer num_total, float sleep_s, float exp_pass) runs on test_CT {
3467 var L1ctlDlMessage l1_dl;
3468 timer T := 10.0;
3469 var integer num_tx := 0;
3470 var integer num_rx := 0;
3471 var integer num_del := 0;
3472 var charstring res_str;
3473 var float rx_ratio;
3474
Harald Welte10474062019-05-30 16:48:17 +02003475 f_init();
Harald Weltee8d750e2018-06-10 21:41:35 +02003476 f_init_l1ctl();
3477 f_l1_tune(L1CTL);
3478
3479 for (var integer i := 0; i < num_total; i := i+1) {
Vadim Yanitskiy92484562020-05-27 02:05:04 +07003480 var ChannelDescription ch_desc := valueof(ts_ChanDescH0(valueof(t_RslChanNr_SDCCH4(0, 0))));
Harald Weltee8d750e2018-06-10 21:41:35 +02003481 var GsmRrMessage ia := valueof(ts_IMM_ASS(42, i, 5, ch_desc, c_MA_null));
3482 var octetstring ia_enc := enc_GsmRrMessage(ia);
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07003483 RSL_CCHAN.send(ts_ASP_RSL_UD(ts_RSL_IMM_ASSIGN(ia_enc, 0)));
Harald Weltee8d750e2018-06-10 21:41:35 +02003484 num_tx := num_tx+1;
3485 f_sleep(sleep_s);
Harald Welte68e495b2018-02-25 00:05:57 +01003486 }
3487 /* FIXME: check if imm.ass arrive on Um side */
Harald Weltee8d750e2018-06-10 21:41:35 +02003488 T.start;
3489 alt {
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07003490 [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_DELETE_IND(?, 0))) {
Harald Weltee8d750e2018-06-10 21:41:35 +02003491 num_del := num_del+1;
3492 repeat;
3493 }
3494 [] RSL_CCHAN.receive {
3495 repeat;
3496 }
3497 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?)) -> value l1_dl {
3498 /* somehow dec_SystemInformation will try to decode even non-RR as SI */
3499 var GsmRrMessage rr := dec_GsmRrMessage(l1_dl.payload.data_ind.payload);
3500 if (not match(rr, tr_IMM_ASS(42, ?, 5, ?, ?))) {
3501 /* FIXME: Why are we seeing paging requests on PCH/AGCH? */
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003502 //Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Unexpected IMM-ASS values on AGCH: ", rr));
Harald Weltee8d750e2018-06-10 21:41:35 +02003503 } else {
3504 num_rx := num_rx+1;
3505 }
3506 repeat;
3507 }
3508 [] L1CTL.receive { repeat; }
3509 [] T.timeout { }
3510 }
3511 res_str := f_fmt_ia_stats(num_tx, num_rx, num_del);
3512 log("AGCH test: " & res_str);
3513 if (num_rx + num_del != num_tx) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003514 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "RX + DEL != TX ?!?: " & res_str);
Harald Weltee8d750e2018-06-10 21:41:35 +02003515 }
3516 rx_ratio := int2float(num_rx) / int2float(num_tx);
3517 if (rx_ratio < exp_pass*0.8 or rx_ratio > exp_pass*1.2) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003518 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 +02003519 } else {
3520 setverdict(pass);
3521 }
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003522 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte68e495b2018-02-25 00:05:57 +01003523}
3524
Harald Weltee8d750e2018-06-10 21:41:35 +02003525/* send a long burst of 1000 IMM.ASS with 20ms spacing (50 per s); expect 75% of them to be deleted */
3526testcase TC_imm_ass_1000_20ms() runs on test_CT {
3527 f_TC_imm_ass(1000, 0.02, 0.25);
3528}
3529
3530/* send a short burst of 200 IMM.ASS without any spacing; expect 95% of them to be deleted */
3531testcase TC_imm_ass_200_0ms() runs on test_CT {
3532 f_TC_imm_ass(200, 0.0, 0.05);
3533}
3534
3535/* send 150 IMM.ASS at rate of 13/s; expect none of them to be deleted */
3536testcase TC_imm_ass_200_76ms() runs on test_CT {
3537 f_TC_imm_ass(150, 0.076, 1.00);
3538}
3539
3540
3541
Harald Welte48494ca2018-02-25 16:59:50 +01003542/***********************************************************************
3543 * BCCH
3544 ***********************************************************************/
3545
3546/* tuple of Frame Number + decoded SI */
3547type record SystemInformationFn {
3548 GsmFrameNumber frame_number,
3549 SystemInformation si
3550}
3551
3552/* an arbitrary-length vector of decoded SI + gsmtap header */
3553type record of SystemInformationFn SystemInformationVector;
3554
3555/* an array of SI-vectors indexed by TC value */
3556type SystemInformationVector SystemInformationVectorPerTc[8];
3557
3558/* determine if a given SI vector contains given SI type at least once */
3559function f_si_vecslot_contains(SystemInformationVector arr, RrMessageType key, boolean bcch_ext := false) return boolean {
3560 for (var integer i:= 0; i< sizeof(arr); i := i + 1) {
3561 var integer fn_mod51 := arr[i].frame_number mod 51;
3562 if (not bcch_ext and fn_mod51 == 2 or
3563 bcch_ext and fn_mod51 == 6) {
3564 if (arr[i].si.header.message_type == key) {
3565 return true;
3566 }
3567 }
3568 }
3569 return false;
3570}
3571
3572/* ensure a given TC slot of the SI vector contains given SI type at least once at TC */
3573function f_ensure_si_vec_contains(SystemInformationVectorPerTc arr, integer tc, RrMessageType key, boolean ext_bcch := false) {
3574 if (not f_si_vecslot_contains(arr[tc], key, ext_bcch)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003575 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("No ", key, " in TC=", tc, "!"));
Harald Welte48494ca2018-02-25 16:59:50 +01003576 }
3577}
3578
3579/* check if a given SI vector contains given SI type at least once on any TC */
3580function f_si_vec_contains(SystemInformationVectorPerTc arr, RrMessageType key) return boolean {
3581 for (var integer tc:= 0; tc < sizeof(arr); tc := tc + 1) {
3582 if (f_si_vecslot_contains(arr[tc], key) or
3583 f_si_vecslot_contains(arr[tc], key, true)) {
3584 return true;
3585 }
3586 }
3587 return false;
3588}
3589
3590/* determine if a given SI vector contains given SI type at least N of M times */
3591function f_si_vecslot_contains_n_of_m(SystemInformationVector arr, RrMessageType key, boolean bcch_ext := false, integer n := 1, integer m := 4) return boolean {
3592 var integer count := 0;
3593 if (sizeof(arr) < m) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003594 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Error: Insufficient SI in array");
Harald Welte48494ca2018-02-25 16:59:50 +01003595 }
3596 for (var integer i:= 0; i < m; i := i + 1) {
3597 var integer fn_mod51 := arr[i].frame_number mod 51;
3598 if (not bcch_ext and fn_mod51 == 2 or
3599 bcch_ext and fn_mod51 == 6) {
3600 if (arr[i].si.header.message_type == key) {
3601 count := count + 1;
3602 }
3603 }
3604 }
3605 if (count >= n) {
3606 return true;
3607 } else {
3608 return false;
3609 }
3610}
3611
3612/* ensure a given TC slot of the SI vector contains given SI type at least N out of M times at TC */
3613function f_ensure_si_vec_contains_n_of_m(SystemInformationVectorPerTc arr, integer tc, RrMessageType key, boolean ext_bcch := false, integer n, integer m) {
3614 if (not f_si_vecslot_contains_n_of_m(arr[tc], key, ext_bcch, n, m)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003615 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Not ", n, "/", m, " of ", key, " in TC=", tc, "!"));
Harald Welte48494ca2018-02-25 16:59:50 +01003616 }
3617}
3618
3619/* determine if a given SI vector contains given SI type at least once */
3620function f_si_vecslot_contains_only(SystemInformationVector arr, RrMessageType key, boolean bcch_ext := false) return boolean {
3621 for (var integer i:= 0; i< sizeof(arr); i := i + 1) {
3622 var integer fn_mod51 := arr[i].frame_number mod 51;
3623 if (not bcch_ext and fn_mod51 == 2 or
3624 bcch_ext and fn_mod51 == 6) {
3625 if (arr[i].si.header.message_type != key) {
3626 return false;
3627 }
3628 }
3629 }
3630 return true;
3631}
3632
3633/* ensure a given TC slot of the SI vector contains only given SI type */
3634function f_ensure_si_vec_contains_only(SystemInformationVectorPerTc arr, integer tc, RrMessageType key, boolean ext_bcch := false) {
3635 if (not f_si_vecslot_contains_only(arr[tc], key, ext_bcch)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003636 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Not all ", key, " in TC=", tc, "!"));
Harald Welte48494ca2018-02-25 16:59:50 +01003637 }
3638}
3639
3640/* SI configuration of cell, against which we validate actual SI messages */
3641type set SystemInformationConfig {
3642 boolean bcch_extended,
3643 boolean si1_present,
3644 boolean si2bis_present,
3645 boolean si2ter_present,
3646 boolean si2quater_present,
3647 boolean si7_present,
3648 boolean si8_present,
3649 boolean si9_present,
3650 boolean si13_present,
3651 boolean si13alt_present,
3652 boolean si15_present,
3653 boolean si16_present,
3654 boolean si17_present,
3655 boolean si2n_present,
3656 boolean si21_present,
3657 boolean si22_present
3658}
3659
3660/* validate the SI scheduling according to TS 45.002 version 14.1.0 Release 14, Section 6.3.1.3 */
3661function f_validate_si_scheduling(SystemInformationConfig cfg, SystemInformationVectorPerTc si_per_tc) {
3662 var integer i;
3663 for (i := 0; i < sizeof(si_per_tc); i := i + 1) {
3664 if (sizeof(si_per_tc[i]) == 0) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003665 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("No SI messages for TC=", i));
Harald Welte48494ca2018-02-25 16:59:50 +01003666 }
3667 }
3668 if (cfg.si1_present) {
3669 /* ii) System Information Type 1 needs to be sent if frequency hopping is in use or
3670 * when the NCH is present in a cell. If the MS finds another message on BCCH Norm
3671 * when TC = 0, it can assume that System Information Type 1 is not in use. */
3672 f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_1);
3673 /* make sure *ALL* contain SI1 */
3674 f_ensure_si_vec_contains_only(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_1);
3675 }
3676 f_ensure_si_vec_contains(si_per_tc, 1, SYSTEM_INFORMATION_TYPE_2);
3677 /* iii) A SI 2 message will be sent at least every time TC = 1 */
3678 f_ensure_si_vec_contains(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_3);
3679 f_ensure_si_vec_contains(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_3);
3680 f_ensure_si_vec_contains(si_per_tc, 3, SYSTEM_INFORMATION_TYPE_4);
3681 f_ensure_si_vec_contains(si_per_tc, 7, SYSTEM_INFORMATION_TYPE_4);
3682
3683 /* iii) System information type 2 bis or 2 ter messages are sent if needed, as determined by the
3684 * system operator. If only one of them is needed, it is sent when TC = 5. If both are
3685 * needed, 2bis is sent when TC = 5 and 2ter is sent at least once within any of 4
3686 * consecutive occurrences of TC = 4. */
3687 if (cfg.si2bis_present and not cfg.si2ter_present) {
3688 f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2bis);
3689 } else if (cfg.si2ter_present and not cfg.si2bis_present) {
3690 f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2ter);
3691 } else if (cfg.si2ter_present and cfg.si2bis_present) {
3692 f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2bis);
3693 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2ter, false, 1, 4);
3694 }
3695
3696 if (cfg.si7_present or cfg.si8_present) {
3697 /* vi) Use of System Information type 7 and 8 is not always necessary. It is necessary
3698 * if System Information type 4 does not contain all information needed for cell
3699 * selection and reselection. */
3700 if (not cfg.bcch_extended) {
3701 testcase.stop("Error: SI7/SI8 require BCCH Extd.");
3702 }
3703 if (cfg.si7_present) {
3704 f_ensure_si_vec_contains(si_per_tc, 7, SYSTEM_INFORMATION_TYPE_7, true);
3705 }
3706 if (cfg.si8_present) {
3707 f_ensure_si_vec_contains(si_per_tc, 3, SYSTEM_INFORMATION_TYPE_8, true);
3708 }
3709 }
3710
3711 if (cfg.si2quater_present) {
3712 /* iii) System information type 2 quater is sent if needed, as determined by the system
3713 * operator. If sent on BCCH Norm, it shall be sent when TC = 5 if neither of 2bis
3714 * and 2ter are used, otherwise it shall be sent at least once within any of 4
3715 * consecutive occurrences of TC = 4. If sent on BCCH Ext, it is sent at least once
3716 * within any of 4 consecutive occurrences of TC = 5. */
3717 if (not (cfg.bcch_extended)) {
3718 if (not (cfg.si2bis_present or cfg.si2ter_present)) {
3719 f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2quater);
3720 } else {
3721 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2quater, false, 1, 4);
3722 }
3723 } else {
3724 f_ensure_si_vec_contains_n_of_m(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2quater, true, 1, 4);
3725 }
3726 }
3727 if (cfg.si9_present) {
3728 /* vi) System Information type 9 is sent in those blocks with TC = 4 which are specified
3729 * in system information type 3 as defined in 3GPP TS 44.018. */
3730 f_ensure_si_vec_contains(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_9); // FIXME SI3
3731 }
3732 if (cfg.si13_present) {
3733 /* vii) System Information type 13 is only related to the GPRS service. System Information
3734 * Type 13 need only be sent if GPRS support is indicated in one or more of System
3735 * Information Type 3 or 4 or 7 or 8 messages. These messages also indicate if the
3736 * message is sent on the BCCH Norm or if the message is transmitted on the BCCH Ext.
3737 * In the case that the message is sent on the BCCH Norm, it is sent at least once
3738 * within any of 4 consecutive occurrences of TC=4. */
3739 if (not cfg.bcch_extended) {
3740 log("not-bccch-extended");
3741 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_13, false, 1, 4);
3742 } else {
3743 log("bccch-extended");
3744 f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_13, true);
3745 }
3746 if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_13alt)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003747 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Cannot have SI13alt and SI13");
Harald Welte48494ca2018-02-25 16:59:50 +01003748 }
3749 }
3750 if (cfg.si16_present or cfg.si17_present) {
3751 /* viii) System Information type 16 and 17 are only related to the SoLSA service. They
3752 * should not be sent in a cell where network sharing is used (see rule xv). */
3753 if (cfg.si22_present) {
3754 testcase.stop("Error: Cannot have SI16/SI17 and SI22!");
3755 }
3756 if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_22)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003757 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Cannot have SI16/SI17 and SI22!");
Harald Welte48494ca2018-02-25 16:59:50 +01003758 }
3759 if (not cfg.bcch_extended) {
3760 testcase.stop("Error: SI16/SI17 requires BCCH Extd!");
3761 }
3762 if (cfg.si16_present) {
3763 f_ensure_si_vec_contains(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_16, true);
3764 }
3765 if (cfg.si17_present) {
3766 f_ensure_si_vec_contains(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_17, true);
3767 }
3768 }
3769
3770 /* ix) System Information type 18 and 20 are sent in order to transmit non-GSM
3771 * broadcast information. The frequency with which they are sent is determined by the
3772 * system operator. System Information type 9 identifies the scheduling of System
3773 * Information type 18 and 20 messages. */
3774
3775 /* x) System Information Type 19 is sent if COMPACT neighbours exist. If System
3776 * Information Type 19 is present, then its scheduling shall be indicated in System
3777 * Information Type 9. */
3778
3779 if (cfg.si15_present) {
3780 /* xi) System Information Type 15 is broadcast if dynamic ARFCN mapping is used in the
3781 * PLMN. If sent on BCCH Norm, it is sent at least once within any of 4 consecutive
3782 * occurrences of TC = 4. If sent on BCCH Ext, it is sent at least once within any of
3783 * 4 consecutive occurrences of TC = 1. */
3784 if (not cfg.bcch_extended) {
3785 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_15, false, 1, 4);
3786 } else {
3787 f_ensure_si_vec_contains_n_of_m(si_per_tc, 1, SYSTEM_INFORMATION_TYPE_15, true, 1, 4);
3788 }
3789 }
3790 if (cfg.si13alt_present) {
3791 /* xii) System Information type 13 alt is only related to the GERAN Iu mode. System
3792 * Information Type 13 alt need only be sent if GERAN Iu mode support is indicated in
3793 * one or more of System Information Type 3 or 4 or 7 or 8 messages and SI 13 is not
3794 * broadcast. These messages also indicate if the message is sent on the BCCH Norm or
3795 * if the message is transmitted on the BCCH Ext. In the case that the message is sent
3796 * on the BCCH Norm, it is sent at least once within any of 4 consecutive occurrences
3797 * of TC = 4. */
3798 if (cfg.si13_present) {
3799 testcase.stop("Error: Cannot have SI13alt and SI13");
3800 }
3801 if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_13)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003802 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Cannot have SI13alt and SI13");
Harald Welte48494ca2018-02-25 16:59:50 +01003803 }
3804 if (not cfg.bcch_extended) {
3805 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_13alt, false, 1, 4);
3806 } else {
3807 f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_13alt, true);
3808 }
3809 }
3810 if (cfg.si2n_present) {
3811 /* xiii) System Information Type 2n is optionally sent on BCCH Norm or BCCH Ext if needed,
3812 * as determined by the system operator. In the case that the message is sent on the
3813 * BCCH Norm, it is sent at least once within any of 4 consecutive occurrences of TC =
3814 * 4. If the message is sent on BCCH Ext, it is sent at least once within any of 2
3815 * consecutive occurrences of TC = 4. */
3816 if (not cfg.bcch_extended) {
3817 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2n, false, 1, 4);
3818 } else {
3819 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2n, true, 2, 4);
3820 }
3821 }
3822 if (cfg.si21_present) {
3823 /* xiv) System Information Type 21 is optionally sent on BCCH Norm or BCCH Ext, as
3824 * determined by the system operator. If Extended Access Barring is in use in the cell
3825 * then this message is sent at least once within any of 4 consecutive occurrences of
3826 * TC = 4 regardless if it is sent on BCCH Norm or BCCH Ext. If BCCH Ext is used in a
3827 * cell then this message shall only be sent on BCCH Ext. */
3828 if (not cfg.bcch_extended) {
3829 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_21, false, 1, 4);
3830 } else {
3831 f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_21, true, 1, 4);
3832 if (f_si_vecslot_contains(si_per_tc[4], SYSTEM_INFORMATION_TYPE_21)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003833 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Cannot have SI21 on BCCH Norm if BCCH Extd enabled!");
Harald Welte48494ca2018-02-25 16:59:50 +01003834 }
3835 }
3836 }
3837 if (cfg.si22_present) {
3838 /* xv) System Information Type 22 is sent if network sharing is in use in the cell. It
3839 * should not be sent in a cell where SoLSA is used (see rule viii). System
3840 * Information Type 22 instances shall be sent on BCCH Ext within any occurrence of TC
3841 * =2 and TC=6. */
3842 if (cfg.si16_present or cfg.si17_present) {
3843 testcase.stop("Error: Cannot have SI16/SI17 and SI22!");
3844 }
3845 if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_16) or
3846 f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_17)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003847 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Cannot have SI16/SI17 and SI22!");
Harald Welte48494ca2018-02-25 16:59:50 +01003848 }
3849 if (not cfg.bcch_extended) {
3850 testcase.stop("Error: SI22 requires BCCH Extd!");
3851 } else {
3852 f_ensure_si_vec_contains_only(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_22, true);
3853 f_ensure_si_vec_contains_only(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_22, true);
3854 }
3855 }
3856}
3857
3858/* sample Systme Information for specified duration via L1CTL */
3859function f_l1_sample_si(L1CTL_PT pt, float duration := 8.0) return SystemInformationVectorPerTc {
3860 timer T := duration;
3861 var SystemInformationVectorPerTc si_per_tc;
3862 var L1ctlDlMessage l1_dl;
3863
3864 /* initialize all per-TC vectors empty */
3865 for (var integer i:= 0; i < sizeof(si_per_tc); i := i+1) {
3866 si_per_tc[i] := {};
3867 }
3868
3869 /* flush all previous L1 queued msgs */
3870 pt.clear;
3871
3872 T.start;
3873 alt {
Harald Weltef8df4cb2018-03-10 15:15:08 +01003874 [] pt.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl {
Harald Welte48494ca2018-02-25 16:59:50 +01003875 /* somehow dec_SystemInformation will try to decode even non-RR as SI */
3876 if (not (l1_dl.payload.data_ind.payload[1] == '06'O)) {
3877 log("Ignoring non-RR SI ", l1_dl);
3878 repeat;
3879 }
3880 var SystemInformationFn sig := {
3881 frame_number := l1_dl.dl_info.frame_nr,
3882 si := dec_SystemInformation(l1_dl.payload.data_ind.payload)
3883 }
3884 var integer tc := f_gsm_compute_tc(sig.frame_number);
3885 log("SI received at TC=", tc, ": ", sig.si);
3886 /* append to the per-TC bucket */
3887 si_per_tc[tc] := si_per_tc[tc] & { sig };
3888 repeat;
3889 }
3890 [] pt.receive { repeat; }
3891 [] T.timeout { }
3892 }
3893
3894 for (var integer i:= 0; i < sizeof(si_per_tc); i := i+1) {
3895 log(testcasename(), ": TC=", i, " has #of SI=", sizeof(si_per_tc[i]));
3896 }
3897 log("si_per_tc=", si_per_tc);
3898 return si_per_tc;
3899}
3900
3901/* helper function: Set given SI via RSL + validate scheduling.
3902 * CALLER MUST MAKE SURE TO CHANGE GLOBAL si_cfg! */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07003903private function f_TC_si_sched() runs on test_CT {
Harald Welte48494ca2018-02-25 16:59:50 +01003904 var SystemInformationVectorPerTc si_per_tc;
3905 f_init_l1ctl();
3906 f_l1_tune(L1CTL);
3907
3908 /* Sample + Validate Scheduling */
3909 si_per_tc := f_l1_sample_si(L1CTL);
3910 f_validate_si_scheduling(si_cfg, si_per_tc);
3911
3912 setverdict(pass);
3913}
3914
3915testcase TC_si_sched_default() runs on test_CT {
3916 f_init();
Harald Welte0cae4552018-03-09 22:20:26 +01003917 /* 2+3+4 are mandatory and set in f_init() */
3918 f_TC_si_sched();
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003919 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte0cae4552018-03-09 22:20:26 +01003920}
3921
3922testcase TC_si_sched_1() runs on test_CT {
3923 f_init();
3924 si_cfg.si1_present := true;
3925 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_1, '5506198fb38000000000000000000000000000e504002b'O);
Harald Welte48494ca2018-02-25 16:59:50 +01003926 f_TC_si_sched();
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003927 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte48494ca2018-02-25 16:59:50 +01003928}
3929
3930testcase TC_si_sched_2bis() runs on test_CT {
3931 f_init();
3932 si_cfg.si2bis_present := true;
3933 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O);
3934 f_TC_si_sched();
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003935 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte48494ca2018-02-25 16:59:50 +01003936}
3937
3938testcase TC_si_sched_2ter() runs on test_CT {
3939 f_init();
3940 si_cfg.si2ter_present := true;
3941 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O);
3942 f_TC_si_sched();
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003943 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte48494ca2018-02-25 16:59:50 +01003944}
3945
3946testcase TC_si_sched_2ter_2bis() runs on test_CT {
3947 f_init();
3948 si_cfg.si2bis_present := true;
3949 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O);
3950 si_cfg.si2ter_present := true;
3951 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O);
3952 f_TC_si_sched();
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003953 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte48494ca2018-02-25 16:59:50 +01003954}
3955
3956testcase TC_si_sched_2quater() runs on test_CT {
3957 f_init();
3958 si_cfg.si2quater_present := true;
3959 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2quater, '050607a8a0364aa698d72ff424feee0506d5e7fff02043'O);
3960 f_TC_si_sched();
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003961 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte48494ca2018-02-25 16:59:50 +01003962}
3963
3964testcase TC_si_sched_13() runs on test_CT {
3965 f_init();
3966 si_cfg.si13_present := true;
Harald Welte5618c2a2018-04-15 16:24:46 +02003967 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_13, '0106009000185a6fc9e08410ab2b2b2b2b2b2b2b2b2b2b'O);
Harald Welte48494ca2018-02-25 16:59:50 +01003968 f_TC_si_sched();
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003969 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte48494ca2018-02-25 16:59:50 +01003970}
3971
3972testcase TC_si_sched_13_2bis_2ter_2quater() runs on test_CT {
3973 f_init();
3974 si_cfg.si2bis_present := true;
3975 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O);
3976 si_cfg.si2ter_present := true;
3977 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O);
3978 si_cfg.si2quater_present := true;
3979 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2quater, '050607a8a0364aa698d72ff424feee0506d5e7fff02043'O);
3980 si_cfg.si13_present := true;
Harald Welte5618c2a2018-04-15 16:24:46 +02003981 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_13, '0106009000185a6fc9e08410ab2b2b2b2b2b2b2b2b2b2b'O);
Harald Welte48494ca2018-02-25 16:59:50 +01003982 f_TC_si_sched();
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003983 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte48494ca2018-02-25 16:59:50 +01003984}
3985
3986
Harald Welte68e495b2018-02-25 00:05:57 +01003987testcase TC_bcch_info() runs on test_CT {
Harald Welte10474062019-05-30 16:48:17 +02003988 f_init();
Harald Welte68e495b2018-02-25 00:05:57 +01003989 /* FIXME: enable / disable individual BCCH info */
3990 //ts_RSL_BCCH_INFO(si_type, info);
3991 /* expect no ERROR REPORT after either of them *
3992 /* negative test: ensure ERROR REPORT on unsupported types */
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02003993 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte68e495b2018-02-25 00:05:57 +01003994}
3995
Harald Welte93640c62018-02-25 16:59:33 +01003996/***********************************************************************
3997 * Low-Level Protocol Errors / ERROR REPORT
3998 ***********************************************************************/
3999
Harald Welte01d982c2018-02-25 01:31:40 +01004000private function f_exp_err_rep(template RSL_Cause cause) runs on test_CT {
4001 timer T := 5.0;
4002 T.start;
4003 alt {
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07004004 [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_ERROR_REPORT(cause))) {
Harald Welte01d982c2018-02-25 01:31:40 +01004005 setverdict(pass);
4006 }
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07004007 [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_ERROR_REPORT(?))) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004008 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Wrong cause in RSL ERR REP");
Harald Welte01d982c2018-02-25 01:31:40 +01004009 }
4010 [] RSL_CCHAN.receive {
4011 repeat;
4012 }
4013 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004014 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RSL ERR REP");
Harald Welte01d982c2018-02-25 01:31:40 +01004015 }
4016 }
4017}
4018
4019/* Provoke a protocol error (message too short) and match on ERROR REPORT */
4020testcase TC_rsl_protocol_error() runs on test_CT {
Harald Welte10474062019-05-30 16:48:17 +02004021 f_init();
Harald Welte01d982c2018-02-25 01:31:40 +01004022 var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O));
4023 rsl.ies := omit;
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07004024 RSL_CCHAN.send(ts_ASP_RSL_UD(rsl));
Harald Welte01d982c2018-02-25 01:31:40 +01004025
4026 f_exp_err_rep(RSL_ERR_PROTO);
4027}
4028
4029/* Provoke a mandatory IE error and match on ERROR REPORT */
4030testcase TC_rsl_mand_ie_error() runs on test_CT {
Harald Welte10474062019-05-30 16:48:17 +02004031 f_init();
Harald Welte01d982c2018-02-25 01:31:40 +01004032
4033 var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O));
4034 rsl.ies := { rsl.ies[0] };
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07004035 RSL_CCHAN.send(ts_ASP_RSL_UD(rsl));
Harald Welte01d982c2018-02-25 01:31:40 +01004036
4037 f_exp_err_rep(RSL_ERR_MAND_IE_ERROR);
4038}
4039
4040/* Provoke an IE content error and match on ERROR REPORT */
4041testcase TC_rsl_ie_content_error() runs on test_CT {
Harald Welte10474062019-05-30 16:48:17 +02004042 f_init();
Harald Welte01d982c2018-02-25 01:31:40 +01004043 var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O));
4044 rsl.ies[1].body.sysinfo_type := RSL_SYSTEM_INFO_5;
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07004045 RSL_CCHAN.send(ts_ASP_RSL_UD(rsl));
Harald Welte01d982c2018-02-25 01:31:40 +01004046
4047 f_exp_err_rep(RSL_ERR_IE_CONTENT);
4048}
4049
Harald Welteee25aae2019-05-19 14:32:37 +02004050/* attempt to activate channel with wrong RSL Message Discriminator IE */
4051function f_TC_chan_act_wrong_mdisc(charstring id) runs on ConnHdlr {
4052 var template RSL_Message rsl := ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode);
4053 rsl.msg_disc := ts_RSL_MsgDisc(RSL_MDISC_RESERVED, false);
4054 RSL.send(rsl);
4055 f_rslem_unregister(0, g_chan_nr);
4056}
4057testcase TC_err_rep_wrong_mdisc() runs on test_CT {
4058 var ConnHdlr vc_conn;
4059 var ConnHdlrPars pars := valueof(t_Pars(ts_RslChanNr_SDCCH4(0,0), ts_RSL_ChanMode_SIGN));
4060
Harald Welte10474062019-05-30 16:48:17 +02004061 f_init();
Harald Welteee25aae2019-05-19 14:32:37 +02004062
4063 vc_conn := f_start_handler(refers(f_TC_chan_act_wrong_mdisc), pars);
4064 vc_conn.done;
4065 f_exp_err_rep(RSL_ERR_MSG_DISCR);
4066
4067 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
4068}
4069
4070/* Send messages with wrong message type */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07004071private function f_TC_wrong_msg_type_dchan(charstring id) runs on ConnHdlr {
Harald Welteee25aae2019-05-19 14:32:37 +02004072 var template (value) RSL_Message rsl_tx;
4073 rsl_tx := ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode);
4074 rsl_tx.msg_type := RSL_MT_NOT_CMD;
4075 RSL.send(rsl_tx);
4076 f_rslem_unregister(0, g_chan_nr);
4077}
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07004078private function f_TC_wrong_msg_type_rll(charstring id) runs on ConnHdlr {
Harald Welteee25aae2019-05-19 14:32:37 +02004079 var template (value) RSL_Message rsl_tx;
4080 /* we first have to activate the dedicated channel */
4081 f_rsl_chan_act(g_pars.chan_mode);
4082 /* ... to then send an invalid RLL message */
4083 rsl_tx := ts_RSL_UNITDATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0), '0102'O);
4084 rsl_tx.msg_type := RSL_MT_CBCH_LOAD_IND;
4085 RSL.send(rsl_tx);
4086 f_rslem_unregister(0, g_chan_nr);
4087}
4088testcase TC_err_rep_wrong_msg_type() runs on test_CT {
4089 var ConnHdlr vc_conn;
4090 var ConnHdlrPars pars := valueof(t_Pars(ts_RslChanNr_SDCCH4(0,0), ts_RSL_ChanMode_SIGN));
4091 var template (value) RSL_Message rsl_tx;
4092
Harald Welte10474062019-05-30 16:48:17 +02004093 f_init();
Harald Welteee25aae2019-05-19 14:32:37 +02004094
4095 /* Common Channel with wrong message type */
4096 RSL_CCHAN.clear;
4097 rsl_tx := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O));
4098 rsl_tx.msg_type := RSL_MT_LOCATION_INFO;
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07004099 RSL_CCHAN.send(ts_ASP_RSL_UD(rsl_tx));
Harald Welteee25aae2019-05-19 14:32:37 +02004100 f_exp_err_rep(RSL_ERR_MSG_TYPE);
4101
4102 /* TRX Management */
4103 RSL_CCHAN.clear;
4104 rsl_tx := ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, ''O);
4105 rsl_tx.msg_type := RSL_MT_UNIT_DATA_IND;
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07004106 RSL_CCHAN.send(ts_ASP_RSL_UD(rsl_tx));
Harald Welteee25aae2019-05-19 14:32:37 +02004107 f_exp_err_rep(RSL_ERR_MSG_TYPE);
4108
4109 /* Dedicated Channel */
4110 RSL_CCHAN.clear;
4111 vc_conn := f_start_handler(refers(f_TC_wrong_msg_type_dchan), pars);
4112 vc_conn.done;
4113 f_exp_err_rep(RSL_ERR_MSG_TYPE);
4114
4115 /* RLL */
4116 RSL_CCHAN.clear;
4117 vc_conn := f_start_handler(refers(f_TC_wrong_msg_type_rll), pars);
4118 vc_conn.done;
4119 f_exp_err_rep(RSL_ERR_MSG_TYPE);
4120}
4121
4122/* Send messages in wrong sequence (RLL to an inactive lchan) */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07004123private function f_TC_err_rep_wrong_sequence(charstring id) runs on ConnHdlr {
Harald Welteee25aae2019-05-19 14:32:37 +02004124 RSL.send(ts_RSL_UNITDATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0), '0102'O));
4125 f_rslem_unregister(0, g_chan_nr);
4126}
4127testcase TC_err_rep_wrong_sequence() runs on test_CT {
4128 var ConnHdlr vc_conn;
4129 var ConnHdlrPars pars := valueof(t_Pars(ts_RslChanNr_SDCCH4(0,0), ts_RSL_ChanMode_SIGN));
4130
Harald Welte10474062019-05-30 16:48:17 +02004131 f_init();
Harald Welteee25aae2019-05-19 14:32:37 +02004132
4133 RSL_CCHAN.clear;
4134 vc_conn := f_start_handler(refers(f_TC_err_rep_wrong_sequence), pars);
4135 vc_conn.done;
4136 f_exp_err_rep(RSL_ERR_MSG_SEQ);
4137}
4138
Harald Welte93640c62018-02-25 16:59:33 +01004139/***********************************************************************
4140 * IPA CRCX/MDCX/DLCS media stream handling
4141 ***********************************************************************/
4142
Harald Weltea871a382018-02-25 02:03:14 +01004143/* Send IPA DLCX to inactive lchan */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07004144private function f_TC_ipa_dlcx_not_active(charstring id) runs on ConnHdlr {
Harald Welte1eba3742018-02-25 12:48:14 +01004145 f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, 0), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?),
4146 "IPA DLCX ACK");
Harald Weltea871a382018-02-25 02:03:14 +01004147}
4148testcase TC_ipa_dlcx_not_active() runs on test_CT {
4149 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
Harald Welte10474062019-05-30 16:48:17 +02004150 f_init();
Harald Weltea871a382018-02-25 02:03:14 +01004151 var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_dlcx_not_active), pars);
4152 vc_conn.done;
4153}
Harald Welte68e495b2018-02-25 00:05:57 +01004154
Harald Weltea3f1df92018-02-25 12:49:55 +01004155/* Send IPA CRCX twice to inactive lchan */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07004156private function f_TC_ipa_crcx_twice_not_active(charstring id) runs on ConnHdlr {
Harald Weltea3f1df92018-02-25 12:49:55 +01004157 f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?),
4158 "IPA CRCX ACK");
4159 f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_NACK(g_chan_nr, RSL_ERR_RES_UNAVAIL),
4160 "IPA CRCX NACK");
4161}
4162testcase TC_ipa_crcx_twice_not_active() runs on test_CT {
4163 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
Harald Welte10474062019-05-30 16:48:17 +02004164 f_init();
Harald Weltea3f1df92018-02-25 12:49:55 +01004165 var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_twice_not_active), pars);
4166 vc_conn.done;
4167}
4168
4169/* Regular sequence of CRCX/MDCX/DLCX */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07004170private function f_TC_ipa_crcx_mdcx_dlcx_not_active(charstring id) runs on ConnHdlr {
Harald Weltea3f1df92018-02-25 12:49:55 +01004171 f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?),
4172 "IPA CRCX ACK");
4173 var uint32_t remote_ip := f_rnd_int(c_UINT32_MAX);
4174 var uint16_t remote_port := f_rnd_int(c_UINT16_MAX);
4175 var uint7_t rtp_pt2 := f_rnd_int(127);
4176 var uint16_t fake_conn_id := 23; /* we're too lazy to read it out from the CRCX ACK above */
4177 f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2),
4178 tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2),
4179 "IPA MDCX ACK");
4180 f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, fake_conn_id), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?),
4181 "IPA DLCX ACK");
4182}
4183testcase TC_ipa_crcx_mdcx_dlcx_not_active() runs on test_CT {
4184 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
Harald Welte10474062019-05-30 16:48:17 +02004185 f_init();
Harald Weltea3f1df92018-02-25 12:49:55 +01004186 var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_mdcx_dlcx_not_active), pars);
4187 vc_conn.done;
4188}
4189
Harald Welte3ae11da2018-02-25 13:36:06 +01004190/* Sequence of CRCX, 2x MDCX, DLCX */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07004191private function f_TC_ipa_crcx_mdcx_mdcx_dlcx_not_active(charstring id) runs on ConnHdlr {
Harald Welte3ae11da2018-02-25 13:36:06 +01004192 f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?),
4193 "IPA CRCX ACK");
4194 var uint32_t remote_ip := f_rnd_int(c_UINT32_MAX);
4195 var uint16_t remote_port := f_rnd_int(c_UINT16_MAX);
4196 var uint7_t rtp_pt2 := f_rnd_int(127);
4197 var uint16_t fake_conn_id := 23; /* we're too lazy to read it out from the CRCX ACK above */
4198 f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2),
4199 tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2),
4200 "IPA MDCX ACK");
4201 /* Second MDCX */
4202 remote_ip := f_rnd_int(c_UINT32_MAX);
4203 remote_port := f_rnd_int(c_UINT16_MAX);
4204 f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2),
4205 tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2),
4206 "IPA MDCX ACK");
4207 f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, fake_conn_id), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?),
4208 "IPA DLCX ACK");
4209}
4210testcase TC_ipa_crcx_mdcx_mdcx_dlcx_not_active() runs on test_CT {
4211 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
Harald Welte10474062019-05-30 16:48:17 +02004212 f_init();
Harald Welte3ae11da2018-02-25 13:36:06 +01004213 var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_mdcx_mdcx_dlcx_not_active), pars);
4214 vc_conn.done;
4215}
4216
Harald Welte9912eb52018-02-25 13:30:15 +01004217/* IPA CRCX on SDCCH/4 and SDCCH/8 (doesn't make sense) */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07004218private function f_TC_ipa_crcx_sdcch_not_active(charstring id) runs on ConnHdlr {
Harald Welte9912eb52018-02-25 13:30:15 +01004219 f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_NACK(g_chan_nr, ?),
4220 "IPA CRCX NACK");
4221}
4222testcase TC_ipa_crcx_sdcch_not_active() runs on test_CT {
4223 var ConnHdlrPars pars;
4224 var ConnHdlr vc_conn;
Harald Welte10474062019-05-30 16:48:17 +02004225 f_init();
Harald Welte9912eb52018-02-25 13:30:15 +01004226
4227 pars := valueof(t_Pars(t_RslChanNr_SDCCH4(0,1), ts_RSL_ChanMode_SIGN));
4228 vc_conn := f_start_handler(refers(f_TC_ipa_crcx_sdcch_not_active), pars);
4229 vc_conn.done;
4230
4231 pars := valueof(t_Pars(t_RslChanNr_SDCCH8(6,5), ts_RSL_ChanMode_SIGN));
4232 vc_conn := f_start_handler(refers(f_TC_ipa_crcx_sdcch_not_active), pars);
4233 vc_conn.done;
4234}
4235
Harald Weltea3f1df92018-02-25 12:49:55 +01004236
Harald Welte883340c2018-02-28 18:59:29 +01004237/***********************************************************************
4238 * PCU Socket related tests
4239 ***********************************************************************/
4240
Harald Welte07bd2d22019-05-25 11:03:30 +02004241/* Verify no RTS before ACT_REQ; verify RTS after ACT_REQ */
Harald Weltead033dc2019-05-25 17:28:16 +02004242friend 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 +01004243runs on test_CT {
4244 timer T := 3.0;
4245
4246 /* we don't expect any RTS.req before PDCH are active */
4247 T.start;
4248 alt {
4249 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(bts_nr))) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004250 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "PCU RTS.req before PDCH active?");
Harald Welte883340c2018-02-28 18:59:29 +01004251 }
4252 [] PCU.receive { repeat; }
4253 [] T.timeout { }
4254 }
4255
4256 /* Send PDCH activate request for known PDCH timeslot */
4257 PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, ts_nr)));
4258
4259 /* we now expect RTS.req for this timeslot (only) */
4260 T.start;
4261 alt {
4262 [exp_success] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr))) {
4263 setverdict(pass);
4264 }
4265 [not exp_success] PCU.receive(t_SD_PCUIF(g_pcu_conn_id,
4266 tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr))) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004267 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RTS.req for supposedly failing activation");
Harald Welte883340c2018-02-28 18:59:29 +01004268 }
4269 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004270 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "RTS.req for wrong TRX/TS");
Harald Welte883340c2018-02-28 18:59:29 +01004271 }
4272 [] PCU.receive { repeat; }
4273 [exp_success] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004274 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PCU RTS.req");
Harald Welte883340c2018-02-28 18:59:29 +01004275 }
4276 [not exp_success] T.timeout {
4277 setverdict(pass);
4278 }
4279 }
4280}
4281
Harald Welte07bd2d22019-05-25 11:03:30 +02004282/* verify no more RTS after DEACT_REQ */
Harald Weltead033dc2019-05-25 17:28:16 +02004283friend 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 +01004284runs on test_CT {
4285 timer T := 3.0;
4286
4287 /* Send PDCH activate request for known PDCH timeslot */
4288 PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_DEACT_REQ(bts_nr, trx_nr, ts_nr)));
4289
4290 PCU.clear;
4291 /* we now expect no RTS.req for this timeslot */
4292 T.start;
4293 alt {
4294 [] 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 +02004295 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received unexpected PCU RTS.req");
Harald Welte883340c2018-02-28 18:59:29 +01004296 }
4297 [] PCU.receive { repeat; }
4298 [] T.timeout {
4299 setverdict(pass);
4300 }
4301 }
4302}
4303
Harald Weltead033dc2019-05-25 17:28:16 +02004304friend function f_init_pcu_test() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01004305 f_init();
4306 PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_TXT_IND(0, PCU_VERSION, testcasename())));
4307}
4308
Harald Welte883340c2018-02-28 18:59:29 +01004309/* PDCH activation via PCU socket; check for presence of RTS.req */
4310testcase TC_pcu_act_req() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01004311 f_init_pcu_test();
4312
Harald Welte883340c2018-02-28 18:59:29 +01004313 f_TC_pcu_act_req(0, 0, 7, true);
4314}
4315
4316/* PDCH activation via PCU socket on non-PDCU timeslot */
4317testcase TC_pcu_act_req_wrong_ts() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01004318 f_init_pcu_test();
4319
Harald Welte883340c2018-02-28 18:59:29 +01004320 f_TC_pcu_act_req(0, 0, 1, false);
4321}
4322
4323/* PDCH activation via PCU socket on wrong BTS */
4324testcase TC_pcu_act_req_wrong_bts() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01004325 f_init_pcu_test();
4326
Harald Welte883340c2018-02-28 18:59:29 +01004327 f_TC_pcu_act_req(23, 0, 7, false);
4328}
4329
4330/* PDCH activation via PCU socket on wrong TRX */
4331testcase TC_pcu_act_req_wrong_trx() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01004332 f_init_pcu_test();
4333
Harald Welte883340c2018-02-28 18:59:29 +01004334 f_TC_pcu_act_req(0, 23, 7, false);
4335}
4336
4337/* PDCH deactivation via PCU socket; check for absence of RTS.req */
4338testcase TC_pcu_deact_req() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01004339 f_init_pcu_test();
4340
Harald Welte883340c2018-02-28 18:59:29 +01004341 /* Activate PDCH */
4342 f_TC_pcu_act_req(0, 0, 7, true);
4343 f_sleep(1.0);
4344 /* and De-Activate again */
4345 f_TC_pcu_deact_req(0, 0, 7);
4346}
4347
4348/* Attempt to deactivate a PDCH on a non-PDCH timeslot */
4349testcase TC_pcu_deact_req_wrong_ts() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01004350 f_init_pcu_test();
4351
Harald Welte883340c2018-02-28 18:59:29 +01004352 f_TC_pcu_deact_req(0, 0, 1);
4353}
4354
4355/* Test the PCU->BTS Version and BTS->PCU SI13 handshake */
4356testcase TC_pcu_ver_si13() runs on test_CT {
4357 const octetstring si13 := '00010203040506070909'O;
4358 var PCUIF_send_data sd;
4359 timer T:= 3.0;
Max2c6f5632019-03-18 17:25:17 +01004360 f_init_pcu_test();
Harald Welte883340c2018-02-28 18:59:29 +01004361
4362 /* Set SI13 via RSL */
4363 f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_13, si13);
Max2c6f5632019-03-18 17:25:17 +01004364
Harald Welte883340c2018-02-28 18:59:29 +01004365 T.start;
4366 alt {
4367 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_DATA_IND(0, 0, 0, ?, PCU_IF_SAPI_BCCH))) -> value sd {
4368 if (substr(sd.data.u.data_ind.data, 0, lengthof(si13)) == si13) {
4369 setverdict(pass);
4370 } else {
4371 repeat;
4372 }
4373 }
4374 [] PCU.receive { repeat; }
4375 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004376 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for SI13");
Harald Welte883340c2018-02-28 18:59:29 +01004377 }
4378 }
4379}
4380
4381private const octetstring c_PCU_DATA := '000102030405060708090a0b0c0d0e0f10111213141516'O;
4382
4383/* helper function to send a PCU DATA.req */
Harald Weltead033dc2019-05-25 17:28:16 +02004384friend function f_pcu_data_req(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr,
Harald Welte883340c2018-02-28 18:59:29 +01004385 uint8_t block_nr, uint32_t fn, PCUIF_Sapi sapi, octetstring data)
4386runs on test_CT
4387{
4388 PCU.send(t_SD_PCUIF(g_pcu_conn_id,
4389 ts_PCUIF_DATA_REQ(bts_nr, trx_nr, ts_nr, block_nr, fn, sapi, data)));
4390}
4391
4392/* 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 +02004393friend function f_pcu_wait_rts_and_data_req(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr,
4394 PCUIF_Sapi sapi, octetstring data)
Harald Welte883340c2018-02-28 18:59:29 +01004395runs on test_CT
4396{
4397 var PCUIF_send_data sd;
4398
4399 timer T := 3.0;
4400 T.start;
4401 alt {
4402 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id,
4403 tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr, sapi))) -> value sd {
4404 f_pcu_data_req(bts_nr, trx_nr, ts_nr, sd.data.u.rts_req.block_nr,
4405 sd.data.u.rts_req.fn, sapi, data);
4406 }
4407 [] PCU.receive { repeat; }
4408 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004409 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RTS.ind");
Harald Welte883340c2018-02-28 18:59:29 +01004410 }
4411 }
4412}
4413
4414/* Send DATA.req on invalid BTS */
4415testcase TC_pcu_data_req_wrong_bts() runs on test_CT {
Harald Welte7162a612019-05-26 12:56:09 +02004416 var TfiUsfArr tua := f_TfiUsfArrInit();
4417 var octetstring data := '0000'O & f_rnd_octstring(21);
4418
4419 f_virtphy_common();
Max2c6f5632019-03-18 17:25:17 +01004420
Harald Welte883340c2018-02-28 18:59:29 +01004421 f_TC_pcu_act_req(0, 0, 7, true);
Harald Welte7162a612019-05-26 12:56:09 +02004422 f_TfiUsfArrSet(tua, 7, 0);
4423 f_L1CTL_TBF_CFG(L1CTL, false, tua);
4424 f_sleep(1.0);
4425
4426 f_pcu_to_l1(23, 0, 7, PCU_IF_SAPI_PDTCH, data, false, false);
Harald Welte883340c2018-02-28 18:59:29 +01004427}
4428
4429/* Send DATA.req on invalid TRX */
4430testcase TC_pcu_data_req_wrong_trx() runs on test_CT {
Harald Welte7162a612019-05-26 12:56:09 +02004431 var TfiUsfArr tua := f_TfiUsfArrInit();
4432 var octetstring data := '0000'O & f_rnd_octstring(21);
4433
4434 f_virtphy_common();
Max2c6f5632019-03-18 17:25:17 +01004435
Harald Welte883340c2018-02-28 18:59:29 +01004436 f_TC_pcu_act_req(0, 0, 7, true);
Harald Welte7162a612019-05-26 12:56:09 +02004437 f_TfiUsfArrSet(tua, 7, 0);
4438 f_L1CTL_TBF_CFG(L1CTL, false, tua);
4439 f_sleep(1.0);
4440
4441 f_pcu_to_l1(0, 100, 7, PCU_IF_SAPI_PDTCH, data, false, false);
Harald Welte883340c2018-02-28 18:59:29 +01004442}
4443
4444/* Send DATA.req on invalid timeslot */
4445testcase TC_pcu_data_req_wrong_ts() runs on test_CT {
Harald Welte7162a612019-05-26 12:56:09 +02004446 var TfiUsfArr tua := f_TfiUsfArrInit();
4447 var octetstring data := '0000'O & f_rnd_octstring(21);
4448
4449 f_virtphy_common();
Max2c6f5632019-03-18 17:25:17 +01004450
Harald Welte883340c2018-02-28 18:59:29 +01004451 f_TC_pcu_act_req(0, 0, 7, true);
Harald Welte7162a612019-05-26 12:56:09 +02004452 f_TfiUsfArrSet(tua, 7, 0);
4453 f_L1CTL_TBF_CFG(L1CTL, false, tua);
4454 f_sleep(1.0);
4455
4456 f_pcu_to_l1(0, 0, 70, PCU_IF_SAPI_PDTCH, data, false, false);
Harald Welte883340c2018-02-28 18:59:29 +01004457}
4458
4459/* Send DATA.req on timeslot that hasn't been activated */
4460testcase TC_pcu_data_req_ts_inactive() runs on test_CT {
Harald Welte7162a612019-05-26 12:56:09 +02004461 var TfiUsfArr tua := f_TfiUsfArrInit();
4462 var octetstring data := '0000'O & f_rnd_octstring(21);
Max2c6f5632019-03-18 17:25:17 +01004463
Harald Welte7162a612019-05-26 12:56:09 +02004464 f_virtphy_common();
4465
4466 f_TfiUsfArrSet(tua, 7, 0);
4467 f_L1CTL_TBF_CFG(L1CTL, false, tua);
4468 f_sleep(1.0);
4469
4470 f_pcu_to_l1(0, 0, 7, PCU_IF_SAPI_PDTCH, data, false, false);
Harald Welte883340c2018-02-28 18:59:29 +01004471}
4472
Harald Weltead033dc2019-05-25 17:28:16 +02004473private function f_pcu_to_l1(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr,
Harald Welte7162a612019-05-26 12:56:09 +02004474 PCUIF_Sapi sapi, octetstring data, boolean expect_data := true,
4475 boolean wait_rts := true)
4476runs on test_CT {
Harald Weltead033dc2019-05-25 17:28:16 +02004477 timer T := 5.0;
Harald Welte7162a612019-05-26 12:56:09 +02004478 var L1ctlDlMessage rx_dl;
Harald Weltead033dc2019-05-25 17:28:16 +02004479
4480 PCU.clear;
Harald Welte7162a612019-05-26 12:56:09 +02004481 if (wait_rts) {
4482 f_pcu_wait_rts_and_data_req(bts_nr, trx_nr, ts_nr, sapi, data);
4483 } else {
4484 f_pcu_data_req(bts_nr, trx_nr, ts_nr, 0, 0, sapi, data);
4485 }
Harald Weltead033dc2019-05-25 17:28:16 +02004486
4487 T.start;
4488 alt {
Harald Welte7162a612019-05-26 12:56:09 +02004489 [expect_data] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PDCH(ts_nr), ?, data)) {
Harald Weltead033dc2019-05-25 17:28:16 +02004490 /* FIXME: why is fn of DATA_IND different to fn of RTS / DATA_REQ above? */
4491 setverdict(pass);
4492 }
Harald Welte7162a612019-05-26 12:56:09 +02004493 [not expect_data] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PDCH(ts_nr), ?, data)) -> value rx_dl {
4494 setverdict(fail, "Received unexpected ", rx_dl);
4495 }
Harald Weltead033dc2019-05-25 17:28:16 +02004496 [] L1CTL.receive {
4497 repeat;
4498 }
Harald Welte7162a612019-05-26 12:56:09 +02004499 [expect_data] T.timeout {
Harald Weltead033dc2019-05-25 17:28:16 +02004500 setverdict(fail, "Timeout waiting for ", data);
4501 }
Harald Welte7162a612019-05-26 12:56:09 +02004502 [not expect_data] T.timeout {
4503 setverdict(pass);
4504 }
Harald Weltead033dc2019-05-25 17:28:16 +02004505 }
4506}
4507
4508private function f_disable_dynamic_ts() runs on test_CT
4509{
4510 f_init_vty_bsc();
4511 /* I'm not quite sure why we need this with osmo-bts-virtual. Somehow it deosn't seem to
4512 * support dynamic timeslots? But it uses the same scheduler as osmo-bts-trx ?!? */
4513 f_vty_config2(BSCVTY, {"network", "bts 0", "trx 0", "timeslot 3"}, "phys_chan_config TCH/F");
4514 f_vty_config2(BSCVTY, {"network", "bts 0", "trx 0", "timeslot 4"}, "phys_chan_config TCH/F");
Max2c6f5632019-03-18 17:25:17 +01004515 f_init_pcu_test();
Harald Weltead033dc2019-05-25 17:28:16 +02004516}
4517
4518private function f_virtphy_common() runs on test_CT {
4519 f_disable_dynamic_ts();
4520 f_init_l1ctl();
4521 f_l1_tune(L1CTL);
4522}
4523
4524testcase TC_pcu_data_req_pdtch() runs on test_CT {
4525 var TfiUsfArr tua := f_TfiUsfArrInit();
4526 var octetstring data := '0000'O & f_rnd_octstring(21);
4527
4528 f_virtphy_common();
Max2c6f5632019-03-18 17:25:17 +01004529
Harald Welte883340c2018-02-28 18:59:29 +01004530 f_TC_pcu_act_req(0, 0, 7, true);
Harald Weltead033dc2019-05-25 17:28:16 +02004531 f_TfiUsfArrSet(tua, 7, 0);
4532 f_L1CTL_TBF_CFG(L1CTL, false, tua);
4533 f_sleep(1.0);
4534
4535 f_pcu_to_l1(0, 0, 7, PCU_IF_SAPI_PDTCH, data); //c_PCU_DATA);
Harald Welte883340c2018-02-28 18:59:29 +01004536}
4537
Vadim Yanitskiy8c242f02019-10-13 15:25:54 +07004538/* FIXME: PTTCH has nothing to do with TBFs */
Harald Welte883340c2018-02-28 18:59:29 +01004539testcase TC_pcu_data_req_ptcch() runs on test_CT {
Harald Weltead033dc2019-05-25 17:28:16 +02004540 var TfiUsfArr tua := f_TfiUsfArrInit();
4541 var octetstring data := '0000'O & f_rnd_octstring(21);
4542
4543 f_virtphy_common();
Max2c6f5632019-03-18 17:25:17 +01004544
Harald Welte883340c2018-02-28 18:59:29 +01004545 f_TC_pcu_act_req(0, 0, 7, true);
Harald Weltead033dc2019-05-25 17:28:16 +02004546 f_TfiUsfArrSet(tua, 7, 0);
4547 f_L1CTL_TBF_CFG(L1CTL, false, tua);
4548 f_sleep(1.0);
4549
4550 f_pcu_to_l1(0, 0, 7, PCU_IF_SAPI_PTCCH, data);
Harald Welte883340c2018-02-28 18:59:29 +01004551}
4552
Vadim Yanitskiy8c242f02019-10-13 15:25:54 +07004553private function f_TC_pcu_ptcch_ul(uint16_t ra)
4554runs on test_CT {
4555 var template PCUIF_Message pcu_rach_ind;
4556 var PCUIF_send_data sd;
4557 var GsmFrameNumber fn;
4558 timer T;
4559
4560 /* Send an Access Burst on PTCCH/U over the Um-interface */
4561 fn := f_L1CTL_RACH(L1CTL, ra := ra, combined := 0, offset := 0,
4562 chan_nr := ts_RslChanNr_PDCH(7),
4563 link_id := ts_RslLinkID_OSMO_PTCCH(0));
4564
Vadim Yanitskiy36558d92019-11-17 02:23:51 +07004565 pcu_rach_ind := tr_PCUIF_RACH_IND(bts_nr := 0, trx_nr := 0, ts_nr := 7,
4566 ra := ra, fn := fn, sapi := PCU_IF_SAPI_PTCCH);
Vadim Yanitskiy8c242f02019-10-13 15:25:54 +07004567
4568 /* Expect a RACH.ind on the PCU interface (timeout is one multi-frame) */
4569 T.start(52.0 * 4.615 / 1000.0);
4570 alt {
4571 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, pcu_rach_ind)) -> value sd {
4572 log("Rx an Access Burst on the PCU interface: ", sd.data);
4573 setverdict(pass);
4574 T.stop;
4575 }
4576 [] PCU.receive { repeat; }
4577 [] T.timeout {
4578 setverdict(fail, "Timeout waiting for RACH.ind on the PCU interface");
4579 /* Keep going, that's not the end of the world */
4580 }
4581 }
4582}
4583
4584testcase TC_pcu_ptcch() runs on test_CT {
4585 var L1ctlDlMessage dl;
4586 var octetstring data;
4587 timer T;
4588
4589 f_init_pcu_test();
4590 f_init_l1ctl();
4591 f_l1_tune(L1CTL);
4592
4593 /* Activate PDCH channel on TS7 */
4594 f_TC_pcu_act_req(0, 0, 7, true);
4595
4596 /* Tune trxcon to that PDCH channel */
Vadim Yanitskiy5afe8852020-05-27 14:40:51 +07004597 L1CTL.send(ts_L1CTL_DM_EST_REQ_H0(ts_RslChanNr_PDCH(7), 7, mp_trx0_arfcn));
Vadim Yanitskiy8c242f02019-10-13 15:25:54 +07004598
4599 /* Verify PTCCH/U: send several access bursts, make sure they're received */
4600 for (var integer i := 0; i < 16; i := i + 1) {
4601 log("Sending an Access Burst towards the L1CTL interface");
4602 f_TC_pcu_ptcch_ul(oct2int(f_rnd_ra_ps()));
4603 }
4604
4605 /* Generate a random payload for PTCCH/D (23 octets, CS-1) */
4606 data := f_rnd_octstring(23);
4607
4608 /* Verify PTCCH/D: send a random data block, make sure it's received */
4609 log("Sending a PTCCH/D block towards the PCU interface: ", data);
4610 f_pcu_wait_rts_and_data_req(0, 0, 7, PCU_IF_SAPI_PTCCH, data);
4611
4612 /* PTCCH/D period is 2 multi-frames (2 * 52 * 4.615 ms), but
4613 * let's give it more time in case if we miss the beginning. */
4614 T.start(2.0 * 2.0 * 52.0 * 4.615 / 1000.0);
4615 alt {
4616 /* PDCH is considered as traffic in trxcon => expect TRAFFIC.ind */
4617 [] L1CTL.receive(tr_L1CTL_TRAFFIC_IND(chan_nr := t_RslChanNr_PDCH(7),
4618 link_id := tr_RslLinkID_OSMO_PTCCH(?),
4619 frame := data)) -> value dl {
4620 log("Rx PTCCH/D data (traffic) block on L1CTL: ", dl);
4621 setverdict(pass);
4622 T.stop;
4623 }
4624 /* Other PHYs (e.g. virt_phy) may consider PDCH as data => expect DATA.ind */
4625 [] L1CTL.receive(tr_L1CTL_DATA_IND(chan_nr := t_RslChanNr_PDCH(7),
4626 link_id := tr_RslLinkID_OSMO_PTCCH(?),
4627 l2_data := data)) -> value dl {
4628 log("Rx PTCCH/D data block on L1CTL: ", dl);
4629 setverdict(pass);
4630 T.stop;
4631 }
4632 [] L1CTL.receive { repeat; }
4633 [] T.timeout {
4634 setverdict(fail, "Timeout waiting for DATA.ind on L1CTL");
4635 }
4636 }
4637}
4638
Harald Welte883340c2018-02-28 18:59:29 +01004639/* Send AGCH from PCU; check it appears on Um side */
4640testcase TC_pcu_data_req_agch() runs on test_CT {
4641 timer T := 3.0;
Max2c6f5632019-03-18 17:25:17 +01004642 f_init_pcu_test();
Harald Welte883340c2018-02-28 18:59:29 +01004643 f_init_l1ctl();
4644 f_l1_tune(L1CTL);
4645
4646 f_TC_pcu_act_req(0, 0, 7, true);
4647 f_pcu_data_req(0, 0, 7, 0, 0, PCU_IF_SAPI_AGCH, c_PCU_DATA);
4648
4649 T.start;
4650 alt {
Harald Weltef8df4cb2018-03-10 15:15:08 +01004651 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?, c_PCU_DATA)) {
Harald Welte883340c2018-02-28 18:59:29 +01004652 setverdict(pass);
4653 }
4654 [] L1CTL.receive { repeat; }
4655 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004656 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PCU-originated AGCH block on Um");
Harald Welte883340c2018-02-28 18:59:29 +01004657 }
4658 }
4659}
4660
Harald Welte928622b2019-05-26 13:22:59 +02004661/* Send AGCH from PCU; check it appears on Um side */
4662testcase TC_pcu_data_req_pch() runs on test_CT {
4663 timer T := 3.0;
4664 f_init_pcu_test();
4665 f_init_l1ctl();
4666 f_l1_tune(L1CTL);
4667
4668 f_TC_pcu_act_req(0, 0, 7, true);
4669 /* three characters prefix: last 3 digits of IMSI as ASCII */
4670 f_pcu_data_req(0, 0, 7, 0, 0, PCU_IF_SAPI_PCH, '313233'O & c_PCU_DATA);
4671
4672 T.start;
4673 alt {
4674 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?, c_PCU_DATA)) {
4675 setverdict(pass);
4676 }
4677 [] L1CTL.receive { repeat; }
4678 [] T.timeout {
4679 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PCU-originated PCH block on Um");
4680 }
4681 }
4682}
4683
Harald Welte883340c2018-02-28 18:59:29 +01004684/* Send IMM.ASS from PCU for PCH; check it appears on Um side */
4685testcase TC_pcu_data_req_imm_ass_pch() runs on test_CT {
4686 var octetstring imm_ass := f_rnd_octstring(23);
Max2c6f5632019-03-18 17:25:17 +01004687 f_init_pcu_test();
Harald Welte883340c2018-02-28 18:59:29 +01004688 f_init_l1ctl();
4689 f_l1_tune(L1CTL);
4690
4691 /* append 3 last imsi digits so BTS can compute pagng group */
4692 var uint32_t fn := f_PCUIF_tx_imm_ass_pch(PCU, g_pcu_conn_id, imm_ass, '123459987'H);
4693
4694 timer T := 0.5;
4695 T.start;
4696 alt {
Harald Weltef8df4cb2018-03-10 15:15:08 +01004697 [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?, imm_ass)) {
Harald Welte883340c2018-02-28 18:59:29 +01004698 /* TODO: verify paging group */
4699 setverdict(pass);
4700 }
4701 [] L1CTL.receive { repeat; }
4702 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004703 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PCU-originated AGCH block on Um");
Harald Welte883340c2018-02-28 18:59:29 +01004704 }
4705 }
4706}
4707
4708/* Send RACH from Um side, expect it to show up on PCU socket */
4709testcase TC_pcu_rach_content() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01004710 f_init_pcu_test();
Harald Welte883340c2018-02-28 18:59:29 +01004711 f_init_l1ctl();
4712 f_l1_tune(L1CTL);
4713
4714 var GsmFrameNumber fn_last := 0;
4715 for (var integer i := 0; i < 1000; i := i+1) {
4716 var OCT1 ra := f_rnd_ra_ps();
4717 var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra));
4718 if (fn == fn_last) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004719 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?");
Harald Welte883340c2018-02-28 18:59:29 +01004720 }
4721 fn_last := fn;
4722
4723 timer T := 2.0;
4724 T.start;
4725 alt {
Vadim Yanitskiy36558d92019-11-17 02:23:51 +07004726 [] 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 +01004727 T.stop;
4728 }
4729 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RACH_IND)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004730 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RACH IND");
Harald Welte883340c2018-02-28 18:59:29 +01004731 }
4732 [] PCU.receive { repeat; }
4733 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004734 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RACH IND");
Harald Welte883340c2018-02-28 18:59:29 +01004735 }
4736 }
4737 }
4738 setverdict(pass);
4739}
4740
Vadim Yanitskiy51cbc102019-04-22 06:37:30 +07004741/* Send extended (11-bit, TS1 & TS2) RACH bursts from the Um side,
4742 * expect them to show up on PCU socket (with proper BURST_TYPE_*). */
4743testcase TC_pcu_ext_rach_content() runs on test_CT {
4744 var template PCUIF_Message pcu_rach_ind;
4745 var GsmFrameNumber fn_last := 0;
4746 var L1ctlRachSynchSeq synch_seq;
4747 var PCUIF_BurstType pcu_bt;
4748 var GsmFrameNumber fn;
4749 var BIT11 ra11;
4750
4751 f_init_pcu_test();
4752 f_init_l1ctl();
4753 f_l1_tune(L1CTL);
4754
4755 for (var integer i := 0; i < 1000; i := i+1) {
4756 /* We need to test both TS1 & TS2 */
4757 if (i rem 2 == 0) {
4758 synch_seq := RACH_SYNCH_SEQ_TS1;
4759 pcu_bt := BURST_TYPE_1;
4760 } else {
4761 synch_seq := RACH_SYNCH_SEQ_TS2;
4762 pcu_bt := BURST_TYPE_2;
4763 }
4764
4765 ra11 := f_rnd_ra11_ps();
4766 fn := f_L1CTL_EXT_RACH(L1CTL, bit2int(ra11), synch_seq);
4767 if (fn == fn_last) {
4768 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
4769 "Two RACH in same FN?!?");
4770 }
4771 fn_last := fn;
4772
4773 /* Compose the expected message */
4774 pcu_rach_ind := tr_PCUIF_RACH_IND(
Vadim Yanitskiy36558d92019-11-17 02:23:51 +07004775 bts_nr := 0, trx_nr := 0, ts_nr := 0,
Vadim Yanitskiy51cbc102019-04-22 06:37:30 +07004776 ra := bit2int(ra11),
4777 is_11bit := 1,
4778 burst_type := pcu_bt,
4779 fn := fn);
4780
4781 timer T := 2.0;
4782 T.start;
4783 alt {
4784 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, pcu_rach_ind)) {
4785 T.stop;
4786 }
4787 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RACH_IND)) {
4788 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RACH IND");
4789 }
4790 [] PCU.receive { repeat; }
4791 [] T.timeout {
4792 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RACH IND");
4793 }
4794 }
4795 }
4796 setverdict(pass);
4797}
4798
Vadim Yanitskiya2c68e82019-07-03 13:07:20 +07004799private function f_TC_pcu_data_ind_lqual_cb(int16_t lqual_cb_exp, int16_t thresh)
4800runs on test_CT {
4801 var template PCUIF_send_data sdt;
4802 var PCUIF_send_data sd;
4803 var int16_t lqual_cb;
4804 timer T := 1.0;
4805
4806 /* PCUIF_DATA.ind is encapsulated into a supplementary record */
4807 sdt := t_SD_PCUIF_MSGT(g_pcu_conn_id, PCU_IF_MSG_DATA_IND);
4808
4809 /* Send a random PDTCH frame over Um */
4810 L1CTL.send(ts_L1CTL_TRAFFIC_REQ(ts_RslChanNr_PDCH(7), ts_RslLinkID_DCCH(0),
4811 '0000'O & f_rnd_octstring(21)));
4812
4813 T.start;
4814 alt {
4815 /* If expected link quality is above the threshold */
4816 [lqual_cb_exp >= thresh] PCU.receive(sdt) -> value sd {
4817 lqual_cb := sd.data.u.data_ind.lqual_cb;
4818 log("Rx PCUIF_DATA.ind (lqual_cb=", lqual_cb, ")");
4819
4820 /* Make sure the actual link quality matches the expected value */
4821 if (not match(lqual_cb, lqual_cb_exp)) {
4822 setverdict(fail, log2str("Link quality ", lqual_cb, " does not match ",
4823 "expected value ", lqual_cb_exp));
4824 } else {
4825 setverdict(pass);
4826 }
4827 }
4828 /* If expected link quality is below the threshold */
4829 [lqual_cb_exp < thresh] PCU.receive(sdt) -> value sd {
4830 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
4831 log2str("Rx unexpected PCUIF_DATA.ind: ", sd.data));
4832 }
4833 /* Ignore PCUIF_RTS.req and PCUIF_TIME.ind */
4834 [] PCU.receive { repeat; }
4835 [lqual_cb_exp < thresh] T.timeout {
4836 log("Rx nothing, as expected");
4837 setverdict(pass);
4838 }
4839 [lqual_cb_exp >= thresh] T.timeout {
4840 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
4841 "Timeout waiting for PCUIF_DATA.ind");
4842 }
4843 }
4844}
4845
4846/* Verify C/I (Carrier-to-Interference ratio) processing of PDTCH frames */
4847testcase TC_pcu_data_ind_lqual_cb() runs on test_CT {
4848 f_init_pcu_test();
4849 PCU.clear;
4850
4851 f_init_l1ctl();
4852 f_l1_tune(L1CTL);
4853
4854 /* Activate a PDCH channel on TS7 */
4855 f_TC_pcu_act_req(0, 0, 7, true);
4856
4857 /* Tune trxcon to that PDCH channel on TS7 */
Vadim Yanitskiy5afe8852020-05-27 14:40:51 +07004858 L1CTL.send(ts_L1CTL_DM_EST_REQ_H0(ts_RslChanNr_PDCH(7), 7, mp_trx0_arfcn));
Vadim Yanitskiya2c68e82019-07-03 13:07:20 +07004859
4860 /* C/I in centiBels, test range: -256 .. +1280, step 128 */
4861 for (var int16_t i := -256; i <= 1280; i := i + 128) {
4862 var TrxcMessage ret;
4863
4864 ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id,
4865 valueof(ts_TRXC_FAKE_CI(i)));
4866
4867 /* FIXME: OsmoBTS may have different threshold (see MIN_QUAL_NORM) */
4868 f_TC_pcu_data_ind_lqual_cb(i, thresh := 0);
4869 }
4870}
4871
Harald Welte883340c2018-02-28 18:59:29 +01004872/* Send PAGING via RSL, expect it to shw up on PCU socket */
4873testcase TC_pcu_paging_from_rsl() runs on test_CT {
Max2c6f5632019-03-18 17:25:17 +01004874 f_init_pcu_test();
Harald Welte883340c2018-02-28 18:59:29 +01004875
4876 for (var integer i := 0; i < 100; i := i+1) {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07004877 var MobileIdentityLV mi_lv;
4878 var octetstring mi_lv_enc;
4879 var MobileIdentityV mi;
Harald Welte883340c2018-02-28 18:59:29 +01004880 timer T := 3.0;
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07004881
Harald Welte883340c2018-02-28 18:59:29 +01004882 if (i < 50) {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07004883 mi := valueof(t_MI_TMSI(f_rnd_octstring(4)));
Harald Welte883340c2018-02-28 18:59:29 +01004884 } else {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07004885 mi := valueof(ts_MI_IMSI(f_gen_imsi(i)));
Harald Welte883340c2018-02-28 18:59:29 +01004886 }
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07004887
4888 /* Fancy encoding for PCUIF */
4889 mi_lv := valueof(ts_MI_LV(mi));
4890 mi_lv_enc := enc_MobileIdentityLV(mi_lv);
4891 mi_lv_enc := f_pad_oct(mi_lv_enc, 9, '00'O);
Harald Welte883340c2018-02-28 18:59:29 +01004892
4893 /* Send RSL PAGING COMMAND */
Vadim Yanitskiy493abe72020-05-25 22:03:48 +07004894 RSL_CCHAN.send(ts_ASP_RSL_UD(ts_RSL_PAGING_CMD(mi, i mod 4)));
Harald Welte883340c2018-02-28 18:59:29 +01004895 T.start;
4896 alt {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07004897 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_PAG_REQ(0, mi_lv_enc))) {
Harald Welte883340c2018-02-28 18:59:29 +01004898 }
4899 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_PAG_REQ)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004900 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected PAGING REQ");
Harald Welte883340c2018-02-28 18:59:29 +01004901 }
4902 [] PCU.receive { repeat; }
4903 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02004904 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PAGING REQ");
Harald Welte883340c2018-02-28 18:59:29 +01004905 }
4906 }
4907 }
4908 setverdict(pass);
4909}
4910
Harald Welted66c9b82019-05-25 09:03:15 +02004911/* test for periodic TIME_IND; check number of FN expired and number of TIME_IND within frames */
4912testcase TC_pcu_time_ind() runs on test_CT {
4913 var PCUIF_send_data pcu_sd;
4914 var integer num_time_ind := 0;
4915 var integer first_fn, last_fn;
4916 var float test_duration := 5.0;
4917 timer T;
4918
4919 f_init_pcu_test();
4920 f_TC_pcu_act_req(0, 0, 7, true);
4921
4922 PCU.clear;
4923 T.start(test_duration);
4924 alt {
4925 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_TIME_IND(0, ?))) -> value pcu_sd {
4926 num_time_ind := num_time_ind + 1;
4927 if (not isbound(first_fn)) {
4928 first_fn := pcu_sd.data.u.time_ind.fn;
4929 }
4930 last_fn := pcu_sd.data.u.time_ind.fn;
4931 repeat;
4932 }
4933 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_TIME_IND(?, ?))) -> value pcu_sd {
4934 setverdict(fail, "Received unexpected PCUIF_TIME_IND: ", pcu_sd.data);
4935 repeat;
4936 }
4937 [] PCU.receive {
4938 repeat;
4939 }
4940 [] T.timeout {}
4941 }
4942 var integer fn_expired := last_fn - first_fn;
4943 log(fn_expired, " fn expired with ", num_time_ind, " PCU_TIME.ind");
4944
4945 /* verify the number of frames expired matches our expectation */
4946 const float c_GSM_FN_DURATION_MS := 4.61538;
4947 var float fn_expected := test_duration * 1000.0 / c_GSM_FN_DURATION_MS;
Harald Weltec761c542019-05-28 11:59:57 +02004948 var template integer t_fn_expected := f_tolerance(float2int(fn_expected), 1, 100000, 20);
Harald Welted66c9b82019-05-25 09:03:15 +02004949 if (not match(fn_expired, t_fn_expected)) {
4950 setverdict(fail, "Number of TDMA Frames (", fn_expired, ") not matching ", t_fn_expected);
4951 }
4952
4953 /* There are three TIME.ind in every fn MOD 13 */
4954 var float time_ind_expected := int2float(fn_expired) * 3.0 / 13.0;
4955 /* Add some tolerance */
4956 var template integer t_time_ind_exp := f_tolerance(float2int(time_ind_expected), 1, 100000, 5);
4957 if (not match(num_time_ind, t_time_ind_exp)) {
4958 setverdict(fail, "Number of TIME.ind (", num_time_ind, ") not matching ", t_time_ind_exp);
4959 }
4960
4961 setverdict(pass);
4962}
4963
Harald Welte4832c862019-05-25 14:57:18 +02004964/* test for periodic RTS_REQ; check number of FN expired and number of RTS_IND per SAPI */
4965testcase TC_pcu_rts_req() runs on test_CT {
4966 var PCUIF_send_data pcu_sd;
4967 var integer first_fn, last_fn;
4968 var integer num_rts_pdtch := 0;
4969 var integer num_rts_ptcch := 0;
4970 var float test_duration := 5.0;
4971 timer T;
4972
4973 f_init_pcu_test();
4974 f_TC_pcu_act_req(0, 0, 7, true);
4975
4976 PCU.clear;
4977 T.start(test_duration);
4978 alt {
4979 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(0, 0, 7, PCU_IF_SAPI_PDTCH, ?, ?)))
4980 -> value pcu_sd {
4981 num_rts_pdtch := num_rts_pdtch + 1;
4982 if (not isbound(first_fn)) {
4983 first_fn := pcu_sd.data.u.rts_req.fn;
4984 }
4985 last_fn := pcu_sd.data.u.rts_req.fn;
4986 repeat;
4987 }
4988 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(0, 0, 7, PCU_IF_SAPI_PTCCH, ?, ?)))
4989 -> value pcu_sd {
4990 num_rts_ptcch := num_rts_ptcch + 1;
4991 if (not isbound(first_fn)) {
4992 first_fn := pcu_sd.data.u.rts_req.fn;
4993 }
4994 last_fn := pcu_sd.data.u.rts_req.fn;
4995 repeat;
4996 }
4997 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ)) -> value pcu_sd {
4998 setverdict(fail, "Received unexpected PCUIF_RTS_REQ: ", pcu_sd.data);
4999 repeat;
5000 }
5001 [] PCU.receive {
5002 repeat;
5003 }
5004 [] T.timeout {}
5005 }
5006 var integer fn_expired := last_fn - first_fn;
5007 log(fn_expired, " fn expired with num_rts_pdtch=", num_rts_pdtch,
5008 ", num_rts_ptcch=", num_rts_ptcch);
5009
5010 /* verify the number of frames expired matches our expectation */
5011 const float c_GSM_FN_DURATION_MS := 4.61538;
5012 var float fn_expected := test_duration * 1000.0 / c_GSM_FN_DURATION_MS;
Harald Weltec761c542019-05-28 11:59:57 +02005013 var template integer t_fn_expected := f_tolerance(float2int(fn_expected), 1, 100000, 20);
Harald Welte4832c862019-05-25 14:57:18 +02005014 if (not match(fn_expired, t_fn_expected)) {
5015 setverdict(fail, "Number of TDMA Frames (", fn_expired, ") not matching ", t_fn_expected);
5016 }
5017
5018 /* PTCCH is in pos. 12 + 38 of 52-multiframe, but four slots/bursts required per block */
5019 var float ptcch_expected := int2float(fn_expired) / 52.0 * 0.5;
5020 var template integer t_ptcch_exp := f_tolerance(float2int(ptcch_expected), 1, 100000, 1);
5021 if (not match(num_rts_ptcch, t_ptcch_exp)) {
5022 setverdict(fail, "Number of RTS.ind for PTCCH (", num_rts_ptcch, ") not matching ",
5023 t_ptcch_exp);
5024 }
5025
5026 /* We have 12 PDTCH blocks every 52-multiframe */
5027 var float pdtch_expected := int2float(fn_expired) / 52.0 * 12.0;
5028 var template integer t_pdtch_exp := f_tolerance(float2int(pdtch_expected), 1, 100000, 2);
5029 if (not match(num_rts_pdtch, t_pdtch_exp)) {
5030 setverdict(fail, "Number of RTS.ind for PDTCH (", num_rts_pdtch, ") not matching ",
5031 t_pdtch_exp);
5032 }
5033
5034 setverdict(pass);
5035}
5036
Harald Welte07bd2d22019-05-25 11:03:30 +02005037/* test for generating Abis side OML ALERT from the PCU */
5038testcase TC_pcu_oml_alert() runs on test_CT {
5039 var PCUIF_send_data pcu_sd;
5040 var integer num_time_ind := 0;
5041 var integer first_fn, last_fn;
5042 var float test_duration := 5.0;
5043 timer T;
5044
5045 f_init_pcu_test();
5046 f_TC_pcu_act_req(0, 0, 7, true);
5047
5048 /* re-connect CTRL port from BTS to BSC */
5049 f_ipa_ctrl_stop();
5050 f_ipa_ctrl_start(mp_bsc_ctrl_ip, mp_bsc_ctrl_port);
5051
5052 /* Send that OML Alert */
5053 PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_TXT_IND(0, PCU_OML_ALERT, testcasename())));
5054
5055 /* This requires https://gerrit.osmocom.org/#/c/osmo-bsc/+/14177 to be merged */
5056 f_ctrl_exp_trap(IPA_CTRL, "bts.0.oml_failure_report", ?);
5057 setverdict(pass);
5058}
5059
Harald Welteeaa9a862019-05-26 23:01:08 +02005060template (value) PDU_ML3_MS_NW ts_RRM_GprsSuspReq(template (value) OCT4 tlli,
5061 template (value) RoutingAreaIdentificationV rai,
5062 template (value) OCT1 cause) := {
5063 discriminator := '0000'B, /* overwritten */
5064 tiOrSkip := {
5065 skipIndicator := '0000'B
5066 },
5067 msgs := {
5068 rrm := {
5069 gPRS_suspensionRequest := {
5070 messageType := '00110100'B,
5071 tLLI := tlli,
5072 routingAreaIdentification := rai,
5073 suspensionCause := cause,
5074 service_Support := omit
5075 }
5076 }
5077 }
5078}
5079
5080/* test for forwarding of RR SUSPEND from CS lchan to PCU via PCU socket */
5081private function f_TC_rr_suspend_req(charstring id) runs on ConnHdlr {
5082 var PCUIF_Message first_info;
5083 var integer pcu_conn_id := -1;
5084 var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0));
5085 var RoutingAreaIdentificationV rai := f_RAI('262'H, '42F'H, '2342'O, '55'O);
5086 var OCT4 tlli := '01020304'O;
5087 var OCT1 cause := '23'O;
5088 timer T := 5.0;
5089
5090 f_init_pcu(PCU, id, pcu_conn_id, first_info);
5091
5092 f_l1_tune(L1CTL);
5093 RSL.clear;
5094
5095 f_est_dchan();
5096 L1CTL.clear;
5097
5098 f_est_rll_mo(link_id.sapi, link_id, '23420815'O);
5099
5100 var PDU_ML3_MS_NW susp_req := valueof(ts_RRM_GprsSuspReq(tlli, rai, cause));
5101 var octetstring l3 := enc_PDU_ML3_MS_NW(susp_req);
5102 f_tx_lapdm(ts_LAPDm_I(link_id.sapi, cr_MO_CMD, true, 1, 0, l3), link_id);
5103
5104 /* ConnHdlr has terminated after sending the RR SUSP REQ over a dedicaed channel */
5105 T.start;
5106 alt {
5107 [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_SUSP_REQ(0, tlli, ?, oct2int(cause)))) {
5108 setverdict(pass);
5109 }
5110 [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_SUSP_REQ(?, ?, ?, ?))) {
5111 setverdict(fail, "Received unexpected PCUIF SUSPE REQ: ");
5112 }
5113 [] PCU.receive {
5114 repeat;
5115 }
5116 [] T.timeout {
5117 setverdict(fail, "Timeout waiting for SUSP REQ on PCUIF");
5118 }
5119 }
Alexander Couzensa0634832019-06-07 00:28:56 +02005120
5121 /* release the channel */
5122 f_rsl_chan_deact();
5123 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
5124 f_rslem_unregister(0, g_chan_nr);
Harald Welteeaa9a862019-05-26 23:01:08 +02005125}
5126testcase TC_pcu_rr_suspend() runs on test_CT {
5127 var ConnHdlrPars pars;
5128 var ConnHdlr vc_conn;
5129
5130 f_init();
5131
5132 pars := valueof(t_Pars(t_RslChanNr_SDCCH4(0,3), ts_RSL_ChanMode_SIGN));
5133 vc_conn := f_start_handler(refers(f_TC_rr_suspend_req), pars, true);
5134 vc_conn.done;
5135}
Harald Welte07bd2d22019-05-25 11:03:30 +02005136
Harald Weltea2e0e942019-05-27 18:12:53 +02005137/* Ensure that PCUIF socket can accept only a single connection */
5138testcase TC_pcu_socket_connect_multi() runs on test_CT {
5139 timer T := 5.0;
5140
5141 /* this (among other things) establishes the first connection to the PCUIF socket */
5142 f_init();
5143
5144 /* try to establish a second connection, expect it to fail */
5145 PCU.send(UD_connect:{mp_pcu_socket, -1});
5146 T.start;
5147 alt {
5148 [] PCU.receive(UD_connect_result:{id := ?, result := { result_code := ERROR, err := ? }}) {
5149 setverdict(pass);
5150 }
5151 [] PCU.receive(UD_connect_result:?) {
5152 setverdict(fail, "Unexpected unix domain connect result");
5153 }
5154 [] T.timeout {
5155 setverdict(pass);
5156 }
5157 }
5158 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
5159}
5160
Harald Weltec8effb72019-05-27 18:23:04 +02005161/* Ensure that PCUIF socket can disconnect + reconnect */
5162testcase TC_pcu_socket_reconnect() runs on test_CT {
5163 /* this (among other things) establishes the first connection to the PCUIF socket */
5164 f_init();
5165
5166 f_sleep(1.0);
5167
5168 f_pcuif_close(PCU, g_pcu_conn_id);
5169 g_pcu_conn_id := -1;
5170
5171 f_sleep(1.0);
5172
5173 /* re-connect */
5174 PCU.clear;
5175 f_init_pcu(PCU, testcasename(), g_pcu_conn_id, g_pcu_last_info);
5176 setverdict(pass);
5177
5178 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
5179}
5180
Harald Weltebe030482019-05-27 22:29:35 +02005181/* Ensure that GPRS capability is not advertised before PCU socket conncet */
Vadim Yanitskiy3c185382020-05-04 14:55:02 +07005182private function f_get_si(L1CTL_PT pt, RrMessageType si_type)
5183runs on test_CT return SystemInformation {
Harald Weltebe030482019-05-27 22:29:35 +02005184 var L1ctlDlMessage l1_dl;
5185 var SystemInformation si;
5186 timer T := 5.0;
5187 T.start;
5188 alt {
5189 [] pt.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl {
5190 /* somehow dec_SystemInformation will try to decode even non-RR as SI */
5191 if (not (l1_dl.payload.data_ind.payload[1] == '06'O)) {
5192 log("Ignoring non-RR SI ", l1_dl);
5193 repeat;
5194 }
5195 si := dec_SystemInformation(l1_dl.payload.data_ind.payload)
Vadim Yanitskiy3c185382020-05-04 14:55:02 +07005196 if (si.header.message_type != si_type) {
Harald Weltebe030482019-05-27 22:29:35 +02005197 repeat;
5198 }
5199 }
5200 [] pt.receive {
5201 repeat;
5202 }
5203 [] T.timeout {
Vadim Yanitskiy3c185382020-05-04 14:55:02 +07005204 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
5205 log2str("Timeout waiting for ", si_type));
Harald Weltebe030482019-05-27 22:29:35 +02005206 }
5207 }
Vadim Yanitskiy3c185382020-05-04 14:55:02 +07005208 return si;
Harald Weltebe030482019-05-27 22:29:35 +02005209}
5210
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07005211/* Check if GPRS Indicator is present in RR System Information of a given type */
5212private function f_si_has_gprs_indicator(RrMessageType si_type)
5213runs on test_CT return boolean {
5214 var SystemInformation si := f_get_si(L1CTL, si_type);
5215
5216 if (si_type == SYSTEM_INFORMATION_TYPE_3) {
5217 var RestOctets ro := si.payload.si3.rest_octets;
5218 var SI3RestOctets rest := dec_SI3RestOctets(ro);
5219 return rest.gprs_ind.presence == '1'B;
5220 } else if (si_type == SYSTEM_INFORMATION_TYPE_4) {
5221 var RestOctets ro := si.payload.si4.rest_octets;
5222 var SI4RestOctets rest := dec_SI4RestOctets(ro);
5223 return rest.gprs_ind.presence == '1'B;
5224 }
5225
5226 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unhandled SI type");
5227 return false;
Harald Weltebe030482019-05-27 22:29:35 +02005228}
5229
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07005230/* Make sure that GPRS Indicator is absent when the PCU is not connected */
5231private function f_TC_pcu_socket_noconnect(RrMessageType si_type)
5232runs on test_CT {
Harald Weltebe030482019-05-27 22:29:35 +02005233 /* don't call f_init() as this would connect PCU socket */
5234 f_init_rsl(testcasename());
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07005235
5236 /* Send both System Information Type 3 and 4 (with GPRS Indicator) */
Harald Weltebe030482019-05-27 22:29:35 +02005237 f_rsl_bcch_fill(RSL_SYSTEM_INFO_3, ts_SI3_default);
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07005238 f_rsl_bcch_fill(RSL_SYSTEM_INFO_4, ts_SI4_default);
Harald Weltebe030482019-05-27 22:29:35 +02005239
5240 f_init_l1ctl();
5241 f_l1_tune(L1CTL);
Harald Weltebe030482019-05-27 22:29:35 +02005242 f_sleep(2.0);
5243 L1CTL.clear;
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07005244
5245 if (f_si_has_gprs_indicator(si_type)) {
5246 setverdict(fail, si_type, " indicates GPRS even before PCU socket connected");
Harald Weltebe030482019-05-27 22:29:35 +02005247 } else {
5248 setverdict(pass);
5249 }
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07005250
Harald Weltebe030482019-05-27 22:29:35 +02005251 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
5252}
5253
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07005254testcase TC_pcu_socket_noconnect_nosi3gprs() runs on test_CT {
5255 f_TC_pcu_socket_noconnect(SYSTEM_INFORMATION_TYPE_3);
5256}
Harald Weltebe030482019-05-27 22:29:35 +02005257
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07005258testcase TC_pcu_socket_noconnect_nosi4gprs() runs on test_CT {
5259 f_TC_pcu_socket_noconnect(SYSTEM_INFORMATION_TYPE_4);
5260}
5261
5262/* Ensure that GPRS capability is advertised after PCU socket connect */
5263private function f_TC_pcu_socket_connect(RrMessageType si_type)
5264runs on test_CT {
Harald Weltebe030482019-05-27 22:29:35 +02005265 /* this (among other things) establishes the first connection to the PCUIF socket */
5266 f_init();
5267 f_init_l1ctl();
5268 f_l1_tune(L1CTL);
5269
5270 f_sleep(2.0);
5271 L1CTL.clear;
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07005272
5273 if (not f_si_has_gprs_indicator(si_type)) {
5274 setverdict(fail, si_type, " indicates no GPRS despite PCU socket connected");
Harald Weltebe030482019-05-27 22:29:35 +02005275 } else {
5276 setverdict(pass);
5277 }
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07005278
Harald Weltebe030482019-05-27 22:29:35 +02005279 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
5280}
5281
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07005282testcase TC_pcu_socket_connect_si3gprs() runs on test_CT {
5283 f_TC_pcu_socket_connect(SYSTEM_INFORMATION_TYPE_3);
5284}
Harald Weltebe030482019-05-27 22:29:35 +02005285
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07005286testcase TC_pcu_socket_connect_si4gprs() runs on test_CT {
5287 f_TC_pcu_socket_connect(SYSTEM_INFORMATION_TYPE_4);
5288}
5289
5290/* Ensure that GPRS capability is no longer advertised after PCU socket disconnect */
5291private function f_TC_pcu_socket_disconnect(RrMessageType si_type)
5292runs on test_CT {
Harald Weltebe030482019-05-27 22:29:35 +02005293 /* this (among other things) establishes the first connection to the PCUIF socket */
5294 f_init();
5295 f_init_l1ctl();
5296 f_l1_tune(L1CTL);
5297
5298 f_pcuif_close(PCU, g_pcu_conn_id);
5299 g_pcu_conn_id := -1;
5300
5301 f_sleep(1.0);
5302
5303 /* re-connect */
5304 PCU.clear;
5305 f_init_pcu(PCU, testcasename(), g_pcu_conn_id, g_pcu_last_info);
5306
5307 f_sleep(2.0);
5308 L1CTL.clear;
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07005309
5310 if (f_si_has_gprs_indicator(si_type)) {
5311 setverdict(fail, si_type, " indicates GPRS after PCU socket disconnected");
Harald Weltebe030482019-05-27 22:29:35 +02005312 } else {
5313 setverdict(pass);
5314 }
5315
5316 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
5317}
5318
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07005319testcase TC_pcu_socket_disconnect_nosi3gprs() runs on test_CT {
5320 f_TC_pcu_socket_disconnect(SYSTEM_INFORMATION_TYPE_3);
5321}
5322
5323testcase TC_pcu_socket_disconnect_nosi4gprs() runs on test_CT {
5324 f_TC_pcu_socket_disconnect(SYSTEM_INFORMATION_TYPE_4);
5325}
5326
Oliver Smithf5239c72019-08-28 10:01:25 +02005327/* 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) */
5328testcase TC_pcu_socket_verify_info_ind() runs on test_CT {
5329 var SystemInformation si3 := valueof(ts_SI3_default);
5330
5331 f_init();
5332
5333 /* Verify cell_id */
5334 var uint16_t cell_id_si3 := si3.payload.si3.cell_id;
5335 var uint16_t cell_id_pcu := g_pcu_last_info.u.info_ind.cell_id;
5336 if (cell_id_si3 != cell_id_pcu) {
Oliver Smithe1c00f02019-09-04 11:35:56 +02005337 setverdict(fail, "Expected cell_id '", cell_id_si3, "' and got '", cell_id_pcu, "'. This either means,",
5338 " that the BTS is sending the wrong cell_id, or that the BTS sent it too early",
5339 " (OS#4179)");
Oliver Smithf5239c72019-08-28 10:01:25 +02005340 }
5341
5342 /* Verify LAC */
5343 var uint16_t lac_si3 := si3.payload.si3.lai.lac;
5344 var uint16_t lac_pcu := g_pcu_last_info.u.info_ind.lac;
5345 if (lac_si3 != lac_pcu) {
5346 setverdict(fail, "Expected LAC ", lac_si3, " got: ", lac_pcu);
5347 }
5348
5349 setverdict(pass);
5350}
Harald Welted66c9b82019-05-25 09:03:15 +02005351
Harald Welte3d04ae62018-04-04 20:29:05 +02005352/***********************************************************************
Harald Welte9bbbfb52018-04-05 09:33:19 +02005353 * Osmocom Style Dynamic Timeslot Support
Harald Welte3d04ae62018-04-04 20:29:05 +02005354 ***********************************************************************/
5355
5356private function f_dyn_osmo_pdch_act(integer pcu_conn_id, integer bts_nr, integer trx_nr)
5357runs on ConnHdlr {
5358 var PCUIF_send_data sd;
5359 /* Expect BTS to immediately acknowledge activation as PDCH */
5360 PCU.clear;
5361 f_rsl_chan_act(g_pars.chan_mode);
5362 /* expect INFO_IND on PCU interface listing TS as PDCH */
Pau Espin Pedrol202c2f72019-10-08 13:11:05 +02005363 timer T_wait := 2.0;
5364 T_wait.start;
Harald Welte3d04ae62018-04-04 20:29:05 +02005365 alt {
5366 [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(bts_nr, ?))) -> value sd {
5367 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 +02005368 log("PCUIF_INFO_IND PDCH_MASK not yet '1' after PDCH ACT on TS", g_chan_nr.tn,
5369 " mask:", sd.data.u.info_ind.trx[trx_nr].pdch_mask);
5370 repeat;
Harald Welte3d04ae62018-04-04 20:29:05 +02005371 }
5372 }
5373 [] PCU.receive { repeat; }
Pau Espin Pedrol202c2f72019-10-08 13:11:05 +02005374 [] T_wait.timeout {
5375 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
5376 log2str("Timeout waiting for PCUIF_INFO_IND PDCH_MASK to be '1' on TS", g_chan_nr.tn));
5377 }
Harald Welte3d04ae62018-04-04 20:29:05 +02005378 }
5379 /* try to activate this PDCH from the PCU point of view */
5380 PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, g_chan_nr.tn)));
5381 /* FIXME: is there a response? */
5382}
5383
5384private function f_dyn_osmo_pdch_deact(integer pcu_conn_id, integer bts_nr, integer trx_nr)
5385runs on ConnHdlr {
5386 var PCUIF_send_data sd;
5387 /* Send RSL CHAN REL (deactivate) */
5388 PCU.clear;
5389 RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr));
5390 /* expect BTS to ask PCU to deactivate the channel */
Pau Espin Pedrol202c2f72019-10-08 13:11:05 +02005391 timer T_wait := 2.0;
5392 T_wait.start;
Harald Welte3d04ae62018-04-04 20:29:05 +02005393 alt {
5394 [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(bts_nr, ?))) -> value sd {
5395 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 +02005396 log("PCUIF_INFO_IND PDCH_MASK not yet '0' after PDCH DEACT on TS", g_chan_nr.tn,
5397 " mask:", sd.data.u.info_ind.trx[trx_nr].pdch_mask);
5398 repeat;
Harald Welte3d04ae62018-04-04 20:29:05 +02005399 }
5400 }
5401 [] PCU.receive { repeat; }
Pau Espin Pedrol202c2f72019-10-08 13:11:05 +02005402 [] T_wait.timeout {
5403 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
5404 log2str("Timeout waiting for PCUIF_INFO_IND PDCH_MASK to be '0' on TS", g_chan_nr.tn));
5405 }
Harald Welte3d04ae62018-04-04 20:29:05 +02005406 }
5407 /* Emulate PCU asking BTS to deactivate PDCH */
5408 PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_DEACT_REQ(bts_nr, trx_nr, g_chan_nr.tn)));
5409 alt {
5410 [] RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr)) {
5411 setverdict(pass);
5412 }
5413 [] RSL.receive { repeat; }
5414 }
5415}
5416
5417/* Activate Osmocom-style dynamic PDCH from BSC side */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07005418private function f_TC_dyn_osmo_pdch_act_deact(charstring id) runs on ConnHdlr {
Harald Welte3d04ae62018-04-04 20:29:05 +02005419 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 f_init_pcu(PCU, id, pcu_conn_id, first_info);
5426
5427 f_dyn_osmo_pdch_act(pcu_conn_id, bts_nr, trx_nr);
5428 f_sleep(3.0);
5429 f_dyn_osmo_pdch_deact(pcu_conn_id, bts_nr, trx_nr);
5430 setverdict(pass);
5431}
5432testcase TC_dyn_osmo_pdch_act_deact() runs on test_CT {
5433 var ConnHdlrPars pars;
5434 var ConnHdlr vc_conn;
Harald Welte10474062019-05-30 16:48:17 +02005435 f_init();
Harald Welte3d04ae62018-04-04 20:29:05 +02005436
5437 pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN));
5438 vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_act_deact), pars, true);
5439 vc_conn.done;
5440}
5441
5442/* send a RF CHAN REL for PDCH on an osmocom dynamci PDCH that's already inactive */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07005443private function f_TC_dyn_osmo_pdch_unsol_deact(charstring id) runs on ConnHdlr {
Harald Welte3d04ae62018-04-04 20:29:05 +02005444 var PCUIF_Message first_info;
Harald Welte3d04ae62018-04-04 20:29:05 +02005445 var integer pcu_conn_id := -1;
5446
5447 f_init_pcu(PCU, id, pcu_conn_id, first_info);
5448
Neels Hofmeyr9c50ca52018-05-08 20:37:54 +02005449 RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr));
5450 /* since the lchan is already released, we don't expect any PCU changes, just a rel ack. */
5451 RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr));
Harald Welte3d04ae62018-04-04 20:29:05 +02005452 setverdict(pass);
5453}
5454testcase TC_dyn_osmo_pdch_unsol_deact() runs on test_CT {
5455 var ConnHdlrPars pars;
5456 var ConnHdlr vc_conn;
Harald Welte10474062019-05-30 16:48:17 +02005457 f_init();
Harald Welte3d04ae62018-04-04 20:29:05 +02005458
5459 pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN));
5460 vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_unsol_deact), pars, true);
5461 vc_conn.done;
5462}
5463
5464/* try to RSL CHAN ACT a PDCH on an osmocom-style PDCH that's already active */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07005465private function f_TC_dyn_osmo_pdch_double_act(charstring id) runs on ConnHdlr {
Harald Welte3d04ae62018-04-04 20:29:05 +02005466 var PCUIF_Message first_info;
5467 var integer ts_nr := g_chan_nr.tn;
5468 var integer trx_nr := 0;
5469 var integer bts_nr := 0;
5470 var integer pcu_conn_id := -1;
5471
5472 f_init_pcu(PCU, id, pcu_conn_id, first_info);
5473
5474 f_dyn_osmo_pdch_act(pcu_conn_id, bts_nr, trx_nr);
Neels Hofmeyrdf936a22018-05-08 22:07:57 +02005475 /* Send a second Chan Activ and expect it to be NACKed */
5476 f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_NACK(g_chan_nr),
5477 "RSL CHAN ACT NACK");
Harald Welte3d04ae62018-04-04 20:29:05 +02005478 setverdict(pass);
5479}
5480testcase TC_dyn_osmo_pdch_double_act() runs on test_CT {
5481 var ConnHdlrPars pars;
5482 var ConnHdlr vc_conn;
Harald Welte10474062019-05-30 16:48:17 +02005483 f_init();
Harald Welte3d04ae62018-04-04 20:29:05 +02005484
5485 pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN));
5486 vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_double_act), pars, true);
5487 vc_conn.done;
5488}
5489
5490/* try to RSL CHAN ACT a TCH/F on an osmocom-style PDCH */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07005491private function f_TC_dyn_osmo_pdch_tchf_act(charstring id) runs on ConnHdlr {
Harald Welte3d04ae62018-04-04 20:29:05 +02005492 var PCUIF_Message first_info;
5493 var integer ts_nr := g_chan_nr.tn;
5494 var integer trx_nr := 0;
5495 var integer bts_nr := 0;
5496 var integer pcu_conn_id := -1;
5497 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(g_chan_nr.tn));
5498
5499 /* register for the TCH/F channel number */
5500 f_rslem_register(0, chan_nr);
5501
5502 f_init_pcu(PCU, id, pcu_conn_id, first_info);
5503
5504 f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_ACK(chan_nr),
5505 "RSL CHAN ACT");
5506 setverdict(pass);
5507}
5508testcase TC_dyn_osmo_pdch_tchf_act() runs on test_CT {
5509 var ConnHdlrPars pars;
5510 var ConnHdlr vc_conn;
Harald Welte10474062019-05-30 16:48:17 +02005511 f_init();
Harald Welte3d04ae62018-04-04 20:29:05 +02005512
5513 pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN));
5514 vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_tchf_act), pars, true);
5515 vc_conn.done;
5516}
5517
5518/* try to RSL CHAN ACT the TCH/H on an osmocom-style PDCH */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07005519private function f_TC_dyn_osmo_pdch_tchh_act(charstring id) runs on ConnHdlr {
Harald Welte3d04ae62018-04-04 20:29:05 +02005520 var PCUIF_Message first_info;
5521 var integer ts_nr := g_chan_nr.tn;
5522 var integer trx_nr := 0;
5523 var integer bts_nr := 0;
5524 var integer pcu_conn_id := -1;
5525 var RslChannelNr chan_nr[2] := { valueof(t_RslChanNr_Lm(g_chan_nr.tn, 0)),
5526 valueof(t_RslChanNr_Lm(g_chan_nr.tn, 1)) };
5527
5528 /* register for the TCH/H channel numbers */
5529 f_rslem_register(0, chan_nr[0]);
5530 f_rslem_register(0, chan_nr[1]);
5531
5532 f_init_pcu(PCU, id, pcu_conn_id, first_info);
5533
5534 f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr[1], g_pars.chan_mode),
5535 tr_RSL_CHAN_ACT_ACK(chan_nr[1]), "RSL CHAN ACT [1]");
5536 f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr[0], g_pars.chan_mode),
5537 tr_RSL_CHAN_ACT_ACK(chan_nr[0]), "RSL CHAN ACT [0]");
5538 setverdict(pass);
5539}
5540testcase TC_dyn_osmo_pdch_tchh_act() runs on test_CT {
5541 var ConnHdlrPars pars;
5542 var ConnHdlr vc_conn;
Harald Welte10474062019-05-30 16:48:17 +02005543 f_init();
Harald Welte3d04ae62018-04-04 20:29:05 +02005544
5545 pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN));
5546 vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_tchh_act), pars, true);
5547 vc_conn.done;
5548}
5549
Harald Welte9bbbfb52018-04-05 09:33:19 +02005550/***********************************************************************
5551 * IPA Style Dynamic Timeslot Support
5552 ***********************************************************************/
5553
5554private function f_dyn_ipa_pdch_act(integer pcu_conn_id, integer bts_nr, integer trx_nr)
5555runs on ConnHdlr {
5556 var PCUIF_send_data sd;
5557 /* Expect BTS to immediately acknowledge activation as PDCH */
5558 PCU.clear;
5559 RSL.send(ts_RSL_IPA_PDCH_ACT(g_chan_nr));
5560 /* expect INFO_IND on PCU interface listing TS as PDCH */
Pau Espin Pedrol446e07b2019-02-18 21:18:36 +01005561 timer T_wait := 2.0;
5562 T_wait.start;
Harald Welte9bbbfb52018-04-05 09:33:19 +02005563 alt {
5564 [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(bts_nr, ?))) -> value sd {
5565 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 +01005566 log("PCUIF_INFO_IND PDCH_MASK not yet '1' after PDCH ACT on TS", g_chan_nr.tn,
5567 " mask:", sd.data.u.info_ind.trx[trx_nr].pdch_mask);
5568 repeat;
Harald Welte9bbbfb52018-04-05 09:33:19 +02005569 }
5570 }
5571 [] PCU.receive { repeat; }
Pau Espin Pedrol446e07b2019-02-18 21:18:36 +01005572 [] T_wait.timeout {
5573 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
5574 log2str("Timeout waiting for PCUIF_INFO_IND PDCH_MASK to be '1' on TS", g_chan_nr.tn));
5575 }
Harald Welte9bbbfb52018-04-05 09:33:19 +02005576 }
5577 /* try to activate this PDCH from the PCU point of view */
5578 PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, g_chan_nr.tn)));
5579 /* FIXME: is there a response? */
5580
5581 RSL.receive(tr_RSL_IPA_PDCH_ACT_ACK(g_chan_nr, ?));
5582}
5583
5584private function f_dyn_ipa_pdch_deact(integer pcu_conn_id, integer bts_nr, integer trx_nr)
5585runs on ConnHdlr {
5586 var PCUIF_send_data sd;
5587 /* Send RSL CHAN REL (deactivate) */
5588 RSL.send(ts_RSL_IPA_PDCH_DEACT(g_chan_nr));
5589 PCU.clear;
5590 /* expect BTS to ask PCU to deactivate the channel */
Pau Espin Pedrol446e07b2019-02-18 21:18:36 +01005591 timer T_wait := 2.0;
5592 T_wait.start;
Harald Welte9bbbfb52018-04-05 09:33:19 +02005593 alt {
5594 [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(bts_nr, ?))) -> value sd {
5595 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 +01005596 log("PCUIF_INFO_IND PDCH_MASK not yet '0' after PDCH DEACT on TS", g_chan_nr.tn,
5597 " mask:", sd.data.u.info_ind.trx[trx_nr].pdch_mask);
5598 repeat;
Harald Welte9bbbfb52018-04-05 09:33:19 +02005599 }
5600 }
5601 [] PCU.receive { repeat; }
Pau Espin Pedrol446e07b2019-02-18 21:18:36 +01005602 [] T_wait.timeout {
5603 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
5604 log2str("Timeout waiting for PCUIF_INFO_IND PDCH_MASK to be '0' on TS", g_chan_nr.tn));
5605 }
Harald Welte9bbbfb52018-04-05 09:33:19 +02005606 }
5607 /* Emulate PCU asking BTS to deactivate PDCH */
5608 PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_DEACT_REQ(bts_nr, trx_nr, g_chan_nr.tn)));
5609 alt {
5610 [] RSL.receive(tr_RSL_IPA_PDCH_DEACT_ACK(g_chan_nr)) {
5611 setverdict(pass);
5612 }
5613 [] RSL.receive { repeat; }
5614 }
5615}
5616
5617/* Activate and de-activate an IPA-style dynamic TCH/F + PDCH */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07005618private function f_TC_dyn_ipa_pdch_act_deact(charstring id) runs on ConnHdlr {
Harald Welte9bbbfb52018-04-05 09:33:19 +02005619 var PCUIF_Message first_info;
5620 var integer ts_nr := g_chan_nr.tn;
5621 var integer trx_nr := 0;
5622 var integer bts_nr := 0;
5623 var integer pcu_conn_id := -1;
5624
5625 f_init_pcu(PCU, id, pcu_conn_id, first_info);
5626
5627 f_dyn_ipa_pdch_act(pcu_conn_id, bts_nr, trx_nr);
5628 f_sleep(3.0);
5629 f_dyn_ipa_pdch_deact(pcu_conn_id, bts_nr, trx_nr);
5630
5631 setverdict(pass);
5632
5633}
5634testcase TC_dyn_ipa_pdch_act_deact() runs on test_CT {
5635 var ConnHdlrPars pars;
5636 var ConnHdlr vc_conn;
5637 f_init();
5638
5639 pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN));
5640 vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_act_deact), pars, true);
5641 vc_conn.done;
5642}
5643
5644/* try to RSL CHAN ACT a TCH/F on an IPA-style PDCH */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07005645private function f_TC_dyn_ipa_pdch_tchf_act(charstring id) runs on ConnHdlr {
Harald Welte9bbbfb52018-04-05 09:33:19 +02005646 var PCUIF_Message first_info;
5647 var integer ts_nr := g_chan_nr.tn;
5648 var integer trx_nr := 0;
5649 var integer bts_nr := 0;
5650 var integer pcu_conn_id := -1;
5651
5652 f_init_pcu(PCU, id, pcu_conn_id, first_info);
5653
5654 f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_ACK(g_chan_nr),
5655 "RSL CHAN ACT");
5656 f_rsl_transceive(ts_RSL_RF_CHAN_REL(g_chan_nr), tr_RSL_RF_CHAN_REL_ACK(g_chan_nr),
5657 "RF CHAN REL", true);
5658 setverdict(pass);
5659}
5660testcase TC_dyn_ipa_pdch_tchf_act() runs on test_CT {
5661 var ConnHdlrPars pars;
5662 var ConnHdlr vc_conn;
Harald Welte10474062019-05-30 16:48:17 +02005663 f_init();
Harald Welte9bbbfb52018-04-05 09:33:19 +02005664
5665 pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN));
5666 vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_tchf_act), pars, true);
5667 vc_conn.done;
5668}
5669
5670/* Activate IPA style dyn PDCH as TCH/F and then illegally try to activate it as PDCH, too */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07005671private function f_TC_dyn_ipa_pdch_tchf_act_pdch_act_nack(charstring id) runs on ConnHdlr {
Harald Welte9bbbfb52018-04-05 09:33:19 +02005672 var PCUIF_Message first_info;
5673 var integer ts_nr := g_chan_nr.tn;
5674 var integer trx_nr := 0;
5675 var integer bts_nr := 0;
5676 var integer pcu_conn_id := -1;
5677
5678 f_init_pcu(PCU, id, pcu_conn_id, first_info);
5679
5680 f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_ACK(g_chan_nr),
5681 "RSL CHAN ACT");
5682
5683 RSL.send(ts_RSL_IPA_PDCH_ACT(g_chan_nr));
5684 alt {
5685 [] RSL.receive(tr_RSL_IPA_PDCH_ACT_NACK(g_chan_nr, ?));
5686 [] RSL.receive(tr_RSL_IPA_PDCH_ACT_ACK(g_chan_nr, ?)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02005687 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected PDCH ACT ACK");
Harald Welte9bbbfb52018-04-05 09:33:19 +02005688 }
5689 [] RSL.receive { repeat; }
5690 }
5691
5692 f_rsl_transceive(ts_RSL_RF_CHAN_REL(g_chan_nr), tr_RSL_RF_CHAN_REL_ACK(g_chan_nr),
5693 "RF CHAN REL", true);
5694 setverdict(pass);
5695}
5696testcase TC_dyn_ipa_pdch_tchf_act_pdch_act_nack() runs on test_CT {
5697 var ConnHdlrPars pars;
5698 var ConnHdlr vc_conn;
Harald Welte10474062019-05-30 16:48:17 +02005699 f_init();
Harald Welte9bbbfb52018-04-05 09:33:19 +02005700
5701 pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN));
5702 vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_tchf_act_pdch_act_nack), pars, true);
5703 vc_conn.done;
5704}
5705
5706/* try to RSL CHAN ACT a TCH/F on an IPA-style PDCH that's already in PDCH mode; expect NACK */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07005707private function f_TC_dyn_ipa_pdch_act_tchf_act_nack(charstring id) runs on ConnHdlr {
Harald Welte9bbbfb52018-04-05 09:33:19 +02005708 var PCUIF_Message first_info;
5709 var integer ts_nr := g_chan_nr.tn;
5710 var integer trx_nr := 0;
5711 var integer bts_nr := 0;
5712 var integer pcu_conn_id := -1;
5713
5714 /* register for the TCH/F channel number */
5715 f_rslem_register(0, g_chan_nr);
5716
5717 f_init_pcu(PCU, id, pcu_conn_id, first_info);
5718
5719 f_dyn_ipa_pdch_act(pcu_conn_id, bts_nr, trx_nr);
5720
5721 f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_NACK(g_chan_nr),
5722 "RSL CHAN ACT");
5723
5724 f_dyn_ipa_pdch_deact(pcu_conn_id, bts_nr, trx_nr);
5725
5726 setverdict(pass);
5727}
5728testcase TC_dyn_ipa_pdch_act_tchf_act_nack() runs on test_CT {
5729 var ConnHdlrPars pars;
5730 var ConnHdlr vc_conn;
Harald Welte10474062019-05-30 16:48:17 +02005731 f_init();
Harald Welte9bbbfb52018-04-05 09:33:19 +02005732
5733 pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN));
5734 vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_act_tchf_act_nack), pars, true);
5735 vc_conn.done;
5736}
5737
5738
Harald Welte0472ab42018-03-12 15:02:26 +01005739/***********************************************************************
5740 * LAPDm / RLL related
5741 ***********************************************************************/
5742
5743private function f_tx_lapdm(template (value) LapdmFrame l,
5744 template (value) RslLinkId link_id) runs on ConnHdlr {
5745 var octetstring l2 := enc_LapdmFrame(valueof(l));
Vadim Yanitskiy0a8d6da2019-05-28 22:18:28 +07005746 var template (value) SacchL1Header l1h;
5747
5748 /* TODO: we can use an extension of TTCN-3 for padding, i.e. PADDING('2B'O) */
Harald Welte0472ab42018-03-12 15:02:26 +01005749 if (valueof(link_id.c) == SACCH) {
Vadim Yanitskiy0a8d6da2019-05-28 22:18:28 +07005750 /* Compose dummy L1 header */
5751 l1h := ts_SacchL1Header(g_pars.l1_pars.ms_power_level, false, g_pars.l1_pars.ms_actual_ta);
5752 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 +02005753 } else {
5754 /* If required, pad L2 frame with constant 0x2b filling */
Vadim Yanitskiy0a8d6da2019-05-28 22:18:28 +07005755 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 +01005756 }
Harald Welte0472ab42018-03-12 15:02:26 +01005757}
5758
5759type record RllTestCase {
5760 uint3_t sapi,
5761 RslLinkId link_id,
5762 octetstring l3,
5763 boolean exp
5764}
5765type record of RllTestCase RllTestCases;
5766template RllTestCase t_EITC(uint3_t sapi, RslLinkId id, octetstring l3, boolean exp) := {
5767 sapi := sapi,
5768 link_id := id,
5769 l3 := l3,
5770 exp := exp
5771}
5772
5773/* execute the same callback function with a set of different parameters (tcs) on a
5774 * variety of logical channels */
5775private function f_rll_testmatrix(RllTestCases tcs, void_fn fn) runs on test_CT {
5776 var ConnHdlrPars pars;
5777 var ConnHdlr vc_conn;
Harald Welte10474062019-05-30 16:48:17 +02005778 f_init();
Harald Welte0472ab42018-03-12 15:02:26 +01005779
5780 /* test on each of the channels we have */
5781 for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i+1) {
5782 pars := valueof(t_Pars(g_AllChanTypes[i], ts_RSL_ChanMode_SIGN));
5783
5784 /* test each of the test cases on the current channel */
5785 for (var integer j := 0; j < sizeof(tcs); j := j+1) {
5786 pars.spec.rll := tcs[j];
5787 log(testcasename(), ": XXX Starting ", tcs[j] , " on ", g_AllChanTypes[i]);
5788 vc_conn := f_start_handler(fn, pars);
5789 vc_conn.done;
5790 }
5791 }
5792
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02005793 Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
Harald Welte0472ab42018-03-12 15:02:26 +01005794}
5795
5796/* test if SABM on Um triggers EST IND (TS 48.058 3.1) */
5797private function f_TC_rll_est_ind(charstring id) runs on ConnHdlr {
5798 var RllTestCase tc := g_pars.spec.rll;
5799 timer T := 3.0;
5800
5801 f_l1_tune(L1CTL);
5802 RSL.clear;
5803
5804 /* activate the logical channel */
5805 f_est_dchan();
5806 L1CTL.clear;
5807
5808 f_tx_lapdm(ts_LAPDm_SABM(tc.sapi, cr_MO_CMD, true, tc.l3), tc.link_id);
5809 T.start;
5810 alt {
5811 [tc.l3 != ''O] RSL.receive(tr_RSL_EST_IND(g_chan_nr, tc.link_id, tc.l3)) {
5812 if (tc.exp) {
5813 setverdict(pass);
5814 } else {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02005815 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Unexpected EST IND with L3 in ", tc));
Harald Welte0472ab42018-03-12 15:02:26 +01005816 }
5817 }
5818 [tc.l3 == ''O] RSL.receive(tr_RSL_EST_IND_NOL3(g_chan_nr, tc.link_id)) {
5819 if (tc.exp) {
5820 setverdict(pass);
5821 } else {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02005822 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Unexpected EST IND without L3 in ", tc));
Harald Welte0472ab42018-03-12 15:02:26 +01005823 }
5824 }
Vadim Yanitskiy35677872018-10-04 17:30:21 +07005825 /* We also expect to receive the measurements */
5826 [] as_meas_res(verify_meas := false);
Harald Welte0472ab42018-03-12 15:02:26 +01005827 [tc.exp] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02005828 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for EST IND");
Harald Welte0472ab42018-03-12 15:02:26 +01005829 }
5830 [not tc.exp] T.timeout {
5831 setverdict(pass);
5832 }
5833 }
5834
5835 f_rsl_chan_deact();
5836 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
5837 f_rslem_unregister(0, g_chan_nr);
5838}
5839testcase TC_rll_est_ind() runs on test_CT {
5840 var RllTestCases tcs := {
Harald Welte7aacbbf2018-05-09 16:56:41 +02005841 /* SAPI0 establishment (contention resolution) */
Harald Welte0472ab42018-03-12 15:02:26 +01005842 valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), '01020304'O, true)),
Harald Welte7aacbbf2018-05-09 16:56:41 +02005843 /* normal SAPI0 establishment */
5844 valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), ''O, true)),
Harald Welte0472ab42018-03-12 15:02:26 +01005845 /* SAPI 3 doesn't support contention resolution */
5846 valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), '01020304'O, false)),
5847 valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), '01020304'O, false)),
5848 /* normal SAPI3 establishment on main DCCH */
5849 valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), ''O, true)),
5850 /* normal SAPI3 establishment on SACCH */
5851 valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), ''O, true))
5852 };
5853 f_rll_testmatrix(tcs, refers(f_TC_rll_est_ind));
5854}
5855
5856/* test if RLL EST REQ trigeres SABM on Um; UA on Um triggers EST CONF (TS 48.058 3.2) */
5857private function f_TC_rll_est_req(charstring id) runs on ConnHdlr {
5858 var RllTestCase tc := g_pars.spec.rll;
5859 var L1ctlDlMessage dl;
5860 timer T := 3.0;
5861
5862 f_l1_tune(L1CTL);
5863 RSL.clear;
5864
5865 /* activate the logical channel */
5866 f_est_dchan();
5867 L1CTL.clear;
5868
5869 /* Send a RSL EST REQ for SAPI3 on main DCCH */
5870 RSL.send(ts_RSL_EST_REQ(g_chan_nr, tc.link_id));
5871 T.start;
5872 alt {
5873 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, ?)) -> value dl {
5874 var LapdmFrame lapdm;
5875 var octetstring l2 := dl.payload.data_ind.payload;
5876 if (dl.dl_info.link_id.c == SACCH) {
5877 /* remove L1 header */
5878 l2 := substr(l2, 2, lengthof(l2)-2);
5879 }
5880 lapdm.ab := dec_LapdmFrameAB(l2);
5881 if (match(lapdm, tr_LAPDm_SABM(tc.sapi, cr_MT_CMD, true, ''O))) {
5882 setverdict(pass);
5883 } else {
5884 repeat;
5885 }
5886 }
5887 [] L1CTL.receive { repeat; }
5888 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02005889 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for SABM");
Harald Welte0472ab42018-03-12 15:02:26 +01005890 }
5891 }
5892
5893 f_rsl_chan_deact();
5894 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
5895 f_rslem_unregister(0, g_chan_nr);
5896}
5897testcase TC_rll_est_req_DCCH_3() runs on test_CT {
5898 var RllTestCases tcs := {
5899 /* normal SAPI3 establishment on main DCCH */
5900 valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), ''O, true))//,
5901 };
5902 f_rll_testmatrix(tcs, refers(f_TC_rll_est_req));
5903}
5904testcase TC_rll_est_req_ACCH_3() runs on test_CT {
5905 var RllTestCases tcs := {
5906 /* normal SAPI3 establishment on SACCH */
5907 valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), ''O, true))
5908 }
5909 f_rll_testmatrix(tcs, refers(f_TC_rll_est_req));
5910}
5911
5912/* altstep to receive a LAPDm frame matching the given template */
5913private altstep as_l1_exp_lapdm(template LapdmFrame exp) runs on ConnHdlr {
5914 var L1ctlDlMessage dl;
5915 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, ?)) -> value dl {
5916 var LapdmFrame lapdm;
5917 var octetstring l2 := dl.payload.data_ind.payload;
5918 if (dl.dl_info.link_id.c == SACCH) {
5919 /* remove L1 header */
5920 l2 := substr(l2, 2, lengthof(l2)-2);
5921 }
5922 if (ischosen(exp.ab)) {
5923 lapdm.ab := dec_LapdmFrameAB(l2);
5924 } else if (ischosen(exp.b4)) {
5925 lapdm.b4 := dec_LapdmFrameB4(l2);
5926 } else if (ischosen(exp.bbis)) {
5927 lapdm.bbis := dec_LapdmFrameBbis(l2);
5928 }
5929 log("Rx LAPDm ", lapdm);
5930 if (match(lapdm, exp)) {
5931 setverdict(pass);
5932 } else {
5933 repeat;
5934 }
5935 }
5936 [] L1CTL.receive { repeat; }
5937}
5938private function f_l1_exp_lapdm(template LapdmFrame exp, float t := 3.0) runs on ConnHdlr {
5939 timer T := t;
5940 T.start;
5941 alt {
5942 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02005943 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Timeout waiting for LAPDm ", exp));
Harald Welte0472ab42018-03-12 15:02:26 +01005944 }
5945 [] as_l1_exp_lapdm(exp);
5946 }
5947}
5948
5949/* establish one Radio Link Layer via SABM -> UA. Use l3 for contention resolution */
5950private function f_est_rll_mo(uint3_t sapi, RslLinkId link_id, octetstring l3) runs on ConnHdlr {
5951 /* send SABM from MS -> BTS */
5952 f_tx_lapdm(ts_LAPDm_SABM(sapi, cr_MO_CMD, true, l3), link_id);
5953 /* expect RLL EST IND on Abis */
5954 alt {
5955 [l3 != ''O] RSL.receive(tr_RSL_EST_IND(g_chan_nr, link_id, l3));
5956 [l3 == ''O] RSL.receive(tr_RSL_EST_IND_NOL3(g_chan_nr, link_id));
5957 [] RSL.receive(tr_RSL_ERROR_IND(g_chan_nr, link_id, ?)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02005958 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Failing due to RSL_ERROR_IND");
Harald Welte0472ab42018-03-12 15:02:26 +01005959 }
5960 [] RSL.receive { repeat; }
5961 }
5962 /* expect UA from BTS -> MS */
5963 f_l1_exp_lapdm(tr_LAPDm_UA(sapi, cr_MT_RSP, true, l3));
5964}
5965
5966/* test if DISC on Um triggers RLL REL IND (TS 48.058 3.3) */
5967private function f_TC_rll_rel_ind(charstring id) runs on ConnHdlr {
5968 var RllTestCase tc := g_pars.spec.rll;
5969
5970 f_l1_tune(L1CTL);
5971 RSL.clear;
5972
5973 /* activate the logical channel */
5974 f_est_dchan();
5975 L1CTL.clear;
5976
5977 /* first establish the link-layer */
5978 f_est_rll_mo(tc.sapi, tc.link_id, tc.l3);
5979
5980 /* then send the DISC */
5981 f_tx_lapdm(ts_LAPDm_DISC(tc.sapi, cr_MO_CMD, true), tc.link_id);
5982 /* ... and expect the REL IND on the RSL side */
5983 alt {
5984 [] RSL.receive(tr_RSL_REL_IND(g_chan_nr, tc.link_id)) {
5985 setverdict(pass);
5986 }
Vadim Yanitskiy35677872018-10-04 17:30:21 +07005987 /* We also expect to receive the measurements */
5988 [] as_meas_res(verify_meas := false);
Harald Welte0472ab42018-03-12 15:02:26 +01005989 }
5990
5991 /* release the channel */
5992 f_rsl_chan_deact();
5993 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
5994 f_rslem_unregister(0, g_chan_nr);
5995}
5996testcase TC_rll_rel_ind_DCCH_0() runs on test_CT {
5997 var RllTestCases tcs := {
5998 valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), '01020304'O, true))
5999 };
6000 f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind));
6001}
6002
6003testcase TC_rll_rel_ind_ACCH_0() runs on test_CT {
6004 var RllTestCases tcs := {
6005 valueof(t_EITC(0, valueof(ts_RslLinkID_SACCH(0)), ''O, true))
6006 };
6007 f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind));
6008}
6009testcase TC_rll_rel_ind_DCCH_3() runs on test_CT {
6010 var RllTestCases tcs := {
6011 valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), ''O, true))
6012 };
6013 f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind));
6014}
6015testcase TC_rll_rel_ind_ACCH_3() runs on test_CT {
6016 var RllTestCases tcs := {
6017 valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), ''O, true))
6018 };
6019 f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind));
6020}
6021
6022/* test if RLL REL REQ triggers DISC on Um; UA/DM triggers RLL REL CONF (TS 48.058 3.4) */
6023private function f_TC_rll_rel_req(charstring id) runs on ConnHdlr {
6024 var RllTestCase tc := g_pars.spec.rll;
6025 f_l1_tune(L1CTL);
6026 RSL.clear;
6027
6028 /* activate the logical channel */
6029 f_est_dchan();
6030 L1CTL.clear;
6031
6032 /* first establish the link-layer */
6033 f_est_rll_mo(tc.sapi, tc.link_id, tc.l3);
6034
6035 /* then send the REL REQ via RSL */
6036 RSL.send(ts_RSL_REL_REQ(g_chan_nr, tc.link_id, RSL_REL_MODE_NORMAL));
6037 /* ... and expect the DISC on the Um side */
6038 alt {
Harald Weltebc6199f2018-05-10 19:38:18 +02006039 [] as_l1_exp_lapdm(tr_LAPDm_DISC(tc.sapi, cr_MT_CMD, true)) {
Harald Welte0472ab42018-03-12 15:02:26 +01006040 /* FIXME: send a UA in resposne to the DISC */
6041 }
6042 }
6043
6044 /* release the channel */
6045 f_rsl_chan_deact();
6046 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
6047 f_rslem_unregister(0, g_chan_nr);
6048}
6049testcase TC_rll_rel_req() runs on test_CT {
6050 var RllTestCases tcs := {
6051 valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), '01020304'O, true)),
6052 valueof(t_EITC(0, valueof(ts_RslLinkID_SACCH(0)), ''O, true)),
6053 valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), ''O, true)),
6054 valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), ''O, true))
6055 };
6056 f_rll_testmatrix(tcs, refers(f_TC_rll_rel_req));
6057}
6058
6059/* test if RLL DATA REQ triggers I-frames on Um (TS 48.058 3.5) */
6060testcase TC_rll_data_req() runs on test_CT {
6061}
6062
6063/* test if I-frames on Um trigger RLL DATA IND (TS 48.058 3.6) */
6064testcase TC_rll_data_ind() runs on test_CT {
6065}
6066
6067/* test if RLL UNIT DATA REQ triggers UI-frame on Um (TS 48.058 3.7) */
6068private function f_TC_rll_ud_req(charstring id) runs on ConnHdlr {
6069 var RllTestCase tc := g_pars.spec.rll;
6070
6071 f_l1_tune(L1CTL);
6072 RSL.clear;
6073
6074 f_est_dchan();
6075 L1CTL.clear;
6076
6077 /* Send UNITDATA REQ on RSL side */
6078 RSL.send(ts_RSL_UNITDATA_REQ(g_chan_nr, tc.link_id, tc.l3));
6079 /* Expect it to arrive on the other side */
6080 if (tc.link_id.c == SACCH) {
Harald Weltee613f962018-04-18 22:38:16 +02006081 f_l1_exp_lapdm(tr_LAPDm_B4_UI(tc.sapi, cr_MT_CMD, tc.l3));
Harald Welte0472ab42018-03-12 15:02:26 +01006082 } else {
Harald Weltee613f962018-04-18 22:38:16 +02006083 f_l1_exp_lapdm(tr_LAPDm_UI(tc.sapi, cr_MT_CMD, tc.l3));
Harald Welte0472ab42018-03-12 15:02:26 +01006084 }
6085
6086 /* release the channel */
6087 f_rsl_chan_deact();
6088 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
6089 f_rslem_unregister(0, g_chan_nr);
6090}
6091testcase TC_rll_unit_data_req_DCCH() runs on test_CT {
6092 var octetstring l3 := f_rnd_octstring(15);
6093 var RllTestCases tcs := {
6094 valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), l3, true)),
6095 valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), l3, true))
6096 };
6097 f_rll_testmatrix(tcs, refers(f_TC_rll_ud_req));
6098}
6099testcase TC_rll_unit_data_req_ACCH() runs on test_CT {
6100 var octetstring l3 := f_rnd_octstring(19);
6101 var RllTestCases tcs := {
6102 valueof(t_EITC(0, valueof(ts_RslLinkID_SACCH(0)), l3, true)),
6103 valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), l3, true))
6104 };
6105 f_rll_testmatrix(tcs, refers(f_TC_rll_ud_req));
6106}
6107
6108/* test if UI-frames on Um trigger RLL UNIT DATA IND (TS 48.058 3.8) */
6109private function f_TC_rll_ud_ind(charstring id) runs on ConnHdlr {
6110 var RllTestCase tc := g_pars.spec.rll;
6111
6112 f_l1_tune(L1CTL);
6113 RSL.clear;
6114
6115 f_est_dchan();
6116 L1CTL.clear;
6117
6118 /* Send LAPDm UI frame. There is no B4 format in uplink! */
Harald Weltee613f962018-04-18 22:38:16 +02006119 f_tx_lapdm(ts_LAPDm_UI(tc.sapi, cr_MO_CMD, tc.l3), tc.link_id);
Harald Welte0472ab42018-03-12 15:02:26 +01006120 /* Expdct RLL UNITDATA IND on RSL side */
6121 alt {
6122 [] RSL.receive(tr_RSL_UNITDATA_IND(g_chan_nr, tc.link_id, tc.l3)) {
6123 setverdict(pass);
6124 }
6125 [] RSL.receive { repeat; }
6126 }
6127
6128 /* release the channel */
6129 f_rsl_chan_deact();
6130 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
6131 f_rslem_unregister(0, g_chan_nr);
6132}
6133testcase TC_rll_unit_data_ind_DCCH() runs on test_CT {
Stefan Sperlingc4181912018-07-25 17:03:08 +02006134 var octetstring l3 := f_rnd_octstring(20);
Harald Welte0472ab42018-03-12 15:02:26 +01006135 var RllTestCases tcs := {
6136 valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), l3, true)),
6137 valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), l3, true))
6138 };
6139 f_rll_testmatrix(tcs, refers(f_TC_rll_ud_ind));
6140}
6141testcase TC_rll_unit_data_ind_ACCH() runs on test_CT {
6142 var octetstring l3 := f_rnd_octstring(18);
6143 var RllTestCases tcs := {
6144 valueof(t_EITC(0, valueof(ts_RslLinkID_SACCH(0)), l3, true)),
6145 valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), l3, true))
6146 };
6147 f_rll_testmatrix(tcs, refers(f_TC_rll_ud_ind));
6148}
6149
Harald Weltee613f962018-04-18 22:38:16 +02006150/***********************************************************************
6151 * Encryption Related
6152 ***********************************************************************/
6153
6154/* send UNITDATA_REQ from BTS to MS and expect it to arrive */
6155function f_unitdata_mt(RslLinkId link_id, octetstring l3) runs on ConnHdlr {
6156 RSL.send(ts_RSL_UNITDATA_REQ(g_chan_nr, link_id, l3));
6157 if (link_id.c == SACCH) {
6158 f_l1_exp_lapdm(tr_LAPDm_B4_UI(link_id.sapi, cr_MT_CMD, l3));
6159 } else {
6160 f_l1_exp_lapdm(tr_LAPDm_UI(link_id.sapi, cr_MT_CMD, l3));
6161 }
6162}
6163
Vadim Yanitskiyad131c82018-10-04 06:18:59 +07006164/* Expect (or not expect) other kinds of messages */
6165private altstep as_rsl_any_ind(boolean exp_any) runs on ConnHdlr {
6166 [exp_any] RSL.receive { repeat; }
6167 [not exp_any] RSL.receive {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02006168 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RSL message!");
Vadim Yanitskiyad131c82018-10-04 06:18:59 +07006169 }
6170}
6171
Harald Weltee613f962018-04-18 22:38:16 +02006172/* Send UI frame from MS and expect it to arrive as RLL UNITDATA IND on Abis */
Vadim Yanitskiy8d8f91c2018-10-04 06:19:45 +07006173private function f_unitdata_mo(
Vadim Yanitskiy98e03152018-10-03 18:06:06 +07006174 RslLinkId link_id,
6175 octetstring l3,
6176 boolean exp_sacch := true, /* Should tolerate SACCH messages? */
Vadim Yanitskiyb9920502018-10-03 18:29:51 +07006177 boolean exp_any := false /* Should tolerate any other RSL messages? */
Vadim Yanitskiy98e03152018-10-03 18:06:06 +07006178) runs on ConnHdlr {
Harald Weltee613f962018-04-18 22:38:16 +02006179 timer T := 3.0;
6180 f_tx_lapdm(ts_LAPDm_UI(link_id.sapi, cr_MO_CMD, l3), link_id);
6181 T.start;
6182 /* Expect RLL UNITDATA IND on RSL side */
6183 alt {
6184 [] RSL.receive(tr_RSL_UNITDATA_IND(g_chan_nr, link_id, l3)) {
6185 setverdict(pass);
6186 }
Vadim Yanitskiye0b91a72018-10-04 15:44:40 +07006187 [exp_sacch] as_meas_res(verify_meas := false);
Vadim Yanitskiyad131c82018-10-04 06:18:59 +07006188 [] as_rsl_any_ind(exp_any);
Harald Weltee613f962018-04-18 22:38:16 +02006189 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02006190 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for UNIT_DATA_IND");
Harald Weltee613f962018-04-18 22:38:16 +02006191 }
Harald Weltee613f962018-04-18 22:38:16 +02006192 }
6193}
6194
Vadim Yanitskiy4d78a702018-10-03 03:59:34 +07006195/* Send I-frame from MS and expect it to arrive as RLL DATA IND on Abis */
6196private function f_data_mo(
6197 RslLinkId link_id,
6198 boolean p, uint3_t nr, uint3_t ns,
6199 octetstring l3,
6200 boolean exp_sacch := true, /* Should tolerate SACCH messages? */
Vadim Yanitskiyb9920502018-10-03 18:29:51 +07006201 boolean exp_any := false /* Should tolerate any other RSL messages? */
Vadim Yanitskiy4d78a702018-10-03 03:59:34 +07006202) runs on ConnHdlr {
6203 timer T := 3.0;
6204 f_tx_lapdm(ts_LAPDm_I(link_id.sapi, cr_MO_CMD, p, nr, ns, l3), link_id);
6205 T.start;
6206 /* Expect RLL DATA IND on RSL side */
6207 alt {
6208 [] RSL.receive(tr_RSL_DATA_IND(g_chan_nr, link_id, l3)) {
6209 setverdict(pass);
6210 }
Vadim Yanitskiye0b91a72018-10-04 15:44:40 +07006211 [exp_sacch] as_meas_res(verify_meas := false);
Vadim Yanitskiy4d78a702018-10-03 03:59:34 +07006212 [] as_rsl_any_ind(exp_any);
6213 [] T.timeout {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02006214 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for DATA_IND");
Vadim Yanitskiy4d78a702018-10-03 03:59:34 +07006215 }
6216 }
6217}
6218
Harald Weltee613f962018-04-18 22:38:16 +02006219/* Test channel activation with A5/n right from the beginning (like in assignment + hand-over) */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07006220private function f_TC_chan_act_encr(charstring id) runs on ConnHdlr {
Harald Weltee613f962018-04-18 22:38:16 +02006221 f_l1_tune(L1CTL);
6222 f_est_dchan(true);
6223
6224 /* now we actually need to transmit some data both ways to check if the encryption works */
6225 var L1ctlDlMessage dl;
6226
Stefan Sperling603d98e2018-07-25 16:47:28 +02006227 var octetstring l3 := f_rnd_octstring(20);
Harald Weltee613f962018-04-18 22:38:16 +02006228 var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0));
6229
6230 /* send UNITDATA_REQ from BTS to MS and expect it to arrive */
6231 f_unitdata_mt(link_id, l3);
6232
6233 /* Send UI frame from MS and expect it to arrive as RLL UNITDATA IND on Abis */
6234 f_unitdata_mo(link_id, l3);
6235
6236 /* release the channel */
6237 f_rsl_chan_deact();
6238 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
6239 f_rslem_unregister(0, g_chan_nr);
6240}
6241testcase TC_chan_act_a51() runs on test_CT {
6242 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
6243 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_1, f_rnd_octstring(8)));
6244 f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr));
6245}
6246testcase TC_chan_act_a52() runs on test_CT {
6247 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
6248 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_2, f_rnd_octstring(8)));
6249 f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr));
6250}
6251testcase TC_chan_act_a53() runs on test_CT {
6252 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
6253 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_3, f_rnd_octstring(8)));
6254 f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr));
6255}
6256
Eric Wildf1827a72019-05-28 17:37:35 +02006257/* Test channel activation with A5/n right from the beginning and RSL MODE MODIFY
6258 which should break the en/decryption on purpose by supplying a new key that is unknown to the MS*/
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07006259private function f_TC_rsl_modify_encr(charstring id) runs on ConnHdlr {
Eric Wildf1827a72019-05-28 17:37:35 +02006260 f_l1_tune(L1CTL);
6261 f_est_dchan(true);
6262
6263 /* now we actually need to transmit some data both ways to check if the encryption works */
6264 var L1ctlDlMessage dl;
6265
6266 var octetstring l3 := f_rnd_octstring(20);
6267 var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0));
6268
6269 /* send UNITDATA_REQ from BTS to MS and expect it to arrive */
6270 f_unitdata_mt(link_id, l3);
6271
6272 /* Send UI frame from MS and expect it to arrive as RLL UNITDATA IND on Abis */
6273 f_unitdata_mo(link_id, l3);
6274
6275 var RSL_Message rsl;
6276 rsl := valueof(ts_RSL_MODE_MODIFY_REQ(g_chan_nr, valueof(ts_RSL_ChanMode_SIGN(false))));
6277
6278 /* modify key to break proper encryption */
6279 g_pars.encr.key := f_rnd_octstring(8);
6280 var RSL_IE ei := valueof(t_RSL_IE(RSL_IE_ENCR_INFO, RSL_IE_Body:{encr_info := g_pars.encr}));
6281 rsl.ies := rsl.ies & { ei };
6282 RSL.send(rsl);
6283
6284 timer T0 := 1.0;
6285 T0.start;
6286 /* Expect RSL MODIFY ACK */
6287 alt {
6288 [] RSL.receive(tr_RSL_MODE_MODIFY_ACK(g_chan_nr)) {}
6289 [] RSL.receive(tr_RSL_MODE_MODIFY_NACK(g_chan_nr, ?)) {
6290 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,"MODE MODIFY NACK");
6291 }
6292 [] T0.timeout {
6293 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for MODE MODIFY (N)ACK");
6294 }
6295 }
6296
6297 var octetstring l3msg := f_rnd_octstring(15);
6298 timer T1 := 3.0;
6299 /* Send UI frame from MS, do not expect it to arrive as RLL UNITDATA IND on Abis
6300 due to broken encryption */
6301 f_tx_lapdm(ts_LAPDm_UI(link_id.sapi, cr_MO_CMD, l3msg), link_id);
6302 T1.start;
6303 alt {
6304 [] RSL.receive(tr_RSL_UNITDATA_IND(g_chan_nr, link_id, l3msg)) {
6305 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "BTS shouldn't be able to decrypt after key change")
6306 }
6307 [] T1.timeout {
6308 setverdict(pass);
6309 }
6310 }
6311
6312 /* release the channel */
6313 f_rsl_chan_deact();
6314 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
6315 f_rslem_unregister(0, g_chan_nr);
6316}
6317testcase TC_rsl_modify_encr() runs on test_CT {
6318 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
6319 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_1, f_rnd_octstring(8)));
6320 f_testmatrix_each_chan(pars, refers(f_TC_rsl_modify_encr));
6321}
Harald Weltee613f962018-04-18 22:38:16 +02006322
6323/* Test unencrypted channel activation followed by explicit ENCR CMD later */
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07006324private function f_TC_encr_cmd(charstring id) runs on ConnHdlr {
Harald Weltee613f962018-04-18 22:38:16 +02006325 /* L3 payload doesn't matter, as it is passed transparently */
6326 var BIT3 l3_alg_id := f_alg_id_to_l3(g_pars.encr.alg_id);
6327 var octetstring l3 := enc_PDU_ML3_NW_MS(valueof(ts_RRM_CiphModeCmd(l3_alg_id)));
6328 var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0));
6329
6330 f_l1_tune(L1CTL);
6331
6332 /* first establish a dedicated channel in the clear */
6333 f_est_dchan(false);
6334
6335 /* Establish ABM */
6336 f_est_rll_mo(link_id.sapi, link_id, '23420815'O);
6337
6338 /* then send the RSL ENCR CMD with an actual RR CIPH MOD CMD inside */
6339 RSL.send(ts_RSL_ENCR_CMD(g_chan_nr, link_id, g_pars.encr.alg_id, g_pars.encr.key, l3));
6340 /* expect the L3 to arrive still unencrypted on the MS side */
6341 f_l1_exp_lapdm(tr_LAPDm_I(link_id.sapi, cr_MT_CMD, ?, ?, ?, l3));
6342
6343 /* configure L1 to apply ciphering */
6344 var uint8_t alg_id := f_alg_id_to_l1ctl(g_pars.encr.alg_id);
6345 f_L1CTL_CRYPTO_REQ(L1CTL, g_pars.chan_nr, alg_id, g_pars.encr.key);
6346
Vadim Yanitskiy4d78a702018-10-03 03:59:34 +07006347 /* send first ciphered I-frame in response and expect it on RSL */
6348 f_data_mo(link_id, true, 1, 0, '0a0b0c0d'O, exp_sacch := true);
Harald Weltee613f962018-04-18 22:38:16 +02006349
6350 /* now the BTS code should have detected the first properly encrypted uplink I-frame,
6351 * and hence enable encryption also on the downlink */
6352
6353 /* expect bi-directional communication work in encrypted mode */
6354 f_unitdata_mo(link_id, f_rnd_octstring(15));
6355 f_unitdata_mt(link_id, f_rnd_octstring(15));
6356
6357 /* release the channel */
6358 f_rsl_chan_deact();
6359 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
6360 f_rslem_unregister(0, g_chan_nr);
6361}
6362testcase TC_encr_cmd_a51() runs on test_CT {
6363 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
6364 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_1, f_rnd_octstring(8)));
6365 f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd));
6366}
6367testcase TC_encr_cmd_a52() runs on test_CT {
6368 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
6369 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_2, f_rnd_octstring(8)));
6370 f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd));
6371}
6372testcase TC_encr_cmd_a53() runs on test_CT {
6373 var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
6374 pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_3, f_rnd_octstring(8)));
6375 f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd));
6376}
6377
6378private function f_assert_lapdm(octetstring enc, template LapdmFrame exp_match, charstring name := "") {
6379 var LapdmFrame lf;
6380 var octetstring reenc;
6381
6382 /* decode the LAPDm frame */
6383 if (ischosen(exp_match.ab)) {
6384 lf.ab := dec_LapdmFrameAB(enc);
6385 } else {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02006386 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "unsupported frame type");
Harald Weltee613f962018-04-18 22:38:16 +02006387 }
6388
6389 /* check if decoder result matches expectation */
6390 if (not match(lf, exp_match)) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02006391 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str(name, ": decoded LAPDm doesn't match"));
Harald Weltee613f962018-04-18 22:38:16 +02006392 } else {
6393 log(name, ": matched");
6394 setverdict(pass);
6395 }
6396
6397 /* test if re-encoded frame equals original input */
6398 reenc := enc_LapdmFrame(lf);
6399 if (enc != reenc) {
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02006400 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str(name, ": re-encoded LAPDm frame doesn't match"));
Harald Weltee613f962018-04-18 22:38:16 +02006401 } else {
6402 setverdict(pass);
6403 }
6404}
6405
6406testcase TC_lapdm_selftest() runs on test_CT {
6407 f_assert_lapdm('030301'O, tr_LAPDm_UI(0, true, ''O), "ui_s0_empty");
6408 f_assert_lapdm('0F0301'O, tr_LAPDm_UI(3, true, ''O), "ui_s3_empty");
6409 f_assert_lapdm('013F01'O, tr_LAPDm_SABM(0, false, true, ''O), "sabm_s0_empty");
6410 f_assert_lapdm('013F1123420815'O, tr_LAPDm_SABM(0, false, true, '23420815'O), "sabm_s0_l3");
6411 f_assert_lapdm('03E101'O, tr_LAPDm_RR(0, true, false, 7), "rr_s0_7");
6412 f_assert_lapdm('03000d063505'O, tr_LAPDm_I(0, true, false, 0, 0, '063505'O), "I/0/0");
6413 f_assert_lapdm('03e00d063505'O, tr_LAPDm_I(0, true, false, 7, 0, '063505'O), "I/7/0");
6414}
6415
Stefan Sperling4880be42018-08-07 18:12:59 +02006416/***********************************************************************
6417 * DTX Related (see GSM 05.08, section 8.3)
6418 ***********************************************************************/
6419
6420/* XXX These functions must be kept in sync with g_AllChannels defined on test_CT. */
6421function f_g_chan_is_tchf() runs on ConnHdlr return boolean {
6422 return (g_chan_nr == valueof(ts_RslChanNr_Bm(1)) or
6423 g_chan_nr == valueof(ts_RslChanNr_Bm(2)) or
6424 g_chan_nr == valueof(ts_RslChanNr_Bm(3)) or
6425 g_chan_nr == valueof(ts_RslChanNr_Bm(4)));
6426}
6427function f_g_chan_is_tchh() runs on ConnHdlr return boolean {
6428 return (g_chan_nr == valueof(ts_RslChanNr_Lm(5,0)) or
6429 g_chan_nr == valueof(ts_RslChanNr_Lm(5,1)));
6430}
6431function f_g_chan_is_sdcch4() runs on ConnHdlr return boolean {
6432 return (g_chan_nr == valueof(ts_RslChanNr_SDCCH4(0,0)) or
6433 g_chan_nr == valueof(ts_RslChanNr_SDCCH4(0,1)) or
6434 g_chan_nr == valueof(ts_RslChanNr_SDCCH4(0,2)) or
6435 g_chan_nr == valueof(ts_RslChanNr_SDCCH4(0,3)));
6436}
6437function f_g_chan_is_sdcch8() runs on ConnHdlr return boolean {
6438 return (g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,0)) or
6439 g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,1)) or
6440 g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,2)) or
6441 g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,3)) or
6442 g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,4)) or
6443 g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,5)) or
6444 g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,6)) or
6445 g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,7)));
6446}
6447
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07006448private function f_test_l2_fill_frames(boolean dtxd) runs on ConnHdlr {
Stefan Sperling4880be42018-08-07 18:12:59 +02006449 var L1ctlDlMessage dl;
6450 var octetstring l2_fill_frame := '0303012B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B'O;
6451 var octetstring l2_fill_frame_sacch := substr(l2_fill_frame, 0, lengthof(l2_fill_frame) - 2);
6452 var GsmFrameNumber first_fn;
6453 var boolean is_first_frame := true;
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02006454 var integer nfill_frames_sacch := 0;
6455 var integer nfill_frames_nonsacch := 0;
6456 var integer expected_fill_frames := 10000; /* initial value causes test failure if not overridden */
Stefan Sperling4880be42018-08-07 18:12:59 +02006457 /* Frames numbers (mod 104) for which a fill frame is expected on TCHF if DTX is enabled. */
6458 var Integers required_tdma_frames_dtx_tchf := { 52, 53, 54, 55, 56, 57, 58, 59 };
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02006459 const integer frame_dtx_tchf_mod := 104;
6460 /* Frame numbers (mod 104) for which a fill frame is expected at the L1SAP level,
6461 * which operates in terms of blocks rather than frames. */
6462 var Integers required_tdma_blocks_dtx_tchf := { 52, 56 };
6463 const integer block_dtx_tchf_mod := 26;
Stefan Sperling4880be42018-08-07 18:12:59 +02006464 timer T := 5.0;
6465
6466 f_l1_tune(L1CTL);
6467 RSL.clear;
6468 L1CTL.clear;
6469
6470 /* activate TCHF signalling channel */
6471 f_est_dchan(false);
6472
6473 T.start;
6474 alt {
6475 [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, ?)) -> value dl {
6476 var GsmFrameNumber fn := dl.dl_info.frame_nr;
6477 var octetstring l2 := dl.payload.data_ind.payload;
6478
6479 if (is_first_frame) {
6480 is_first_frame := false;
6481 first_fn := dl.dl_info.frame_nr;
6482 }
6483
6484 if (dl.dl_info.link_id.c == SACCH) {
6485 l2 := substr(l2, 2, lengthof(l2) - 2); /* remove L1 header */
6486 if (not match(l2_fill_frame_sacch, l2)) {
6487 repeat;
6488 }
6489 } else if (not match(l2_fill_frame, l2)) {
6490 repeat;
6491 }
6492
6493 if (dtxd) {
6494 if (not f_g_chan_is_tchf()) {
6495 T.stop;
6496 f_rsl_chan_deact();
6497 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02006498 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 +02006499 }
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02006500 if (fn > first_fn + frame_dtx_tchf_mod) {
Stefan Sperling4880be42018-08-07 18:12:59 +02006501 T.stop;
6502 f_rsl_chan_deact();
6503 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02006504
6505 /* With DTX enabled we can expect at least 3 fill frames for every 104 frames.
6506 * 2 SACCH, 1 TCH/F */
6507 expected_fill_frames := 3;
6508
6509 if (nfill_frames_sacch + nfill_frames_nonsacch < expected_fill_frames) {
6510 log("received only ", nfill_frames_sacch, "+", nfill_frames_nonsacch,
6511 " (SACCH+other) out of ", expected_fill_frames, " expected fill frames");
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02006512 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Not enough fill frames received");
Stefan Sperling4880be42018-08-07 18:12:59 +02006513 } else {
6514 setverdict(pass);
6515 }
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02006516 } else {
6517 if (dl.dl_info.link_id.c == SACCH) {
6518 nfill_frames_sacch := nfill_frames_sacch + 1;
Stefan Sperling4880be42018-08-07 18:12:59 +02006519 repeat;
6520 }
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02006521 /* On DTX TCH/F channels, fill frames occur only for specific frame numbers mod 104.
6522 * Furthermore, the L1SAP layer gives us frame numbers for the start of a block so
6523 * we should only see the subset of frames numbers which correspond to a block boundary.
6524 * TCH/F blocks are defined to start at 0,4,8,13,17,21 (modulo 26) */
6525 for (var integer i := 0; i < lengthof(required_tdma_blocks_dtx_tchf); i := i + 1) {
6526 if (fn mod frame_dtx_tchf_mod == required_tdma_blocks_dtx_tchf[i]) {
6527 nfill_frames_nonsacch := nfill_frames_nonsacch + 1;
6528 repeat;
6529 }
6530 }
6531 log("Received DTX TCH fill frame with bad frame number: ", fn,
6532 " (mod ", frame_dtx_tchf_mod, ": ", fn mod frame_dtx_tchf_mod, ")",
6533 " (mod ", block_dtx_tchf_mod, ": ", fn mod block_dtx_tchf_mod, ")");
6534 f_rsl_chan_deact();
6535 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02006536 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected L2 fill frame received on Um");
Stefan Sperling4880be42018-08-07 18:12:59 +02006537 }
Stefan Sperling4880be42018-08-07 18:12:59 +02006538 } else {
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02006539 if (dl.dl_info.link_id.c == SACCH) {
6540 nfill_frames_sacch := nfill_frames_sacch + 1;
6541 } else {
6542 nfill_frames_nonsacch := nfill_frames_nonsacch + 1;
6543 }
6544 if (fn > first_fn + frame_dtx_tchf_mod) {
Stefan Sperling4880be42018-08-07 18:12:59 +02006545 T.stop;
6546 if (f_g_chan_is_tchf()) {
6547 /* Without DTX we can expect 25 fill frames for every 104 frames.
6548 * (24 FACCH + 1 SACCH filling) */
6549 expected_fill_frames := 25;
6550 } else if (f_g_chan_is_tchh()) {
6551 /* We can expect 2 fill frames for every 104 frames. */
6552 expected_fill_frames := 2;
6553 } else if (f_g_chan_is_sdcch4() or f_g_chan_is_sdcch8()) {
6554 /* We can expect 5 fill frames for every 104 frames. */
6555 expected_fill_frames := 5;
6556 } else {
6557 f_rsl_chan_deact();
6558 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02006559 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unknown channel type");
Stefan Sperling4880be42018-08-07 18:12:59 +02006560 }
6561
6562 f_rsl_chan_deact();
6563 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02006564
6565 if (nfill_frames_sacch + nfill_frames_nonsacch >= expected_fill_frames) {
Stefan Sperling4880be42018-08-07 18:12:59 +02006566 setverdict(pass);
6567 } else {
Stefan Sperling91d4c9d2018-08-09 20:03:08 +02006568 log("received only ", nfill_frames_sacch, "+", nfill_frames_nonsacch,
6569 " (SACCH+other) out of ", expected_fill_frames, " expected fill frames");
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02006570 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Not enough fill frames received");
Stefan Sperling4880be42018-08-07 18:12:59 +02006571 }
6572 } else {
6573 repeat;
6574 }
6575 }
6576 }
6577 [] L1CTL.receive { repeat; }
6578 [] T.timeout {
6579 f_rsl_chan_deact();
6580 f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
Daniel Willmann0fcc4d32018-10-23 20:32:19 +02006581 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for L2 fill frames on Um");
Stefan Sperling4880be42018-08-07 18:12:59 +02006582 }
6583 }
6584}
6585
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07006586private function f_TC_tch_sign_l2_fill_frame(charstring id) runs on ConnHdlr {
Stefan Sperling4880be42018-08-07 18:12:59 +02006587 f_test_l2_fill_frames(false);
6588}
6589
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07006590private function f_TC_tch_sign_l2_fill_frame_dtxd(charstring id) runs on ConnHdlr {
Stefan Sperling4880be42018-08-07 18:12:59 +02006591 f_test_l2_fill_frames(true);
6592}
6593
Vadim Yanitskiy71c39ea2020-07-04 20:44:42 +07006594private function f_tch_sign_l2_fill_frame(boolean dtxd) runs on test_CT {
Stefan Sperling4880be42018-08-07 18:12:59 +02006595 var ConnHdlr vc_conn;
6596 var ConnHdlrPars pars;
6597 pars.t_guard := 60.0;
Harald Welte10474062019-05-30 16:48:17 +02006598 f_init();
Stefan Sperling4880be42018-08-07 18:12:59 +02006599 for (var integer i := 0; i < sizeof(g_AllChannels); i := i + 1) {
6600 pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN(dtxd)));
6601 if (dtxd) {
6602 if (i >= 4) { /* DTX is only allowed on TCH/F */
6603 break;
6604 }
6605 vc_conn := f_start_handler(refers(f_TC_tch_sign_l2_fill_frame_dtxd), pars);
6606 } else {
6607 vc_conn := f_start_handler(refers(f_TC_tch_sign_l2_fill_frame), pars);
6608 }
6609 vc_conn.done;
6610 }
6611}
6612
6613/* Verify that L2 fill frames are sent on TCH in signaling mode if
6614 * there is nothing to transmit while DTX is disabled on downlink. */
6615testcase TC_tch_sign_l2_fill_frame() runs on test_CT {
6616 f_tch_sign_l2_fill_frame(false);
6617}
6618
6619/* Verify that particular L2 fill frames are sent on TCH in signaling mode if
6620 * there is nothing to transmit while DTX is enabled on downlink. */
6621testcase TC_tch_sign_l2_fill_frame_dtxd() runs on test_CT {
6622 f_tch_sign_l2_fill_frame(true);
6623}
Harald Welte0472ab42018-03-12 15:02:26 +01006624
Stefan Sperling0ec1c262018-10-15 15:12:52 +02006625testcase TC_chopped_ipa_ping() runs on test_CT {
6626 IPA_Testing.f_run_TC_chopped_ipa_ping(mp_rsl_ip, mp_rsl_port, LISTEN_FOR_CLIENT);
6627}
6628
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02006629testcase TC_chopped_ipa_payload() runs on test_CT {
6630 IPA_Testing.f_run_TC_chopped_ipa_payload(mp_rsl_ip, mp_rsl_port, LISTEN_FOR_CLIENT);
6631}
6632
Harald Welte0472ab42018-03-12 15:02:26 +01006633/* test generation of RLL ERR IND based on Um errors (TS 48.058 3.9) */
6634/* protocol error as per 44.006 */
6635/* link layer failure (repetition of I-frame N200 times without ACK */
6636/* repetition of SABM or DISC N200 times without ACK */
6637/* receptiom of SABM in multi-frame established state */
6638
6639
Harald Welte68e495b2018-02-25 00:05:57 +01006640/* TODO Areas:
6641
6642* channel activation
6643** with BS_Power / MS_Power, bypassing power control loop
6644** on primary vs. secondary TRX
Harald Welte68e495b2018-02-25 00:05:57 +01006645** with timing advance from initial activation on
6646* mode modify
6647** encryption
6648** multirate
6649* check DEACTIVATE SACCH
Harald Welte68e495b2018-02-25 00:05:57 +01006650** unsupported algorithm
6651* handover detection
Harald Welte68e495b2018-02-25 00:05:57 +01006652* BS Power Control
6653* Physical Context
Harald Welte68e495b2018-02-25 00:05:57 +01006654* RF resource ind
Harald Welte68e495b2018-02-25 00:05:57 +01006655* error handling
Harald Welte68e495b2018-02-25 00:05:57 +01006656** IE duplicated?
Harald Welte883340c2018-02-28 18:59:29 +01006657* PCU interface
Harald Welte883340c2018-02-28 18:59:29 +01006658** DATA_IND from BTS->PCU
6659** verification of PCU-originated DATA_REQ arrival on Um/MS side
Harald Welte68e495b2018-02-25 00:05:57 +01006660
6661*/
Harald Welte70767382018-02-21 12:16:40 +01006662
6663control {
6664 execute( TC_chan_act_stress() );
6665 execute( TC_chan_act_react() );
6666 execute( TC_chan_deact_not_active() );
6667 execute( TC_chan_act_wrong_nr() );
Harald Welte629cc6b2018-03-11 17:19:05 +01006668 execute( TC_deact_sacch() );
Harald Welteea17b912018-03-11 22:29:31 +01006669 execute( TC_sacch_filling() );
6670 execute( TC_sacch_info_mod() );
Harald Welte075d84c2018-03-12 13:07:24 +01006671 execute( TC_sacch_multi() );
Harald Welte55700662018-03-12 13:15:43 +01006672 execute( TC_sacch_multi_chg() );
Harald Weltec8d363c2019-05-19 20:36:48 +02006673 execute( TC_sacch_chan_act() );
Harald Welte8b01c792019-05-19 22:51:25 +02006674 execute( TC_sacch_chan_act_ho_async() );
6675 execute( TC_sacch_chan_act_ho_sync() );
Harald Welte8c24c2b2018-02-26 08:31:31 +01006676 execute( TC_rach_content() );
6677 execute( TC_rach_count() );
Harald Welte54a2a2d2018-02-26 09:14:05 +01006678 execute( TC_rach_max_ta() );
Vadim Yanitskiy7c2c10c2019-05-31 20:42:01 +07006679 execute( TC_ho_rach() );
Harald Welte3453ab42019-05-24 21:19:58 +02006680 execute( TC_rach_load_idle_thresh0() );
6681 execute( TC_rach_load_idle_below_thresh() );
6682 execute( TC_rach_load_count() );
Harald Welte70767382018-02-21 12:16:40 +01006683 execute( TC_meas_res_sign_tchf() );
6684 execute( TC_meas_res_sign_tchh() );
6685 execute( TC_meas_res_sign_sdcch4() );
6686 execute( TC_meas_res_sign_sdcch8() );
Harald Welte685d5982018-02-27 20:42:05 +01006687 execute( TC_meas_res_sign_tchh_toa256() );
Pau Espin Pedrola2e079c2020-06-03 17:31:04 +02006688 execute( TC_tx_power_start_ramp_up_bcch() );
Pau Espin Pedrolb6985f92020-06-23 14:01:02 +02006689 execute( TC_tx_power_start_ramp_down_bcch() );
Pau Espin Pedrol45fe5e02020-06-23 19:00:00 +02006690 execute( TC_tx_power_ramp_adm_state_change() );
Eric Wildae8f2622019-06-18 17:05:11 +02006691 execute( TC_rsl_bs_pwr_static_ass() );
6692 execute( TC_rsl_bs_pwr_static_power_control() );
Philipp Maier4d1e9c92018-12-20 11:11:56 +01006693 execute( TC_rsl_ms_pwr_ctrl() );
Eric Wild280ccb82019-06-17 11:11:52 +02006694 execute( TC_rsl_ms_pwr_dyn_active() );
Eric Wild095024b2019-06-17 15:08:57 +02006695 execute( TC_rsl_ms_pwr_dyn_active2() );
Eric Wild61edb7e2019-06-03 12:38:31 +02006696 execute( TC_rsl_ms_pwr_dyn_up() );
6697 execute( TC_rsl_ms_pwr_dyn_down() );
6698 execute( TC_rsl_ms_pwr_dyn_ass_updown() );
6699 execute( TC_rsl_ms_pwr_dyn_max() );
Eric Wilde57e1a62019-05-28 13:30:55 +02006700 execute( TC_rsl_chan_initial_ms_pwr() );
Eric Wild6833cc92019-05-23 19:34:44 +02006701 execute( TC_rsl_chan_initial_ta() );
Eric Wildf1827a72019-05-28 17:37:35 +02006702 execute( TC_rsl_modify_encr() );
Harald Welte70767382018-02-21 12:16:40 +01006703 execute( TC_conn_fail_crit() );
Harald Welte68e495b2018-02-25 00:05:57 +01006704 execute( TC_paging_imsi_80percent() );
6705 execute( TC_paging_tmsi_80percent() );
6706 execute( TC_paging_imsi_200percent() );
6707 execute( TC_paging_tmsi_200percent() );
Harald Welte01d982c2018-02-25 01:31:40 +01006708 execute( TC_rsl_protocol_error() );
6709 execute( TC_rsl_mand_ie_error() );
6710 execute( TC_rsl_ie_content_error() );
Harald Welte48494ca2018-02-25 16:59:50 +01006711 execute( TC_si_sched_default() );
Harald Welte0cae4552018-03-09 22:20:26 +01006712 execute( TC_si_sched_1() );
Harald Welte48494ca2018-02-25 16:59:50 +01006713 execute( TC_si_sched_2bis() );
6714 execute( TC_si_sched_2ter() );
6715 execute( TC_si_sched_2ter_2bis() );
6716 execute( TC_si_sched_2quater() );
6717 execute( TC_si_sched_13() );
6718 execute( TC_si_sched_13_2bis_2ter_2quater() );
Harald Weltea871a382018-02-25 02:03:14 +01006719 execute( TC_ipa_dlcx_not_active() );
Harald Weltea3f1df92018-02-25 12:49:55 +01006720 execute( TC_ipa_crcx_twice_not_active() );
6721 execute( TC_ipa_crcx_mdcx_dlcx_not_active() );
Harald Welte3ae11da2018-02-25 13:36:06 +01006722 execute( TC_ipa_crcx_mdcx_mdcx_dlcx_not_active() );
Harald Welte9912eb52018-02-25 13:30:15 +01006723 execute( TC_ipa_crcx_sdcch_not_active() );
Harald Welte883340c2018-02-28 18:59:29 +01006724
Pau Espin Pedrola14a8af2018-11-20 13:12:22 +01006725 if (mp_pcu_socket != "") {
6726 execute( TC_pcu_act_req() );
6727 execute( TC_pcu_act_req_wrong_ts() );
6728 execute( TC_pcu_act_req_wrong_bts() );
6729 execute( TC_pcu_act_req_wrong_trx() );
6730 execute( TC_pcu_deact_req() );
6731 execute( TC_pcu_deact_req_wrong_ts() );
6732 execute( TC_pcu_ver_si13() );
Harald Weltead033dc2019-05-25 17:28:16 +02006733 if (mp_l1_supports_gprs) {
6734 execute( TC_pcu_data_req_pdtch() );
6735 execute( TC_pcu_data_req_ptcch() );
Harald Welte7162a612019-05-26 12:56:09 +02006736 execute( TC_pcu_data_req_wrong_bts() );
6737 execute( TC_pcu_data_req_wrong_trx() );
6738 execute( TC_pcu_data_req_wrong_ts() );
6739 execute( TC_pcu_data_req_ts_inactive() );
Harald Weltead033dc2019-05-25 17:28:16 +02006740 }
Vadim Yanitskiy970b1532019-10-24 15:22:19 +07006741 execute( TC_pcu_ptcch() );
Pau Espin Pedrola14a8af2018-11-20 13:12:22 +01006742 execute( TC_pcu_data_req_agch() );
Harald Welte928622b2019-05-26 13:22:59 +02006743 execute( TC_pcu_data_req_pch() );
Pau Espin Pedrola14a8af2018-11-20 13:12:22 +01006744 execute( TC_pcu_data_req_imm_ass_pch() );
6745 execute( TC_pcu_rach_content() );
Vadim Yanitskiy51cbc102019-04-22 06:37:30 +07006746 execute( TC_pcu_ext_rach_content() );
Vadim Yanitskiya2c68e82019-07-03 13:07:20 +07006747 execute( TC_pcu_data_ind_lqual_cb() );
Pau Espin Pedrola14a8af2018-11-20 13:12:22 +01006748 execute( TC_pcu_paging_from_rsl() );
Harald Welted66c9b82019-05-25 09:03:15 +02006749 execute( TC_pcu_time_ind() );
Harald Welte4832c862019-05-25 14:57:18 +02006750 execute( TC_pcu_rts_req() );
Harald Welte07bd2d22019-05-25 11:03:30 +02006751 execute( TC_pcu_oml_alert() );
Harald Welteeaa9a862019-05-26 23:01:08 +02006752 execute( TC_pcu_rr_suspend() );
Harald Weltea2e0e942019-05-27 18:12:53 +02006753 execute( TC_pcu_socket_connect_multi() );
Harald Weltec8effb72019-05-27 18:23:04 +02006754 execute( TC_pcu_socket_reconnect() );
Harald Weltebe030482019-05-27 22:29:35 +02006755 execute( TC_pcu_socket_noconnect_nosi3gprs() );
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07006756 execute( TC_pcu_socket_noconnect_nosi4gprs() );
Harald Weltebe030482019-05-27 22:29:35 +02006757 execute( TC_pcu_socket_connect_si3gprs() );
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07006758 execute( TC_pcu_socket_connect_si4gprs() );
Harald Weltebe030482019-05-27 22:29:35 +02006759 execute( TC_pcu_socket_disconnect_nosi3gprs() );
Vadim Yanitskiya8e83a82020-05-04 16:05:12 +07006760 execute( TC_pcu_socket_disconnect_nosi4gprs() );
Oliver Smithf5239c72019-08-28 10:01:25 +02006761 execute( TC_pcu_socket_verify_info_ind() );
Philipp Maier15cd6872020-01-08 13:41:41 +01006762 execute( TC_dyn_osmo_pdch_act_deact() );
6763 execute( TC_dyn_osmo_pdch_double_act() );
6764 execute( TC_dyn_ipa_pdch_act_deact() );
6765 execute( TC_dyn_ipa_pdch_act_tchf_act_nack() );
6766
Pau Espin Pedrola14a8af2018-11-20 13:12:22 +01006767 } else {
6768 log("PCU socket path not available, skipping PCU tests");
6769 }
Harald Welte3d04ae62018-04-04 20:29:05 +02006770
Harald Welte3d04ae62018-04-04 20:29:05 +02006771 execute( TC_dyn_osmo_pdch_unsol_deact() );
Harald Welte3d04ae62018-04-04 20:29:05 +02006772 execute( TC_dyn_osmo_pdch_tchf_act() );
6773 execute( TC_dyn_osmo_pdch_tchh_act() );
Harald Welte9bbbfb52018-04-05 09:33:19 +02006774 execute( TC_dyn_ipa_pdch_tchf_act() );
6775 execute( TC_dyn_ipa_pdch_tchf_act_pdch_act_nack() );
Harald Welte0472ab42018-03-12 15:02:26 +01006776
6777 execute( TC_rll_est_ind() );
6778 execute( TC_rll_est_req_DCCH_3() );
6779 execute( TC_rll_est_req_ACCH_3() );
6780 execute( TC_rll_rel_ind_DCCH_0() );
6781 execute( TC_rll_rel_ind_DCCH_3() );
6782 execute( TC_rll_rel_ind_ACCH_0() );
6783 execute( TC_rll_rel_ind_ACCH_3() );
6784 execute( TC_rll_rel_req() );
6785 execute( TC_rll_unit_data_req_DCCH() );
6786 execute( TC_rll_unit_data_req_ACCH() );
6787 execute( TC_rll_unit_data_ind_DCCH() );
6788 execute( TC_rll_unit_data_ind_ACCH() );
Harald Weltee613f962018-04-18 22:38:16 +02006789
6790 execute( TC_chan_act_a51() );
6791 execute( TC_chan_act_a52() );
6792 execute( TC_chan_act_a53() );
6793 execute( TC_encr_cmd_a51() );
6794 execute( TC_encr_cmd_a52() );
6795 execute( TC_encr_cmd_a53() );
6796
Harald Welteee25aae2019-05-19 14:32:37 +02006797 execute( TC_err_rep_wrong_mdisc() );
6798 execute( TC_err_rep_wrong_msg_type() );
6799 execute( TC_err_rep_wrong_sequence() );
6800
Harald Weltee613f962018-04-18 22:38:16 +02006801 execute( TC_lapdm_selftest() );
Stefan Sperling4880be42018-08-07 18:12:59 +02006802
6803 execute( TC_tch_sign_l2_fill_frame() );
6804 execute( TC_tch_sign_l2_fill_frame_dtxd() );
Stefan Sperling0ec1c262018-10-15 15:12:52 +02006805
6806 execute( TC_chopped_ipa_ping() );
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02006807 execute( TC_chopped_ipa_payload() );
Harald Welte70767382018-02-21 12:16:40 +01006808}
6809
6810
6811}