blob: f1aea75c142bcc112a5fbec1e832f6336b8dab93 [file] [log] [blame]
Harald Welte28d943e2017-11-25 15:00:50 +01001module BSC_Tests {
2
Harald Welte21b46bd2017-12-17 19:46:32 +01003/* Integration Tests for OsmoBSC
Harald Weltea0630032018-03-20 21:09:55 +01004 * (C) 2017-2018 by Harald Welte <laforge@gnumonks.org>
Harald Welte21b46bd2017-12-17 19:46:32 +01005 * All rights reserved.
6 *
7 * Released under the terms of GNU General Public License, Version 2 or
8 * (at your option) any later version.
9 *
Harald Welte34b5a952019-05-27 11:54:11 +020010 * SPDX-License-Identifier: GPL-2.0-or-later
11 *
Harald Welte21b46bd2017-12-17 19:46:32 +010012 * This test suite tests OsmoBSC while emulating both multiple BTS + MS as
13 * well as the MSC. See README for more details.
14 *
15 * There are test cases that run in so-called 'handler mode' and test cases
16 * that run directly on top of the BSSAP and RSL CodecPorts. The "handler mode"
17 * tests abstract the multiplexing/demultiplexing of multiple SCCP connections
18 * and/or RSL channels and are hence suitable for higher-level test cases, while
19 * the "raw" tests directly on top of the CodecPorts are more suitable for lower-
20 * level testing.
21 */
22
Neels Hofmeyr4f118412020-06-04 15:25:10 +020023import from Misc_Helpers all;
Harald Welte4003d112017-12-09 22:35:39 +010024import from General_Types all;
Harald Welte28d943e2017-11-25 15:00:50 +010025import from Osmocom_Types all;
Harald Welteae026692017-12-09 01:03:01 +010026import from GSM_Types all;
Harald Welte28d943e2017-11-25 15:00:50 +010027import from IPL4asp_Types all;
28
Harald Welte6f521d82017-12-11 19:52:02 +010029import from BSSAP_Types all;
Harald Welte6811d102019-04-14 22:23:14 +020030import from RAN_Adapter all;
Harald Welteae026692017-12-09 01:03:01 +010031import from BSSAP_CodecPort all;
32import from BSSMAP_Templates all;
Harald Welte28d943e2017-11-25 15:00:50 +010033import from IPA_Emulation all;
Stefan Sperling830dc9d2018-02-12 21:08:28 +010034import from IPA_CodecPort all;
Harald Welteae026692017-12-09 01:03:01 +010035import from IPA_Types all;
Stefan Sperling0796a822018-10-05 13:01:39 +020036import from IPA_Testing all;
Harald Welteae026692017-12-09 01:03:01 +010037import from RSL_Types all;
Harald Welte624f9632017-12-16 19:26:04 +010038import from RSL_Emulation all;
Daniel Willmann191e0d92018-01-17 12:44:35 +010039import from MGCP_Emulation all;
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +010040import from MGCP_Templates all;
41import from MGCP_Types all;
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +020042import from MGCP_CodecPort all;
Harald Welte28d943e2017-11-25 15:00:50 +010043
Harald Welte96c94412017-12-09 03:12:45 +010044import from Osmocom_CTRL_Functions all;
Harald Weltea5d2ab22017-12-09 14:21:42 +010045import from Osmocom_CTRL_Types all;
Harald Welteffe55fc2018-01-17 22:39:54 +010046import from Osmocom_CTRL_Adapter all;
Harald Welte96c94412017-12-09 03:12:45 +010047
Harald Weltebc03c762018-02-12 18:09:38 +010048import from Osmocom_VTY_Functions all;
49import from TELNETasp_PortType all;
50
Harald Welte6f521d82017-12-11 19:52:02 +010051import from MobileL3_CommonIE_Types all;
Harald Weltee3bd6582018-01-31 22:51:25 +010052import from MobileL3_Types all;
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +010053import from MobileL3_RRM_Types all;
Harald Welte6f521d82017-12-11 19:52:02 +010054import from L3_Templates all;
55import from GSM_RR_Types all;
56
Stefan Sperlingc307e682018-06-14 15:15:46 +020057import from SCCP_Templates all;
Neels Hofmeyr4ff93282018-03-12 04:25:35 +010058import from BSSMAP_Templates all;
59
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +010060import from SCCPasp_Types all;
61
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +020062import from GSM_SystemInformation all;
63import from GSM_RestOctets all;
64
Harald Welte5d1a2202017-12-13 19:51:29 +010065const integer NUM_BTS := 3;
Neels Hofmeyrf246a922020-05-13 02:27:10 +020066const integer NUM_MSC := 3;
Harald Welteae026692017-12-09 01:03:01 +010067const float T3101_MAX := 12.0;
Harald Welte28d943e2017-11-25 15:00:50 +010068
Harald Welte799c97b2017-12-14 17:50:30 +010069/* make sure to sync this with the osmo-bts.cfg you're using */
Philipp Maiercb6cc482018-03-26 13:08:00 +020070const integer NUM_TCHH_PER_BTS := 2;
71const integer NUM_TCHF_PER_BTS := 4;
Harald Weltedd8cbf32018-01-28 12:07:52 +010072const integer NUM_SDCCH_PER_BTS := 4;
Harald Welte799c97b2017-12-14 17:50:30 +010073
Harald Welte4003d112017-12-09 22:35:39 +010074
Harald Welte21b46bd2017-12-17 19:46:32 +010075/* per-BTS state which we keep */
Harald Welte96c94412017-12-09 03:12:45 +010076type record BTS_State {
Harald Welte21b46bd2017-12-17 19:46:32 +010077 /* component reference to the IPA_Client component used for RSL */
Harald Weltea5d2ab22017-12-09 14:21:42 +010078 IPA_Client rsl
Harald Welte96c94412017-12-09 03:12:45 +010079}
80
Neels Hofmeyr22c3f792020-06-17 02:49:28 +020081/* Default list of counters for an 'msc' entity. */
82const CounterNameVals counternames_msc_mscpool := {
83 { "mscpool:subscr:new", 0 },
84 { "mscpool:subscr:known", 0 },
85 { "mscpool:subscr:reattach", 0 },
86 { "mscpool:subscr:attach_lost", 0 },
87 { "mscpool:subscr:paged", 0 }
88};
89
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +020090/* Set of all System Information received during one RSL port's startup.
91 * Note that some System Information may be sent on RSL, but lacking actual SI data, to indicate that the BTS should not
92 * broadcast that SI type. That will be reflected as 'omit' here.
93 */
94type record SystemInformationConfig {
95 SystemInformationType1 si1 optional,
96 SystemInformationType2 si2 optional,
97 SystemInformationType2bis si2bis optional,
98 SystemInformationType2ter si2ter optional,
99 record of SI2quaterRestOctets si2quater optional,
100 SystemInformationType3 si3 optional,
101 SystemInformationType4 si4 optional,
102 /* TODO: replace with proper decoding of SI13, implement SI13 in GSM_SystemInformation.ttcn */
103 octetstring si13 optional,
104 SystemInformationType5 si5 optional,
105 SystemInformationType5bis si5bis optional,
106 SystemInformationType5ter si5ter optional,
107 SystemInformationType6 si6 optional
108};
109
110const SystemInformationConfig SystemInformationConfig_omit := {
111 si1 := omit,
112 si2 := omit,
113 si2bis := omit,
114 si2ter := omit,
115 si2quater := omit,
116 si3 := omit,
117 si4 := omit,
118 si13 := omit,
119 si5 := omit,
120 si5bis := omit,
121 si5ter := omit,
122 si6 := omit
123};
124
125/* tr_EUTRAN_CellDesc with defaults used in BSC_Tests.ttcn */
126template EUTRAN_CellDesc tr_EUTRAN_CellDesc_default(template (present) uint16_t e_arfcn := ?,
127 template uint3_t meas_bw := 3)
128:= tr_EUTRAN_CellDesc(e_arfcn := e_arfcn,
129 meas_bw_presence := '1'B,
130 meas_bw := meas_bw);
131
132/* tr_EUTRAN_NeighbourCells with defaults used in BSC_Tests.ttcn */
133template EUTRAN_NeighbourCells tr_EUTRAN_NeighbourCells_default(template EUTRAN_CellDescs cell_desc_list := { tr_EUTRAN_CellDesc_default },
134 template uint3_t prio := 3,
135 template (present) uint5_t thresh_high := 20,
136 template uint5_t thresh_low := 10,
137 template uint5_t qrxlevmin := 22)
138:= tr_EUTRAN_NeighbourCells(
139 cell_desc_list := cell_desc_list,
140 prio_presence := '1'B,
141 prio := prio,
142 thresh_high := thresh_high,
143 thresh_low_presence := '1'B,
144 thresh_low := thresh_low,
145 qrxlevmin_presence := '1'B,
146 qrxlevmin := qrxlevmin);
147
148template SystemInformationConfig SystemInformationConfig_default := {
149 si1 := {
150 cell_chan_desc := '8FB38000000000000000000000000000'O,
151 rach_control := {
152 max_retrans := RACH_MAX_RETRANS_7,
153 tx_integer := '1001'B,
154 cell_barr_access := false,
155 re_not_allowed := true,
156 acc := '0000010000000000'B
157 },
158 rest_octets := ?
159 },
160 si2 := {
161 bcch_freq_list := '00000000000000000000000000000000'O,
162 ncc_permitted := '11111111'B,
163 rach_control := {
164 max_retrans := RACH_MAX_RETRANS_7,
165 tx_integer := '1001'B,
166 cell_barr_access := false,
167 re_not_allowed := true,
168 acc := '0000010000000000'B
169 }
170 },
171 si2bis := omit,
172 si2ter := {
173 extd_bcch_freq_list := '8E320000000000000000000000000800'O,
174 rest_octets := ?
175 },
176 si2quater := {
177 tr_SI2quaterRestOctets_EUTRAN( repeated_neigh_cells := { tr_EUTRAN_NeighbourCells_default } )
178 },
179 si3 := {
180 cell_id := 0,
181 lai := {
182 mcc_mnc := '001F01'H,
183 lac := 1
184 },
185 ctrl_chan_desc := {
186 msc_r99 := true,
187 att := true,
188 bs_ag_blks_res := 1,
189 ccch_conf := CCHAN_DESC_1CCCH_COMBINED,
190 si22ind := false,
191 cbq3 := CBQ3_IU_MODE_NOT_SUPPORTED,
192 spare := '00'B,
193 bs_pa_mfrms := 3,
194 t3212 := 30
195 },
196 cell_options := {
197 dn_ind := false,
198 pwrc := false,
199 dtx := MS_SHALL_USE_UL_DTX,
200 radio_link_tout_div4 := 7
201 },
202 cell_sel_par := {
203 cell_resel_hyst_2dB := 2,
204 ms_txpwr_max_cch := 7,
205 acs := '0'B,
206 neci := true,
207 rxlev_access_min := 0
208 },
209 rach_control := {
210 max_retrans := RACH_MAX_RETRANS_7,
211 tx_integer := '1001'B,
212 cell_barr_access := false,
213 re_not_allowed := true,
214 acc := '0000010000000000'B
215 },
216 rest_octets := {
217 sel_params := {
218 presence := '0'B,
219 params := omit
220 },
221 pwr_offset := {
222 presence := '0'B,
223 offset := omit
224 },
225 si_2ter_ind := '1'B,
226 early_cm_ind := '0'B,
227 sched_where := {
228 presence := '0'B,
229 where := omit
230 },
231 gprs_ind := {
232 presence := '1'B,
233 ind := {
234 ra_colour := 0,
235 si13_pos := '0'B
236 }
237 },
238 umts_early_cm_ind := '1'B,
239 si2_quater_ind := {
240 presence := '1'B,
241 ind := '0'B
242 },
243 iu_mode_ind := omit,
244 si21_ind := {
245 presence := '0'B,
246 pos := omit
247 }
248 }
249 },
250 si4 := {
251 lai := {
252 mcc_mnc := '001F01'H,
253 lac := 1
254 },
255 cell_sel_par := {
256 cell_resel_hyst_2dB := 2,
257 ms_txpwr_max_cch := 7,
258 acs := '0'B,
259 neci := true,
260 rxlev_access_min := 0
261 },
262 rach_control := {
263 max_retrans := RACH_MAX_RETRANS_7,
264 tx_integer := '1001'B,
265 cell_barr_access := false,
266 re_not_allowed := true,
267 acc := '0000010000000000'B
268 },
269 cbch_chan_desc := omit,
270 cbch_mobile_alloc := omit,
271 rest_octets := {
272 sel_params := {
273 presence := '0'B,
274 params := omit
275 },
276 pwr_offset := {
277 presence := '0'B,
278 offset := omit
279 },
280 gprs_ind := {
281 presence := '1'B,
282 ind := {
283 ra_colour := 0,
284 si13_pos := '0'B
285 }
286 },
287 s_presence := '0'B,
288 s := omit
289 }
290 },
291 si13 := '9000185A6FC9E08410AB2B2B2B2B2B2B2B2B2B2B'O,
292 si5 := {
293 bcch_freq_list := '10000000000000000000000000000000'O
294 },
295 si5bis := omit,
296 si5ter := {
297 extd_bcch_freq_list := '9E050020000000000000000000000000'O
298 },
299 si6 := {
300 cell_id := 0,
301 lai := {
302 mcc_mnc := '001F01'H,
303 lac := 1
304 },
305 cell_options := {
306 dtx_ext := '1'B,
307 pwrc := false,
308 dtx := '01'B,
309 radio_link_timeout := '0111'B
310 },
311 ncc_permitted := '11111111'B,
312 rest_octets := ?
313 }
314 };
315
316
317/* List of all the System Information received on all RSL ports */
318type record of SystemInformationConfig SystemInformationConfig_list;
319
320function f_sysinfo_dec_raw(inout SystemInformationConfig si, RSL_Message rsl)
321{
322 var RSL_IE_Body sysinfo_type_ie;
323 var RSL_IE_SysinfoType si_type;
324 var octetstring data;
325
326 if (f_rsl_find_ie(rsl, RSL_IE_SYSINFO_TYPE, sysinfo_type_ie) == false) {
327 setverdict(fail, "Cannot find RSL_IE_SYSINFO_TYPE");
328 mtc.stop;
329 }
330 si_type := sysinfo_type_ie.sysinfo_type;
331
332 if (rsl.msg_type == RSL_MT_BCCH_INFO) {
333 var RSL_IE_Body bcch_ie;
334 if (f_rsl_find_ie(rsl, RSL_IE_FULL_BCCH_INFO, bcch_ie)) {
335 data := bcch_ie.other.payload;
336 }
337 } else if (rsl.msg_type == RSL_MT_SACCH_FILL) {
338 var RSL_IE_Body l3_ie;
339 if (f_rsl_find_ie(rsl, RSL_IE_L3_INFO, l3_ie)) {
340 data := l3_ie.l3_info.payload;
341 }
342 } else {
343 setverdict(fail, "Don't understand this System Information message");
344 mtc.stop;
345 }
346
347 var boolean handled := false;
348
349 if (rsl.msg_type == RSL_MT_BCCH_INFO) {
350 handled := true;
351
352 if (si_type == RSL_SYSTEM_INFO_1) {
353 if (not isbound(data)) {
354 si.si1 := omit;
355 } else {
356 si.si1 := dec_SystemInformation(data).payload.si1;
357 }
358 } else if (si_type == RSL_SYSTEM_INFO_2) {
359 if (not isbound(data)) {
360 si.si2 := omit;
361 } else {
362 si.si2 := dec_SystemInformation(data).payload.si2;
363 }
364 } else if (si_type == RSL_SYSTEM_INFO_2bis) {
365 if (not isbound(data)) {
366 si.si2bis := omit;
367 } else {
368 si.si2bis := dec_SystemInformation(data).payload.si2bis;
369 }
370 } else if (si_type == RSL_SYSTEM_INFO_2ter) {
371 if (not isbound(data)) {
372 si.si2ter := omit;
373 } else {
374 si.si2ter := dec_SystemInformation(data).payload.si2ter;
375 }
376 } else if (si_type == RSL_SYSTEM_INFO_2quater) {
377 if (not isbound(data)) {
378 si.si2quater := {};
379 } else {
380 var SystemInformationType2quater decoded := dec_SystemInformation(data).payload.si2quater;
381 /* this is a *record* of SI2quaterRestOctets! (multiplexed) */
382 si.si2quater[decoded.rest_octets.si2quater_index] := decoded.rest_octets;
383 }
384 } else if (si_type == RSL_SYSTEM_INFO_3) {
385 if (not isbound(data)) {
386 si.si3 := omit;
387 } else {
388 si.si3 := dec_SystemInformation(data).payload.si3;
389 }
390 } else if (si_type == RSL_SYSTEM_INFO_4) {
391 if (not isbound(data)) {
392 si.si4 := omit;
393 } else {
394 si.si4 := dec_SystemInformation(data).payload.si4;
395 }
396 } else if (si_type == RSL_SYSTEM_INFO_13) {
397 if (not isbound(data)) {
398 si.si13 := omit;
399 } else {
400 si.si13 := dec_SystemInformation(data).payload.other;
401 }
402 } else {
403 handled := false;
404 }
405 } else if (rsl.msg_type == RSL_MT_SACCH_FILL) {
406 handled := true;
407
408 if (si_type == RSL_SYSTEM_INFO_5) {
409 if (not isbound(data)) {
410 si.si5 := omit;
411 } else {
412 si.si5 := dec_SystemInformation(data).payload.si5;
413 }
414 } else if (si_type == RSL_SYSTEM_INFO_5bis) {
415 if (not isbound(data)) {
416 si.si5bis := omit;
417 } else {
418 si.si5bis := dec_SystemInformation(data).payload.si5bis;
419 }
420 } else if (si_type == RSL_SYSTEM_INFO_5ter) {
421 if (not isbound(data)) {
422 si.si5ter := omit;
423 } else {
424 si.si5ter := dec_SystemInformation(data).payload.si5ter;
425 }
426 } else if (si_type == RSL_SYSTEM_INFO_6) {
427 if (not isbound(data)) {
428 si.si6 := omit;
429 } else {
430 si.si6 := dec_SystemInformation(data).payload.si6;
431 }
432 } else {
433 handled := false;
434 }
435 }
436
437 if (not handled) {
438 setverdict(fail, "Unexpected SI type in ", rsl.msg_type, " message: ", si_type);
439 }
440}
441
Harald Weltea4ca4462018-02-09 00:17:14 +0100442type component test_CT extends CTRL_Adapter_CT {
Harald Welte21b46bd2017-12-17 19:46:32 +0100443 /* Array of per-BTS state */
Harald Welte96c94412017-12-09 03:12:45 +0100444 var BTS_State bts[NUM_BTS];
Harald Welte89ab1912018-02-23 18:56:29 +0100445 /* RSL common Channel Port (for RSL_Emulation) */
446 port RSL_CCHAN_PT RSL_CCHAN[NUM_BTS];
Harald Welte21b46bd2017-12-17 19:46:32 +0100447 /* array of per-BTS RSL test ports */
Harald Welteae026692017-12-09 01:03:01 +0100448 port IPA_RSL_PT IPA_RSL[NUM_BTS];
Stefan Sperling830dc9d2018-02-12 21:08:28 +0100449 port IPA_CODEC_PT IPA; /* Required for compilation of TC_rsl_unknown_unit_id() */
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +0200450 /* CTRL muxed over IPA in SCCPlite conn BSC<->MSC (or BSC-NAT) */
451 port IPA_CTRL_PT SCCPLITE_IPA_CTRL;
Harald Weltea5d2ab22017-12-09 14:21:42 +0100452
Daniel Willmann191e0d92018-01-17 12:44:35 +0100453 var MGCP_Emulation_CT vc_MGCP;
Harald Weltebc03c762018-02-12 18:09:38 +0100454 port TELNETasp_PT BSCVTY;
Daniel Willmann191e0d92018-01-17 12:44:35 +0100455
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200456 var RAN_Adapter g_bssap[NUM_MSC];
Harald Weltea4ca4462018-02-09 00:17:14 +0100457 /* for old legacy-tests only */
458 port BSSAP_CODEC_PT BSSAP;
459
Harald Welte21b46bd2017-12-17 19:46:32 +0100460 /* are we initialized yet */
Harald Welte28d943e2017-11-25 15:00:50 +0100461 var boolean g_initialized := false;
Harald Welte21b46bd2017-12-17 19:46:32 +0100462
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200463 /* Osmux is enabled through VTY */
464 var boolean g_osmux_enabled := false;
465
Pau Espin Pedrolc675b612020-01-09 19:55:40 +0100466 /*Configure T(tias) over VTY, seconds */
467 var integer g_bsc_sccp_timer_ias := 7 * 60;
468 /*Configure T(tiar) over VTY, seconds */
469 var integer g_bsc_sccp_timer_iar := 15 * 60;
470
Neels Hofmeyr4fbad7f2020-06-16 00:30:47 +0200471 /* global test case guard timer (actual timeout value is set in f_init()) */
Harald Welteae026692017-12-09 01:03:01 +0100472 timer T_guard := 30.0;
473
Neels Hofmeyr22c3f792020-06-17 02:49:28 +0200474 var CounterNameValsList g_ctr_msc;
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200475
476 /* System Information bytes as received during RSL startup, for each RSL[idx]. */
477 var SystemInformationConfig_list g_system_information := {};
Harald Welte28d943e2017-11-25 15:00:50 +0100478}
479
480modulepar {
Harald Welte21b46bd2017-12-17 19:46:32 +0100481 /* IP address at which the BSC can be reached */
Harald Welte696ddb62017-12-08 14:01:43 +0100482 charstring mp_bsc_ip := "127.0.0.1";
Stefan Sperling830dc9d2018-02-12 21:08:28 +0100483 /* port number to which to establish the IPA OML connections */
484 integer mp_bsc_oml_port := 3002;
Harald Welte21b46bd2017-12-17 19:46:32 +0100485 /* port number to which to establish the IPA RSL connections */
Harald Welte696ddb62017-12-08 14:01:43 +0100486 integer mp_bsc_rsl_port := 3003;
Harald Welte21b46bd2017-12-17 19:46:32 +0100487 /* port number to which to establish the IPA CTRL connection */
Harald Welte96c94412017-12-09 03:12:45 +0100488 integer mp_bsc_ctrl_port := 4249;
Daniel Willmann191e0d92018-01-17 12:44:35 +0100489 /* IP address at which the test binds */
490 charstring mp_test_ip := "127.0.0.1";
Harald Weltea4ca4462018-02-09 00:17:14 +0100491
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200492 RAN_Configurations mp_bssap_cfg := {
493 {
494 transport := BSSAP_TRANSPORT_AoIP,
495 sccp_service_type := "mtp3_itu",
496 sctp_addr := { 23905, "127.0.0.1", 2905, "127.0.0.1" },
497 own_pc := 185, /* 0.23.1 first MSC emulation */
498 own_ssn := 254,
499 peer_pc := 187, /* 0.23.3 osmo-bsc */
500 peer_ssn := 254,
501 sio := '83'O,
Harald Weltecb0cc432020-06-21 19:42:31 +0200502 rctx := 1
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200503 },
504 {
505 transport := BSSAP_TRANSPORT_AoIP,
506 sccp_service_type := "mtp3_itu",
507 sctp_addr := { 23906, "127.0.0.1", 2905, "127.0.0.1" },
508 own_pc := 2, /* 0.0.2 second MSC emulation */
509 own_ssn := 254,
510 peer_pc := 187, /* 0.23.3 osmo-bsc */
511 peer_ssn := 254,
512 sio := '83'O,
513 rctx := 2
514 },
515 {
516 transport := BSSAP_TRANSPORT_AoIP,
517 sccp_service_type := "mtp3_itu",
518 sctp_addr := { 23907, "127.0.0.1", 2905, "127.0.0.1" },
519 own_pc := 3, /* 0.0.3 third MSC emulation */
520 own_ssn := 254,
521 peer_pc := 187, /* 0.23.3 osmo-bsc */
522 peer_ssn := 254,
523 sio := '83'O,
524 rctx := 3
525 }
Harald Weltea4ca4462018-02-09 00:17:14 +0100526 };
Pau Espin Pedrol58cf6822019-05-28 18:11:33 +0200527
528 /* Whether to enable osmux tests. Can be dropped completely and enable
529 unconditionally once new version of osmo-bsc is released (current
530 version: 1.4.1) */
531 boolean mp_enable_osmux_test := true;
Pau Espin Pedrol8f30ccd2019-11-01 17:30:57 +0100532 /* Value set in osmo-bsc.cfg "ms max power" */
533 uint8_t mp_exp_ms_power_level := 7;
Harald Weltea4ca4462018-02-09 00:17:14 +0100534}
535
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200536private function f_gen_test_hdlr_pars(integer bssap_idx := 0) return TestHdlrParams {
Philipp Maier48604732018-10-09 15:00:37 +0200537
538 var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200539 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Philipp Maier48604732018-10-09 15:00:37 +0200540 pars.aoip := true;
541 } else {
542 pars.aoip := false;
543 }
Pau Espin Pedrol8f30ccd2019-11-01 17:30:57 +0100544 pars.exp_ms_power_level := mp_exp_ms_power_level;
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200545 pars.mscpool.bssap_idx := bssap_idx;
Philipp Maier48604732018-10-09 15:00:37 +0200546
547 return pars;
548}
549
Neels Hofmeyr22c3f792020-06-17 02:49:28 +0200550/* Convenience functions for rate counters using g_ctr_msc. */
551
552private function f_ctrs_msc_init(integer mscs_count := NUM_MSC, CounterNameVals counternames := counternames_msc_mscpool) runs on test_CT {
553 g_ctr_msc := f_counter_name_vals_get_n(IPA_CTRL, "msc", mscs_count, counternames);
554 log("initial msc rate counters: ", g_ctr_msc);
555}
556
557private function f_ctrs_msc_add(integer msc_nr, charstring countername, integer val := 1) runs on test_CT {
Neels Hofmeyr9656e922020-06-30 01:27:01 +0200558 f_counter_name_vals_list_add(g_ctr_msc, msc_nr, countername, val);
Neels Hofmeyr22c3f792020-06-17 02:49:28 +0200559}
560
561/* f_ctrs_msc_init();
562 * f_do_thing(on_msc := 0);
563 * f_do_thing(on_msc := 0);
564 * f_do_other(on_msc := 1);
565 * f_ctrs_msc_add(0, "thing", 2);
566 * f_ctrs_msc_add(1, "other");
567 * f_ctrs_msc_verify();
568 */
569private function f_ctrs_msc_verify() runs on test_CT {
570 log("verifying msc rate counters: ", g_ctr_msc);
571 f_counter_name_vals_expect_n(IPA_CTRL, "msc", g_ctr_msc);
572}
573
574/* convenience: f_ctrs_msc_add() and f_ctrs_msc_verify() in one call.
575 * f_ctrs_msc_init();
576 * f_do_thing(on_msc := 0);
577 * f_do_thing(on_msc := 0);
578 * f_do_thing(on_msc := 0);
579 * f_ctrs_msc_expect(0, "thing", 3);
580 */
581private function f_ctrs_msc_expect(integer msc_nr, charstring countername, integer val := 1) runs on test_CT {
582 f_ctrs_msc_add(msc_nr, countername, val);
583 f_ctrs_msc_verify();
584}
585
586
Philipp Maier282ca4b2018-02-27 17:17:00 +0100587private function f_shutdown_helper() runs on test_CT {
Daniel Willmann637ef6c2018-07-25 10:49:09 +0200588 all component.stop;
Philipp Maier282ca4b2018-02-27 17:17:00 +0100589 setverdict(pass);
Daniel Willmannafce8662018-07-06 23:11:32 +0200590 mtc.stop;
Philipp Maier282ca4b2018-02-27 17:17:00 +0100591}
592
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200593private function f_legacy_bssap_reset(integer bssap_idx := 0) runs on test_CT {
Harald Weltea4ca4462018-02-09 00:17:14 +0100594 var BSSAP_N_UNITDATA_ind ud_ind;
595 timer T := 5.0;
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200596 BSSAP.send(ts_BSSAP_UNITDATA_req(g_bssap[bssap_idx].sccp_addr_peer, g_bssap[bssap_idx].sccp_addr_own,
597 ts_BSSMAP_Reset(0, g_osmux_enabled)));
Harald Weltea4ca4462018-02-09 00:17:14 +0100598 T.start;
599 alt {
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200600 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(g_bssap[bssap_idx].sccp_addr_own, g_bssap[bssap_idx].sccp_addr_peer,
601 tr_BSSMAP_ResetAck(g_osmux_enabled))) {
Harald Weltea4ca4462018-02-09 00:17:14 +0100602 log("Received RESET-ACK in response to RESET, we're ready to go!");
603 }
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200604 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset(g_osmux_enabled))) -> value ud_ind {
Harald Weltea4ca4462018-02-09 00:17:14 +0100605 log("Respoding to inbound RESET with RESET-ACK");
606 BSSAP.send(ts_BSSAP_UNITDATA_req(ud_ind.callingAddress, ud_ind.calledAddress,
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200607 ts_BSSMAP_ResetAck(g_osmux_enabled)));
Harald Weltea4ca4462018-02-09 00:17:14 +0100608 repeat;
609 }
610 [] BSSAP.receive { repeat; }
611 [] T.timeout { setverdict(fail, "Waiting for RESET-ACK after sending RESET"); }
612 }
Harald Welte28d943e2017-11-25 15:00:50 +0100613}
614
Harald Welteae026692017-12-09 01:03:01 +0100615type record IPA_Client {
Harald Welte21b46bd2017-12-17 19:46:32 +0100616 /* IPA Emulation component reference */
Harald Welteae026692017-12-09 01:03:01 +0100617 IPA_Emulation_CT vc_IPA,
Harald Welte21b46bd2017-12-17 19:46:32 +0100618 /* Unit-ID and other CCM parameters to use for IPA client emulation */
Harald Welteae026692017-12-09 01:03:01 +0100619 IPA_CCM_Parameters ccm_pars,
Harald Welte21b46bd2017-12-17 19:46:32 +0100620 /* String identifier for this IPA Client */
Harald Welte624f9632017-12-16 19:26:04 +0100621 charstring id,
Harald Welte21b46bd2017-12-17 19:46:32 +0100622 /* Associated RSL Emulation Component (if any). Only used in "Handler mode" */
Harald Welte624f9632017-12-16 19:26:04 +0100623 RSL_Emulation_CT vc_RSL optional
Harald Welte28d943e2017-11-25 15:00:50 +0100624}
625
Harald Welte21b46bd2017-12-17 19:46:32 +0100626/*! Start the IPA/RSL related bits for one IPA_Client.
627 * \param clnt IPA_Client for which to establish
628 * \param bsc_host IP address / hostname of the BSC
629 * \param bsc_port TCP port number of the BSC
630 * \param i number identifying this BTS
631 * \param handler_mode Start an RSL_Emulation_CT component (true) or not (false) */
Harald Welte624f9632017-12-16 19:26:04 +0100632function f_ipa_rsl_start(inout IPA_Client clnt, charstring bsc_host, PortNumber bsc_port, integer i,
633 boolean handler_mode := false)
Harald Welte28d943e2017-11-25 15:00:50 +0100634runs on test_CT {
Harald Welteae026692017-12-09 01:03:01 +0100635 timer T := 10.0;
636
Harald Welte96c94412017-12-09 03:12:45 +0100637 clnt.id := "IPA" & int2str(i) & "-RSL";
Harald Welteae026692017-12-09 01:03:01 +0100638 clnt.vc_IPA := IPA_Emulation_CT.create(clnt.id & "-IPA");
639 clnt.ccm_pars := c_IPA_default_ccm_pars;
640 clnt.ccm_pars.name := "Osmocom TTCN-3 BTS Simulator";
641 clnt.ccm_pars.unit_id := int2str(1234+i) & "/0/0";
Harald Welte624f9632017-12-16 19:26:04 +0100642 if (handler_mode) {
643 clnt.vc_RSL := RSL_Emulation_CT.create(clnt.id & "-RSL");
Harald Welte89ab1912018-02-23 18:56:29 +0100644 connect(clnt.vc_RSL:CCHAN_PT, self:RSL_CCHAN[i]);
Harald Welte624f9632017-12-16 19:26:04 +0100645 }
Harald Welteae026692017-12-09 01:03:01 +0100646
647 map(clnt.vc_IPA:IPA_PORT, system:IPA_CODEC_PT);
Harald Welte624f9632017-12-16 19:26:04 +0100648 if (handler_mode) {
649 connect(clnt.vc_IPA:IPA_RSL_PORT, clnt.vc_RSL:IPA_PT);
650 } else {
651 connect(clnt.vc_IPA:IPA_RSL_PORT, self:IPA_RSL[i]);
652 }
Harald Welteae026692017-12-09 01:03:01 +0100653
Harald Welte5d1a2202017-12-13 19:51:29 +0100654 clnt.vc_IPA.start(IPA_Emulation.main_client(bsc_host, bsc_port, "", 10000+i, clnt.ccm_pars));
Harald Welte624f9632017-12-16 19:26:04 +0100655 if (handler_mode) {
656 clnt.vc_RSL.start(RSL_Emulation.main());
657 return;
658 }
Harald Welteae026692017-12-09 01:03:01 +0100659
660 /* wait for IPA RSL link to connect and send ID ACK */
661 T.start;
662 alt {
Vadim Yanitskiya2afacc2020-05-18 21:16:19 +0700663 [] IPA_RSL[i].receive(tr_ASP_IPA_EV(ASP_IPA_EVENT_ID_ACK)) {
Harald Welteae026692017-12-09 01:03:01 +0100664 T.stop;
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +0700665 IPA_RSL[i].send(ts_ASP_RSL_UD(ts_RSL_PAGING_LOAD_IND(23)));
Harald Welteae026692017-12-09 01:03:01 +0100666 }
Harald Welte60e823a2017-12-10 14:10:59 +0100667 [] IPA_RSL[i].receive(ASP_IPA_Event:?) { repeat }
Harald Welteae026692017-12-09 01:03:01 +0100668 [] IPA_RSL[i].receive { repeat }
669 [] T.timeout {
Harald Welte96c94412017-12-09 03:12:45 +0100670 setverdict(fail, "Timeout RSL waiting for ASP_IPA_EVENT_ID_ACK");
Daniel Willmannafce8662018-07-06 23:11:32 +0200671 mtc.stop;
Harald Welteae026692017-12-09 01:03:01 +0100672 }
673 }
674}
675
Harald Welte12055472018-03-17 20:10:08 +0100676function f_ipa_rsl_stop(inout IPA_Client clnt) runs on test_CT {
677 if (not isbound(clnt) or not isbound(clnt.vc_IPA)) {
678 return;
679 }
680 clnt.vc_IPA.stop;
681 if (isbound(clnt.vc_RSL)) {
682 clnt.vc_RSL.stop;
683 }
684}
685
Harald Welte21b46bd2017-12-17 19:46:32 +0100686/* Wait for the OML connection to be brought up by the external osmo-bts-omldummy */
Harald Weltea5d2ab22017-12-09 14:21:42 +0100687function f_wait_oml(integer bts_nr, charstring status, float secs_max) runs on test_CT {
688 timer T := secs_max;
689 T.start;
690 while (true) {
691 if (f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-connection-state") == status) {
692 T.stop;
Harald Weltebd868bd2017-12-10 18:28:40 +0100693 /* the 'degraded' state exists from OML connection time, and we have to wait
694 * until all MO's are initialized */
695 T.start(1.0);
696 T.timeout;
Harald Weltea5d2ab22017-12-09 14:21:42 +0100697 return;
698 }
Harald Weltef0d6ac62017-12-17 17:02:21 +0100699 f_sleep(0.1);
Harald Weltea5d2ab22017-12-09 14:21:42 +0100700 if (not T.running) {
Max99253902018-11-16 17:57:39 +0100701 setverdict(fail, "Timeout waiting for BTS" & int2str(bts_nr) & " oml-connection-state ", status);
Daniel Willmannafce8662018-07-06 23:11:32 +0200702 mtc.stop;
Harald Weltea5d2ab22017-12-09 14:21:42 +0100703 }
704 }
705}
706
Harald Welte21b46bd2017-12-17 19:46:32 +0100707/* global altstep for global guard timer; also takes care of responding RESET witH RESET-ACK */
Harald Welteae026692017-12-09 01:03:01 +0100708altstep as_Tguard() runs on test_CT {
Harald Welte60e823a2017-12-10 14:10:59 +0100709 var BSSAP_N_UNITDATA_ind ud_ind;
Neels Hofmeyrcc3f76a2018-03-12 01:43:25 +0100710 [] T_guard.timeout {
711 setverdict(fail, "Timeout of T_guard");
Daniel Willmannafce8662018-07-06 23:11:32 +0200712 mtc.stop;
Neels Hofmeyrcc3f76a2018-03-12 01:43:25 +0100713 }
Harald Welte60e823a2017-12-10 14:10:59 +0100714 /* always respond with RESET ACK to RESET */
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200715 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset(g_osmux_enabled))) -> value ud_ind {
Harald Welte60e823a2017-12-10 14:10:59 +0100716 BSSAP.send(ts_BSSAP_UNITDATA_req(ud_ind.callingAddress, ud_ind.calledAddress,
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200717 ts_BSSMAP_ResetAck(g_osmux_enabled)));
Harald Welte69c1c262017-12-13 21:02:08 +0100718 repeat;
Harald Welte60e823a2017-12-10 14:10:59 +0100719 }
Harald Welte28d943e2017-11-25 15:00:50 +0100720}
721
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +0100722altstep no_bssmap_reset() runs on test_CT {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200723 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset(g_osmux_enabled))) {
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +0100724 setverdict(fail, "unexpected BSSMAP Reset");
Daniel Willmannafce8662018-07-06 23:11:32 +0200725 mtc.stop;
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +0100726 }
727}
728
Daniel Willmann191e0d92018-01-17 12:44:35 +0100729function f_init_mgcp(charstring id) runs on test_CT {
730 id := id & "-MGCP";
731
732 var MGCPOps ops := {
733 create_cb := refers(MGCP_Emulation.ExpectedCreateCallback),
734 unitdata_cb := refers(MGCP_Emulation.DummyUnitdataCallback)
735 };
736 var MGCP_conn_parameters mgcp_pars := {
737 callagent_ip := mp_bsc_ip,
Harald Welte9e4273e2018-01-29 22:01:22 +0100738 callagent_udp_port := -1,
Daniel Willmann191e0d92018-01-17 12:44:35 +0100739 mgw_ip := mp_test_ip,
Pau Espin Pedrol1a026a52019-06-18 17:21:52 +0200740 mgw_udp_port := 2427,
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +0200741 /* Enable it for SCCPlite, since we have 2 MGCP sockets towards MGW (UDP one +
742 the on with MGCP over IPA forwarded from MSC one) */
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200743 multi_conn_mode := (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_SCCPlite_SERVER)
Daniel Willmann191e0d92018-01-17 12:44:35 +0100744 };
745
746 vc_MGCP := MGCP_Emulation_CT.create(id);
747 vc_MGCP.start(MGCP_Emulation.main(ops, mgcp_pars, id));
748}
749
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200750/* Enable or disable (current default) Osmux. When enabling, BSSMAP Reset
751 * contains extra IE (OsmuxSupport) and osmo-bsc will handle AssignReq with
752 * OsmuxCID IE.
753 */
754private function f_vty_allow_osmux(boolean allow) runs on test_CT {
755 f_vty_enter_cfg_msc(BSCVTY, 0);
756 if (allow) {
757 f_vty_transceive(BSCVTY, "osmux on");
758 } else {
759 f_vty_transceive(BSCVTY, "osmux off");
760 }
761 f_vty_transceive(BSCVTY, "exit");
762 f_vty_transceive(BSCVTY, "exit");
763 g_osmux_enabled := allow;
764}
765
Max2253c0b2018-11-06 19:28:05 +0100766function f_init_vty(charstring id := "foo") runs on test_CT {
Harald Welte94e0c342018-04-07 11:33:23 +0200767 if (BSCVTY.checkstate("Mapped")) {
768 /* skip initialization if already executed once */
769 return;
770 }
Harald Weltebc03c762018-02-12 18:09:38 +0100771 map(self:BSCVTY, system:BSCVTY);
772 f_vty_set_prompts(BSCVTY);
773 f_vty_transceive(BSCVTY, "enable");
Pau Espin Pedrolc675b612020-01-09 19:55:40 +0100774 f_cs7_inst_0_cfg(BSCVTY, {"sccp-timer ias " & int2str(g_bsc_sccp_timer_ias),
775 "sccp-timer iar " & int2str(g_bsc_sccp_timer_iar)});
Harald Weltebc03c762018-02-12 18:09:38 +0100776}
777
Neels Hofmeyr4f118412020-06-04 15:25:10 +0200778private function f_logp(charstring log_msg) runs on MSC_ConnHdlr
779{
780 // log on TTCN3 log output
781 log(log_msg);
782 // log in stderr log
783 f_vty_transceive(BSCVTY, "logp lglobal notice " & log_msg);
784}
785
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200786private function f_sysinfo_seen(integer rsl_idx, RSL_Message rsl) runs on test_CT
787{
788 if (rsl_idx >= lengthof(g_system_information)) {
789 g_system_information[rsl_idx] := SystemInformationConfig_omit
790 }
791 f_sysinfo_dec_raw(g_system_information[rsl_idx], rsl);
792}
793
794altstep as_catch_RSL_sysinfo(integer rsl_idx) runs on test_CT {
795 var ASP_RSL_Unitdata rx_rsl_ud;
796
797 /* For handler_mode := false, receiving the RSL bootstrap messages directly on IPA_RSL */
798 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_NO_BCCH_INFO)) -> value rx_rsl_ud {
799 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
800 repeat;
801 }
802 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_BCCH_INFO)) -> value rx_rsl_ud {
803 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
804 repeat;
805 }
806 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_NO_SACCH_FILL)) -> value rx_rsl_ud {
807 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
808 repeat;
809 }
810 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_SACCH_FILL)) -> value rx_rsl_ud {
811 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
812 repeat;
813 }
814
815 /* For handler_mode := true, receiving the RSL bootstrap messages via RSL_Emulation */
816 [] RSL_CCHAN[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_NO_BCCH_INFO)) -> value rx_rsl_ud {
817 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
818 repeat;
819 }
820 [] RSL_CCHAN[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_BCCH_INFO)) -> value rx_rsl_ud {
821 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
822 repeat;
823 }
824 [] RSL_CCHAN[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_NO_SACCH_FILL)) -> value rx_rsl_ud {
825 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
826 repeat;
827 }
828 [] RSL_CCHAN[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_SACCH_FILL)) -> value rx_rsl_ud {
829 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
830 repeat;
831 }
832}
833
Harald Welte21b46bd2017-12-17 19:46:32 +0100834/* global initialization function
835 * \param nr_bts Number of BTSs we should start/bring up
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200836 * \param handler_mode Start an RSL_Emulation_CT component (true) or not (false).
837 * \param nr_msc Number of virtual MSCs to bring up to connect to osmo-bsc.
838 */
839function f_init(integer nr_bts := NUM_BTS, boolean handler_mode := false, boolean allow_osmux := false,
Neels Hofmeyr4fbad7f2020-06-16 00:30:47 +0200840 integer nr_msc := 1, float guard_timeout := 30.0) runs on test_CT {
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200841 var integer bssap_idx;
Harald Welte28d943e2017-11-25 15:00:50 +0100842
Harald Welteae026692017-12-09 01:03:01 +0100843 if (g_initialized) {
844 return;
Harald Welte28d943e2017-11-25 15:00:50 +0100845 }
Harald Welteae026692017-12-09 01:03:01 +0100846 g_initialized := true;
847
Neels Hofmeyr4fbad7f2020-06-16 00:30:47 +0200848 T_guard.start(guard_timeout);
Daniel Willmanne68f9272018-11-27 15:15:28 +0100849 activate(as_Tguard());
850
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200851 f_init_vty("VirtMSC");
Pau Espin Pedrol58cf6822019-05-28 18:11:33 +0200852 if (mp_enable_osmux_test) {
853 f_vty_allow_osmux(allow_osmux);
854 }
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200855
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200856 for (bssap_idx := 0; bssap_idx < nr_msc; bssap_idx := bssap_idx+1) {
857 /* Call a function of our 'parent component' RAN_Adapter_CT to start the
858 * MSC-side BSSAP emulation */
859 if (handler_mode) {
860 var RanOps ranops := MSC_RanOps;
861 ranops.use_osmux := g_osmux_enabled;
862 f_ran_adapter_init(g_bssap[bssap_idx], mp_bssap_cfg[bssap_idx], "VirtMSC", ranops);
863 connect(self:SCCPLITE_IPA_CTRL, g_bssap[bssap_idx].vc_RAN:CTRL_CLIENT);
864 f_ran_adapter_start(g_bssap[bssap_idx]);
865 } else {
866 f_ran_adapter_init(g_bssap[bssap_idx], mp_bssap_cfg[bssap_idx], "VirtMSC", omit);
867 connect(self:BSSAP, g_bssap[bssap_idx].vc_SCCP:SCCP_SP_PORT);
868 f_ran_adapter_start(g_bssap[bssap_idx]);
869 f_legacy_bssap_reset();
870 }
Harald Welte67089ee2018-01-17 22:19:03 +0100871 }
Harald Welted5833a82018-05-27 16:52:56 +0200872
Harald Welteffe55fc2018-01-17 22:39:54 +0100873 f_ipa_ctrl_start(mp_bsc_ip, mp_bsc_ctrl_port);
Harald Welte28d943e2017-11-25 15:00:50 +0100874
Daniel Willmann191e0d92018-01-17 12:44:35 +0100875 f_init_mgcp("VirtMSC");
876
Neels Hofmeyr0b7365b2020-07-04 00:52:34 +0200877 for (var integer i := 0; i < nr_bts; i := i+1) {
878 f_init_bts(i, handler_mode);
Harald Welte696ddb62017-12-08 14:01:43 +0100879 }
Neels Hofmeyr0b7365b2020-07-04 00:52:34 +0200880}
Harald Welte696ddb62017-12-08 14:01:43 +0100881
Neels Hofmeyr0b7365b2020-07-04 00:52:34 +0200882function f_init_bts(integer bts_idx := 0, boolean handler_mode := false)
883runs on test_CT {
884 /* wait until osmo-bts-omldummy has respawned */
885 f_wait_oml(bts_idx, "degraded", 5.0);
886
887 /* start RSL connection */
888 f_ipa_rsl_start(bts[bts_idx].rsl, mp_bsc_ip, mp_bsc_rsl_port, bts_idx, handler_mode);
889 /* wait until BSC tells us "connected" */
890 f_wait_oml(bts_idx, "connected", 5.0);
Harald Welte28d943e2017-11-25 15:00:50 +0100891}
892
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200893function f_init_bts_and_check_sysinfo(integer bts_idx := 0, boolean handler_mode := false,
894 template SystemInformationConfig expect_si)
895runs on test_CT {
896 var default sysinfo := activate(as_catch_RSL_sysinfo(bts_idx));
897
898 f_init_bts(bts_idx, handler_mode);
899
900 /* Give some time to (hopefully/most likely) collect all system informations from RSL startup.
901 * We could stop as soon as all expected SI are received, but then we might miss SI that we don't expect and
902 * that might be sent afterwards. So rather give a generous timeout and be quite sure to catch all SI.
903 */
904 f_sleep(5.0);
905 log("RSL ", bts_idx, " SYSTEM INFORMATION: ", g_system_information[bts_idx]);
906
907 deactivate(sysinfo);
908
909 if (match(g_system_information[bts_idx], expect_si)) {
910 setverdict(pass);
911 } else {
912 log("RSL ", bts_idx, ": EXPECTED SI: ", expect_si);
913 log("RSL ", bts_idx, ": GOT SI: ", g_system_information[bts_idx]);
914 setverdict(fail, "received SI does not match expectations");
915 return;
916 }
917}
918
Maxd4e56962018-10-31 19:08:25 +0100919/* expect to receive a RSL message matching a specified template on a given BTS / stream */
Harald Welteae026692017-12-09 01:03:01 +0100920function f_exp_ipa_rx(integer bts_nr, template RSL_Message t_rx, float t_secs := 2.0, IpaStreamId sid := IPAC_PROTO_RSL_TRX0)
921runs on test_CT return RSL_Message {
922 var ASP_RSL_Unitdata rx_rsl_ud;
923 timer T := t_secs;
924
925 T.start;
926 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +0700927 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(t_rx, sid)) -> value rx_rsl_ud {
Harald Welteae026692017-12-09 01:03:01 +0100928 T.stop;
929 }
930 [] IPA_RSL[bts_nr].receive { repeat; }
Harald Welteb2917702017-12-10 15:48:52 +0100931 [] T.timeout {
932 setverdict(fail, "Timeout expecting ", t_rx);
Daniel Willmannafce8662018-07-06 23:11:32 +0200933 mtc.stop;
Harald Welteb2917702017-12-10 15:48:52 +0100934 }
Harald Welteae026692017-12-09 01:03:01 +0100935 }
936 return rx_rsl_ud.rsl;
937}
938
Harald Welte21b46bd2017-12-17 19:46:32 +0100939/* helper function to transmit RSL on a given BTS/stream */
Harald Welteae026692017-12-09 01:03:01 +0100940function f_ipa_tx(integer bts_nr, template RSL_Message t_tx, IpaStreamId sid := IPAC_PROTO_RSL_TRX0)
941runs on test_CT {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +0700942 IPA_RSL[bts_nr].send(ts_ASP_RSL_UD(t_tx, sid));
Harald Welteae026692017-12-09 01:03:01 +0100943}
944
945
Harald Welte4003d112017-12-09 22:35:39 +0100946/* verify we get a CHAN_ACT after CHAN RQD */
Harald Welteae026692017-12-09 01:03:01 +0100947testcase TC_chan_act_noreply() runs on test_CT {
948 var BSSAP_N_UNITDATA_ind ud_ind;
Harald Welte930d0a72018-03-22 22:08:40 +0100949 var RSL_Message rsl_unused;
Harald Welte28d943e2017-11-25 15:00:50 +0100950
Harald Welte89d42e82017-12-17 16:42:41 +0100951 f_init(1);
Harald Welte28d943e2017-11-25 15:00:50 +0100952
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +0700953 IPA_RSL[0].send(ts_ASP_RSL_UD(ts_RSL_CHAN_RQD('23'O, 23)));
Harald Welte930d0a72018-03-22 22:08:40 +0100954 rsl_unused := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
Harald Welteae026692017-12-09 01:03:01 +0100955 setverdict(pass);
Harald Welte28d943e2017-11-25 15:00:50 +0100956}
957
Harald Welte4003d112017-12-09 22:35:39 +0100958/* verify if the "chreq:total" counter increments as expected */
959testcase TC_chan_act_counter() runs on test_CT {
960 var BSSAP_N_UNITDATA_ind ud_ind;
961 var integer chreq_total;
Harald Welte930d0a72018-03-22 22:08:40 +0100962 var RSL_Message rsl_unused;
Harald Welte4003d112017-12-09 22:35:39 +0100963
Harald Welte89d42e82017-12-17 16:42:41 +0100964 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +0100965
966 chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total");
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +0700967 IPA_RSL[0].send(ts_ASP_RSL_UD(ts_RSL_CHAN_RQD('23'O, 23)));
Harald Welte930d0a72018-03-22 22:08:40 +0100968 rsl_unused := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
Harald Welte4003d112017-12-09 22:35:39 +0100969 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total", chreq_total+1);
970
971 setverdict(pass);
972}
973
Harald Welteae026692017-12-09 01:03:01 +0100974/* CHAN RQD -> CHAN ACT -> CHAN ACT ACK -> RF CHAN REL */
975testcase TC_chan_act_ack_noest() runs on test_CT {
976 var RSL_Message rx_rsl;
977
Harald Welte89d42e82017-12-17 16:42:41 +0100978 f_init(1);
Harald Welteae026692017-12-09 01:03:01 +0100979
980 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +0100981 var RslChannelNr chan_nr := f_chreq_act_ack();
Harald Welteae026692017-12-09 01:03:01 +0100982
983 /* expect BSC to disable the channel again if there's no RLL EST IND */
984 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX);
985
986 setverdict(pass);
987}
988
989/* Test behavior if MSC never answers to CR */
990testcase TC_chan_act_ack_est_ind_noreply() runs on test_CT {
Harald Weltef77aef62018-01-28 15:35:42 +0100991 var RslLinkId main_dcch := valueof(ts_RslLinkID_DCCH(0));
992 var IpaStreamId sid := IPAC_PROTO_RSL_TRX0;
Harald Welteae026692017-12-09 01:03:01 +0100993 var RSL_Message rx_rsl;
Harald Weltef77aef62018-01-28 15:35:42 +0100994 var ASP_RSL_Unitdata rx_rsl_ud;
Harald Welteae026692017-12-09 01:03:01 +0100995
Harald Welte89d42e82017-12-17 16:42:41 +0100996 f_init(1);
Harald Welteae026692017-12-09 01:03:01 +0100997
998 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +0100999 var RslChannelNr chan_nr := f_chreq_act_ack();
Harald Welteae026692017-12-09 01:03:01 +01001000
1001 var octetstring l3 := '00010203040506'O
1002 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
1003
1004 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3)));
1005
1006 /* expect BSC to disable the channel again if there's no response from MSC */
Harald Weltef77aef62018-01-28 15:35:42 +01001007 /* MS waits 20s (T3210) at LU; 10s (T3230) at CM SERV REQ and 5s (T3220) AT detach */
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001008 f_expect_chan_rel(0, chan_nr, expect_rll_rel_req := false);
Harald Welteae026692017-12-09 01:03:01 +01001009 setverdict(pass);
1010}
1011
1012/* Test behavior if MSC answers with CREF to CR */
1013testcase TC_chan_act_ack_est_ind_refused() runs on test_CT {
1014 var BSSAP_N_CONNECT_ind rx_c_ind;
1015 var RSL_Message rx_rsl;
1016
Harald Welte89d42e82017-12-17 16:42:41 +01001017 f_init(1);
Harald Welteae026692017-12-09 01:03:01 +01001018
1019 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +01001020 var RslChannelNr chan_nr := f_chreq_act_ack();
Harald Welteae026692017-12-09 01:03:01 +01001021
1022 var octetstring l3 := '00010203040506'O
1023 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
1024
1025 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
1026 BSSAP.send(ts_BSSAP_DISC_req(rx_c_ind.connectionId, 0));
1027
1028 /* expect BSC to disable the channel */
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001029 f_expect_chan_rel(0, chan_nr, expect_rll_rel_req := false);
Harald Welteae026692017-12-09 01:03:01 +01001030 setverdict(pass);
1031}
1032
Harald Welte618ef642017-12-14 14:58:20 +01001033/* CHAN RQD -> CHAN ACT -> CHAN ACT NACK -> RF CHAN REL */
1034testcase TC_chan_act_nack() runs on test_CT {
1035 var RSL_Message rx_rsl;
1036 var integer chact_nack;
1037
Harald Welte89d42e82017-12-17 16:42:41 +01001038 f_init(1);
Harald Welte618ef642017-12-14 14:58:20 +01001039
1040 chact_nack := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chan_act:nack");
1041
1042 f_ipa_tx(0, ts_RSL_CHAN_RQD('33'O, 33));
1043 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
1044 var RslChannelNr chan_nr := rx_rsl.ies[0].body.chan_nr;
1045
1046 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, RSL_ERR_EQUIPMENT_FAIL));
1047
1048 /* wait for some time to hope the NACK arrives before the CTRL GET below */
1049 f_sleep(0.5);
1050
1051 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chan_act:nack", chact_nack+1);
1052
1053 setverdict(pass);
1054}
1055
Harald Welte799c97b2017-12-14 17:50:30 +01001056/* Test for channel exhaustion due to RACH overload */
1057testcase TC_chan_exhaustion() runs on test_CT {
1058 var ASP_RSL_Unitdata rsl_ud;
1059 var integer i;
1060 var integer chreq_total, chreq_nochan;
1061
Harald Welte89d42e82017-12-17 16:42:41 +01001062 f_init(1);
Harald Welte799c97b2017-12-14 17:50:30 +01001063
1064 chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total");
1065 chreq_nochan := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel");
1066
Pau Espin Pedrolfe200d72018-12-10 12:41:04 +01001067 /* GSM 04.08 Table 9.9a:
1068 * RA = '33'O -> Establishment cause = 0011xxxx (MS dual rate capable and asks for "TCH/H or TCH/F").
1069 * With current setup, expect 4xSDCCH + 4xTCH/F + 1xTCH/H to succeed */
Philipp Maiercb6cc482018-03-26 13:08:00 +02001070 for (i := 0; i < NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS; i := i+1) {
Pau Espin Pedrolfe200d72018-12-10 12:41:04 +01001071 var RslChannelNr chan_nr := f_chreq_act_ack('33'O, i);
Harald Welte799c97b2017-12-14 17:50:30 +01001072 }
1073
1074 IPA_RSL[0].clear;
1075
Harald Weltedd8cbf32018-01-28 12:07:52 +01001076 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total",
Philipp Maiercb6cc482018-03-26 13:08:00 +02001077 chreq_total + NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS);
Harald Welte799c97b2017-12-14 17:50:30 +01001078
1079 /* now expect additional channel activations to fail */
1080 f_ipa_tx(0, ts_RSL_CHAN_RQD('42'O, 42));
1081
1082 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001083 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV))) {
Harald Welte799c97b2017-12-14 17:50:30 +01001084 setverdict(fail, "Received CHAN ACT ACK without resources?!?");
1085 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001086 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_IMM_ASSIGN(?))) -> value rsl_ud {
Harald Welte799c97b2017-12-14 17:50:30 +01001087 var GsmRrMessage rr;
1088 /* match on IMM ASS REJ */
1089 rr := dec_GsmRrMessage(rsl_ud.rsl.ies[1].body.full_imm_ass_info.payload);
1090 if (rr.header.message_type == IMMEDIATE_ASSIGNMENT_REJECT) {
1091 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total",
Philipp Maiercb6cc482018-03-26 13:08:00 +02001092 chreq_total + NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS+1);
Harald Welte799c97b2017-12-14 17:50:30 +01001093 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel",
1094 chreq_nochan+1);
1095 setverdict(pass);
1096 } else {
1097 repeat;
1098 }
1099 }
1100 [] IPA_RSL[0].receive { repeat; }
1101 }
1102}
1103
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07001104/* Test channel deactivation due to silence from MS */
1105testcase TC_chan_deact_silence() runs on test_CT {
1106 var RslChannelNr chan_nr;
1107
1108 f_init(1);
1109
1110 /* Request for a dedicated channel */
1111 chan_nr := f_chreq_act_ack('23'O);
1112
1113 /* Wait some time until the channel is released */
1114 f_sleep(2.0);
1115
1116 /* Expect CHANnel RELease */
1117 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001118 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL))) {
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07001119 log("Received CHANnel RELease");
1120 setverdict(pass);
1121 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001122 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_IMM_ASSIGN(?))) {
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07001123 /* See OS#3709, OsmoBSC should not send Immediate
1124 * Assignment Reject since a dedicated channel was
1125 * already allocated, and Immediate Assignment was
1126 * already sent. */
1127 setverdict(fail, "Unexpected Immediate Assignment!");
1128 }
1129 [] IPA_RSL[0].receive {
1130 setverdict(fail, "Unexpected RSL message!");
1131 }
1132 }
1133}
1134
Harald Weltecfe2c962017-12-15 12:09:32 +01001135/***********************************************************************
1136 * Assignment Testing
1137 ***********************************************************************/
1138
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02001139/* Verify that the BSC refuses any BSSAP connection from the MSC (They are all BSC->MSC direction,
1140 * except for the inter-BSC handover, MT side) */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001141testcase TC_outbound_connect(integer bssap_idx := 0) runs on test_CT {
Harald Welte89d42e82017-12-17 16:42:41 +01001142 f_init(1);
Harald Weltecfe2c962017-12-15 12:09:32 +01001143
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001144 BSSAP.send(ts_BSSAP_CONNECT_req(g_bssap[bssap_idx].sccp_addr_peer, g_bssap[bssap_idx].sccp_addr_own,
1145 2342, ts_BSSMAP_AssignmentReq));
Harald Weltecfe2c962017-12-15 12:09:32 +01001146 BSSAP.receive(tr_BSSAP_DISC_ind(2342, ?, ?));
1147 setverdict(pass);
1148}
1149
Harald Welte16a4adf2017-12-14 18:54:01 +01001150/* Test behavior if MSC answers with CREF to CR */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001151testcase TC_assignment_cic_only(integer bssap_idx := 0) runs on test_CT {
Harald Welte16a4adf2017-12-14 18:54:01 +01001152 var BSSAP_N_CONNECT_ind rx_c_ind;
1153 var RSL_Message rx_rsl;
1154 var DchanTuple dt;
1155
Harald Welte89d42e82017-12-17 16:42:41 +01001156 f_init(1);
Harald Welte16a4adf2017-12-14 18:54:01 +01001157
1158 dt := f_est_dchan('23'O, 23, '00000000'O);
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001159 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welte17b27da2018-05-25 20:33:53 +02001160 /* send assignment without AoIP IEs */
1161 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_AssignmentReq(ts_BSSMAP_IE_CIC(0, 1))));
1162 } else {
1163 /* Send assignmetn without CIC in IPA case */
1164 var BSSMAP_IE_AoIP_TransportLayerAddress tla :=
1165 valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342));
1166 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_AssignmentReq(omit, tla)));
1167 }
Harald Welte16a4adf2017-12-14 18:54:01 +01001168 alt {
1169 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentComplete)) {
1170 setverdict(fail, "AoIP BSC cannot accept ASSIGNMENT without AoIP Transport IE");
1171 }
Harald Welte235ebf12017-12-15 14:18:16 +01001172 /* TODO: Actually expect GSM0808_CAUSE_REQ_A_IF_TYPE_NOT_SUPP */
Harald Welte16a4adf2017-12-14 18:54:01 +01001173 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentFail)) {
1174 setverdict(pass);
1175 }
1176 [] BSSAP.receive { repeat; }
1177 }
1178}
1179
Harald Welteed848512018-05-24 22:27:58 +02001180/* generate an assignment request for either AoIP or SCCPlite */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001181function f_gen_ass_req(boolean osmux_enabled := false, integer bssap_idx := 0) return PDU_BSSAP {
Harald Welteed848512018-05-24 22:27:58 +02001182 var PDU_BSSAP ass_cmd;
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001183 var BSSMAP_IE_Osmo_OsmuxCID osmux_cid := valueof(ts_OsmuxCID(0));
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001184 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welteed848512018-05-24 22:27:58 +02001185 var BSSMAP_IE_AoIP_TransportLayerAddress tla :=
1186 valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342));
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001187 if (osmux_enabled) {
1188 ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla, osmux_cid));
1189 } else {
1190 ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla));
1191 }
Harald Welteed848512018-05-24 22:27:58 +02001192 } else {
1193 var BSSMAP_IE_CircuitIdentityCode cic := valueof(ts_BSSMAP_IE_CIC(0,1));
Pau Espin Pedrol096d73d2019-06-06 12:49:17 +02001194 ass_cmd := valueof(ts_BSSMAP_AssignmentReq(cic, omit));
Harald Welteed848512018-05-24 22:27:58 +02001195 }
1196 return ass_cmd;
1197}
1198
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001199function f_gen_handover_req(integer bssap_idx := 0) return PDU_BSSAP {
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01001200 var PDU_BSSAP ho_req;
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001201 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01001202 var BSSMAP_IE_AoIP_TransportLayerAddress tla :=
1203 valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342));
1204 ho_req := valueof(ts_BSSMAP_HandoverRequest(omit, tla));
1205 } else {
1206 var BSSMAP_IE_CircuitIdentityCode cic := valueof(ts_BSSMAP_IE_CIC(0,1));
1207 ho_req := valueof(ts_BSSMAP_HandoverRequest(cic, omit));
1208 }
1209 return ho_req;
1210}
1211
Harald Welteed848512018-05-24 22:27:58 +02001212/* generate an assignment complete template for either AoIP or SCCPlite */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001213function f_gen_exp_compl(boolean expect_osmux := false, integer bssap_idx := 0) return template PDU_BSSAP {
Harald Welteed848512018-05-24 22:27:58 +02001214 var template PDU_BSSAP exp_compl;
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001215 var BSSMAP_IE_Osmo_OsmuxCID osmux_cid := valueof(ts_OsmuxCID(0));
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001216 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001217 if (expect_osmux) {
1218 exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?, osmux_cid);
1219 } else {
1220 exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?, omit);
1221 }
Harald Welteed848512018-05-24 22:27:58 +02001222 } else {
1223 /* CIC is optional "*" as the MSC allocated it */
Pau Espin Pedrol096d73d2019-06-06 12:49:17 +02001224 exp_compl := tr_BSSMAP_AssignmentComplete(*, omit);
Harald Welteed848512018-05-24 22:27:58 +02001225 }
1226 return exp_compl;
1227}
1228
Harald Welte235ebf12017-12-15 14:18:16 +01001229/* Run everything required up to sending a caller-specified assignment command and expect response */
1230function f_assignment_exp(PDU_BSSAP ass_cmd, template PDU_BSSAP exp, charstring fail_text)
1231runs on test_CT {
1232 var BSSAP_N_CONNECT_ind rx_c_ind;
1233 var RSL_Message rx_rsl;
1234 var DchanTuple dt;
1235
Harald Welte89d42e82017-12-17 16:42:41 +01001236 f_init(1);
Harald Welte235ebf12017-12-15 14:18:16 +01001237
1238 dt := f_est_dchan('23'O, 23, '00000000'O);
1239 /* send assignment without AoIP IEs */
1240 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ass_cmd));
1241 alt {
1242 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentComplete)) {
1243 if (ischosen(exp.pdu.bssmap.assignmentComplete)) {
1244 setverdict(pass);
1245 } else {
1246 setverdict(fail, fail_text);
1247 }
1248 }
1249 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentFail)) {
1250 if (ischosen(exp.pdu.bssmap.assignmentFailure)) {
1251 setverdict(pass);
1252 } else {
1253 setverdict(fail, fail_text);
1254 }
1255 }
1256 [] BSSAP.receive { repeat; }
1257 }
1258}
1259testcase TC_assignment_csd() runs on test_CT {
1260 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +02001261 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte235ebf12017-12-15 14:18:16 +01001262 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeCSD);
1263 //exp_fail.pdu.bssmap.assignmentFailure.cause.causeValue := int2bit(enum2int(GSM0808_CAUSE_REQ_CODEC_TYPE_OR_CONFIG_UNAVAIL), 7);
1264 f_assignment_exp(ass_cmd, exp_fail, "BSC accepted Assignment for CSD");
1265}
1266
1267testcase TC_assignment_ctm() runs on test_CT {
1268 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +02001269 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte235ebf12017-12-15 14:18:16 +01001270 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeCTM);
1271 //exp_fail.pdu.bssmap.assignmentFailure.cause.causeValue := int2bit(enum2int(GSM0808_CAUSE_REQ_CODEC_TYPE_OR_CONFIG_UNAVAIL), 7);
1272 f_assignment_exp(ass_cmd, exp_fail, "BSC accepted Assignment for Speech+CTM");
1273}
1274
Harald Welte4003d112017-12-09 22:35:39 +01001275type record DchanTuple {
1276 integer sccp_conn_id,
1277 RslChannelNr rsl_chan_nr
Harald Weltea5d2ab22017-12-09 14:21:42 +01001278}
1279
Harald Welted6939652017-12-13 21:02:46 +01001280/* Send CHAN RQD and wait for allocation; acknowledge it */
1281private function f_chreq_act_ack(OCT1 ra := '23'O, GsmFrameNumber fn := 23)
1282runs on test_CT return RslChannelNr {
1283 var RSL_Message rx_rsl;
1284 f_ipa_tx(0, ts_RSL_CHAN_RQD(ra, fn));
1285 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
1286 var RslChannelNr chan_nr := rx_rsl.ies[0].body.chan_nr;
1287 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, fn+10));
Daniel Willmannf4ac4ce2018-08-02 14:06:30 +02001288 rx_rsl := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
Harald Welted6939652017-12-13 21:02:46 +01001289 return chan_nr;
1290}
1291
Harald Welte4003d112017-12-09 22:35:39 +01001292/* helper function to establish a dedicated channel via BTS and MSC */
1293function f_est_dchan(OCT1 ra, GsmFrameNumber fn, octetstring l3)
1294runs on test_CT return DchanTuple {
1295 var BSSAP_N_CONNECT_ind rx_c_ind;
Harald Welte4003d112017-12-09 22:35:39 +01001296 var DchanTuple dt;
Harald Weltea5d2ab22017-12-09 14:21:42 +01001297
Harald Welte4003d112017-12-09 22:35:39 +01001298 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +01001299 dt.rsl_chan_nr := f_chreq_act_ack(ra, fn);
Harald Welte4003d112017-12-09 22:35:39 +01001300
1301 f_ipa_tx(0, ts_RSL_EST_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
1302
1303 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
1304 dt.sccp_conn_id := rx_c_ind.connectionId;
1305 BSSAP.send(ts_BSSAP_CONNECT_res(dt.sccp_conn_id));
1306
1307 return dt;
Harald Weltea5d2ab22017-12-09 14:21:42 +01001308}
1309
Harald Welte641fcbe2018-06-14 10:58:35 +02001310/* expect RF CAN REL from BTS, acknowledge it and clear the MSC side */
1311private function f_exp_chan_rel_and_clear(DchanTuple dt, integer bts_nr := 0) runs on test_CT {
1312 var RSL_Message rx_rsl;
1313 /* expect BSC to disable the channel */
1314 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX);
1315 /* respond with CHAN REL ACK */
1316 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
1317
1318 /* expect Clear Complete from BSC */
1319 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete));
1320
1321 /* MSC disconnects as instructed. */
1322 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1323}
1324
Harald Welte4003d112017-12-09 22:35:39 +01001325/* Test behavior of channel release after unilateral RLL REL IND (DISC from MS) */
1326testcase TC_chan_rel_rll_rel_ind() runs on test_CT {
Neels Hofmeyr27f64362018-03-12 01:44:00 +01001327 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +01001328 var DchanTuple dt;
Harald Welte96c94412017-12-09 03:12:45 +01001329
Harald Welte89d42e82017-12-17 16:42:41 +01001330 f_init(1);
Harald Welte96c94412017-12-09 03:12:45 +01001331
Harald Welte4003d112017-12-09 22:35:39 +01001332 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1333
1334 /* simulate RLL REL IND */
1335 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0))));
1336
Neels Hofmeyr27f64362018-03-12 01:44:00 +01001337 /* expect Clear Request on MSC side */
1338 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
1339
1340 /* Instruct BSC to clear channel */
1341 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
1342 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
1343
Harald Welte4003d112017-12-09 22:35:39 +01001344 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02001345 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyr27f64362018-03-12 01:44:00 +01001346
1347 /* wait for SCCP emulation to do its job */
1348 f_sleep(1.0);
Harald Welte4003d112017-12-09 22:35:39 +01001349
1350 setverdict(pass);
1351}
1352
1353/* Test behavior of channel release after CONN FAIL IND from BTS */
1354testcase TC_chan_rel_conn_fail() runs on test_CT {
1355 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +01001356 var DchanTuple dt;
1357
Harald Welte89d42e82017-12-17 16:42:41 +01001358 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01001359
1360 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1361
1362 /* simulate CONN FAIL IND */
Harald Weltea8ed9062017-12-14 09:46:01 +01001363 f_ipa_tx(0, ts_RSL_CONN_FAIL_IND(dt.rsl_chan_nr, RSL_ERR_RADIO_LINK_FAIL));
Harald Welte4003d112017-12-09 22:35:39 +01001364 /* TODO: different cause values? */
1365
Harald Welte4003d112017-12-09 22:35:39 +01001366 /* expect Clear Request from BSC */
1367 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
1368
1369 /* Instruct BSC to clear channel */
1370 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
1371 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
1372
Harald Welte6ff76ea2018-01-28 13:08:01 +01001373 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02001374 f_exp_chan_rel_and_clear(dt, 0);
Harald Welte4003d112017-12-09 22:35:39 +01001375
1376 /* wait for SCCP emulation to do its job */
1377 f_sleep(1.0);
1378
1379 setverdict(pass);
1380}
1381
Harald Welte99f3ca02018-06-14 13:40:29 +02001382/* Test behavior of early CONN FAIL IND from BTS (before EST IND!) */
1383/* See also https://www.osmocom.org/issues/3182 */
1384testcase TC_early_conn_fail() runs on test_CT {
1385 var RSL_Message rx_rsl;
1386 var DchanTuple dt;
1387
1388 f_init(1);
1389
1390 /* BTS->BSC: Send CHAN RQD and wait for allocation; acknowledge it */
1391 dt.rsl_chan_nr := f_chreq_act_ack(f_rnd_octstring(1), 23);
1392
1393 /* BTS->BSC: simulate CONN FAIL IND */
1394 f_ipa_tx(0, ts_RSL_CONN_FAIL_IND(dt.rsl_chan_nr, RSL_ERR_RADIO_LINK_FAIL));
1395
1396 /* BTS->BSC: Expect RF channel release from BSC on Abis */
1397 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), 10.0);
1398
1399 /* BTS<-BSC: respond with CHAN REL ACK */
1400 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
1401
1402 setverdict(pass);
1403}
1404
1405/* Test behavior of late CONN FAIL IND from BTS (ater REL IND!) */
1406/* See also https://www.osmocom.org/issues/3182 */
1407testcase TC_late_conn_fail() runs on test_CT {
1408 var RSL_Message rx_rsl;
1409 var DchanTuple dt;
1410
1411 f_init(1);
1412
1413 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1414
1415 /* BSC<-MSC: Instruct BSC to clear connection */
1416 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(0)));
1417
1418 /* BTS->BSC: expect BSC to deactivate SACCH */
1419 rx_rsl := f_exp_ipa_rx(0, tr_RSL_DEACT_SACCH(dt.rsl_chan_nr));
1420
1421 /* BTS->BSC: simulate a late CONN FAIL IND from BTS */
1422 f_ipa_tx(0, ts_RSL_CONN_FAIL_IND(dt.rsl_chan_nr, RSL_ERR_RADIO_LINK_FAIL));
1423
1424 /* BTS<-BSC: Expect RF channel release from BSC on Abis */
1425 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), 10.0);
1426 /* BTS->BSC: respond with CHAN REL ACK */
1427 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
1428
1429 /* BSC->MSC: expect Clear Complete from BSC */
1430 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete));
1431
1432 /* BSC<-MSC: MSC disconnects as requested. */
1433 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1434
1435 setverdict(pass);
1436}
1437
Neels Hofmeyrf44ccd12018-11-05 19:15:23 +01001438function f_expect_chan_rel(integer bts_nr, RslChannelNr rsl_chan_nr,
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001439 boolean expect_deact_sacch := true,
1440 boolean expect_rr_chan_rel := true,
1441 boolean expect_rll_rel_req := true,
Harald Welte99787102019-02-04 10:41:36 +01001442 boolean handle_rll_rel := true,
1443 boolean is_csfb := false
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001444 ) runs on test_CT {
Harald Welte91d54a52018-01-28 15:35:07 +01001445
1446 var RslLinkId main_dcch := valueof(ts_RslLinkID_DCCH(0));
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001447 var boolean got_deact_sacch := false;
1448 var boolean got_rr_chan_rel := false;
1449 var boolean got_rll_rel_req := false;
1450 log("f_expect_chan_rel() expecting: expect_deact_sacch=", expect_deact_sacch, " expect_rr_chan_rel=", expect_rr_chan_rel,
1451 " expect_rll_rel_req=", expect_rll_rel_req);
Harald Welte91d54a52018-01-28 15:35:07 +01001452 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001453 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_DEACT_SACCH(rsl_chan_nr))) {
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001454 got_deact_sacch := true;
Harald Welte91d54a52018-01-28 15:35:07 +01001455 repeat;
1456 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001457 [is_csfb] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_DATA_REQ(rsl_chan_nr, ?, decmatch tr_RRM_RR_RELEASE_CSFB))) {
Harald Welte99787102019-02-04 10:41:36 +01001458 got_rr_chan_rel := true;
1459 repeat;
1460 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001461 [not is_csfb] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_DATA_REQ(rsl_chan_nr, ?, decmatch tr_RRM_RR_RELEASE))) {
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001462 got_rr_chan_rel := true;
Neels Hofmeyr211169d2018-11-07 00:37:29 +01001463 repeat;
1464 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001465 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_REL_REQ(rsl_chan_nr, ?))) {
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001466 got_rll_rel_req := true;
Harald Welte91d54a52018-01-28 15:35:07 +01001467 /* FIXME: Why are we getting this for LinkID SACCH? */
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001468 if (handle_rll_rel) {
1469 f_ipa_tx(0, ts_RSL_REL_CONF(rsl_chan_nr, main_dcch));
1470 }
Harald Welte91d54a52018-01-28 15:35:07 +01001471 repeat;
1472 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001473 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL))) {
Harald Welte91d54a52018-01-28 15:35:07 +01001474 /* respond with CHAN REL ACK */
1475 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(rsl_chan_nr));
1476 }
1477 /* ignore any user data */
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001478 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeR(?))) {
Harald Welte91d54a52018-01-28 15:35:07 +01001479 repeat;
1480 }
1481 }
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001482
1483 log("f_expect_chan_rel() summary: got_deact_sacch=", got_deact_sacch, " got_rr_chan_rel=", got_rr_chan_rel,
1484 " got_rll_rel_req=", got_rll_rel_req);
1485
1486 if (expect_deact_sacch != got_deact_sacch) {
1487 setverdict(fail, "f_expect_chan_rel(): expect_deact_sacch=", expect_deact_sacch, " got_deact_sacch=", got_deact_sacch);
1488 }
1489 if (expect_rr_chan_rel != got_rr_chan_rel) {
1490 setverdict(fail, "f_expect_chan_rel(): expect_rr_chan_rel=", expect_rr_chan_rel, " got_rr_chan_rel=", got_rr_chan_rel);
1491 }
1492 if (expect_rll_rel_req != got_rll_rel_req) {
1493 setverdict(fail, "f_expect_chan_rel(): expect_rll_rel_req=", expect_rll_rel_req, " got_rll_rel_req=", got_rll_rel_req);
1494 }
Harald Welte91d54a52018-01-28 15:35:07 +01001495}
1496
Harald Welte4003d112017-12-09 22:35:39 +01001497/* Test behavior of channel release after hard Clear Command from MSC */
1498testcase TC_chan_rel_hard_clear() runs on test_CT {
1499 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +01001500 var DchanTuple dt;
Harald Welte4003d112017-12-09 22:35:39 +01001501
Harald Welte89d42e82017-12-17 16:42:41 +01001502 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01001503
1504 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1505
1506 /* Instruct BSC to clear channel */
1507 var BssmapCause cause := 0;
1508 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
1509
1510 /* expect Clear Complete from BSC on A */
1511 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
1512 /* release the SCCP connection */
1513 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1514 }
1515
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001516 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Harald Welte4003d112017-12-09 22:35:39 +01001517 setverdict(pass);
1518}
1519
Harald Welte99787102019-02-04 10:41:36 +01001520/* Test behavior of channel release after Clear Command with CSFB indicator from MSC */
1521testcase TC_chan_rel_hard_clear_csfb() runs on test_CT {
1522 var BSSAP_N_DATA_ind rx_di;
1523 var DchanTuple dt;
1524
1525 f_init(1);
1526
1527 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1528
1529 /* Instruct BSC to clear channel */
1530 var BssmapCause cause := 0;
1531 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommandCSFB(cause)));
1532
1533 /* expect Clear Complete from BSC on A */
1534 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
1535 /* release the SCCP connection */
1536 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1537 }
1538
1539 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false, is_csfb := true);
1540 setverdict(pass);
1541}
1542
Harald Welted8c36cd2017-12-09 23:05:31 +01001543/* Test behavior of channel release after hard RLSD from MSC */
1544testcase TC_chan_rel_hard_rlsd() runs on test_CT {
Harald Welted8c36cd2017-12-09 23:05:31 +01001545 var DchanTuple dt;
Harald Welted8c36cd2017-12-09 23:05:31 +01001546
Harald Welte89d42e82017-12-17 16:42:41 +01001547 f_init(1);
Harald Welted8c36cd2017-12-09 23:05:31 +01001548
1549 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1550
1551 /* release the SCCP connection */
1552 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1553
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001554 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Harald Welted8c36cd2017-12-09 23:05:31 +01001555 setverdict(pass);
1556}
1557
Harald Welte550daf92018-06-11 19:22:13 +02001558/* Test behavior of channel release after hard RLSD from MSC and MS is not responding to RLL REL REQ */
1559testcase TC_chan_rel_hard_rlsd_ms_dead() runs on test_CT {
1560 var DchanTuple dt;
1561
1562 f_init(1);
1563
1564 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1565
1566 /* release the SCCP connection */
1567 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1568
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001569 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Harald Welte550daf92018-06-11 19:22:13 +02001570 setverdict(pass);
1571}
1572
Harald Welte85804d42017-12-10 14:11:58 +01001573/* Test behavior of channel release after BSSMAP RESET from MSC */
1574testcase TC_chan_rel_a_reset() runs on test_CT {
Harald Welte85804d42017-12-10 14:11:58 +01001575 var DchanTuple dt;
Harald Welte85804d42017-12-10 14:11:58 +01001576
Harald Welte89d42e82017-12-17 16:42:41 +01001577 f_init(1);
Harald Welte85804d42017-12-10 14:11:58 +01001578
1579 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1580
1581 /* Clear the queue, it might still contain stuff like IMMEDIATE ASSIGN */
1582 IPA_RSL[0].clear;
1583
1584 /* perform BSSAP RESET, expect RESET ACK and DISC.ind on connection */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001585 BSSAP.send(ts_BSSAP_UNITDATA_req(g_bssap[0].sccp_addr_peer, g_bssap[0].sccp_addr_own, ts_BSSMAP_Reset(0, g_osmux_enabled)));
Harald Welte85804d42017-12-10 14:11:58 +01001586 interleave {
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001587 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(g_bssap[0].sccp_addr_own, g_bssap[0].sccp_addr_peer, tr_BSSMAP_ResetAck(g_osmux_enabled))) { }
Harald Welte85804d42017-12-10 14:11:58 +01001588 [] BSSAP.receive(tr_BSSAP_DISC_ind(dt.sccp_conn_id, ?, ?)) { }
1589 }
1590
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001591 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Harald Welte85804d42017-12-10 14:11:58 +01001592 setverdict(pass);
1593}
1594
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01001595/* Verify T(iar) triggers and releases the channel */
1596testcase TC_chan_rel_sccp_tiar_timeout() runs on test_CT {
1597 var DchanTuple dt;
1598
1599 /* Set T(iar) in BSC low enough that it will trigger before other side
1600 has time to keep alive with a T(ias). Keep recommended ratio of
1601 T(iar) >= T(ias)*2 */
1602 g_bsc_sccp_timer_ias := 2;
1603 g_bsc_sccp_timer_iar := 5;
1604
1605 f_init(1);
1606
1607 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1608 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
1609 setverdict(pass);
1610}
1611
Harald Welte5cd20ed2017-12-13 21:03:20 +01001612/* Test behavior if RSL EST IND for non-active channel */
1613testcase TC_rll_est_ind_inact_lchan() runs on test_CT {
1614 timer T := 2.0;
1615
Harald Welte89d42e82017-12-17 16:42:41 +01001616 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01001617
1618 var octetstring l3 := '00010203040506'O;
1619 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
1620 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
1621
1622 T.start;
1623 alt {
1624 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
1625 setverdict(fail, "MSC received COMPL L3 for non-active lchan");
1626 }
1627 [] BSSAP.receive {}
1628 [] IPA_RSL[0].receive {}
1629 [] T.timeout {}
1630 }
1631
1632 setverdict(pass);
1633}
1634
1635/* Test behavior if RSL EST IND for invalid SAPI */
1636testcase TC_rll_est_ind_inval_sapi1() runs on test_CT {
1637 var RslChannelNr chan_nr;
1638
Harald Welte89d42e82017-12-17 16:42:41 +01001639 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01001640
1641 chan_nr := f_chreq_act_ack()
1642
1643 var octetstring l3 := '00010203040506'O;
1644 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(1)), l3));
1645
1646 timer T := 2.0;
1647 T.start;
1648 alt {
1649 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
1650 setverdict(fail, "MSC received COMPL L3 for invalid SAPI 1");
1651 }
1652 [] BSSAP.receive { repeat; }
1653 [] IPA_RSL[0].receive { repeat; }
1654 [] T.timeout {}
1655 }
1656
1657 setverdict(pass);
1658}
1659
1660/* Test behavior if RSL EST IND for invalid SAPI */
1661testcase TC_rll_est_ind_inval_sapi3() runs on test_CT {
1662 timer T := 2.0;
1663
Harald Welte89d42e82017-12-17 16:42:41 +01001664 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01001665
1666 var RslChannelNr chan_nr := f_chreq_act_ack();
1667
1668 var octetstring l3 := '00010203040506'O;
1669 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(3)), l3));
1670
1671 T.start;
1672 alt {
1673 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
1674 setverdict(fail, "MSC received COMPL L3 for invalid SAPI 3");
1675 }
1676 [] BSSAP.receive { repeat; }
1677 [] IPA_RSL[0].receive { repeat; }
1678 [] T.timeout {}
1679 }
1680
1681 setverdict(pass);
1682}
1683
1684/* Test behavior if RSL EST IND for invalid SACCH */
1685testcase TC_rll_est_ind_inval_sacch() runs on test_CT {
1686 timer T := 2.0;
1687
Harald Welte89d42e82017-12-17 16:42:41 +01001688 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01001689
1690 var RslChannelNr chan_nr := f_chreq_act_ack();
1691
1692 var octetstring l3 := '00010203040506'O;
1693 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_SACCH(0)), l3));
1694
1695 T.start;
1696 alt {
1697 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
1698 setverdict(fail, "MSC received COMPL L3 for invalid Link SACCH");
1699 }
1700 [] BSSAP.receive { repeat; }
1701 [] IPA_RSL[0].receive { repeat; }
1702 [] T.timeout {}
1703 }
1704
1705 setverdict(pass);
1706}
1707
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02001708testcase TC_si_default() runs on test_CT {
1709 f_init(0);
1710 f_init_bts_and_check_sysinfo(0, expect_si := SystemInformationConfig_default);
1711}
Harald Welte4003d112017-12-09 22:35:39 +01001712
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02001713function f_test_si2quater(integer total_earfcns, template SystemInformationConfig expect_si) runs on test_CT {
1714
1715 f_init(0);
1716
1717 /* E-ARFCN 111 is already added in the osmo-bsc.cfg, so only add more arfcns if total_earfcns > 1 */
1718 for (var integer i := 1; i < total_earfcns; i := i + 1) {
1719 f_bts_0_cfg(BSCVTY, {"si2quater neighbor-list add earfcn " & int2str(22 + i) & " thresh-hi 20 thresh-lo 10 prio 3 qrxlv 22 meas 3"});
1720 }
1721
1722 f_init_bts_and_check_sysinfo(0, expect_si := expect_si);
1723
1724 for (var integer i := 1; i < total_earfcns; i := i + 1) {
1725 f_bts_0_cfg(BSCVTY, {"si2quater neighbor-list del earfcn " & int2str(22 + i)});
1726 }
1727}
1728
1729testcase TC_si2quater_2_earfcns() runs on test_CT {
1730 var template SystemInformationConfig sic := SystemInformationConfig_default;
1731 sic.si2quater := {
1732 tr_SI2quaterRestOctets_EUTRAN(
1733 repeated_neigh_cells := {
1734 tr_EUTRAN_NeighbourCells_default(
1735 cell_desc_list := {
1736 tr_EUTRAN_CellDesc_default(e_arfcn := 111),
1737 tr_EUTRAN_CellDesc_default(e_arfcn := 23)
1738 }
1739 )
1740 }
1741 )
1742 };
1743 f_test_si2quater(2, sic);
1744}
1745
1746testcase TC_si2quater_3_earfcns() runs on test_CT {
1747 var template SystemInformationConfig sic := SystemInformationConfig_default;
1748 sic.si2quater := {
1749 tr_SI2quaterRestOctets_EUTRAN(
1750 repeated_neigh_cells := {
1751 tr_EUTRAN_NeighbourCells_default(
1752 cell_desc_list := {
1753 tr_EUTRAN_CellDesc_default(e_arfcn := 111),
1754 tr_EUTRAN_CellDesc_default(e_arfcn := 23),
1755 tr_EUTRAN_CellDesc_default(e_arfcn := 24)
1756 }
1757 )
1758 }
1759 )
1760 };
1761 f_test_si2quater(3, sic);
1762}
1763
1764testcase TC_si2quater_4_earfcns() runs on test_CT {
1765 var template SystemInformationConfig sic := SystemInformationConfig_default;
1766 sic.si2quater := {
1767 tr_SI2quaterRestOctets_EUTRAN(
1768 index := 0,
1769 count := 1,
1770 repeated_neigh_cells := {
1771 tr_EUTRAN_NeighbourCells_default(
1772 cell_desc_list := {
1773 tr_EUTRAN_CellDesc_default(e_arfcn := 111),
1774 tr_EUTRAN_CellDesc_default(e_arfcn := 23),
1775 tr_EUTRAN_CellDesc_default(e_arfcn := 24)
1776 }
1777 )
1778 }
1779 ),
1780 tr_SI2quaterRestOctets_EUTRAN(
1781 index := 1,
1782 count := 1,
1783 repeated_neigh_cells := {
1784 tr_EUTRAN_NeighbourCells_default(
1785 cell_desc_list := {
1786 tr_EUTRAN_CellDesc_default(e_arfcn := 25)
1787 }
1788 )
1789 }
1790 )
1791 };
1792 f_test_si2quater(4, sic);
1793}
1794
1795testcase TC_si2quater_5_earfcns() runs on test_CT {
1796 var template SystemInformationConfig sic := SystemInformationConfig_default;
1797 sic.si2quater := {
1798 tr_SI2quaterRestOctets_EUTRAN(
1799 index := 0,
1800 count := 1,
1801 repeated_neigh_cells := {
1802 tr_EUTRAN_NeighbourCells_default(
1803 cell_desc_list := {
1804 tr_EUTRAN_CellDesc_default(e_arfcn := 111),
1805 tr_EUTRAN_CellDesc_default(e_arfcn := 23),
1806 tr_EUTRAN_CellDesc_default(e_arfcn := 24)
1807 }
1808 )
1809 }
1810 ),
1811 tr_SI2quaterRestOctets_EUTRAN(
1812 index := 1,
1813 count := 1,
1814 repeated_neigh_cells := {
1815 tr_EUTRAN_NeighbourCells_default(
1816 cell_desc_list := {
1817 tr_EUTRAN_CellDesc_default(e_arfcn := 25),
1818 tr_EUTRAN_CellDesc_default(e_arfcn := 26)
1819 }
1820 )
1821 }
1822 )
1823 };
1824 f_test_si2quater(5, sic);
1825}
1826
1827testcase TC_si2quater_6_earfcns() runs on test_CT {
1828 var template SystemInformationConfig sic := SystemInformationConfig_default;
1829 sic.si2quater := {
1830 tr_SI2quaterRestOctets_EUTRAN(
1831 index := 0,
1832 count := 1,
1833 repeated_neigh_cells := {
1834 tr_EUTRAN_NeighbourCells_default(
1835 cell_desc_list := {
1836 tr_EUTRAN_CellDesc_default(e_arfcn := 111),
1837 tr_EUTRAN_CellDesc_default(e_arfcn := 23),
1838 tr_EUTRAN_CellDesc_default(e_arfcn := 24)
1839 }
1840 )
1841 }
1842 ),
1843 tr_SI2quaterRestOctets_EUTRAN(
1844 index := 1,
1845 count := 1,
1846 repeated_neigh_cells := {
1847 tr_EUTRAN_NeighbourCells_default(
1848 cell_desc_list := {
1849 tr_EUTRAN_CellDesc_default(e_arfcn := 25),
1850 tr_EUTRAN_CellDesc_default(e_arfcn := 26),
1851 tr_EUTRAN_CellDesc_default(e_arfcn := 27)
1852 }
1853 )
1854 }
1855 )
1856 };
1857 f_test_si2quater(6, sic);
1858}
1859
1860
Harald Welte4003d112017-12-09 22:35:39 +01001861testcase TC_ctrl_msc_connection_status() runs on test_CT {
1862 var charstring ctrl_resp;
1863
Harald Welte89d42e82017-12-17 16:42:41 +01001864 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01001865
1866 /* See https://osmocom.org/issues/2729 */
1867 f_ctrl_get_exp(IPA_CTRL, "msc_connection_status", "connected");
1868 setverdict(pass);
1869}
1870
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01001871testcase TC_ctrl_msc0_connection_status() runs on test_CT {
1872 var charstring ctrl_resp;
1873
1874 f_init(1);
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01001875
1876 f_ctrl_get_exp(IPA_CTRL, "msc.0.connection_status", "connected");
1877 setverdict(pass);
1878}
1879
Harald Welte4003d112017-12-09 22:35:39 +01001880testcase TC_ctrl() runs on test_CT {
1881 var charstring ctrl_resp;
1882
Harald Welte89d42e82017-12-17 16:42:41 +01001883 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01001884
1885 /* all below values must match the osmo-bsc.cfg config file used */
1886
Harald Welte6a129692018-03-17 17:30:14 +01001887 f_ctrl_get_exp(IPA_CTRL, "mcc", "001");
1888 f_ctrl_get_exp(IPA_CTRL, "mnc", "01");
Oliver Smith75aa0202019-08-19 14:17:50 +02001889 f_ctrl_get_exp(IPA_CTRL, "number-of-bts", "4");
Harald Welte4003d112017-12-09 22:35:39 +01001890
1891 var integer bts_nr := 0;
1892 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "location-area-code", "1");
1893 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "cell-identity", "0");
1894 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "oml-connection-state", "connected");
1895 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "gprs-mode", "gprs");
1896 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "rf_state", "operational,unlocked,on");
1897 f_ctrl_get_exp_trx(IPA_CTRL, bts_nr, 0, "arfcn", "871");
1898 f_ctrl_get_exp_trx(IPA_CTRL, bts_nr, 0, "max-power-reduction", "20");
1899
1900 var integer uptime := str2int(f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-uptime"));
1901 f_sleep(2.0);
1902 if (str2int(f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-uptime")) < uptime+1) {
1903 setverdict(fail, "oml-uptime not incrementing as expected");
1904 }
1905 /* TODO: Disconnect RSL, imply that OML is disconnected and check for uptime zero? */
1906
1907 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted", 0);
1908
1909 setverdict(pass);
Harald Welte96c94412017-12-09 03:12:45 +01001910}
1911
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +02001912/* Verify that Upon receival of SET "location", BSC forwards a TRAP
1913 "location-state" over the SCCPlite IPA conn */
1914testcase TC_ctrl_location() runs on test_CT {
1915 var MSC_ConnHdlr vc_conn;
1916 var integer bts_nr := 0;
1917
1918 f_init(1, true);
1919 f_sleep(1.0);
1920
1921 f_ctrl_set_bts(IPA_CTRL, bts_nr, "location", "1234567,fix3d,0.340000,0.560000,0.780000");
1922 f_ctrl_exp_trap(SCCPLITE_IPA_CTRL, "bts." & int2str(bts_nr) & ".location-state",
1923 "1234567,fix3d,0.340000,0.560000,0.780000,operational,unlocked,on,001,01");
1924
1925 f_ctrl_set(SCCPLITE_IPA_CTRL, "rf_locked", "1");
1926 f_sleep(2.0);
1927
1928 f_ctrl_set_bts(IPA_CTRL, bts_nr, "location", "1234888,fix3d,0.350000,0.570000,0.790000");
1929 f_ctrl_exp_trap(SCCPLITE_IPA_CTRL, "bts." & int2str(bts_nr) & ".location-state",
1930 "1234888,fix3d,0.350000,0.570000,0.790000,operational,locked,off,001,01");
1931
1932 /* should match the one from config */
1933 f_ctrl_set(SCCPLITE_IPA_CTRL, "rf_locked", "0");
1934
1935 setverdict(pass);
1936}
1937
Harald Welte6f521d82017-12-11 19:52:02 +01001938
1939/***********************************************************************
1940 * Paging Testing
1941 ***********************************************************************/
1942
1943type record Cell_Identity {
1944 GsmMcc mcc,
1945 GsmMnc mnc,
1946 GsmLac lac,
1947 GsmCellId ci
1948};
Harald Welte24135bd2018-03-17 19:27:53 +01001949private const Cell_Identity cid := { '001'H, '01'H, 1, 0 };
Stefan Sperling049a86e2018-03-20 15:51:00 +01001950private const Cell_Identity unknown_cid := { '678'H, 'f90'H, 1, 0 };
Harald Welte6f521d82017-12-11 19:52:02 +01001951
Harald Welte5d1a2202017-12-13 19:51:29 +01001952type set of integer BtsIdList;
1953
1954private function f_bts_in_list(integer bts_id, BtsIdList bts_ids) return boolean {
1955 for (var integer j := 0; j < sizeof(bts_ids); j := j + 1) {
1956 if (bts_id == bts_ids[j]) {
1957 return true;
1958 }
1959 }
1960 return false;
1961}
Harald Welte6f521d82017-12-11 19:52:02 +01001962
1963/* core paging test helper function; used by most paging test cases */
1964private function f_pageing_helper(hexstring imsi,
1965 template BSSMAP_FIELD_CellIdentificationList cid_list,
Harald Welte5d1a2202017-12-13 19:51:29 +01001966 BtsIdList bts_ids := { 0 },
Harald Welte6f521d82017-12-11 19:52:02 +01001967 template RSL_ChanNeeded rsl_chneed := omit,
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07001968 template (omit) OCT4 tmsi := omit) runs on test_CT
Harald Welte6f521d82017-12-11 19:52:02 +01001969{
1970 var template BSSMAP_IE_ChannelNeeded bssmap_chneed;
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07001971 var template MobileIdentityV mi;
Harald Welte6f521d82017-12-11 19:52:02 +01001972 var RSL_Message rx_rsl;
1973 var integer paging_group := hex2int(imsi[lengthof(imsi)-1]);
Harald Welte5d1a2202017-12-13 19:51:29 +01001974 var integer i;
Harald Welte6f521d82017-12-11 19:52:02 +01001975
1976 f_init();
Harald Welte6f521d82017-12-11 19:52:02 +01001977
1978 /* Clear the queue, it might still contain stuff like BCCH FILLING */
Harald Weltec3068592018-03-17 19:55:31 +01001979 for (i := 0; i < NUM_BTS; i := i + 1) {
1980 IPA_RSL[i].clear;
Harald Welte5d1a2202017-12-13 19:51:29 +01001981 }
Harald Welte6f521d82017-12-11 19:52:02 +01001982
1983 if (isvalue(rsl_chneed)) {
1984 /* The values of 08.08 3.2.2.36 and 08.58 9.3.40 are luckily identical */
1985 bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
1986 } else {
1987 bssmap_chneed := omit;
1988 }
1989
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001990 BSSAP.send(ts_BSSAP_UNITDATA_req(g_bssap[0].sccp_addr_peer, g_bssap[0].sccp_addr_own,
1991 ts_BSSMAP_Paging(imsi, cid_list, tmsi, bssmap_chneed)));
Harald Welte6f521d82017-12-11 19:52:02 +01001992
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07001993 if (not istemplatekind(tmsi, "omit")) {
1994 mi := t_MI_TMSI(tmsi);
Harald Welte6f521d82017-12-11 19:52:02 +01001995 } else {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07001996 mi := tr_MI_IMSI(imsi);
Harald Welte6f521d82017-12-11 19:52:02 +01001997 }
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07001998
Harald Welte5d1a2202017-12-13 19:51:29 +01001999 for (i := 0; i < sizeof(bts_ids); i := i + 1) {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002000 rx_rsl := f_exp_ipa_rx(bts_ids[i], tr_RSL_PAGING_CMD(mi));
Harald Welte5d1a2202017-12-13 19:51:29 +01002001 /* check channel type, paging group */
2002 if (rx_rsl.ies[1].body.paging_group != paging_group) {
2003 setverdict(fail, "Paging for wrong paging group");
2004 }
2005 if (ispresent(rsl_chneed) and
2006 rx_rsl.ies[3].body.chan_needed.chan_needed != valueof(rsl_chneed)) {
2007 setverdict(fail, "RSL Channel Needed != BSSMAP Channel Needed");
2008 }
Harald Welte6f521d82017-12-11 19:52:02 +01002009 }
Harald Welte2fccd982018-01-31 15:48:19 +01002010 f_sleep(2.0);
Harald Welte5d1a2202017-12-13 19:51:29 +01002011 /* do a quick check on all not-included BTSs if they received paging */
2012 for (i := 0; i < NUM_BTS; i := i + 1) {
2013 timer T := 0.1;
2014 if (f_bts_in_list(i, bts_ids)) {
2015 continue;
2016 }
2017 T.start;
2018 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07002019 [] IPA_RSL[i].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(mi))) {
Harald Welte5d1a2202017-12-13 19:51:29 +01002020 setverdict(fail, "Paging on BTS ", i, " which is not part of ", bts_ids);
2021 }
2022 [] IPA_RSL[i].receive { repeat; }
2023 [] T.timeout { }
2024 }
Harald Welte6f521d82017-12-11 19:52:02 +01002025 }
2026
2027 setverdict(pass);
2028}
2029
Harald Welte5d1a2202017-12-13 19:51:29 +01002030const BtsIdList c_BtsId_all := { 0, 1, 2 };
Harald Welte751d3eb2018-01-31 15:51:06 +01002031const BtsIdList c_BtsId_none := { };
Harald Welte5d1a2202017-12-13 19:51:29 +01002032const BtsIdList c_BtsId_LAC1 := { 0, 1 };
2033const BtsIdList c_BtsId_LAC2 := { 2 };
2034
Harald Welte6f521d82017-12-11 19:52:02 +01002035/* PAGING by IMSI + TMSI */
2036testcase TC_paging_imsi_nochan() runs on test_CT {
2037 var BSSMAP_FIELD_CellIdentificationList cid_list;
2038 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Philipp Maier8c04b0a2018-02-23 13:48:48 +01002039 f_pageing_helper('001010100000001'H, cid_list, c_BtsId_all, omit, omit);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002040 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002041}
2042
2043/* PAGING by IMSI + TMSI */
2044testcase TC_paging_tmsi_nochan() runs on test_CT {
2045 var BSSMAP_FIELD_CellIdentificationList cid_list;
2046 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002047 f_pageing_helper('001010100000001'H, cid_list, c_BtsId_all, omit, 'A1B2C301'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002048 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002049}
2050
2051/* Paging with different "channel needed' values */
2052testcase TC_paging_tmsi_any() runs on test_CT {
2053 var BSSMAP_FIELD_CellIdentificationList cid_list;
2054 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002055 f_pageing_helper('001010100000002'H, cid_list, c_BtsId_all, RSL_CHANNEED_ANY, 'A1B2C302'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002056 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002057}
2058testcase TC_paging_tmsi_sdcch() runs on test_CT {
2059 var BSSMAP_FIELD_CellIdentificationList cid_list;
2060 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002061 f_pageing_helper('001010100000003'H, cid_list, c_BtsId_all, RSL_CHANNEED_SDCCH, 'A1B2C303'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002062 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002063}
2064testcase TC_paging_tmsi_tch_f() runs on test_CT {
2065 var BSSMAP_FIELD_CellIdentificationList cid_list;
2066 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002067 f_pageing_helper('001010000000004'H, cid_list, c_BtsId_all, RSL_CHANNEED_TCH_F, 'A1B2C304'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002068 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002069}
2070testcase TC_paging_tmsi_tch_hf() runs on test_CT {
2071 var BSSMAP_FIELD_CellIdentificationList cid_list;
2072 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002073 f_pageing_helper('001010000000005'H, cid_list, c_BtsId_all, RSL_CHANNEED_TCH_ForH, 'A1B2C305'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002074 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002075}
2076
2077/* Paging by CGI */
2078testcase TC_paging_imsi_nochan_cgi() runs on test_CT {
2079 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2080 cid_list := { cIl_CGI := { ts_BSSMAP_CI_CGI(cid.mcc, cid.mnc, cid.lac, cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002081 f_pageing_helper('001010000000006'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01002082 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002083}
2084
2085/* Paging by LAC+CI */
2086testcase TC_paging_imsi_nochan_lac_ci() runs on test_CT {
2087 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2088 cid_list := { cIl_LAC_CI := { ts_BSSMAP_CI_LAC_CI(cid.lac, cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002089 f_pageing_helper('001010000000007'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01002090 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002091}
2092
2093/* Paging by CI */
2094testcase TC_paging_imsi_nochan_ci() runs on test_CT {
2095 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2096 cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002097 f_pageing_helper('001010000000008'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01002098 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002099}
2100
2101/* Paging by LAI */
2102testcase TC_paging_imsi_nochan_lai() runs on test_CT {
2103 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2104 cid_list := { cIl_LAI := { ts_BSSMAP_CI_LAI(cid.mcc, cid.mnc, cid.lac) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002105 f_pageing_helper('001010000000009'H, cid_list, c_BtsId_LAC1);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002106 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002107}
2108
2109/* Paging by LAC */
2110testcase TC_paging_imsi_nochan_lac() runs on test_CT {
2111 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2112 cid_list := { cIl_LAC := { ts_BSSMAP_CI_LAC(cid.lac) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002113 f_pageing_helper('001010000000010'H, cid_list, c_BtsId_LAC1);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002114 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002115}
2116
2117/* Paging by "all in BSS" */
2118testcase TC_paging_imsi_nochan_all() runs on test_CT {
2119 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2120 cid_list := { cIl_allInBSS := ''O };
Harald Welte5d1a2202017-12-13 19:51:29 +01002121 f_pageing_helper('001010000000011'H, cid_list, c_BtsId_all);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002122 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002123}
2124
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002125/* Paging by PLMN+LAC+RNC; We do not implement this; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01002126testcase TC_paging_imsi_nochan_plmn_lac_rnc() runs on test_CT {
2127 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2128 cid_list := { cIl_PLMN_LAC_RNC := { ts_BSSMAP_CI_PLMN_LAC_RNC(cid.mcc, cid.mnc, cid.lac, 12) } };
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002129 f_pageing_helper('001010000000012'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002130 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002131}
Harald Welte6f521d82017-12-11 19:52:02 +01002132
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002133/* Paging by RNC; We do not implement this; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01002134testcase TC_paging_imsi_nochan_rnc() runs on test_CT {
2135 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2136 cid_list := { cIl_RNC := { int2oct(13, 2) } };
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002137 f_pageing_helper('001010000000013'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002138 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002139}
2140
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002141/* Paging by LAC+RNC; We do not implement; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01002142testcase TC_paging_imsi_nochan_lac_rnc() runs on test_CT {
2143 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2144 cid_list := { cIl_LAC_RNC := { ts_BSSMAP_CI_LAC_RNC(cid.lac, 14) } };
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002145 f_pageing_helper('001010000000014'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002146 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002147}
2148
Harald Welte6f521d82017-12-11 19:52:02 +01002149/* Paging on multiple cells (multiple entries in list): Verify all of them page */
Harald Welte751d3eb2018-01-31 15:51:06 +01002150testcase TC_paging_imsi_nochan_lacs() runs on test_CT {
2151 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2152 cid_list := { cIl_LAC := { ts_BSSMAP_CI_LAC(1), ts_BSSMAP_CI_LAC(2) } };
2153 f_pageing_helper('001010000000015'H, cid_list, c_BtsId_all);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002154 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002155}
2156
2157/* Paging on empty list: Verify none of them page */
2158testcase TC_paging_imsi_nochan_lacs_empty() runs on test_CT {
2159 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2160 cid_list := { cIl_LAC := { } };
2161 f_pageing_helper('001010000000016'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002162 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002163}
2164
Stefan Sperling049a86e2018-03-20 15:51:00 +01002165/* Paging by CGI with unknown MCC/MNC: Verify nothing is paged. */
2166testcase TC_paging_imsi_nochan_cgi_unknown_cid() runs on test_CT {
2167 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2168 cid_list := { cIl_CGI := { ts_BSSMAP_CI_CGI(unknown_cid.mcc, unknown_cid.mnc, unknown_cid.lac, unknown_cid.ci) } };
2169 f_pageing_helper('001010000000006'H, cid_list, c_BtsId_none);
2170 f_shutdown_helper();
2171}
2172
Harald Welte6f521d82017-12-11 19:52:02 +01002173/* Verify paging retransmission interval + count */
2174/* Verify paging stops after channel establishment */
Harald Welte6f521d82017-12-11 19:52:02 +01002175/* Test behavior under paging overload */
Harald Welteae026692017-12-09 01:03:01 +01002176
Harald Weltee65d40e2017-12-13 00:09:06 +01002177/* Verify PCH load */
2178testcase TC_paging_imsi_load() runs on test_CT {
2179 var BSSMAP_FIELD_CellIdentificationList cid_list;
2180 timer T := 4.0;
Harald Welte2caa1062018-03-17 18:19:05 +01002181 timer T_retrans := 1.0;
Harald Weltee65d40e2017-12-13 00:09:06 +01002182 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002183 f_pageing_helper('001010123456789'H, cid_list, c_BtsId_all);
Harald Weltee65d40e2017-12-13 00:09:06 +01002184
2185 /* tell BSC there is no paging space anymore */
2186 f_ipa_tx(0, ts_RSL_PAGING_LOAD_IND(0));
Harald Welte3b57ab52018-03-17 18:01:10 +01002187 f_sleep(0.2);
2188 IPA_RSL[0].clear;
Harald Weltee65d40e2017-12-13 00:09:06 +01002189
2190 /* Wait for 4 seconds if any more PAGING CMD are received on RSL. Normally,
2191 * there would be 8 retransmissions during 4 seconds */
2192 T.start;
Harald Welte2caa1062018-03-17 18:19:05 +01002193 T_retrans.start;
Harald Weltee65d40e2017-12-13 00:09:06 +01002194 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07002195 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Weltee65d40e2017-12-13 00:09:06 +01002196 setverdict(fail, "Received PAGING after LOAD_IND(0)");
Daniel Willmannafce8662018-07-06 23:11:32 +02002197 mtc.stop;
Harald Weltee65d40e2017-12-13 00:09:06 +01002198 }
Harald Welte2caa1062018-03-17 18:19:05 +01002199 [] T_retrans.timeout {
2200 /* re-trnsmit the zero-space LOAD IND to avoid BSC 'auto credit' */
2201 f_ipa_tx(0, ts_RSL_PAGING_LOAD_IND(0));
2202 T_retrans.start;
2203 repeat;
2204 }
Harald Weltee65d40e2017-12-13 00:09:06 +01002205 [] T.timeout {
2206 setverdict(pass);
2207 }
2208 }
Philipp Maier282ca4b2018-02-27 17:17:00 +01002209
2210 f_shutdown_helper();
Harald Weltee65d40e2017-12-13 00:09:06 +01002211}
2212
Harald Welte235ebf12017-12-15 14:18:16 +01002213/* Verify Paging Counter */
Harald Welte1ff69992017-12-14 12:31:17 +01002214testcase TC_paging_counter() runs on test_CT {
2215 var BSSMAP_FIELD_CellIdentificationList cid_list;
2216 timer T := 4.0;
2217 var integer i;
2218 var integer paging_attempted_bsc;
2219 var integer paging_attempted_bts[NUM_BTS];
2220 var integer paging_expired_bts[NUM_BTS];
2221 cid_list := valueof(ts_BSSMAP_CIL_noCell);
2222
2223 f_init();
2224
2225 /* read counters before paging */
2226 paging_attempted_bsc := f_ctrl_get_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted");
2227 for (i := 0; i < NUM_BTS; i := i+1) {
2228 paging_attempted_bts[i] := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", i, "paging:attempted");
2229 paging_expired_bts[i] := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", i, "paging:expired");
2230 }
2231
2232 f_pageing_helper('001230000000001'H, cid_list, c_BtsId_all);
2233
2234 /* expect the attempted pages on BSC and each BTSs to have incremented by one */
2235 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted", paging_attempted_bsc+1);
2236 for (i := 0; i < NUM_BTS; i := i+1) {
2237 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", i, "paging:attempted",
2238 paging_attempted_bts[i]+1);
2239 }
2240
2241 /* assume that 12s later the paging on all BTSs have expired and hence incremented by 1 */
2242 f_sleep(12.0);
2243 for (i := 0; i < NUM_BTS; i := i+1) {
2244 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", i, "paging:expired",
2245 paging_expired_bts[i]+1);
2246 }
Harald Welte1ff69992017-12-14 12:31:17 +01002247
Philipp Maier282ca4b2018-02-27 17:17:00 +01002248 f_shutdown_helper();
Harald Welte1ff69992017-12-14 12:31:17 +01002249}
2250
2251
Harald Welte10985002017-12-12 09:29:15 +01002252/* Verify paging stops after A-RESET */
2253testcase TC_paging_imsi_a_reset() runs on test_CT {
2254 var BSSMAP_FIELD_CellIdentificationList cid_list;
2255 timer T := 3.0;
2256 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002257 f_pageing_helper('001010123456789'H, cid_list, c_BtsId_all);
Harald Welte10985002017-12-12 09:29:15 +01002258
2259 /* Perform a BSSMAP Reset and wait for ACK */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02002260 BSSAP.send(ts_BSSAP_UNITDATA_req(g_bssap[0].sccp_addr_peer, g_bssap[0].sccp_addr_own, ts_BSSMAP_Reset(0, g_osmux_enabled)));
Harald Welte10985002017-12-12 09:29:15 +01002261 alt {
Neels Hofmeyrf246a922020-05-13 02:27:10 +02002262 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(g_bssap[0].sccp_addr_own, g_bssap[0].sccp_addr_peer, tr_BSSMAP_ResetAck(g_osmux_enabled))) { }
Harald Welte10985002017-12-12 09:29:15 +01002263 [] BSSAP.receive { repeat; }
2264 }
2265
Daniel Willmanncbef3982018-07-30 09:22:40 +02002266 /* Wait to avoid a possible race condition if a paging message is
2267 * received right before the reset ACK. */
2268 f_sleep(0.2);
2269
Harald Welte10985002017-12-12 09:29:15 +01002270 /* Clear the queue, it might still contain stuff like BCCH FILLING */
Philipp Maier1e6b4422018-02-23 14:02:13 +01002271 for (var integer i := 0; i < sizeof(IPA_RSL); i := i+1) {
2272 IPA_RSL[i].clear;
2273 }
Harald Welte10985002017-12-12 09:29:15 +01002274
2275 /* Wait for 3 seconds if any more PAGING CMD are received on RSL */
2276 T.start;
2277 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07002278 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Welte10985002017-12-12 09:29:15 +01002279 setverdict(fail, "Received PAGING after A-RESET");
Daniel Willmannafce8662018-07-06 23:11:32 +02002280 mtc.stop;
Harald Welte10985002017-12-12 09:29:15 +01002281 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07002282 [] IPA_RSL[1].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Welte5d1a2202017-12-13 19:51:29 +01002283 setverdict(fail, "Received PAGING after A-RESET");
Daniel Willmannafce8662018-07-06 23:11:32 +02002284 mtc.stop;
Harald Welte5d1a2202017-12-13 19:51:29 +01002285 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07002286 [] IPA_RSL[2].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Welte5d1a2202017-12-13 19:51:29 +01002287 setverdict(fail, "Received PAGING after A-RESET");
Daniel Willmannafce8662018-07-06 23:11:32 +02002288 mtc.stop;
Harald Welte5d1a2202017-12-13 19:51:29 +01002289 }
Harald Welte10985002017-12-12 09:29:15 +01002290 [] T.timeout {
2291 setverdict(pass);
2292 }
2293 }
Philipp Maier282ca4b2018-02-27 17:17:00 +01002294
2295 f_shutdown_helper();
Harald Welte10985002017-12-12 09:29:15 +01002296}
Harald Welteae026692017-12-09 01:03:01 +01002297
Philipp Maierf45824a2019-08-14 14:44:10 +02002298/* Verify how we handle unsolicited Paging Response. In case of an unsolicit
2299 * paging response we can not know which MSC is in charge, so we will blindly
2300 * pick the first configured MSC. This behavior is required in order to make
2301 * MT-CSFB calls working because in those cases the BSC can not know that the
2302 * MSC has already paged the subscriver via SGs. So any MT-CSFB call will look
2303 * like an unsolicited Paging Response to the MSC.
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01002304 */
2305testcase TC_paging_resp_unsol() runs on test_CT {
2306
2307 f_init(1);
Philipp Maierf45824a2019-08-14 14:44:10 +02002308 timer T := 5.0;
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01002309
2310 var BSSAP_N_CONNECT_ind rx_c_ind;
2311 var DchanTuple dt;
2312 var PDU_ML3_MS_NW l3 := valueof(ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010008880018'H))));
Philipp Maierf45824a2019-08-14 14:44:10 +02002313 var octetstring rr_pag_resp := enc_PDU_ML3_MS_NW(l3);
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01002314
2315 /* Send CHAN RQD and wait for allocation; acknowledge it */
2316 dt.rsl_chan_nr := f_chreq_act_ack();
2317
2318 /* Send unsolicited Paging response (no matching Paging CMD stored in BSC) */
2319 f_ipa_tx(0, ts_RSL_EST_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)), enc_PDU_ML3_MS_NW(l3)));
2320
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01002321
Philipp Maierf45824a2019-08-14 14:44:10 +02002322 /* Expevct a CR with a matching Paging response on the A-Interface */
2323 T.start;
2324 alt {
2325 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(rr_pag_resp))) {
2326 setverdict(pass);
2327 }
2328 [] BSSAP.receive {
2329 setverdict(fail, "Received unexpected message on A-Interface!");
2330 }
2331 [] T.timeout {
2332 setverdict(fail, "Received nothing on A-Interface!");
2333 }
2334 }
2335
2336 setverdict(pass);
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01002337}
2338
Harald Welte4e9b9cc2017-12-14 18:31:02 +01002339/* Test RSL link drop causes counter increment */
2340testcase TC_rsl_drop_counter() runs on test_CT {
2341 var integer rsl_fail;
2342
Harald Welte89d42e82017-12-17 16:42:41 +01002343 f_init(1);
Harald Welte4e9b9cc2017-12-14 18:31:02 +01002344
2345 rsl_fail := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "rsl_fail");
2346
2347 bts[0].rsl.vc_IPA.stop;
2348
2349 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "rsl_fail", rsl_fail+1);
2350
2351 setverdict(pass);
2352}
2353
2354/* TODO: Test OML link drop causes counter increment */
2355
Stefan Sperling830dc9d2018-02-12 21:08:28 +01002356/* The body of TC_rsl_unknown_unit_id() and TC_oml_unknown_unit_id() tests. */
2357function f_ipa_unknown_unit_id(integer mp_bsc_ipa_port) runs on test_CT return boolean {
2358 timer T := 10.0;
2359
2360 bts[0].rsl.id := "IPA-0-RSL";
2361 bts[0].rsl.vc_IPA := IPA_Emulation_CT.create(bts[0].rsl.id & "-IPA");
2362 bts[0].rsl.ccm_pars := c_IPA_default_ccm_pars;
2363 bts[0].rsl.ccm_pars.name := "Osmocom TTCN-3 BTS Simulator";
Oliver Smith92c2bdb2019-08-20 15:11:24 +02002364 bts[0].rsl.ccm_pars.unit_id := "99/0/0"; /* value which is unknown at BTS */
Stefan Sperling830dc9d2018-02-12 21:08:28 +01002365
Stefan Sperling830dc9d2018-02-12 21:08:28 +01002366 f_ipa_ctrl_start(mp_bsc_ip, mp_bsc_ctrl_port);
2367
2368 f_init_mgcp("VirtMSC");
2369
2370 /* start RSL/OML connection (XXX re-uses RSL port/protocol definitions for OML) */
2371 map(bts[0].rsl.vc_IPA:IPA_PORT, system:IPA);
2372 connect(bts[0].rsl.vc_IPA:IPA_RSL_PORT, self:IPA_RSL[0]);
2373 bts[0].rsl.vc_IPA.start(IPA_Emulation.main_client(mp_bsc_ip, mp_bsc_ipa_port, "", 10000, bts[0].rsl.ccm_pars));
2374
2375 /* wait for IPA OML link to connect and then disconnect */
2376 T.start;
2377 alt {
Vadim Yanitskiya2afacc2020-05-18 21:16:19 +07002378 [] IPA_RSL[0].receive(tr_ASP_IPA_EV(ASP_IPA_EVENT_DOWN)) {
Stefan Sperling830dc9d2018-02-12 21:08:28 +01002379 T.stop;
2380 return true;
2381 }
2382 [] IPA_RSL[0].receive { repeat }
2383 [] T.timeout {
Daniel Willmannafce8662018-07-06 23:11:32 +02002384 return false;
Stefan Sperling830dc9d2018-02-12 21:08:28 +01002385 }
2386 }
Stefan Sperling830dc9d2018-02-12 21:08:28 +01002387 return false;
2388}
2389
2390/* BSC should close an RSL connection from a BTS with unknown unit ID (OS#2714). */
2391testcase TC_rsl_unknown_unit_id() runs on test_CT {
2392 if (f_ipa_unknown_unit_id(mp_bsc_rsl_port)) {
2393 setverdict(pass);
2394 } else {
2395 setverdict(fail, "Timeout RSL waiting for connection to close");
2396 }
2397}
2398
2399
2400/* BSC should close an RSL connection from a BTS with unknown unit ID (OS#2714). */
2401testcase TC_oml_unknown_unit_id() runs on test_CT {
2402 if (f_ipa_unknown_unit_id(mp_bsc_oml_port)) {
2403 setverdict(pass);
2404 } else {
2405 setverdict(fail, "Timeout OML waiting for connection to close");
2406 }
2407}
2408
2409
Harald Weltec1a2fff2017-12-17 11:06:19 +01002410/***********************************************************************
Harald Welte6811d102019-04-14 22:23:14 +02002411 * "New world" test cases using RSL_Emulation + RAN_Emulation
Harald Weltec1a2fff2017-12-17 11:06:19 +01002412 ***********************************************************************/
2413
Harald Welte6811d102019-04-14 22:23:14 +02002414import from RAN_Emulation all;
Harald Weltec1a2fff2017-12-17 11:06:19 +01002415import from RSL_Emulation all;
2416import from MSC_ConnectionHandler all;
2417
2418type function void_fn(charstring id) runs on MSC_ConnHdlr;
2419
Harald Welte336820c2018-05-31 20:34:52 +02002420/* helper function to create and connect a MSC_ConnHdlr component */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02002421private function f_connect_handler(inout MSC_ConnHdlr vc_conn, integer bssap_idx := 0) runs on test_CT {
2422 connect(vc_conn:RAN, g_bssap[bssap_idx].vc_RAN:PROC);
Daniel Willmann191e0d92018-01-17 12:44:35 +01002423 connect(vc_conn:MGCP_PROC, vc_MGCP:MGCP_PROC);
Harald Weltec1a2fff2017-12-17 11:06:19 +01002424 connect(vc_conn:RSL, bts[0].rsl.vc_RSL:CLIENT_PT);
Harald Weltef70df652018-01-29 22:00:23 +01002425 connect(vc_conn:RSL_PROC, bts[0].rsl.vc_RSL:RSL_PROC);
Philipp Maier88f4ae82018-03-01 14:00:58 +01002426 if (isvalue(bts[1])) {
Philipp Maier956a92f2018-02-16 10:58:07 +01002427 connect(vc_conn:RSL1, bts[1].rsl.vc_RSL:CLIENT_PT);
2428 connect(vc_conn:RSL1_PROC, bts[1].rsl.vc_RSL:RSL_PROC);
2429 }
Neels Hofmeyr91401012019-07-11 00:42:35 +02002430 if (isvalue(bts[2])) {
2431 connect(vc_conn:RSL2, bts[2].rsl.vc_RSL:CLIENT_PT);
2432 connect(vc_conn:RSL2_PROC, bts[2].rsl.vc_RSL:RSL_PROC);
2433 }
Neels Hofmeyrf246a922020-05-13 02:27:10 +02002434 connect(vc_conn:BSSAP, g_bssap[bssap_idx].vc_RAN:CLIENT);
Daniel Willmann191e0d92018-01-17 12:44:35 +01002435 connect(vc_conn:MGCP, vc_MGCP:MGCP_CLIENT);
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02002436 connect(vc_conn:MGCP_MULTI, vc_MGCP:MGCP_CLIENT_MULTI);
Harald Welte336820c2018-05-31 20:34:52 +02002437}
2438
2439function f_start_handler(void_fn fn, template (omit) TestHdlrParams pars := omit)
2440runs on test_CT return MSC_ConnHdlr {
2441 var charstring id := testcasename();
2442 var MSC_ConnHdlr vc_conn;
Neels Hofmeyrf246a922020-05-13 02:27:10 +02002443 var integer bssap_idx := 0;
2444 if (isvalue(pars)) {
2445 bssap_idx := valueof(pars).mscpool.bssap_idx;
2446 }
Harald Welte336820c2018-05-31 20:34:52 +02002447 vc_conn := MSC_ConnHdlr.create(id);
Neels Hofmeyrf246a922020-05-13 02:27:10 +02002448 f_connect_handler(vc_conn, bssap_idx);
Harald Weltea0630032018-03-20 21:09:55 +01002449 vc_conn.start(f_handler_init(fn, id, pars));
Harald Weltec1a2fff2017-12-17 11:06:19 +01002450 return vc_conn;
2451}
2452
Harald Weltea0630032018-03-20 21:09:55 +01002453/* first function inside ConnHdlr component; sets g_pars + starts function */
2454private function f_handler_init(void_fn fn, charstring id, template (omit) TestHdlrParams pars := omit)
2455runs on MSC_ConnHdlr {
2456 if (isvalue(pars)) {
2457 g_pars := valueof(pars);
2458 }
2459 fn.apply(id);
2460}
2461
Harald Welte3c86ea02018-05-10 22:28:05 +02002462/* Establish signalling channel (non-assignment case) followed by cipher mode */
2463private function f_tc_ciph_mode_a5(charstring id) runs on MSC_ConnHdlr {
Harald Welteed848512018-05-24 22:27:58 +02002464 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2465 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte3c86ea02018-05-10 22:28:05 +02002466 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeSIGNAL);
Philipp Maier23000732018-05-18 11:25:37 +02002467 ass_cmd.pdu.bssmap.assignmentRequest.circuitIdentityCode := omit;
2468 ass_cmd.pdu.bssmap.assignmentRequest.aoIPTransportLayer := omit;
2469 exp_compl.pdu.bssmap.assignmentComplete.circuitIdentityCode := omit;
2470 exp_compl.pdu.bssmap.assignmentComplete.aoIPTransportLayer := omit;
Harald Welte3c86ea02018-05-10 22:28:05 +02002471
Philipp Maier23000732018-05-18 11:25:37 +02002472 f_establish_fully(ass_cmd, exp_compl);
Harald Welte3c86ea02018-05-10 22:28:05 +02002473}
2474testcase TC_ciph_mode_a5_0() runs on test_CT {
2475 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02002476 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02002477 pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
2478
2479 f_init(1, true);
2480 f_sleep(1.0);
2481 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
2482 vc_conn.done;
2483}
2484testcase TC_ciph_mode_a5_1() runs on test_CT {
2485 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02002486 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02002487 pars.encr := valueof(t_EncrParams('02'O, f_rnd_octstring(8)));
2488
2489 f_init(1, true);
2490 f_sleep(1.0);
2491 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
2492 vc_conn.done;
2493}
2494testcase TC_ciph_mode_a5_3() runs on test_CT {
2495 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02002496 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02002497 pars.encr := valueof(t_EncrParams('08'O, f_rnd_octstring(8)));
2498
2499 f_init(1, true);
2500 f_sleep(1.0);
2501 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
2502 vc_conn.done;
2503}
2504
2505
2506/* establish initial channel, enable ciphering followed by assignment to ciphered channel */
Harald Welte651fcdc2018-05-10 20:23:16 +02002507private function f_tc_assignment_fr_a5(charstring id) runs on MSC_ConnHdlr {
Harald Welteed848512018-05-24 22:27:58 +02002508 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2509 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Weltec1a2fff2017-12-17 11:06:19 +01002510
Harald Welte552620d2017-12-16 23:21:36 +01002511 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2512 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Welte73cd2712017-12-17 00:44:52 +01002513
Harald Weltea0630032018-03-20 21:09:55 +01002514 f_establish_fully(ass_cmd, exp_compl);
Harald Welte552620d2017-12-16 23:21:36 +01002515}
Harald Welte552620d2017-12-16 23:21:36 +01002516testcase TC_assignment_fr_a5_0() runs on test_CT {
2517 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02002518 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02002519 pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
Harald Welte552620d2017-12-16 23:21:36 +01002520
Harald Welte89d42e82017-12-17 16:42:41 +01002521 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01002522 f_sleep(1.0);
Harald Welte651fcdc2018-05-10 20:23:16 +02002523 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
Harald Welte552620d2017-12-16 23:21:36 +01002524 vc_conn.done;
2525}
Harald Welte552620d2017-12-16 23:21:36 +01002526testcase TC_assignment_fr_a5_1() runs on test_CT {
Harald Weltec1a2fff2017-12-17 11:06:19 +01002527 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02002528 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02002529 pars.encr := valueof(t_EncrParams('02'O, f_rnd_octstring(8)));
Harald Weltec1a2fff2017-12-17 11:06:19 +01002530
Harald Welte89d42e82017-12-17 16:42:41 +01002531 f_init(1, true);
Harald Weltec1a2fff2017-12-17 11:06:19 +01002532 f_sleep(1.0);
Harald Welte651fcdc2018-05-10 20:23:16 +02002533 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
2534 vc_conn.done;
2535}
2536testcase TC_assignment_fr_a5_3() runs on test_CT {
2537 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02002538 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02002539 pars.encr := valueof(t_EncrParams('08'O, f_rnd_octstring(8)));
Harald Weltec1a2fff2017-12-17 11:06:19 +01002540
Harald Welte651fcdc2018-05-10 20:23:16 +02002541 f_init(1, true);
2542 f_sleep(1.0);
2543 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
Harald Weltec1a2fff2017-12-17 11:06:19 +01002544 vc_conn.done;
2545}
2546
Harald Welte552620d2017-12-16 23:21:36 +01002547/* Expect ASSIGNMENT FAIL if mandatory IE is missing */
2548private function f_tc_assignment_fr_a5_1_codec_missing(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02002549 g_pars := f_gen_test_hdlr_pars();
Harald Welte552620d2017-12-16 23:21:36 +01002550 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +02002551 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte552620d2017-12-16 23:21:36 +01002552 const OCT8 kc := '0001020304050607'O;
2553
2554 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02002555 /* Omit: ass_cmd.pdu.bssmap.assignmentRequest.codecList */
2556
Harald Weltea0630032018-03-20 21:09:55 +01002557 f_establish_fully(ass_cmd, exp_fail);
Harald Welte552620d2017-12-16 23:21:36 +01002558}
Harald Welte552620d2017-12-16 23:21:36 +01002559testcase TC_assignment_fr_a5_1_codec_missing() runs on test_CT {
2560 var MSC_ConnHdlr vc_conn;
2561
Harald Welte89d42e82017-12-17 16:42:41 +01002562 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01002563 f_sleep(1.0);
2564
Harald Welte8863fa12018-05-10 20:15:27 +02002565 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5_1_codec_missing));
Harald Welte552620d2017-12-16 23:21:36 +01002566 vc_conn.done;
2567}
2568
Harald Welte552620d2017-12-16 23:21:36 +01002569private function f_tc_assignment_fr_a5_4(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02002570 g_pars := f_gen_test_hdlr_pars();
Harald Welteed848512018-05-24 22:27:58 +02002571 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2572 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte552620d2017-12-16 23:21:36 +01002573 const OCT8 kc := '0001020304050607'O;
2574 const OCT16 kc128 := kc & kc;
2575
2576 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2577 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Weltea0630032018-03-20 21:09:55 +01002578 f_establish_fully(ass_cmd, exp_compl);
Harald Welte38b2a102017-12-23 02:42:58 +01002579 f_cipher_mode('10'O, kc, kc128, true);
Harald Welte552620d2017-12-16 23:21:36 +01002580 /* TODO: expect GSM0808_CAUSE_CIPHERING_ALGORITHM_NOT_SUPPORTED cause value */
Harald Welte552620d2017-12-16 23:21:36 +01002581}
Harald Welte552620d2017-12-16 23:21:36 +01002582testcase TC_assignment_fr_a5_4() runs on test_CT {
2583 var MSC_ConnHdlr vc_conn;
2584
Harald Welte89d42e82017-12-17 16:42:41 +01002585 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01002586 f_sleep(1.0);
2587
Harald Welte8863fa12018-05-10 20:15:27 +02002588 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5_4));
Harald Welte552620d2017-12-16 23:21:36 +01002589 vc_conn.done;
2590}
2591
2592
Harald Welte4532e0a2017-12-23 02:05:44 +01002593private function f_tc_assignment_sign(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02002594 g_pars := f_gen_test_hdlr_pars();
Harald Welte4532e0a2017-12-23 02:05:44 +01002595 var template PDU_BSSAP exp_compl := tr_BSSMAP_AssignmentComplete(omit, omit);
Philipp Maier48604732018-10-09 15:00:37 +02002596 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte4532e0a2017-12-23 02:05:44 +01002597 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeSIGNAL);
Harald Weltea0630032018-03-20 21:09:55 +01002598 f_establish_fully(ass_cmd, exp_compl);
Harald Welte4532e0a2017-12-23 02:05:44 +01002599}
2600
2601testcase TC_assignment_sign() runs on test_CT {
2602 var MSC_ConnHdlr vc_conn;
2603
2604 f_init(1, true);
2605 f_sleep(1.0);
2606
Harald Welte8863fa12018-05-10 20:15:27 +02002607 vc_conn := f_start_handler(refers(f_tc_assignment_sign));
Harald Welte4532e0a2017-12-23 02:05:44 +01002608 vc_conn.done;
2609}
2610
Harald Welte60aa5762018-03-21 19:33:13 +01002611/***********************************************************************
2612 * Codec (list) testing
2613 ***********************************************************************/
2614
2615/* check if the given rsl_mode is compatible with the a_elem */
2616private function f_match_codec(BSSMAP_FIELD_CodecElement a_elem, RSL_IE_ChannelMode rsl_mode)
2617return boolean {
2618 select (a_elem.codecType) {
2619 case (GSM_FR) {
2620 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM1))) {
2621 return true;
2622 }
2623 }
2624 case (GSM_HR) {
2625 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1))) {
2626 return true;
2627 }
2628 }
2629 case (GSM_EFR) {
2630 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM2))) {
2631 return true;
2632 }
2633 }
2634 case (FR_AMR) {
2635 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM3))) {
2636 return true;
2637 }
2638 }
2639 case (HR_AMR) {
2640 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM3))) {
2641 return true;
2642 }
2643 }
2644 case else { }
2645 }
2646 return false;
2647}
2648
2649/* check if the given rsl_mode is compatible with the a_list */
2650private function f_match_codecs(BSSMAP_IE_SpeechCodecList a_list, RSL_IE_ChannelMode rsl_mode)
2651return boolean {
2652 for (var integer i := 0; i < sizeof(a_list); i := i+1) {
2653 if (f_match_codec(a_list.codecElements[i], rsl_mode)) {
2654 return true;
2655 }
2656 }
2657 return false;
2658}
2659
2660/* determine BSSMAP_IE_ChannelType from *first* element of BSSMAP_FIELD_CodecElement */
Philipp Maier61f6b572018-07-06 14:03:38 +02002661function f_BSSMAP_chtype_from_codec(BSSMAP_FIELD_CodecElement a_elem)
Harald Welte60aa5762018-03-21 19:33:13 +01002662return BSSMAP_IE_ChannelType {
2663 /* FIXME: actually look at all elements of BSSMAP_IE_SpeechCodecList */
2664 var BSSMAP_IE_ChannelType ret := valueof(ts_BSSMAP_IE_ChannelType);
2665 select (a_elem.codecType) {
2666 case (GSM_FR) {
2667 ret.channelRateAndType := ChRate_TCHF;
2668 ret.speechId_DataIndicator := Spdi_TCHF_FR;
2669 }
2670 case (GSM_HR) {
2671 ret.channelRateAndType := ChRate_TCHH;
2672 ret.speechId_DataIndicator := Spdi_TCHH_HR;
2673 }
2674 case (GSM_EFR) {
2675 ret.channelRateAndType := ChRate_TCHF;
2676 ret.speechId_DataIndicator := Spdi_TCHF_EFR;
2677 }
2678 case (FR_AMR) {
2679 ret.channelRateAndType := ChRate_TCHF;
2680 ret.speechId_DataIndicator := Spdi_TCHF_AMR;
2681 }
2682 case (HR_AMR) {
2683 ret.channelRateAndType := ChRate_TCHH;
2684 ret.speechId_DataIndicator := Spdi_TCHH_AMR;
2685 }
2686 case else {
2687 setverdict(fail, "Unsupported codec ", a_elem);
Daniel Willmannafce8662018-07-06 23:11:32 +02002688 mtc.stop;
Harald Welte60aa5762018-03-21 19:33:13 +01002689 }
2690 }
2691 return ret;
2692}
2693
Harald Weltea63b9102018-03-22 20:36:16 +01002694private function f_rsl_chmod_tmpl_from_codec(BSSMAP_FIELD_CodecElement a_elem)
2695return template RSL_IE_Body {
2696 var template RSL_IE_Body mode_ie := {
2697 chan_mode := {
2698 len := ?,
2699 reserved := ?,
2700 dtx_d := ?,
2701 dtx_u := ?,
2702 spd_ind := RSL_SPDI_SPEECH,
2703 ch_rate_type := -,
2704 coding_alg_rate := -
2705 }
2706 }
2707
2708 select (a_elem.codecType) {
2709 case (GSM_FR) {
2710 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
2711 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM1;
2712 }
2713 case (GSM_HR) {
2714 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_H;
2715 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM1;
2716 }
2717 case (GSM_EFR) {
2718 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
2719 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM2;
2720 }
2721 case (FR_AMR) {
2722 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
2723 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM3;
2724 }
2725 case (HR_AMR) {
2726 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_H;
2727 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM3;
2728 }
2729 }
2730 return mode_ie;
2731}
2732
Harald Welte60aa5762018-03-21 19:33:13 +01002733type record CodecListTest {
2734 BSSMAP_IE_SpeechCodecList codec_list,
2735 charstring id
2736}
2737type record of CodecListTest CodecListTests
2738
2739private function f_TC_assignment_codec(charstring id) runs on MSC_ConnHdlr {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02002740 var PDU_BSSAP ass_cmd := f_gen_ass_req(g_pars.use_osmux);
2741 var template PDU_BSSAP exp_compl := f_gen_exp_compl(g_pars.use_osmux);
Harald Welte60aa5762018-03-21 19:33:13 +01002742
2743 /* puzzle together the ASSIGNMENT REQ for given codec[s] */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02002744 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welte79f3f542018-05-25 20:02:37 +02002745 ass_cmd.pdu.bssmap.assignmentRequest.codecList := g_pars.ass_codec_list;
2746 exp_compl.pdu.bssmap.assignmentComplete.speechCodec.codecElements[0] :=
2747 g_pars.ass_codec_list.codecElements[0];
Philipp Maierd0e64b02019-03-13 14:15:23 +01002748 if (isvalue(g_pars.expect_mr_s0_s7)) {
2749 exp_compl.pdu.bssmap.assignmentComplete.speechCodec.codecElements[0].s0_7 :=
2750 g_pars.expect_mr_s0_s7;
2751 }
Harald Welte79f3f542018-05-25 20:02:37 +02002752 }
Harald Welte60aa5762018-03-21 19:33:13 +01002753 ass_cmd.pdu.bssmap.assignmentRequest.channelType :=
2754 f_BSSMAP_chtype_from_codec(g_pars.ass_codec_list.codecElements[0]);
Harald Welte60aa5762018-03-21 19:33:13 +01002755 log("expecting ASS COMPL like this: ", exp_compl);
2756
2757 f_establish_fully(ass_cmd, exp_compl);
Harald Weltea63b9102018-03-22 20:36:16 +01002758
2759 /* Verify that the RSL-side activation actually matches our expectations */
2760 var RSL_Message rsl := f_rslem_get_last_act(RSL_PROC, 0, g_chan_nr);
2761
2762 var RSL_IE_Body mode_ie;
2763 if (f_rsl_find_ie(rsl, RSL_IE_CHAN_MODE, mode_ie) == false) {
2764 setverdict(fail, "Couldn't find CHAN_MODE IE");
Daniel Willmannafce8662018-07-06 23:11:32 +02002765 mtc.stop;
Harald Weltea63b9102018-03-22 20:36:16 +01002766 }
2767 var template RSL_IE_Body t_mode_ie := f_rsl_chmod_tmpl_from_codec(g_pars.ass_codec_list.codecElements[0]);
2768 if (not match(mode_ie, t_mode_ie)) {
2769 setverdict(fail, "RSL Channel Mode IE doesn't match expectation");
2770 }
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02002771
2772 var RSL_IE_Body mr_conf;
2773 if (g_pars.expect_mr_conf_ie != omit) {
2774 if (f_rsl_find_ie(rsl, RSL_IE_MR_CONFIG, mr_conf) == false) {
2775 setverdict(fail, "Missing MR CONFIG IE in RSL Chan Activ");
Daniel Willmannafce8662018-07-06 23:11:32 +02002776 mtc.stop;
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02002777 }
2778 log("found RSL MR CONFIG IE: ", mr_conf);
2779
2780 if (not match(mr_conf, g_pars.expect_mr_conf_ie)) {
2781 setverdict(fail, "RSL MR CONFIG IE does not match expectation. Expected: ",
2782 g_pars.expect_mr_conf_ie);
2783 }
2784 } else {
2785 if (f_rsl_find_ie(rsl, RSL_IE_MR_CONFIG, mr_conf) == true) {
2786 log("found RSL MR CONFIG IE: ", mr_conf);
2787 setverdict(fail, "Found MR CONFIG IE in RSL Chan Activ, expecting omit");
Daniel Willmannafce8662018-07-06 23:11:32 +02002788 mtc.stop;
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02002789 }
2790 }
Harald Welte60aa5762018-03-21 19:33:13 +01002791}
2792
Philipp Maierd0e64b02019-03-13 14:15:23 +01002793private function f_TC_assignment_codec_fail(charstring id) runs on MSC_ConnHdlr {
2794
2795 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2796 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
2797
2798 /* puzzle together the ASSIGNMENT REQ for given codec[s] */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02002799 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Philipp Maierd0e64b02019-03-13 14:15:23 +01002800 ass_cmd.pdu.bssmap.assignmentRequest.codecList := g_pars.ass_codec_list;
2801 }
2802 ass_cmd.pdu.bssmap.assignmentRequest.channelType :=
2803 f_BSSMAP_chtype_from_codec(g_pars.ass_codec_list.codecElements[0]);
2804 log("expecting ASS FAIL like this: ", exp_fail);
2805
2806 f_establish_fully(ass_cmd, exp_fail);
2807}
2808
Harald Welte60aa5762018-03-21 19:33:13 +01002809testcase TC_assignment_codec_fr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02002810 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01002811 var MSC_ConnHdlr vc_conn;
2812
2813 f_init(1, true);
2814 f_sleep(1.0);
2815
2816 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Welte8863fa12018-05-10 20:15:27 +02002817 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01002818 vc_conn.done;
2819}
2820
2821testcase TC_assignment_codec_hr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02002822 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01002823 var MSC_ConnHdlr vc_conn;
2824
2825 f_init(1, true);
2826 f_sleep(1.0);
2827
2828 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
Harald Welte8863fa12018-05-10 20:15:27 +02002829 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01002830 vc_conn.done;
2831}
2832
2833testcase TC_assignment_codec_efr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02002834 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01002835 var MSC_ConnHdlr vc_conn;
2836
2837 f_init(1, true);
2838 f_sleep(1.0);
2839
2840 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecEFR}));
Harald Welte8863fa12018-05-10 20:15:27 +02002841 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01002842 vc_conn.done;
2843}
2844
Philipp Maierd0e64b02019-03-13 14:15:23 +01002845/* Allow 5,90k only (current default config) */
2846private function f_allow_amr_rate_5_90k() runs on test_CT {
2847 f_vty_enter_cfg_msc(BSCVTY, 0);
2848 f_vty_transceive(BSCVTY, "amr-config 12_2k forbidden");
2849 f_vty_transceive(BSCVTY, "amr-config 10_2k forbidden");
2850 f_vty_transceive(BSCVTY, "amr-config 7_95k forbidden");
2851 f_vty_transceive(BSCVTY, "amr-config 7_40k forbidden");
2852 f_vty_transceive(BSCVTY, "amr-config 6_70k forbidden");
2853 f_vty_transceive(BSCVTY, "amr-config 5_90k allowed");
2854 f_vty_transceive(BSCVTY, "amr-config 5_15k forbidden");
2855 f_vty_transceive(BSCVTY, "amr-config 4_75k forbidden");
2856 f_vty_transceive(BSCVTY, "exit");
2857 f_vty_transceive(BSCVTY, "exit");
2858}
2859
2860/* Allow 4,75k, 5,90k, 4,70k and 12,2k, which are the most common rates
2861 * ("Config-NB-Code = 1") */
2862private function f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k() runs on test_CT {
2863 f_vty_enter_cfg_msc(BSCVTY, 0);
2864 f_vty_transceive(BSCVTY, "amr-config 12_2k allowed");
2865 f_vty_transceive(BSCVTY, "amr-config 10_2k forbidden");
2866 f_vty_transceive(BSCVTY, "amr-config 7_95k forbidden");
2867 f_vty_transceive(BSCVTY, "amr-config 7_40k allowed");
2868 f_vty_transceive(BSCVTY, "amr-config 6_70k forbidden");
2869 f_vty_transceive(BSCVTY, "amr-config 5_90k allowed");
2870 f_vty_transceive(BSCVTY, "amr-config 5_15k forbidden");
2871 f_vty_transceive(BSCVTY, "amr-config 4_75k allowed");
2872 f_vty_transceive(BSCVTY, "exit");
2873 f_vty_transceive(BSCVTY, "exit");
2874}
2875
Harald Welte60aa5762018-03-21 19:33:13 +01002876testcase TC_assignment_codec_amr_f() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02002877 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01002878 var MSC_ConnHdlr vc_conn;
Philipp Maier7695a0d2018-09-27 17:52:14 +02002879
2880 /* Note: This setups the codec configuration. The parameter payload in
2881 * mr_conf must be consistant with the parameter codecElements in pars
2882 * and also must match the amr-config in osmo-bsc.cfg! */
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02002883 var RSL_IE_Body mr_conf := {
2884 other := {
2885 len := 2,
2886 payload := '2804'O
2887 }
2888 };
Harald Welte60aa5762018-03-21 19:33:13 +01002889
Philipp Maier7695a0d2018-09-27 17:52:14 +02002890 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
Philipp Maier806f8f12019-03-12 12:13:41 +01002891 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
Philipp Maier7695a0d2018-09-27 17:52:14 +02002892 pars.ass_codec_list.codecElements[0].s8_15 := '01010111'B;
2893 pars.expect_mr_conf_ie := mr_conf;
2894
Harald Welte60aa5762018-03-21 19:33:13 +01002895 f_init(1, true);
2896 f_sleep(1.0);
2897
Harald Welte8863fa12018-05-10 20:15:27 +02002898 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01002899 vc_conn.done;
2900}
2901
2902testcase TC_assignment_codec_amr_h() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02002903 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01002904 var MSC_ConnHdlr vc_conn;
Philipp Maier7695a0d2018-09-27 17:52:14 +02002905
2906 /* See note above */
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02002907 var RSL_IE_Body mr_conf := {
2908 other := {
2909 len := 2,
2910 payload := '2804'O
2911 }
2912 };
Harald Welte60aa5762018-03-21 19:33:13 +01002913
Philipp Maier7695a0d2018-09-27 17:52:14 +02002914 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
Philipp Maier806f8f12019-03-12 12:13:41 +01002915 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
Philipp Maier7695a0d2018-09-27 17:52:14 +02002916 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
2917 pars.expect_mr_conf_ie := mr_conf;
2918
Harald Welte60aa5762018-03-21 19:33:13 +01002919 f_init(1, true);
2920 f_sleep(1.0);
2921
Harald Welte8863fa12018-05-10 20:15:27 +02002922 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01002923 vc_conn.done;
2924}
2925
Philipp Maierd0e64b02019-03-13 14:15:23 +01002926function f_TC_assignment_codec_amr(boolean fr, octetstring mrconf, bitstring s8_s0, bitstring exp_s8_s0)
2927runs on test_CT {
2928
2929 var TestHdlrParams pars := f_gen_test_hdlr_pars();
2930 var MSC_ConnHdlr vc_conn;
2931
2932 /* See note above */
2933 var RSL_IE_Body mr_conf := {
2934 other := {
2935 len := lengthof(mrconf),
2936 payload := mrconf
2937 }
2938 };
2939
2940 if (fr) {
2941 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
2942 } else {
2943 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
2944 }
2945 pars.ass_codec_list.codecElements[0].s0_7 := s8_s0;
2946 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
2947 pars.expect_mr_conf_ie := mr_conf;
2948 pars.expect_mr_s0_s7 := exp_s8_s0;
2949
2950 f_init(1, true);
2951 f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k();
2952 f_sleep(1.0);
2953
2954 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
2955 vc_conn.done;
2956 f_allow_amr_rate_5_90k();
2957}
2958
2959function f_TC_assignment_codec_amr_fail(boolean fr, bitstring s8_s0)
2960runs on test_CT {
2961
2962 var TestHdlrParams pars := f_gen_test_hdlr_pars();
2963 var MSC_ConnHdlr vc_conn;
2964
2965 if (fr) {
2966 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
2967 } else {
2968 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
2969 }
2970 pars.ass_codec_list.codecElements[0].s0_7 := s8_s0;
2971 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
2972
2973 f_init(1, true);
2974 f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k();
2975 f_sleep(1.0);
2976
2977 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fail), pars);
2978 vc_conn.done;
2979 f_allow_amr_rate_5_90k();
2980}
2981
2982
2983/* Set S1, we expect an AMR multirate configuration IE with all four rates
2984 * set. */
2985testcase TC_assignment_codec_amr_f_S1() runs on test_CT {
2986 f_TC_assignment_codec_amr(true, '289520882208'O, '00000010'B, '00000010'B);
2987}
2988
2989/* Set S1, we expect an AMR multirate configuration IE with the lower three
2990 * rates set. */
2991testcase TC_assignment_codec_amr_h_S1() runs on test_CT {
2992 f_TC_assignment_codec_amr(false, '2815208820'O, '00000010'B, '00000010'B);
2993}
2994
2995/* Set S1 and two other rates, we expect an AMR MULTIRATE CONFIGURATION IE with
2996 * all four rates (and only S1 set in the ASSIGNMENT COMPLETE) */
2997testcase TC_assignment_codec_amr_f_S124() runs on test_CT {
2998 f_TC_assignment_codec_amr(true, '289520882208'O, '00010110'B, '00000010'B);
2999}
3000
3001/* Set S1 and two other rates, we expect an AMR MULTIRATE CONFIGURATION IE with
3002 * all four rates (and only S1 set in the ASSIGNMENT COMPLETE) */
3003testcase TC_assignment_codec_amr_h_S124() runs on test_CT {
3004 f_TC_assignment_codec_amr(false, '2815208820'O, '00010110'B, '00000010'B);
3005}
3006
3007/* The following block of tests selects more and more rates until all four
3008 * possible rates are in the active set (full rate) */
3009testcase TC_assignment_codec_amr_f_S0() runs on test_CT {
3010 f_TC_assignment_codec_amr(true, '2801'O, '00000001'B, '00000001'B);
3011}
3012
3013testcase TC_assignment_codec_amr_f_S02() runs on test_CT {
3014 f_TC_assignment_codec_amr(true, '28052080'O, '00000101'B, '00000101'B);
3015}
3016
3017testcase TC_assignment_codec_amr_f_S024() runs on test_CT {
3018 f_TC_assignment_codec_amr(true, '2815208820'O, '00010101'B, '00010101'B);
3019}
3020
3021testcase TC_assignment_codec_amr_f_S0247() runs on test_CT {
3022 f_TC_assignment_codec_amr(true, '289520882208'O, '10010101'B, '10010101'B);
3023}
3024
3025/* The following block of tests selects more and more rates until all three
3026 * possible rates are in the active set (half rate) */
3027testcase TC_assignment_codec_amr_h_S0() runs on test_CT {
3028 f_TC_assignment_codec_amr(false, '2801'O, '00000001'B, '00000001'B);
3029}
3030
3031testcase TC_assignment_codec_amr_h_S02() runs on test_CT {
3032 f_TC_assignment_codec_amr(false, '28052080'O, '00000101'B, '00000101'B);
3033}
3034
3035testcase TC_assignment_codec_amr_h_S024() runs on test_CT {
3036 f_TC_assignment_codec_amr(false, '2815208820'O, '00010101'B, '00010101'B);
3037}
3038
3039/* The following block tests what happens when the MSC does offer rate
3040 * configurations that are not supported by the BSC. Normally such situations
3041 * should not happen because the MSC gets informed by the BSC in advance via
3042 * the L3 COMPLETE message which rates are applicable. The MSC should not try
3043 * to offer rates that are not applicable anyway. */
3044
3045testcase TC_assignment_codec_amr_h_S0247() runs on test_CT {
3046 /* Try to include 12,2k in into the active set even though the channel
3047 * is half rate only. The BSC is expected to remove the 12,0k */
3048 f_TC_assignment_codec_amr(false, '2815208820'O, '10010101'B, '00010101'B);
3049}
3050
3051testcase TC_assignment_codec_amr_f_S01234567() runs on test_CT {
3052 /* See what happens when all rates are selected at once. Since then
3053 * Also S1 is selected, this setting will be prefered and we should
3054 * get 12.2k, 7,40k, 5,90k, and 4,75k in the active set. */
3055 f_TC_assignment_codec_amr(true, '289520882208'O, '11111111'B, '00000010'B);
3056}
3057
3058testcase TC_assignment_codec_amr_f_S0234567() runs on test_CT {
3059 /* Same as above, but with S1 missing, the MSC is then expected to
3060 * select the currently supported rates, which are also 12.2k, 7,40k,
3061 * 5,90k, and 4,75k, into the active set. */
3062 f_TC_assignment_codec_amr(true, '289520882208'O, '11111101'B, '10010101'B);
3063}
3064
3065testcase TC_assignment_codec_amr_f_zero() runs on test_CT {
3066 /* Try to select no rates at all */
3067 f_TC_assignment_codec_amr_fail(true, '00000000'B);
3068}
3069
3070testcase TC_assignment_codec_amr_f_unsupp() runs on test_CT {
3071 /* Try to select only unsupported rates */
3072 f_TC_assignment_codec_amr_fail(true, '01101000'B);
3073}
3074
3075testcase TC_assignment_codec_amr_h_S7() runs on test_CT {
3076 /* Try to select 12,2k for half rate */
3077 f_TC_assignment_codec_amr_fail(false, '10000000'B);
3078}
3079
Philipp Maierac09bfc2019-01-08 13:41:39 +01003080private function f_disable_all_tch_f() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01003081 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 1 sub-slot 0 borken");
3082 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 2 sub-slot 0 borken");
3083 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 3 sub-slot 0 borken");
3084 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 4 sub-slot 0 borken");
Philipp Maierac09bfc2019-01-08 13:41:39 +01003085}
3086
3087private function f_disable_all_tch_h() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01003088 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 0 borken");
3089 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 1 borken");
Philipp Maierac09bfc2019-01-08 13:41:39 +01003090}
3091
3092private function f_enable_all_tch() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01003093 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 1 sub-slot 0 unused");
3094 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 2 sub-slot 0 unused");
3095 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 3 sub-slot 0 unused");
3096 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 4 sub-slot 0 unused");
3097 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 0 unused");
3098 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 1 unused");
Philipp Maierac09bfc2019-01-08 13:41:39 +01003099}
3100
3101/* Allow HR only */
3102private function f_TC_assignment_codec_xr_exhausted_req_hr(charstring id) runs on MSC_ConnHdlr {
3103 g_pars := f_gen_test_hdlr_pars();
3104 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3105 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3106 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3107 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '09'O;
3108 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '05'O;
3109 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
3110 f_establish_fully(ass_cmd, exp_compl);
3111}
3112
3113/* Allow FR only */
3114private function f_TC_assignment_codec_xr_exhausted_req_fr(charstring id) runs on MSC_ConnHdlr {
3115 g_pars := f_gen_test_hdlr_pars();
3116 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3117 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3118 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3119 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '08'O;
3120 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '01'O;
3121 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
3122 f_establish_fully(ass_cmd, exp_compl);
3123}
3124
3125/* Allow HR only (expect assignment failure) */
3126private function f_TC_assignment_codec_xr_exhausted_req_hr_fail(charstring id) runs on MSC_ConnHdlr {
3127 g_pars := f_gen_test_hdlr_pars();
3128 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3129 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
3130 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3131 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '09'O;
3132 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '05'O;
3133 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
3134 f_establish_fully(ass_cmd, exp_fail);
3135}
3136
3137/* Allow FR only (expect assignment failure) */
3138private function f_TC_assignment_codec_xr_exhausted_req_fr_fail(charstring id) runs on MSC_ConnHdlr {
3139 g_pars := f_gen_test_hdlr_pars();
3140 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3141 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
3142 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3143 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '08'O;
3144 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '01'O;
3145 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
3146 f_establish_fully(ass_cmd, exp_fail);
3147}
3148
3149/* Allow FR and HR, but prefer FR */
3150private function f_TC_assignment_codec_fr_exhausted_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
3151 g_pars := f_gen_test_hdlr_pars();
3152 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3153 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3154 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3155 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
3156 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
3157 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
3158 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
3159 f_establish_fully(ass_cmd, exp_compl);
3160}
3161
3162/* Allow FR and HR, but prefer HR */
3163private function f_TC_assignment_codec_fr_exhausted_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
3164 g_pars := f_gen_test_hdlr_pars();
3165 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3166 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3167 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3168 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
3169 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
3170 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
3171 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
3172 f_establish_fully(ass_cmd, exp_compl);
3173}
3174
3175/* Allow FR and HR, but prefer FR */
3176private function f_TC_assignment_codec_hr_exhausted_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
3177 g_pars := f_gen_test_hdlr_pars();
3178 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3179 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3180 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3181 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
3182 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
3183 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
3184 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
3185 f_establish_fully(ass_cmd, exp_compl);
3186}
3187
3188/* Allow FR and HR, but prefer HR */
3189private function f_TC_assignment_codec_hr_exhausted_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
3190 g_pars := f_gen_test_hdlr_pars();
3191 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3192 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3193 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3194 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
3195 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
3196 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
3197 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
3198 f_establish_fully(ass_cmd, exp_compl);
3199}
3200
3201/* Request a HR channel while all FR channels are exhausted, this is expected
3202 * to work without conflicts */
3203testcase TC_assignment_codec_fr_exhausted_req_hr() runs on test_CT {
3204 var MSC_ConnHdlr vc_conn;
3205 f_init(1, true);
3206 f_sleep(1.0);
3207 f_enable_all_tch();
3208 f_disable_all_tch_f();
3209 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_hr));
3210 vc_conn.done;
3211 f_enable_all_tch();
3212 setverdict(pass);
3213}
3214
3215/* Request a FR channel while all FR channels are exhausted, this is expected
3216 * to fail. */
3217testcase TC_assignment_codec_fr_exhausted_req_fr() runs on test_CT {
3218 var MSC_ConnHdlr vc_conn;
3219 f_init(1, true);
3220 f_sleep(1.0);
3221 f_enable_all_tch();
3222 f_disable_all_tch_f();
3223 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_fr_fail));
3224 vc_conn.done;
3225 f_enable_all_tch();
3226 setverdict(pass);
3227}
3228
3229/* Request a FR (prefered) or alternatively a HR channel while all FR channels
3230 * are exhausted, this is expected to be resolved by selecting a HR channel. */
3231testcase TC_assignment_codec_fr_exhausted_req_fr_hr() runs on test_CT {
3232 var MSC_ConnHdlr vc_conn;
3233 f_init(1, true);
3234 f_sleep(1.0);
3235 f_enable_all_tch();
3236 f_disable_all_tch_f();
3237 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fr_exhausted_req_fr_hr));
3238 vc_conn.done;
3239 f_enable_all_tch();
3240 setverdict(pass);
3241}
3242
3243/* Request a HR (prefered) or alternatively a FR channel while all FR channels
3244 * are exhausted, this is expected to work without conflicts. */
3245testcase TC_assignment_codec_fr_exhausted_req_hr_fr() runs on test_CT {
3246 var MSC_ConnHdlr vc_conn;
3247 f_init(1, true);
3248 f_sleep(1.0);
3249 f_enable_all_tch();
3250 f_disable_all_tch_f();
3251 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fr_exhausted_req_hr_fr));
3252 vc_conn.done;
3253 f_enable_all_tch();
3254 setverdict(pass);
3255}
3256
3257/* Request a FR channel while all HR channels are exhausted, this is expected
3258 * to work without conflicts */
3259testcase TC_assignment_codec_hr_exhausted_req_fr() runs on test_CT {
3260 var MSC_ConnHdlr vc_conn;
3261 f_init(1, true);
3262 f_sleep(1.0);
3263 f_enable_all_tch();
3264 f_disable_all_tch_h();
3265 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_fr));
3266 vc_conn.done;
3267 f_enable_all_tch();
3268 setverdict(pass);
3269}
3270
3271/* Request a HR channel while all HR channels are exhausted, this is expected
3272 * to fail. */
3273testcase TC_assignment_codec_hr_exhausted_req_hr() runs on test_CT {
3274 var MSC_ConnHdlr vc_conn;
3275 f_init(1, true);
3276 f_sleep(1.0);
3277 f_enable_all_tch();
3278 f_disable_all_tch_h();
3279 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_hr_fail));
3280 vc_conn.done;
3281 f_enable_all_tch();
3282 setverdict(pass);
3283}
3284
3285/* Request a HR (prefered) or alternatively a FR channel while all HR channels
3286 * are exhausted, this is expected to be resolved by selecting a FR channel. */
3287testcase TC_assignment_codec_hr_exhausted_req_hr_fr() runs on test_CT {
3288 var MSC_ConnHdlr vc_conn;
3289 f_init(1, true);
3290 f_sleep(1.0);
3291 f_enable_all_tch();
3292 f_disable_all_tch_h();
3293 vc_conn := f_start_handler(refers(f_TC_assignment_codec_hr_exhausted_req_hr_fr));
3294 vc_conn.done;
3295 f_enable_all_tch();
3296 setverdict(pass);
3297}
3298
3299/* Request a FR (prefered) or alternatively a HR channel while all HR channels
3300 * are exhausted, this is expected to work without conflicts. */
3301testcase TC_assignment_codec_hr_exhausted_req_fr_hr() runs on test_CT {
3302 var MSC_ConnHdlr vc_conn;
3303 f_init(1, true);
3304 f_sleep(1.0);
3305 f_enable_all_tch();
3306 f_disable_all_tch_h();
3307 vc_conn := f_start_handler(refers(f_TC_assignment_codec_hr_exhausted_req_fr_hr));
3308 vc_conn.done;
3309 f_enable_all_tch();
3310 setverdict(pass);
3311}
3312
3313/* Allow FR and HR, but prefer HR */
3314private function f_TC_assignment_codec_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
3315 g_pars := f_gen_test_hdlr_pars();
3316 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3317 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3318 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3319 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
3320 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
3321 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
3322 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
3323 f_establish_fully(ass_cmd, exp_compl);
3324}
3325
3326/* Allow FR and HR, but prefer FR */
3327private function f_TC_assignment_codec_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
3328 g_pars := f_gen_test_hdlr_pars();
3329 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3330 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3331 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3332 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
3333 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
3334 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
3335 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
3336 f_establish_fully(ass_cmd, exp_compl);
3337}
3338
3339/* Request a HR (prefered) or alternatively a FR channel, it is expected that
3340 * HR, which is the prefered type, is selected. */
3341testcase TC_assignment_codec_req_hr_fr() runs on test_CT {
3342 var MSC_ConnHdlr vc_conn;
3343 f_init(1, true);
3344 f_sleep(1.0);
3345 f_enable_all_tch();
3346 vc_conn := f_start_handler(refers(f_TC_assignment_codec_req_hr_fr));
3347 vc_conn.done;
3348 setverdict(pass);
3349}
3350
3351/* Request a FR (prefered) or alternatively a HR channel, it is expected that
3352 * FR, which is the prefered type, is selected. */
3353testcase TC_assignment_codec_req_fr_hr() runs on test_CT {
3354 var MSC_ConnHdlr vc_conn;
3355 f_init(1, true);
3356 f_sleep(1.0);
3357 f_enable_all_tch();
3358 vc_conn := f_start_handler(refers(f_TC_assignment_codec_req_fr_hr));
3359 vc_conn.done;
3360 setverdict(pass);
3361}
3362
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02003363testcase TC_assignment_osmux() runs on test_CT {
3364 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3365 var MSC_ConnHdlr vc_conn;
3366
3367 /* See note above */
3368 var RSL_IE_Body mr_conf := {
3369 other := {
3370 len := 2,
3371 payload := '2804'O
3372 }
3373 };
3374
3375 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
3376 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
3377 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
3378 pars.expect_mr_conf_ie := mr_conf;
3379 pars.use_osmux := true;
3380
3381 f_init(1, true, true);
3382 f_sleep(1.0);
3383
3384 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
3385 vc_conn.done;
3386}
3387
Neels Hofmeyr92b12b72018-09-18 14:30:23 +02003388/* test the procedure of the MSC requesting a Classmark Update:
3389 * a) BSSMAP Classmark Request should result in RR CLASSMARK ENQUIRY,
3390 * b) L3 RR CLASSMARK CHANGE should result in BSSMAP CLASSMARK UPDATE */
Harald Welte898113b2018-01-31 18:32:21 +01003391private function f_tc_classmark(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02003392 g_pars := f_gen_test_hdlr_pars();
3393
Harald Weltea0630032018-03-20 21:09:55 +01003394 f_create_chan_and_exp();
Harald Welte898113b2018-01-31 18:32:21 +01003395 /* we should now have a COMPL_L3 at the MSC */
3396 BSSAP.receive(tr_BSSMAP_ComplL3);
3397
Neels Hofmeyr92b12b72018-09-18 14:30:23 +02003398 BSSAP.send(ts_BSSMAP_ClassmarkRequest);
3399 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_CM_ENQUIRY));
3400
Harald Welte898113b2018-01-31 18:32:21 +01003401 f_rsl_send_l3(ts_RRM_CM_CHG(valueof(ts_CM2)));
3402 BSSAP.receive(tr_BSSMAP_ClassmarkUpd(?, omit));
3403 setverdict(pass);
3404}
3405testcase TC_classmark() runs on test_CT {
3406 var MSC_ConnHdlr vc_conn;
3407 f_init(1, true);
3408 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02003409 vc_conn := f_start_handler(refers(f_tc_classmark));
Harald Welte898113b2018-01-31 18:32:21 +01003410 vc_conn.done;
3411}
3412
Harald Welteeddf0e92020-06-21 19:42:15 +02003413/* Send a CommonID from the simulated MSC and verify that the information is used to
3414 * fill BSC-internal data structures (specifically, bsc_subscr associated with subscr_conn) */
3415private function f_tc_common_id(charstring id) runs on MSC_ConnHdlr {
3416 g_pars := f_gen_test_hdlr_pars();
3417 f_MscConnHdlr_init_vty();
3418
3419 f_create_chan_and_exp();
3420 /* we should now have a COMPL_L3 at the MSC */
3421 BSSAP.receive(tr_BSSMAP_ComplL3);
3422
3423 /* Send CommonID */
3424 BSSAP.send(ts_BSSMAP_CommonId(g_pars.imsi));
3425
3426 /* Use VTY to verify that the IMSI of the subscr_conn is set */
3427 var charstring regex := "*(IMSI: " & hex2str(g_pars.imsi) & ")*";
3428 f_vty_transceive_match_regexp_retry(BSCVTY, "show conns", regex, 0, 4, 1.0);
3429
3430 setverdict(pass);
3431}
3432testcase TC_common_id() runs on test_CT {
3433 var MSC_ConnHdlr vc_conn;
3434 f_init(1, true);
3435 f_sleep(1.0);
3436 vc_conn := f_start_handler(refers(f_tc_common_id));
3437 vc_conn.done;
3438}
3439
Harald Weltee3bd6582018-01-31 22:51:25 +01003440private function f_est_single_l3(template PDU_ML3_MS_NW l3) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02003441 g_pars := f_gen_test_hdlr_pars();
Harald Weltea0630032018-03-20 21:09:55 +01003442 f_create_chan_and_exp();
Harald Welte898113b2018-01-31 18:32:21 +01003443 /* we should now have a COMPL_L3 at the MSC */
3444 BSSAP.receive(tr_BSSMAP_ComplL3);
3445
Harald Weltee3bd6582018-01-31 22:51:25 +01003446 /* send the single message we want to send */
3447 f_rsl_send_l3(l3);
3448}
3449
3450private function f_bssap_expect_nothing(float sec := 5.00) runs on MSC_ConnHdlr {
3451 timer T := sec;
3452 var PDU_BSSAP bssap;
Harald Welte898113b2018-01-31 18:32:21 +01003453 T.start;
3454 alt {
Harald Weltee3bd6582018-01-31 22:51:25 +01003455 [] BSSAP.receive(PDU_BSSAP:?) -> value bssap {
3456 setverdict(fail, "Unexpected BSSMAP ", bssap);
Daniel Willmannafce8662018-07-06 23:11:32 +02003457 mtc.stop;
Harald Welte898113b2018-01-31 18:32:21 +01003458 }
3459 [] T.timeout {
3460 setverdict(pass);
3461 }
3462 }
3463}
3464
Harald Weltee3bd6582018-01-31 22:51:25 +01003465/* unsolicited ASSIGNMENT FAIL (without ASSIGN) from MS shouldn't bring BSC down */
3466private function f_tc_unsol_ass_fail(charstring id) runs on MSC_ConnHdlr {
3467 f_est_single_l3(ts_RRM_AssignmentFailure('00'O));
3468 f_bssap_expect_nothing();
3469}
Harald Welte898113b2018-01-31 18:32:21 +01003470testcase TC_unsol_ass_fail() runs on test_CT {
3471 var MSC_ConnHdlr vc_conn;
3472 f_init(1, true);
3473 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02003474 vc_conn := f_start_handler(refers(f_tc_unsol_ass_fail));
Harald Welte898113b2018-01-31 18:32:21 +01003475 vc_conn.done;
3476}
Harald Welte552620d2017-12-16 23:21:36 +01003477
Harald Welteea99a002018-01-31 20:46:43 +01003478
3479/* unsolicited ASSIGNMENT COMPLETE (without ASSIGN) from MS shouldn't bring BSC down */
3480private function f_tc_unsol_ass_compl(charstring id) runs on MSC_ConnHdlr {
Harald Weltee3bd6582018-01-31 22:51:25 +01003481 f_est_single_l3(ts_RRM_AssignmentComplete('00'O));
3482 f_bssap_expect_nothing();
Harald Welteea99a002018-01-31 20:46:43 +01003483}
3484testcase TC_unsol_ass_compl() runs on test_CT {
3485 var MSC_ConnHdlr vc_conn;
3486 f_init(1, true);
3487 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02003488 vc_conn := f_start_handler(refers(f_tc_unsol_ass_compl));
Harald Welteea99a002018-01-31 20:46:43 +01003489 vc_conn.done;
3490}
3491
3492
Harald Weltefbf9b5e2018-01-31 20:41:23 +01003493/* unsolicited HANDOVER FAIL (without ASSIGN) from MS shouldn't bring BSC down */
3494private function f_tc_unsol_ho_fail(charstring id) runs on MSC_ConnHdlr {
Harald Weltee3bd6582018-01-31 22:51:25 +01003495 f_est_single_l3(ts_RRM_HandoverFailure('00'O));
3496 f_bssap_expect_nothing();
Harald Weltefbf9b5e2018-01-31 20:41:23 +01003497}
Harald Weltefbf9b5e2018-01-31 20:41:23 +01003498testcase TC_unsol_ho_fail() runs on test_CT {
3499 var MSC_ConnHdlr vc_conn;
3500 f_init(1, true);
3501 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02003502 vc_conn := f_start_handler(refers(f_tc_unsol_ho_fail));
Harald Weltefbf9b5e2018-01-31 20:41:23 +01003503 vc_conn.done;
3504}
3505
3506
Harald Weltee3bd6582018-01-31 22:51:25 +01003507/* short message from MS should be ignored */
3508private function f_tc_err_82_short_msg(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02003509 g_pars := f_gen_test_hdlr_pars();
Harald Weltea0630032018-03-20 21:09:55 +01003510 f_create_chan_and_exp();
Harald Weltee3bd6582018-01-31 22:51:25 +01003511 /* we should now have a COMPL_L3 at the MSC */
3512 BSSAP.receive(tr_BSSMAP_ComplL3);
3513
3514 /* send short message */
3515 RSL.send(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), ''O));
3516 f_bssap_expect_nothing();
3517}
3518testcase TC_err_82_short_msg() runs on test_CT {
3519 var MSC_ConnHdlr vc_conn;
3520 f_init(1, true);
3521 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02003522 vc_conn := f_start_handler(refers(f_tc_err_82_short_msg));
Harald Weltee3bd6582018-01-31 22:51:25 +01003523 vc_conn.done;
3524}
3525
3526
Harald Weltee9e02e42018-01-31 23:36:25 +01003527/* 24.008 8.4 Unknown message must trigger RR STATUS */
3528private function f_tc_err_84_unknown_msg(charstring id) runs on MSC_ConnHdlr {
3529 f_est_single_l3(ts_RRM_UL_REL('00'O));
3530 timer T := 3.0
3531 alt {
3532 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_STATUS)) {
3533 setverdict(pass);
3534 }
3535 [] BSSAP.receive { setverdict(fail, "unexpected BSSAP"); }
Harald Welte458fd372018-03-21 11:26:23 +01003536 [] T.timeout { setverdict(fail, "Timeout waiting for RR STATUS"); }
Harald Weltee9e02e42018-01-31 23:36:25 +01003537 }
3538}
3539testcase TC_err_84_unknown_msg() runs on test_CT {
3540 var MSC_ConnHdlr vc_conn;
3541 f_init(1, true);
3542 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02003543 vc_conn := f_start_handler(refers(f_tc_err_84_unknown_msg));
Harald Weltee9e02e42018-01-31 23:36:25 +01003544 vc_conn.done;
3545}
3546
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01003547/***********************************************************************
3548 * Handover
3549 ***********************************************************************/
3550
Harald Welte94e0c342018-04-07 11:33:23 +02003551/* execute a "bts <0-255> trx <0-255> timeslot <0-7> " command on given Dchan */
3552private function f_vty_ts_action(charstring suffix, integer bts_nr, integer trx_nr, integer ts_nr)
3553runs on test_CT {
3554 var charstring cmd := "bts "&int2str(bts_nr)&" trx "&int2str(trx_nr)&
3555 " timeslot "&int2str(ts_nr)&" ";
3556 f_vty_transceive(BSCVTY, cmd & suffix);
3557}
3558
Harald Welte261af4b2018-02-12 21:20:39 +01003559/* execute a "bts <0-255> trx <0-255> timeslot <0-7> sub-slot <0-7>" command on given Dchan */
3560private function f_vty_ss_action(charstring suffix, integer bts_nr, integer trx_nr, RslChannelNr chan_nr)
3561runs on MSC_ConnHdlr {
3562 /* FIXME: resolve those from component-global state */
3563 var integer ts_nr := chan_nr.tn;
3564 var integer ss_nr;
3565 if (ischosen(chan_nr.u.ch0)) {
3566 ss_nr := 0;
3567 } else if (ischosen(chan_nr.u.lm)) {
3568 ss_nr := chan_nr.u.lm.sub_chan;
3569 } else if (ischosen(chan_nr.u.sdcch4)) {
3570 ss_nr := chan_nr.u.sdcch4.sub_chan;
3571 } else if (ischosen(chan_nr.u.sdcch8)) {
3572 ss_nr := chan_nr.u.sdcch8.sub_chan;
3573 } else {
3574 setverdict(fail, "Invalid ChanNr ", chan_nr);
Daniel Willmannafce8662018-07-06 23:11:32 +02003575 mtc.stop;
Harald Welte261af4b2018-02-12 21:20:39 +01003576 }
3577
3578 var charstring cmd := "bts "&int2str(bts_nr)&" trx "&int2str(trx_nr)&
3579 " timeslot "&int2str(ts_nr)&" sub-slot "&int2str(ss_nr)&" ";
3580 f_vty_transceive(BSCVTY, cmd & suffix);
3581}
3582
Neels Hofmeyr91401012019-07-11 00:42:35 +02003583/* Even though the VTY command to trigger handover takes a new BTS number as argument, behind the scenes osmo-bsc always
3584 * translates that to a target ARFCN+BSIC first. See bsc_vty.c trigger_ho_or_as(), which puts the selected BTS' neighbor
3585 * ident key (ARFCN + BSIC) in the struct passed on to handover_request(). handover_start() then resolves that to a
3586 * viable actual neighbor cell. So from the internal osmo-bsc perspective, we always request handover to an ARFCN + BSIC
3587 * pair, not really to a specific BTS number. */
Harald Welte261af4b2018-02-12 21:20:39 +01003588private function f_vty_handover(integer bts_nr, integer trx_nr, RslChannelNr chan_nr,
3589 integer new_bts_nr)
3590runs on MSC_ConnHdlr {
3591 f_vty_ss_action("handover " & int2str(new_bts_nr), bts_nr, trx_nr, chan_nr);
3592}
3593
3594/* intra-BSC hand-over between BTS0 and BTS1 */
3595private function f_tc_ho_int(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02003596 g_pars := f_gen_test_hdlr_pars();
Harald Welteed848512018-05-24 22:27:58 +02003597 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3598 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte261af4b2018-02-12 21:20:39 +01003599 const OCT8 kc := '0001020304050607'O;
3600
3601 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3602 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
3603
Harald Weltea0630032018-03-20 21:09:55 +01003604 f_establish_fully(ass_cmd, exp_compl);
Neels Hofmeyr666f0432020-07-04 00:53:07 +02003605 f_bts_0_cfg(BSCVTY, {"neighbor bts 1"});
Harald Welte261af4b2018-02-12 21:20:39 +01003606
3607 var HandoverState hs := {
3608 rr_ho_cmpl_seen := false,
3609 handover_done := false,
3610 old_chan_nr := -
3611 };
3612 /* issue hand-over command on VTY */
3613 f_vty_handover(0, 0, g_chan_nr, 1);
3614 /* temporarily suspend DChan processing on BTS1 to avoid race with RSLEM_register */
3615 f_rslem_suspend(RSL1_PROC);
Philipp Maier3e2af5d2018-07-11 17:01:05 +02003616
3617 /* From the MGW perspective, a handover is is characterized by
3618 * performing one MDCX operation with the MGW. So we expect to see
3619 * one more MDCX during handover. */
3620 g_media.mgcp_conn[0].mdcx_seen_exp := g_media.mgcp_conn[0].crcx_seen_exp + 1;
3621
Harald Welte261af4b2018-02-12 21:20:39 +01003622 alt {
3623 [] as_handover(hs);
Harald Welte261af4b2018-02-12 21:20:39 +01003624 }
Philipp Maier3e2af5d2018-07-11 17:01:05 +02003625
Philipp Maier4dae0652018-11-12 12:03:26 +01003626 /* Since this is an internal handover we expect the BSC to inform the
3627 * MSC about the event */
3628 BSSAP.receive(tr_BSSMAP_HandoverPerformed);
3629
Philipp Maier3e2af5d2018-07-11 17:01:05 +02003630 /* Check the amount of MGCP transactions is still consistant with the
3631 * test expectation */
3632 f_check_mgcp_expectations()
Neels Hofmeyr861a4c12018-11-07 01:23:17 +01003633 f_sleep(0.5);
Harald Welte261af4b2018-02-12 21:20:39 +01003634}
3635
3636testcase TC_ho_int() runs on test_CT {
3637 var MSC_ConnHdlr vc_conn;
3638 f_init(2, true);
3639 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02003640 vc_conn := f_start_handler(refers(f_tc_ho_int));
Harald Welte261af4b2018-02-12 21:20:39 +01003641 vc_conn.done;
3642}
Harald Weltee9e02e42018-01-31 23:36:25 +01003643
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02003644/* Expecting MGCP to DLCX the endpoint's two connections: towards BTS and towards MSC */
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02003645private function f_expect_dlcx_conns() runs on MSC_ConnHdlr {
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02003646 var MgcpCommand mgcp;
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02003647 var template MgcpResponse mgcp_resp;
3648 var MGCP_RecvFrom mrf;
3649 var template MgcpMessage msg_resp;
3650 var template MgcpMessage msg_dlcx := {
3651 command := tr_DLCX()
3652 }
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02003653
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02003654 if (g_pars.aoip) {
3655 MGCP.receive(tr_DLCX()) -> value mgcp {
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02003656 log("Got first DLCX: ", mgcp);
3657 MGCP.send(ts_DLCX_ACK2(mgcp.line.trans_id));
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02003658 };
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02003659
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02003660 MGCP.receive(tr_DLCX()) -> value mgcp {
3661 log("Got second DLCX: ", mgcp);
3662 MGCP.send(ts_DLCX_ACK2(mgcp.line.trans_id));
3663 };
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02003664 } else {
3665 /* For SCCPLite, BSC doesn't handle the MSC-side */
3666 MGCP_MULTI.receive(tr_MGCP_RecvFrom_any(msg_dlcx)) -> value mrf {
3667 log("Got first DLCX: ", mrf.msg.command);
3668 msg_resp := {
3669 response := ts_DLCX_ACK2(mrf.msg.command.line.trans_id)
3670 }
3671 MGCP_MULTI.send(t_MGCP_SendToMrf(mrf, msg_resp));
3672 };
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02003673 }
3674
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02003675 BSSAP.receive(tr_BSSMAP_ClearComplete);
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02003676}
3677
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01003678private function f_tc_ho_out_of_this_bsc(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02003679 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01003680
3681 var PDU_BSSAP ass_req := f_gen_ass_req();
3682 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3683 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
3684 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3685 f_establish_fully(ass_req, exp_compl);
3686
Neels Hofmeyr666f0432020-07-04 00:53:07 +02003687 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01003688 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
3689
3690 BSSAP.receive(tr_BSSMAP_HandoverRequired);
3691
3692 f_sleep(0.5);
3693 /* The MSC negotiates Handover Request and Handover Request Ack with
3694 * the other BSS and comes back with a BSSMAP Handover Command
3695 * containing an RR Handover Command coming from the target BSS... */
3696
3697 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
3698 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
3699 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
3700 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
3701 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
3702
3703 /* expect the Handover Command to go out on RR */
3704 var RSL_Message rsl_ho_cmd
3705 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
3706 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
3707 var RSL_IE_Body rsl_ho_cmd_l3;
3708 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
3709 log("RSL message contains no L3 Info IE, expected RR Handover Command");
3710 setverdict(fail);
3711 } else {
3712 log("Found L3 Info: ", rsl_ho_cmd_l3);
3713 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
3714 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
3715 setverdict(fail);
3716 } else {
3717 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
3718 setverdict(pass);
3719 }
3720 }
3721
3722 /* When the other BSS has reported a completed handover, this side is
3723 * torn down. */
3724
3725 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_HANDOVER_SUCCESSFUL;
3726 var BssmapCause cause := enum2int(cause_val);
3727 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
3728
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02003729 f_expect_dlcx_conns();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01003730 setverdict(pass);
3731 f_sleep(1.0);
3732}
3733testcase TC_ho_out_of_this_bsc() runs on test_CT {
3734 var MSC_ConnHdlr vc_conn;
3735
3736 f_init(1, true);
3737 f_sleep(1.0);
3738
3739 vc_conn := f_start_handler(refers(f_tc_ho_out_of_this_bsc));
3740 vc_conn.done;
3741}
3742
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02003743/* BSC asks for inter-BSC HO, but the MSC decides that it won't happen and
3744 * simply never sends a BSSMAP Handover Command. */
3745private function f_tc_ho_out_fail_no_msc_response(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01003746 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02003747
3748 var PDU_BSSAP ass_req := f_gen_ass_req();
3749 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3750 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
3751 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3752 f_establish_fully(ass_req, exp_compl);
3753
Neels Hofmeyr666f0432020-07-04 00:53:07 +02003754 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02003755 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
3756
3757 BSSAP.receive(tr_BSSMAP_HandoverRequired);
3758
3759 /* osmo-bsc should time out 10 seconds after the handover started.
3760 * Let's give it a bit extra. */
3761 f_sleep(15.0);
3762
3763 /* The old lchan and conn should still be active. See that arbitrary L3
3764 * is still going through. */
3765 var octetstring l3 := '0123456789'O;
3766 RSL.send(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
3767 var template PDU_BSSAP exp_data := {
3768 discriminator := '1'B,
3769 spare := '0000000'B,
3770 dlci := '00'O,
3771 lengthIndicator := 5,
3772 pdu := {
3773 dtap := l3
3774 }
3775 };
3776 BSSAP.receive(exp_data);
3777 setverdict(pass);
3778 f_sleep(1.0);
3779}
3780testcase TC_ho_out_fail_no_msc_response() runs on test_CT {
3781 var MSC_ConnHdlr vc_conn;
3782
3783 f_init(1, true);
3784 f_sleep(1.0);
3785
3786 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_no_msc_response));
3787 vc_conn.done;
3788}
3789
3790/* BSC asks for inter-BSC HO, receives BSSMAP Handover Command, but MS reports
3791 * RR Handover Failure. */
3792private function f_tc_ho_out_fail_rr_ho_failure(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01003793 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02003794
3795 var PDU_BSSAP ass_req := f_gen_ass_req();
3796 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3797 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
3798 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3799 f_establish_fully(ass_req, exp_compl);
3800
Neels Hofmeyr666f0432020-07-04 00:53:07 +02003801 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02003802 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
3803
3804 BSSAP.receive(tr_BSSMAP_HandoverRequired);
3805
3806 f_sleep(0.5);
3807 /* The MSC negotiates Handover Request and Handover Request Ack with
3808 * the other BSS and comes back with a BSSMAP Handover Command
3809 * containing an RR Handover Command coming from the target BSS... */
3810
3811 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
3812 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
3813 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
3814 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
3815 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
3816
3817 /* expect the Handover Command to go out on RR */
3818 var RSL_Message rsl_ho_cmd
3819 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
3820 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
3821 var RSL_IE_Body rsl_ho_cmd_l3;
3822 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
3823 log("RSL message contains no L3 Info IE, expected RR Handover Command");
3824 setverdict(fail);
3825 } else {
3826 log("Found L3 Info: ", rsl_ho_cmd_l3);
3827 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
3828 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
3829 setverdict(fail);
3830 } else {
3831 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
3832 setverdict(pass);
3833 }
3834 }
3835
3836 f_sleep(0.2);
3837 f_rsl_send_l3(ts_RRM_HandoverFailure('00'O));
3838
3839 /* Should tell the MSC about the failure */
3840 BSSAP.receive(tr_BSSMAP_HandoverFailure);
3841
3842 f_sleep(1.0);
3843
3844 /* The old lchan and conn should still be active. See that arbitrary L3
3845 * is still going through. */
3846 var octetstring l3 := '0123456789'O;
3847 RSL.send(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
3848 var template PDU_BSSAP exp_data := {
3849 discriminator := '1'B,
3850 spare := '0000000'B,
3851 dlci := '00'O,
3852 lengthIndicator := 5,
3853 pdu := {
3854 dtap := l3
3855 }
3856 };
3857 BSSAP.receive(exp_data);
3858 setverdict(pass);
3859 f_sleep(1.0);
3860
3861 setverdict(pass);
3862 f_sleep(1.0);
3863}
3864testcase TC_ho_out_fail_rr_ho_failure() runs on test_CT {
3865 var MSC_ConnHdlr vc_conn;
3866
3867 f_init(1, true);
3868 f_sleep(1.0);
3869
3870 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_rr_ho_failure));
3871 vc_conn.done;
3872}
3873
Neels Hofmeyr10f2bfa2019-07-09 19:33:29 +02003874/* BSC asks for inter-BSC-out HO, receives BSSMAP Handover Command, but then no reply is received about HO outcome
3875 * (neither BSSMAP Clear Command for success nor RR Handover Failure). 48.008 3.1.5.3.3 "Abnormal Conditions" applies
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02003876 * and the lchan is released. */
3877private function f_tc_ho_out_fail_no_result_after_ho_cmd(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01003878 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02003879
3880 var PDU_BSSAP ass_req := f_gen_ass_req();
3881 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3882 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
3883 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3884 f_establish_fully(ass_req, exp_compl);
3885
Neels Hofmeyr666f0432020-07-04 00:53:07 +02003886 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02003887 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
3888
3889 BSSAP.receive(tr_BSSMAP_HandoverRequired);
3890
3891 f_sleep(0.5);
3892 /* The MSC negotiates Handover Request and Handover Request Ack with
3893 * the other BSS and comes back with a BSSMAP Handover Command
3894 * containing an RR Handover Command coming from the target BSS... */
3895
3896 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
3897 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
3898 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
3899 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
3900 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
3901
3902 /* expect the Handover Command to go out on RR */
3903 var RSL_Message rsl_ho_cmd
3904 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
3905 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
3906 var RSL_IE_Body rsl_ho_cmd_l3;
3907 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
3908 log("RSL message contains no L3 Info IE, expected RR Handover Command");
3909 setverdict(fail);
3910 } else {
3911 log("Found L3 Info: ", rsl_ho_cmd_l3);
3912 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
3913 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
3914 setverdict(fail);
3915 } else {
3916 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
3917 setverdict(pass);
3918 }
3919 }
3920
Neels Hofmeyr10f2bfa2019-07-09 19:33:29 +02003921 /* We get neither success nor failure report from the remote BSS. Eventually T8 times out and we run into 3GPP
3922 * TS 48.008 3.1.5.3.3 "Abnormal Conditions": Clear Request should go to the MSC, and RR should be released
3923 * after Clear Command */
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02003924
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02003925 var PDU_BSSAP rx_clear_request;
Neels Hofmeyre1797aa2019-07-09 19:34:04 +02003926 BSSAP.receive(tr_BSSMAP_ClearRequest) -> value rx_clear_request;
3927 log("Got BSSMAP Clear Request");
3928 /* Instruct BSC to clear channel */
3929 var BssmapCause cause := bit2int(rx_clear_request.pdu.bssmap.clearRequest.cause.causeValue);
3930 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
3931
3932 var MgcpCommand mgcp;
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02003933 interleave {
Neels Hofmeyr861a4c12018-11-07 01:23:17 +01003934 [] RSL.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
3935 log("Got Deact SACCH");
3936 }
Harald Welte924b6ea2019-02-04 01:05:34 +01003937 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
Neels Hofmeyr211169d2018-11-07 00:37:29 +01003938 log("Got RR Release");
3939 }
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02003940 [] RSL.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
3941 log("Got RF Chan Rel");
3942 RSL.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
3943 }
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02003944 }
3945
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02003946 f_expect_dlcx_conns();
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02003947
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02003948 setverdict(pass);
3949 f_sleep(1.0);
3950}
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02003951testcase TC_ho_out_fail_no_result_after_ho_cmd() runs on test_CT {
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02003952 var MSC_ConnHdlr vc_conn;
3953
3954 f_init(1, true);
3955 f_sleep(1.0);
3956
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02003957 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_no_result_after_ho_cmd));
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02003958 vc_conn.done;
3959}
3960
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01003961private function f_tc_ho_into_this_bsc(charstring id) runs on MSC_ConnHdlr {
3962 /* Hack: the proper way would be to wait for the BSSMAP Handover Request ACK and extract the
3963 * actual assigned chan_nr from its L3 (RR Handover Command) message. But osmo-bsc starts acting
3964 * on the lchan even before we get a chance to evaluate the BSSMAP Handover Request ACK. So we
3965 * need to assume that osmo-bsc will activate TS 1 and already set up this lchan's RSL emulation
3966 * before we get started. */
3967 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
3968 f_rslem_register(0, new_chan_nr);
3969 g_chan_nr := new_chan_nr;
3970 f_sleep(1.0);
3971
3972 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
3973 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
3974 activate(as_Media());
3975
Neels Hofmeyr90f80962020-06-12 16:16:55 +02003976 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01003977 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02003978 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01003979
3980 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
3981
3982 var PDU_BSSAP rx_bssap;
3983 var octetstring ho_command_str;
3984
3985 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
Pau Espin Pedrol76ba5412019-06-10 11:00:33 +02003986
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01003987 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
3988 log("Received L3 Info in HO Request Ack: ", ho_command_str);
3989 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
3990 log("L3 Info in HO Request Ack is ", ho_command);
3991
3992 var GsmArfcn arfcn;
3993 var RslChannelNr actual_new_chan_nr;
3994 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
3995 actual_new_chan_nr, arfcn);
3996
3997 if (actual_new_chan_nr != new_chan_nr) {
3998 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
3999 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
4000 setverdict(fail);
4001 return;
4002 }
4003 log("Handover Command chan_nr is", actual_new_chan_nr);
4004
4005 /* Now the MSC forwards the RR Handover Command to the other BSC, which
4006 * tells the MS to handover to the new lchan. Here comes the new MS on
4007 * the new lchan with a Handover RACH: */
4008
4009 /* send handover detect */
4010
4011 RSL.send(ts_RSL_HANDO_DET(new_chan_nr));
4012
4013 BSSAP.receive(tr_BSSMAP_HandoverDetect);
4014
4015 /* send handover complete over the new channel */
4016
4017 var PDU_ML3_MS_NW l3_tx := valueof(ts_RRM_HandoverComplete('00'O));
4018 RSL.send(ts_RSL_EST_IND(new_chan_nr, valueof(ts_RslLinkID_DCCH(0)),
4019 enc_PDU_ML3_MS_NW(l3_tx)));
4020
4021 BSSAP.receive(tr_BSSMAP_HandoverComplete);
4022 setverdict(pass);
4023}
4024testcase TC_ho_into_this_bsc() runs on test_CT {
4025 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02004026 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004027
4028 f_init(1, true);
4029 f_sleep(1.0);
4030
Neels Hofmeyr90f80962020-06-12 16:16:55 +02004031 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
4032 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004033
4034 vc_conn := f_start_handler(refers(f_tc_ho_into_this_bsc), pars);
4035 vc_conn.done;
4036}
4037
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004038private function f_tc_ho_in_fail_msc_clears(charstring id) runs on MSC_ConnHdlr {
4039 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
4040 f_rslem_register(0, new_chan_nr);
4041 g_chan_nr := new_chan_nr;
4042 f_sleep(1.0);
4043
4044 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
4045 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
4046 activate(as_Media());
4047
Neels Hofmeyr90f80962020-06-12 16:16:55 +02004048 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004049 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02004050 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004051
4052 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
4053
4054 var PDU_BSSAP rx_bssap;
4055 var octetstring ho_command_str;
4056
4057 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
4058
4059 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
4060 log("Received L3 Info in HO Request Ack: ", ho_command_str);
4061 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
4062 log("L3 Info in HO Request Ack is ", ho_command);
4063
4064 var GsmArfcn arfcn;
4065 var RslChannelNr actual_new_chan_nr;
4066 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
4067 actual_new_chan_nr, arfcn);
4068
4069 if (actual_new_chan_nr != new_chan_nr) {
4070 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
4071 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
4072 setverdict(fail);
4073 return;
4074 }
4075 log("Handover Command chan_nr is", actual_new_chan_nr);
4076
Neels Hofmeyr61ca08d2019-05-06 23:52:22 +02004077 /* For deterministic test results, give some time for the MGW endpoint to be configured */
4078 f_sleep(1.0);
4079
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004080 /* Now the MSC forwards the RR Handover Command to the other BSC, which
4081 * tells the MS to handover to the new lchan. In this case, the MS
4082 * reports a Handover Failure to the old BSS, which forwards a BSSMAP
4083 * Handover Failure to the MSC. The procedure according to 3GPP TS
4084 * 48.008 3.1.5.3.2 "Handover Failure" is then that the MSC sends a
4085 * BSSMAP Clear Command: */
4086
4087 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
4088 var BssmapCause cause := enum2int(cause_val);
4089 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
4090
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004091 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004092 setverdict(pass);
4093 f_sleep(1.0);
4094
4095 setverdict(pass);
4096}
4097testcase TC_ho_in_fail_msc_clears() runs on test_CT {
4098 var MSC_ConnHdlr vc_conn;
4099 var TestHdlrParams pars := f_gen_test_hdlr_pars();
4100
4101 f_init(1, true);
4102 f_sleep(1.0);
4103
Neels Hofmeyr90f80962020-06-12 16:16:55 +02004104 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
4105 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004106
4107 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_msc_clears), pars);
4108 vc_conn.done;
4109}
4110
4111private function f_tc_ho_in_fail_msc_clears_after_ho_detect(charstring id) runs on MSC_ConnHdlr {
4112 /* Hack: the proper way would be to wait for the BSSMAP Handover Request ACK and extract the
4113 * actual assigned chan_nr from its L3 (RR Handover Command) message. But osmo-bsc starts acting
4114 * on the lchan even before we get a chance to evaluate the BSSMAP Handover Request ACK. So we
4115 * need to assume that osmo-bsc will activate TS 1 and already set up this lchan's RSL emulation
4116 * before we get started. */
4117 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
4118 f_rslem_register(0, new_chan_nr);
4119 g_chan_nr := new_chan_nr;
4120 f_sleep(1.0);
4121
4122 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
4123 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
4124 activate(as_Media());
4125
Neels Hofmeyr90f80962020-06-12 16:16:55 +02004126 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004127 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02004128 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004129
4130 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
4131
4132 var PDU_BSSAP rx_bssap;
4133 var octetstring ho_command_str;
4134
4135 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
4136
4137 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
4138 log("Received L3 Info in HO Request Ack: ", ho_command_str);
4139 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
4140 log("L3 Info in HO Request Ack is ", ho_command);
4141
4142 var GsmArfcn arfcn;
4143 var RslChannelNr actual_new_chan_nr;
4144 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
4145 actual_new_chan_nr, arfcn);
4146
4147 if (actual_new_chan_nr != new_chan_nr) {
4148 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
4149 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
4150 setverdict(fail);
4151 return;
4152 }
4153 log("Handover Command chan_nr is", actual_new_chan_nr);
4154
4155 /* Now the MSC forwards the RR Handover Command to the other BSC, which
4156 * tells the MS to handover to the new lchan. Here comes the new MS on
4157 * the new lchan with a Handover RACH: */
4158
4159 /* send handover detect */
4160
4161 RSL.send(ts_RSL_HANDO_DET(new_chan_nr));
4162
4163 BSSAP.receive(tr_BSSMAP_HandoverDetect);
4164
4165 /* The MSC chooses to clear the connection now, maybe we got the
4166 * Handover RACH on the new cell but the MS still signaled Handover
4167 * Failure to the old BSS? */
4168
4169 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
4170 var BssmapCause cause := enum2int(cause_val);
4171 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
4172
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004173 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004174 setverdict(pass);
4175 f_sleep(1.0);
4176}
4177testcase TC_ho_in_fail_msc_clears_after_ho_detect() runs on test_CT {
4178 var MSC_ConnHdlr vc_conn;
4179 var TestHdlrParams pars := f_gen_test_hdlr_pars();
4180
4181 f_init(1, true);
4182 f_sleep(1.0);
4183
Neels Hofmeyr90f80962020-06-12 16:16:55 +02004184 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
4185 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004186
4187 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_msc_clears_after_ho_detect), pars);
4188 vc_conn.done;
4189}
4190
4191/* The new BSS's lchan times out before the MSC decides that handover failed. */
4192private function f_tc_ho_in_fail_no_detect(charstring id) runs on MSC_ConnHdlr {
4193 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
4194 f_rslem_register(0, new_chan_nr);
4195 g_chan_nr := new_chan_nr;
4196 f_sleep(1.0);
4197
4198 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
4199 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
4200 activate(as_Media());
4201
Neels Hofmeyr90f80962020-06-12 16:16:55 +02004202 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004203 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02004204 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004205
4206 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
4207
4208 var PDU_BSSAP rx_bssap;
4209 var octetstring ho_command_str;
4210
4211 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
4212
4213 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
4214 log("Received L3 Info in HO Request Ack: ", ho_command_str);
4215 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
4216 log("L3 Info in HO Request Ack is ", ho_command);
4217
4218 var GsmArfcn arfcn;
4219 var RslChannelNr actual_new_chan_nr;
4220 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
4221 actual_new_chan_nr, arfcn);
4222
4223 if (actual_new_chan_nr != new_chan_nr) {
4224 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
4225 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
4226 setverdict(fail);
4227 return;
4228 }
4229 log("Handover Command chan_nr is", actual_new_chan_nr);
4230
4231 /* Now the MSC forwards the RR Handover Command to the other BSC, which
4232 * tells the MS to handover to the new lchan. But the MS never shows up
4233 * on the new lchan. */
4234
4235 BSSAP.receive(tr_BSSMAP_HandoverFailure);
4236
4237 /* Did osmo-bsc also send a Clear Request? */
4238 timer T := 0.5;
4239 T.start;
4240 alt {
4241 [] BSSAP.receive(tr_BSSMAP_ClearRequest);
4242 [] T.timeout { }
4243 }
4244
4245 /* MSC plays along with a Clear Command (no matter whether osmo-bsc
4246 * asked for it, this is a Handover Failure after all). */
4247
4248 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
4249 var BssmapCause cause := enum2int(cause_val);
4250 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
4251
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004252 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004253 setverdict(pass);
4254 f_sleep(1.0);
4255
4256 setverdict(pass);
4257}
4258testcase TC_ho_in_fail_no_detect() runs on test_CT {
4259 var MSC_ConnHdlr vc_conn;
4260 var TestHdlrParams pars := f_gen_test_hdlr_pars();
4261
4262 f_init(1, true);
4263 f_sleep(1.0);
4264
Neels Hofmeyr90f80962020-06-12 16:16:55 +02004265 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
4266 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004267
4268 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_no_detect), pars);
4269 vc_conn.done;
4270}
4271
4272/* Same as f_tc_ho_in_fail_no_detect, but MSC fails to send a Clear Command */
4273private function f_tc_ho_in_fail_no_detect2(charstring id) runs on MSC_ConnHdlr {
4274 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
4275 f_rslem_register(0, new_chan_nr);
4276 g_chan_nr := new_chan_nr;
4277 f_sleep(1.0);
4278
4279 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
4280 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
4281 activate(as_Media());
4282
Neels Hofmeyr90f80962020-06-12 16:16:55 +02004283 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004284 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02004285 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004286
4287 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
4288
4289 var PDU_BSSAP rx_bssap;
4290 var octetstring ho_command_str;
4291
4292 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
4293
4294 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
4295 log("Received L3 Info in HO Request Ack: ", ho_command_str);
4296 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
4297 log("L3 Info in HO Request Ack is ", ho_command);
4298
4299 var GsmArfcn arfcn;
4300 var RslChannelNr actual_new_chan_nr;
4301 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
4302 actual_new_chan_nr, arfcn);
4303
4304 if (actual_new_chan_nr != new_chan_nr) {
4305 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
4306 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
4307 setverdict(fail);
4308 return;
4309 }
4310 log("Handover Command chan_nr is", actual_new_chan_nr);
4311
4312 /* Now the MSC forwards the RR Handover Command to the other BSC, which
4313 * tells the MS to handover to the new lchan. But the MS never shows up
4314 * on the new lchan. */
4315
4316 BSSAP.receive(tr_BSSMAP_HandoverFailure);
4317
4318 /* MSC plays dumb and sends no Clear Command */
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004319 var PDU_BSSAP rx_clear_request;
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004320
4321 BSSAP.receive(tr_BSSMAP_ClearRequest) -> value rx_clear_request {
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004322 var BssmapCause cause := bit2int(rx_clear_request.pdu.bssmap.clearRequest.cause.causeValue);
4323 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
4324 };
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004325 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004326 setverdict(pass);
4327 f_sleep(1.0);
4328}
4329testcase TC_ho_in_fail_no_detect2() runs on test_CT {
4330 var MSC_ConnHdlr vc_conn;
4331 var TestHdlrParams pars := f_gen_test_hdlr_pars();
4332
4333 f_init(1, true);
4334 f_sleep(1.0);
4335
Neels Hofmeyr90f80962020-06-12 16:16:55 +02004336 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
4337 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004338
4339 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_no_detect2), pars);
4340 vc_conn.done;
4341}
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004342
Neels Hofmeyr91401012019-07-11 00:42:35 +02004343type record of charstring Commands;
4344
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004345private function f_bts_0_cfg(TELNETasp_PT pt, Commands cmds := {})
Neels Hofmeyr91401012019-07-11 00:42:35 +02004346{
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004347 f_vty_enter_cfg_bts(pt, 0);
Neels Hofmeyr91401012019-07-11 00:42:35 +02004348 for (var integer i := 0; i < sizeof(cmds); i := i+1) {
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004349 f_vty_transceive(pt, cmds[i]);
Neels Hofmeyr91401012019-07-11 00:42:35 +02004350 }
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004351 f_vty_transceive(pt, "end");
Neels Hofmeyr91401012019-07-11 00:42:35 +02004352}
4353
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01004354private function f_cs7_inst_0_cfg(TELNETasp_PT pt, Commands cmds := {})
4355{
4356 f_vty_enter_cfg_cs7_inst(pt, 0);
4357 for (var integer i := 0; i < sizeof(cmds); i := i+1) {
4358 f_vty_transceive(pt, cmds[i]);
4359 }
4360 f_vty_transceive(pt, "end");
4361}
4362
Neels Hofmeyr91401012019-07-11 00:42:35 +02004363private function f_probe_for_handover(charstring log_label,
4364 charstring log_descr,
4365 charstring handover_vty_cmd,
4366 boolean expect_handover,
4367 boolean is_inter_bsc_handover := false)
4368runs on MSC_ConnHdlr
4369{
Neels Hofmeyrb3fc8982020-05-11 00:16:42 +02004370 /* We're going to thwart any and all handover attempts, just be ready to handle (and ignore) handover target
4371 * lchans to be established on bts 1 or bts 2. */
4372 f_rslem_suspend(RSL1_PROC);
4373 f_rslem_suspend(RSL2_PROC);
4374
Neels Hofmeyr91401012019-07-11 00:42:35 +02004375 var RSL_Message rsl;
4376
4377 var charstring log_msg := " (expecting handover)"
4378 if (not expect_handover) {
4379 log_msg := " (expecting NO handover)";
4380 }
4381 log("f_probe_for_handover starting: " & log_label & ": " & log_descr & log_msg);
4382 f_vty_transceive(BSCVTY, handover_vty_cmd);
4383
Neels Hofmeyr91401012019-07-11 00:42:35 +02004384 timer T := 2.0;
4385 T.start;
4386
4387 alt {
4388 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr)) -> value rsl {
4389 var PDU_ML3_NW_MS l3 := dec_PDU_ML3_NW_MS(rsl.ies[2].body.l3_info.payload);
4390 log("Rx L3 from net: ", l3);
4391 if (ischosen(l3.msgs.rrm.handoverCommand)) {
4392 var RslChannelNr new_chan_nr;
4393 var GsmArfcn arfcn;
4394 f_ChDesc2RslChanNr(l3.msgs.rrm.handoverCommand.channelDescription2,
4395 new_chan_nr, arfcn);
4396 log("Handover to new chan ", new_chan_nr, " on ARFCN ", arfcn);
4397 log(l3.msgs.rrm.handoverCommand);
4398
4399 /* Need to register for new lchan on new BTS -- it's either bts 1 or bts 2. It doesn't really
4400 * matter on which BTS it really is, we're not going to follow through an entire handover
4401 * anyway. */
4402 f_rslem_register(0, new_chan_nr, RSL1_PROC);
4403 f_rslem_resume(RSL1_PROC);
4404 f_rslem_register(0, new_chan_nr, RSL2_PROC);
4405 f_rslem_resume(RSL2_PROC);
4406
4407 if (expect_handover and not is_inter_bsc_handover) {
4408 setverdict(pass);
4409 log("f_probe_for_handover(" & log_label & "): Got RSL Handover Command as expected.");
4410 } else {
4411 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected none, but got RSL Handover Command. "
4412 & log_label & ": " & log_descr);
4413 }
4414
4415 log("f_probe_for_handover(" & log_label & "): Ending the test: Handover Failure stops the procedure.");
4416 /* osmo-bsc has triggered Handover. That's all we need to know for this test, reply with
4417 * Handover Failure. */
4418 f_rsl_send_l3(ts_RRM_HandoverFailure('00'O));
4419
4420 /* target BTS is told to release lchan again; don't care which BTS nor what messages. */
4421 f_sleep(0.5);
4422 RSL1.clear;
4423 RSL2.clear;
4424 log("f_probe_for_handover(" & log_label & "): done (got RSL Handover Command)");
4425 break;
4426 } else {
4427 repeat;
4428 }
4429 }
4430 [] BSSAP.receive(tr_BSSMAP_HandoverRequired) {
4431 if (expect_handover and is_inter_bsc_handover) {
4432 setverdict(pass);
4433 log("f_probe_for_handover(" & log_label & "): Got BSSMAP Handover Required as expected.");
4434 } else {
4435 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected none, but got BSSMAP Handover Required. "
4436 & log_label & ": " & log_descr);
4437 }
4438
4439 log("f_probe_for_handover(" & log_label & "): done (got BSSMAP Handover Required)");
4440
4441 /* Note: f_tc_ho_neighbor_config_start() sets T7, the timeout for BSSMAP Handover Required, to
4442 * 1 second. There is no legal way to quickly abort a handover after a BSSMAP Handover Required,
4443 * setting a short timeout and waiting is the only way. */
4444 log("f_probe_for_handover(" & log_label & "): waiting for inter-BSC HO to time out...");
4445 f_sleep(1.5);
4446 log("f_probe_for_handover(" & log_label & "): ...done");
4447
4448 break;
4449 }
4450 [] T.timeout {
4451 if (expect_handover) {
4452 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected Handover, but got none. "
4453 & log_label & ": " & log_descr);
4454 } else {
4455 setverdict(pass);
4456 log("f_probe_for_handover(" & log_label & "): Got no Handover, as expected.");
4457 }
4458 log("f_probe_for_handover(" & log_label & "): done (got no Handover)");
4459 break;
4460 }
4461 }
4462
4463 f_rslem_resume(RSL1_PROC);
4464 f_rslem_resume(RSL2_PROC);
4465 f_sleep(3.0);
4466 RSL.clear;
4467
4468 log("f_probe_for_handover(" & log_label & "): done clearing");
4469}
4470
4471/* Test the effect of various neighbor configuration scenarios:
4472 *
4473 * To avoid complexity, block off any actual handover operation, and always remain on the lchan at bts 0.
4474 * Reconfigure the neighbors for bts 0, trigger a Handover, and probe whether osmo-bsc does or doesn't start HO.
4475 */
4476private function f_tc_ho_neighbor_config_start() runs on MSC_ConnHdlr {
4477 g_pars := f_gen_test_hdlr_pars();
4478 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4479 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4480 const OCT8 kc := '0001020304050607'O;
4481
4482 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4483 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4484
4485 /* Establish lchan at bts 0 */
4486 f_establish_fully(ass_cmd, exp_compl);
4487
4488 /* Shorten the inter-BSC Handover timeout, to not wait so long for inter-BSC Handovers */
4489 f_vty_enter_cfg_network(BSCVTY);
4490 f_vty_transceive(BSCVTY, "timer T7 1");
4491 f_vty_transceive(BSCVTY, "end");
4492}
4493
4494private function f_tc_ho_neighbor_config_1(charstring id) runs on MSC_ConnHdlr {
4495 f_tc_ho_neighbor_config_start();
4496
4497 /*
4498 * bts 0 ARFCN 871 BSIC 10
4499 * bts 1 ARFCN 871 BSIC 11
4500 * bts 2 ARFCN 871 BSIC 12
4501 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
4502 */
4503
4504 log("f_tc_ho_neighbor_config: 1. No 'neighbor' config");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004505 f_bts_0_cfg(BSCVTY, {"no neighbors"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02004506 f_probe_for_handover("1.a", "HO to bts 1 works, implicitly listed as neighbor (legacy behavior when none are configured)",
4507 "handover any to arfcn 871 bsic 11",
4508 true);
4509
4510 f_probe_for_handover("1.b", "HO to unknown cell does not start",
4511 "handover any to arfcn 13 bsic 39",
4512 false);
4513
4514 f_probe_for_handover("1.c", "HO to 871-12 is ambiguous = error",
4515 "handover any to arfcn 871 bsic 12",
4516 false);
4517
4518 f_probe_for_handover("1.d", "HO to 871-11 still works (verify that this test properly cleans up)",
4519 "handover any to arfcn 871 bsic 11",
4520 true);
4521}
4522private function f_tc_ho_neighbor_config_2(charstring id) runs on MSC_ConnHdlr {
4523 f_tc_ho_neighbor_config_start();
4524
4525 /*
4526 * bts 0 ARFCN 871 BSIC 10
4527 * bts 1 ARFCN 871 BSIC 11
4528 * bts 2 ARFCN 871 BSIC 12
4529 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
4530 */
4531
4532 log("f_tc_ho_neighbor_config: 2. explicit local neighbor: 'neighbor bts 1'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004533 f_bts_0_cfg(BSCVTY, {"neighbor bts 1"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02004534 f_sleep(0.5);
4535
4536 f_probe_for_handover("2.a", "HO to bts 1 works, explicitly listed as neighbor",
4537 "handover any to arfcn 871 bsic 11",
4538 true);
4539
4540 f_probe_for_handover("2.b", "HO to bts 2 doesn't work, not listed as neighbor",
4541 "handover any to arfcn 871 bsic 12",
4542 false);
4543}
4544private function f_tc_ho_neighbor_config_3(charstring id) runs on MSC_ConnHdlr {
4545 f_tc_ho_neighbor_config_start();
4546
4547 /*
4548 * bts 0 ARFCN 871 BSIC 10
4549 * bts 1 ARFCN 871 BSIC 11
4550 * bts 2 ARFCN 871 BSIC 12
4551 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
4552 */
4553
4554 log("f_tc_ho_neighbor_config: 3. explicit local neighbor: 'neighbor bts 2'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004555 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor bts 2"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02004556 f_sleep(0.5);
4557
4558 f_probe_for_handover("3.a", "HO to bts 1 doesn't work, not listed as neighbor",
4559 "handover any to arfcn 871 bsic 11",
4560 false);
4561 f_probe_for_handover("3.b", "HO to bts 2 works, explicitly listed as neighbor; no ambiguity because bts 3 is not listed as neighbor",
4562 "handover any to arfcn 871 bsic 12",
4563 true);
4564}
4565private function f_tc_ho_neighbor_config_4(charstring id) runs on MSC_ConnHdlr {
4566 f_tc_ho_neighbor_config_start();
4567
4568 /*
4569 * bts 0 ARFCN 871 BSIC 10
4570 * bts 1 ARFCN 871 BSIC 11
4571 * bts 2 ARFCN 871 BSIC 12
4572 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
4573 */
4574
4575 log("f_tc_ho_neighbor_config: 4. explicit remote neighbor: 'neighbor lac 99 arfcn 123 bsic 45'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004576 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor lac 99 arfcn 123 bsic 45"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02004577 f_sleep(0.5);
4578
4579 f_probe_for_handover("4.a", "HO to bts 1 doesn't work, not listed as neighbor",
4580 "handover any to arfcn 871 bsic 11",
4581 false);
4582 f_probe_for_handover("4.b", "HO to bts 2 doesn't work, not listed as neighbor",
4583 "handover any to arfcn 871 bsic 12",
4584 false);
4585 f_probe_for_handover("4.c", "HO to 123-45 triggers inter-BSC HO",
4586 "handover any to arfcn 123 bsic 45",
4587 true, true);
4588}
4589private function f_tc_ho_neighbor_config_5(charstring id) runs on MSC_ConnHdlr {
4590 f_tc_ho_neighbor_config_start();
4591
4592 /*
4593 * bts 0 ARFCN 871 BSIC 10
4594 * bts 1 ARFCN 871 BSIC 11
4595 * bts 2 ARFCN 871 BSIC 12
4596 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
4597 */
4598
4599 log("f_tc_ho_neighbor_config: 5. explicit remote neighbor re-using ARFCN+BSIC: 'neighbor lac 99 arfcn 871 bsic 12'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004600 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor lac 99 arfcn 871 bsic 12"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02004601 f_sleep(0.5);
4602
4603 f_probe_for_handover("5.a", "HO to 871-12 triggers inter-BSC HO (ignoring local cells with same ARFCN+BSIC)",
4604 "handover any to arfcn 871 bsic 12",
4605 true, true);
4606}
4607private function f_tc_ho_neighbor_config_6(charstring id) runs on MSC_ConnHdlr {
4608 f_tc_ho_neighbor_config_start();
4609
4610 /*
4611 * bts 0 ARFCN 871 BSIC 10
4612 * bts 1 ARFCN 871 BSIC 11
4613 * bts 2 ARFCN 871 BSIC 12
4614 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
4615 */
4616
4617 log("f_tc_ho_neighbor_config: 6. config error: explicit local and remote neighbors with ambiguous ARFCN+BSIC:"
4618 & " 'neighbor bts 2; neighbor lac 99 arfcn 871 bsic 12'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004619 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor bts 2", "neighbor lac 99 arfcn 871 bsic 12"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02004620 f_sleep(0.5);
4621
4622 f_probe_for_handover("6.a", "HO to 871-12 is ambiguous = error",
4623 "handover any to arfcn 871 bsic 12",
4624 false);
4625}
4626private function f_tc_ho_neighbor_config_7(charstring id) runs on MSC_ConnHdlr {
4627 f_tc_ho_neighbor_config_start();
4628
4629 /*
4630 * bts 0 ARFCN 871 BSIC 10
4631 * bts 1 ARFCN 871 BSIC 11
4632 * bts 2 ARFCN 871 BSIC 12
4633 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
4634 */
4635
4636 log("f_tc_ho_neighbor_config: 7. explicit local and remote neighbors:"
4637 & " 'neighbor bts 2; neighbor lac 99 arfcn 123 bsic 45'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004638 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor bts 2", "neighbor lac 99 arfcn 123 bsic 45"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02004639 f_sleep(0.5);
4640
4641 f_probe_for_handover("7.a", "HO to 871-12 does HO to bts 2",
4642 "handover any to arfcn 871 bsic 12",
4643 true);
4644 f_probe_for_handover("7.b", "HO to 123-45 triggers inter-BSC HO",
4645 "handover any to arfcn 123 bsic 45",
4646 true, true);
4647}
4648
4649testcase TC_ho_neighbor_config_1() runs on test_CT {
4650 var MSC_ConnHdlr vc_conn;
Neels Hofmeyrf2b88032020-06-16 00:35:04 +02004651 f_init(3, true, guard_timeout := 60.0);
Neels Hofmeyr91401012019-07-11 00:42:35 +02004652 f_sleep(1.0);
4653 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_1));
4654 vc_conn.done;
4655}
4656testcase TC_ho_neighbor_config_2() runs on test_CT {
4657 var MSC_ConnHdlr vc_conn;
Neels Hofmeyrf2b88032020-06-16 00:35:04 +02004658 f_init(3, true, guard_timeout := 50.0);
Neels Hofmeyr91401012019-07-11 00:42:35 +02004659 f_sleep(1.0);
4660 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_2));
4661 vc_conn.done;
4662}
4663testcase TC_ho_neighbor_config_3() runs on test_CT {
4664 var MSC_ConnHdlr vc_conn;
Neels Hofmeyrf2b88032020-06-16 00:35:04 +02004665 f_init(3, true, guard_timeout := 50.0);
Neels Hofmeyr91401012019-07-11 00:42:35 +02004666 f_sleep(1.0);
4667 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_3));
4668 vc_conn.done;
4669}
4670testcase TC_ho_neighbor_config_4() runs on test_CT {
4671 var MSC_ConnHdlr vc_conn;
Neels Hofmeyrf2b88032020-06-16 00:35:04 +02004672 f_init(3, true, guard_timeout := 50.0);
Neels Hofmeyr91401012019-07-11 00:42:35 +02004673 f_sleep(1.0);
4674 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_4));
4675 vc_conn.done;
4676}
4677testcase TC_ho_neighbor_config_5() runs on test_CT {
4678 var MSC_ConnHdlr vc_conn;
4679 f_init(3, true);
4680 f_sleep(1.0);
4681 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_5));
4682 vc_conn.done;
4683}
4684testcase TC_ho_neighbor_config_6() runs on test_CT {
4685 var MSC_ConnHdlr vc_conn;
4686 f_init(3, true);
4687 f_sleep(1.0);
4688 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_6));
4689 vc_conn.done;
4690}
4691testcase TC_ho_neighbor_config_7() runs on test_CT {
4692 var MSC_ConnHdlr vc_conn;
Neels Hofmeyrf2b88032020-06-16 00:35:04 +02004693 f_init(3, true, guard_timeout := 50.0);
Neels Hofmeyr91401012019-07-11 00:42:35 +02004694 f_sleep(1.0);
4695 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_7));
4696 vc_conn.done;
4697}
4698
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01004699/* OS#3041: Open and close N connections in a normal fashion, and expect no
4700 * BSSMAP Reset just because of that. */
4701testcase TC_bssap_rlsd_does_not_cause_bssmap_reset() runs on test_CT {
4702 var default d;
4703 var integer i;
4704 var DchanTuple dt;
4705
4706 f_init();
4707
4708 /* Wait for initial BSSMAP Reset to pass */
4709 f_sleep(4.0);
4710
4711 d := activate(no_bssmap_reset());
4712
4713 /* Setup up a number of connections and RLSD them again from the MSC
4714 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
4715 * Let's do it some more times for good measure. */
Harald Weltec3260d92018-06-11 17:48:16 +02004716 for (i := 0; i < 4; i := i+1) {
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01004717 /* Since we're doing a lot of runs, give each one a fresh
4718 * T_guard from the top. */
4719 T_guard.start;
4720
4721 /* Setup a BSSAP connection and clear it right away. This is
4722 * the MSC telling the BSC about a planned release, it's not an
4723 * erratic loss of a connection. */
Harald Weltea1897182018-06-11 13:53:09 +02004724 dt := f_est_dchan(int2oct(i,1), 23+i, '00010203040506'O);
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01004725
4726 /* MSC disconnects (RLSD). */
4727 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
4728 }
4729
4730 /* In the buggy behavior, a timeout of 2 seconds happens between above
4731 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
4732 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
4733 f_sleep(4.0);
4734
4735 deactivate(d);
4736 f_shutdown_helper();
4737}
Harald Welte552620d2017-12-16 23:21:36 +01004738
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01004739/* OS#3041: Open and close N connections in a normal fashion, and expect no
4740 * BSSMAP Reset just because of that. Invoke the release by a BSSMAP Clear from
4741 * the MSC. */
4742testcase TC_bssmap_clear_does_not_cause_bssmap_reset() runs on test_CT {
4743 var default d;
4744 var integer i;
4745 var DchanTuple dt;
4746 var BSSAP_N_DATA_ind rx_di;
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01004747 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_CALL_CONTROL;
4748 var BssmapCause cause := enum2int(cause_val);
4749
4750 f_init();
4751
4752 /* Wait for initial BSSMAP Reset to pass */
4753 f_sleep(4.0);
4754
4755 d := activate(no_bssmap_reset());
4756
4757 /* Setup up a number of connections and RLSD them again from the MSC
4758 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
4759 * Let's do it some more times for good measure. */
4760 for (i := 0; i < 8; i := i+1) {
4761 /* Since we're doing a lot of runs, give each one a fresh
4762 * T_guard from the top. */
4763 T_guard.start;
4764
4765 /* Setup a BSSAP connection and clear it right away. This is
4766 * the MSC telling the BSC about a planned release, it's not an
4767 * erratic loss of a connection. */
Harald Weltea1897182018-06-11 13:53:09 +02004768 dt := f_est_dchan(int2oct(i,1), 23+i, '00010203040506'O);
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01004769
4770 /* Instruct BSC to clear channel */
4771 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
4772
4773 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02004774 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01004775 }
4776
4777 /* In the buggy behavior, a timeout of 2 seconds happens between above
4778 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
4779 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
4780 f_sleep(4.0);
4781
4782 deactivate(d);
4783 f_shutdown_helper();
4784}
4785
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01004786/* OS#3041: Open and close N connections in a normal fashion, and expect no
4787 * BSSMAP Reset just because of that. Close connections from the MS side with a
4788 * Release Ind on RSL. */
4789testcase TC_ms_rel_ind_does_not_cause_bssmap_reset() runs on test_CT {
4790 var default d;
4791 var integer i;
4792 var DchanTuple dt;
4793 var BSSAP_N_DATA_ind rx_di;
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01004794 var integer j;
4795
4796 f_init();
4797
4798 /* Wait for initial BSSMAP Reset to pass */
4799 f_sleep(4.0);
4800
4801 d := activate(no_bssmap_reset());
4802
4803 /* Setup up a number of connections and RLSD them again from the MSC
4804 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
4805 * Let's do it some more times for good measure. */
4806 for (i := 0; i < 8; i := i+1) {
4807 /* Since we're doing a lot of runs, give each one a fresh
4808 * T_guard from the top. */
4809 T_guard.start;
4810
4811 /* Setup a BSSAP connection and clear it right away. This is
4812 * the MSC telling the BSC about a planned release, it's not an
4813 * erratic loss of a connection. */
4814 dt := f_est_dchan('23'O, 23, '00010203040506'O);
4815
4816 /* simulate RLL REL IND */
4817 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0))));
4818
4819 /* expect Clear Request on MSC side */
4820 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
4821
4822 /* Instruct BSC to clear channel */
4823 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
4824 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
4825
4826 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02004827 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01004828 }
4829
4830 /* In the buggy behavior, a timeout of 2 seconds happens between above
4831 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
4832 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
4833 f_sleep(4.0);
4834
4835 deactivate(d);
4836 f_shutdown_helper();
4837}
4838
Harald Welte94e0c342018-04-07 11:33:23 +02004839/***********************************************************************
4840 * IPA style dynamic PDCH
4841 ***********************************************************************/
4842
4843private function f_dyn_ipa_pdch_act(integer bts_nr, integer trx_nr, integer ts_nr,
4844 template (omit) RSL_Cause nack := omit)
4845runs on test_CT {
4846 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(ts_nr));
4847 var RSL_Message rsl_unused;
4848 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
4849 f_vty_ts_action("pdch activate", bts_nr, trx_nr, ts_nr);
4850 /* expect the BSC to issue the related RSL command */
4851 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
4852 if (istemplatekind(nack, "omit")) {
4853 /* respond with a related acknowledgement */
4854 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
4855 } else {
4856 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_NACK(chan_nr, valueof(nack)));
4857 }
4858}
4859
4860private function f_dyn_ipa_pdch_deact(integer bts_nr, integer trx_nr, integer ts_nr,
4861 template (omit) RSL_Cause nack := omit)
4862runs on test_CT {
4863 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(ts_nr));
4864 var RSL_Message rsl_unused;
4865 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
4866 f_vty_ts_action("pdch deactivate", bts_nr, trx_nr, ts_nr);
4867 /* expect the BSC to issue the related RSL command */
4868 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_DEACT(chan_nr));
4869 if (istemplatekind(nack, "omit")) {
4870 /* respond with a related acknowledgement */
4871 f_ipa_tx(0, ts_RSL_IPA_PDCH_DEACT_ACK(chan_nr));
4872 } else {
4873 f_ipa_tx(0, ts_RSL_IPA_PDCH_DEACT_NACK(chan_nr, valueof(nack)));
4874 }
4875}
4876
4877private function f_ts_dyn_mode_get(integer bts_nr, integer trx_nr, integer ts_nr)
4878runs on test_CT return charstring {
4879 var charstring cmd, resp;
4880 cmd := "show timeslot "&int2str(bts_nr)&" "&int2str(trx_nr)&" "&int2str(ts_nr);
Stefan Sperlingcff13562018-11-13 15:24:06 +01004881 return f_vty_transceive_match_regexp_retry(BSCVTY, cmd, "*\((*)\)*", 0, 4, 1.0);
Harald Welte94e0c342018-04-07 11:33:23 +02004882}
4883
4884private function f_ts_dyn_mode_assert(integer bts_nr, integer trx_nr, integer ts_nr,
4885 template charstring exp)
4886runs on test_CT {
4887 var charstring mode := f_ts_dyn_mode_get(bts_nr, trx_nr, ts_nr);
4888 if (not match(mode, exp)) {
4889 setverdict(fail, "Unexpected TS Mode: ", mode);
Daniel Willmannafce8662018-07-06 23:11:32 +02004890 mtc.stop;
Harald Welte94e0c342018-04-07 11:33:23 +02004891 }
4892}
4893
4894private function f_ts_set_chcomb(integer bts_nr, integer trx_nr, integer ts_nr, charstring chcomb)
4895runs on test_CT {
4896 f_vty_enter_cfg_ts(BSCVTY, bts_nr, trx_nr, ts_nr);
4897 f_vty_transceive(BSCVTY, "phys_chan_config " & chcomb);
4898 f_vty_transceive(BSCVTY, "end");
4899}
4900
4901private const charstring TCHF_MODE := "TCH/F mode";
4902private const charstring TCHH_MODE := "TCH/H mode";
4903private const charstring PDCH_MODE := "PDCH mode";
4904private const charstring NONE_MODE := "NONE mode";
4905
4906/* Test IPA PDCH activation / deactivation triggered by VTY */
4907testcase TC_dyn_pdch_ipa_act_deact() runs on test_CT {
4908 var RSL_Message rsl_unused;
4909
4910 /* change Timeslot 6 before f_init() starts RSL */
4911 f_init_vty();
4912 f_ts_set_chcomb(0, 0, 6, "TCH/F_PDCH");
4913 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
4914
4915 f_init(1, false);
4916 f_sleep(1.0);
4917
4918 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
4919
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02004920 log("TCH/F_PDCH pchan starts out in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02004921 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
4922 /* The BSC will activate the dynamic PDCH by default, so confirm that */
4923 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
4924 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
4925 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02004926 log("TCH/F_PDCH pchan, PDCH ACT was ACKed, so now in PDCH mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02004927 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
4928
4929 /* De-activate it via VTY */
4930 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
4931 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02004932 log("TCH/F_PDCH pchan, PDCH DEACT via VTY, so now back in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02004933 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
4934
4935 /* re-activate it via VTY */
4936 f_dyn_ipa_pdch_act(0, 0, chan_nr.tn);
4937 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02004938 log("TCH/F_PDCH pchan, PDCH ACT via VTY, so now in PDCH mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02004939 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
4940
4941 /* and finally de-activate it again */
4942 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
4943 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02004944 log("TCH/F_PDCH pchan, PDCH DEACT via VTY, so now back in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02004945 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
4946
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02004947 /* clean up config */
4948 f_ts_set_chcomb(0, 0, 6, "PDCH");
4949
Harald Welte94e0c342018-04-07 11:33:23 +02004950 setverdict(pass);
4951}
4952
4953/* Test IPA PDCH activation NACK */
4954testcase TC_dyn_pdch_ipa_act_nack() runs on test_CT {
4955 var RSL_Message rsl_unused;
4956
4957 /* change Timeslot 6 before f_init() starts RSL */
4958 f_init_vty();
4959 f_ts_set_chcomb(0, 0, 6, "TCH/F_PDCH");
4960 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
4961
4962 f_init(1, false);
4963 f_sleep(1.0);
4964
4965 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
4966
4967 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
4968 /* The BSC will activate the dynamic PDCH by default, so confirm that */
4969 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
4970 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
4971 f_sleep(1.0);
4972 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
4973
4974 /* De-activate it via VTY */
4975 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
4976 f_sleep(1.0);
4977 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
4978
4979 /* re-activate it via VTY, but fail that; check BSC still assumes TCH/F mode */
4980 f_dyn_ipa_pdch_act(0, 0, chan_nr.tn, RSL_ERR_EQUIPMENT_FAIL);
4981 f_sleep(1.0);
4982 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
4983
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02004984 /* clean up config */
4985 f_ts_set_chcomb(0, 0, 6, "PDCH");
4986
Harald Welte94e0c342018-04-07 11:33:23 +02004987 setverdict(pass);
4988}
4989
4990
4991/***********************************************************************
4992 * Osmocom style dynamic PDCH
4993 ***********************************************************************/
4994
4995private function f_dyn_osmo_pdch_act(integer bts_nr, integer trx_nr, integer ts_nr,
4996 template (omit) RSL_Cause nack := omit)
4997runs on test_CT {
4998 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(ts_nr));
4999 var RSL_Message rsl_unused;
5000 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
5001 /* FIXME: no VTY command to activate Osmocom PDCH !! */
5002 /* expect the BSC to issue the related RSL command */
5003 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT(chan_nr, ?));
5004 if (istemplatekind(nack, "omit")) {
5005 /* respond with a related acknowledgement */
5006 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342));
5007 } else {
5008 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, valueof(nack)));
5009 }
5010}
5011
5012private function f_dyn_osmo_pdch_deact(integer bts_nr, integer trx_nr, integer ts_nr,
5013 template (omit) RSL_Cause nack := omit)
5014runs on test_CT {
5015 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(ts_nr));
5016 var RSL_Message rsl_unused;
5017 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
5018 /* FIXME: no VTY command to activate Osmocom PDCH !! */
5019 /* expect the BSC to issue the related RSL command */
5020 rsl_unused := f_exp_ipa_rx(0, tr_RSL_RF_CHAN_REL(chan_nr));
5021 if (istemplatekind(nack, "omit")) {
5022 /* respond with a related acknowledgement */
5023 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(chan_nr));
5024 } else {
5025 //f_ipa_tx(0, ts_RSL_RF_CHAN_REL_NACK(chan_nr, valueof(nack)));
5026 }
5027}
5028
5029/* Test Osmocom dyn PDCH activation / deactivation triggered by VTY */
5030testcase TC_dyn_pdch_osmo_act_deact() runs on test_CT {
5031 var RSL_Message rsl_unused;
5032
5033 /* change Timeslot 6 before f_init() starts RSL */
5034 f_init_vty();
5035 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_PDCH");
5036 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
5037
5038 f_init(1, false);
5039 f_sleep(1.0);
5040
5041 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(6));
5042
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02005043 log("TCH/F_TCH/H_PDCH pchan starts out in disabled mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02005044 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
5045 /* The BSC will activate the dynamic PDCH by default, so confirm that */
5046 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
5047
5048 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342));
5049 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02005050 log("TCH/F_TCH/H_PDCH requested to PDCH ACT on startup, which was ACKed, so now in PDCH:");
Harald Welte94e0c342018-04-07 11:33:23 +02005051 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
5052
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02005053 /* clean up config */
5054 f_ts_set_chcomb(0, 0, 6, "PDCH");
5055
Harald Welte94e0c342018-04-07 11:33:23 +02005056 setverdict(pass);
5057}
5058
5059/* Test Osmocom dyn PDCH activation NACK behavior */
5060testcase TC_dyn_pdch_osmo_act_nack() runs on test_CT {
5061 var RSL_Message rsl_unused;
5062
5063 /* change Timeslot 6 before f_init() starts RSL */
5064 f_init_vty();
5065 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_PDCH");
5066 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
5067
5068 f_init(1, false);
5069 f_sleep(1.0);
5070
5071 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(6));
5072
5073 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
5074 /* The BSC will activate the dynamic PDCH by default, so confirm that */
5075 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
5076
5077 /* NACK this activation and expect the "show timeslot" mode still to be NONE */
5078 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, RSL_ERR_EQUIPMENT_FAIL));
5079 f_sleep(1.0);
5080 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
5081
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02005082 /* clean up config */
5083 f_ts_set_chcomb(0, 0, 6, "PDCH");
5084
Harald Welte94e0c342018-04-07 11:33:23 +02005085 setverdict(pass);
5086}
5087
Stefan Sperling0796a822018-10-05 13:01:39 +02005088testcase TC_chopped_ipa_ping() runs on test_CT {
Stefan Sperling554123f2018-10-09 14:12:30 +02005089 const Integers bsc_ipa_ports := {mp_bsc_rsl_port, mp_bsc_oml_port, mp_bsc_ctrl_port};
Stefan Sperling0796a822018-10-05 13:01:39 +02005090 for (var integer i := 0; i < lengthof(bsc_ipa_ports); i := i + 1) {
5091 IPA_Testing.f_run_TC_chopped_ipa_ping(mp_bsc_ip, bsc_ipa_ports[i], CONNECT_TO_SERVER);
5092 }
5093}
5094
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02005095testcase TC_chopped_ipa_payload() runs on test_CT {
5096 const Integers bsc_ipa_ports := {mp_bsc_rsl_port, mp_bsc_oml_port
5097 /* TODO: mp_bsc_ctrl_port does not work yet */};
5098 for (var integer i := 0; i < lengthof(bsc_ipa_ports); i := i + 1) {
5099 IPA_Testing.f_run_TC_chopped_ipa_payload(mp_bsc_ip, bsc_ipa_ports[i], CONNECT_TO_SERVER);
5100 }
5101}
5102
Pau Espin Pedrol8f773632019-11-05 11:46:53 +01005103/* Verify the BSC sends the MS Power Parameters IE during CHAN ACT to make sure
5104 the BTS does autonomous MS power control loop */
5105testcase TC_assignment_verify_ms_power_params_ie() runs on test_CT {
5106 var MSC_ConnHdlr vc_conn;
5107 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5108 //pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
5109 pars.exp_ms_power_params := true;
5110
5111 f_init(1, true);
5112 f_sleep(1.0);
5113 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
5114 vc_conn.done;
5115}
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02005116
Neels Hofmeyr4f118412020-06-04 15:25:10 +02005117/***********************************************************************
5118 * MSC Pooling
5119 ***********************************************************************/
5120
5121function f_tmsi_nri(integer nri_v, octetstring base_tmsi := '42000023'O, integer nri_bitlen := 10) return octetstring
5122{
5123 return int2oct( oct2int(base_tmsi) + bit2int( (int2bit(nri_v, 32) << ( 24 - nri_bitlen)) ),
5124 4);
5125}
5126
5127template MobileIdentityLV ts_MI_TMSI_NRI_LV(integer nri_v, integer nri_bitlen := 10) :=
5128 ts_MI_TMSI_LV(tmsi := f_tmsi_nri(nri_v, nri_bitlen := nri_bitlen));
5129
5130private function f_perform_clear(RSL_DCHAN_PT rsl) runs on MSC_ConnHdlr {
5131 f_logp("MSC instructs BSC to clear channel");
5132 BSSAP.send(ts_BSSMAP_ClearCommand(0));
5133 interleave {
5134 [] rsl.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
5135 f_logp("Got RSL RR Release");
5136 }
5137 [] rsl.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
5138 f_logp("Got RSL Deact SACCH");
5139 }
5140 [] BSSAP.receive(tr_BSSMAP_ClearComplete) {
5141 f_logp("Got BSSMAP Clear Complete");
5142 /* Also drop the SCCP connection */
5143 BSSAP.send(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_REQ);
5144 }
5145 [] rsl.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
5146 f_logp("Got RSL RF Chan Rel, sending Rel Ack");
5147 rsl.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
5148 }
5149 }
5150}
5151
5152private function f_perform_compl_l3(RSL_DCHAN_PT rsl, template PDU_ML3_MS_NW l3_info, boolean do_clear := true)
5153runs on MSC_ConnHdlr {
5154 timer T := 10.0;
5155 var octetstring l3_enc := enc_PDU_ML3_MS_NW(valueof(l3_info));
5156
5157 f_logp("establish channel, send Complete Layer 3 Info");
5158 f_create_bssmap_exp(l3_enc);
5159
5160 /* RSL_Emulation.f_chan_est() on rsl:
5161 * This is basically code dup with s/RSL/rsl from:
5162 * RSL_Emulation.f_chan_est(g_pars.ra, l3_enc, g_pars.link_id, g_pars.fn);
5163 */
5164 var RSL_Message rx_rsl;
5165 var GsmRrMessage rr;
5166
5167 /* request a channel to be established */
5168 rsl.send(ts_RSLDC_ChanRqd(g_pars.ra, g_pars.fn));
5169 /* expect immediate assignment.
5170 * Code dup with s/RSL/rsl from:
5171 * rx_rsl := f_rx_or_fail(tr_RSL_IMM_ASSIGN);
5172 */
5173 timer Tt := 10.0;
5174
5175 /* request a channel to be established */
5176 Tt.start;
5177 alt {
5178 [] rsl.receive(tr_RSL_IMM_ASSIGN) -> value rx_rsl {
5179 Tt.stop;
5180 }
5181 [] rsl.receive {
5182 setverdict(fail, "Unexpected RSL message on DCHAN");
5183 mtc.stop;
5184 }
5185 [] Tt.timeout {
5186 setverdict(fail, "Timeout waiting for RSL on DCHAN");
5187 mtc.stop;
5188 }
5189 }
5190 rr := dec_GsmRrMessage(rx_rsl.ies[1].body.full_imm_ass_info.payload);
5191 g_chan_nr := rr.payload.imm_ass.chan_desc.chan_nr;
5192 rsl.send(ts_RSL_EST_IND(g_chan_nr, valueof(g_pars.link_id), l3_enc));
5193
5194
5195 f_logp("expect BSSAP Complete Layer 3 Info at MSC");
5196 var template PDU_BSSAP exp_l3_compl;
5197 exp_l3_compl := tr_BSSMAP_ComplL3()
5198 if (g_pars.aoip == false) {
5199 exp_l3_compl.pdu.bssmap.completeLayer3Information.codecList := omit;
5200 } else {
5201 exp_l3_compl.pdu.bssmap.completeLayer3Information.codecList := ?;
5202 }
5203
5204 var PDU_BSSAP bssap;
5205 T.start;
5206 alt {
5207 [] BSSAP.receive(exp_l3_compl) -> value bssap {
5208 f_logp("received expected Complete Layer 3 Info at MSC");
5209 log("rx exp_l3_compl = ", bssap);
5210 }
5211 [] BSSAP.receive(tr_BSSMAP_ComplL3) {
5212 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received non-matching COMPLETE LAYER 3 INFORMATION");
5213 }
5214 [] T.timeout {
5215 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for COMPLETE LAYER 3 INFORMATION");
5216 }
5217 }
5218
5219 /* start ciphering, if requested */
5220 if (ispresent(g_pars.encr)) {
5221 f_logp("start ciphering");
5222 f_cipher_mode(g_pars.encr.enc_alg, g_pars.encr.enc_key);
5223 }
5224
5225 if (do_clear) {
5226 f_perform_clear(rsl);
5227 }
5228 setverdict(pass);
5229 f_sleep(1.0);
5230}
5231
5232private function f_tc_mscpool_compl_l3(charstring id) runs on MSC_ConnHdlr {
5233 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5234 if (g_pars.mscpool.rsl_idx == 0) {
5235 f_perform_compl_l3(RSL, g_pars.mscpool.l3_info);
5236 } else if (g_pars.mscpool.rsl_idx == 1) {
5237 f_perform_compl_l3(RSL1, g_pars.mscpool.l3_info);
5238 } else if (g_pars.mscpool.rsl_idx == 2) {
5239 f_perform_compl_l3(RSL2, g_pars.mscpool.l3_info);
5240 }
5241}
5242
5243/* Various Complete Layer 3 by IMSI all end up with the first MSC, because the other MSCs are not connected. */
5244private function f_tc_mscpool_L3Compl_on_1_msc(charstring id) runs on MSC_ConnHdlr {
5245 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5246 f_perform_compl_l3(RSL, ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000001'H)), '00F110'O) );
5247 f_perform_compl_l3(RSL, ts_CM_SERV_REQ(CM_TYPE_MO_SMS, valueof(ts_MI_IMSI_LV('001010000000002'H))) );
5248 f_perform_compl_l3(RSL, ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010000000003'H))) );
5249 f_perform_compl_l3(RSL, ts_ML3_MO_MM_IMSI_DET_Ind(valueof(ts_MI_IMSI_LV('001010000000004'H))) );
5250}
5251testcase TC_mscpool_L3Compl_on_1_msc() runs on test_CT {
5252
5253 f_init(1, true);
5254 f_sleep(1.0);
5255 var MSC_ConnHdlr vc_conn;
5256 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02005257
5258 f_ctrs_msc_init();
5259
Neels Hofmeyr4f118412020-06-04 15:25:10 +02005260 vc_conn := f_start_handler(refers(f_tc_mscpool_L3Compl_on_1_msc), pars);
5261 vc_conn.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02005262
5263 f_ctrs_msc_expect(0, "mscpool:subscr:new", 4);
Neels Hofmeyr4f118412020-06-04 15:25:10 +02005264}
5265
5266/* Three Layer 3 Complete by IMSI are round-robin'ed across two connected MSCs */
5267/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
5268 * just as well using only RSL. */
5269testcase TC_mscpool_L3Complete_by_imsi_round_robin() runs on test_CT {
5270
5271 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
5272 f_sleep(1.0);
5273
5274 /* Control which MSC gets chosen next by the round-robin, otherwise
5275 * would be randomly affected by which other tests ran before this. */
5276 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
5277
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02005278 f_ctrs_msc_init();
5279
Neels Hofmeyr4f118412020-06-04 15:25:10 +02005280 var MSC_ConnHdlr vc_conn1;
5281 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
5282 pars1.mscpool.rsl_idx := 0;
5283 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000001'H)), '00F110'O));
5284 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
5285 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02005286 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02005287
5288 var MSC_ConnHdlr vc_conn2;
5289 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
5290 pars2.mscpool.rsl_idx := 1;
5291 pars2.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000002'H))));
5292 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
5293 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02005294 f_ctrs_msc_expect(1, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02005295
5296 /* Test round-robin wrap to the first MSC */
5297 var MSC_ConnHdlr vc_conn3;
5298 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
5299 pars3.mscpool.rsl_idx := 2;
5300 pars3.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010000000003'H))));
5301 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
5302 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02005303 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02005304}
5305
5306/* Three LU by TMSI are round-robin'ed across two connected MSCs, because they contain the NULL-NRI 0
5307 * (configured in osmo-bsc.cfg). */
5308/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
5309 * just as well using only RSL. */
5310testcase TC_mscpool_LU_by_tmsi_null_nri_0_round_robin() runs on test_CT {
5311
5312 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
5313 f_sleep(1.0);
5314
5315 /* Control which MSC gets chosen next by the round-robin, otherwise
5316 * would be randomly affected by which other tests ran before this. */
5317 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
5318
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02005319 f_ctrs_msc_init();
5320
Neels Hofmeyr4f118412020-06-04 15:25:10 +02005321 var MSC_ConnHdlr vc_conn1;
5322 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
5323 pars1.mscpool.rsl_idx := 0;
5324 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(0)), '00F110'O));
5325 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
5326 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02005327 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02005328
5329 var MSC_ConnHdlr vc_conn2;
5330 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
5331 pars2.mscpool.rsl_idx := 1;
5332 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(0)), '00F110'O));
5333 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
5334 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02005335 f_ctrs_msc_expect(1, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02005336
5337 /* Test round-robin wrap to the first MSC */
5338 var MSC_ConnHdlr vc_conn3;
5339 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
5340 pars3.mscpool.rsl_idx := 2;
5341 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(0)), '00F110'O));
5342 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
5343 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02005344 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02005345}
5346
5347/* Three LU by TMSI are round-robin'ed across two connected MSCs, because they contain the NULL-NRI 1
5348 * (configured in osmo-bsc.cfg). In this case, one of the MSC also has the NULL-NRI as part of its owned NRIs, but the
5349 * NULL-NRI setting is stronger than that. */
5350/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
5351 * just as well using only RSL. */
5352testcase TC_mscpool_LU_by_tmsi_null_nri_1_round_robin() runs on test_CT {
5353
5354 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
5355 f_sleep(1.0);
5356
5357 /* Control which MSC gets chosen next by the round-robin, otherwise
5358 * would be randomly affected by which other tests ran before this. */
5359 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
5360
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02005361 f_ctrs_msc_init();
5362
Neels Hofmeyr4f118412020-06-04 15:25:10 +02005363 var MSC_ConnHdlr vc_conn1;
5364 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
5365 pars1.mscpool.rsl_idx := 0;
5366 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(1)), '00F110'O));
5367 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
5368 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02005369 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02005370
5371 var MSC_ConnHdlr vc_conn2;
5372 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
5373 pars2.mscpool.rsl_idx := 1;
5374 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(1)), '00F110'O));
5375 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
5376 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02005377 f_ctrs_msc_expect(1, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02005378
5379 /* Test round-robin wrap to the first MSC */
5380 var MSC_ConnHdlr vc_conn3;
5381 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
5382 pars3.mscpool.rsl_idx := 2;
5383 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(1)), '00F110'O));
5384 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
5385 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02005386 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02005387}
5388
5389/* Three Layer 3 Complete by TMSI are round-robin'ed across two connected MSCs, because they contain an NRI not
5390 * assigned to any MSC (configured in osmo-bsc.cfg). */
5391/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
5392 * just as well using only RSL. */
5393testcase TC_mscpool_L3Complete_by_tmsi_unassigned_nri_round_robin() runs on test_CT {
5394
5395 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
5396 f_sleep(1.0);
5397
5398 /* Control which MSC gets chosen next by the round-robin, otherwise
5399 * would be randomly affected by which other tests ran before this. */
5400 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
5401
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02005402 f_ctrs_msc_init();
5403
Neels Hofmeyr4f118412020-06-04 15:25:10 +02005404 var MSC_ConnHdlr vc_conn1;
5405 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
5406 pars1.mscpool.rsl_idx := 0;
5407 /* An NRI that is not assigned to any MSC */
5408 pars1.mscpool.l3_info := valueof(ts_ML3_MO_MM_IMSI_DET_Ind(valueof(ts_MI_TMSI_NRI_LV(1023))));
5409 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
5410 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02005411 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02005412
5413 var MSC_ConnHdlr vc_conn2;
5414 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
5415 pars2.mscpool.rsl_idx := 1;
5416 /* An NRI that is not assigned to any MSC */
5417 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(768)), '00F110'O));
5418 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
5419 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02005420 f_ctrs_msc_expect(1, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02005421
5422 /* Test round-robin wrap to the first MSC */
5423 var MSC_ConnHdlr vc_conn3;
5424 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
5425 pars3.mscpool.rsl_idx := 2;
5426 /* An NRI that is not assigned to any MSC */
5427 pars3.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_SS_ACT, valueof(ts_MI_TMSI_NRI_LV(819))));
5428 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
5429 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02005430 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02005431}
5432
5433/* Three Layer 3 Complete by TMSI are round-robin'ed across two connected MSCs, because they contain an NRI
5434 * assigned to an MSC that is currently not connected (configured in osmo-bsc.cfg). */
5435/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
5436 * just as well using only RSL. */
5437testcase TC_mscpool_L3Complete_by_tmsi_valid_nri_msc_not_connected_round_robin() runs on test_CT {
5438
5439 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
5440 f_sleep(1.0);
5441
5442 /* Control which MSC gets chosen next by the round-robin, otherwise
5443 * would be randomly affected by which other tests ran before this. */
5444 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
5445
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02005446 f_ctrs_msc_init();
5447
Neels Hofmeyr4f118412020-06-04 15:25:10 +02005448 var MSC_ConnHdlr vc_conn1;
5449 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
5450 pars1.mscpool.rsl_idx := 0;
5451 /* An NRI that is assigned to an unconnected MSC */
5452 pars1.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(512))));
5453 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
5454 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02005455 f_ctrs_msc_add(2, "mscpool:subscr:attach_lost");
5456 f_ctrs_msc_add(0, "mscpool:subscr:new");
5457 f_ctrs_msc_verify();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02005458
5459 var MSC_ConnHdlr vc_conn2;
5460 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
5461 pars2.mscpool.rsl_idx := 1;
5462 /* An NRI that is assigned to an unconnected MSC */
5463 pars2.mscpool.l3_info := valueof(ts_ML3_MO_MM_IMSI_DET_Ind(valueof(ts_MI_TMSI_NRI_LV(767))));
5464 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
5465 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02005466 f_ctrs_msc_add(2, "mscpool:subscr:attach_lost");
5467 f_ctrs_msc_add(1, "mscpool:subscr:new");
5468 f_ctrs_msc_verify();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02005469
5470 /* Test round-robin wrap to the first MSC */
5471 var MSC_ConnHdlr vc_conn3;
5472 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
5473 pars3.mscpool.rsl_idx := 2;
5474 /* An NRI that is assigned to an unconnected MSC */
5475 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(750)), '00F110'O));
5476 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
5477 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02005478 f_ctrs_msc_add(2, "mscpool:subscr:attach_lost");
5479 f_ctrs_msc_add(0, "mscpool:subscr:new");
5480 f_ctrs_msc_verify();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02005481}
5482
5483/* Three Layer 3 Complete by TMSI with valid NRI for the second MSC are all directed to the second MSC (configured in
5484 * osmo-bsc.cfg). */
5485/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
5486 * just as well using only RSL. */
5487testcase TC_mscpool_L3Complete_by_tmsi_valid_nri_1() runs on test_CT {
5488
5489 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
5490 f_sleep(1.0);
5491
5492 /* All TMSIs in this test point at the second MSC, set the round robin to point at the first MSC to make sure
5493 * this is not using round-robin. */
5494 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
5495
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02005496 f_ctrs_msc_init();
5497
Neels Hofmeyr4f118412020-06-04 15:25:10 +02005498 var MSC_ConnHdlr vc_conn1;
5499 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 1);
5500 pars1.mscpool.rsl_idx := 0;
5501 /* An NRI of the second MSC's range (256-511) */
5502 pars1.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_SMS, valueof(ts_MI_TMSI_NRI_LV(256))));
5503 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
5504 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02005505 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02005506
5507 var MSC_ConnHdlr vc_conn2;
5508 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
5509 pars2.mscpool.rsl_idx := 1;
5510 /* An NRI of the second MSC's range (256-511) */
5511 pars2.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(260))));
5512 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
5513 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02005514 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02005515
5516 var MSC_ConnHdlr vc_conn3;
5517 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 1);
5518 pars3.mscpool.rsl_idx := 2;
5519 /* An NRI of the second MSC's range (256-511) */
5520 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(511)), '00F110'O));
5521 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
5522 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02005523 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02005524}
5525
5526/* Layer 3 Complete by TMSI with valid NRI for the third MSC are directed to the third MSC (configured in osmo-bsc.cfg),
5527 * while a round-robin remains unaffected by that. */
5528/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
5529 * just as well using only RSL. */
5530testcase TC_mscpool_L3Complete_by_tmsi_valid_nri_2() runs on test_CT {
5531
5532 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
5533 f_sleep(1.0);
5534
5535 /* All TMSIs in this test point at the third MSC, set the round robin to point at the second MSC to make sure
5536 * this is not using round-robin. */
5537 f_vty_transceive(BSCVTY, "mscpool roundrobin next 1");
5538
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02005539 f_ctrs_msc_init();
5540
Neels Hofmeyr4f118412020-06-04 15:25:10 +02005541 var MSC_ConnHdlr vc_conn1;
5542 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 2);
5543 pars1.mscpool.rsl_idx := 0;
5544 /* An NRI of the third MSC's range (512-767) */
5545 pars1.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_SMS, valueof(ts_MI_TMSI_NRI_LV(512))));
5546 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
5547 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02005548 f_ctrs_msc_expect(2, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02005549
5550 var MSC_ConnHdlr vc_conn2;
5551 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 2);
5552 pars2.mscpool.rsl_idx := 1;
5553 /* An NRI of the third MSC's range (512-767) */
5554 pars2.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(678))));
5555 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
5556 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02005557 f_ctrs_msc_expect(2, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02005558
5559 /* The above forwardings to third MSC have not affected the round robin, which still points at the second MSC */
5560 var MSC_ConnHdlr vc_conn3;
5561 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 1);
5562 pars3.mscpool.rsl_idx := 2;
5563 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000013'H)), '00F110'O));
5564 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
5565 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02005566 f_ctrs_msc_expect(1, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02005567}
5568
5569/* LU with a TMSI but indicating a different PLMN in its previous LAI: ignore the NRI. */
5570/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
5571 * just as well using only RSL. */
5572testcase TC_mscpool_LU_by_tmsi_from_other_PLMN() runs on test_CT {
5573
5574 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
5575 f_sleep(1.0);
5576
5577 /* The TMSIs in this test points at the second MSC, but since it is from a different PLMN, round-robin is used
5578 * instead, and hits msc 0. */
5579 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
5580
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02005581 f_ctrs_msc_init();
5582
Neels Hofmeyr4f118412020-06-04 15:25:10 +02005583 /* An NRI of the second MSC's range (256-511), but a PLMN that doesn't match with osmo-bsc.cfg */
5584 var MSC_ConnHdlr vc_conn1;
5585 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
5586 pars1.mscpool.rsl_idx := 0;
5587 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(260)), '99F999'O));
5588 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
5589 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02005590 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02005591
5592 /* An NRI of the third MSC's range (512-767) and a matching PLMN gets directed by NRI. */
5593 var MSC_ConnHdlr vc_conn2;
5594 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 2);
5595 pars2.mscpool.rsl_idx := 1;
5596 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(555)), '00F110'O));
5597 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
5598 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02005599 f_ctrs_msc_expect(2, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02005600}
5601
5602/* Make sure that whichever MSC paged a subscriber will also get the Paging Response. Page by IMSI, which would be
5603 * round-robined to another MSC, to make sure the Paging->Response relation is stronger than the NRI->MSC mapping. */
5604private function f_tc_mscpool_paging_imsi(charstring id) runs on MSC_ConnHdlr {
5605 var template BSSMAP_FIELD_CellIdentificationList cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(0) } };
5606 //cid_list := { cIl_allInBSS := ''O };
5607 var RSL_ChanNeeded rsl_chneed := RSL_CHANNEED_SDCCH;
5608 var template BSSMAP_IE_ChannelNeeded bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
5609 var BSSAP_N_UNITDATA_req paging;
5610 var hexstring imsi := '001010000000123'H;
5611
5612 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5613
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005614 paging := valueof(ts_BSSAP_UNITDATA_req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr4f118412020-06-04 15:25:10 +02005615 valueof(ts_BSSMAP_Paging(imsi, cid_list, omit, bssmap_chneed))));
5616 BSSAP.send(paging);
5617
5618 /* Register any RSL conn so that the Paging Command gets received here. With the current RSL_Emulation's main()
5619 * handling of '[bts_role] IPA_PT.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD()))' it doesn't matter at all which
5620 * channel number is picked here. */
5621 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(0, RSL_CHAN_NR_INVALID));
5622 f_rslem_register(0, new_chan_nr);
5623 RSL.receive(tr_RSL_PAGING_CMD(tr_MI_IMSI(imsi)));
5624 f_rslem_unregister(0, new_chan_nr);
5625
5626 /* Despite the round robin pointing at the second MSC ('roundrobin next 1'), the earlier Paging for the same IMSI
5627 * causes this Paging Response to go to the first MSC (bssap_idx := 0). */
5628 f_perform_compl_l3(RSL, ts_PAG_RESP(valueof(ts_MI_IMSI_LV(imsi))) );
5629 setverdict(pass);
5630 f_sleep(1.0);
5631}
5632testcase TC_mscpool_paging_and_response_imsi() runs on test_CT {
5633 f_init(nr_bts := 1, handler_mode := true, nr_msc := 3);
5634 f_sleep(1.0);
5635
5636 /* Testing a Paging on the first MSC to get a Paging Response back to the first MSC. Set round robin to the
5637 * second MSC to make sure we're getting the Paging logic, not a coincidental round robin match. */
5638 f_vty_transceive(BSCVTY, "mscpool roundrobin next 1");
5639
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02005640 f_ctrs_msc_init();
5641
Neels Hofmeyr4f118412020-06-04 15:25:10 +02005642 var MSC_ConnHdlr vc_conn1;
5643 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
5644 pars1.mscpool.rsl_idx := 0;
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005645 pars1.sccp_addr_bsc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_peer;
5646 pars1.sccp_addr_msc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_own;
Neels Hofmeyr4f118412020-06-04 15:25:10 +02005647 vc_conn1 := f_start_handler(refers(f_tc_mscpool_paging_imsi), pars1);
5648 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02005649 f_ctrs_msc_expect(0, "mscpool:subscr:paged");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02005650}
5651
5652/* Make sure that whichever MSC paged a subscriber will also get the Paging Response. Page by TMSI with an NRI value
5653 * that matches a different MSC, to make sure the Paging->Response relation is stronger than the NRI->MSC mapping. */
5654private function f_tc_mscpool_paging_tmsi(charstring id) runs on MSC_ConnHdlr {
5655 var template BSSMAP_FIELD_CellIdentificationList cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(0) } };
5656 //cid_list := { cIl_allInBSS := ''O };
5657 var RSL_ChanNeeded rsl_chneed := RSL_CHANNEED_SDCCH;
5658 var template BSSMAP_IE_ChannelNeeded bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
5659 var integer nri_v := 300; /* <-- second MSC's NRI */
5660 var octetstring tmsi := f_tmsi_nri(nri_v);
5661 var BSSAP_N_UNITDATA_req paging;
5662
5663 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5664
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005665 paging := valueof(ts_BSSAP_UNITDATA_req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr4f118412020-06-04 15:25:10 +02005666 valueof(ts_BSSMAP_Paging('001010000000011'H, cid_list, tmsi, bssmap_chneed))));
5667 BSSAP.send(paging);
5668
5669 /* Register any RSL conn so that the Paging Command gets received here. With the current RSL_Emulation's main()
5670 * handling of '[bts_role] IPA_PT.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD()))' it doesn't matter at all which
5671 * channel number is picked here. */
5672 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(0, RSL_CHAN_NR_INVALID));
5673 f_rslem_register(0, new_chan_nr);
5674 RSL.receive(tr_RSL_PAGING_CMD(t_MI_TMSI(tmsi)));
5675 f_rslem_unregister(0, new_chan_nr);
5676
5677 /* Despite the NRI matching the second MSC (NRI from 'msc 1' in osmo-bsc.cfg) and round robin pointing at the
5678 * third MSC ('roundrobin next 2'), the earlier Paging for the same TMSI causes this Paging Response to go to
5679 * the first MSC (bssap_idx := 0). */
5680 f_perform_compl_l3(RSL, ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(nri_v))) );
5681 setverdict(pass);
5682 f_sleep(1.0);
5683}
5684testcase TC_mscpool_paging_and_response_tmsi() runs on test_CT {
5685 f_init(nr_bts := 1, handler_mode := true, nr_msc := 3);
5686 f_sleep(1.0);
5687
5688 /* Testing a Paging on the first MSC to get a Paging Response back to the first MSC. Set round robin to the
5689 * third MSC to make sure we're getting the Paging logic, not a coincidental round robin match. */
5690 f_vty_transceive(BSCVTY, "mscpool roundrobin next 2");
5691
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02005692 f_ctrs_msc_init();
5693
Neels Hofmeyr4f118412020-06-04 15:25:10 +02005694 var MSC_ConnHdlr vc_conn1;
5695 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
5696 pars1.mscpool.rsl_idx := 0;
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005697 pars1.sccp_addr_bsc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_peer;
5698 pars1.sccp_addr_msc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_own;
Neels Hofmeyr4f118412020-06-04 15:25:10 +02005699 vc_conn1 := f_start_handler(refers(f_tc_mscpool_paging_tmsi), pars1);
5700 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02005701 f_ctrs_msc_expect(0, "mscpool:subscr:paged");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02005702}
5703
5704/* For round-robin, skip an MSC that has 'no allow-attach' set. */
5705/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
5706 * just as well using only RSL. */
5707testcase TC_mscpool_no_allow_attach_round_robin() runs on test_CT {
5708
5709 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
5710 f_sleep(1.0);
5711
5712 /* Control which MSC gets chosen next by the round-robin, otherwise
5713 * would be randomly affected by which other tests ran before this. */
5714 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
5715
5716 /* Mark the second MSC as offloading, round-robin should skip this MSC now. */
5717 f_vty_enter_cfg_msc(BSCVTY, 1);
5718 f_vty_transceive(BSCVTY, "no allow-attach");
5719 f_vty_transceive(BSCVTY, "exit");
5720 f_vty_transceive(BSCVTY, "exit");
5721
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02005722 f_ctrs_msc_init();
5723
Neels Hofmeyr4f118412020-06-04 15:25:10 +02005724 var MSC_ConnHdlr vc_conn1;
5725 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
5726 pars1.mscpool.rsl_idx := 0;
5727 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000001'H)), '00F110'O));
5728 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
5729 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02005730 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02005731
5732 var MSC_ConnHdlr vc_conn2;
5733 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 2);
5734 pars2.mscpool.rsl_idx := 1;
5735 pars2.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000002'H))));
5736 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
5737 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02005738 f_ctrs_msc_expect(2, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02005739
5740 var MSC_ConnHdlr vc_conn3;
5741 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
5742 pars3.mscpool.rsl_idx := 2;
5743 pars3.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010000000003'H))));
5744 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
5745 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02005746 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02005747
5748 f_vty_enter_cfg_msc(BSCVTY, 1);
5749 f_vty_transceive(BSCVTY, "allow-attach");
5750 f_vty_transceive(BSCVTY, "exit");
5751 f_vty_transceive(BSCVTY, "exit");
5752}
5753
5754/* An MSC that has 'no allow-attach' set should still serve subscribers that are already attached according to their
5755 * TMSI NRI. */
5756testcase TC_mscpool_no_allow_attach_valid_nri() runs on test_CT {
5757
5758 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
5759 f_sleep(1.0);
5760
5761 /* Control which MSC gets chosen next by the round-robin, otherwise
5762 * would be randomly affected by which other tests ran before this. */
5763 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
5764
5765 /* Mark the second MSC as offloading, round-robin should skip this MSC now. */
5766 f_vty_enter_cfg_msc(BSCVTY, 1);
5767 f_vty_transceive(BSCVTY, "no allow-attach");
5768 f_vty_transceive(BSCVTY, "exit");
5769 f_vty_transceive(BSCVTY, "exit");
5770
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02005771 f_ctrs_msc_init();
5772
Neels Hofmeyr4f118412020-06-04 15:25:10 +02005773 /* Round robin points at msc 0, but the valid NRI directs to msc 1, even though msc 1 has 'no allow-attach'. */
5774 var MSC_ConnHdlr vc_conn1;
5775 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 1);
5776 pars1.mscpool.rsl_idx := 0;
5777 /* An NRI of the second MSC's range (256-511) */
5778 pars1.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_TMSI_NRI_LV(260))));
5779 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
5780 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02005781 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02005782
5783 var MSC_ConnHdlr vc_conn2;
5784 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 0);
5785 pars2.mscpool.rsl_idx := 1;
5786 pars2.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000002'H))));
5787 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
5788 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02005789 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02005790
5791 var MSC_ConnHdlr vc_conn3;
5792 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 2);
5793 pars3.mscpool.rsl_idx := 2;
5794 pars3.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000003'H))));
5795 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
5796 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02005797 f_ctrs_msc_expect(2, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02005798
5799 f_vty_enter_cfg_msc(BSCVTY, 1);
5800 f_vty_transceive(BSCVTY, "allow-attach");
5801 f_vty_transceive(BSCVTY, "exit");
5802 f_vty_transceive(BSCVTY, "exit");
5803}
5804
Harald Welte0ea2d5e2018-04-07 21:40:29 +02005805/* Dyn PDCH todo:
5806 * activate OSMO as TCH/F
5807 * activate OSMO as TCH/H
5808 * does the BSC-located PCU socket get the updated INFO?
5809 * what if no PCU is connected at the time?
5810 * is the info correct on delayed PCU (re)connect?
5811 */
Harald Welte94e0c342018-04-07 11:33:23 +02005812
Harald Welte28d943e2017-11-25 15:00:50 +01005813control {
Harald Welte898113b2018-01-31 18:32:21 +01005814 /* CTRL interface testing */
Harald Welte4003d112017-12-09 22:35:39 +01005815 execute( TC_ctrl_msc_connection_status() );
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01005816 execute( TC_ctrl_msc0_connection_status() );
Harald Welte96c94412017-12-09 03:12:45 +01005817 execute( TC_ctrl() );
Neels Hofmeyrf246a922020-05-13 02:27:10 +02005818 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_SCCPlite_SERVER) {
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +02005819 execute( TC_ctrl_location() );
5820 }
Harald Welte898113b2018-01-31 18:32:21 +01005821
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02005822 execute( TC_si_default() );
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02005823 execute( TC_si2quater_2_earfcns() );
5824 execute( TC_si2quater_3_earfcns() );
5825 execute( TC_si2quater_4_earfcns() );
5826 execute( TC_si2quater_5_earfcns() );
5827 execute( TC_si2quater_6_earfcns() );
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02005828
Harald Welte898113b2018-01-31 18:32:21 +01005829 /* RSL DCHAN Channel ACtivation / Deactivation */
Harald Welteae026692017-12-09 01:03:01 +01005830 execute( TC_chan_act_noreply() );
Harald Welte4003d112017-12-09 22:35:39 +01005831 execute( TC_chan_act_counter() );
Harald Welteae026692017-12-09 01:03:01 +01005832 execute( TC_chan_act_ack_noest() );
5833 execute( TC_chan_act_ack_est_ind_noreply() );
5834 execute( TC_chan_act_ack_est_ind_refused() );
Harald Welte618ef642017-12-14 14:58:20 +01005835 execute( TC_chan_act_nack() );
Harald Welte799c97b2017-12-14 17:50:30 +01005836 execute( TC_chan_exhaustion() );
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07005837 execute( TC_chan_deact_silence() );
Harald Welte4003d112017-12-09 22:35:39 +01005838 execute( TC_chan_rel_rll_rel_ind() );
5839 execute( TC_chan_rel_conn_fail() );
5840 execute( TC_chan_rel_hard_clear() );
Harald Welte99787102019-02-04 10:41:36 +01005841 execute( TC_chan_rel_hard_clear_csfb() );
Harald Welted8c36cd2017-12-09 23:05:31 +01005842 execute( TC_chan_rel_hard_rlsd() );
Harald Welte550daf92018-06-11 19:22:13 +02005843 execute( TC_chan_rel_hard_rlsd_ms_dead() );
Harald Welte85804d42017-12-10 14:11:58 +01005844 execute( TC_chan_rel_a_reset() );
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01005845 execute( TC_chan_rel_sccp_tiar_timeout() );
Harald Welte6f521d82017-12-11 19:52:02 +01005846
Harald Weltecfe2c962017-12-15 12:09:32 +01005847 execute( TC_outbound_connect() );
Harald Welte898113b2018-01-31 18:32:21 +01005848
5849 /* Assignment related */
Harald Welte16a4adf2017-12-14 18:54:01 +01005850 execute( TC_assignment_cic_only() );
Harald Welte235ebf12017-12-15 14:18:16 +01005851 execute( TC_assignment_csd() );
5852 execute( TC_assignment_ctm() );
5853 execute( TC_assignment_sign() );
5854 execute( TC_assignment_fr_a5_0() );
5855 execute( TC_assignment_fr_a5_1() );
Neels Hofmeyrf246a922020-05-13 02:27:10 +02005856 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welte8f67d1d2018-05-25 20:38:42 +02005857 execute( TC_assignment_fr_a5_1_codec_missing() );
5858 }
Harald Welte235ebf12017-12-15 14:18:16 +01005859 execute( TC_assignment_fr_a5_3() );
5860 execute( TC_assignment_fr_a5_4() );
Harald Welte3c86ea02018-05-10 22:28:05 +02005861 execute( TC_ciph_mode_a5_0() );
5862 execute( TC_ciph_mode_a5_1() );
5863 execute( TC_ciph_mode_a5_3() );
Harald Welte16a4adf2017-12-14 18:54:01 +01005864
Harald Welte60aa5762018-03-21 19:33:13 +01005865 execute( TC_assignment_codec_fr() );
5866 execute( TC_assignment_codec_hr() );
5867 execute( TC_assignment_codec_efr() );
5868 execute( TC_assignment_codec_amr_f() );
5869 execute( TC_assignment_codec_amr_h() );
Philipp Maier8a581d22019-03-26 18:32:48 +01005870
Neels Hofmeyrf246a922020-05-13 02:27:10 +02005871 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Philipp Maier8a581d22019-03-26 18:32:48 +01005872 execute( TC_assignment_codec_amr_f_S1() );
5873 execute( TC_assignment_codec_amr_h_S1() );
5874 execute( TC_assignment_codec_amr_f_S124() );
5875 execute( TC_assignment_codec_amr_h_S124() );
5876 execute( TC_assignment_codec_amr_f_S0() );
5877 execute( TC_assignment_codec_amr_f_S02() );
5878 execute( TC_assignment_codec_amr_f_S024() );
5879 execute( TC_assignment_codec_amr_f_S0247() );
5880 execute( TC_assignment_codec_amr_h_S0() );
5881 execute( TC_assignment_codec_amr_h_S02() );
5882 execute( TC_assignment_codec_amr_h_S024() );
5883 execute( TC_assignment_codec_amr_h_S0247() );
5884 execute( TC_assignment_codec_amr_f_S01234567() );
5885 execute( TC_assignment_codec_amr_f_S0234567() );
5886 execute( TC_assignment_codec_amr_f_zero() );
5887 execute( TC_assignment_codec_amr_f_unsupp() );
5888 execute( TC_assignment_codec_amr_h_S7() );
5889 }
Harald Welte60aa5762018-03-21 19:33:13 +01005890
Philipp Maierac09bfc2019-01-08 13:41:39 +01005891 execute( TC_assignment_codec_fr_exhausted_req_hr() );
5892 execute( TC_assignment_codec_fr_exhausted_req_fr() );
5893 execute( TC_assignment_codec_fr_exhausted_req_fr_hr() );
5894 execute( TC_assignment_codec_fr_exhausted_req_hr_fr() );
5895 execute( TC_assignment_codec_hr_exhausted_req_fr() );
5896 execute( TC_assignment_codec_hr_exhausted_req_hr() );
5897 execute( TC_assignment_codec_hr_exhausted_req_hr_fr() );
5898 execute( TC_assignment_codec_hr_exhausted_req_fr_hr() );
5899 execute( TC_assignment_codec_req_hr_fr() );
5900 execute( TC_assignment_codec_req_fr_hr() );
5901
Pau Espin Pedrol58cf6822019-05-28 18:11:33 +02005902 if (mp_enable_osmux_test) {
5903 execute( TC_assignment_osmux() );
5904 }
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02005905
Harald Welte898113b2018-01-31 18:32:21 +01005906 /* RLL Establish Indication on inactive DCHAN / SAPI */
Harald Welte5cd20ed2017-12-13 21:03:20 +01005907 execute( TC_rll_est_ind_inact_lchan() );
5908 execute( TC_rll_est_ind_inval_sapi1() );
5909 execute( TC_rll_est_ind_inval_sapi3() );
5910 execute( TC_rll_est_ind_inval_sacch() );
5911
Harald Welte898113b2018-01-31 18:32:21 +01005912 /* Paging related tests */
Harald Welte6f521d82017-12-11 19:52:02 +01005913 execute( TC_paging_imsi_nochan() );
5914 execute( TC_paging_tmsi_nochan() );
5915 execute( TC_paging_tmsi_any() );
5916 execute( TC_paging_tmsi_sdcch() );
5917 execute( TC_paging_tmsi_tch_f() );
5918 execute( TC_paging_tmsi_tch_hf() );
5919 execute( TC_paging_imsi_nochan_cgi() );
5920 execute( TC_paging_imsi_nochan_lac_ci() );
5921 execute( TC_paging_imsi_nochan_ci() );
5922 execute( TC_paging_imsi_nochan_lai() );
5923 execute( TC_paging_imsi_nochan_lac() );
5924 execute( TC_paging_imsi_nochan_all() );
Harald Welte751d3eb2018-01-31 15:51:06 +01005925 execute( TC_paging_imsi_nochan_plmn_lac_rnc() );
5926 execute( TC_paging_imsi_nochan_rnc() );
5927 execute( TC_paging_imsi_nochan_lac_rnc() );
5928 execute( TC_paging_imsi_nochan_lacs() );
5929 execute( TC_paging_imsi_nochan_lacs_empty() );
Stefan Sperling049a86e2018-03-20 15:51:00 +01005930 execute( TC_paging_imsi_nochan_cgi_unknown_cid() );
Harald Welte10985002017-12-12 09:29:15 +01005931 execute( TC_paging_imsi_a_reset() );
Harald Weltee65d40e2017-12-13 00:09:06 +01005932 execute( TC_paging_imsi_load() );
Philipp Maier779a7922018-02-16 11:00:37 +01005933 execute( TC_paging_counter() );
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01005934 execute( TC_paging_resp_unsol() );
Harald Welte4e9b9cc2017-12-14 18:31:02 +01005935
5936 execute( TC_rsl_drop_counter() );
Stefan Sperling830dc9d2018-02-12 21:08:28 +01005937 execute( TC_rsl_unknown_unit_id() );
5938
5939 execute( TC_oml_unknown_unit_id() );
Harald Welte898113b2018-01-31 18:32:21 +01005940
5941 execute( TC_classmark() );
Harald Welteeddf0e92020-06-21 19:42:15 +02005942 execute( TC_common_id() );
Harald Welte898113b2018-01-31 18:32:21 +01005943 execute( TC_unsol_ass_fail() );
Harald Welteea99a002018-01-31 20:46:43 +01005944 execute( TC_unsol_ass_compl() );
Harald Weltefbf9b5e2018-01-31 20:41:23 +01005945 execute( TC_unsol_ho_fail() );
Harald Weltee3bd6582018-01-31 22:51:25 +01005946 execute( TC_err_82_short_msg() );
Harald Weltee9e02e42018-01-31 23:36:25 +01005947 execute( TC_err_84_unknown_msg() );
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005948
Harald Welte261af4b2018-02-12 21:20:39 +01005949 execute( TC_ho_int() );
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005950
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005951 execute( TC_ho_out_of_this_bsc() );
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005952 execute( TC_ho_out_fail_no_msc_response() );
5953 execute( TC_ho_out_fail_rr_ho_failure() );
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02005954 execute( TC_ho_out_fail_no_result_after_ho_cmd() );
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005955
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005956 execute( TC_ho_into_this_bsc() );
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005957 execute( TC_ho_in_fail_msc_clears() );
5958 execute( TC_ho_in_fail_msc_clears_after_ho_detect() );
5959 execute( TC_ho_in_fail_no_detect() );
5960 execute( TC_ho_in_fail_no_detect2() );
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01005961
Neels Hofmeyr91401012019-07-11 00:42:35 +02005962 execute( TC_ho_neighbor_config_1() );
5963 execute( TC_ho_neighbor_config_2() );
5964 execute( TC_ho_neighbor_config_3() );
5965 execute( TC_ho_neighbor_config_4() );
5966 execute( TC_ho_neighbor_config_5() );
5967 execute( TC_ho_neighbor_config_6() );
5968 execute( TC_ho_neighbor_config_7() );
5969
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01005970 execute( TC_bssap_rlsd_does_not_cause_bssmap_reset() );
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01005971 execute( TC_bssmap_clear_does_not_cause_bssmap_reset() );
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01005972 execute( TC_ms_rel_ind_does_not_cause_bssmap_reset() );
Harald Welte94e0c342018-04-07 11:33:23 +02005973
5974 execute( TC_dyn_pdch_ipa_act_deact() );
5975 execute( TC_dyn_pdch_ipa_act_nack() );
5976 execute( TC_dyn_pdch_osmo_act_deact() );
5977 execute( TC_dyn_pdch_osmo_act_nack() );
Harald Welte99f3ca02018-06-14 13:40:29 +02005978
Stefan Sperling0796a822018-10-05 13:01:39 +02005979 execute( TC_chopped_ipa_ping() );
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02005980 execute( TC_chopped_ipa_payload() );
Stefan Sperling0796a822018-10-05 13:01:39 +02005981
Pau Espin Pedrol8f773632019-11-05 11:46:53 +01005982 /* Power control related */
5983 execute( TC_assignment_verify_ms_power_params_ie() );
Neels Hofmeyr4f118412020-06-04 15:25:10 +02005984
5985 /* MSC pooling */
5986 /* FIXME: in SCCPlite, indicating how many MSCs should be connected does currently not work. Since
5987 * RESET->RESET-ACK is unconditionally negotiated for all configured MSCs, they always all appear as connected
5988 * to osmo-bsc. The MSC pooling tests however require disconnecting selected MSCs, and hence don't work out as
5989 * intended on SCCPlite. So for now, run these only for SCCP/M3UA. */
5990 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
5991 execute( TC_mscpool_L3Compl_on_1_msc() );
5992 execute( TC_mscpool_L3Complete_by_imsi_round_robin() );
5993 execute( TC_mscpool_LU_by_tmsi_null_nri_0_round_robin() );
5994 execute( TC_mscpool_LU_by_tmsi_null_nri_1_round_robin() );
5995 execute( TC_mscpool_L3Complete_by_tmsi_unassigned_nri_round_robin() );
5996 execute( TC_mscpool_L3Complete_by_tmsi_valid_nri_msc_not_connected_round_robin() );
5997 execute( TC_mscpool_L3Complete_by_tmsi_valid_nri_1() );
5998 execute( TC_mscpool_L3Complete_by_tmsi_valid_nri_2() );
5999 execute( TC_mscpool_LU_by_tmsi_from_other_PLMN() );
6000 execute( TC_mscpool_paging_and_response_imsi() );
6001 execute( TC_mscpool_paging_and_response_tmsi() );
6002 execute( TC_mscpool_no_allow_attach_round_robin() );
6003 execute( TC_mscpool_no_allow_attach_valid_nri() );
6004 }
6005
Harald Welte99f3ca02018-06-14 13:40:29 +02006006 /* at bottom as they might crash OsmoBSC before OS#3182 is fixed */
6007 execute( TC_early_conn_fail() );
6008 execute( TC_late_conn_fail() );
6009
Harald Welte28d943e2017-11-25 15:00:50 +01006010}
6011
6012}