blob: 6170e481ff3a089fdc79568a1007fbcdfac93e68 [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 Welte47cd0e32020-08-21 12:39:11 +020031import from BSSAP_LE_Adapter all;
32import from BSSAP_LE_CodecPort all;
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +020033import from BSSAP_LE_Types all;
34import from BSSLAP_Types all;
Harald Welteae026692017-12-09 01:03:01 +010035import from BSSAP_CodecPort all;
36import from BSSMAP_Templates all;
Harald Welte28d943e2017-11-25 15:00:50 +010037import from IPA_Emulation all;
Stefan Sperling830dc9d2018-02-12 21:08:28 +010038import from IPA_CodecPort all;
Harald Welteae026692017-12-09 01:03:01 +010039import from IPA_Types all;
Stefan Sperling0796a822018-10-05 13:01:39 +020040import from IPA_Testing all;
Harald Welteae026692017-12-09 01:03:01 +010041import from RSL_Types all;
Harald Welte624f9632017-12-16 19:26:04 +010042import from RSL_Emulation all;
Daniel Willmann191e0d92018-01-17 12:44:35 +010043import from MGCP_Emulation all;
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +010044import from MGCP_Templates all;
45import from MGCP_Types all;
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +020046import from MGCP_CodecPort all;
Harald Welte28d943e2017-11-25 15:00:50 +010047
Harald Welte96c94412017-12-09 03:12:45 +010048import from Osmocom_CTRL_Functions all;
Harald Weltea5d2ab22017-12-09 14:21:42 +010049import from Osmocom_CTRL_Types all;
Harald Welteffe55fc2018-01-17 22:39:54 +010050import from Osmocom_CTRL_Adapter all;
Harald Welte96c94412017-12-09 03:12:45 +010051
Daniel Willmannebdecc02020-08-12 15:30:17 +020052import from StatsD_Types all;
53import from StatsD_CodecPort all;
54import from StatsD_CodecPort_CtrlFunct all;
55import from StatsD_Checker all;
56
Harald Weltebc03c762018-02-12 18:09:38 +010057import from Osmocom_VTY_Functions all;
58import from TELNETasp_PortType all;
59
Harald Welte6f521d82017-12-11 19:52:02 +010060import from MobileL3_CommonIE_Types all;
Harald Weltee3bd6582018-01-31 22:51:25 +010061import from MobileL3_Types all;
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +010062import from MobileL3_RRM_Types all;
Harald Welte6f521d82017-12-11 19:52:02 +010063import from L3_Templates all;
64import from GSM_RR_Types all;
65
Stefan Sperlingc307e682018-06-14 15:15:46 +020066import from SCCP_Templates all;
Neels Hofmeyr4ff93282018-03-12 04:25:35 +010067import from BSSMAP_Templates all;
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +020068import from BSSMAP_LE_Templates all;
Neels Hofmeyr4ff93282018-03-12 04:25:35 +010069
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +010070import from SCCPasp_Types all;
71
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +020072import from GSM_SystemInformation all;
73import from GSM_RestOctets all;
Neels Hofmeyrad132f22020-07-08 02:20:16 +020074import from TCCConversion_Functions all;
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +020075
Harald Welte5d1a2202017-12-13 19:51:29 +010076const integer NUM_BTS := 3;
Neels Hofmeyrf246a922020-05-13 02:27:10 +020077const integer NUM_MSC := 3;
Harald Welteae026692017-12-09 01:03:01 +010078const float T3101_MAX := 12.0;
Harald Welte28d943e2017-11-25 15:00:50 +010079
Harald Welte799c97b2017-12-14 17:50:30 +010080/* make sure to sync this with the osmo-bts.cfg you're using */
Philipp Maiercb6cc482018-03-26 13:08:00 +020081const integer NUM_TCHH_PER_BTS := 2;
82const integer NUM_TCHF_PER_BTS := 4;
Neels Hofmeyr74083c22020-07-29 00:43:01 +020083const integer NUM_SDCCH_PER_BTS := 3;
Harald Welte799c97b2017-12-14 17:50:30 +010084
Harald Welte4003d112017-12-09 22:35:39 +010085
Harald Welte21b46bd2017-12-17 19:46:32 +010086/* per-BTS state which we keep */
Harald Welte96c94412017-12-09 03:12:45 +010087type record BTS_State {
Harald Welte21b46bd2017-12-17 19:46:32 +010088 /* component reference to the IPA_Client component used for RSL */
Harald Weltea5d2ab22017-12-09 14:21:42 +010089 IPA_Client rsl
Harald Welte96c94412017-12-09 03:12:45 +010090}
91
Neels Hofmeyr22c3f792020-06-17 02:49:28 +020092/* Default list of counters for an 'msc' entity. */
93const CounterNameVals counternames_msc_mscpool := {
94 { "mscpool:subscr:new", 0 },
95 { "mscpool:subscr:known", 0 },
96 { "mscpool:subscr:reattach", 0 },
97 { "mscpool:subscr:attach_lost", 0 },
98 { "mscpool:subscr:paged", 0 }
99};
100
Neels Hofmeyrbf037052020-10-28 22:52:02 +0000101/* List of global mscpool counters, not related to a specific 'msc' entity. */
102const CounterNameVals counternames_bsc_mscpool := {
103 { "mscpool:subscr:no_msc", 0 }
104};
105
Neels Hofmeyr12941bd2020-08-29 03:21:26 +0000106/* Default list of counters for 'bsc' and 'bts' entities. */
107const CounterNameVals counternames_bsc_bts_handover := {
108 { "assignment:attempted", 0 },
109 { "assignment:completed", 0 },
110 { "assignment:stopped", 0 },
111 { "assignment:no_channel", 0 },
112 { "assignment:timeout", 0 },
113 { "assignment:failed", 0 },
114 { "assignment:error", 0 },
115
116 { "handover:attempted", 0 },
117 { "handover:completed", 0 },
118 { "handover:stopped", 0 },
119 { "handover:no_channel", 0 },
120 { "handover:timeout", 0 },
121 { "handover:failed", 0 },
122 { "handover:error", 0 },
123
124 { "intra_cell_ho:attempted", 0 },
125 { "intra_cell_ho:completed", 0 },
126 { "intra_cell_ho:stopped", 0 },
127 { "intra_cell_ho:no_channel", 0 },
128 { "intra_cell_ho:timeout", 0 },
129 { "intra_cell_ho:failed", 0 },
130 { "intra_cell_ho:error", 0 },
131
132 { "intra_bsc_ho:attempted", 0 },
133 { "intra_bsc_ho:completed", 0 },
134 { "intra_bsc_ho:stopped", 0 },
135 { "intra_bsc_ho:no_channel", 0 },
136 { "intra_bsc_ho:timeout", 0 },
137 { "intra_bsc_ho:failed", 0 },
138 { "intra_bsc_ho:error", 0 },
139
140 { "interbsc_ho_out:attempted", 0 },
141 { "interbsc_ho_out:completed", 0 },
142 { "interbsc_ho_out:stopped", 0 },
143 { "interbsc_ho_out:timeout", 0 },
144 { "interbsc_ho_out:failed", 0 },
145 { "interbsc_ho_out:error", 0 },
146
147 { "interbsc_ho_in:attempted", 0 },
148 { "interbsc_ho_in:completed", 0 },
149 { "interbsc_ho_in:stopped", 0 },
150 { "interbsc_ho_in:no_channel", 0 },
151 { "interbsc_ho_in:timeout", 0 },
152 { "interbsc_ho_in:failed", 0 },
153 { "interbsc_ho_in:error", 0 }
154};
155
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200156/* Set of all System Information received during one RSL port's startup.
157 * Note that some System Information may be sent on RSL, but lacking actual SI data, to indicate that the BTS should not
158 * broadcast that SI type. That will be reflected as 'omit' here.
159 */
160type record SystemInformationConfig {
161 SystemInformationType1 si1 optional,
162 SystemInformationType2 si2 optional,
163 SystemInformationType2bis si2bis optional,
164 SystemInformationType2ter si2ter optional,
Neels Hofmeyrad132f22020-07-08 02:20:16 +0200165 SI2quaterRestOctetsList si2quater optional,
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200166 SystemInformationType3 si3 optional,
167 SystemInformationType4 si4 optional,
Pau Espin Pedrol28652d82021-02-09 20:20:17 +0100168 SystemInformationType13 si13 optional,
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200169 SystemInformationType5 si5 optional,
170 SystemInformationType5bis si5bis optional,
171 SystemInformationType5ter si5ter optional,
172 SystemInformationType6 si6 optional
173};
174
175const SystemInformationConfig SystemInformationConfig_omit := {
176 si1 := omit,
177 si2 := omit,
178 si2bis := omit,
179 si2ter := omit,
180 si2quater := omit,
181 si3 := omit,
182 si4 := omit,
183 si13 := omit,
184 si5 := omit,
185 si5bis := omit,
186 si5ter := omit,
187 si6 := omit
188};
189
190/* tr_EUTRAN_CellDesc with defaults used in BSC_Tests.ttcn */
191template EUTRAN_CellDesc tr_EUTRAN_CellDesc_default(template (present) uint16_t e_arfcn := ?,
192 template uint3_t meas_bw := 3)
193:= tr_EUTRAN_CellDesc(e_arfcn := e_arfcn,
194 meas_bw_presence := '1'B,
195 meas_bw := meas_bw);
196
197/* tr_EUTRAN_NeighbourCells with defaults used in BSC_Tests.ttcn */
Harald Welte65e419a2020-08-21 12:38:33 +0200198template EUTRAN_NeighbourCells tr_EUTRAN_NeighbourCells_default(template (present) EUTRAN_CellDescs cell_desc_list := { tr_EUTRAN_CellDesc_default },
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200199 template uint3_t prio := 3,
200 template (present) uint5_t thresh_high := 20,
201 template uint5_t thresh_low := 10,
202 template uint5_t qrxlevmin := 22)
203:= tr_EUTRAN_NeighbourCells(
204 cell_desc_list := cell_desc_list,
205 prio_presence := '1'B,
206 prio := prio,
207 thresh_high := thresh_high,
208 thresh_low_presence := '1'B,
209 thresh_low := thresh_low,
210 qrxlevmin_presence := '1'B,
211 qrxlevmin := qrxlevmin);
212
213template SystemInformationConfig SystemInformationConfig_default := {
214 si1 := {
215 cell_chan_desc := '8FB38000000000000000000000000000'O,
216 rach_control := {
217 max_retrans := RACH_MAX_RETRANS_7,
218 tx_integer := '1001'B,
219 cell_barr_access := false,
220 re_not_allowed := true,
221 acc := '0000010000000000'B
222 },
223 rest_octets := ?
224 },
225 si2 := {
226 bcch_freq_list := '00000000000000000000000000000000'O,
227 ncc_permitted := '11111111'B,
228 rach_control := {
229 max_retrans := RACH_MAX_RETRANS_7,
230 tx_integer := '1001'B,
231 cell_barr_access := false,
232 re_not_allowed := true,
233 acc := '0000010000000000'B
234 }
235 },
236 si2bis := omit,
237 si2ter := {
238 extd_bcch_freq_list := '8E320000000000000000000000000800'O,
239 rest_octets := ?
240 },
241 si2quater := {
242 tr_SI2quaterRestOctets_EUTRAN( repeated_neigh_cells := { tr_EUTRAN_NeighbourCells_default } )
243 },
244 si3 := {
245 cell_id := 0,
246 lai := {
247 mcc_mnc := '001F01'H,
248 lac := 1
249 },
250 ctrl_chan_desc := {
251 msc_r99 := true,
252 att := true,
253 bs_ag_blks_res := 1,
254 ccch_conf := CCHAN_DESC_1CCCH_COMBINED,
255 si22ind := false,
256 cbq3 := CBQ3_IU_MODE_NOT_SUPPORTED,
257 spare := '00'B,
258 bs_pa_mfrms := 3,
259 t3212 := 30
260 },
261 cell_options := {
262 dn_ind := false,
263 pwrc := false,
264 dtx := MS_SHALL_USE_UL_DTX,
265 radio_link_tout_div4 := 7
266 },
267 cell_sel_par := {
268 cell_resel_hyst_2dB := 2,
269 ms_txpwr_max_cch := 7,
270 acs := '0'B,
271 neci := true,
272 rxlev_access_min := 0
273 },
274 rach_control := {
275 max_retrans := RACH_MAX_RETRANS_7,
276 tx_integer := '1001'B,
277 cell_barr_access := false,
278 re_not_allowed := true,
279 acc := '0000010000000000'B
280 },
281 rest_octets := {
282 sel_params := {
283 presence := '0'B,
284 params := omit
285 },
286 pwr_offset := {
287 presence := '0'B,
288 offset := omit
289 },
290 si_2ter_ind := '1'B,
291 early_cm_ind := '0'B,
292 sched_where := {
293 presence := '0'B,
294 where := omit
295 },
296 gprs_ind := {
297 presence := '1'B,
298 ind := {
299 ra_colour := 0,
300 si13_pos := '0'B
301 }
302 },
303 umts_early_cm_ind := '1'B,
304 si2_quater_ind := {
305 presence := '1'B,
306 ind := '0'B
307 },
308 iu_mode_ind := omit,
309 si21_ind := {
310 presence := '0'B,
311 pos := omit
312 }
313 }
314 },
315 si4 := {
316 lai := {
317 mcc_mnc := '001F01'H,
318 lac := 1
319 },
320 cell_sel_par := {
321 cell_resel_hyst_2dB := 2,
322 ms_txpwr_max_cch := 7,
323 acs := '0'B,
324 neci := true,
325 rxlev_access_min := 0
326 },
327 rach_control := {
328 max_retrans := RACH_MAX_RETRANS_7,
329 tx_integer := '1001'B,
330 cell_barr_access := false,
331 re_not_allowed := true,
332 acc := '0000010000000000'B
333 },
Neels Hofmeyr74083c22020-07-29 00:43:01 +0200334 cbch_chan_desc := {
335 iei := '64'O,
336 v := {
337 chan_nr := {
338 u := {
339 sdcch4 := {
340 tag := '001'B,
341 sub_chan := 2
342 }
343 },
344 tn := 0
345 },
346 tsc := 2,
347 h := false,
348 arfcn := 871,
349 maio_hsn := omit
350 }
351 },
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200352 cbch_mobile_alloc := omit,
353 rest_octets := {
354 sel_params := {
355 presence := '0'B,
356 params := omit
357 },
358 pwr_offset := {
359 presence := '0'B,
360 offset := omit
361 },
362 gprs_ind := {
363 presence := '1'B,
364 ind := {
365 ra_colour := 0,
366 si13_pos := '0'B
367 }
368 },
369 s_presence := '0'B,
370 s := omit
371 }
372 },
Pau Espin Pedrol28652d82021-02-09 20:20:17 +0100373 si13 := {
374 rest_octets := {
375 presence := '1'B,
376 bcch_change_mark := ?,
377 si_change_field := '0000'B,
378 presence2 := '0'B,
379 si13_change_mark := omit,
380 gprs_ma := omit,
381 zero := '0'B, /* PBCCH not present in cell */
382 rac := 0,
383 spgc_ccch_sup := '0'B,
384 priority_access_thr := '110'B,
385 network_control_order := '00'B,
386 gprs_cell_opts := {
387 nmo := '01'B,
388 t3168 := '011'B,
389 t3192 := '010'B,
390 drx_timer_max := '011'B,
391 access_burst_type := '0'B,
392 control_ack_type := '1'B,
393 bs_cv_max := 15,
394 pan_presence := '1'B,
395 pan_dec := 1,
396 pan_inc := 1,
397 pan_max := '111'B,
398 ext_info_presence := ?,
399 ext_info_length := *,
400 ext_info := *
401 },
402 gprs_pwr_ctrl_params := {
403 alpha := 0,
404 t_avg_w := '10000'B,
405 t_avg_t := '10000'B,
406 pc_meas_chan := '0'B,
407 n_avg_i := '1000'B
408 }
409 }
410 },
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200411 si5 := {
412 bcch_freq_list := '10000000000000000000000000000000'O
413 },
414 si5bis := omit,
415 si5ter := {
416 extd_bcch_freq_list := '9E050020000000000000000000000000'O
417 },
418 si6 := {
419 cell_id := 0,
420 lai := {
421 mcc_mnc := '001F01'H,
422 lac := 1
423 },
424 cell_options := {
425 dtx_ext := '1'B,
426 pwrc := false,
427 dtx := '01'B,
428 radio_link_timeout := '0111'B
429 },
430 ncc_permitted := '11111111'B,
431 rest_octets := ?
432 }
433 };
434
435
436/* List of all the System Information received on all RSL ports */
437type record of SystemInformationConfig SystemInformationConfig_list;
438
439function f_sysinfo_dec_raw(inout SystemInformationConfig si, RSL_Message rsl)
440{
441 var RSL_IE_Body sysinfo_type_ie;
442 var RSL_IE_SysinfoType si_type;
443 var octetstring data;
444
445 if (f_rsl_find_ie(rsl, RSL_IE_SYSINFO_TYPE, sysinfo_type_ie) == false) {
446 setverdict(fail, "Cannot find RSL_IE_SYSINFO_TYPE");
447 mtc.stop;
448 }
449 si_type := sysinfo_type_ie.sysinfo_type;
450
451 if (rsl.msg_type == RSL_MT_BCCH_INFO) {
452 var RSL_IE_Body bcch_ie;
453 if (f_rsl_find_ie(rsl, RSL_IE_FULL_BCCH_INFO, bcch_ie)) {
454 data := bcch_ie.other.payload;
455 }
456 } else if (rsl.msg_type == RSL_MT_SACCH_FILL) {
457 var RSL_IE_Body l3_ie;
458 if (f_rsl_find_ie(rsl, RSL_IE_L3_INFO, l3_ie)) {
459 data := l3_ie.l3_info.payload;
460 }
461 } else {
462 setverdict(fail, "Don't understand this System Information message");
463 mtc.stop;
464 }
465
466 var boolean handled := false;
467
468 if (rsl.msg_type == RSL_MT_BCCH_INFO) {
469 handled := true;
470
471 if (si_type == RSL_SYSTEM_INFO_1) {
472 if (not isbound(data)) {
473 si.si1 := omit;
474 } else {
475 si.si1 := dec_SystemInformation(data).payload.si1;
476 }
477 } else if (si_type == RSL_SYSTEM_INFO_2) {
478 if (not isbound(data)) {
479 si.si2 := omit;
480 } else {
481 si.si2 := dec_SystemInformation(data).payload.si2;
482 }
483 } else if (si_type == RSL_SYSTEM_INFO_2bis) {
484 if (not isbound(data)) {
485 si.si2bis := omit;
486 } else {
487 si.si2bis := dec_SystemInformation(data).payload.si2bis;
488 }
489 } else if (si_type == RSL_SYSTEM_INFO_2ter) {
490 if (not isbound(data)) {
491 si.si2ter := omit;
492 } else {
493 si.si2ter := dec_SystemInformation(data).payload.si2ter;
494 }
495 } else if (si_type == RSL_SYSTEM_INFO_2quater) {
496 if (not isbound(data)) {
497 si.si2quater := {};
498 } else {
499 var SystemInformationType2quater decoded := dec_SystemInformation(data).payload.si2quater;
500 /* this is a *record* of SI2quaterRestOctets! (multiplexed) */
501 si.si2quater[decoded.rest_octets.si2quater_index] := decoded.rest_octets;
502 }
503 } else if (si_type == RSL_SYSTEM_INFO_3) {
504 if (not isbound(data)) {
505 si.si3 := omit;
506 } else {
507 si.si3 := dec_SystemInformation(data).payload.si3;
508 }
509 } else if (si_type == RSL_SYSTEM_INFO_4) {
510 if (not isbound(data)) {
511 si.si4 := omit;
512 } else {
513 si.si4 := dec_SystemInformation(data).payload.si4;
514 }
515 } else if (si_type == RSL_SYSTEM_INFO_13) {
516 if (not isbound(data)) {
517 si.si13 := omit;
518 } else {
Pau Espin Pedrol28652d82021-02-09 20:20:17 +0100519 si.si13 := dec_SystemInformation(data).payload.si13;
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200520 }
521 } else {
522 handled := false;
523 }
524 } else if (rsl.msg_type == RSL_MT_SACCH_FILL) {
525 handled := true;
526
527 if (si_type == RSL_SYSTEM_INFO_5) {
528 if (not isbound(data)) {
529 si.si5 := omit;
530 } else {
531 si.si5 := dec_SystemInformation(data).payload.si5;
532 }
533 } else if (si_type == RSL_SYSTEM_INFO_5bis) {
534 if (not isbound(data)) {
535 si.si5bis := omit;
536 } else {
537 si.si5bis := dec_SystemInformation(data).payload.si5bis;
538 }
539 } else if (si_type == RSL_SYSTEM_INFO_5ter) {
540 if (not isbound(data)) {
541 si.si5ter := omit;
542 } else {
543 si.si5ter := dec_SystemInformation(data).payload.si5ter;
544 }
545 } else if (si_type == RSL_SYSTEM_INFO_6) {
546 if (not isbound(data)) {
547 si.si6 := omit;
548 } else {
549 si.si6 := dec_SystemInformation(data).payload.si6;
550 }
551 } else {
552 handled := false;
553 }
554 }
555
556 if (not handled) {
557 setverdict(fail, "Unexpected SI type in ", rsl.msg_type, " message: ", si_type);
558 }
559}
560
Harald Weltea4ca4462018-02-09 00:17:14 +0100561type component test_CT extends CTRL_Adapter_CT {
Harald Welte21b46bd2017-12-17 19:46:32 +0100562 /* Array of per-BTS state */
Harald Welte96c94412017-12-09 03:12:45 +0100563 var BTS_State bts[NUM_BTS];
Harald Welte89ab1912018-02-23 18:56:29 +0100564 /* RSL common Channel Port (for RSL_Emulation) */
565 port RSL_CCHAN_PT RSL_CCHAN[NUM_BTS];
Harald Welte21b46bd2017-12-17 19:46:32 +0100566 /* array of per-BTS RSL test ports */
Harald Welteae026692017-12-09 01:03:01 +0100567 port IPA_RSL_PT IPA_RSL[NUM_BTS];
Stefan Sperling830dc9d2018-02-12 21:08:28 +0100568 port IPA_CODEC_PT IPA; /* Required for compilation of TC_rsl_unknown_unit_id() */
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +0200569 /* CTRL muxed over IPA in SCCPlite conn BSC<->MSC (or BSC-NAT) */
570 port IPA_CTRL_PT SCCPLITE_IPA_CTRL;
Harald Weltea5d2ab22017-12-09 14:21:42 +0100571
Daniel Willmann191e0d92018-01-17 12:44:35 +0100572 var MGCP_Emulation_CT vc_MGCP;
Harald Weltebc03c762018-02-12 18:09:38 +0100573 port TELNETasp_PT BSCVTY;
Daniel Willmann191e0d92018-01-17 12:44:35 +0100574
Daniel Willmannebdecc02020-08-12 15:30:17 +0200575 /* StatsD */
576 var StatsD_Checker_CT vc_STATSD;
577
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200578 var RAN_Adapter g_bssap[NUM_MSC];
Harald Welte47cd0e32020-08-21 12:39:11 +0200579 var BSSAP_LE_Adapter g_bssap_le;
Harald Weltea4ca4462018-02-09 00:17:14 +0100580 /* for old legacy-tests only */
581 port BSSAP_CODEC_PT BSSAP;
Harald Welte47cd0e32020-08-21 12:39:11 +0200582 port BSSAP_LE_CODEC_PT BSSAP_LE;
Harald Weltea4ca4462018-02-09 00:17:14 +0100583
Harald Welte21b46bd2017-12-17 19:46:32 +0100584 /* are we initialized yet */
Harald Welte28d943e2017-11-25 15:00:50 +0100585 var boolean g_initialized := false;
Harald Welte21b46bd2017-12-17 19:46:32 +0100586
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200587 /* Osmux is enabled through VTY */
588 var boolean g_osmux_enabled := false;
589
Pau Espin Pedrolc675b612020-01-09 19:55:40 +0100590 /*Configure T(tias) over VTY, seconds */
591 var integer g_bsc_sccp_timer_ias := 7 * 60;
592 /*Configure T(tiar) over VTY, seconds */
593 var integer g_bsc_sccp_timer_iar := 15 * 60;
594
Neels Hofmeyr4fbad7f2020-06-16 00:30:47 +0200595 /* global test case guard timer (actual timeout value is set in f_init()) */
Harald Welteae026692017-12-09 01:03:01 +0100596 timer T_guard := 30.0;
597
Neels Hofmeyr22c3f792020-06-17 02:49:28 +0200598 var CounterNameValsList g_ctr_msc;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +0000599 var CounterNameValsList g_ctr_bsc;
600 var CounterNameValsList g_ctr_bts;
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200601
602 /* System Information bytes as received during RSL startup, for each RSL[idx]. */
603 var SystemInformationConfig_list g_system_information := {};
Harald Welte28d943e2017-11-25 15:00:50 +0100604}
605
606modulepar {
Harald Welte21b46bd2017-12-17 19:46:32 +0100607 /* IP address at which the BSC can be reached */
Harald Welte696ddb62017-12-08 14:01:43 +0100608 charstring mp_bsc_ip := "127.0.0.1";
Stefan Sperling830dc9d2018-02-12 21:08:28 +0100609 /* port number to which to establish the IPA OML connections */
610 integer mp_bsc_oml_port := 3002;
Harald Welte21b46bd2017-12-17 19:46:32 +0100611 /* port number to which to establish the IPA RSL connections */
Harald Welte696ddb62017-12-08 14:01:43 +0100612 integer mp_bsc_rsl_port := 3003;
Harald Welte21b46bd2017-12-17 19:46:32 +0100613 /* port number to which to establish the IPA CTRL connection */
Harald Welte96c94412017-12-09 03:12:45 +0100614 integer mp_bsc_ctrl_port := 4249;
Daniel Willmannebdecc02020-08-12 15:30:17 +0200615 /* port number to which to listen for STATSD metrics */
616 integer mp_bsc_statsd_port := 8125;
Daniel Willmann191e0d92018-01-17 12:44:35 +0100617 /* IP address at which the test binds */
618 charstring mp_test_ip := "127.0.0.1";
Harald Weltea4ca4462018-02-09 00:17:14 +0100619
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200620 RAN_Configurations mp_bssap_cfg := {
621 {
622 transport := BSSAP_TRANSPORT_AoIP,
623 sccp_service_type := "mtp3_itu",
624 sctp_addr := { 23905, "127.0.0.1", 2905, "127.0.0.1" },
625 own_pc := 185, /* 0.23.1 first MSC emulation */
626 own_ssn := 254,
627 peer_pc := 187, /* 0.23.3 osmo-bsc */
628 peer_ssn := 254,
629 sio := '83'O,
Harald Weltecb0cc432020-06-21 19:42:31 +0200630 rctx := 1
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200631 },
632 {
633 transport := BSSAP_TRANSPORT_AoIP,
634 sccp_service_type := "mtp3_itu",
635 sctp_addr := { 23906, "127.0.0.1", 2905, "127.0.0.1" },
636 own_pc := 2, /* 0.0.2 second MSC emulation */
637 own_ssn := 254,
638 peer_pc := 187, /* 0.23.3 osmo-bsc */
639 peer_ssn := 254,
640 sio := '83'O,
641 rctx := 2
642 },
643 {
644 transport := BSSAP_TRANSPORT_AoIP,
645 sccp_service_type := "mtp3_itu",
646 sctp_addr := { 23907, "127.0.0.1", 2905, "127.0.0.1" },
647 own_pc := 3, /* 0.0.3 third MSC emulation */
648 own_ssn := 254,
649 peer_pc := 187, /* 0.23.3 osmo-bsc */
650 peer_ssn := 254,
651 sio := '83'O,
652 rctx := 3
653 }
Harald Weltea4ca4462018-02-09 00:17:14 +0100654 };
Pau Espin Pedrol58cf6822019-05-28 18:11:33 +0200655
Harald Welte47cd0e32020-08-21 12:39:11 +0200656 BSSAP_LE_Configuration mp_bssap_le_cfg := {
657 sccp_service_type := "mtp3_itu",
658 sctp_addr := { 23908, "127.0.0.1", 2905, "127.0.0.1" },
Neels Hofmeyrac086c12020-09-18 23:46:42 +0200659 own_pc := 190, /* 0.23.6 SMLC emulation */
Harald Welte47cd0e32020-08-21 12:39:11 +0200660 own_ssn := 252, /* SMLC side SSN */
661 peer_pc := 187, /* 0.23.3 osmo-bsc */
662 peer_ssn := 250, /* BSC side SSN */
663 sio := '83'O,
664 rctx := 6
665 };
Neels Hofmeyrcfe44062020-10-15 02:28:08 +0200666 boolean mp_enable_lcs_tests := true;
Harald Welte47cd0e32020-08-21 12:39:11 +0200667
Pau Espin Pedrol58cf6822019-05-28 18:11:33 +0200668 /* Whether to enable osmux tests. Can be dropped completely and enable
669 unconditionally once new version of osmo-bsc is released (current
670 version: 1.4.1) */
671 boolean mp_enable_osmux_test := true;
Pau Espin Pedrol8f30ccd2019-11-01 17:30:57 +0100672 /* Value set in osmo-bsc.cfg "ms max power" */
673 uint8_t mp_exp_ms_power_level := 7;
Harald Weltea4ca4462018-02-09 00:17:14 +0100674}
675
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200676private function f_gen_test_hdlr_pars(integer bssap_idx := 0) return TestHdlrParams {
Philipp Maier48604732018-10-09 15:00:37 +0200677
678 var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200679 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Philipp Maier48604732018-10-09 15:00:37 +0200680 pars.aoip := true;
681 } else {
682 pars.aoip := false;
683 }
Pau Espin Pedrol8f30ccd2019-11-01 17:30:57 +0100684 pars.exp_ms_power_level := mp_exp_ms_power_level;
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200685 pars.mscpool.bssap_idx := bssap_idx;
Philipp Maier48604732018-10-09 15:00:37 +0200686
687 return pars;
688}
689
Neels Hofmeyr22c3f792020-06-17 02:49:28 +0200690/* Convenience functions for rate counters using g_ctr_msc. */
691
692private function f_ctrs_msc_init(integer mscs_count := NUM_MSC, CounterNameVals counternames := counternames_msc_mscpool) runs on test_CT {
693 g_ctr_msc := f_counter_name_vals_get_n(IPA_CTRL, "msc", mscs_count, counternames);
694 log("initial msc rate counters: ", g_ctr_msc);
695}
696
697private function f_ctrs_msc_add(integer msc_nr, charstring countername, integer val := 1) runs on test_CT {
Neels Hofmeyr9656e922020-06-30 01:27:01 +0200698 f_counter_name_vals_list_add(g_ctr_msc, msc_nr, countername, val);
Neels Hofmeyr22c3f792020-06-17 02:49:28 +0200699}
700
701/* f_ctrs_msc_init();
702 * f_do_thing(on_msc := 0);
703 * f_do_thing(on_msc := 0);
704 * f_do_other(on_msc := 1);
705 * f_ctrs_msc_add(0, "thing", 2);
706 * f_ctrs_msc_add(1, "other");
707 * f_ctrs_msc_verify();
708 */
709private function f_ctrs_msc_verify() runs on test_CT {
710 log("verifying msc rate counters: ", g_ctr_msc);
711 f_counter_name_vals_expect_n(IPA_CTRL, "msc", g_ctr_msc);
712}
713
714/* convenience: f_ctrs_msc_add() and f_ctrs_msc_verify() in one call.
715 * f_ctrs_msc_init();
716 * f_do_thing(on_msc := 0);
717 * f_do_thing(on_msc := 0);
718 * f_do_thing(on_msc := 0);
719 * f_ctrs_msc_expect(0, "thing", 3);
720 */
721private function f_ctrs_msc_expect(integer msc_nr, charstring countername, integer val := 1) runs on test_CT {
722 f_ctrs_msc_add(msc_nr, countername, val);
723 f_ctrs_msc_verify();
724}
725
Neels Hofmeyr12941bd2020-08-29 03:21:26 +0000726/* Convenience functions for rate counters using g_ctr_bts, always also including g_ctr_bsc. */
727
728private function f_ctrs_bsc_and_bts_init(integer bts_count := NUM_BTS, CounterNameVals counternames := counternames_bsc_bts_handover) runs on test_CT {
729 g_ctr_bts := f_counter_name_vals_get_n(IPA_CTRL, "bts", bts_count, counternames);
730 log("initial bts rate counters: ", g_ctr_bts);
731 f_ctrs_bsc_init(counternames);
732}
733
734private function f_ctrs_bsc_and_bts_add(integer bts_nr, charstring countername, integer val := 1) runs on test_CT {
735 f_counter_name_vals_list_add(g_ctr_bts, bts_nr, countername, val);
736 f_ctrs_bsc_add(countername, val);
737}
738
739/* f_ctrs_bsc_and_bts_init();
740 * f_do_thing(on_bts := 0);
741 * f_do_thing(on_bts := 0);
742 * f_do_other(on_bts := 1);
743 * f_ctrs_bsc_and_bts_add(0, "thing", 2);
744 * f_ctrs_bsc_and_bts_add(1, "other");
745 * f_ctrs_bsc_and_bts_verify();
746 */
747private function f_ctrs_bsc_and_bts_verify() runs on test_CT {
748 f_counter_name_vals_expect_n(IPA_CTRL, "bts", g_ctr_bts);
749 f_ctrs_bsc_verify();
750}
751
752/* convenience: f_ctrs_bsc_and_bts_add() and f_ctrs_bsc_and_bts_verify() in one call.
753 * f_ctrs_bsc_and_bts_init();
754 * f_do_thing(on_bts := 0);
755 * f_do_thing(on_bts := 0);
756 * f_do_thing(on_bts := 0);
757 * f_ctrs_bsc_and_bts_expect(0, "thing", 3);
758 */
759private function f_ctrs_bsc_and_bts_expect(integer bts_nr, charstring countername, integer val := 1) runs on test_CT {
760 f_ctrs_bsc_and_bts_add(bts_nr, countername, val);
761 f_ctrs_bsc_and_bts_verify();
762}
763
764
765/* Convenience functions for rate counters using g_ctr_bsc. */
766
767private function f_ctrs_bsc_init(CounterNameVals counternames := counternames_bsc_bts_handover) runs on test_CT {
768 g_ctr_bsc := f_counter_name_vals_get_n(IPA_CTRL, "bsc", 1, counternames);
769 log("initial bsc rate counters: ", g_ctr_bsc);
770}
771
772private function f_ctrs_bsc_add(charstring countername, integer val := 1) runs on test_CT {
773 f_counter_name_vals_list_add(g_ctr_bsc, 0, countername, val);
774}
775
776/* f_ctrs_bsc_init();
777 * f_do_thing();
778 * f_do_thing();
779 * f_do_other();
780 * f_ctrs_bsc_add("thing", 2);
781 * f_ctrs_bsc_add("other");
782 * f_ctrs_bsc_verify();
783 */
784private function f_ctrs_bsc_verify() runs on test_CT {
785 f_counter_name_vals_expect_n(IPA_CTRL, "bsc", g_ctr_bsc);
786}
787
788/* convenience: f_ctrs_bsc_add() and f_ctrs_bsc_verify() in one call.
789 * f_ctrs_bsc_init();
790 * f_do_thing();
791 * f_ctrs_bsc_expect("thing", 1);
792 */
793private function f_ctrs_bsc_expect(charstring countername, integer val := 1) runs on test_CT {
794 f_ctrs_bsc_add(countername, val);
795 f_ctrs_bsc_verify();
796}
797
Neels Hofmeyr22c3f792020-06-17 02:49:28 +0200798
Philipp Maier282ca4b2018-02-27 17:17:00 +0100799private function f_shutdown_helper() runs on test_CT {
Daniel Willmann637ef6c2018-07-25 10:49:09 +0200800 all component.stop;
Philipp Maier282ca4b2018-02-27 17:17:00 +0100801 setverdict(pass);
Daniel Willmannafce8662018-07-06 23:11:32 +0200802 mtc.stop;
Philipp Maier282ca4b2018-02-27 17:17:00 +0100803}
804
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200805private function f_legacy_bssap_reset(integer bssap_idx := 0) runs on test_CT {
Harald Weltea4ca4462018-02-09 00:17:14 +0100806 var BSSAP_N_UNITDATA_ind ud_ind;
Pau Espin Pedrol24c05992020-09-01 12:54:12 +0200807 var boolean reset_received := false;
Harald Weltea4ca4462018-02-09 00:17:14 +0100808 timer T := 5.0;
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200809 BSSAP.send(ts_BSSAP_UNITDATA_req(g_bssap[bssap_idx].sccp_addr_peer, g_bssap[bssap_idx].sccp_addr_own,
810 ts_BSSMAP_Reset(0, g_osmux_enabled)));
Harald Weltea4ca4462018-02-09 00:17:14 +0100811 T.start;
812 alt {
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200813 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(g_bssap[bssap_idx].sccp_addr_own, g_bssap[bssap_idx].sccp_addr_peer,
814 tr_BSSMAP_ResetAck(g_osmux_enabled))) {
Neels Hofmeyr4f5d7be2020-10-16 16:28:16 +0200815 log("BSSMAP: Received RESET-ACK in response to RESET, we're ready to go!");
Harald Weltea4ca4462018-02-09 00:17:14 +0100816 }
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200817 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset(g_osmux_enabled))) -> value ud_ind {
Neels Hofmeyr4f5d7be2020-10-16 16:28:16 +0200818 log("BSSMAP: Respoding to inbound RESET with RESET-ACK");
Harald Weltea4ca4462018-02-09 00:17:14 +0100819 BSSAP.send(ts_BSSAP_UNITDATA_req(ud_ind.callingAddress, ud_ind.calledAddress,
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200820 ts_BSSMAP_ResetAck(g_osmux_enabled)));
Pau Espin Pedrol24c05992020-09-01 12:54:12 +0200821 reset_received := true;
Harald Weltea4ca4462018-02-09 00:17:14 +0100822 repeat;
823 }
824 [] BSSAP.receive { repeat; }
Pau Espin Pedrol24c05992020-09-01 12:54:12 +0200825 [] T.timeout {
Neels Hofmeyr4f5d7be2020-10-16 16:28:16 +0200826 log("BSSMAP: Timeout waiting for RESET-ACK after sending RESET");
Pau Espin Pedrol24c05992020-09-01 12:54:12 +0200827 /* If we received a RESET after ours was sent, it
828 may be a race condition where the other peer beacame
829 available after we sent it, but we are in a desired
830 state anyway, so go forward. */
831 if (not reset_received) {
832 setverdict(fail);
833 }
834 }
Harald Weltea4ca4462018-02-09 00:17:14 +0100835 }
Harald Welte28d943e2017-11-25 15:00:50 +0100836}
837
Harald Welteae026692017-12-09 01:03:01 +0100838type record IPA_Client {
Harald Welte21b46bd2017-12-17 19:46:32 +0100839 /* IPA Emulation component reference */
Harald Welteae026692017-12-09 01:03:01 +0100840 IPA_Emulation_CT vc_IPA,
Harald Welte21b46bd2017-12-17 19:46:32 +0100841 /* Unit-ID and other CCM parameters to use for IPA client emulation */
Harald Welteae026692017-12-09 01:03:01 +0100842 IPA_CCM_Parameters ccm_pars,
Harald Welte21b46bd2017-12-17 19:46:32 +0100843 /* String identifier for this IPA Client */
Harald Welte624f9632017-12-16 19:26:04 +0100844 charstring id,
Harald Welte21b46bd2017-12-17 19:46:32 +0100845 /* Associated RSL Emulation Component (if any). Only used in "Handler mode" */
Harald Welte624f9632017-12-16 19:26:04 +0100846 RSL_Emulation_CT vc_RSL optional
Harald Welte28d943e2017-11-25 15:00:50 +0100847}
848
Harald Welte21b46bd2017-12-17 19:46:32 +0100849/*! Start the IPA/RSL related bits for one IPA_Client.
850 * \param clnt IPA_Client for which to establish
851 * \param bsc_host IP address / hostname of the BSC
852 * \param bsc_port TCP port number of the BSC
853 * \param i number identifying this BTS
854 * \param handler_mode Start an RSL_Emulation_CT component (true) or not (false) */
Harald Welte624f9632017-12-16 19:26:04 +0100855function f_ipa_rsl_start(inout IPA_Client clnt, charstring bsc_host, PortNumber bsc_port, integer i,
856 boolean handler_mode := false)
Harald Welte28d943e2017-11-25 15:00:50 +0100857runs on test_CT {
Harald Welteae026692017-12-09 01:03:01 +0100858 timer T := 10.0;
859
Harald Welte96c94412017-12-09 03:12:45 +0100860 clnt.id := "IPA" & int2str(i) & "-RSL";
Harald Welteae026692017-12-09 01:03:01 +0100861 clnt.vc_IPA := IPA_Emulation_CT.create(clnt.id & "-IPA");
862 clnt.ccm_pars := c_IPA_default_ccm_pars;
863 clnt.ccm_pars.name := "Osmocom TTCN-3 BTS Simulator";
864 clnt.ccm_pars.unit_id := int2str(1234+i) & "/0/0";
Harald Welte624f9632017-12-16 19:26:04 +0100865 if (handler_mode) {
866 clnt.vc_RSL := RSL_Emulation_CT.create(clnt.id & "-RSL");
Harald Welte89ab1912018-02-23 18:56:29 +0100867 connect(clnt.vc_RSL:CCHAN_PT, self:RSL_CCHAN[i]);
Harald Welte624f9632017-12-16 19:26:04 +0100868 }
Harald Welteae026692017-12-09 01:03:01 +0100869
870 map(clnt.vc_IPA:IPA_PORT, system:IPA_CODEC_PT);
Harald Welte624f9632017-12-16 19:26:04 +0100871 if (handler_mode) {
872 connect(clnt.vc_IPA:IPA_RSL_PORT, clnt.vc_RSL:IPA_PT);
873 } else {
874 connect(clnt.vc_IPA:IPA_RSL_PORT, self:IPA_RSL[i]);
875 }
Harald Welteae026692017-12-09 01:03:01 +0100876
Harald Welte5d1a2202017-12-13 19:51:29 +0100877 clnt.vc_IPA.start(IPA_Emulation.main_client(bsc_host, bsc_port, "", 10000+i, clnt.ccm_pars));
Harald Welte624f9632017-12-16 19:26:04 +0100878 if (handler_mode) {
879 clnt.vc_RSL.start(RSL_Emulation.main());
880 return;
881 }
Harald Welteae026692017-12-09 01:03:01 +0100882
883 /* wait for IPA RSL link to connect and send ID ACK */
884 T.start;
885 alt {
Vadim Yanitskiya2afacc2020-05-18 21:16:19 +0700886 [] IPA_RSL[i].receive(tr_ASP_IPA_EV(ASP_IPA_EVENT_ID_ACK)) {
Harald Welteae026692017-12-09 01:03:01 +0100887 T.stop;
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +0700888 IPA_RSL[i].send(ts_ASP_RSL_UD(ts_RSL_PAGING_LOAD_IND(23)));
Harald Welteae026692017-12-09 01:03:01 +0100889 }
Harald Welte60e823a2017-12-10 14:10:59 +0100890 [] IPA_RSL[i].receive(ASP_IPA_Event:?) { repeat }
Harald Welteae026692017-12-09 01:03:01 +0100891 [] IPA_RSL[i].receive { repeat }
892 [] T.timeout {
Harald Welte96c94412017-12-09 03:12:45 +0100893 setverdict(fail, "Timeout RSL waiting for ASP_IPA_EVENT_ID_ACK");
Daniel Willmannafce8662018-07-06 23:11:32 +0200894 mtc.stop;
Harald Welteae026692017-12-09 01:03:01 +0100895 }
896 }
897}
898
Harald Welte12055472018-03-17 20:10:08 +0100899function f_ipa_rsl_stop(inout IPA_Client clnt) runs on test_CT {
900 if (not isbound(clnt) or not isbound(clnt.vc_IPA)) {
901 return;
902 }
903 clnt.vc_IPA.stop;
904 if (isbound(clnt.vc_RSL)) {
905 clnt.vc_RSL.stop;
906 }
907}
908
Harald Welte21b46bd2017-12-17 19:46:32 +0100909/* Wait for the OML connection to be brought up by the external osmo-bts-omldummy */
Harald Weltea5d2ab22017-12-09 14:21:42 +0100910function f_wait_oml(integer bts_nr, charstring status, float secs_max) runs on test_CT {
911 timer T := secs_max;
912 T.start;
913 while (true) {
914 if (f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-connection-state") == status) {
915 T.stop;
Harald Weltebd868bd2017-12-10 18:28:40 +0100916 /* the 'degraded' state exists from OML connection time, and we have to wait
917 * until all MO's are initialized */
918 T.start(1.0);
919 T.timeout;
Harald Weltea5d2ab22017-12-09 14:21:42 +0100920 return;
921 }
Harald Weltef0d6ac62017-12-17 17:02:21 +0100922 f_sleep(0.1);
Harald Weltea5d2ab22017-12-09 14:21:42 +0100923 if (not T.running) {
Max99253902018-11-16 17:57:39 +0100924 setverdict(fail, "Timeout waiting for BTS" & int2str(bts_nr) & " oml-connection-state ", status);
Daniel Willmannafce8662018-07-06 23:11:32 +0200925 mtc.stop;
Harald Weltea5d2ab22017-12-09 14:21:42 +0100926 }
927 }
928}
929
Harald Welte21b46bd2017-12-17 19:46:32 +0100930/* global altstep for global guard timer; also takes care of responding RESET witH RESET-ACK */
Harald Welteae026692017-12-09 01:03:01 +0100931altstep as_Tguard() runs on test_CT {
Harald Welte60e823a2017-12-10 14:10:59 +0100932 var BSSAP_N_UNITDATA_ind ud_ind;
Neels Hofmeyrcc3f76a2018-03-12 01:43:25 +0100933 [] T_guard.timeout {
934 setverdict(fail, "Timeout of T_guard");
Daniel Willmannafce8662018-07-06 23:11:32 +0200935 mtc.stop;
Neels Hofmeyrcc3f76a2018-03-12 01:43:25 +0100936 }
Harald Welte60e823a2017-12-10 14:10:59 +0100937 /* always respond with RESET ACK to RESET */
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200938 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset(g_osmux_enabled))) -> value ud_ind {
Harald Welte60e823a2017-12-10 14:10:59 +0100939 BSSAP.send(ts_BSSAP_UNITDATA_req(ud_ind.callingAddress, ud_ind.calledAddress,
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200940 ts_BSSMAP_ResetAck(g_osmux_enabled)));
Harald Welte69c1c262017-12-13 21:02:08 +0100941 repeat;
Harald Welte60e823a2017-12-10 14:10:59 +0100942 }
Harald Welte28d943e2017-11-25 15:00:50 +0100943}
944
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +0100945altstep no_bssmap_reset() runs on test_CT {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200946 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset(g_osmux_enabled))) {
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +0100947 setverdict(fail, "unexpected BSSMAP Reset");
Daniel Willmannafce8662018-07-06 23:11:32 +0200948 mtc.stop;
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +0100949 }
950}
951
Daniel Willmann191e0d92018-01-17 12:44:35 +0100952function f_init_mgcp(charstring id) runs on test_CT {
953 id := id & "-MGCP";
954
955 var MGCPOps ops := {
956 create_cb := refers(MGCP_Emulation.ExpectedCreateCallback),
957 unitdata_cb := refers(MGCP_Emulation.DummyUnitdataCallback)
958 };
959 var MGCP_conn_parameters mgcp_pars := {
960 callagent_ip := mp_bsc_ip,
Harald Welte9e4273e2018-01-29 22:01:22 +0100961 callagent_udp_port := -1,
Daniel Willmann191e0d92018-01-17 12:44:35 +0100962 mgw_ip := mp_test_ip,
Pau Espin Pedrol1a026a52019-06-18 17:21:52 +0200963 mgw_udp_port := 2427,
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +0200964 /* Enable it for SCCPlite, since we have 2 MGCP sockets towards MGW (UDP one +
965 the on with MGCP over IPA forwarded from MSC one) */
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200966 multi_conn_mode := (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_SCCPlite_SERVER)
Daniel Willmann191e0d92018-01-17 12:44:35 +0100967 };
968
969 vc_MGCP := MGCP_Emulation_CT.create(id);
970 vc_MGCP.start(MGCP_Emulation.main(ops, mgcp_pars, id));
971}
972
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200973/* Enable or disable (current default) Osmux. When enabling, BSSMAP Reset
974 * contains extra IE (OsmuxSupport) and osmo-bsc will handle AssignReq with
975 * OsmuxCID IE.
976 */
977private function f_vty_allow_osmux(boolean allow) runs on test_CT {
978 f_vty_enter_cfg_msc(BSCVTY, 0);
979 if (allow) {
980 f_vty_transceive(BSCVTY, "osmux on");
981 } else {
982 f_vty_transceive(BSCVTY, "osmux off");
983 }
984 f_vty_transceive(BSCVTY, "exit");
985 f_vty_transceive(BSCVTY, "exit");
986 g_osmux_enabled := allow;
987}
988
Max2253c0b2018-11-06 19:28:05 +0100989function f_init_vty(charstring id := "foo") runs on test_CT {
Harald Welte94e0c342018-04-07 11:33:23 +0200990 if (BSCVTY.checkstate("Mapped")) {
991 /* skip initialization if already executed once */
992 return;
993 }
Harald Weltebc03c762018-02-12 18:09:38 +0100994 map(self:BSCVTY, system:BSCVTY);
995 f_vty_set_prompts(BSCVTY);
996 f_vty_transceive(BSCVTY, "enable");
Pau Espin Pedrolc675b612020-01-09 19:55:40 +0100997 f_cs7_inst_0_cfg(BSCVTY, {"sccp-timer ias " & int2str(g_bsc_sccp_timer_ias),
998 "sccp-timer iar " & int2str(g_bsc_sccp_timer_iar)});
Harald Weltebc03c762018-02-12 18:09:38 +0100999}
1000
Neels Hofmeyr767548a2020-08-09 20:26:07 +00001001private function f_logp(TELNETasp_PT pt, charstring log_msg)
Neels Hofmeyr4f118412020-06-04 15:25:10 +02001002{
1003 // log on TTCN3 log output
1004 log(log_msg);
1005 // log in stderr log
Neels Hofmeyr767548a2020-08-09 20:26:07 +00001006 f_vty_transceive(pt, "logp lglobal notice TTCN3 f_logp(): " & log_msg);
Neels Hofmeyr4f118412020-06-04 15:25:10 +02001007}
1008
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02001009private function f_sysinfo_seen(integer rsl_idx, RSL_Message rsl) runs on test_CT
1010{
1011 if (rsl_idx >= lengthof(g_system_information)) {
1012 g_system_information[rsl_idx] := SystemInformationConfig_omit
1013 }
1014 f_sysinfo_dec_raw(g_system_information[rsl_idx], rsl);
1015}
1016
1017altstep as_catch_RSL_sysinfo(integer rsl_idx) runs on test_CT {
1018 var ASP_RSL_Unitdata rx_rsl_ud;
1019
1020 /* For handler_mode := false, receiving the RSL bootstrap messages directly on IPA_RSL */
1021 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_NO_BCCH_INFO)) -> value rx_rsl_ud {
1022 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1023 repeat;
1024 }
1025 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_BCCH_INFO)) -> value rx_rsl_ud {
1026 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1027 repeat;
1028 }
1029 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_NO_SACCH_FILL)) -> value rx_rsl_ud {
1030 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1031 repeat;
1032 }
1033 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_SACCH_FILL)) -> value rx_rsl_ud {
1034 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1035 repeat;
1036 }
1037
1038 /* For handler_mode := true, receiving the RSL bootstrap messages via RSL_Emulation */
1039 [] RSL_CCHAN[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_NO_BCCH_INFO)) -> value rx_rsl_ud {
1040 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1041 repeat;
1042 }
1043 [] RSL_CCHAN[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_BCCH_INFO)) -> value rx_rsl_ud {
1044 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1045 repeat;
1046 }
1047 [] RSL_CCHAN[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_NO_SACCH_FILL)) -> value rx_rsl_ud {
1048 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1049 repeat;
1050 }
1051 [] RSL_CCHAN[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_SACCH_FILL)) -> value rx_rsl_ud {
1052 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1053 repeat;
1054 }
1055}
1056
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001057/* TODO: use BooleanList from COMMON/src/General_Types.ttcn */
1058private type record of boolean my_BooleanList;
1059
1060private function f_vty_msc_allow_attach(TELNETasp_PT pt, my_BooleanList allow_attach_list)
1061{
Neels Hofmeyr8f576712020-08-12 22:49:53 +00001062 var charstring config := f_vty_transceive_ret(pt, "show running-config");
1063
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001064 for (var integer msc_nr := 0; msc_nr < sizeof(allow_attach_list); msc_nr := msc_nr+1) {
Neels Hofmeyr8f576712020-08-12 22:49:53 +00001065 if (f_strstr(config, "\nmsc " & int2str(msc_nr) & "\n") < 0) {
1066 /* There is no 'msc N' for this msc_nr in the running config, so don't create an empty msc by
1067 * stepping into that config node. */
1068 log("msc ", msc_nr, " is not configured, skipping");
1069 continue;
1070 }
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001071 f_vty_enter_cfg_msc(pt, msc_nr);
1072 if (allow_attach_list[msc_nr]) {
1073 /* strict := false: ignore if osmo-bsc does not support this config option (latest build) */
1074 f_vty_transceive(pt, "allow-attach", strict := false);
1075 } else {
1076 f_vty_transceive(pt, "no allow-attach", strict := false);
1077 }
1078 f_vty_transceive(pt, "exit");
1079 f_vty_transceive(pt, "exit");
1080 }
1081}
1082
Harald Welte21b46bd2017-12-17 19:46:32 +01001083/* global initialization function
1084 * \param nr_bts Number of BTSs we should start/bring up
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001085 * \param handler_mode Start an RSL_Emulation_CT component (true) or not (false).
1086 * \param nr_msc Number of virtual MSCs to bring up to connect to osmo-bsc.
1087 */
1088function f_init(integer nr_bts := NUM_BTS, boolean handler_mode := false, boolean allow_osmux := false,
Neels Hofmeyr4fbad7f2020-06-16 00:30:47 +02001089 integer nr_msc := 1, float guard_timeout := 30.0) runs on test_CT {
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001090 var integer bssap_idx;
Harald Welte28d943e2017-11-25 15:00:50 +01001091
Harald Welteae026692017-12-09 01:03:01 +01001092 if (g_initialized) {
1093 return;
Harald Welte28d943e2017-11-25 15:00:50 +01001094 }
Harald Welteae026692017-12-09 01:03:01 +01001095 g_initialized := true;
1096
Neels Hofmeyr4fbad7f2020-06-16 00:30:47 +02001097 T_guard.start(guard_timeout);
Daniel Willmanne68f9272018-11-27 15:15:28 +01001098 activate(as_Tguard());
1099
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001100 f_init_vty("VirtMSC");
Pau Espin Pedrol58cf6822019-05-28 18:11:33 +02001101 if (mp_enable_osmux_test) {
1102 f_vty_allow_osmux(allow_osmux);
1103 }
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001104
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001105 var my_BooleanList allow_attach := { false, false, false };
Daniel Willmannebdecc02020-08-12 15:30:17 +02001106 f_init_statsd("VirtMSC", vc_STATSD, mp_test_ip, mp_bsc_statsd_port);
1107
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001108 for (bssap_idx := 0; bssap_idx < nr_msc; bssap_idx := bssap_idx+1) {
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001109 allow_attach[bssap_idx] := true;
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001110 /* Call a function of our 'parent component' RAN_Adapter_CT to start the
1111 * MSC-side BSSAP emulation */
1112 if (handler_mode) {
1113 var RanOps ranops := MSC_RanOps;
1114 ranops.use_osmux := g_osmux_enabled;
1115 f_ran_adapter_init(g_bssap[bssap_idx], mp_bssap_cfg[bssap_idx], "VirtMSC", ranops);
1116 connect(self:SCCPLITE_IPA_CTRL, g_bssap[bssap_idx].vc_RAN:CTRL_CLIENT);
1117 f_ran_adapter_start(g_bssap[bssap_idx]);
1118 } else {
1119 f_ran_adapter_init(g_bssap[bssap_idx], mp_bssap_cfg[bssap_idx], "VirtMSC", omit);
1120 connect(self:BSSAP, g_bssap[bssap_idx].vc_SCCP:SCCP_SP_PORT);
1121 f_ran_adapter_start(g_bssap[bssap_idx]);
1122 f_legacy_bssap_reset();
1123 }
Harald Welte67089ee2018-01-17 22:19:03 +01001124 }
Harald Welted5833a82018-05-27 16:52:56 +02001125
Neels Hofmeyrcfe44062020-10-15 02:28:08 +02001126 if (mp_enable_lcs_tests) {
1127 if (handler_mode) {
1128 f_bssap_le_adapter_init(g_bssap_le, mp_bssap_le_cfg, "VirtSMLC", SMLC_BssapLeOps);
1129 } else {
1130 f_bssap_le_adapter_init(g_bssap_le, mp_bssap_le_cfg, "VirtSMLC", omit);
1131 connect(self:BSSAP_LE, g_bssap_le.vc_SCCP:SCCP_SP_PORT);
1132 }
1133 f_bssap_le_adapter_start(g_bssap_le);
Harald Welte47cd0e32020-08-21 12:39:11 +02001134 }
Harald Welte47cd0e32020-08-21 12:39:11 +02001135
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001136 /* start the test with exactly all enabled MSCs allowed to attach */
1137 f_vty_msc_allow_attach(BSCVTY, allow_attach);
1138
Pau Espin Pedrol9a5b8ff2021-01-04 19:01:31 +01001139 f_ipa_ctrl_start_client(mp_bsc_ip, mp_bsc_ctrl_port);
Harald Welte28d943e2017-11-25 15:00:50 +01001140
Daniel Willmann191e0d92018-01-17 12:44:35 +01001141 f_init_mgcp("VirtMSC");
1142
Neels Hofmeyr0b7365b2020-07-04 00:52:34 +02001143 for (var integer i := 0; i < nr_bts; i := i+1) {
1144 f_init_bts(i, handler_mode);
Harald Welte696ddb62017-12-08 14:01:43 +01001145 }
Neels Hofmeyr0b7365b2020-07-04 00:52:34 +02001146}
Harald Welte696ddb62017-12-08 14:01:43 +01001147
Neels Hofmeyr0b7365b2020-07-04 00:52:34 +02001148function f_init_bts(integer bts_idx := 0, boolean handler_mode := false)
1149runs on test_CT {
1150 /* wait until osmo-bts-omldummy has respawned */
1151 f_wait_oml(bts_idx, "degraded", 5.0);
1152
1153 /* start RSL connection */
1154 f_ipa_rsl_start(bts[bts_idx].rsl, mp_bsc_ip, mp_bsc_rsl_port, bts_idx, handler_mode);
1155 /* wait until BSC tells us "connected" */
1156 f_wait_oml(bts_idx, "connected", 5.0);
Harald Welte28d943e2017-11-25 15:00:50 +01001157}
1158
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02001159function f_init_bts_and_check_sysinfo(integer bts_idx := 0, boolean handler_mode := false,
1160 template SystemInformationConfig expect_si)
1161runs on test_CT {
1162 var default sysinfo := activate(as_catch_RSL_sysinfo(bts_idx));
1163
1164 f_init_bts(bts_idx, handler_mode);
1165
1166 /* Give some time to (hopefully/most likely) collect all system informations from RSL startup.
1167 * We could stop as soon as all expected SI are received, but then we might miss SI that we don't expect and
1168 * that might be sent afterwards. So rather give a generous timeout and be quite sure to catch all SI.
1169 */
1170 f_sleep(5.0);
1171 log("RSL ", bts_idx, " SYSTEM INFORMATION: ", g_system_information[bts_idx]);
1172
1173 deactivate(sysinfo);
1174
1175 if (match(g_system_information[bts_idx], expect_si)) {
1176 setverdict(pass);
1177 } else {
1178 log("RSL ", bts_idx, ": EXPECTED SI: ", expect_si);
1179 log("RSL ", bts_idx, ": GOT SI: ", g_system_information[bts_idx]);
1180 setverdict(fail, "received SI does not match expectations");
1181 return;
1182 }
1183}
1184
Maxd4e56962018-10-31 19:08:25 +01001185/* expect to receive a RSL message matching a specified template on a given BTS / stream */
Harald Welte65e419a2020-08-21 12:38:33 +02001186function f_exp_ipa_rx(integer bts_nr, template (present) RSL_Message t_rx, float t_secs := 2.0, IpaStreamId sid := IPAC_PROTO_RSL_TRX0)
Harald Welteae026692017-12-09 01:03:01 +01001187runs on test_CT return RSL_Message {
1188 var ASP_RSL_Unitdata rx_rsl_ud;
1189 timer T := t_secs;
1190
1191 T.start;
1192 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001193 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(t_rx, sid)) -> value rx_rsl_ud {
Harald Welteae026692017-12-09 01:03:01 +01001194 T.stop;
1195 }
1196 [] IPA_RSL[bts_nr].receive { repeat; }
Harald Welteb2917702017-12-10 15:48:52 +01001197 [] T.timeout {
1198 setverdict(fail, "Timeout expecting ", t_rx);
Daniel Willmannafce8662018-07-06 23:11:32 +02001199 mtc.stop;
Harald Welteb2917702017-12-10 15:48:52 +01001200 }
Harald Welteae026692017-12-09 01:03:01 +01001201 }
1202 return rx_rsl_ud.rsl;
1203}
1204
Harald Welte21b46bd2017-12-17 19:46:32 +01001205/* helper function to transmit RSL on a given BTS/stream */
Harald Welte65e419a2020-08-21 12:38:33 +02001206function f_ipa_tx(integer bts_nr, template (value) RSL_Message t_tx, IpaStreamId sid := IPAC_PROTO_RSL_TRX0)
Harald Welteae026692017-12-09 01:03:01 +01001207runs on test_CT {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001208 IPA_RSL[bts_nr].send(ts_ASP_RSL_UD(t_tx, sid));
Harald Welteae026692017-12-09 01:03:01 +01001209}
1210
1211
Harald Welte4003d112017-12-09 22:35:39 +01001212/* verify we get a CHAN_ACT after CHAN RQD */
Harald Welteae026692017-12-09 01:03:01 +01001213testcase TC_chan_act_noreply() runs on test_CT {
1214 var BSSAP_N_UNITDATA_ind ud_ind;
Harald Welte930d0a72018-03-22 22:08:40 +01001215 var RSL_Message rsl_unused;
Harald Welte28d943e2017-11-25 15:00:50 +01001216
Harald Welte89d42e82017-12-17 16:42:41 +01001217 f_init(1);
Harald Welte28d943e2017-11-25 15:00:50 +01001218
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001219 IPA_RSL[0].send(ts_ASP_RSL_UD(ts_RSL_CHAN_RQD('23'O, 23)));
Harald Welte930d0a72018-03-22 22:08:40 +01001220 rsl_unused := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001221 f_shutdown_helper();
Harald Welte28d943e2017-11-25 15:00:50 +01001222}
1223
Harald Welte4003d112017-12-09 22:35:39 +01001224/* verify if the "chreq:total" counter increments as expected */
1225testcase TC_chan_act_counter() runs on test_CT {
1226 var BSSAP_N_UNITDATA_ind ud_ind;
1227 var integer chreq_total;
Harald Welte930d0a72018-03-22 22:08:40 +01001228 var RSL_Message rsl_unused;
Harald Welte4003d112017-12-09 22:35:39 +01001229
Harald Welte89d42e82017-12-17 16:42:41 +01001230 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01001231
1232 chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total");
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001233 IPA_RSL[0].send(ts_ASP_RSL_UD(ts_RSL_CHAN_RQD('23'O, 23)));
Harald Welte930d0a72018-03-22 22:08:40 +01001234 rsl_unused := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
Harald Welte4003d112017-12-09 22:35:39 +01001235 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total", chreq_total+1);
1236
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001237 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01001238}
1239
Harald Welteae026692017-12-09 01:03:01 +01001240/* CHAN RQD -> CHAN ACT -> CHAN ACT ACK -> RF CHAN REL */
Philipp Maier9c60a622020-07-09 15:08:46 +02001241private function f_TC_chan_act_ack_noest(OCT1 ra := '23'O) runs on test_CT {
Harald Welteae026692017-12-09 01:03:01 +01001242 var RSL_Message rx_rsl;
1243
Harald Welteae026692017-12-09 01:03:01 +01001244 /* Send CHAN RQD and wait for allocation; acknowledge it */
Philipp Maier9c60a622020-07-09 15:08:46 +02001245 var RslChannelNr chan_nr := f_chreq_act_ack(ra);
Harald Welteae026692017-12-09 01:03:01 +01001246
1247 /* expect BSC to disable the channel again if there's no RLL EST IND */
1248 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX);
1249
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001250 f_shutdown_helper();
Harald Welteae026692017-12-09 01:03:01 +01001251}
1252
Philipp Maier9c60a622020-07-09 15:08:46 +02001253/* Normal variant */
1254testcase TC_chan_act_ack_noest() runs on test_CT {
Philipp Maieraf58db22020-08-12 17:24:40 +02001255 f_init(1);
Philipp Maier9c60a622020-07-09 15:08:46 +02001256 f_TC_chan_act_ack_noest();
1257}
1258
1259/* Emergency call variant */
1260testcase TC_chan_act_ack_noest_emerg() runs on test_CT {
1261 /* See also: 3GPP TS 04.08, Table 9.9, ra=101xxxxx */
Philipp Maieraf58db22020-08-12 17:24:40 +02001262 f_init(1);
1263 f_vty_allow_emerg_bts(true, 0);
Philipp Maier9c60a622020-07-09 15:08:46 +02001264 f_TC_chan_act_ack_noest(ra := 'A5'O);
1265}
1266
Philipp Maier606f07d2020-08-12 17:21:58 +02001267/* Emergency call variant, but emergency calls are not allowed */
1268testcase TC_chan_rqd_emerg_deny() runs on test_CT {
1269 /* See also: 3GPP TS 04.08, Table 9.9, ra=101xxxxx */
1270
1271 var RSL_Message rx_rsl;
1272 var GsmRrMessage rr;
1273
1274 f_init(1);
1275 f_vty_allow_emerg_bts(false, 0);
1276
1277 IPA_RSL[0].clear;
1278 f_ipa_tx(0, ts_RSL_CHAN_RQD('A5'O, 23));
1279
1280 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeC(RSL_MT_IMMEDIATE_ASSIGN_CMD));
1281 rr := dec_GsmRrMessage(rx_rsl.ies[1].body.full_imm_ass_info.payload);
1282 if (rr.header.message_type == IMMEDIATE_ASSIGNMENT_REJECT) {
1283 setverdict(pass);
1284 } else {
1285 setverdict(fail, "immediate assignment not rejected");
1286 }
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01001287
1288 f_shutdown_helper();
Philipp Maier606f07d2020-08-12 17:21:58 +02001289}
1290
Harald Welteae026692017-12-09 01:03:01 +01001291/* Test behavior if MSC never answers to CR */
1292testcase TC_chan_act_ack_est_ind_noreply() runs on test_CT {
Harald Weltef77aef62018-01-28 15:35:42 +01001293 var RslLinkId main_dcch := valueof(ts_RslLinkID_DCCH(0));
1294 var IpaStreamId sid := IPAC_PROTO_RSL_TRX0;
Harald Welteae026692017-12-09 01:03:01 +01001295 var RSL_Message rx_rsl;
Harald Weltef77aef62018-01-28 15:35:42 +01001296 var ASP_RSL_Unitdata rx_rsl_ud;
Harald Welteae026692017-12-09 01:03:01 +01001297
Harald Welte89d42e82017-12-17 16:42:41 +01001298 f_init(1);
Harald Welteae026692017-12-09 01:03:01 +01001299
1300 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +01001301 var RslChannelNr chan_nr := f_chreq_act_ack();
Harald Welteae026692017-12-09 01:03:01 +01001302
1303 var octetstring l3 := '00010203040506'O
1304 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
1305
1306 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3)));
1307
1308 /* expect BSC to disable the channel again if there's no response from MSC */
Harald Weltef77aef62018-01-28 15:35:42 +01001309 /* MS waits 20s (T3210) at LU; 10s (T3230) at CM SERV REQ and 5s (T3220) AT detach */
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001310 f_expect_chan_rel(0, chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001311 f_shutdown_helper();
Harald Welteae026692017-12-09 01:03:01 +01001312}
1313
1314/* Test behavior if MSC answers with CREF to CR */
1315testcase TC_chan_act_ack_est_ind_refused() runs on test_CT {
1316 var BSSAP_N_CONNECT_ind rx_c_ind;
1317 var RSL_Message rx_rsl;
1318
Harald Welte89d42e82017-12-17 16:42:41 +01001319 f_init(1);
Harald Welteae026692017-12-09 01:03:01 +01001320
1321 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +01001322 var RslChannelNr chan_nr := f_chreq_act_ack();
Harald Welteae026692017-12-09 01:03:01 +01001323
1324 var octetstring l3 := '00010203040506'O
1325 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
1326
1327 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
1328 BSSAP.send(ts_BSSAP_DISC_req(rx_c_ind.connectionId, 0));
1329
1330 /* expect BSC to disable the channel */
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001331 f_expect_chan_rel(0, chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001332 f_shutdown_helper();
Harald Welteae026692017-12-09 01:03:01 +01001333}
1334
Harald Welte618ef642017-12-14 14:58:20 +01001335/* CHAN RQD -> CHAN ACT -> CHAN ACT NACK -> RF CHAN REL */
1336testcase TC_chan_act_nack() runs on test_CT {
1337 var RSL_Message rx_rsl;
1338 var integer chact_nack;
1339
Harald Welte89d42e82017-12-17 16:42:41 +01001340 f_init(1);
Harald Welte618ef642017-12-14 14:58:20 +01001341
1342 chact_nack := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chan_act:nack");
1343
1344 f_ipa_tx(0, ts_RSL_CHAN_RQD('33'O, 33));
1345 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
1346 var RslChannelNr chan_nr := rx_rsl.ies[0].body.chan_nr;
1347
1348 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, RSL_ERR_EQUIPMENT_FAIL));
1349
1350 /* wait for some time to hope the NACK arrives before the CTRL GET below */
1351 f_sleep(0.5);
1352
1353 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chan_act:nack", chact_nack+1);
1354
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001355 f_shutdown_helper();
Harald Welte618ef642017-12-14 14:58:20 +01001356}
1357
Harald Welte799c97b2017-12-14 17:50:30 +01001358/* Test for channel exhaustion due to RACH overload */
1359testcase TC_chan_exhaustion() runs on test_CT {
1360 var ASP_RSL_Unitdata rsl_ud;
1361 var integer i;
1362 var integer chreq_total, chreq_nochan;
1363
Harald Welte89d42e82017-12-17 16:42:41 +01001364 f_init(1);
Harald Welte799c97b2017-12-14 17:50:30 +01001365
1366 chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total");
1367 chreq_nochan := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel");
1368
Pau Espin Pedrolfe200d72018-12-10 12:41:04 +01001369 /* GSM 04.08 Table 9.9a:
1370 * RA = '33'O -> Establishment cause = 0011xxxx (MS dual rate capable and asks for "TCH/H or TCH/F").
1371 * With current setup, expect 4xSDCCH + 4xTCH/F + 1xTCH/H to succeed */
Philipp Maiercb6cc482018-03-26 13:08:00 +02001372 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 +01001373 var RslChannelNr chan_nr := f_chreq_act_ack('33'O, i);
Harald Welte799c97b2017-12-14 17:50:30 +01001374 }
1375
1376 IPA_RSL[0].clear;
1377
Harald Weltedd8cbf32018-01-28 12:07:52 +01001378 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total",
Philipp Maiercb6cc482018-03-26 13:08:00 +02001379 chreq_total + NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS);
Harald Welte799c97b2017-12-14 17:50:30 +01001380
1381 /* now expect additional channel activations to fail */
1382 f_ipa_tx(0, ts_RSL_CHAN_RQD('42'O, 42));
1383
1384 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001385 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV))) {
Harald Welte799c97b2017-12-14 17:50:30 +01001386 setverdict(fail, "Received CHAN ACT ACK without resources?!?");
1387 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001388 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_IMM_ASSIGN(?))) -> value rsl_ud {
Harald Welte799c97b2017-12-14 17:50:30 +01001389 var GsmRrMessage rr;
1390 /* match on IMM ASS REJ */
1391 rr := dec_GsmRrMessage(rsl_ud.rsl.ies[1].body.full_imm_ass_info.payload);
1392 if (rr.header.message_type == IMMEDIATE_ASSIGNMENT_REJECT) {
1393 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total",
Philipp Maiercb6cc482018-03-26 13:08:00 +02001394 chreq_total + NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS+1);
Harald Welte799c97b2017-12-14 17:50:30 +01001395 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel",
1396 chreq_nochan+1);
1397 setverdict(pass);
1398 } else {
1399 repeat;
1400 }
1401 }
1402 [] IPA_RSL[0].receive { repeat; }
1403 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001404 f_shutdown_helper();
Harald Welte799c97b2017-12-14 17:50:30 +01001405}
1406
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07001407/* Test channel deactivation due to silence from MS */
1408testcase TC_chan_deact_silence() runs on test_CT {
1409 var RslChannelNr chan_nr;
1410
1411 f_init(1);
1412
1413 /* Request for a dedicated channel */
1414 chan_nr := f_chreq_act_ack('23'O);
1415
1416 /* Wait some time until the channel is released */
1417 f_sleep(2.0);
1418
1419 /* Expect CHANnel RELease */
1420 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001421 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL))) {
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07001422 log("Received CHANnel RELease");
1423 setverdict(pass);
1424 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001425 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_IMM_ASSIGN(?))) {
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07001426 /* See OS#3709, OsmoBSC should not send Immediate
1427 * Assignment Reject since a dedicated channel was
1428 * already allocated, and Immediate Assignment was
1429 * already sent. */
1430 setverdict(fail, "Unexpected Immediate Assignment!");
1431 }
1432 [] IPA_RSL[0].receive {
1433 setverdict(fail, "Unexpected RSL message!");
1434 }
1435 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001436 f_shutdown_helper();
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07001437}
1438
Harald Weltecfe2c962017-12-15 12:09:32 +01001439/***********************************************************************
1440 * Assignment Testing
1441 ***********************************************************************/
1442
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02001443/* Verify that the BSC refuses any BSSAP connection from the MSC (They are all BSC->MSC direction,
1444 * except for the inter-BSC handover, MT side) */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001445testcase TC_outbound_connect(integer bssap_idx := 0) runs on test_CT {
Harald Welte89d42e82017-12-17 16:42:41 +01001446 f_init(1);
Harald Weltecfe2c962017-12-15 12:09:32 +01001447
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001448 BSSAP.send(ts_BSSAP_CONNECT_req(g_bssap[bssap_idx].sccp_addr_peer, g_bssap[bssap_idx].sccp_addr_own,
1449 2342, ts_BSSMAP_AssignmentReq));
Harald Weltecfe2c962017-12-15 12:09:32 +01001450 BSSAP.receive(tr_BSSAP_DISC_ind(2342, ?, ?));
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001451 f_shutdown_helper();
Harald Weltecfe2c962017-12-15 12:09:32 +01001452}
1453
Harald Welte16a4adf2017-12-14 18:54:01 +01001454/* Test behavior if MSC answers with CREF to CR */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001455testcase TC_assignment_cic_only(integer bssap_idx := 0) runs on test_CT {
Harald Welte16a4adf2017-12-14 18:54:01 +01001456 var BSSAP_N_CONNECT_ind rx_c_ind;
1457 var RSL_Message rx_rsl;
1458 var DchanTuple dt;
1459
Harald Welte89d42e82017-12-17 16:42:41 +01001460 f_init(1);
Harald Welte16a4adf2017-12-14 18:54:01 +01001461
1462 dt := f_est_dchan('23'O, 23, '00000000'O);
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001463 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welte17b27da2018-05-25 20:33:53 +02001464 /* send assignment without AoIP IEs */
1465 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_AssignmentReq(ts_BSSMAP_IE_CIC(0, 1))));
1466 } else {
1467 /* Send assignmetn without CIC in IPA case */
1468 var BSSMAP_IE_AoIP_TransportLayerAddress tla :=
1469 valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342));
1470 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_AssignmentReq(omit, tla)));
1471 }
Harald Welte16a4adf2017-12-14 18:54:01 +01001472 alt {
1473 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentComplete)) {
1474 setverdict(fail, "AoIP BSC cannot accept ASSIGNMENT without AoIP Transport IE");
1475 }
Harald Welte235ebf12017-12-15 14:18:16 +01001476 /* TODO: Actually expect GSM0808_CAUSE_REQ_A_IF_TYPE_NOT_SUPP */
Harald Welte16a4adf2017-12-14 18:54:01 +01001477 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentFail)) {
1478 setverdict(pass);
1479 }
1480 [] BSSAP.receive { repeat; }
1481 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001482 f_shutdown_helper();
Harald Welte16a4adf2017-12-14 18:54:01 +01001483}
1484
Harald Welteed848512018-05-24 22:27:58 +02001485/* generate an assignment request for either AoIP or SCCPlite */
Pau Espin Pedrol07866632020-09-03 19:10:55 +02001486function f_gen_ass_req(boolean osmux_enabled := false, integer bssap_idx := 0, charstring aoip_tla := "1.2.3.4") return PDU_BSSAP {
Harald Welteed848512018-05-24 22:27:58 +02001487 var PDU_BSSAP ass_cmd;
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001488 var BSSMAP_IE_Osmo_OsmuxCID osmux_cid := valueof(ts_OsmuxCID(0));
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001489 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welteed848512018-05-24 22:27:58 +02001490 var BSSMAP_IE_AoIP_TransportLayerAddress tla :=
Pau Espin Pedrol07866632020-09-03 19:10:55 +02001491 valueof(f_ts_BSSMAP_IE_AoIP_TLA(aoip_tla, 2342));
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001492 if (osmux_enabled) {
1493 ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla, osmux_cid));
1494 } else {
1495 ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla));
1496 }
Harald Welteed848512018-05-24 22:27:58 +02001497 } else {
1498 var BSSMAP_IE_CircuitIdentityCode cic := valueof(ts_BSSMAP_IE_CIC(0,1));
Pau Espin Pedrol096d73d2019-06-06 12:49:17 +02001499 ass_cmd := valueof(ts_BSSMAP_AssignmentReq(cic, omit));
Harald Welteed848512018-05-24 22:27:58 +02001500 }
1501 return ass_cmd;
1502}
1503
Pau Espin Pedrol07866632020-09-03 19:10:55 +02001504function f_gen_handover_req(integer bssap_idx := 0, charstring aoip_tla := "1.2.3.4") return PDU_BSSAP {
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01001505 var PDU_BSSAP ho_req;
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001506 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01001507 var BSSMAP_IE_AoIP_TransportLayerAddress tla :=
Pau Espin Pedrol07866632020-09-03 19:10:55 +02001508 valueof(f_ts_BSSMAP_IE_AoIP_TLA(aoip_tla, 2342));
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01001509 ho_req := valueof(ts_BSSMAP_HandoverRequest(omit, tla));
1510 } else {
1511 var BSSMAP_IE_CircuitIdentityCode cic := valueof(ts_BSSMAP_IE_CIC(0,1));
1512 ho_req := valueof(ts_BSSMAP_HandoverRequest(cic, omit));
1513 }
1514 return ho_req;
1515}
1516
Harald Welteed848512018-05-24 22:27:58 +02001517/* generate an assignment complete template for either AoIP or SCCPlite */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001518function f_gen_exp_compl(boolean expect_osmux := false, integer bssap_idx := 0) return template PDU_BSSAP {
Harald Welteed848512018-05-24 22:27:58 +02001519 var template PDU_BSSAP exp_compl;
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001520 var BSSMAP_IE_Osmo_OsmuxCID osmux_cid := valueof(ts_OsmuxCID(0));
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001521 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001522 if (expect_osmux) {
1523 exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?, osmux_cid);
1524 } else {
1525 exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?, omit);
1526 }
Harald Welteed848512018-05-24 22:27:58 +02001527 } else {
1528 /* CIC is optional "*" as the MSC allocated it */
Pau Espin Pedrol096d73d2019-06-06 12:49:17 +02001529 exp_compl := tr_BSSMAP_AssignmentComplete(*, omit);
Harald Welteed848512018-05-24 22:27:58 +02001530 }
1531 return exp_compl;
1532}
1533
Harald Welte235ebf12017-12-15 14:18:16 +01001534/* Run everything required up to sending a caller-specified assignment command and expect response */
1535function f_assignment_exp(PDU_BSSAP ass_cmd, template PDU_BSSAP exp, charstring fail_text)
1536runs on test_CT {
1537 var BSSAP_N_CONNECT_ind rx_c_ind;
1538 var RSL_Message rx_rsl;
1539 var DchanTuple dt;
1540
Harald Welte89d42e82017-12-17 16:42:41 +01001541 f_init(1);
Harald Welte235ebf12017-12-15 14:18:16 +01001542
1543 dt := f_est_dchan('23'O, 23, '00000000'O);
1544 /* send assignment without AoIP IEs */
1545 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ass_cmd));
1546 alt {
1547 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentComplete)) {
1548 if (ischosen(exp.pdu.bssmap.assignmentComplete)) {
1549 setverdict(pass);
1550 } else {
1551 setverdict(fail, fail_text);
1552 }
1553 }
1554 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentFail)) {
1555 if (ischosen(exp.pdu.bssmap.assignmentFailure)) {
1556 setverdict(pass);
1557 } else {
1558 setverdict(fail, fail_text);
1559 }
1560 }
1561 [] BSSAP.receive { repeat; }
1562 }
1563}
1564testcase TC_assignment_csd() runs on test_CT {
1565 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +02001566 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte235ebf12017-12-15 14:18:16 +01001567 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeCSD);
1568 //exp_fail.pdu.bssmap.assignmentFailure.cause.causeValue := int2bit(enum2int(GSM0808_CAUSE_REQ_CODEC_TYPE_OR_CONFIG_UNAVAIL), 7);
1569 f_assignment_exp(ass_cmd, exp_fail, "BSC accepted Assignment for CSD");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001570 f_shutdown_helper();
Harald Welte235ebf12017-12-15 14:18:16 +01001571}
1572
1573testcase TC_assignment_ctm() runs on test_CT {
1574 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +02001575 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte235ebf12017-12-15 14:18:16 +01001576 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeCTM);
1577 //exp_fail.pdu.bssmap.assignmentFailure.cause.causeValue := int2bit(enum2int(GSM0808_CAUSE_REQ_CODEC_TYPE_OR_CONFIG_UNAVAIL), 7);
1578 f_assignment_exp(ass_cmd, exp_fail, "BSC accepted Assignment for Speech+CTM");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001579 f_shutdown_helper();
Harald Welte235ebf12017-12-15 14:18:16 +01001580}
1581
Harald Welte4003d112017-12-09 22:35:39 +01001582type record DchanTuple {
1583 integer sccp_conn_id,
1584 RslChannelNr rsl_chan_nr
Harald Weltea5d2ab22017-12-09 14:21:42 +01001585}
1586
Harald Welted6939652017-12-13 21:02:46 +01001587/* Send CHAN RQD and wait for allocation; acknowledge it */
1588private function f_chreq_act_ack(OCT1 ra := '23'O, GsmFrameNumber fn := 23)
1589runs on test_CT return RslChannelNr {
1590 var RSL_Message rx_rsl;
1591 f_ipa_tx(0, ts_RSL_CHAN_RQD(ra, fn));
1592 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
1593 var RslChannelNr chan_nr := rx_rsl.ies[0].body.chan_nr;
1594 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, fn+10));
Daniel Willmannf4ac4ce2018-08-02 14:06:30 +02001595 rx_rsl := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
Harald Welted6939652017-12-13 21:02:46 +01001596 return chan_nr;
1597}
1598
Harald Welte4003d112017-12-09 22:35:39 +01001599/* helper function to establish a dedicated channel via BTS and MSC */
1600function f_est_dchan(OCT1 ra, GsmFrameNumber fn, octetstring l3)
1601runs on test_CT return DchanTuple {
1602 var BSSAP_N_CONNECT_ind rx_c_ind;
Harald Welte4003d112017-12-09 22:35:39 +01001603 var DchanTuple dt;
Harald Weltea5d2ab22017-12-09 14:21:42 +01001604
Harald Welte4003d112017-12-09 22:35:39 +01001605 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +01001606 dt.rsl_chan_nr := f_chreq_act_ack(ra, fn);
Harald Welte4003d112017-12-09 22:35:39 +01001607
1608 f_ipa_tx(0, ts_RSL_EST_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
1609
1610 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
1611 dt.sccp_conn_id := rx_c_ind.connectionId;
1612 BSSAP.send(ts_BSSAP_CONNECT_res(dt.sccp_conn_id));
1613
1614 return dt;
Harald Weltea5d2ab22017-12-09 14:21:42 +01001615}
1616
Harald Welte641fcbe2018-06-14 10:58:35 +02001617/* expect RF CAN REL from BTS, acknowledge it and clear the MSC side */
1618private function f_exp_chan_rel_and_clear(DchanTuple dt, integer bts_nr := 0) runs on test_CT {
1619 var RSL_Message rx_rsl;
1620 /* expect BSC to disable the channel */
1621 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX);
1622 /* respond with CHAN REL ACK */
1623 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
1624
1625 /* expect Clear Complete from BSC */
1626 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete));
1627
1628 /* MSC disconnects as instructed. */
1629 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1630}
1631
Harald Welte4003d112017-12-09 22:35:39 +01001632/* Test behavior of channel release after unilateral RLL REL IND (DISC from MS) */
1633testcase TC_chan_rel_rll_rel_ind() runs on test_CT {
Neels Hofmeyr27f64362018-03-12 01:44:00 +01001634 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +01001635 var DchanTuple dt;
Harald Welte96c94412017-12-09 03:12:45 +01001636
Harald Welte89d42e82017-12-17 16:42:41 +01001637 f_init(1);
Harald Welte96c94412017-12-09 03:12:45 +01001638
Harald Welte4003d112017-12-09 22:35:39 +01001639 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1640
1641 /* simulate RLL REL IND */
1642 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0))));
1643
Neels Hofmeyr27f64362018-03-12 01:44:00 +01001644 /* expect Clear Request on MSC side */
1645 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
1646
1647 /* Instruct BSC to clear channel */
1648 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
1649 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
1650
Harald Welte4003d112017-12-09 22:35:39 +01001651 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02001652 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyr27f64362018-03-12 01:44:00 +01001653
1654 /* wait for SCCP emulation to do its job */
1655 f_sleep(1.0);
Harald Welte4003d112017-12-09 22:35:39 +01001656
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001657 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01001658}
1659
1660/* Test behavior of channel release after CONN FAIL IND from BTS */
1661testcase TC_chan_rel_conn_fail() runs on test_CT {
1662 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +01001663 var DchanTuple dt;
1664
Harald Welte89d42e82017-12-17 16:42:41 +01001665 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01001666
1667 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1668
1669 /* simulate CONN FAIL IND */
Harald Weltea8ed9062017-12-14 09:46:01 +01001670 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 +01001671 /* TODO: different cause values? */
1672
Harald Welte4003d112017-12-09 22:35:39 +01001673 /* expect Clear Request from BSC */
1674 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
1675
1676 /* Instruct BSC to clear channel */
1677 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
1678 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
1679
Harald Welte6ff76ea2018-01-28 13:08:01 +01001680 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02001681 f_exp_chan_rel_and_clear(dt, 0);
Harald Welte4003d112017-12-09 22:35:39 +01001682
1683 /* wait for SCCP emulation to do its job */
1684 f_sleep(1.0);
1685
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001686 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01001687}
1688
Harald Welte99f3ca02018-06-14 13:40:29 +02001689/* Test behavior of early CONN FAIL IND from BTS (before EST IND!) */
1690/* See also https://www.osmocom.org/issues/3182 */
1691testcase TC_early_conn_fail() runs on test_CT {
1692 var RSL_Message rx_rsl;
1693 var DchanTuple dt;
1694
1695 f_init(1);
1696
1697 /* BTS->BSC: Send CHAN RQD and wait for allocation; acknowledge it */
Harald Weltec46ea3c2020-10-10 18:46:12 +02001698 dt.rsl_chan_nr := f_chreq_act_ack(f_rnd_ra_cs(), 23);
Harald Welte99f3ca02018-06-14 13:40:29 +02001699
1700 /* BTS->BSC: simulate CONN FAIL IND */
1701 f_ipa_tx(0, ts_RSL_CONN_FAIL_IND(dt.rsl_chan_nr, RSL_ERR_RADIO_LINK_FAIL));
1702
1703 /* BTS->BSC: Expect RF channel release from BSC on Abis */
1704 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), 10.0);
1705
1706 /* BTS<-BSC: respond with CHAN REL ACK */
1707 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
1708
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001709 f_shutdown_helper();
Harald Welte99f3ca02018-06-14 13:40:29 +02001710}
1711
1712/* Test behavior of late CONN FAIL IND from BTS (ater REL IND!) */
1713/* See also https://www.osmocom.org/issues/3182 */
1714testcase TC_late_conn_fail() runs on test_CT {
1715 var RSL_Message rx_rsl;
1716 var DchanTuple dt;
1717
1718 f_init(1);
1719
1720 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1721
1722 /* BSC<-MSC: Instruct BSC to clear connection */
1723 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(0)));
1724
1725 /* BTS->BSC: expect BSC to deactivate SACCH */
1726 rx_rsl := f_exp_ipa_rx(0, tr_RSL_DEACT_SACCH(dt.rsl_chan_nr));
1727
1728 /* BTS->BSC: simulate a late CONN FAIL IND from BTS */
1729 f_ipa_tx(0, ts_RSL_CONN_FAIL_IND(dt.rsl_chan_nr, RSL_ERR_RADIO_LINK_FAIL));
1730
1731 /* BTS<-BSC: Expect RF channel release from BSC on Abis */
1732 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), 10.0);
1733 /* BTS->BSC: respond with CHAN REL ACK */
1734 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
1735
1736 /* BSC->MSC: expect Clear Complete from BSC */
1737 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete));
1738
1739 /* BSC<-MSC: MSC disconnects as requested. */
1740 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1741
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001742 f_shutdown_helper();
Harald Welte99f3ca02018-06-14 13:40:29 +02001743}
1744
Neels Hofmeyrf44ccd12018-11-05 19:15:23 +01001745function f_expect_chan_rel(integer bts_nr, RslChannelNr rsl_chan_nr,
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001746 boolean expect_deact_sacch := true,
1747 boolean expect_rr_chan_rel := true,
1748 boolean expect_rll_rel_req := true,
Harald Welte99787102019-02-04 10:41:36 +01001749 boolean handle_rll_rel := true,
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001750 boolean is_csfb := false,
Pau Espin Pedrol36bd4fa2021-04-15 13:00:24 +02001751 template CellSelIndValue expect_cells := omit,
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001752 template RR_Cause expect_rr_cause := ?
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001753 ) runs on test_CT {
Harald Welte91d54a52018-01-28 15:35:07 +01001754
1755 var RslLinkId main_dcch := valueof(ts_RslLinkID_DCCH(0));
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001756 var boolean got_deact_sacch := false;
1757 var boolean got_rr_chan_rel := false;
1758 var boolean got_rll_rel_req := false;
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001759 var ASP_RSL_Unitdata ud;
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001760 var RSL_IE_Body l3_ie;
1761 var PDU_ML3_NW_MS l3;
1762 var RR_Cause got_cause;
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001763 log("f_expect_chan_rel() expecting: expect_deact_sacch=", expect_deact_sacch, " expect_rr_chan_rel=", expect_rr_chan_rel,
1764 " expect_rll_rel_req=", expect_rll_rel_req);
Harald Welte91d54a52018-01-28 15:35:07 +01001765 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001766 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_DEACT_SACCH(rsl_chan_nr))) {
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001767 got_deact_sacch := true;
Harald Welte91d54a52018-01-28 15:35:07 +01001768 repeat;
1769 }
Pau Espin Pedrol36bd4fa2021-04-15 13:00:24 +02001770 [is_csfb] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_DATA_REQ(rsl_chan_nr, ?, decmatch tr_RRM_RR_RELEASE_CellSelectInd))) -> value ud {
Harald Welte99787102019-02-04 10:41:36 +01001771 got_rr_chan_rel := true;
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001772
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001773 if (f_rsl_find_ie(ud.rsl, RSL_IE_L3_INFO, l3_ie) == false) {
1774 setverdict(fail, "cannot find L3");
1775 mtc.stop;
1776 }
1777 l3 := dec_PDU_ML3_NW_MS(l3_ie.l3_info.payload);
1778
Pau Espin Pedrol36bd4fa2021-04-15 13:00:24 +02001779 if (not istemplatekind(expect_cells, "omit")) {
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001780 var CellSelIndValue cells := dec_CellSelIndValue(
1781 l3.msgs.rrm.channelRelease.cellSelectionIndicator.cellSelectionIndicatorValue);
1782
Pau Espin Pedrol36bd4fa2021-04-15 13:00:24 +02001783 log("GOT RR CHANNEL RELEASE WITH CELLS: ", cells);
1784 if (match(cells, expect_cells)) {
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001785 setverdict(pass);
1786 } else {
Pau Espin Pedrol36bd4fa2021-04-15 13:00:24 +02001787 log("EXPECTED CELLS: ", expect_cells);
1788 setverdict(fail, "Received cells list on RR Channel Release does not match expectations");
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001789 }
1790 }
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001791
1792 if (not istemplatekind(expect_rr_cause, "omit")) {
1793 int2enum(oct2int(l3.msgs.rrm.channelRelease.rRCause.valuePart), got_cause);
1794 log("GOT CAUSE CODE: ", l3.msgs.rrm.channelRelease.rRCause.valuePart, " = ", got_cause);
1795 if (match(got_cause, expect_rr_cause)) {
1796 setverdict(pass);
1797 } else {
1798 log("EXPECTED CAUSE CODE: ", expect_rr_cause);
1799 setverdict(fail, "Received RR Channel Release Cause code does not match expectations");
1800 }
1801 }
Harald Welte99787102019-02-04 10:41:36 +01001802 repeat;
1803 }
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001804 [not is_csfb] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_DATA_REQ(rsl_chan_nr, ?, decmatch tr_RRM_RR_RELEASE))) -> value ud {
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001805 got_rr_chan_rel := true;
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001806
1807 if (not istemplatekind(expect_rr_cause, "omit")) {
1808 if (f_rsl_find_ie(ud.rsl, RSL_IE_L3_INFO, l3_ie) == false) {
1809 setverdict(fail, "cannot find L3");
1810 mtc.stop;
1811 }
1812 l3 := dec_PDU_ML3_NW_MS(l3_ie.l3_info.payload);
1813
1814 int2enum(oct2int(l3.msgs.rrm.channelRelease.rRCause.valuePart), got_cause);
1815 log("GOT CAUSE CODE: ", l3.msgs.rrm.channelRelease.rRCause.valuePart, " = ", got_cause);
1816 if (match(got_cause, expect_rr_cause)) {
1817 setverdict(pass);
1818 } else {
1819 log("EXPECTED CAUSE CODE: ", expect_rr_cause);
1820 setverdict(fail, "Received RR Channel Release Cause code does not match expectations");
1821 }
1822 }
Neels Hofmeyr211169d2018-11-07 00:37:29 +01001823 repeat;
1824 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001825 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_REL_REQ(rsl_chan_nr, ?))) {
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001826 got_rll_rel_req := true;
Harald Welte91d54a52018-01-28 15:35:07 +01001827 /* FIXME: Why are we getting this for LinkID SACCH? */
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001828 if (handle_rll_rel) {
1829 f_ipa_tx(0, ts_RSL_REL_CONF(rsl_chan_nr, main_dcch));
1830 }
Harald Welte91d54a52018-01-28 15:35:07 +01001831 repeat;
1832 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001833 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL))) {
Harald Welte91d54a52018-01-28 15:35:07 +01001834 /* respond with CHAN REL ACK */
1835 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(rsl_chan_nr));
1836 }
1837 /* ignore any user data */
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001838 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeR(?))) {
Harald Welte91d54a52018-01-28 15:35:07 +01001839 repeat;
1840 }
1841 }
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001842
1843 log("f_expect_chan_rel() summary: got_deact_sacch=", got_deact_sacch, " got_rr_chan_rel=", got_rr_chan_rel,
1844 " got_rll_rel_req=", got_rll_rel_req);
1845
1846 if (expect_deact_sacch != got_deact_sacch) {
1847 setverdict(fail, "f_expect_chan_rel(): expect_deact_sacch=", expect_deact_sacch, " got_deact_sacch=", got_deact_sacch);
1848 }
1849 if (expect_rr_chan_rel != got_rr_chan_rel) {
1850 setverdict(fail, "f_expect_chan_rel(): expect_rr_chan_rel=", expect_rr_chan_rel, " got_rr_chan_rel=", got_rr_chan_rel);
1851 }
1852 if (expect_rll_rel_req != got_rll_rel_req) {
1853 setverdict(fail, "f_expect_chan_rel(): expect_rll_rel_req=", expect_rll_rel_req, " got_rll_rel_req=", got_rll_rel_req);
1854 }
Harald Welte91d54a52018-01-28 15:35:07 +01001855}
1856
Harald Welte4003d112017-12-09 22:35:39 +01001857/* Test behavior of channel release after hard Clear Command from MSC */
1858testcase TC_chan_rel_hard_clear() runs on test_CT {
1859 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +01001860 var DchanTuple dt;
Harald Welte4003d112017-12-09 22:35:39 +01001861
Harald Welte89d42e82017-12-17 16:42:41 +01001862 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01001863
1864 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1865
1866 /* Instruct BSC to clear channel */
1867 var BssmapCause cause := 0;
1868 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
1869
1870 /* expect Clear Complete from BSC on A */
1871 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
1872 /* release the SCCP connection */
1873 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1874 }
1875
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001876 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001877 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01001878}
1879
Harald Welte99787102019-02-04 10:41:36 +01001880/* Test behavior of channel release after Clear Command with CSFB indicator from MSC */
1881testcase TC_chan_rel_hard_clear_csfb() runs on test_CT {
1882 var BSSAP_N_DATA_ind rx_di;
1883 var DchanTuple dt;
1884
1885 f_init(1);
1886
1887 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1888
1889 /* Instruct BSC to clear channel */
1890 var BssmapCause cause := 0;
1891 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommandCSFB(cause)));
1892
1893 /* expect Clear Complete from BSC on A */
1894 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
1895 /* release the SCCP connection */
1896 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1897 }
1898
1899 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false, is_csfb := true);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001900 f_shutdown_helper();
Harald Welte99787102019-02-04 10:41:36 +01001901}
1902
Harald Welted8c36cd2017-12-09 23:05:31 +01001903/* Test behavior of channel release after hard RLSD from MSC */
1904testcase TC_chan_rel_hard_rlsd() runs on test_CT {
Harald Welted8c36cd2017-12-09 23:05:31 +01001905 var DchanTuple dt;
Harald Welted8c36cd2017-12-09 23:05:31 +01001906
Harald Welte89d42e82017-12-17 16:42:41 +01001907 f_init(1);
Harald Welted8c36cd2017-12-09 23:05:31 +01001908
1909 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1910
1911 /* release the SCCP connection */
1912 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1913
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001914 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001915 f_shutdown_helper();
Harald Welted8c36cd2017-12-09 23:05:31 +01001916}
1917
Harald Welte550daf92018-06-11 19:22:13 +02001918/* Test behavior of channel release after hard RLSD from MSC and MS is not responding to RLL REL REQ */
1919testcase TC_chan_rel_hard_rlsd_ms_dead() runs on test_CT {
1920 var DchanTuple dt;
1921
1922 f_init(1);
1923
1924 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1925
1926 /* release the SCCP connection */
1927 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1928
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001929 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001930 f_shutdown_helper();
Harald Welte550daf92018-06-11 19:22:13 +02001931}
1932
Harald Welte85804d42017-12-10 14:11:58 +01001933/* Test behavior of channel release after BSSMAP RESET from MSC */
1934testcase TC_chan_rel_a_reset() runs on test_CT {
Harald Welte85804d42017-12-10 14:11:58 +01001935 var DchanTuple dt;
Harald Welte85804d42017-12-10 14:11:58 +01001936
Harald Welte89d42e82017-12-17 16:42:41 +01001937 f_init(1);
Harald Welte85804d42017-12-10 14:11:58 +01001938
1939 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1940
1941 /* Clear the queue, it might still contain stuff like IMMEDIATE ASSIGN */
1942 IPA_RSL[0].clear;
1943
1944 /* perform BSSAP RESET, expect RESET ACK and DISC.ind on connection */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001945 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 +01001946 interleave {
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001947 [] 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 +01001948 [] BSSAP.receive(tr_BSSAP_DISC_ind(dt.sccp_conn_id, ?, ?)) { }
1949 }
1950
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001951 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001952 f_shutdown_helper();
Harald Welte85804d42017-12-10 14:11:58 +01001953}
1954
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01001955/* Verify T(iar) triggers and releases the channel */
1956testcase TC_chan_rel_sccp_tiar_timeout() runs on test_CT {
1957 var DchanTuple dt;
1958
1959 /* Set T(iar) in BSC low enough that it will trigger before other side
1960 has time to keep alive with a T(ias). Keep recommended ratio of
1961 T(iar) >= T(ias)*2 */
1962 g_bsc_sccp_timer_ias := 2;
1963 g_bsc_sccp_timer_iar := 5;
1964
1965 f_init(1);
1966
1967 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1968 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001969 f_shutdown_helper();
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01001970}
1971
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001972private function f_tc_chan_rel_rr_cause(myBSSMAP_Cause clear_cmd_cause, template RR_Cause expect_rr_cause)
1973runs on test_CT
1974{
1975 var DchanTuple dt;
1976
1977 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1978 var BssmapCause cause := 0;
1979 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(enum2int(clear_cmd_cause))));
1980 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
1981 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1982 }
1983
1984 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false, expect_rr_cause := expect_rr_cause);
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001985}
1986
1987/* Test that Clear Command cause codes affect the RR Channel Release cause code */
1988testcase TC_chan_rel_rr_cause() runs on test_CT {
1989 f_init(1);
1990
1991 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_CALL_CONTROL, GSM48_RR_CAUSE_NORMAL);
1992 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_HANDOVER_SUCCESSFUL, GSM48_RR_CAUSE_NORMAL);
1993 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_PREEMPTION, GSM48_RR_CAUSE_PREMPTIVE_REL);
1994 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_RADIO_INTERFACE_MESSAGE_FAILURE, GSM48_RR_CAUSE_PROT_ERROR_UNSPC);
1995 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_RADIO_INTERFACE_FAILURE, GSM48_RR_CAUSE_ABNORMAL_UNSPEC);
1996 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_EQUIPMENT_FAILURE, GSM48_RR_CAUSE_ABNORMAL_UNSPEC);
Vadim Yanitskiye18aebb2021-01-03 13:10:43 +01001997
1998 f_shutdown_helper();
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001999}
2000
Harald Welte5cd20ed2017-12-13 21:03:20 +01002001/* Test behavior if RSL EST IND for non-active channel */
2002testcase TC_rll_est_ind_inact_lchan() runs on test_CT {
2003 timer T := 2.0;
2004
Harald Welte89d42e82017-12-17 16:42:41 +01002005 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01002006
2007 var octetstring l3 := '00010203040506'O;
2008 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
2009 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
2010
2011 T.start;
2012 alt {
2013 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
2014 setverdict(fail, "MSC received COMPL L3 for non-active lchan");
2015 }
2016 [] BSSAP.receive {}
2017 [] IPA_RSL[0].receive {}
2018 [] T.timeout {}
2019 }
2020
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002021 f_shutdown_helper();
Harald Welte5cd20ed2017-12-13 21:03:20 +01002022}
2023
2024/* Test behavior if RSL EST IND for invalid SAPI */
2025testcase TC_rll_est_ind_inval_sapi1() runs on test_CT {
2026 var RslChannelNr chan_nr;
2027
Harald Welte89d42e82017-12-17 16:42:41 +01002028 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01002029
2030 chan_nr := f_chreq_act_ack()
2031
2032 var octetstring l3 := '00010203040506'O;
2033 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(1)), l3));
2034
2035 timer T := 2.0;
2036 T.start;
2037 alt {
2038 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
2039 setverdict(fail, "MSC received COMPL L3 for invalid SAPI 1");
2040 }
2041 [] BSSAP.receive { repeat; }
2042 [] IPA_RSL[0].receive { repeat; }
2043 [] T.timeout {}
2044 }
2045
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002046 f_shutdown_helper();
Harald Welte5cd20ed2017-12-13 21:03:20 +01002047}
2048
2049/* Test behavior if RSL EST IND for invalid SAPI */
2050testcase TC_rll_est_ind_inval_sapi3() runs on test_CT {
2051 timer T := 2.0;
2052
Harald Welte89d42e82017-12-17 16:42:41 +01002053 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01002054
2055 var RslChannelNr chan_nr := f_chreq_act_ack();
2056
2057 var octetstring l3 := '00010203040506'O;
2058 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(3)), l3));
2059
2060 T.start;
2061 alt {
2062 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
2063 setverdict(fail, "MSC received COMPL L3 for invalid SAPI 3");
2064 }
2065 [] BSSAP.receive { repeat; }
2066 [] IPA_RSL[0].receive { repeat; }
2067 [] T.timeout {}
2068 }
2069
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002070 f_shutdown_helper();
Harald Welte5cd20ed2017-12-13 21:03:20 +01002071}
2072
2073/* Test behavior if RSL EST IND for invalid SACCH */
2074testcase TC_rll_est_ind_inval_sacch() runs on test_CT {
2075 timer T := 2.0;
2076
Harald Welte89d42e82017-12-17 16:42:41 +01002077 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01002078
2079 var RslChannelNr chan_nr := f_chreq_act_ack();
2080
2081 var octetstring l3 := '00010203040506'O;
2082 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_SACCH(0)), l3));
2083
2084 T.start;
2085 alt {
2086 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
2087 setverdict(fail, "MSC received COMPL L3 for invalid Link SACCH");
2088 }
2089 [] BSSAP.receive { repeat; }
2090 [] IPA_RSL[0].receive { repeat; }
2091 [] T.timeout {}
2092 }
2093
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002094 f_shutdown_helper();
Harald Welte5cd20ed2017-12-13 21:03:20 +01002095}
2096
Vadim Yanitskiy61f784a2020-10-01 21:12:19 +07002097/* Verify DLCI / RSL Link ID conversion for MO/MT messages on SAPI0/SAPI3 */
2098private function f_TC_tch_dlci_link_id_sapi(charstring id) runs on MSC_ConnHdlr {
2099 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2100 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2101
2102 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2103 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
2104
2105 f_establish_fully(ass_cmd, exp_compl);
2106
2107 /* SAPI0 has already been established by f_establish_fully(), establish SAPI3 */
2108 RSL.send(ts_RSL_EST_IND(g_chan_nr, ts_RslLinkID_SACCH(3), '0904'O));
2109 /* Expect BSSAP/DTAP on SAPI3 (DLCI IE) */
2110 BSSAP.receive(PDU_BSSAP:{
2111 discriminator := '1'B,
2112 spare := '0000000'B,
2113 dlci := 'C3'O,
2114 lengthIndicator := ?,
2115 pdu := { dtap := '0904'O }
2116 });
2117
2118 /* Send messages on DCCH/SAPI0 and ACCH/SAPI3 */
2119 for (var integer i := 0; i < 32; i := i + 1) {
2120 var octetstring l3 := '09'O & f_rnd_octstring(14);
2121 var template (value) RslLinkId link_id;
2122 var template (value) OCT1 dlci;
2123
2124 if (i mod 2 == 0) {
2125 /* SAPI0 on FACCH or SDCCH */
2126 link_id := ts_RslLinkID_DCCH(0);
2127 dlci := '80'O;
2128 } else {
2129 /* SAPI3 on SACCH */
2130 link_id := ts_RslLinkID_SACCH(3);
2131 dlci := 'C3'O;
2132 }
2133
2134 /* Send MO message: RSL -> BSSAP */
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00002135 f_mo_l3_transceive(RSL, link_id, dlci, l3);
Vadim Yanitskiy61f784a2020-10-01 21:12:19 +07002136 /* Send MT message: BSSAP -> RSL */
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00002137 f_mt_l3_transceive(RSL, link_id, dlci, l3);
Vadim Yanitskiy61f784a2020-10-01 21:12:19 +07002138 }
2139}
2140testcase TC_tch_dlci_link_id_sapi() runs on test_CT {
2141 var TestHdlrParams pars := f_gen_test_hdlr_pars();
2142 var MSC_ConnHdlr vc_conn;
2143
2144 f_init(1, true);
2145 f_sleep(1.0);
2146
2147 vc_conn := f_start_handler(refers(f_TC_tch_dlci_link_id_sapi), pars);
2148 vc_conn.done;
2149
2150 f_shutdown_helper();
2151}
2152
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07002153private function f_exp_sapi_n_reject(template (present) GsmSapi sapi := ?,
2154 template myBSSMAP_Cause cause := ?,
2155 float T_val := 2.0)
2156runs on test_CT {
2157 var BSSAP_N_DATA_ind rx_di;
2158 timer T;
2159
2160 var template BSSMAP_IE_Cause tr_cause := tr_BSSMAP_IE_Cause(cause);
2161 var template PDU_BSSAP tr_pdu := tr_BSSMAP_SAPInReject(sapi);
2162
2163 T.start(T_val);
2164 alt {
2165 [] BSSAP.receive(tr_BSSAP_DATA_ind(?, tr_pdu)) -> value rx_di {
2166 var BSSMAP_IE_Cause rx_cause := rx_di.userData.pdu.bssmap.sAPInReject.cause;
2167 if (not match(rx_cause, tr_cause)) {
2168 setverdict(fail, "Rx unexpected Cause IE: ",
2169 rx_cause, " vs expected ", tr_cause);
2170 }
2171 setverdict(pass);
2172 }
2173 [] BSSAP.receive(BSSAP_N_DATA_ind:?) -> value rx_di {
2174 setverdict(fail, "Rx unexpected BSSAP PDU: ", rx_di);
2175 }
2176 [] T.timeout {
2177 setverdict(fail, "Timeout waiting for BSSMAP SAPI N Reject");
2178 }
2179 }
2180}
2181
2182/* Check if we get SAPI N Reject on receipt of unexpected RLL RELease INDication */
2183testcase TC_rll_rel_ind_sapi_n_reject() runs on test_CT {
2184 var octetstring rnd_data := f_rnd_octstring(16);
2185 var RSL_Message rx_rsl;
2186 var DchanTuple dt;
2187
2188 f_init(1);
2189
2190 /* MS establishes a SAPI=0 link on DCCH */
2191 dt := f_est_dchan(f_rnd_ra_cs(), 23, rnd_data);
2192
2193 /* MSC sends some data on (not yet established) SAPI=3 link */
2194 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSAP_DTAP(rnd_data, '03'O)));
2195 /* BSC attempts to establish a SAPI=3 link on DCCH */
2196 rx_rsl := f_exp_ipa_rx(0, tr_RSL_EST_REQ(dt.rsl_chan_nr, tr_RslLinkID_DCCH(3)));
2197
2198 /* MS sends unexpected RELease INDication on SAPI=3 */
2199 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, ts_RslLinkID_DCCH(3)));
2200 /* We expect to receive BSSMAP SAPI N Reject message from the BSC */
2201 f_exp_sapi_n_reject(3, GSM0808_CAUSE_MS_NOT_EQUIPPED);
2202
2203 /* Clean up the connection */
2204 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2205 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
2206
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002207 f_shutdown_helper();
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07002208}
2209
2210/* Check if we get SAPI N Reject on receipt of unexpected RLL ERROR INDication */
2211testcase TC_rll_err_ind_sapi_n_reject() runs on test_CT {
2212 var octetstring rnd_data := f_rnd_octstring(16);
2213 var RSL_Message rx_rsl;
2214 var DchanTuple dt;
2215
2216 f_init(1);
2217
2218 /* MS establishes a SAPI=0 link on DCCH */
2219 dt := f_est_dchan(f_rnd_ra_cs(), 23, rnd_data);
2220
2221 /* MSC sends some data on (not yet established) SAPI=3 link */
2222 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSAP_DTAP(rnd_data, '03'O)));
2223 /* BSC attempts to establish a SAPI=3 link on DCCH */
2224 rx_rsl := f_exp_ipa_rx(0, tr_RSL_EST_REQ(dt.rsl_chan_nr, tr_RslLinkID_DCCH(3)));
2225
2226 /* BTS sends unexpected ERROR INDication on SAPI=3 */
2227 f_ipa_tx(0, ts_RSL_ERROR_IND(dt.rsl_chan_nr, ts_RslLinkID_DCCH(3), ''O));
2228 /* We expect to receive BSSMAP SAPI N Reject message from the BSC */
2229 f_exp_sapi_n_reject(3, GSM0808_CAUSE_BSS_NOT_EQUIPPED);
2230
2231 /* Clean up the connection */
2232 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2233 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
2234
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002235 f_shutdown_helper();
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07002236}
2237
2238/* Check if we get SAPI N Reject due to a SAPI=3 link establishment timeout */
2239testcase TC_rll_timeout_sapi_n_reject() runs on test_CT {
2240 var octetstring rnd_data := f_rnd_octstring(16);
2241 var RSL_Message rx_rsl;
2242 var DchanTuple dt;
2243
2244 f_init(1);
2245
2246 /* MS establishes a SAPI=0 link on DCCH */
2247 dt := f_est_dchan(f_rnd_ra_cs(), 23, rnd_data);
2248
2249 /* MSC sends some data on (not yet established) SAPI=3 link */
2250 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSAP_DTAP(rnd_data, '03'O)));
2251 /* BSC attempts to establish a SAPI=3 link on DCCH */
2252 rx_rsl := f_exp_ipa_rx(0, tr_RSL_EST_REQ(dt.rsl_chan_nr, tr_RslLinkID_DCCH(3)));
2253
2254 /* MS does not respond, so the link establishment timeout triggers SAPI N Reject */
2255 f_exp_sapi_n_reject(3, GSM0808_CAUSE_BSS_NOT_EQUIPPED, T_val := 8.0);
2256
2257 /* Clean up the connection */
2258 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2259 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
2260
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002261 f_shutdown_helper();
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07002262}
2263
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02002264testcase TC_si_default() runs on test_CT {
2265 f_init(0);
2266 f_init_bts_and_check_sysinfo(0, expect_si := SystemInformationConfig_default);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002267 f_shutdown_helper();
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02002268}
Harald Welte4003d112017-12-09 22:35:39 +01002269
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002270/* We're testing SI2quater with lists of EARFCNs. Instead of just incrementing EARFCNs, also pick some from the edges of
2271 * the entire value range. This function provides the same EARFCN numbers for the same earfcn_index */
2272private function f_test_si2quater_earfcn_by_idx(integer earfcn_index) return uint16_t
2273{
2274 select (earfcn_index) {
2275 case (0) {
2276 /* E-ARFCN 111 is already added in the osmo-bsc.cfg */
2277 return 111;
2278 }
2279 case (1) {
2280 return 1;
2281 }
2282 case (2) {
2283 return 0;
2284 }
2285 case (3) {
2286 return 65535;
2287 }
2288 case else {
2289 return 23 * (earfcn_index - 3);
2290 }
2291 }
2292}
2293
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002294function f_test_si2quater(integer total_earfcns, template SystemInformationConfig expect_si,
2295 template CellSelIndValue expect_cells := omit) runs on test_CT {
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002296
2297 f_init(0);
2298
2299 /* E-ARFCN 111 is already added in the osmo-bsc.cfg, so only add more arfcns if total_earfcns > 1 */
2300 for (var integer i := 1; i < total_earfcns; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002301 f_bts_0_cfg(BSCVTY, {"si2quater neighbor-list add earfcn " & int2str(f_test_si2quater_earfcn_by_idx(i))
2302 & " thresh-hi 20 thresh-lo 10 prio 3 qrxlv 22 meas 3"});
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002303 }
2304
2305 f_init_bts_and_check_sysinfo(0, expect_si := expect_si);
2306
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002307 if (not istemplatekind(expect_cells, "omit")) {
2308 /* Also check that RR Channel Release contains these EARFCNs.
2309 * (copied code from TC_chan_rel_hard_clear_csfb) */
2310 var BSSAP_N_DATA_ind rx_di;
2311 var DchanTuple dt;
2312
2313 dt := f_est_dchan('23'O, 23, '00010203040506'O);
2314
2315 /* Instruct BSC to clear channel */
2316 var BssmapCause cause := 0;
2317 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommandCSFB(cause)));
2318
2319 /* expect Clear Complete from BSC on A */
2320 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
2321 /* release the SCCP connection */
2322 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2323 }
2324
2325 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false, is_csfb := true,
Pau Espin Pedrol36bd4fa2021-04-15 13:00:24 +02002326 expect_cells := expect_cells);
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002327 }
2328
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002329 for (var integer i := 1; i < total_earfcns; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002330 f_bts_0_cfg(BSCVTY, {"si2quater neighbor-list del earfcn " & int2str(f_test_si2quater_earfcn_by_idx(i))});
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002331 }
2332}
2333
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002334private function f_tr_si2quater_earfcns(integer count) return template SI2quaterRestOctetsList
2335{
2336 var template SI2quaterRestOctetsList si2quater := {};
2337 var integer si2quater_count := (count + 2) / 3;
2338
2339 for (var integer i := 0; i < count; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002340 var integer earfcn := f_test_si2quater_earfcn_by_idx(i);
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002341 var integer index := i / 3;
2342 var integer earfcn_index := i mod 3;
2343 if (index >= lengthof(si2quater)) {
2344 si2quater[index] := tr_SI2quaterRestOctets_EUTRAN(index := index, count := si2quater_count - 1);
2345 }
2346 si2quater[index].rel_additions.rel5.rel6.rel7.rel8.prio_eutran_params_desc.desc.eutran_params_desc.desc.repeated_neigh_cells[0].cell_desc_list[earfcn_index] := tr_EUTRAN_CellDesc_default(e_arfcn := earfcn);
2347 }
2348
2349 return si2quater;
2350}
2351
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002352private function f_tr_rr_chan_rel_earfcns(integer count) return template CellSelIndValue
2353{
2354 var template CellSelIndValue_EUTRAN_Descrs cells := {};
2355
Alexander Couzensf74b5cb2020-09-10 22:28:40 +02002356 /* the lte neighbors must match the config & vty to pass this test */
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002357 for (var integer i := 0; i < count; i := i + 1) {
2358 var integer earfcn := f_test_si2quater_earfcn_by_idx(i);
Alexander Couzensf74b5cb2020-09-10 22:28:40 +02002359 cells[i] := tr_CellSelIndValue_EUTRAN_Descr(earfcn, '1'B, 3);
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002360 }
2361
2362 return tr_CellSelIndValue_EUTRAN(cells);
2363}
2364
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002365private function f_tc_si2quater_n_earfcns(integer n) runs on test_CT
2366{
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002367 var template SystemInformationConfig sic := SystemInformationConfig_default;
Pau Espin Pedrol8ab62e42020-12-18 16:19:11 +01002368 sic.si2quater := f_tr_si2quater_earfcns(n);
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002369 var template CellSelIndValue cells := f_tr_rr_chan_rel_earfcns(n);
2370 f_test_si2quater(n, sic, cells);
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002371}
2372
2373testcase TC_si2quater_2_earfcns() runs on test_CT {
2374 f_tc_si2quater_n_earfcns(2);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002375 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002376}
2377
2378testcase TC_si2quater_3_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002379 f_tc_si2quater_n_earfcns(3);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002380 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002381}
2382
2383testcase TC_si2quater_4_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002384 f_tc_si2quater_n_earfcns(4);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002385 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002386}
2387
2388testcase TC_si2quater_5_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002389 f_tc_si2quater_n_earfcns(5);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002390 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002391}
2392
2393testcase TC_si2quater_6_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002394 f_tc_si2quater_n_earfcns(6);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002395 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002396}
2397
2398testcase TC_si2quater_12_earfcns() runs on test_CT {
2399 f_tc_si2quater_n_earfcns(12);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002400 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002401}
2402
2403testcase TC_si2quater_23_earfcns() runs on test_CT {
2404 f_tc_si2quater_n_earfcns(23);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002405 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002406}
2407
2408testcase TC_si2quater_32_earfcns() runs on test_CT {
2409 f_tc_si2quater_n_earfcns(32);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002410 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002411}
2412
2413testcase TC_si2quater_33_earfcns() runs on test_CT {
2414 f_tc_si2quater_n_earfcns(33);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002415 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002416}
2417
2418testcase TC_si2quater_42_earfcns() runs on test_CT {
2419 f_tc_si2quater_n_earfcns(42);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002420 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002421}
2422
2423testcase TC_si2quater_48_earfcns() runs on test_CT {
2424 f_tc_si2quater_n_earfcns(48);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002425 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002426}
2427
2428/* verify the VTY error response when adding too many EARFCNs, and showing that osmo-bsc still sends 16 SI2quater with
2429 * 48 EARFCNs. */
2430testcase TC_si2quater_49_earfcns() runs on test_CT {
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002431 var template SystemInformationConfig sic := SystemInformationConfig_default;
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002432 sic.si2quater := f_tr_si2quater_earfcns(48); /* 48, not 49! */
2433 f_init(0);
2434
2435 for (var integer i := 1; i < 48; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002436 f_bts_0_cfg(BSCVTY, {"si2quater neighbor-list add earfcn " & int2str(f_test_si2quater_earfcn_by_idx(i))
2437 & " thresh-hi 20 thresh-lo 10 prio 3 qrxlv 22 meas 3"});
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002438 }
2439
2440 /* The 49th EARFCN no longer fits, expect VTY error */
2441 f_vty_enter_cfg_bts(BSCVTY, 0);
2442 var charstring vty_error;
2443 vty_error := f_vty_transceive_ret(BSCVTY,
2444 "si2quater neighbor-list add earfcn 70 thresh-hi 20 thresh-lo 10 prio 3 qrxlv 22 meas 3")
2445 f_vty_transceive(BSCVTY, "end");
2446
2447 if (f_strstr(vty_error, "Unable to add ARFCN 70") >= 0) {
2448 log("Got expected VTY error: ", vty_error);
2449 setverdict(pass);
2450 } else {
2451 setverdict(fail, "Expected the 49th EUTRAN ARFCN to be rejected by vty config, got: ", vty_error);
2452 }
2453
2454 f_init_bts_and_check_sysinfo(0, expect_si := sic);
2455
2456 for (var integer i := 1; i < 48; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002457 f_bts_0_cfg(BSCVTY, {"si2quater neighbor-list del earfcn " & int2str(f_test_si2quater_earfcn_by_idx(i))});
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002458 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002459 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002460}
2461
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002462private function f_acc09_count_allowed(AccessControlClass acc) return uint8_t
2463{
2464 var uint8_t count := 0;
2465 for (var integer i := 5; i < 16; i := i + 1) {
2466 if (acc[i] == '0'B) { /* the list marks barred, we count allowed */
2467 count := count + 1;
2468 }
2469 }
2470 return count;
2471}
2472
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002473private function f_recv_next_si1(integer rsl_idx := 0) runs on test_CT return SystemInformationType1
2474{
2475 var ASP_RSL_Unitdata rx_rsl_ud;
2476 var SystemInformationType1 last_si1;
2477
2478 timer T := 30.0;
2479 T.start;
2480 alt {
2481 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD((tr_RSL_NO_BCCH_INFO,
2482 tr_RSL_BCCH_INFO,
2483 tr_RSL_NO_SACCH_FILL,
2484 tr_RSL_SACCH_FILL))
2485 ) -> value rx_rsl_ud {
2486 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
2487 if (g_system_information[rsl_idx].si1 == omit) {
2488 repeat;
2489 }
2490 last_si1 := g_system_information[rsl_idx].si1;
2491 g_system_information[rsl_idx].si1 := omit;
2492 T.stop;
2493 }
Vadim Yanitskiy79ebd5e2021-01-04 00:12:55 +01002494 [] IPA_RSL[rsl_idx].receive { repeat; }
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002495 [] T.timeout { setverdict(fail, "Timeout receiving next SI1"); }
2496 }
2497 return last_si1;
2498}
2499
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002500/* verify ACC rotate feature */
2501testcase TC_si_acc_rotate() runs on test_CT {
2502 var template SystemInformationConfig sic := SystemInformationConfig_default;
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002503 var SystemInformationType1 last_si1;
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002504 var AccessControlClass acc;
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002505 var uint8_t count;
2506 var integer times_allowed[10] := { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
2507
2508 f_init(0, guard_timeout := 60.0);
2509
2510 f_bts_0_cfg(BSCVTY, {"rach access-control-class 5 barred",
2511 "access-control-class-rotate 3",
2512 "access-control-class-rotate-quantum 1"});
2513
2514 /* Init and get first sysinfo */
2515 f_init_bts_and_check_sysinfo(0, expect_si := ?);
2516
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002517 for (var integer i:= 0; i < 20; i := i + 1) {
2518 last_si1 := f_recv_next_si1(0);
2519 acc := last_si1.rach_control.acc;
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002520 count := f_acc09_count_allowed(acc);
2521 log("RSL: GOT SI1 ACC len=", count, ": ", acc);
2522
2523 if (count != 3) {
2524 log("RSL: EXPECTED SI ACC len=3");
2525 setverdict(fail, "received SI does not match expectations");
2526 break;
2527 }
2528
2529 for (var integer j := 0; j < 10; j := j + 1) {
2530 if (acc[16 - 1 - j] == '0'B) { /* the list marks barred, we count allowed */
2531 times_allowed[j] := times_allowed[j] + 1;
2532 }
2533 }
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002534 }
2535
2536 for (var integer j := 0; j < 10; j := j + 1) {
2537 log("ACC", j, " allowed ", times_allowed[j], " times" );
2538 if (j != 5 and times_allowed[j] < 3) {
2539 setverdict(fail, "ACC", j, " ERROR: allowed ", times_allowed[j], " < 1 times");
2540 } else if (j == 5 and times_allowed[j] > 0) {
2541 setverdict(fail, "ACC", j, " ERROR: allowed ", times_allowed[j], " > 0 times");
2542 }
2543 }
2544
2545 f_bts_0_cfg(BSCVTY, {"access-control-class-rotate 10",
2546 "rach access-control-class 5 allowed"});
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002547 f_shutdown_helper();
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002548}
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002549
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002550/* verify ACC startup ramp+rotate feature */
2551testcase TC_si_acc_ramp_rotate() runs on test_CT {
2552 var template SystemInformationConfig sic := SystemInformationConfig_default;
2553 var SystemInformationType1 last_si1;
2554 var AccessControlClass acc;
2555 var ASP_RSL_Unitdata rx_rsl_ud;
2556 var uint8_t count;
2557 var uint8_t prev_count;
2558 var integer times_allowed[10] := { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
2559
2560 f_init(0, guard_timeout := 80.0);
2561
2562 f_bts_0_cfg(BSCVTY, {"rach access-control-class 4 barred",
2563 "access-control-class-rotate 0",
2564 "access-control-class-rotate-quantum 1",
2565 "access-control-class-ramping",
2566 "access-control-class-ramping-step-interval 5",
2567 "access-control-class-ramping-step-size 5"});
2568
2569 /* Init and get first sysinfo */
2570 f_init_bts_and_check_sysinfo(0, expect_si := ?);
2571 last_si1 := g_system_information[0].si1;
2572 acc := last_si1.rach_control.acc;
2573 count := f_acc09_count_allowed(acc);
2574 /* Adm subset size was set to 0 above, so wait until all ACC are barred */
2575 while (count > 0) {
2576 last_si1 := f_recv_next_si1(0);
2577 acc := last_si1.rach_control.acc;
2578 count := f_acc09_count_allowed(acc);
2579 log("RSL: wait len()=0: GOT SI1 ACC len=", count, ": ", acc);
2580 }
2581
2582 /* Increase adm subset size, we should see ramping start up */
2583 f_bts_0_cfg(BSCVTY, {"access-control-class-rotate 10"});
2584 prev_count := 0;
2585 while (true) {
2586 last_si1 := f_recv_next_si1(0);
2587 acc := last_si1.rach_control.acc;
2588 count := f_acc09_count_allowed(acc);
2589 log("RSL: GOT SI1 ACC len=", count, ": ", acc);
2590
2591 if (prev_count > count) {
2592 setverdict(fail, "ACC allowed count dropped while expecting grow: ", prev_count, " -> ", count);
2593 break;
2594 }
2595
2596 if (count == 9) {
2597 break; /* Maximum reached (10 - 1 perm barred), done here */
2598 }
2599
2600 prev_count := count;
2601 }
2602
2603 setverdict(pass);
2604
2605 f_bts_0_cfg(BSCVTY, {"access-control-class-rotate 10",
2606 "rach access-control-class 4 allowed",
2607 "no access-control-class-ramping"});
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002608 f_shutdown_helper();
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002609}
2610
Harald Welte4003d112017-12-09 22:35:39 +01002611testcase TC_ctrl_msc_connection_status() runs on test_CT {
2612 var charstring ctrl_resp;
2613
Harald Welte89d42e82017-12-17 16:42:41 +01002614 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01002615
2616 /* See https://osmocom.org/issues/2729 */
2617 f_ctrl_get_exp(IPA_CTRL, "msc_connection_status", "connected");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002618 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01002619}
2620
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01002621testcase TC_ctrl_msc0_connection_status() runs on test_CT {
2622 var charstring ctrl_resp;
2623
2624 f_init(1);
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01002625
2626 f_ctrl_get_exp(IPA_CTRL, "msc.0.connection_status", "connected");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002627 f_shutdown_helper();
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01002628}
2629
Harald Welte4003d112017-12-09 22:35:39 +01002630testcase TC_ctrl() runs on test_CT {
2631 var charstring ctrl_resp;
2632
Harald Welte89d42e82017-12-17 16:42:41 +01002633 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01002634
2635 /* all below values must match the osmo-bsc.cfg config file used */
2636
Harald Welte6a129692018-03-17 17:30:14 +01002637 f_ctrl_get_exp(IPA_CTRL, "mcc", "001");
2638 f_ctrl_get_exp(IPA_CTRL, "mnc", "01");
Oliver Smith75aa0202019-08-19 14:17:50 +02002639 f_ctrl_get_exp(IPA_CTRL, "number-of-bts", "4");
Harald Welte4003d112017-12-09 22:35:39 +01002640
2641 var integer bts_nr := 0;
2642 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "location-area-code", "1");
2643 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "cell-identity", "0");
2644 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "oml-connection-state", "connected");
2645 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "gprs-mode", "gprs");
2646 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "rf_state", "operational,unlocked,on");
2647 f_ctrl_get_exp_trx(IPA_CTRL, bts_nr, 0, "arfcn", "871");
2648 f_ctrl_get_exp_trx(IPA_CTRL, bts_nr, 0, "max-power-reduction", "20");
2649
2650 var integer uptime := str2int(f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-uptime"));
2651 f_sleep(2.0);
2652 if (str2int(f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-uptime")) < uptime+1) {
2653 setverdict(fail, "oml-uptime not incrementing as expected");
2654 }
2655 /* TODO: Disconnect RSL, imply that OML is disconnected and check for uptime zero? */
2656
2657 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted", 0);
2658
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002659 f_shutdown_helper();
Harald Welte96c94412017-12-09 03:12:45 +01002660}
2661
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +02002662/* Verify that Upon receival of SET "location", BSC forwards a TRAP
2663 "location-state" over the SCCPlite IPA conn */
2664testcase TC_ctrl_location() runs on test_CT {
2665 var MSC_ConnHdlr vc_conn;
2666 var integer bts_nr := 0;
2667
2668 f_init(1, true);
2669 f_sleep(1.0);
2670
2671 f_ctrl_set_bts(IPA_CTRL, bts_nr, "location", "1234567,fix3d,0.340000,0.560000,0.780000");
2672 f_ctrl_exp_trap(SCCPLITE_IPA_CTRL, "bts." & int2str(bts_nr) & ".location-state",
2673 "1234567,fix3d,0.340000,0.560000,0.780000,operational,unlocked,on,001,01");
2674
2675 f_ctrl_set(SCCPLITE_IPA_CTRL, "rf_locked", "1");
2676 f_sleep(2.0);
2677
2678 f_ctrl_set_bts(IPA_CTRL, bts_nr, "location", "1234888,fix3d,0.350000,0.570000,0.790000");
2679 f_ctrl_exp_trap(SCCPLITE_IPA_CTRL, "bts." & int2str(bts_nr) & ".location-state",
2680 "1234888,fix3d,0.350000,0.570000,0.790000,operational,locked,off,001,01");
2681
2682 /* should match the one from config */
2683 f_ctrl_set(SCCPLITE_IPA_CTRL, "rf_locked", "0");
2684
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002685 f_shutdown_helper();
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +02002686}
2687
Harald Welte6f521d82017-12-11 19:52:02 +01002688
2689/***********************************************************************
2690 * Paging Testing
2691 ***********************************************************************/
2692
2693type record Cell_Identity {
2694 GsmMcc mcc,
2695 GsmMnc mnc,
2696 GsmLac lac,
2697 GsmCellId ci
2698};
Harald Welte24135bd2018-03-17 19:27:53 +01002699private const Cell_Identity cid := { '001'H, '01'H, 1, 0 };
Stefan Sperling049a86e2018-03-20 15:51:00 +01002700private const Cell_Identity unknown_cid := { '678'H, 'f90'H, 1, 0 };
Harald Welte6f521d82017-12-11 19:52:02 +01002701
Harald Welte5d1a2202017-12-13 19:51:29 +01002702type set of integer BtsIdList;
2703
2704private function f_bts_in_list(integer bts_id, BtsIdList bts_ids) return boolean {
2705 for (var integer j := 0; j < sizeof(bts_ids); j := j + 1) {
2706 if (bts_id == bts_ids[j]) {
2707 return true;
2708 }
2709 }
2710 return false;
2711}
Harald Welte6f521d82017-12-11 19:52:02 +01002712
2713/* core paging test helper function; used by most paging test cases */
2714private function f_pageing_helper(hexstring imsi,
2715 template BSSMAP_FIELD_CellIdentificationList cid_list,
Harald Welte5d1a2202017-12-13 19:51:29 +01002716 BtsIdList bts_ids := { 0 },
Harald Welte6f521d82017-12-11 19:52:02 +01002717 template RSL_ChanNeeded rsl_chneed := omit,
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002718 template (omit) OCT4 tmsi := omit) runs on test_CT
Harald Welte6f521d82017-12-11 19:52:02 +01002719{
2720 var template BSSMAP_IE_ChannelNeeded bssmap_chneed;
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002721 var template MobileIdentityV mi;
Harald Welte6f521d82017-12-11 19:52:02 +01002722 var RSL_Message rx_rsl;
2723 var integer paging_group := hex2int(imsi[lengthof(imsi)-1]);
Harald Welte5d1a2202017-12-13 19:51:29 +01002724 var integer i;
Harald Welte6f521d82017-12-11 19:52:02 +01002725
2726 f_init();
Harald Welte6f521d82017-12-11 19:52:02 +01002727
2728 /* Clear the queue, it might still contain stuff like BCCH FILLING */
Harald Weltec3068592018-03-17 19:55:31 +01002729 for (i := 0; i < NUM_BTS; i := i + 1) {
2730 IPA_RSL[i].clear;
Harald Welte5d1a2202017-12-13 19:51:29 +01002731 }
Harald Welte6f521d82017-12-11 19:52:02 +01002732
2733 if (isvalue(rsl_chneed)) {
2734 /* The values of 08.08 3.2.2.36 and 08.58 9.3.40 are luckily identical */
2735 bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
2736 } else {
2737 bssmap_chneed := omit;
2738 }
2739
Neels Hofmeyrf246a922020-05-13 02:27:10 +02002740 BSSAP.send(ts_BSSAP_UNITDATA_req(g_bssap[0].sccp_addr_peer, g_bssap[0].sccp_addr_own,
2741 ts_BSSMAP_Paging(imsi, cid_list, tmsi, bssmap_chneed)));
Harald Welte6f521d82017-12-11 19:52:02 +01002742
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002743 if (not istemplatekind(tmsi, "omit")) {
2744 mi := t_MI_TMSI(tmsi);
Harald Welte6f521d82017-12-11 19:52:02 +01002745 } else {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002746 mi := tr_MI_IMSI(imsi);
Harald Welte6f521d82017-12-11 19:52:02 +01002747 }
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002748
Harald Welte5d1a2202017-12-13 19:51:29 +01002749 for (i := 0; i < sizeof(bts_ids); i := i + 1) {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002750 rx_rsl := f_exp_ipa_rx(bts_ids[i], tr_RSL_PAGING_CMD(mi));
Harald Welte5d1a2202017-12-13 19:51:29 +01002751 /* check channel type, paging group */
2752 if (rx_rsl.ies[1].body.paging_group != paging_group) {
2753 setverdict(fail, "Paging for wrong paging group");
2754 }
2755 if (ispresent(rsl_chneed) and
2756 rx_rsl.ies[3].body.chan_needed.chan_needed != valueof(rsl_chneed)) {
2757 setverdict(fail, "RSL Channel Needed != BSSMAP Channel Needed");
2758 }
Harald Welte6f521d82017-12-11 19:52:02 +01002759 }
Harald Welte2fccd982018-01-31 15:48:19 +01002760 f_sleep(2.0);
Harald Welte5d1a2202017-12-13 19:51:29 +01002761 /* do a quick check on all not-included BTSs if they received paging */
2762 for (i := 0; i < NUM_BTS; i := i + 1) {
2763 timer T := 0.1;
2764 if (f_bts_in_list(i, bts_ids)) {
2765 continue;
2766 }
2767 T.start;
2768 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07002769 [] IPA_RSL[i].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(mi))) {
Harald Welte5d1a2202017-12-13 19:51:29 +01002770 setverdict(fail, "Paging on BTS ", i, " which is not part of ", bts_ids);
2771 }
2772 [] IPA_RSL[i].receive { repeat; }
2773 [] T.timeout { }
2774 }
Harald Welte6f521d82017-12-11 19:52:02 +01002775 }
2776
2777 setverdict(pass);
2778}
2779
Harald Welte5d1a2202017-12-13 19:51:29 +01002780const BtsIdList c_BtsId_all := { 0, 1, 2 };
Harald Welte751d3eb2018-01-31 15:51:06 +01002781const BtsIdList c_BtsId_none := { };
Harald Welte5d1a2202017-12-13 19:51:29 +01002782const BtsIdList c_BtsId_LAC1 := { 0, 1 };
2783const BtsIdList c_BtsId_LAC2 := { 2 };
2784
Harald Welte6f521d82017-12-11 19:52:02 +01002785/* PAGING by IMSI + TMSI */
2786testcase TC_paging_imsi_nochan() runs on test_CT {
2787 var BSSMAP_FIELD_CellIdentificationList cid_list;
2788 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Philipp Maier8c04b0a2018-02-23 13:48:48 +01002789 f_pageing_helper('001010100000001'H, cid_list, c_BtsId_all, omit, omit);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002790 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002791}
2792
2793/* PAGING by IMSI + TMSI */
2794testcase TC_paging_tmsi_nochan() runs on test_CT {
2795 var BSSMAP_FIELD_CellIdentificationList cid_list;
2796 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002797 f_pageing_helper('001010100000001'H, cid_list, c_BtsId_all, omit, 'A1B2C301'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002798 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002799}
2800
2801/* Paging with different "channel needed' values */
2802testcase TC_paging_tmsi_any() runs on test_CT {
2803 var BSSMAP_FIELD_CellIdentificationList cid_list;
2804 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002805 f_pageing_helper('001010100000002'H, cid_list, c_BtsId_all, RSL_CHANNEED_ANY, 'A1B2C302'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002806 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002807}
2808testcase TC_paging_tmsi_sdcch() runs on test_CT {
2809 var BSSMAP_FIELD_CellIdentificationList cid_list;
2810 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002811 f_pageing_helper('001010100000003'H, cid_list, c_BtsId_all, RSL_CHANNEED_SDCCH, 'A1B2C303'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002812 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002813}
2814testcase TC_paging_tmsi_tch_f() runs on test_CT {
2815 var BSSMAP_FIELD_CellIdentificationList cid_list;
2816 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002817 f_pageing_helper('001010000000004'H, cid_list, c_BtsId_all, RSL_CHANNEED_TCH_F, 'A1B2C304'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002818 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002819}
2820testcase TC_paging_tmsi_tch_hf() runs on test_CT {
2821 var BSSMAP_FIELD_CellIdentificationList cid_list;
2822 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002823 f_pageing_helper('001010000000005'H, cid_list, c_BtsId_all, RSL_CHANNEED_TCH_ForH, 'A1B2C305'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002824 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002825}
2826
2827/* Paging by CGI */
2828testcase TC_paging_imsi_nochan_cgi() runs on test_CT {
2829 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2830 cid_list := { cIl_CGI := { ts_BSSMAP_CI_CGI(cid.mcc, cid.mnc, cid.lac, cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002831 f_pageing_helper('001010000000006'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01002832 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002833}
2834
2835/* Paging by LAC+CI */
2836testcase TC_paging_imsi_nochan_lac_ci() runs on test_CT {
2837 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2838 cid_list := { cIl_LAC_CI := { ts_BSSMAP_CI_LAC_CI(cid.lac, cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002839 f_pageing_helper('001010000000007'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01002840 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002841}
2842
2843/* Paging by CI */
2844testcase TC_paging_imsi_nochan_ci() runs on test_CT {
2845 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2846 cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002847 f_pageing_helper('001010000000008'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01002848 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002849}
2850
2851/* Paging by LAI */
2852testcase TC_paging_imsi_nochan_lai() runs on test_CT {
2853 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2854 cid_list := { cIl_LAI := { ts_BSSMAP_CI_LAI(cid.mcc, cid.mnc, cid.lac) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002855 f_pageing_helper('001010000000009'H, cid_list, c_BtsId_LAC1);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002856 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002857}
2858
2859/* Paging by LAC */
2860testcase TC_paging_imsi_nochan_lac() runs on test_CT {
2861 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2862 cid_list := { cIl_LAC := { ts_BSSMAP_CI_LAC(cid.lac) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002863 f_pageing_helper('001010000000010'H, cid_list, c_BtsId_LAC1);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002864 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002865}
2866
2867/* Paging by "all in BSS" */
2868testcase TC_paging_imsi_nochan_all() runs on test_CT {
2869 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2870 cid_list := { cIl_allInBSS := ''O };
Harald Welte5d1a2202017-12-13 19:51:29 +01002871 f_pageing_helper('001010000000011'H, cid_list, c_BtsId_all);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002872 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002873}
2874
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002875/* Paging by PLMN+LAC+RNC; We do not implement this; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01002876testcase TC_paging_imsi_nochan_plmn_lac_rnc() runs on test_CT {
2877 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2878 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 +01002879 f_pageing_helper('001010000000012'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002880 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002881}
Harald Welte6f521d82017-12-11 19:52:02 +01002882
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002883/* Paging by RNC; We do not implement this; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01002884testcase TC_paging_imsi_nochan_rnc() runs on test_CT {
2885 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2886 cid_list := { cIl_RNC := { int2oct(13, 2) } };
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002887 f_pageing_helper('001010000000013'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002888 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002889}
2890
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002891/* Paging by LAC+RNC; We do not implement; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01002892testcase TC_paging_imsi_nochan_lac_rnc() runs on test_CT {
2893 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2894 cid_list := { cIl_LAC_RNC := { ts_BSSMAP_CI_LAC_RNC(cid.lac, 14) } };
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002895 f_pageing_helper('001010000000014'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002896 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002897}
2898
Harald Welte6f521d82017-12-11 19:52:02 +01002899/* Paging on multiple cells (multiple entries in list): Verify all of them page */
Harald Welte751d3eb2018-01-31 15:51:06 +01002900testcase TC_paging_imsi_nochan_lacs() runs on test_CT {
2901 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2902 cid_list := { cIl_LAC := { ts_BSSMAP_CI_LAC(1), ts_BSSMAP_CI_LAC(2) } };
2903 f_pageing_helper('001010000000015'H, cid_list, c_BtsId_all);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002904 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002905}
2906
2907/* Paging on empty list: Verify none of them page */
2908testcase TC_paging_imsi_nochan_lacs_empty() runs on test_CT {
2909 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2910 cid_list := { cIl_LAC := { } };
2911 f_pageing_helper('001010000000016'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002912 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002913}
2914
Stefan Sperling049a86e2018-03-20 15:51:00 +01002915/* Paging by CGI with unknown MCC/MNC: Verify nothing is paged. */
2916testcase TC_paging_imsi_nochan_cgi_unknown_cid() runs on test_CT {
2917 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2918 cid_list := { cIl_CGI := { ts_BSSMAP_CI_CGI(unknown_cid.mcc, unknown_cid.mnc, unknown_cid.lac, unknown_cid.ci) } };
2919 f_pageing_helper('001010000000006'H, cid_list, c_BtsId_none);
2920 f_shutdown_helper();
2921}
2922
Harald Welte6f521d82017-12-11 19:52:02 +01002923/* Verify paging retransmission interval + count */
2924/* Verify paging stops after channel establishment */
Harald Welte6f521d82017-12-11 19:52:02 +01002925/* Test behavior under paging overload */
Harald Welteae026692017-12-09 01:03:01 +01002926
Harald Weltee65d40e2017-12-13 00:09:06 +01002927/* Verify PCH load */
2928testcase TC_paging_imsi_load() runs on test_CT {
2929 var BSSMAP_FIELD_CellIdentificationList cid_list;
2930 timer T := 4.0;
Harald Welte2caa1062018-03-17 18:19:05 +01002931 timer T_retrans := 1.0;
Harald Weltee65d40e2017-12-13 00:09:06 +01002932 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002933 f_pageing_helper('001010123456789'H, cid_list, c_BtsId_all);
Harald Weltee65d40e2017-12-13 00:09:06 +01002934
2935 /* tell BSC there is no paging space anymore */
2936 f_ipa_tx(0, ts_RSL_PAGING_LOAD_IND(0));
Harald Welte3b57ab52018-03-17 18:01:10 +01002937 f_sleep(0.2);
2938 IPA_RSL[0].clear;
Harald Weltee65d40e2017-12-13 00:09:06 +01002939
2940 /* Wait for 4 seconds if any more PAGING CMD are received on RSL. Normally,
2941 * there would be 8 retransmissions during 4 seconds */
2942 T.start;
Harald Welte2caa1062018-03-17 18:19:05 +01002943 T_retrans.start;
Harald Weltee65d40e2017-12-13 00:09:06 +01002944 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07002945 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Weltee65d40e2017-12-13 00:09:06 +01002946 setverdict(fail, "Received PAGING after LOAD_IND(0)");
Daniel Willmannafce8662018-07-06 23:11:32 +02002947 mtc.stop;
Harald Weltee65d40e2017-12-13 00:09:06 +01002948 }
Harald Welte2caa1062018-03-17 18:19:05 +01002949 [] T_retrans.timeout {
2950 /* re-trnsmit the zero-space LOAD IND to avoid BSC 'auto credit' */
2951 f_ipa_tx(0, ts_RSL_PAGING_LOAD_IND(0));
2952 T_retrans.start;
2953 repeat;
2954 }
Harald Weltee65d40e2017-12-13 00:09:06 +01002955 [] T.timeout {
2956 setverdict(pass);
2957 }
2958 }
Philipp Maier282ca4b2018-02-27 17:17:00 +01002959
2960 f_shutdown_helper();
Harald Weltee65d40e2017-12-13 00:09:06 +01002961}
2962
Harald Welte235ebf12017-12-15 14:18:16 +01002963/* Verify Paging Counter */
Harald Welte1ff69992017-12-14 12:31:17 +01002964testcase TC_paging_counter() runs on test_CT {
2965 var BSSMAP_FIELD_CellIdentificationList cid_list;
2966 timer T := 4.0;
2967 var integer i;
2968 var integer paging_attempted_bsc;
2969 var integer paging_attempted_bts[NUM_BTS];
2970 var integer paging_expired_bts[NUM_BTS];
2971 cid_list := valueof(ts_BSSMAP_CIL_noCell);
2972
2973 f_init();
2974
2975 /* read counters before paging */
2976 paging_attempted_bsc := f_ctrl_get_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted");
2977 for (i := 0; i < NUM_BTS; i := i+1) {
2978 paging_attempted_bts[i] := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", i, "paging:attempted");
2979 paging_expired_bts[i] := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", i, "paging:expired");
2980 }
2981
2982 f_pageing_helper('001230000000001'H, cid_list, c_BtsId_all);
2983
2984 /* expect the attempted pages on BSC and each BTSs to have incremented by one */
2985 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted", paging_attempted_bsc+1);
2986 for (i := 0; i < NUM_BTS; i := i+1) {
2987 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", i, "paging:attempted",
2988 paging_attempted_bts[i]+1);
2989 }
2990
2991 /* assume that 12s later the paging on all BTSs have expired and hence incremented by 1 */
2992 f_sleep(12.0);
2993 for (i := 0; i < NUM_BTS; i := i+1) {
2994 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", i, "paging:expired",
2995 paging_expired_bts[i]+1);
2996 }
Harald Welte1ff69992017-12-14 12:31:17 +01002997
Philipp Maier282ca4b2018-02-27 17:17:00 +01002998 f_shutdown_helper();
Harald Welte1ff69992017-12-14 12:31:17 +01002999}
3000
3001
Harald Welte10985002017-12-12 09:29:15 +01003002/* Verify paging stops after A-RESET */
3003testcase TC_paging_imsi_a_reset() runs on test_CT {
3004 var BSSMAP_FIELD_CellIdentificationList cid_list;
3005 timer T := 3.0;
3006 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01003007 f_pageing_helper('001010123456789'H, cid_list, c_BtsId_all);
Harald Welte10985002017-12-12 09:29:15 +01003008
3009 /* Perform a BSSMAP Reset and wait for ACK */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003010 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 +01003011 alt {
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003012 [] 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 +01003013 [] BSSAP.receive { repeat; }
3014 }
3015
Daniel Willmanncbef3982018-07-30 09:22:40 +02003016 /* Wait to avoid a possible race condition if a paging message is
3017 * received right before the reset ACK. */
3018 f_sleep(0.2);
3019
Harald Welte10985002017-12-12 09:29:15 +01003020 /* Clear the queue, it might still contain stuff like BCCH FILLING */
Philipp Maier1e6b4422018-02-23 14:02:13 +01003021 for (var integer i := 0; i < sizeof(IPA_RSL); i := i+1) {
3022 IPA_RSL[i].clear;
3023 }
Harald Welte10985002017-12-12 09:29:15 +01003024
3025 /* Wait for 3 seconds if any more PAGING CMD are received on RSL */
3026 T.start;
3027 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07003028 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Welte10985002017-12-12 09:29:15 +01003029 setverdict(fail, "Received PAGING after A-RESET");
Daniel Willmannafce8662018-07-06 23:11:32 +02003030 mtc.stop;
Harald Welte10985002017-12-12 09:29:15 +01003031 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07003032 [] IPA_RSL[1].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Welte5d1a2202017-12-13 19:51:29 +01003033 setverdict(fail, "Received PAGING after A-RESET");
Daniel Willmannafce8662018-07-06 23:11:32 +02003034 mtc.stop;
Harald Welte5d1a2202017-12-13 19:51:29 +01003035 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07003036 [] IPA_RSL[2].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Welte5d1a2202017-12-13 19:51:29 +01003037 setverdict(fail, "Received PAGING after A-RESET");
Daniel Willmannafce8662018-07-06 23:11:32 +02003038 mtc.stop;
Harald Welte5d1a2202017-12-13 19:51:29 +01003039 }
Harald Welte10985002017-12-12 09:29:15 +01003040 [] T.timeout {
3041 setverdict(pass);
3042 }
3043 }
Philipp Maier282ca4b2018-02-27 17:17:00 +01003044
3045 f_shutdown_helper();
Harald Welte10985002017-12-12 09:29:15 +01003046}
Harald Welteae026692017-12-09 01:03:01 +01003047
Philipp Maierf45824a2019-08-14 14:44:10 +02003048/* Verify how we handle unsolicited Paging Response. In case of an unsolicit
3049 * paging response we can not know which MSC is in charge, so we will blindly
3050 * pick the first configured MSC. This behavior is required in order to make
3051 * MT-CSFB calls working because in those cases the BSC can not know that the
3052 * MSC has already paged the subscriver via SGs. So any MT-CSFB call will look
3053 * like an unsolicited Paging Response to the MSC.
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003054 */
3055testcase TC_paging_resp_unsol() runs on test_CT {
3056
3057 f_init(1);
Philipp Maierf45824a2019-08-14 14:44:10 +02003058 timer T := 5.0;
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003059
3060 var BSSAP_N_CONNECT_ind rx_c_ind;
3061 var DchanTuple dt;
3062 var PDU_ML3_MS_NW l3 := valueof(ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010008880018'H))));
Philipp Maierf45824a2019-08-14 14:44:10 +02003063 var octetstring rr_pag_resp := enc_PDU_ML3_MS_NW(l3);
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003064
3065 /* Send CHAN RQD and wait for allocation; acknowledge it */
3066 dt.rsl_chan_nr := f_chreq_act_ack();
3067
3068 /* Send unsolicited Paging response (no matching Paging CMD stored in BSC) */
3069 f_ipa_tx(0, ts_RSL_EST_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)), enc_PDU_ML3_MS_NW(l3)));
3070
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003071
Philipp Maierf45824a2019-08-14 14:44:10 +02003072 /* Expevct a CR with a matching Paging response on the A-Interface */
3073 T.start;
3074 alt {
3075 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(rr_pag_resp))) {
3076 setverdict(pass);
3077 }
3078 [] BSSAP.receive {
3079 setverdict(fail, "Received unexpected message on A-Interface!");
3080 }
3081 [] T.timeout {
3082 setverdict(fail, "Received nothing on A-Interface!");
3083 }
3084 }
3085
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003086 f_shutdown_helper();
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003087}
3088
Harald Welte4e9b9cc2017-12-14 18:31:02 +01003089/* Test RSL link drop causes counter increment */
3090testcase TC_rsl_drop_counter() runs on test_CT {
3091 var integer rsl_fail;
3092
Harald Welte89d42e82017-12-17 16:42:41 +01003093 f_init(1);
Harald Welte4e9b9cc2017-12-14 18:31:02 +01003094
3095 rsl_fail := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "rsl_fail");
3096
3097 bts[0].rsl.vc_IPA.stop;
3098
3099 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "rsl_fail", rsl_fail+1);
3100
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003101 f_shutdown_helper();
Harald Welte4e9b9cc2017-12-14 18:31:02 +01003102}
3103
3104/* TODO: Test OML link drop causes counter increment */
3105
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003106/* The body of TC_rsl_unknown_unit_id() and TC_oml_unknown_unit_id() tests. */
3107function f_ipa_unknown_unit_id(integer mp_bsc_ipa_port) runs on test_CT return boolean {
3108 timer T := 10.0;
3109
3110 bts[0].rsl.id := "IPA-0-RSL";
3111 bts[0].rsl.vc_IPA := IPA_Emulation_CT.create(bts[0].rsl.id & "-IPA");
3112 bts[0].rsl.ccm_pars := c_IPA_default_ccm_pars;
3113 bts[0].rsl.ccm_pars.name := "Osmocom TTCN-3 BTS Simulator";
Oliver Smith92c2bdb2019-08-20 15:11:24 +02003114 bts[0].rsl.ccm_pars.unit_id := "99/0/0"; /* value which is unknown at BTS */
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003115
Pau Espin Pedrol9a5b8ff2021-01-04 19:01:31 +01003116 f_ipa_ctrl_start_client(mp_bsc_ip, mp_bsc_ctrl_port);
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003117
3118 f_init_mgcp("VirtMSC");
3119
3120 /* start RSL/OML connection (XXX re-uses RSL port/protocol definitions for OML) */
3121 map(bts[0].rsl.vc_IPA:IPA_PORT, system:IPA);
3122 connect(bts[0].rsl.vc_IPA:IPA_RSL_PORT, self:IPA_RSL[0]);
3123 bts[0].rsl.vc_IPA.start(IPA_Emulation.main_client(mp_bsc_ip, mp_bsc_ipa_port, "", 10000, bts[0].rsl.ccm_pars));
3124
3125 /* wait for IPA OML link to connect and then disconnect */
3126 T.start;
3127 alt {
Vadim Yanitskiya2afacc2020-05-18 21:16:19 +07003128 [] IPA_RSL[0].receive(tr_ASP_IPA_EV(ASP_IPA_EVENT_DOWN)) {
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003129 T.stop;
3130 return true;
3131 }
3132 [] IPA_RSL[0].receive { repeat }
3133 [] T.timeout {
Daniel Willmannafce8662018-07-06 23:11:32 +02003134 return false;
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003135 }
3136 }
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003137 return false;
3138}
3139
3140/* BSC should close an RSL connection from a BTS with unknown unit ID (OS#2714). */
3141testcase TC_rsl_unknown_unit_id() runs on test_CT {
3142 if (f_ipa_unknown_unit_id(mp_bsc_rsl_port)) {
3143 setverdict(pass);
3144 } else {
3145 setverdict(fail, "Timeout RSL waiting for connection to close");
3146 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003147 f_shutdown_helper();
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003148}
3149
3150
3151/* BSC should close an RSL connection from a BTS with unknown unit ID (OS#2714). */
3152testcase TC_oml_unknown_unit_id() runs on test_CT {
3153 if (f_ipa_unknown_unit_id(mp_bsc_oml_port)) {
3154 setverdict(pass);
3155 } else {
3156 setverdict(fail, "Timeout OML waiting for connection to close");
3157 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003158 f_shutdown_helper();
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003159}
3160
3161
Harald Weltec1a2fff2017-12-17 11:06:19 +01003162/***********************************************************************
Harald Welte6811d102019-04-14 22:23:14 +02003163 * "New world" test cases using RSL_Emulation + RAN_Emulation
Harald Weltec1a2fff2017-12-17 11:06:19 +01003164 ***********************************************************************/
3165
Harald Welte6811d102019-04-14 22:23:14 +02003166import from RAN_Emulation all;
Harald Welte47cd0e32020-08-21 12:39:11 +02003167import from BSSAP_LE_Emulation all;
Harald Weltec1a2fff2017-12-17 11:06:19 +01003168import from RSL_Emulation all;
3169import from MSC_ConnectionHandler all;
3170
3171type function void_fn(charstring id) runs on MSC_ConnHdlr;
3172
Harald Welte336820c2018-05-31 20:34:52 +02003173/* helper function to create and connect a MSC_ConnHdlr component */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003174private function f_connect_handler(inout MSC_ConnHdlr vc_conn, integer bssap_idx := 0) runs on test_CT {
3175 connect(vc_conn:RAN, g_bssap[bssap_idx].vc_RAN:PROC);
Daniel Willmann191e0d92018-01-17 12:44:35 +01003176 connect(vc_conn:MGCP_PROC, vc_MGCP:MGCP_PROC);
Harald Weltec1a2fff2017-12-17 11:06:19 +01003177 connect(vc_conn:RSL, bts[0].rsl.vc_RSL:CLIENT_PT);
Harald Weltef70df652018-01-29 22:00:23 +01003178 connect(vc_conn:RSL_PROC, bts[0].rsl.vc_RSL:RSL_PROC);
Philipp Maier88f4ae82018-03-01 14:00:58 +01003179 if (isvalue(bts[1])) {
Philipp Maier956a92f2018-02-16 10:58:07 +01003180 connect(vc_conn:RSL1, bts[1].rsl.vc_RSL:CLIENT_PT);
3181 connect(vc_conn:RSL1_PROC, bts[1].rsl.vc_RSL:RSL_PROC);
3182 }
Neels Hofmeyr91401012019-07-11 00:42:35 +02003183 if (isvalue(bts[2])) {
3184 connect(vc_conn:RSL2, bts[2].rsl.vc_RSL:CLIENT_PT);
3185 connect(vc_conn:RSL2_PROC, bts[2].rsl.vc_RSL:RSL_PROC);
3186 }
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003187 connect(vc_conn:BSSAP, g_bssap[bssap_idx].vc_RAN:CLIENT);
Neels Hofmeyrcfe44062020-10-15 02:28:08 +02003188 if (mp_enable_lcs_tests) {
3189 connect(vc_conn:BSSAP_LE, g_bssap_le.vc_BSSAP_LE:CLIENT);
3190 connect(vc_conn:BSSAP_LE_PROC, g_bssap_le.vc_BSSAP_LE:PROC);
3191 }
Daniel Willmann191e0d92018-01-17 12:44:35 +01003192 connect(vc_conn:MGCP, vc_MGCP:MGCP_CLIENT);
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02003193 connect(vc_conn:MGCP_MULTI, vc_MGCP:MGCP_CLIENT_MULTI);
Daniel Willmannebdecc02020-08-12 15:30:17 +02003194 connect(vc_conn:STATSD_PROC, vc_STATSD:STATSD_PROC);
Harald Welte336820c2018-05-31 20:34:52 +02003195}
3196
3197function f_start_handler(void_fn fn, template (omit) TestHdlrParams pars := omit)
3198runs on test_CT return MSC_ConnHdlr {
3199 var charstring id := testcasename();
3200 var MSC_ConnHdlr vc_conn;
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003201 var integer bssap_idx := 0;
3202 if (isvalue(pars)) {
3203 bssap_idx := valueof(pars).mscpool.bssap_idx;
3204 }
Harald Welte336820c2018-05-31 20:34:52 +02003205 vc_conn := MSC_ConnHdlr.create(id);
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003206 f_connect_handler(vc_conn, bssap_idx);
Neels Hofmeyr1708d1b2020-10-10 16:56:48 +02003207 /* Emit a marker to appear in the SUT's own logging output */
3208 f_logp(BSCVTY, testcasename() & "() start");
Harald Weltea0630032018-03-20 21:09:55 +01003209 vc_conn.start(f_handler_init(fn, id, pars));
Harald Weltec1a2fff2017-12-17 11:06:19 +01003210 return vc_conn;
3211}
3212
Harald Weltea0630032018-03-20 21:09:55 +01003213/* first function inside ConnHdlr component; sets g_pars + starts function */
3214private function f_handler_init(void_fn fn, charstring id, template (omit) TestHdlrParams pars := omit)
3215runs on MSC_ConnHdlr {
3216 if (isvalue(pars)) {
3217 g_pars := valueof(pars);
3218 }
3219 fn.apply(id);
3220}
3221
Harald Welte3c86ea02018-05-10 22:28:05 +02003222/* Establish signalling channel (non-assignment case) followed by cipher mode */
3223private function f_tc_ciph_mode_a5(charstring id) runs on MSC_ConnHdlr {
Harald Welteed848512018-05-24 22:27:58 +02003224 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3225 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte3c86ea02018-05-10 22:28:05 +02003226 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeSIGNAL);
Philipp Maier23000732018-05-18 11:25:37 +02003227 ass_cmd.pdu.bssmap.assignmentRequest.circuitIdentityCode := omit;
3228 ass_cmd.pdu.bssmap.assignmentRequest.aoIPTransportLayer := omit;
3229 exp_compl.pdu.bssmap.assignmentComplete.circuitIdentityCode := omit;
3230 exp_compl.pdu.bssmap.assignmentComplete.aoIPTransportLayer := omit;
Harald Welte3c86ea02018-05-10 22:28:05 +02003231
Philipp Maier23000732018-05-18 11:25:37 +02003232 f_establish_fully(ass_cmd, exp_compl);
Harald Welte3c86ea02018-05-10 22:28:05 +02003233}
3234testcase TC_ciph_mode_a5_0() runs on test_CT {
3235 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003236 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02003237 pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
3238
3239 f_init(1, true);
3240 f_sleep(1.0);
3241 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
3242 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003243 f_shutdown_helper();
Harald Welte3c86ea02018-05-10 22:28:05 +02003244}
3245testcase TC_ciph_mode_a5_1() runs on test_CT {
3246 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003247 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02003248 pars.encr := valueof(t_EncrParams('02'O, f_rnd_octstring(8)));
3249
3250 f_init(1, true);
3251 f_sleep(1.0);
3252 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
3253 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003254 f_shutdown_helper();
Harald Welte3c86ea02018-05-10 22:28:05 +02003255}
3256testcase TC_ciph_mode_a5_3() runs on test_CT {
3257 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003258 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02003259 pars.encr := valueof(t_EncrParams('08'O, f_rnd_octstring(8)));
3260
3261 f_init(1, true);
3262 f_sleep(1.0);
3263 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
3264 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003265 f_shutdown_helper();
Harald Welte3c86ea02018-05-10 22:28:05 +02003266}
3267
Pau Espin Pedrol07866632020-09-03 19:10:55 +02003268/* establish initial channel, enable ciphering followed by assignment to ciphered channel */
3269private function f_tc_assignment_aoip_tla_v6(charstring id) runs on MSC_ConnHdlr {
3270 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3271 var PDU_BSSAP ass_cmd := f_gen_ass_req(aoip_tla := "::3");
3272 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3273 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
3274
3275 f_establish_fully(ass_cmd, exp_compl);
3276}
3277testcase TC_assignment_aoip_tla_v6() runs on test_CT {
3278 var MSC_ConnHdlr vc_conn;
3279 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3280
3281 f_init(1, true);
3282 f_sleep(1.0);
3283 vc_conn := f_start_handler(refers(f_tc_assignment_aoip_tla_v6), pars);
3284 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003285 f_shutdown_helper();
Pau Espin Pedrol07866632020-09-03 19:10:55 +02003286}
3287
Harald Welte3c86ea02018-05-10 22:28:05 +02003288
3289/* establish initial channel, enable ciphering followed by assignment to ciphered channel */
Harald Welte651fcdc2018-05-10 20:23:16 +02003290private function f_tc_assignment_fr_a5(charstring id) runs on MSC_ConnHdlr {
Harald Welteed848512018-05-24 22:27:58 +02003291 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3292 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Weltec1a2fff2017-12-17 11:06:19 +01003293
Harald Welte552620d2017-12-16 23:21:36 +01003294 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3295 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Welte73cd2712017-12-17 00:44:52 +01003296
Harald Weltea0630032018-03-20 21:09:55 +01003297 f_establish_fully(ass_cmd, exp_compl);
Harald Welte552620d2017-12-16 23:21:36 +01003298}
Harald Welte552620d2017-12-16 23:21:36 +01003299testcase TC_assignment_fr_a5_0() runs on test_CT {
3300 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003301 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02003302 pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
Harald Welte552620d2017-12-16 23:21:36 +01003303
Harald Welte89d42e82017-12-17 16:42:41 +01003304 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01003305 f_sleep(1.0);
Harald Welte651fcdc2018-05-10 20:23:16 +02003306 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
Harald Welte552620d2017-12-16 23:21:36 +01003307 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003308 f_shutdown_helper();
Harald Welte552620d2017-12-16 23:21:36 +01003309}
Harald Welte552620d2017-12-16 23:21:36 +01003310testcase TC_assignment_fr_a5_1() runs on test_CT {
Harald Weltec1a2fff2017-12-17 11:06:19 +01003311 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003312 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02003313 pars.encr := valueof(t_EncrParams('02'O, f_rnd_octstring(8)));
Harald Weltec1a2fff2017-12-17 11:06:19 +01003314
Harald Welte89d42e82017-12-17 16:42:41 +01003315 f_init(1, true);
Harald Weltec1a2fff2017-12-17 11:06:19 +01003316 f_sleep(1.0);
Harald Welte651fcdc2018-05-10 20:23:16 +02003317 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
3318 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003319 f_shutdown_helper();
Harald Welte651fcdc2018-05-10 20:23:16 +02003320}
3321testcase TC_assignment_fr_a5_3() runs on test_CT {
3322 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003323 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02003324 pars.encr := valueof(t_EncrParams('08'O, f_rnd_octstring(8)));
Harald Weltec1a2fff2017-12-17 11:06:19 +01003325
Harald Welte651fcdc2018-05-10 20:23:16 +02003326 f_init(1, true);
3327 f_sleep(1.0);
3328 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
Harald Weltec1a2fff2017-12-17 11:06:19 +01003329 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003330 f_shutdown_helper();
Harald Weltec1a2fff2017-12-17 11:06:19 +01003331}
3332
Harald Welte552620d2017-12-16 23:21:36 +01003333/* Expect ASSIGNMENT FAIL if mandatory IE is missing */
3334private function f_tc_assignment_fr_a5_1_codec_missing(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02003335 g_pars := f_gen_test_hdlr_pars();
Harald Welte552620d2017-12-16 23:21:36 +01003336 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +02003337 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte552620d2017-12-16 23:21:36 +01003338 const OCT8 kc := '0001020304050607'O;
3339
3340 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02003341 /* Omit: ass_cmd.pdu.bssmap.assignmentRequest.codecList */
3342
Harald Weltea0630032018-03-20 21:09:55 +01003343 f_establish_fully(ass_cmd, exp_fail);
Harald Welte552620d2017-12-16 23:21:36 +01003344}
Harald Welte552620d2017-12-16 23:21:36 +01003345testcase TC_assignment_fr_a5_1_codec_missing() runs on test_CT {
3346 var MSC_ConnHdlr vc_conn;
3347
Harald Welte89d42e82017-12-17 16:42:41 +01003348 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01003349 f_sleep(1.0);
3350
Harald Welte8863fa12018-05-10 20:15:27 +02003351 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5_1_codec_missing));
Harald Welte552620d2017-12-16 23:21:36 +01003352 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003353 f_shutdown_helper();
Harald Welte552620d2017-12-16 23:21:36 +01003354}
3355
Harald Welte552620d2017-12-16 23:21:36 +01003356private function f_tc_assignment_fr_a5_4(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02003357 g_pars := f_gen_test_hdlr_pars();
Harald Welteed848512018-05-24 22:27:58 +02003358 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3359 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte552620d2017-12-16 23:21:36 +01003360 const OCT8 kc := '0001020304050607'O;
3361 const OCT16 kc128 := kc & kc;
3362
3363 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3364 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Weltea0630032018-03-20 21:09:55 +01003365 f_establish_fully(ass_cmd, exp_compl);
Harald Welte38b2a102017-12-23 02:42:58 +01003366 f_cipher_mode('10'O, kc, kc128, true);
Harald Welte552620d2017-12-16 23:21:36 +01003367 /* TODO: expect GSM0808_CAUSE_CIPHERING_ALGORITHM_NOT_SUPPORTED cause value */
Harald Welte552620d2017-12-16 23:21:36 +01003368}
Harald Welte552620d2017-12-16 23:21:36 +01003369testcase TC_assignment_fr_a5_4() runs on test_CT {
3370 var MSC_ConnHdlr vc_conn;
3371
Harald Welte89d42e82017-12-17 16:42:41 +01003372 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01003373 f_sleep(1.0);
3374
Harald Welte8863fa12018-05-10 20:15:27 +02003375 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5_4));
Harald Welte552620d2017-12-16 23:21:36 +01003376 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003377 f_shutdown_helper();
Harald Welte552620d2017-12-16 23:21:36 +01003378}
3379
3380
Harald Welte4532e0a2017-12-23 02:05:44 +01003381private function f_tc_assignment_sign(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02003382 g_pars := f_gen_test_hdlr_pars();
Harald Welte4532e0a2017-12-23 02:05:44 +01003383 var template PDU_BSSAP exp_compl := tr_BSSMAP_AssignmentComplete(omit, omit);
Philipp Maier48604732018-10-09 15:00:37 +02003384 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte4532e0a2017-12-23 02:05:44 +01003385 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeSIGNAL);
Daniel Willmannebdecc02020-08-12 15:30:17 +02003386
3387 f_statsd_reset();
Harald Weltea0630032018-03-20 21:09:55 +01003388 f_establish_fully(ass_cmd, exp_compl);
Daniel Willmannebdecc02020-08-12 15:30:17 +02003389
3390 var StatsDExpects expect := {
Daniel Willmannc5398f72020-09-21 10:41:35 +02003391 { name := "TTCN3.bts.0.chreq.total", mtype := "c", min := 1, max := 1},
3392 { name := "TTCN3.bts.0.chreq.successful", mtype := "c", min := 1, max := 1},
Daniel Willmannebdecc02020-08-12 15:30:17 +02003393 { name := "TTCN3.bsc.0.assignment.attempted", mtype := "c", min := 1, max := 1},
3394 { name := "TTCN3.bsc.0.assignment.completed", mtype := "c", min := 1, max := 1}
3395 };
3396 f_statsd_expect(expect);
Harald Welte4532e0a2017-12-23 02:05:44 +01003397}
3398
3399testcase TC_assignment_sign() runs on test_CT {
3400 var MSC_ConnHdlr vc_conn;
3401
3402 f_init(1, true);
3403 f_sleep(1.0);
3404
Harald Welte8863fa12018-05-10 20:15:27 +02003405 vc_conn := f_start_handler(refers(f_tc_assignment_sign));
Harald Welte4532e0a2017-12-23 02:05:44 +01003406 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003407 f_shutdown_helper();
Harald Welte4532e0a2017-12-23 02:05:44 +01003408}
3409
Harald Welte60aa5762018-03-21 19:33:13 +01003410/***********************************************************************
3411 * Codec (list) testing
3412 ***********************************************************************/
3413
3414/* check if the given rsl_mode is compatible with the a_elem */
3415private function f_match_codec(BSSMAP_FIELD_CodecElement a_elem, RSL_IE_ChannelMode rsl_mode)
3416return boolean {
3417 select (a_elem.codecType) {
3418 case (GSM_FR) {
3419 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM1))) {
3420 return true;
3421 }
3422 }
3423 case (GSM_HR) {
3424 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1))) {
3425 return true;
3426 }
3427 }
3428 case (GSM_EFR) {
3429 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM2))) {
3430 return true;
3431 }
3432 }
3433 case (FR_AMR) {
3434 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM3))) {
3435 return true;
3436 }
3437 }
3438 case (HR_AMR) {
3439 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM3))) {
3440 return true;
3441 }
3442 }
3443 case else { }
3444 }
3445 return false;
3446}
3447
3448/* check if the given rsl_mode is compatible with the a_list */
3449private function f_match_codecs(BSSMAP_IE_SpeechCodecList a_list, RSL_IE_ChannelMode rsl_mode)
3450return boolean {
3451 for (var integer i := 0; i < sizeof(a_list); i := i+1) {
3452 if (f_match_codec(a_list.codecElements[i], rsl_mode)) {
3453 return true;
3454 }
3455 }
3456 return false;
3457}
3458
3459/* determine BSSMAP_IE_ChannelType from *first* element of BSSMAP_FIELD_CodecElement */
Philipp Maier61f6b572018-07-06 14:03:38 +02003460function f_BSSMAP_chtype_from_codec(BSSMAP_FIELD_CodecElement a_elem)
Harald Welte60aa5762018-03-21 19:33:13 +01003461return BSSMAP_IE_ChannelType {
3462 /* FIXME: actually look at all elements of BSSMAP_IE_SpeechCodecList */
3463 var BSSMAP_IE_ChannelType ret := valueof(ts_BSSMAP_IE_ChannelType);
3464 select (a_elem.codecType) {
3465 case (GSM_FR) {
3466 ret.channelRateAndType := ChRate_TCHF;
3467 ret.speechId_DataIndicator := Spdi_TCHF_FR;
3468 }
3469 case (GSM_HR) {
3470 ret.channelRateAndType := ChRate_TCHH;
3471 ret.speechId_DataIndicator := Spdi_TCHH_HR;
3472 }
3473 case (GSM_EFR) {
3474 ret.channelRateAndType := ChRate_TCHF;
3475 ret.speechId_DataIndicator := Spdi_TCHF_EFR;
3476 }
3477 case (FR_AMR) {
3478 ret.channelRateAndType := ChRate_TCHF;
3479 ret.speechId_DataIndicator := Spdi_TCHF_AMR;
3480 }
3481 case (HR_AMR) {
3482 ret.channelRateAndType := ChRate_TCHH;
3483 ret.speechId_DataIndicator := Spdi_TCHH_AMR;
3484 }
3485 case else {
3486 setverdict(fail, "Unsupported codec ", a_elem);
Daniel Willmannafce8662018-07-06 23:11:32 +02003487 mtc.stop;
Harald Welte60aa5762018-03-21 19:33:13 +01003488 }
3489 }
3490 return ret;
3491}
3492
Harald Weltea63b9102018-03-22 20:36:16 +01003493private function f_rsl_chmod_tmpl_from_codec(BSSMAP_FIELD_CodecElement a_elem)
3494return template RSL_IE_Body {
3495 var template RSL_IE_Body mode_ie := {
3496 chan_mode := {
3497 len := ?,
3498 reserved := ?,
3499 dtx_d := ?,
3500 dtx_u := ?,
3501 spd_ind := RSL_SPDI_SPEECH,
3502 ch_rate_type := -,
3503 coding_alg_rate := -
3504 }
3505 }
3506
3507 select (a_elem.codecType) {
3508 case (GSM_FR) {
3509 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
3510 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM1;
3511 }
3512 case (GSM_HR) {
3513 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_H;
3514 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM1;
3515 }
3516 case (GSM_EFR) {
3517 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
3518 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM2;
3519 }
3520 case (FR_AMR) {
3521 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
3522 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM3;
3523 }
3524 case (HR_AMR) {
3525 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_H;
3526 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM3;
3527 }
3528 }
3529 return mode_ie;
3530}
3531
Harald Welte60aa5762018-03-21 19:33:13 +01003532type record CodecListTest {
3533 BSSMAP_IE_SpeechCodecList codec_list,
3534 charstring id
3535}
3536type record of CodecListTest CodecListTests
3537
3538private function f_TC_assignment_codec(charstring id) runs on MSC_ConnHdlr {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02003539 var PDU_BSSAP ass_cmd := f_gen_ass_req(g_pars.use_osmux);
3540 var template PDU_BSSAP exp_compl := f_gen_exp_compl(g_pars.use_osmux);
Harald Welte60aa5762018-03-21 19:33:13 +01003541
3542 /* puzzle together the ASSIGNMENT REQ for given codec[s] */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003543 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welte79f3f542018-05-25 20:02:37 +02003544 ass_cmd.pdu.bssmap.assignmentRequest.codecList := g_pars.ass_codec_list;
3545 exp_compl.pdu.bssmap.assignmentComplete.speechCodec.codecElements[0] :=
3546 g_pars.ass_codec_list.codecElements[0];
Philipp Maierd0e64b02019-03-13 14:15:23 +01003547 if (isvalue(g_pars.expect_mr_s0_s7)) {
3548 exp_compl.pdu.bssmap.assignmentComplete.speechCodec.codecElements[0].s0_7 :=
3549 g_pars.expect_mr_s0_s7;
3550 }
Harald Welte79f3f542018-05-25 20:02:37 +02003551 }
Harald Welte60aa5762018-03-21 19:33:13 +01003552 ass_cmd.pdu.bssmap.assignmentRequest.channelType :=
3553 f_BSSMAP_chtype_from_codec(g_pars.ass_codec_list.codecElements[0]);
Harald Welte60aa5762018-03-21 19:33:13 +01003554 log("expecting ASS COMPL like this: ", exp_compl);
3555
3556 f_establish_fully(ass_cmd, exp_compl);
Harald Weltea63b9102018-03-22 20:36:16 +01003557
3558 /* Verify that the RSL-side activation actually matches our expectations */
3559 var RSL_Message rsl := f_rslem_get_last_act(RSL_PROC, 0, g_chan_nr);
3560
3561 var RSL_IE_Body mode_ie;
3562 if (f_rsl_find_ie(rsl, RSL_IE_CHAN_MODE, mode_ie) == false) {
3563 setverdict(fail, "Couldn't find CHAN_MODE IE");
Daniel Willmannafce8662018-07-06 23:11:32 +02003564 mtc.stop;
Harald Weltea63b9102018-03-22 20:36:16 +01003565 }
3566 var template RSL_IE_Body t_mode_ie := f_rsl_chmod_tmpl_from_codec(g_pars.ass_codec_list.codecElements[0]);
3567 if (not match(mode_ie, t_mode_ie)) {
3568 setverdict(fail, "RSL Channel Mode IE doesn't match expectation");
3569 }
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003570
3571 var RSL_IE_Body mr_conf;
3572 if (g_pars.expect_mr_conf_ie != omit) {
3573 if (f_rsl_find_ie(rsl, RSL_IE_MR_CONFIG, mr_conf) == false) {
3574 setverdict(fail, "Missing MR CONFIG IE in RSL Chan Activ");
Daniel Willmannafce8662018-07-06 23:11:32 +02003575 mtc.stop;
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003576 }
3577 log("found RSL MR CONFIG IE: ", mr_conf);
3578
3579 if (not match(mr_conf, g_pars.expect_mr_conf_ie)) {
3580 setverdict(fail, "RSL MR CONFIG IE does not match expectation. Expected: ",
3581 g_pars.expect_mr_conf_ie);
3582 }
3583 } else {
3584 if (f_rsl_find_ie(rsl, RSL_IE_MR_CONFIG, mr_conf) == true) {
3585 log("found RSL MR CONFIG IE: ", mr_conf);
3586 setverdict(fail, "Found MR CONFIG IE in RSL Chan Activ, expecting omit");
Daniel Willmannafce8662018-07-06 23:11:32 +02003587 mtc.stop;
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003588 }
3589 }
Harald Welte60aa5762018-03-21 19:33:13 +01003590}
3591
Philipp Maierd0e64b02019-03-13 14:15:23 +01003592private function f_TC_assignment_codec_fail(charstring id) runs on MSC_ConnHdlr {
3593
3594 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3595 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
3596
3597 /* puzzle together the ASSIGNMENT REQ for given codec[s] */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003598 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Philipp Maierd0e64b02019-03-13 14:15:23 +01003599 ass_cmd.pdu.bssmap.assignmentRequest.codecList := g_pars.ass_codec_list;
3600 }
3601 ass_cmd.pdu.bssmap.assignmentRequest.channelType :=
3602 f_BSSMAP_chtype_from_codec(g_pars.ass_codec_list.codecElements[0]);
3603 log("expecting ASS FAIL like this: ", exp_fail);
3604
3605 f_establish_fully(ass_cmd, exp_fail);
3606}
3607
Harald Welte60aa5762018-03-21 19:33:13 +01003608testcase TC_assignment_codec_fr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003609 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003610 var MSC_ConnHdlr vc_conn;
3611
3612 f_init(1, true);
3613 f_sleep(1.0);
3614
3615 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Welte8863fa12018-05-10 20:15:27 +02003616 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003617 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003618 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01003619}
3620
3621testcase TC_assignment_codec_hr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003622 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003623 var MSC_ConnHdlr vc_conn;
3624
3625 f_init(1, true);
3626 f_sleep(1.0);
3627
3628 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
Harald Welte8863fa12018-05-10 20:15:27 +02003629 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003630 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003631 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01003632}
3633
3634testcase TC_assignment_codec_efr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003635 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003636 var MSC_ConnHdlr vc_conn;
3637
3638 f_init(1, true);
3639 f_sleep(1.0);
3640
3641 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecEFR}));
Harald Welte8863fa12018-05-10 20:15:27 +02003642 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003643 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003644 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01003645}
3646
Philipp Maierd0e64b02019-03-13 14:15:23 +01003647/* Allow 5,90k only (current default config) */
3648private function f_allow_amr_rate_5_90k() runs on test_CT {
Neels Hofmeyr2a5670b2020-11-25 23:39:57 +00003649 f_vty_cfg_msc(BSCVTY, 0, {
3650 "amr-config 12_2k forbidden",
3651 "amr-config 10_2k forbidden",
3652 "amr-config 7_95k forbidden",
3653 "amr-config 7_40k forbidden",
3654 "amr-config 6_70k forbidden",
3655 "amr-config 5_90k allowed",
3656 "amr-config 5_15k forbidden",
3657 "amr-config 4_75k forbidden"
3658 });
Philipp Maierd0e64b02019-03-13 14:15:23 +01003659}
3660
3661/* Allow 4,75k, 5,90k, 4,70k and 12,2k, which are the most common rates
3662 * ("Config-NB-Code = 1") */
3663private function f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k() runs on test_CT {
Neels Hofmeyr2a5670b2020-11-25 23:39:57 +00003664 f_vty_cfg_msc(BSCVTY, 0, {
3665 "amr-config 12_2k allowed",
3666 "amr-config 10_2k forbidden",
3667 "amr-config 7_95k forbidden",
3668 "amr-config 7_40k allowed",
3669 "amr-config 6_70k forbidden",
3670 "amr-config 5_90k allowed",
3671 "amr-config 5_15k forbidden",
3672 "amr-config 4_75k allowed"
3673 });
Philipp Maierd0e64b02019-03-13 14:15:23 +01003674}
3675
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003676private function f_vty_amr_start_mode_set(boolean fr, charstring startmode) runs on test_CT {
3677 var charstring tch;
3678 if (fr) {
3679 tch := "tch-f";
3680 } else {
3681 tch := "tch-h";
3682 }
3683 f_vty_cfg_bts(BSCVTY, 0, { "amr " & tch & " start-mode " & startmode });
3684}
3685
3686/* Set the AMR start-mode for this TCH back to the default configuration. */
3687private function f_vty_amr_start_mode_restore(boolean fr) runs on test_CT {
3688 f_vty_amr_start_mode_set(fr, "auto");
3689}
3690
Harald Welte60aa5762018-03-21 19:33:13 +01003691testcase TC_assignment_codec_amr_f() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003692 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003693 var MSC_ConnHdlr vc_conn;
Philipp Maier7695a0d2018-09-27 17:52:14 +02003694
3695 /* Note: This setups the codec configuration. The parameter payload in
3696 * mr_conf must be consistant with the parameter codecElements in pars
3697 * and also must match the amr-config in osmo-bsc.cfg! */
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003698 var RSL_IE_Body mr_conf := {
3699 other := {
3700 len := 2,
3701 payload := '2804'O
3702 }
3703 };
Harald Welte60aa5762018-03-21 19:33:13 +01003704
Philipp Maier7695a0d2018-09-27 17:52:14 +02003705 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
Philipp Maier806f8f12019-03-12 12:13:41 +01003706 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
Philipp Maier7695a0d2018-09-27 17:52:14 +02003707 pars.ass_codec_list.codecElements[0].s8_15 := '01010111'B;
3708 pars.expect_mr_conf_ie := mr_conf;
3709
Harald Welte60aa5762018-03-21 19:33:13 +01003710 f_init(1, true);
3711 f_sleep(1.0);
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003712 f_vty_amr_start_mode_set(true, "1");
Harald Welte60aa5762018-03-21 19:33:13 +01003713
Harald Welte8863fa12018-05-10 20:15:27 +02003714 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003715 vc_conn.done;
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003716
3717 f_vty_amr_start_mode_restore(true);
Vadim Yanitskiy292e5962021-01-03 14:18:47 +01003718 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01003719}
3720
3721testcase TC_assignment_codec_amr_h() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003722 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003723 var MSC_ConnHdlr vc_conn;
Philipp Maier7695a0d2018-09-27 17:52:14 +02003724
3725 /* See note above */
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003726 var RSL_IE_Body mr_conf := {
3727 other := {
3728 len := 2,
3729 payload := '2804'O
3730 }
3731 };
Harald Welte60aa5762018-03-21 19:33:13 +01003732
Philipp Maier7695a0d2018-09-27 17:52:14 +02003733 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
Philipp Maier806f8f12019-03-12 12:13:41 +01003734 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
Philipp Maier7695a0d2018-09-27 17:52:14 +02003735 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
3736 pars.expect_mr_conf_ie := mr_conf;
3737
Harald Welte60aa5762018-03-21 19:33:13 +01003738 f_init(1, true);
3739 f_sleep(1.0);
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003740 f_vty_amr_start_mode_set(false, "1");
Harald Welte60aa5762018-03-21 19:33:13 +01003741
Harald Welte8863fa12018-05-10 20:15:27 +02003742 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003743 vc_conn.done;
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003744
3745 f_vty_amr_start_mode_restore(false);
Vadim Yanitskiy292e5962021-01-03 14:18:47 +01003746 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01003747}
3748
Neels Hofmeyr454d7922020-11-26 02:24:57 +00003749/* 'amr start-mode auto' should not keep the (unused) 'smod' bits from previous configuration */
3750testcase TC_assignment_codec_amr_startmode_cruft() runs on test_CT {
3751 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3752 var MSC_ConnHdlr vc_conn;
3753
3754 var RSL_IE_Body mr_conf := {
3755 other := {
3756 len := 2,
3757 payload := '2004'O /* <- expect ICMI=0, smod=00 */
3758 }
3759 };
3760
3761 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
3762 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
3763 pars.ass_codec_list.codecElements[0].s8_15 := '01010111'B;
3764 pars.expect_mr_conf_ie := mr_conf;
3765
3766 f_init(1, true);
3767 f_sleep(1.0);
3768
3769 /* First set nonzero start mode bits */
3770 f_vty_amr_start_mode_set(true, "4");
3771 /* Now set to auto, and expect the startmode bits to be zero in the message, i.e. ensure that osmo-bsc does not
3772 * let the startmode bits stick around and has deterministic MultiRate config for 'start-mode auto'; that is
3773 * ensured by above '2004'O, where 'x0xx'O indicates ICMI = 0, spare = 0, smod = 00. */
3774 f_vty_amr_start_mode_set(true, "auto");
3775
3776 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
3777 vc_conn.done;
Neels Hofmeyr454d7922020-11-26 02:24:57 +00003778
3779 /* Clear the startmode bits to not affect subsequent tests, in case the bits should indeed stick around. */
3780 f_vty_amr_start_mode_set(true, "1");
3781 f_vty_amr_start_mode_restore(true);
Vadim Yanitskiy292e5962021-01-03 14:18:47 +01003782 f_shutdown_helper();
Neels Hofmeyr454d7922020-11-26 02:24:57 +00003783}
3784
Neels Hofmeyr21863562020-11-26 00:34:33 +00003785function f_TC_assignment_codec_amr(boolean fr, octetstring mrconf, bitstring s8_s0, bitstring exp_s8_s0,
3786 charstring start_mode := "1")
Philipp Maierd0e64b02019-03-13 14:15:23 +01003787runs on test_CT {
3788
3789 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3790 var MSC_ConnHdlr vc_conn;
3791
3792 /* See note above */
3793 var RSL_IE_Body mr_conf := {
3794 other := {
3795 len := lengthof(mrconf),
3796 payload := mrconf
3797 }
3798 };
3799
3800 if (fr) {
3801 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
3802 } else {
3803 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
3804 }
3805 pars.ass_codec_list.codecElements[0].s0_7 := s8_s0;
3806 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
3807 pars.expect_mr_conf_ie := mr_conf;
3808 pars.expect_mr_s0_s7 := exp_s8_s0;
3809
3810 f_init(1, true);
3811 f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k();
Neels Hofmeyr21863562020-11-26 00:34:33 +00003812 f_vty_amr_start_mode_set(fr, start_mode);
Philipp Maierd0e64b02019-03-13 14:15:23 +01003813 f_sleep(1.0);
3814
3815 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
3816 vc_conn.done;
3817 f_allow_amr_rate_5_90k();
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003818 f_vty_amr_start_mode_restore(fr);
Philipp Maierd0e64b02019-03-13 14:15:23 +01003819}
3820
3821function f_TC_assignment_codec_amr_fail(boolean fr, bitstring s8_s0)
3822runs on test_CT {
3823
3824 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3825 var MSC_ConnHdlr vc_conn;
3826
3827 if (fr) {
3828 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
3829 } else {
3830 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
3831 }
3832 pars.ass_codec_list.codecElements[0].s0_7 := s8_s0;
3833 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
3834
3835 f_init(1, true);
3836 f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k();
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003837 f_vty_amr_start_mode_set(fr, "1");
Philipp Maierd0e64b02019-03-13 14:15:23 +01003838 f_sleep(1.0);
3839
3840 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fail), pars);
3841 vc_conn.done;
3842 f_allow_amr_rate_5_90k();
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003843 f_vty_amr_start_mode_restore(fr);
Philipp Maierd0e64b02019-03-13 14:15:23 +01003844}
3845
3846
3847/* Set S1, we expect an AMR multirate configuration IE with all four rates
3848 * set. */
3849testcase TC_assignment_codec_amr_f_S1() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003850 f_TC_assignment_codec_amr(true, '289520882208'O, '00000010'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003851 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003852}
3853
3854/* Set S1, we expect an AMR multirate configuration IE with the lower three
3855 * rates set. */
3856testcase TC_assignment_codec_amr_h_S1() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003857 f_TC_assignment_codec_amr(false, '2815208820'O, '00000010'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003858 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003859}
3860
3861/* Set S1 and two other rates, we expect an AMR MULTIRATE CONFIGURATION IE with
3862 * all four rates (and only S1 set in the ASSIGNMENT COMPLETE) */
3863testcase TC_assignment_codec_amr_f_S124() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003864 f_TC_assignment_codec_amr(true, '289520882208'O, '00010110'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003865 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003866}
3867
3868/* Set S1 and two other rates, we expect an AMR MULTIRATE CONFIGURATION IE with
3869 * all four rates (and only S1 set in the ASSIGNMENT COMPLETE) */
3870testcase TC_assignment_codec_amr_h_S124() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003871 f_TC_assignment_codec_amr(false, '2815208820'O, '00010110'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003872 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003873}
3874
3875/* The following block of tests selects more and more rates until all four
3876 * possible rates are in the active set (full rate) */
3877testcase TC_assignment_codec_amr_f_S0() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003878 f_TC_assignment_codec_amr(true, '2801'O, '00000001'B, '00000001'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003879 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003880}
3881
3882testcase TC_assignment_codec_amr_f_S02() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003883 f_TC_assignment_codec_amr(true, '28052080'O, '00000101'B, '00000101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003884 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003885}
3886
3887testcase TC_assignment_codec_amr_f_S024() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003888 f_TC_assignment_codec_amr(true, '2815208820'O, '00010101'B, '00010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003889 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003890}
3891
3892testcase TC_assignment_codec_amr_f_S0247() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003893 f_TC_assignment_codec_amr(true, '289520882208'O, '10010101'B, '10010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003894 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003895}
3896
3897/* The following block of tests selects more and more rates until all three
3898 * possible rates are in the active set (half rate) */
3899testcase TC_assignment_codec_amr_h_S0() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003900 f_TC_assignment_codec_amr(false, '2801'O, '00000001'B, '00000001'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003901 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003902}
3903
3904testcase TC_assignment_codec_amr_h_S02() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003905 f_TC_assignment_codec_amr(false, '28052080'O, '00000101'B, '00000101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003906 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003907}
3908
3909testcase TC_assignment_codec_amr_h_S024() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003910 f_TC_assignment_codec_amr(false, '2815208820'O, '00010101'B, '00010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003911 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003912}
3913
3914/* The following block tests what happens when the MSC does offer rate
3915 * configurations that are not supported by the BSC. Normally such situations
3916 * should not happen because the MSC gets informed by the BSC in advance via
3917 * the L3 COMPLETE message which rates are applicable. The MSC should not try
3918 * to offer rates that are not applicable anyway. */
3919
3920testcase TC_assignment_codec_amr_h_S0247() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003921 /* Try to include 12,2k in into the active set even though the channel
3922 * is half rate only. The BSC is expected to remove the 12,0k */
3923 f_TC_assignment_codec_amr(false, '2815208820'O, '10010101'B, '00010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003924 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003925}
3926
3927testcase TC_assignment_codec_amr_f_S01234567() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003928 /* See what happens when all rates are selected at once. Since then
3929 * Also S1 is selected, this setting will be prefered and we should
3930 * get 12.2k, 7,40k, 5,90k, and 4,75k in the active set. */
3931 f_TC_assignment_codec_amr(true, '289520882208'O, '11111111'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003932 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003933}
3934
3935testcase TC_assignment_codec_amr_f_S0234567() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003936 /* Same as above, but with S1 missing, the MSC is then expected to
3937 * select the currently supported rates, which are also 12.2k, 7,40k,
3938 * 5,90k, and 4,75k, into the active set. */
3939 f_TC_assignment_codec_amr(true, '289520882208'O, '11111101'B, '10010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003940 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003941}
3942
3943testcase TC_assignment_codec_amr_f_zero() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003944 /* Try to select no rates at all */
3945 f_TC_assignment_codec_amr_fail(true, '00000000'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003946 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003947}
3948
3949testcase TC_assignment_codec_amr_f_unsupp() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003950 /* Try to select only unsupported rates */
3951 f_TC_assignment_codec_amr_fail(true, '01101000'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003952 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003953}
3954
3955testcase TC_assignment_codec_amr_h_S7() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003956 /* Try to select 12,2k for half rate */
3957 f_TC_assignment_codec_amr_fail(false, '10000000'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003958 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003959}
3960
Neels Hofmeyr21863562020-11-26 00:34:33 +00003961testcase TC_assignment_codec_amr_f_start_mode_auto() runs on test_CT {
3962 f_TC_assignment_codec_amr(true, '209520882208'O, '11111111'B, '00000010'B,
3963 start_mode := "auto");
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01003964 f_shutdown_helper();
Neels Hofmeyr21863562020-11-26 00:34:33 +00003965}
3966
3967testcase TC_assignment_codec_amr_h_start_mode_auto() runs on test_CT {
3968 f_TC_assignment_codec_amr(false, '2015208820'O, '10010101'B, '00010101'B,
3969 start_mode := "auto");
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01003970 f_shutdown_helper();
Neels Hofmeyr21863562020-11-26 00:34:33 +00003971}
3972
Neels Hofmeyr3eb94562020-11-26 02:40:26 +00003973testcase TC_assignment_codec_amr_f_start_mode_4() runs on test_CT {
Vadim Yanitskiy7815f482021-01-03 17:07:37 +01003974 /* "amr tch-f modes 0 2 4 7" => total 4 modes and start mode 4 => '11'B on the wire */
Neels Hofmeyr3eb94562020-11-26 02:40:26 +00003975 f_TC_assignment_codec_amr(true, '2b9520882208'O, '11111111'B, '00000010'B,
3976 start_mode := "4");
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01003977 f_shutdown_helper();
Neels Hofmeyr3eb94562020-11-26 02:40:26 +00003978}
3979
3980testcase TC_assignment_codec_amr_h_start_mode_4() runs on test_CT {
Vadim Yanitskiy7815f482021-01-03 17:07:37 +01003981 /* "amr tch-h modes 0 2 4" => total 3 modes and start mode 4 => '10'B on the wire */
3982 f_TC_assignment_codec_amr(false, '2a15208820'O, '10010101'B, '00010101'B,
Neels Hofmeyr3eb94562020-11-26 02:40:26 +00003983 start_mode := "4");
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01003984 f_shutdown_helper();
Neels Hofmeyr3eb94562020-11-26 02:40:26 +00003985}
3986
Philipp Maierac09bfc2019-01-08 13:41:39 +01003987private function f_disable_all_tch_f() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01003988 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 1 sub-slot 0 borken");
3989 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 2 sub-slot 0 borken");
3990 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 3 sub-slot 0 borken");
3991 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 4 sub-slot 0 borken");
Philipp Maierac09bfc2019-01-08 13:41:39 +01003992}
3993
3994private function f_disable_all_tch_h() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01003995 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 0 borken");
3996 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 1 borken");
Philipp Maierac09bfc2019-01-08 13:41:39 +01003997}
3998
3999private function f_enable_all_tch() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01004000 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 1 sub-slot 0 unused");
4001 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 2 sub-slot 0 unused");
4002 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 3 sub-slot 0 unused");
4003 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 4 sub-slot 0 unused");
4004 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 0 unused");
4005 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 1 unused");
Philipp Maierac09bfc2019-01-08 13:41:39 +01004006}
4007
4008/* Allow HR only */
4009private function f_TC_assignment_codec_xr_exhausted_req_hr(charstring id) runs on MSC_ConnHdlr {
4010 g_pars := f_gen_test_hdlr_pars();
4011 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4012 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4013 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4014 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '09'O;
4015 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '05'O;
4016 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
4017 f_establish_fully(ass_cmd, exp_compl);
4018}
4019
4020/* Allow FR only */
4021private function f_TC_assignment_codec_xr_exhausted_req_fr(charstring id) runs on MSC_ConnHdlr {
4022 g_pars := f_gen_test_hdlr_pars();
4023 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4024 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4025 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4026 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '08'O;
4027 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '01'O;
4028 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4029 f_establish_fully(ass_cmd, exp_compl);
4030}
4031
4032/* Allow HR only (expect assignment failure) */
4033private function f_TC_assignment_codec_xr_exhausted_req_hr_fail(charstring id) runs on MSC_ConnHdlr {
4034 g_pars := f_gen_test_hdlr_pars();
4035 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4036 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
4037 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4038 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '09'O;
4039 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '05'O;
4040 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
4041 f_establish_fully(ass_cmd, exp_fail);
4042}
4043
4044/* Allow FR only (expect assignment failure) */
4045private function f_TC_assignment_codec_xr_exhausted_req_fr_fail(charstring id) runs on MSC_ConnHdlr {
4046 g_pars := f_gen_test_hdlr_pars();
4047 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4048 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
4049 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4050 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '08'O;
4051 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '01'O;
4052 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4053 f_establish_fully(ass_cmd, exp_fail);
4054}
4055
4056/* Allow FR and HR, but prefer FR */
4057private function f_TC_assignment_codec_fr_exhausted_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
4058 g_pars := f_gen_test_hdlr_pars();
4059 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4060 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4061 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4062 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
4063 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
4064 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
4065 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
4066 f_establish_fully(ass_cmd, exp_compl);
4067}
4068
4069/* Allow FR and HR, but prefer HR */
4070private function f_TC_assignment_codec_fr_exhausted_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
4071 g_pars := f_gen_test_hdlr_pars();
4072 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4073 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4074 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4075 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
4076 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
4077 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
4078 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
4079 f_establish_fully(ass_cmd, exp_compl);
4080}
4081
4082/* Allow FR and HR, but prefer FR */
4083private function f_TC_assignment_codec_hr_exhausted_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
4084 g_pars := f_gen_test_hdlr_pars();
4085 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4086 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4087 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4088 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
4089 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
4090 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
4091 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
4092 f_establish_fully(ass_cmd, exp_compl);
4093}
4094
4095/* Allow FR and HR, but prefer HR */
4096private function f_TC_assignment_codec_hr_exhausted_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
4097 g_pars := f_gen_test_hdlr_pars();
4098 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4099 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4100 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4101 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
4102 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
4103 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
4104 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
4105 f_establish_fully(ass_cmd, exp_compl);
4106}
4107
4108/* Request a HR channel while all FR channels are exhausted, this is expected
4109 * to work without conflicts */
4110testcase TC_assignment_codec_fr_exhausted_req_hr() runs on test_CT {
4111 var MSC_ConnHdlr vc_conn;
4112 f_init(1, true);
4113 f_sleep(1.0);
4114 f_enable_all_tch();
4115 f_disable_all_tch_f();
4116 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_hr));
4117 vc_conn.done;
4118 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004119 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004120}
4121
4122/* Request a FR channel while all FR channels are exhausted, this is expected
4123 * to fail. */
4124testcase TC_assignment_codec_fr_exhausted_req_fr() runs on test_CT {
4125 var MSC_ConnHdlr vc_conn;
4126 f_init(1, true);
4127 f_sleep(1.0);
4128 f_enable_all_tch();
4129 f_disable_all_tch_f();
4130 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_fr_fail));
4131 vc_conn.done;
4132 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004133 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004134}
4135
4136/* Request a FR (prefered) or alternatively a HR channel while all FR channels
4137 * are exhausted, this is expected to be resolved by selecting a HR channel. */
4138testcase TC_assignment_codec_fr_exhausted_req_fr_hr() runs on test_CT {
4139 var MSC_ConnHdlr vc_conn;
4140 f_init(1, true);
4141 f_sleep(1.0);
4142 f_enable_all_tch();
4143 f_disable_all_tch_f();
4144 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fr_exhausted_req_fr_hr));
4145 vc_conn.done;
4146 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004147 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004148}
4149
4150/* Request a HR (prefered) or alternatively a FR channel while all FR channels
4151 * are exhausted, this is expected to work without conflicts. */
4152testcase TC_assignment_codec_fr_exhausted_req_hr_fr() runs on test_CT {
4153 var MSC_ConnHdlr vc_conn;
4154 f_init(1, true);
4155 f_sleep(1.0);
4156 f_enable_all_tch();
4157 f_disable_all_tch_f();
4158 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fr_exhausted_req_hr_fr));
4159 vc_conn.done;
4160 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004161 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004162}
4163
4164/* Request a FR channel while all HR channels are exhausted, this is expected
4165 * to work without conflicts */
4166testcase TC_assignment_codec_hr_exhausted_req_fr() runs on test_CT {
4167 var MSC_ConnHdlr vc_conn;
4168 f_init(1, true);
4169 f_sleep(1.0);
4170 f_enable_all_tch();
4171 f_disable_all_tch_h();
4172 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_fr));
4173 vc_conn.done;
4174 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004175 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004176}
4177
4178/* Request a HR channel while all HR channels are exhausted, this is expected
4179 * to fail. */
4180testcase TC_assignment_codec_hr_exhausted_req_hr() runs on test_CT {
4181 var MSC_ConnHdlr vc_conn;
4182 f_init(1, true);
4183 f_sleep(1.0);
4184 f_enable_all_tch();
4185 f_disable_all_tch_h();
4186 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_hr_fail));
4187 vc_conn.done;
4188 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004189 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004190}
4191
4192/* Request a HR (prefered) or alternatively a FR channel while all HR channels
4193 * are exhausted, this is expected to be resolved by selecting a FR channel. */
4194testcase TC_assignment_codec_hr_exhausted_req_hr_fr() runs on test_CT {
4195 var MSC_ConnHdlr vc_conn;
4196 f_init(1, true);
4197 f_sleep(1.0);
4198 f_enable_all_tch();
4199 f_disable_all_tch_h();
4200 vc_conn := f_start_handler(refers(f_TC_assignment_codec_hr_exhausted_req_hr_fr));
4201 vc_conn.done;
4202 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004203 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004204}
4205
4206/* Request a FR (prefered) or alternatively a HR channel while all HR channels
4207 * are exhausted, this is expected to work without conflicts. */
4208testcase TC_assignment_codec_hr_exhausted_req_fr_hr() runs on test_CT {
4209 var MSC_ConnHdlr vc_conn;
4210 f_init(1, true);
4211 f_sleep(1.0);
4212 f_enable_all_tch();
4213 f_disable_all_tch_h();
4214 vc_conn := f_start_handler(refers(f_TC_assignment_codec_hr_exhausted_req_fr_hr));
4215 vc_conn.done;
4216 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004217 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004218}
4219
4220/* Allow FR and HR, but prefer HR */
4221private function f_TC_assignment_codec_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
4222 g_pars := f_gen_test_hdlr_pars();
4223 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4224 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4225 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4226 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
4227 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
4228 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
4229 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
4230 f_establish_fully(ass_cmd, exp_compl);
4231}
4232
4233/* Allow FR and HR, but prefer FR */
4234private function f_TC_assignment_codec_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
4235 g_pars := f_gen_test_hdlr_pars();
4236 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4237 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4238 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4239 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
4240 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
4241 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
4242 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
4243 f_establish_fully(ass_cmd, exp_compl);
4244}
4245
4246/* Request a HR (prefered) or alternatively a FR channel, it is expected that
4247 * HR, which is the prefered type, is selected. */
4248testcase TC_assignment_codec_req_hr_fr() runs on test_CT {
4249 var MSC_ConnHdlr vc_conn;
4250 f_init(1, true);
4251 f_sleep(1.0);
4252 f_enable_all_tch();
4253 vc_conn := f_start_handler(refers(f_TC_assignment_codec_req_hr_fr));
4254 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004255 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004256}
4257
4258/* Request a FR (prefered) or alternatively a HR channel, it is expected that
4259 * FR, which is the prefered type, is selected. */
4260testcase TC_assignment_codec_req_fr_hr() runs on test_CT {
4261 var MSC_ConnHdlr vc_conn;
4262 f_init(1, true);
4263 f_sleep(1.0);
4264 f_enable_all_tch();
4265 vc_conn := f_start_handler(refers(f_TC_assignment_codec_req_fr_hr));
4266 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004267 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004268}
4269
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02004270testcase TC_assignment_osmux() runs on test_CT {
4271 var TestHdlrParams pars := f_gen_test_hdlr_pars();
4272 var MSC_ConnHdlr vc_conn;
4273
4274 /* See note above */
4275 var RSL_IE_Body mr_conf := {
4276 other := {
4277 len := 2,
4278 payload := '2804'O
4279 }
4280 };
4281
4282 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
4283 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
4284 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
4285 pars.expect_mr_conf_ie := mr_conf;
4286 pars.use_osmux := true;
4287
4288 f_init(1, true, true);
4289 f_sleep(1.0);
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00004290 f_vty_amr_start_mode_set(false, "1");
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02004291
4292 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
4293 vc_conn.done;
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00004294
4295 f_vty_amr_start_mode_restore(false);
Vadim Yanitskiy292e5962021-01-03 14:18:47 +01004296 f_shutdown_helper();
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02004297}
4298
Neels Hofmeyr92b12b72018-09-18 14:30:23 +02004299/* test the procedure of the MSC requesting a Classmark Update:
4300 * a) BSSMAP Classmark Request should result in RR CLASSMARK ENQUIRY,
4301 * b) L3 RR CLASSMARK CHANGE should result in BSSMAP CLASSMARK UPDATE */
Harald Welte898113b2018-01-31 18:32:21 +01004302private function f_tc_classmark(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004303 g_pars := f_gen_test_hdlr_pars();
4304
Harald Weltea0630032018-03-20 21:09:55 +01004305 f_create_chan_and_exp();
Harald Welte898113b2018-01-31 18:32:21 +01004306 /* we should now have a COMPL_L3 at the MSC */
4307 BSSAP.receive(tr_BSSMAP_ComplL3);
4308
Neels Hofmeyr92b12b72018-09-18 14:30:23 +02004309 BSSAP.send(ts_BSSMAP_ClassmarkRequest);
4310 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_CM_ENQUIRY));
4311
Harald Welte898113b2018-01-31 18:32:21 +01004312 f_rsl_send_l3(ts_RRM_CM_CHG(valueof(ts_CM2)));
4313 BSSAP.receive(tr_BSSMAP_ClassmarkUpd(?, omit));
4314 setverdict(pass);
4315}
4316testcase TC_classmark() runs on test_CT {
4317 var MSC_ConnHdlr vc_conn;
4318 f_init(1, true);
4319 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004320 vc_conn := f_start_handler(refers(f_tc_classmark));
Harald Welte898113b2018-01-31 18:32:21 +01004321 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004322 f_shutdown_helper();
Harald Welte898113b2018-01-31 18:32:21 +01004323}
4324
Harald Welteeddf0e92020-06-21 19:42:15 +02004325/* Send a CommonID from the simulated MSC and verify that the information is used to
4326 * fill BSC-internal data structures (specifically, bsc_subscr associated with subscr_conn) */
4327private function f_tc_common_id(charstring id) runs on MSC_ConnHdlr {
4328 g_pars := f_gen_test_hdlr_pars();
4329 f_MscConnHdlr_init_vty();
4330
4331 f_create_chan_and_exp();
4332 /* we should now have a COMPL_L3 at the MSC */
4333 BSSAP.receive(tr_BSSMAP_ComplL3);
4334
4335 /* Send CommonID */
4336 BSSAP.send(ts_BSSMAP_CommonId(g_pars.imsi));
4337
4338 /* Use VTY to verify that the IMSI of the subscr_conn is set */
4339 var charstring regex := "*(IMSI: " & hex2str(g_pars.imsi) & ")*";
4340 f_vty_transceive_match_regexp_retry(BSCVTY, "show conns", regex, 0, 4, 1.0);
4341
4342 setverdict(pass);
4343}
4344testcase TC_common_id() runs on test_CT {
4345 var MSC_ConnHdlr vc_conn;
4346 f_init(1, true);
4347 f_sleep(1.0);
4348 vc_conn := f_start_handler(refers(f_tc_common_id));
4349 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004350 f_shutdown_helper();
Harald Welteeddf0e92020-06-21 19:42:15 +02004351}
4352
Harald Weltee3bd6582018-01-31 22:51:25 +01004353private function f_est_single_l3(template PDU_ML3_MS_NW l3) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004354 g_pars := f_gen_test_hdlr_pars();
Harald Weltea0630032018-03-20 21:09:55 +01004355 f_create_chan_and_exp();
Harald Welte898113b2018-01-31 18:32:21 +01004356 /* we should now have a COMPL_L3 at the MSC */
4357 BSSAP.receive(tr_BSSMAP_ComplL3);
4358
Harald Weltee3bd6582018-01-31 22:51:25 +01004359 /* send the single message we want to send */
4360 f_rsl_send_l3(l3);
4361}
4362
4363private function f_bssap_expect_nothing(float sec := 5.00) runs on MSC_ConnHdlr {
4364 timer T := sec;
4365 var PDU_BSSAP bssap;
Harald Welte898113b2018-01-31 18:32:21 +01004366 T.start;
4367 alt {
Harald Weltee3bd6582018-01-31 22:51:25 +01004368 [] BSSAP.receive(PDU_BSSAP:?) -> value bssap {
4369 setverdict(fail, "Unexpected BSSMAP ", bssap);
Daniel Willmannafce8662018-07-06 23:11:32 +02004370 mtc.stop;
Harald Welte898113b2018-01-31 18:32:21 +01004371 }
4372 [] T.timeout {
4373 setverdict(pass);
4374 }
4375 }
4376}
4377
Harald Weltee3bd6582018-01-31 22:51:25 +01004378/* unsolicited ASSIGNMENT FAIL (without ASSIGN) from MS shouldn't bring BSC down */
4379private function f_tc_unsol_ass_fail(charstring id) runs on MSC_ConnHdlr {
4380 f_est_single_l3(ts_RRM_AssignmentFailure('00'O));
4381 f_bssap_expect_nothing();
4382}
Harald Welte898113b2018-01-31 18:32:21 +01004383testcase TC_unsol_ass_fail() runs on test_CT {
4384 var MSC_ConnHdlr vc_conn;
4385 f_init(1, true);
4386 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004387 vc_conn := f_start_handler(refers(f_tc_unsol_ass_fail));
Harald Welte898113b2018-01-31 18:32:21 +01004388 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004389 f_shutdown_helper();
Harald Welte898113b2018-01-31 18:32:21 +01004390}
Harald Welte552620d2017-12-16 23:21:36 +01004391
Harald Welteea99a002018-01-31 20:46:43 +01004392
4393/* unsolicited ASSIGNMENT COMPLETE (without ASSIGN) from MS shouldn't bring BSC down */
4394private function f_tc_unsol_ass_compl(charstring id) runs on MSC_ConnHdlr {
Harald Weltee3bd6582018-01-31 22:51:25 +01004395 f_est_single_l3(ts_RRM_AssignmentComplete('00'O));
4396 f_bssap_expect_nothing();
Harald Welteea99a002018-01-31 20:46:43 +01004397}
4398testcase TC_unsol_ass_compl() runs on test_CT {
4399 var MSC_ConnHdlr vc_conn;
4400 f_init(1, true);
4401 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004402 vc_conn := f_start_handler(refers(f_tc_unsol_ass_compl));
Harald Welteea99a002018-01-31 20:46:43 +01004403 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004404 f_shutdown_helper();
Harald Welteea99a002018-01-31 20:46:43 +01004405}
4406
4407
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004408/* unsolicited HANDOVER FAIL (without ASSIGN) from MS shouldn't bring BSC down */
4409private function f_tc_unsol_ho_fail(charstring id) runs on MSC_ConnHdlr {
Harald Weltee3bd6582018-01-31 22:51:25 +01004410 f_est_single_l3(ts_RRM_HandoverFailure('00'O));
4411 f_bssap_expect_nothing();
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004412}
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004413testcase TC_unsol_ho_fail() runs on test_CT {
4414 var MSC_ConnHdlr vc_conn;
4415 f_init(1, true);
4416 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004417 vc_conn := f_start_handler(refers(f_tc_unsol_ho_fail));
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004418 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004419 f_shutdown_helper();
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004420}
4421
4422
Harald Weltee3bd6582018-01-31 22:51:25 +01004423/* short message from MS should be ignored */
4424private function f_tc_err_82_short_msg(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004425 g_pars := f_gen_test_hdlr_pars();
Harald Weltea0630032018-03-20 21:09:55 +01004426 f_create_chan_and_exp();
Harald Weltee3bd6582018-01-31 22:51:25 +01004427 /* we should now have a COMPL_L3 at the MSC */
4428 BSSAP.receive(tr_BSSMAP_ComplL3);
4429
4430 /* send short message */
4431 RSL.send(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), ''O));
4432 f_bssap_expect_nothing();
4433}
4434testcase TC_err_82_short_msg() runs on test_CT {
4435 var MSC_ConnHdlr vc_conn;
4436 f_init(1, true);
4437 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004438 vc_conn := f_start_handler(refers(f_tc_err_82_short_msg));
Harald Weltee3bd6582018-01-31 22:51:25 +01004439 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004440 f_shutdown_helper();
Harald Weltee3bd6582018-01-31 22:51:25 +01004441}
4442
4443
Harald Weltee9e02e42018-01-31 23:36:25 +01004444/* 24.008 8.4 Unknown message must trigger RR STATUS */
4445private function f_tc_err_84_unknown_msg(charstring id) runs on MSC_ConnHdlr {
4446 f_est_single_l3(ts_RRM_UL_REL('00'O));
4447 timer T := 3.0
4448 alt {
4449 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_STATUS)) {
4450 setverdict(pass);
4451 }
4452 [] BSSAP.receive { setverdict(fail, "unexpected BSSAP"); }
Harald Welte458fd372018-03-21 11:26:23 +01004453 [] T.timeout { setverdict(fail, "Timeout waiting for RR STATUS"); }
Harald Weltee9e02e42018-01-31 23:36:25 +01004454 }
4455}
4456testcase TC_err_84_unknown_msg() runs on test_CT {
4457 var MSC_ConnHdlr vc_conn;
4458 f_init(1, true);
4459 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004460 vc_conn := f_start_handler(refers(f_tc_err_84_unknown_msg));
Harald Weltee9e02e42018-01-31 23:36:25 +01004461 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004462 f_shutdown_helper();
Harald Weltee9e02e42018-01-31 23:36:25 +01004463}
4464
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004465/***********************************************************************
4466 * Handover
4467 ***********************************************************************/
4468
Harald Welte94e0c342018-04-07 11:33:23 +02004469/* execute a "bts <0-255> trx <0-255> timeslot <0-7> " command on given Dchan */
4470private function f_vty_ts_action(charstring suffix, integer bts_nr, integer trx_nr, integer ts_nr)
4471runs on test_CT {
4472 var charstring cmd := "bts "&int2str(bts_nr)&" trx "&int2str(trx_nr)&
4473 " timeslot "&int2str(ts_nr)&" ";
4474 f_vty_transceive(BSCVTY, cmd & suffix);
4475}
4476
Harald Welte261af4b2018-02-12 21:20:39 +01004477/* execute a "bts <0-255> trx <0-255> timeslot <0-7> sub-slot <0-7>" command on given Dchan */
Vadim Yanitskiy00070722020-09-02 17:27:57 +07004478private function f_vty_ss_action(TELNETasp_PT pt, charstring suffix,
4479 uint8_t bts_nr, uint8_t trx_nr,
4480 in RslChannelNr chan_nr)
4481{
Harald Welte261af4b2018-02-12 21:20:39 +01004482 /* FIXME: resolve those from component-global state */
4483 var integer ts_nr := chan_nr.tn;
4484 var integer ss_nr;
4485 if (ischosen(chan_nr.u.ch0)) {
4486 ss_nr := 0;
4487 } else if (ischosen(chan_nr.u.lm)) {
4488 ss_nr := chan_nr.u.lm.sub_chan;
4489 } else if (ischosen(chan_nr.u.sdcch4)) {
4490 ss_nr := chan_nr.u.sdcch4.sub_chan;
4491 } else if (ischosen(chan_nr.u.sdcch8)) {
4492 ss_nr := chan_nr.u.sdcch8.sub_chan;
4493 } else {
4494 setverdict(fail, "Invalid ChanNr ", chan_nr);
Daniel Willmannafce8662018-07-06 23:11:32 +02004495 mtc.stop;
Harald Welte261af4b2018-02-12 21:20:39 +01004496 }
4497
4498 var charstring cmd := "bts "&int2str(bts_nr)&" trx "&int2str(trx_nr)&
4499 " timeslot "&int2str(ts_nr)&" sub-slot "&int2str(ss_nr)&" ";
Vadim Yanitskiy00070722020-09-02 17:27:57 +07004500 f_vty_transceive(pt, cmd & suffix);
Harald Welte261af4b2018-02-12 21:20:39 +01004501}
4502
Neels Hofmeyr91401012019-07-11 00:42:35 +02004503/* Even though the VTY command to trigger handover takes a new BTS number as argument, behind the scenes osmo-bsc always
4504 * translates that to a target ARFCN+BSIC first. See bsc_vty.c trigger_ho_or_as(), which puts the selected BTS' neighbor
4505 * ident key (ARFCN + BSIC) in the struct passed on to handover_request(). handover_start() then resolves that to a
4506 * viable actual neighbor cell. So from the internal osmo-bsc perspective, we always request handover to an ARFCN + BSIC
4507 * pair, not really to a specific BTS number. */
Vadim Yanitskiy00070722020-09-02 17:27:57 +07004508private function f_vty_handover(TELNETasp_PT pt, uint8_t bts_nr, uint8_t trx_nr,
4509 in RslChannelNr chan_nr, uint8_t new_bts_nr)
4510{
4511 f_vty_ss_action(pt, "handover " & int2str(new_bts_nr), bts_nr, trx_nr, chan_nr);
Harald Welte261af4b2018-02-12 21:20:39 +01004512}
4513
4514/* intra-BSC hand-over between BTS0 and BTS1 */
4515private function f_tc_ho_int(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004516 g_pars := f_gen_test_hdlr_pars();
Harald Welteed848512018-05-24 22:27:58 +02004517 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4518 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte261af4b2018-02-12 21:20:39 +01004519 const OCT8 kc := '0001020304050607'O;
4520
4521 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4522 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4523
Harald Weltea0630032018-03-20 21:09:55 +01004524 f_establish_fully(ass_cmd, exp_compl);
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004525 f_bts_0_cfg(BSCVTY, {"neighbor bts 1"});
Harald Welte261af4b2018-02-12 21:20:39 +01004526
4527 var HandoverState hs := {
4528 rr_ho_cmpl_seen := false,
4529 handover_done := false,
4530 old_chan_nr := -
4531 };
4532 /* issue hand-over command on VTY */
Vadim Yanitskiy00070722020-09-02 17:27:57 +07004533 f_vty_handover(BSCVTY, 0, 0, g_chan_nr, 1);
Harald Welte261af4b2018-02-12 21:20:39 +01004534 /* temporarily suspend DChan processing on BTS1 to avoid race with RSLEM_register */
4535 f_rslem_suspend(RSL1_PROC);
Philipp Maier3e2af5d2018-07-11 17:01:05 +02004536
4537 /* From the MGW perspective, a handover is is characterized by
4538 * performing one MDCX operation with the MGW. So we expect to see
4539 * one more MDCX during handover. */
4540 g_media.mgcp_conn[0].mdcx_seen_exp := g_media.mgcp_conn[0].crcx_seen_exp + 1;
4541
Harald Welte261af4b2018-02-12 21:20:39 +01004542 alt {
4543 [] as_handover(hs);
Harald Welte261af4b2018-02-12 21:20:39 +01004544 }
Philipp Maier3e2af5d2018-07-11 17:01:05 +02004545
Philipp Maier4dae0652018-11-12 12:03:26 +01004546 /* Since this is an internal handover we expect the BSC to inform the
4547 * MSC about the event */
4548 BSSAP.receive(tr_BSSMAP_HandoverPerformed);
4549
Philipp Maier3e2af5d2018-07-11 17:01:05 +02004550 /* Check the amount of MGCP transactions is still consistant with the
4551 * test expectation */
4552 f_check_mgcp_expectations()
Neels Hofmeyr861a4c12018-11-07 01:23:17 +01004553 f_sleep(0.5);
Harald Welte261af4b2018-02-12 21:20:39 +01004554}
4555
4556testcase TC_ho_int() runs on test_CT {
4557 var MSC_ConnHdlr vc_conn;
4558 f_init(2, true);
4559 f_sleep(1.0);
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004560
4561 f_ctrs_bsc_and_bts_init();
4562
Harald Welte8863fa12018-05-10 20:15:27 +02004563 vc_conn := f_start_handler(refers(f_tc_ho_int));
Harald Welte261af4b2018-02-12 21:20:39 +01004564 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004565
4566 /* from f_establish_fully() */
4567 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4568 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4569 /* from handover */
4570 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4571 f_ctrs_bsc_and_bts_add(0, "handover:completed");
4572 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
4573 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:completed");
4574 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004575 f_shutdown_helper();
Harald Welte261af4b2018-02-12 21:20:39 +01004576}
Harald Weltee9e02e42018-01-31 23:36:25 +01004577
Neels Hofmeyr5f144212020-11-03 15:41:58 +00004578/* intra-BSC hand-over with CONNection FAILure and cause Radio Link Failure: check RR release cause */
4579private function f_tc_ho_int_radio_link_failure(charstring id) runs on MSC_ConnHdlr {
4580 g_pars := f_gen_test_hdlr_pars();
4581 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4582 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4583 const OCT8 kc := '0001020304050607'O;
4584
4585 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4586 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4587
4588 f_establish_fully(ass_cmd, exp_compl);
4589 f_bts_0_cfg(BSCVTY, {"neighbor bts 1"});
4590
4591 var HandoverState hs := {
4592 rr_ho_cmpl_seen := false,
4593 handover_done := false,
4594 old_chan_nr := -
4595 };
4596 /* issue hand-over command on VTY */
4597 f_vty_handover(BSCVTY, 0, 0, g_chan_nr, 1);
4598 /* temporarily suspend DChan processing on BTS1 to avoid race with RSLEM_register */
4599 f_rslem_suspend(RSL1_PROC);
4600
4601 /* From the MGW perspective, a handover is is characterized by
4602 * performing one MDCX operation with the MGW. So we expect to see
4603 * one more MDCX during handover. */
4604 g_media.mgcp_conn[0].mdcx_seen_exp := g_media.mgcp_conn[0].crcx_seen_exp + 1;
4605
4606 var RSL_Message rsl;
4607 var PDU_ML3_NW_MS l3;
4608 var RslChannelNr new_chan_nr;
4609 var GsmArfcn arfcn;
4610 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr)) -> value rsl {
4611 l3 := dec_PDU_ML3_NW_MS(rsl.ies[2].body.l3_info.payload);
4612 if (not ischosen(l3.msgs.rrm.handoverCommand)) {
4613 setverdict(fail, "Expected handoverCommand");
4614 mtc.stop;
4615 }
4616 }
4617 f_ChDesc2RslChanNr(l3.msgs.rrm.handoverCommand.channelDescription2,
4618 new_chan_nr, arfcn);
4619
4620 f_rslem_register(0, new_chan_nr, RSL1_PROC);
4621
4622 /* resume processing of RSL DChan messages, which was temporarily suspended
4623 * before performing a hand-over */
4624 f_rslem_resume(RSL1_PROC);
4625 RSL1.receive(tr_RSL_IPA_CRCX(new_chan_nr));
4626
4627 f_sleep(1.0);
4628
4629 /* Handover fails because no HANDO DET appears on the new lchan,
4630 * and the old lchan reports a Radio Link Failure. */
4631 RSL.send(ts_RSL_CONN_FAIL_IND(g_chan_nr, RSL_ERR_RADIO_LINK_FAIL));
4632
4633 var PDU_BSSAP rx_clear_request;
4634 BSSAP.receive(tr_BSSMAP_ClearRequest) -> value rx_clear_request;
4635 var BssmapCause cause := bit2int(rx_clear_request.pdu.bssmap.clearRequest.cause.causeValue);
4636 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
4637
4638 var RR_Cause rr_cause := GSM48_RR_CAUSE_ABNORMAL_UNSPEC;
4639
4640 var MgcpCommand mgcp;
4641 interleave {
4642 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE(int2oct(enum2int(rr_cause), 1)))) {}
4643 [] RSL.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {}
4644 [] RSL.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
4645 RSL.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
4646 }
4647 [] RSL1.receive(tr_RSL_DEACT_SACCH(new_chan_nr)) {}
4648 [] RSL1.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
4649 RSL1.send(ts_RSL_RF_CHAN_REL_ACK(new_chan_nr));
4650 }
4651 [] BSSAP.receive(tr_BSSMAP_ClearComplete) {}
4652 }
4653
4654 f_sleep(0.5);
4655 setverdict(pass);
4656}
4657testcase TC_ho_int_radio_link_failure() runs on test_CT {
4658 var MSC_ConnHdlr vc_conn;
4659 f_init(2, true);
4660 f_sleep(1.0);
4661
4662 f_ctrs_bsc_and_bts_init();
4663
4664 vc_conn := f_start_handler(refers(f_tc_ho_int_radio_link_failure));
4665 vc_conn.done;
4666
4667 /* from f_establish_fully() */
4668 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4669 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4670 /* from handover */
4671 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4672 f_ctrs_bsc_and_bts_add(0, "handover:stopped");
4673 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
4674 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:stopped");
4675 f_ctrs_bsc_and_bts_verify();
4676 f_shutdown_helper();
4677}
4678
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004679/* Expecting MGCP to DLCX the endpoint's two connections: towards BTS and towards MSC */
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004680private function f_expect_dlcx_conns() runs on MSC_ConnHdlr {
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004681 var MgcpCommand mgcp;
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02004682 var template MgcpResponse mgcp_resp;
4683 var MGCP_RecvFrom mrf;
4684 var template MgcpMessage msg_resp;
4685 var template MgcpMessage msg_dlcx := {
4686 command := tr_DLCX()
4687 }
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004688
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02004689 if (g_pars.aoip) {
4690 MGCP.receive(tr_DLCX()) -> value mgcp {
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004691 log("Got first DLCX: ", mgcp);
4692 MGCP.send(ts_DLCX_ACK2(mgcp.line.trans_id));
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02004693 };
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004694
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004695 MGCP.receive(tr_DLCX()) -> value mgcp {
4696 log("Got second DLCX: ", mgcp);
4697 MGCP.send(ts_DLCX_ACK2(mgcp.line.trans_id));
4698 };
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02004699 } else {
4700 /* For SCCPLite, BSC doesn't handle the MSC-side */
4701 MGCP_MULTI.receive(tr_MGCP_RecvFrom_any(msg_dlcx)) -> value mrf {
4702 log("Got first DLCX: ", mrf.msg.command);
4703 msg_resp := {
4704 response := ts_DLCX_ACK2(mrf.msg.command.line.trans_id)
4705 }
4706 MGCP_MULTI.send(t_MGCP_SendToMrf(mrf, msg_resp));
4707 };
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004708 }
4709
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004710 BSSAP.receive(tr_BSSMAP_ClearComplete);
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004711}
4712
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004713private function f_tc_ho_out_of_this_bsc(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004714 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004715
4716 var PDU_BSSAP ass_req := f_gen_ass_req();
4717 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4718 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4719 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4720 f_establish_fully(ass_req, exp_compl);
4721
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004722 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004723 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
4724
4725 BSSAP.receive(tr_BSSMAP_HandoverRequired);
4726
4727 f_sleep(0.5);
4728 /* The MSC negotiates Handover Request and Handover Request Ack with
4729 * the other BSS and comes back with a BSSMAP Handover Command
4730 * containing an RR Handover Command coming from the target BSS... */
4731
4732 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
4733 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
4734 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
4735 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
4736 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
4737
4738 /* expect the Handover Command to go out on RR */
4739 var RSL_Message rsl_ho_cmd
4740 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
4741 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
4742 var RSL_IE_Body rsl_ho_cmd_l3;
4743 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
4744 log("RSL message contains no L3 Info IE, expected RR Handover Command");
4745 setverdict(fail);
4746 } else {
4747 log("Found L3 Info: ", rsl_ho_cmd_l3);
4748 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
4749 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
4750 setverdict(fail);
4751 } else {
4752 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
4753 setverdict(pass);
4754 }
4755 }
4756
4757 /* When the other BSS has reported a completed handover, this side is
4758 * torn down. */
4759
4760 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_HANDOVER_SUCCESSFUL;
4761 var BssmapCause cause := enum2int(cause_val);
4762 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
4763
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004764 f_expect_dlcx_conns();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004765 setverdict(pass);
4766 f_sleep(1.0);
4767}
4768testcase TC_ho_out_of_this_bsc() runs on test_CT {
4769 var MSC_ConnHdlr vc_conn;
4770
4771 f_init(1, true);
4772 f_sleep(1.0);
4773
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004774 f_ctrs_bsc_and_bts_init();
4775
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004776 vc_conn := f_start_handler(refers(f_tc_ho_out_of_this_bsc));
4777 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004778
4779 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4780 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4781 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4782 f_ctrs_bsc_and_bts_add(0, "handover:completed");
4783 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
4784 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:completed");
4785 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004786 f_shutdown_helper();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004787}
4788
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00004789private function f_mo_l3_transceive(RSL_DCHAN_PT rsl := RSL,
4790 template (value) RslLinkId link_id := ts_RslLinkID_DCCH(0),
Vadim Yanitskiy2ef6a2f2020-10-08 23:17:32 +07004791 template (present) OCT1 dlci := ?,
Vadim Yanitskiyb93aa432020-10-01 14:23:11 +07004792 octetstring l3 := '0123456789'O)
4793runs on MSC_ConnHdlr {
Neels Hofmeyr43654812020-09-25 01:35:35 +02004794 /* The old lchan and conn should still be active. See that arbitrary L3
4795 * is still going through. */
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00004796 rsl.send(ts_RSL_DATA_IND(g_chan_nr, link_id, l3));
Neels Hofmeyr43654812020-09-25 01:35:35 +02004797 var template PDU_BSSAP exp_data := {
4798 discriminator := '1'B,
4799 spare := '0000000'B,
Vadim Yanitskiyb93aa432020-10-01 14:23:11 +07004800 dlci := dlci,
4801 lengthIndicator := lengthof(l3),
Neels Hofmeyr43654812020-09-25 01:35:35 +02004802 pdu := {
4803 dtap := l3
4804 }
4805 };
4806 BSSAP.receive(exp_data);
4807 setverdict(pass);
4808}
4809
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00004810private function f_mt_l3_transceive(RSL_DCHAN_PT rsl := RSL,
4811 template (present) RslLinkId link_id := tr_RslLinkID_DCCH(0),
Vadim Yanitskiy0033a3b2020-10-01 22:21:16 +07004812 template (value) OCT1 dlci := '00'O,
4813 octetstring l3 := '0123456789'O)
4814runs on MSC_ConnHdlr {
4815 BSSAP.send(PDU_BSSAP:{
4816 discriminator := '1'B,
4817 spare := '0000000'B,
4818 dlci := dlci,
4819 lengthIndicator := lengthof(l3),
4820 pdu := {
4821 dtap := l3
4822 }
4823 });
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00004824 rsl.receive(tr_RSL_DATA_REQ(g_chan_nr, link_id, l3));
Vadim Yanitskiy0033a3b2020-10-01 22:21:16 +07004825 setverdict(pass);
4826}
4827
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004828/* BSC asks for inter-BSC HO, but the MSC decides that it won't happen and
4829 * simply never sends a BSSMAP Handover Command. */
4830private function f_tc_ho_out_fail_no_msc_response(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01004831 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004832
4833 var PDU_BSSAP ass_req := f_gen_ass_req();
4834 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4835 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4836 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4837 f_establish_fully(ass_req, exp_compl);
4838
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004839 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004840 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
4841
4842 BSSAP.receive(tr_BSSMAP_HandoverRequired);
4843
4844 /* osmo-bsc should time out 10 seconds after the handover started.
4845 * Let's give it a bit extra. */
4846 f_sleep(15.0);
4847
Vadim Yanitskiy74ae5eb2020-10-01 22:13:29 +07004848 f_mo_l3_transceive();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004849 f_sleep(1.0);
4850}
4851testcase TC_ho_out_fail_no_msc_response() runs on test_CT {
4852 var MSC_ConnHdlr vc_conn;
4853
4854 f_init(1, true);
4855 f_sleep(1.0);
4856
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004857 f_ctrs_bsc_and_bts_init();
4858
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004859 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_no_msc_response));
4860 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004861
4862 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4863 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4864 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4865 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
4866 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
4867 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
4868 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004869 f_shutdown_helper();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004870}
4871
4872/* BSC asks for inter-BSC HO, receives BSSMAP Handover Command, but MS reports
4873 * RR Handover Failure. */
4874private function f_tc_ho_out_fail_rr_ho_failure(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01004875 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004876
4877 var PDU_BSSAP ass_req := f_gen_ass_req();
4878 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4879 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4880 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4881 f_establish_fully(ass_req, exp_compl);
4882
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004883 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004884 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
4885
4886 BSSAP.receive(tr_BSSMAP_HandoverRequired);
4887
4888 f_sleep(0.5);
4889 /* The MSC negotiates Handover Request and Handover Request Ack with
4890 * the other BSS and comes back with a BSSMAP Handover Command
4891 * containing an RR Handover Command coming from the target BSS... */
4892
4893 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
4894 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
4895 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
4896 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
4897 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
4898
4899 /* expect the Handover Command to go out on RR */
4900 var RSL_Message rsl_ho_cmd
4901 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
4902 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
4903 var RSL_IE_Body rsl_ho_cmd_l3;
4904 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
4905 log("RSL message contains no L3 Info IE, expected RR Handover Command");
4906 setverdict(fail);
4907 } else {
4908 log("Found L3 Info: ", rsl_ho_cmd_l3);
4909 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
4910 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
4911 setverdict(fail);
4912 } else {
4913 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
4914 setverdict(pass);
4915 }
4916 }
4917
4918 f_sleep(0.2);
4919 f_rsl_send_l3(ts_RRM_HandoverFailure('00'O));
4920
4921 /* Should tell the MSC about the failure */
4922 BSSAP.receive(tr_BSSMAP_HandoverFailure);
4923
4924 f_sleep(1.0);
4925
Vadim Yanitskiy74ae5eb2020-10-01 22:13:29 +07004926 f_mo_l3_transceive();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004927 f_sleep(1.0);
4928
4929 setverdict(pass);
4930 f_sleep(1.0);
4931}
4932testcase TC_ho_out_fail_rr_ho_failure() runs on test_CT {
4933 var MSC_ConnHdlr vc_conn;
4934
4935 f_init(1, true);
4936 f_sleep(1.0);
4937
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004938 f_ctrs_bsc_and_bts_init();
4939
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004940 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_rr_ho_failure));
4941 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004942
4943 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4944 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4945 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4946 f_ctrs_bsc_and_bts_add(0, "handover:failed");
4947 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
4948 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:failed");
4949 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004950 f_shutdown_helper();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004951}
4952
Neels Hofmeyr10f2bfa2019-07-09 19:33:29 +02004953/* BSC asks for inter-BSC-out HO, receives BSSMAP Handover Command, but then no reply is received about HO outcome
4954 * (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 +02004955 * and the lchan is released. */
4956private function f_tc_ho_out_fail_no_result_after_ho_cmd(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01004957 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004958
4959 var PDU_BSSAP ass_req := f_gen_ass_req();
4960 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4961 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4962 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4963 f_establish_fully(ass_req, exp_compl);
4964
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004965 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004966 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
4967
4968 BSSAP.receive(tr_BSSMAP_HandoverRequired);
4969
4970 f_sleep(0.5);
4971 /* The MSC negotiates Handover Request and Handover Request Ack with
4972 * the other BSS and comes back with a BSSMAP Handover Command
4973 * containing an RR Handover Command coming from the target BSS... */
4974
4975 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
4976 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
4977 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
4978 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
4979 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
4980
4981 /* expect the Handover Command to go out on RR */
4982 var RSL_Message rsl_ho_cmd
4983 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
4984 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
4985 var RSL_IE_Body rsl_ho_cmd_l3;
4986 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
4987 log("RSL message contains no L3 Info IE, expected RR Handover Command");
4988 setverdict(fail);
4989 } else {
4990 log("Found L3 Info: ", rsl_ho_cmd_l3);
4991 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
4992 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
4993 setverdict(fail);
4994 } else {
4995 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
4996 setverdict(pass);
4997 }
4998 }
4999
Neels Hofmeyr10f2bfa2019-07-09 19:33:29 +02005000 /* We get neither success nor failure report from the remote BSS. Eventually T8 times out and we run into 3GPP
5001 * TS 48.008 3.1.5.3.3 "Abnormal Conditions": Clear Request should go to the MSC, and RR should be released
5002 * after Clear Command */
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005003
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005004 var PDU_BSSAP rx_clear_request;
Neels Hofmeyre1797aa2019-07-09 19:34:04 +02005005 BSSAP.receive(tr_BSSMAP_ClearRequest) -> value rx_clear_request;
5006 log("Got BSSMAP Clear Request");
5007 /* Instruct BSC to clear channel */
5008 var BssmapCause cause := bit2int(rx_clear_request.pdu.bssmap.clearRequest.cause.causeValue);
5009 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5010
5011 var MgcpCommand mgcp;
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005012 interleave {
Neels Hofmeyr861a4c12018-11-07 01:23:17 +01005013 [] RSL.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
5014 log("Got Deact SACCH");
5015 }
Harald Welte924b6ea2019-02-04 01:05:34 +01005016 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
Neels Hofmeyr211169d2018-11-07 00:37:29 +01005017 log("Got RR Release");
5018 }
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005019 [] RSL.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
5020 log("Got RF Chan Rel");
5021 RSL.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
5022 }
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005023 }
5024
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005025 f_expect_dlcx_conns();
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02005026
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005027 setverdict(pass);
5028 f_sleep(1.0);
5029}
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02005030testcase TC_ho_out_fail_no_result_after_ho_cmd() runs on test_CT {
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005031 var MSC_ConnHdlr vc_conn;
5032
5033 f_init(1, true);
5034 f_sleep(1.0);
5035
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005036 f_ctrs_bsc_and_bts_init();
5037
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02005038 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_no_result_after_ho_cmd));
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005039 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005040
5041 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5042 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5043 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5044 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
5045 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
5046 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
5047 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005048 f_shutdown_helper();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005049}
5050
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005051private function f_tc_ho_into_this_bsc(charstring id) runs on MSC_ConnHdlr {
5052 /* Hack: the proper way would be to wait for the BSSMAP Handover Request ACK and extract the
5053 * actual assigned chan_nr from its L3 (RR Handover Command) message. But osmo-bsc starts acting
5054 * on the lchan even before we get a chance to evaluate the BSSMAP Handover Request ACK. So we
5055 * need to assume that osmo-bsc will activate TS 1 and already set up this lchan's RSL emulation
5056 * before we get started. */
5057 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
5058 f_rslem_register(0, new_chan_nr);
5059 g_chan_nr := new_chan_nr;
5060 f_sleep(1.0);
5061
5062 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
5063 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5064 activate(as_Media());
5065
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005066 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Pau Espin Pedrol07866632020-09-03 19:10:55 +02005067 f_gen_handover_req(aoip_tla := g_pars.host_aoip_tla)));
Harald Welte6811d102019-04-14 22:23:14 +02005068 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005069
5070 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
5071
5072 var PDU_BSSAP rx_bssap;
5073 var octetstring ho_command_str;
5074
5075 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
Pau Espin Pedrol76ba5412019-06-10 11:00:33 +02005076
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005077 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
5078 log("Received L3 Info in HO Request Ack: ", ho_command_str);
5079 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
5080 log("L3 Info in HO Request Ack is ", ho_command);
5081
5082 var GsmArfcn arfcn;
5083 var RslChannelNr actual_new_chan_nr;
5084 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
5085 actual_new_chan_nr, arfcn);
5086
5087 if (actual_new_chan_nr != new_chan_nr) {
5088 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
5089 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
5090 setverdict(fail);
5091 return;
5092 }
5093 log("Handover Command chan_nr is", actual_new_chan_nr);
5094
5095 /* Now the MSC forwards the RR Handover Command to the other BSC, which
5096 * tells the MS to handover to the new lchan. Here comes the new MS on
5097 * the new lchan with a Handover RACH: */
5098
5099 /* send handover detect */
5100
5101 RSL.send(ts_RSL_HANDO_DET(new_chan_nr));
5102
5103 BSSAP.receive(tr_BSSMAP_HandoverDetect);
5104
5105 /* send handover complete over the new channel */
5106
5107 var PDU_ML3_MS_NW l3_tx := valueof(ts_RRM_HandoverComplete('00'O));
5108 RSL.send(ts_RSL_EST_IND(new_chan_nr, valueof(ts_RslLinkID_DCCH(0)),
5109 enc_PDU_ML3_MS_NW(l3_tx)));
5110
5111 BSSAP.receive(tr_BSSMAP_HandoverComplete);
5112 setverdict(pass);
5113}
Pau Espin Pedrol07866632020-09-03 19:10:55 +02005114function f_tc_ho_into_this_bsc_main(TestHdlrParams pars) runs on test_CT {
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005115 var MSC_ConnHdlr vc_conn;
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005116
5117 f_init(1, true);
5118 f_sleep(1.0);
5119
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005120 f_ctrs_bsc_and_bts_init();
5121
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005122 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5123 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005124
5125 vc_conn := f_start_handler(refers(f_tc_ho_into_this_bsc), pars);
5126 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005127
5128 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5129 f_ctrs_bsc_and_bts_add(0, "handover:completed");
5130 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
5131 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:completed");
5132 f_ctrs_bsc_and_bts_verify();
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01005133 f_shutdown_helper();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005134}
5135
Pau Espin Pedrol07866632020-09-03 19:10:55 +02005136testcase TC_ho_into_this_bsc() runs on test_CT {
5137 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5138 f_tc_ho_into_this_bsc_main(pars);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005139 f_shutdown_helper();
Pau Espin Pedrol07866632020-09-03 19:10:55 +02005140}
5141
5142testcase TC_ho_into_this_bsc_tla_v6() runs on test_CT {
5143 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5144 pars.host_aoip_tla := "::6";
5145 f_tc_ho_into_this_bsc_main(pars);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005146 f_shutdown_helper();
Pau Espin Pedrol07866632020-09-03 19:10:55 +02005147}
5148
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005149private function f_tc_ho_in_fail_msc_clears(charstring id) runs on MSC_ConnHdlr {
5150 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
5151 f_rslem_register(0, new_chan_nr);
5152 g_chan_nr := new_chan_nr;
5153 f_sleep(1.0);
5154
5155 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
5156 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5157 activate(as_Media());
5158
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005159 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005160 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02005161 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005162
5163 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
5164
5165 var PDU_BSSAP rx_bssap;
5166 var octetstring ho_command_str;
5167
5168 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
5169
5170 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
5171 log("Received L3 Info in HO Request Ack: ", ho_command_str);
5172 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
5173 log("L3 Info in HO Request Ack is ", ho_command);
5174
5175 var GsmArfcn arfcn;
5176 var RslChannelNr actual_new_chan_nr;
5177 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
5178 actual_new_chan_nr, arfcn);
5179
5180 if (actual_new_chan_nr != new_chan_nr) {
5181 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
5182 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
5183 setverdict(fail);
5184 return;
5185 }
5186 log("Handover Command chan_nr is", actual_new_chan_nr);
5187
Neels Hofmeyr61ca08d2019-05-06 23:52:22 +02005188 /* For deterministic test results, give some time for the MGW endpoint to be configured */
5189 f_sleep(1.0);
5190
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005191 /* Now the MSC forwards the RR Handover Command to the other BSC, which
5192 * tells the MS to handover to the new lchan. In this case, the MS
5193 * reports a Handover Failure to the old BSS, which forwards a BSSMAP
5194 * Handover Failure to the MSC. The procedure according to 3GPP TS
5195 * 48.008 3.1.5.3.2 "Handover Failure" is then that the MSC sends a
5196 * BSSMAP Clear Command: */
5197
5198 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
5199 var BssmapCause cause := enum2int(cause_val);
5200 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5201
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005202 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005203 setverdict(pass);
5204 f_sleep(1.0);
5205
5206 setverdict(pass);
5207}
5208testcase TC_ho_in_fail_msc_clears() runs on test_CT {
5209 var MSC_ConnHdlr vc_conn;
5210 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5211
5212 f_init(1, true);
5213 f_sleep(1.0);
5214
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005215 f_ctrs_bsc_and_bts_init();
5216
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005217 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5218 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005219
5220 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_msc_clears), pars);
5221 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005222
5223 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5224 f_ctrs_bsc_and_bts_add(0, "handover:stopped");
5225 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
5226 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:stopped");
5227 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005228 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005229}
5230
5231private function f_tc_ho_in_fail_msc_clears_after_ho_detect(charstring id) runs on MSC_ConnHdlr {
5232 /* Hack: the proper way would be to wait for the BSSMAP Handover Request ACK and extract the
5233 * actual assigned chan_nr from its L3 (RR Handover Command) message. But osmo-bsc starts acting
5234 * on the lchan even before we get a chance to evaluate the BSSMAP Handover Request ACK. So we
5235 * need to assume that osmo-bsc will activate TS 1 and already set up this lchan's RSL emulation
5236 * before we get started. */
5237 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
5238 f_rslem_register(0, new_chan_nr);
5239 g_chan_nr := new_chan_nr;
5240 f_sleep(1.0);
5241
5242 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
5243 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5244 activate(as_Media());
5245
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005246 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005247 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02005248 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005249
5250 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
5251
5252 var PDU_BSSAP rx_bssap;
5253 var octetstring ho_command_str;
5254
5255 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
5256
5257 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
5258 log("Received L3 Info in HO Request Ack: ", ho_command_str);
5259 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
5260 log("L3 Info in HO Request Ack is ", ho_command);
5261
5262 var GsmArfcn arfcn;
5263 var RslChannelNr actual_new_chan_nr;
5264 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
5265 actual_new_chan_nr, arfcn);
5266
5267 if (actual_new_chan_nr != new_chan_nr) {
5268 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
5269 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
5270 setverdict(fail);
5271 return;
5272 }
5273 log("Handover Command chan_nr is", actual_new_chan_nr);
5274
5275 /* Now the MSC forwards the RR Handover Command to the other BSC, which
5276 * tells the MS to handover to the new lchan. Here comes the new MS on
5277 * the new lchan with a Handover RACH: */
5278
5279 /* send handover detect */
5280
5281 RSL.send(ts_RSL_HANDO_DET(new_chan_nr));
5282
5283 BSSAP.receive(tr_BSSMAP_HandoverDetect);
5284
5285 /* The MSC chooses to clear the connection now, maybe we got the
5286 * Handover RACH on the new cell but the MS still signaled Handover
5287 * Failure to the old BSS? */
5288
5289 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
5290 var BssmapCause cause := enum2int(cause_val);
5291 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5292
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005293 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005294 f_sleep(1.0);
5295}
5296testcase TC_ho_in_fail_msc_clears_after_ho_detect() runs on test_CT {
5297 var MSC_ConnHdlr vc_conn;
5298 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5299
5300 f_init(1, true);
5301 f_sleep(1.0);
5302
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005303 f_ctrs_bsc_and_bts_init();
5304
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005305 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5306 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005307
5308 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_msc_clears_after_ho_detect), pars);
5309 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005310
5311 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5312 f_ctrs_bsc_and_bts_add(0, "handover:stopped");
5313 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
5314 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:stopped");
5315 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005316 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005317}
5318
5319/* The new BSS's lchan times out before the MSC decides that handover failed. */
5320private function f_tc_ho_in_fail_no_detect(charstring id) runs on MSC_ConnHdlr {
5321 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
5322 f_rslem_register(0, new_chan_nr);
5323 g_chan_nr := new_chan_nr;
5324 f_sleep(1.0);
5325
5326 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
5327 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5328 activate(as_Media());
5329
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005330 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005331 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02005332 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005333
5334 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
5335
5336 var PDU_BSSAP rx_bssap;
5337 var octetstring ho_command_str;
5338
5339 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
5340
5341 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
5342 log("Received L3 Info in HO Request Ack: ", ho_command_str);
5343 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
5344 log("L3 Info in HO Request Ack is ", ho_command);
5345
5346 var GsmArfcn arfcn;
5347 var RslChannelNr actual_new_chan_nr;
5348 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
5349 actual_new_chan_nr, arfcn);
5350
5351 if (actual_new_chan_nr != new_chan_nr) {
5352 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
5353 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
5354 setverdict(fail);
5355 return;
5356 }
5357 log("Handover Command chan_nr is", actual_new_chan_nr);
5358
5359 /* Now the MSC forwards the RR Handover Command to the other BSC, which
5360 * tells the MS to handover to the new lchan. But the MS never shows up
5361 * on the new lchan. */
5362
5363 BSSAP.receive(tr_BSSMAP_HandoverFailure);
5364
5365 /* Did osmo-bsc also send a Clear Request? */
5366 timer T := 0.5;
5367 T.start;
5368 alt {
5369 [] BSSAP.receive(tr_BSSMAP_ClearRequest);
5370 [] T.timeout { }
5371 }
5372
5373 /* MSC plays along with a Clear Command (no matter whether osmo-bsc
5374 * asked for it, this is a Handover Failure after all). */
5375
5376 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
5377 var BssmapCause cause := enum2int(cause_val);
5378 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5379
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005380 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005381 f_sleep(1.0);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005382}
5383testcase TC_ho_in_fail_no_detect() runs on test_CT {
5384 var MSC_ConnHdlr vc_conn;
5385 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5386
5387 f_init(1, true);
5388 f_sleep(1.0);
5389
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005390 f_ctrs_bsc_and_bts_init();
5391
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005392 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5393 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005394
5395 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_no_detect), pars);
5396 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005397
5398 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5399 f_ctrs_bsc_and_bts_add(0, "handover:error");
5400 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
5401 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:error");
5402 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005403 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005404}
5405
5406/* Same as f_tc_ho_in_fail_no_detect, but MSC fails to send a Clear Command */
5407private function f_tc_ho_in_fail_no_detect2(charstring id) runs on MSC_ConnHdlr {
5408 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
5409 f_rslem_register(0, new_chan_nr);
5410 g_chan_nr := new_chan_nr;
5411 f_sleep(1.0);
5412
5413 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
5414 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5415 activate(as_Media());
5416
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005417 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005418 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02005419 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005420
5421 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
5422
5423 var PDU_BSSAP rx_bssap;
5424 var octetstring ho_command_str;
5425
5426 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
5427
5428 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
5429 log("Received L3 Info in HO Request Ack: ", ho_command_str);
5430 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
5431 log("L3 Info in HO Request Ack is ", ho_command);
5432
5433 var GsmArfcn arfcn;
5434 var RslChannelNr actual_new_chan_nr;
5435 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
5436 actual_new_chan_nr, arfcn);
5437
5438 if (actual_new_chan_nr != new_chan_nr) {
5439 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
5440 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
5441 setverdict(fail);
5442 return;
5443 }
5444 log("Handover Command chan_nr is", actual_new_chan_nr);
5445
5446 /* Now the MSC forwards the RR Handover Command to the other BSC, which
5447 * tells the MS to handover to the new lchan. But the MS never shows up
5448 * on the new lchan. */
5449
5450 BSSAP.receive(tr_BSSMAP_HandoverFailure);
5451
5452 /* MSC plays dumb and sends no Clear Command */
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005453 var PDU_BSSAP rx_clear_request;
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02005454
5455 BSSAP.receive(tr_BSSMAP_ClearRequest) -> value rx_clear_request {
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005456 var BssmapCause cause := bit2int(rx_clear_request.pdu.bssmap.clearRequest.cause.causeValue);
5457 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5458 };
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005459 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005460 f_sleep(1.0);
5461}
5462testcase TC_ho_in_fail_no_detect2() runs on test_CT {
5463 var MSC_ConnHdlr vc_conn;
5464 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5465
5466 f_init(1, true);
5467 f_sleep(1.0);
5468
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005469 f_ctrs_bsc_and_bts_init();
5470
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005471 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5472 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005473
5474 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_no_detect2), pars);
5475 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005476
5477 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5478 f_ctrs_bsc_and_bts_add(0, "handover:error");
5479 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
5480 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:error");
5481 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005482 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005483}
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005484
Neels Hofmeyr91401012019-07-11 00:42:35 +02005485type record of charstring Commands;
5486
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005487private function f_bts_0_cfg(TELNETasp_PT pt, Commands cmds := {})
Neels Hofmeyr91401012019-07-11 00:42:35 +02005488{
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005489 f_vty_enter_cfg_bts(pt, 0);
Neels Hofmeyr91401012019-07-11 00:42:35 +02005490 for (var integer i := 0; i < sizeof(cmds); i := i+1) {
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005491 f_vty_transceive(pt, cmds[i]);
Neels Hofmeyr91401012019-07-11 00:42:35 +02005492 }
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005493 f_vty_transceive(pt, "end");
Neels Hofmeyr91401012019-07-11 00:42:35 +02005494}
5495
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01005496private function f_cs7_inst_0_cfg(TELNETasp_PT pt, Commands cmds := {})
5497{
5498 f_vty_enter_cfg_cs7_inst(pt, 0);
5499 for (var integer i := 0; i < sizeof(cmds); i := i+1) {
5500 f_vty_transceive(pt, cmds[i]);
5501 }
5502 f_vty_transceive(pt, "end");
5503}
5504
Neels Hofmeyr91401012019-07-11 00:42:35 +02005505private function f_probe_for_handover(charstring log_label,
5506 charstring log_descr,
5507 charstring handover_vty_cmd,
5508 boolean expect_handover,
5509 boolean is_inter_bsc_handover := false)
5510runs on MSC_ConnHdlr
5511{
Neels Hofmeyrb3fc8982020-05-11 00:16:42 +02005512 /* We're going to thwart any and all handover attempts, just be ready to handle (and ignore) handover target
5513 * lchans to be established on bts 1 or bts 2. */
5514 f_rslem_suspend(RSL1_PROC);
5515 f_rslem_suspend(RSL2_PROC);
5516
Neels Hofmeyr91401012019-07-11 00:42:35 +02005517 var RSL_Message rsl;
5518
5519 var charstring log_msg := " (expecting handover)"
5520 if (not expect_handover) {
5521 log_msg := " (expecting NO handover)";
5522 }
5523 log("f_probe_for_handover starting: " & log_label & ": " & log_descr & log_msg);
5524 f_vty_transceive(BSCVTY, handover_vty_cmd);
5525
Neels Hofmeyr91401012019-07-11 00:42:35 +02005526 timer T := 2.0;
5527 T.start;
5528
5529 alt {
5530 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr)) -> value rsl {
5531 var PDU_ML3_NW_MS l3 := dec_PDU_ML3_NW_MS(rsl.ies[2].body.l3_info.payload);
5532 log("Rx L3 from net: ", l3);
5533 if (ischosen(l3.msgs.rrm.handoverCommand)) {
5534 var RslChannelNr new_chan_nr;
5535 var GsmArfcn arfcn;
5536 f_ChDesc2RslChanNr(l3.msgs.rrm.handoverCommand.channelDescription2,
5537 new_chan_nr, arfcn);
5538 log("Handover to new chan ", new_chan_nr, " on ARFCN ", arfcn);
5539 log(l3.msgs.rrm.handoverCommand);
5540
5541 /* Need to register for new lchan on new BTS -- it's either bts 1 or bts 2. It doesn't really
5542 * matter on which BTS it really is, we're not going to follow through an entire handover
5543 * anyway. */
5544 f_rslem_register(0, new_chan_nr, RSL1_PROC);
5545 f_rslem_resume(RSL1_PROC);
5546 f_rslem_register(0, new_chan_nr, RSL2_PROC);
5547 f_rslem_resume(RSL2_PROC);
5548
5549 if (expect_handover and not is_inter_bsc_handover) {
5550 setverdict(pass);
5551 log("f_probe_for_handover(" & log_label & "): Got RSL Handover Command as expected.");
5552 } else {
5553 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected none, but got RSL Handover Command. "
5554 & log_label & ": " & log_descr);
5555 }
5556
5557 log("f_probe_for_handover(" & log_label & "): Ending the test: Handover Failure stops the procedure.");
5558 /* osmo-bsc has triggered Handover. That's all we need to know for this test, reply with
5559 * Handover Failure. */
5560 f_rsl_send_l3(ts_RRM_HandoverFailure('00'O));
5561
5562 /* target BTS is told to release lchan again; don't care which BTS nor what messages. */
5563 f_sleep(0.5);
5564 RSL1.clear;
5565 RSL2.clear;
5566 log("f_probe_for_handover(" & log_label & "): done (got RSL Handover Command)");
5567 break;
5568 } else {
5569 repeat;
5570 }
5571 }
5572 [] BSSAP.receive(tr_BSSMAP_HandoverRequired) {
5573 if (expect_handover and is_inter_bsc_handover) {
5574 setverdict(pass);
5575 log("f_probe_for_handover(" & log_label & "): Got BSSMAP Handover Required as expected.");
5576 } else {
5577 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected none, but got BSSMAP Handover Required. "
5578 & log_label & ": " & log_descr);
5579 }
5580
5581 log("f_probe_for_handover(" & log_label & "): done (got BSSMAP Handover Required)");
5582
5583 /* Note: f_tc_ho_neighbor_config_start() sets T7, the timeout for BSSMAP Handover Required, to
5584 * 1 second. There is no legal way to quickly abort a handover after a BSSMAP Handover Required,
5585 * setting a short timeout and waiting is the only way. */
5586 log("f_probe_for_handover(" & log_label & "): waiting for inter-BSC HO to time out...");
5587 f_sleep(1.5);
5588 log("f_probe_for_handover(" & log_label & "): ...done");
5589
5590 break;
5591 }
5592 [] T.timeout {
5593 if (expect_handover) {
5594 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected Handover, but got none. "
5595 & log_label & ": " & log_descr);
5596 } else {
5597 setverdict(pass);
5598 log("f_probe_for_handover(" & log_label & "): Got no Handover, as expected.");
5599 }
5600 log("f_probe_for_handover(" & log_label & "): done (got no Handover)");
5601 break;
5602 }
5603 }
5604
5605 f_rslem_resume(RSL1_PROC);
5606 f_rslem_resume(RSL2_PROC);
5607 f_sleep(3.0);
5608 RSL.clear;
5609
5610 log("f_probe_for_handover(" & log_label & "): done clearing");
5611}
5612
5613/* Test the effect of various neighbor configuration scenarios:
5614 *
5615 * To avoid complexity, block off any actual handover operation, and always remain on the lchan at bts 0.
5616 * Reconfigure the neighbors for bts 0, trigger a Handover, and probe whether osmo-bsc does or doesn't start HO.
5617 */
5618private function f_tc_ho_neighbor_config_start() runs on MSC_ConnHdlr {
5619 g_pars := f_gen_test_hdlr_pars();
5620 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
5621 var PDU_BSSAP ass_cmd := f_gen_ass_req();
5622 const OCT8 kc := '0001020304050607'O;
5623
5624 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
5625 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
5626
5627 /* Establish lchan at bts 0 */
5628 f_establish_fully(ass_cmd, exp_compl);
5629
5630 /* Shorten the inter-BSC Handover timeout, to not wait so long for inter-BSC Handovers */
5631 f_vty_enter_cfg_network(BSCVTY);
5632 f_vty_transceive(BSCVTY, "timer T7 1");
5633 f_vty_transceive(BSCVTY, "end");
5634}
5635
5636private function f_tc_ho_neighbor_config_1(charstring id) runs on MSC_ConnHdlr {
5637 f_tc_ho_neighbor_config_start();
5638
5639 /*
5640 * bts 0 ARFCN 871 BSIC 10
5641 * bts 1 ARFCN 871 BSIC 11
5642 * bts 2 ARFCN 871 BSIC 12
5643 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5644 */
5645
5646 log("f_tc_ho_neighbor_config: 1. No 'neighbor' config");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005647 f_bts_0_cfg(BSCVTY, {"no neighbors"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005648 f_probe_for_handover("1.a", "HO to bts 1 works, implicitly listed as neighbor (legacy behavior when none are configured)",
5649 "handover any to arfcn 871 bsic 11",
5650 true);
5651
5652 f_probe_for_handover("1.b", "HO to unknown cell does not start",
5653 "handover any to arfcn 13 bsic 39",
5654 false);
5655
5656 f_probe_for_handover("1.c", "HO to 871-12 is ambiguous = error",
5657 "handover any to arfcn 871 bsic 12",
5658 false);
5659
5660 f_probe_for_handover("1.d", "HO to 871-11 still works (verify that this test properly cleans up)",
5661 "handover any to arfcn 871 bsic 11",
5662 true);
5663}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005664testcase TC_ho_neighbor_config_1() runs on test_CT {
5665 var MSC_ConnHdlr vc_conn;
5666 f_init(3, true, guard_timeout := 60.0);
5667 f_sleep(1.0);
5668 f_ctrs_bsc_and_bts_init();
5669 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_1));
5670 vc_conn.done;
5671
5672 /* f_tc_ho_neighbor_config_start() */
5673 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5674 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5675
5676 /* 1.a */
5677 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
5678 * handover quickly by sending a Handover Failure message. */
5679 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5680 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5681 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5682 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
5683
5684 /* 1.b */
5685 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5686 f_ctrs_bsc_and_bts_add(0, "handover:error");
5687
5688 /* 1.c */
5689 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5690 f_ctrs_bsc_and_bts_add(0, "handover:error");
5691
5692 /* 1.d */
5693 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5694 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5695 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5696 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
5697
5698 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005699 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005700}
5701
Neels Hofmeyr91401012019-07-11 00:42:35 +02005702private function f_tc_ho_neighbor_config_2(charstring id) runs on MSC_ConnHdlr {
5703 f_tc_ho_neighbor_config_start();
5704
5705 /*
5706 * bts 0 ARFCN 871 BSIC 10
5707 * bts 1 ARFCN 871 BSIC 11
5708 * bts 2 ARFCN 871 BSIC 12
5709 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5710 */
5711
5712 log("f_tc_ho_neighbor_config: 2. explicit local neighbor: 'neighbor bts 1'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005713 f_bts_0_cfg(BSCVTY, {"neighbor bts 1"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005714 f_sleep(0.5);
5715
5716 f_probe_for_handover("2.a", "HO to bts 1 works, explicitly listed as neighbor",
5717 "handover any to arfcn 871 bsic 11",
5718 true);
5719
5720 f_probe_for_handover("2.b", "HO to bts 2 doesn't work, not listed as neighbor",
5721 "handover any to arfcn 871 bsic 12",
5722 false);
5723}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005724testcase TC_ho_neighbor_config_2() runs on test_CT {
5725 var MSC_ConnHdlr vc_conn;
5726 f_init(3, true, guard_timeout := 50.0);
5727 f_sleep(1.0);
5728 f_ctrs_bsc_and_bts_init();
5729 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_2));
5730 vc_conn.done;
5731
5732 /* f_tc_ho_neighbor_config_start() */
5733 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5734 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5735
5736 /* 2.a */
5737 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
5738 * handover quickly by sending a Handover Failure message. */
5739 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5740 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5741 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5742 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
5743
5744 /* 2.b */
5745 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5746 f_ctrs_bsc_and_bts_add(0, "handover:error");
5747
5748 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005749 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005750}
5751
Neels Hofmeyr91401012019-07-11 00:42:35 +02005752private function f_tc_ho_neighbor_config_3(charstring id) runs on MSC_ConnHdlr {
5753 f_tc_ho_neighbor_config_start();
5754
5755 /*
5756 * bts 0 ARFCN 871 BSIC 10
5757 * bts 1 ARFCN 871 BSIC 11
5758 * bts 2 ARFCN 871 BSIC 12
5759 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5760 */
5761
5762 log("f_tc_ho_neighbor_config: 3. explicit local neighbor: 'neighbor bts 2'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005763 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor bts 2"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005764 f_sleep(0.5);
5765
5766 f_probe_for_handover("3.a", "HO to bts 1 doesn't work, not listed as neighbor",
5767 "handover any to arfcn 871 bsic 11",
5768 false);
5769 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",
5770 "handover any to arfcn 871 bsic 12",
5771 true);
5772}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005773testcase TC_ho_neighbor_config_3() runs on test_CT {
5774 var MSC_ConnHdlr vc_conn;
5775 f_init(3, true, guard_timeout := 50.0);
5776 f_sleep(1.0);
5777 f_ctrs_bsc_and_bts_init();
5778 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_3));
5779 vc_conn.done;
5780
5781 /* f_tc_ho_neighbor_config_start() */
5782 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5783 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5784
5785 /* 3.a */
5786 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5787 f_ctrs_bsc_and_bts_add(0, "handover:error");
5788
5789 /* 3.b */
5790 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
5791 * handover quickly by sending a Handover Failure message. */
5792 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5793 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5794 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5795 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
5796
5797 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005798 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005799}
5800
Neels Hofmeyr91401012019-07-11 00:42:35 +02005801private function f_tc_ho_neighbor_config_4(charstring id) runs on MSC_ConnHdlr {
5802 f_tc_ho_neighbor_config_start();
5803
5804 /*
5805 * bts 0 ARFCN 871 BSIC 10
5806 * bts 1 ARFCN 871 BSIC 11
5807 * bts 2 ARFCN 871 BSIC 12
5808 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5809 */
5810
5811 log("f_tc_ho_neighbor_config: 4. explicit remote neighbor: 'neighbor lac 99 arfcn 123 bsic 45'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005812 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor lac 99 arfcn 123 bsic 45"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005813 f_sleep(0.5);
5814
5815 f_probe_for_handover("4.a", "HO to bts 1 doesn't work, not listed as neighbor",
5816 "handover any to arfcn 871 bsic 11",
5817 false);
5818 f_probe_for_handover("4.b", "HO to bts 2 doesn't work, not listed as neighbor",
5819 "handover any to arfcn 871 bsic 12",
5820 false);
5821 f_probe_for_handover("4.c", "HO to 123-45 triggers inter-BSC HO",
5822 "handover any to arfcn 123 bsic 45",
5823 true, true);
5824}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005825testcase TC_ho_neighbor_config_4() runs on test_CT {
5826 var MSC_ConnHdlr vc_conn;
5827 f_init(3, true, guard_timeout := 50.0);
5828 f_sleep(1.0);
5829 f_ctrs_bsc_and_bts_init();
5830 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_4));
5831 vc_conn.done;
5832
5833 /* f_tc_ho_neighbor_config_start() */
5834 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5835 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5836
5837 /* 4.a */
5838 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5839 f_ctrs_bsc_and_bts_add(0, "handover:error");
5840
5841 /* 4.b */
5842 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5843 f_ctrs_bsc_and_bts_add(0, "handover:error");
5844
5845 /* 4.c */
5846 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
5847 * handover quickly by timing out after the Handover Required message */
5848 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5849 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
5850 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
5851 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
5852
5853 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005854 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005855}
5856
Neels Hofmeyr91401012019-07-11 00:42:35 +02005857private function f_tc_ho_neighbor_config_5(charstring id) runs on MSC_ConnHdlr {
5858 f_tc_ho_neighbor_config_start();
5859
5860 /*
5861 * bts 0 ARFCN 871 BSIC 10
5862 * bts 1 ARFCN 871 BSIC 11
5863 * bts 2 ARFCN 871 BSIC 12
5864 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5865 */
5866
5867 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 +02005868 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor lac 99 arfcn 871 bsic 12"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005869 f_sleep(0.5);
5870
5871 f_probe_for_handover("5.a", "HO to 871-12 triggers inter-BSC HO (ignoring local cells with same ARFCN+BSIC)",
5872 "handover any to arfcn 871 bsic 12",
5873 true, true);
5874}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005875testcase TC_ho_neighbor_config_5() runs on test_CT {
5876 var MSC_ConnHdlr vc_conn;
5877 f_init(3, true);
5878 f_sleep(1.0);
5879 f_ctrs_bsc_and_bts_init();
5880 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_5));
5881 vc_conn.done;
5882
5883 /* f_tc_ho_neighbor_config_start() */
5884 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5885 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5886
5887 /* 5 */
5888 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
5889 * handover quickly by timing out after the Handover Required message */
5890 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5891 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
5892 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
5893 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
5894
5895 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005896 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005897}
5898
Neels Hofmeyr91401012019-07-11 00:42:35 +02005899private function f_tc_ho_neighbor_config_6(charstring id) runs on MSC_ConnHdlr {
5900 f_tc_ho_neighbor_config_start();
5901
5902 /*
5903 * bts 0 ARFCN 871 BSIC 10
5904 * bts 1 ARFCN 871 BSIC 11
5905 * bts 2 ARFCN 871 BSIC 12
5906 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5907 */
5908
5909 log("f_tc_ho_neighbor_config: 6. config error: explicit local and remote neighbors with ambiguous ARFCN+BSIC:"
5910 & " 'neighbor bts 2; neighbor lac 99 arfcn 871 bsic 12'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005911 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor bts 2", "neighbor lac 99 arfcn 871 bsic 12"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005912 f_sleep(0.5);
5913
5914 f_probe_for_handover("6.a", "HO to 871-12 is ambiguous = error",
5915 "handover any to arfcn 871 bsic 12",
5916 false);
5917}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005918testcase TC_ho_neighbor_config_6() runs on test_CT {
5919 var MSC_ConnHdlr vc_conn;
5920 f_init(3, true);
5921 f_sleep(1.0);
5922 f_ctrs_bsc_and_bts_init();
5923 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_6));
5924 vc_conn.done;
5925
5926 /* f_tc_ho_neighbor_config_start() */
5927 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5928 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5929
5930 /* 6.a */
5931 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
5932 * handover quickly by timing out after the Handover Required message */
5933 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5934 f_ctrs_bsc_and_bts_add(0, "handover:error");
5935
5936 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005937 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005938}
5939
Neels Hofmeyr91401012019-07-11 00:42:35 +02005940private function f_tc_ho_neighbor_config_7(charstring id) runs on MSC_ConnHdlr {
5941 f_tc_ho_neighbor_config_start();
5942
5943 /*
5944 * bts 0 ARFCN 871 BSIC 10
5945 * bts 1 ARFCN 871 BSIC 11
5946 * bts 2 ARFCN 871 BSIC 12
5947 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5948 */
5949
5950 log("f_tc_ho_neighbor_config: 7. explicit local and remote neighbors:"
5951 & " 'neighbor bts 2; neighbor lac 99 arfcn 123 bsic 45'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005952 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor bts 2", "neighbor lac 99 arfcn 123 bsic 45"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005953 f_sleep(0.5);
5954
5955 f_probe_for_handover("7.a", "HO to 871-12 does HO to bts 2",
5956 "handover any to arfcn 871 bsic 12",
5957 true);
5958 f_probe_for_handover("7.b", "HO to 123-45 triggers inter-BSC HO",
5959 "handover any to arfcn 123 bsic 45",
5960 true, true);
5961}
Neels Hofmeyr91401012019-07-11 00:42:35 +02005962testcase TC_ho_neighbor_config_7() runs on test_CT {
5963 var MSC_ConnHdlr vc_conn;
Neels Hofmeyrf2b88032020-06-16 00:35:04 +02005964 f_init(3, true, guard_timeout := 50.0);
Neels Hofmeyr91401012019-07-11 00:42:35 +02005965 f_sleep(1.0);
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005966 f_ctrs_bsc_and_bts_init();
Neels Hofmeyr91401012019-07-11 00:42:35 +02005967 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_7));
5968 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005969
5970 /* f_tc_ho_neighbor_config_start() */
5971 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5972 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5973
5974 /* 7.a */
5975 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
5976 * handover quickly by sending a Handover Failure message. */
5977 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5978 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5979 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5980 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
5981
5982 /* 7.b */
5983 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
5984 * handover quickly by timing out after the Handover Required message */
5985 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5986 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
5987 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
5988 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
5989
5990 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005991 f_shutdown_helper();
Neels Hofmeyr91401012019-07-11 00:42:35 +02005992}
5993
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01005994/* OS#3041: Open and close N connections in a normal fashion, and expect no
5995 * BSSMAP Reset just because of that. */
5996testcase TC_bssap_rlsd_does_not_cause_bssmap_reset() runs on test_CT {
5997 var default d;
5998 var integer i;
5999 var DchanTuple dt;
6000
6001 f_init();
6002
6003 /* Wait for initial BSSMAP Reset to pass */
6004 f_sleep(4.0);
6005
6006 d := activate(no_bssmap_reset());
6007
6008 /* Setup up a number of connections and RLSD them again from the MSC
6009 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
6010 * Let's do it some more times for good measure. */
Harald Weltec3260d92018-06-11 17:48:16 +02006011 for (i := 0; i < 4; i := i+1) {
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01006012 /* Since we're doing a lot of runs, give each one a fresh
6013 * T_guard from the top. */
6014 T_guard.start;
6015
6016 /* Setup a BSSAP connection and clear it right away. This is
6017 * the MSC telling the BSC about a planned release, it's not an
6018 * erratic loss of a connection. */
Harald Weltea1897182018-06-11 13:53:09 +02006019 dt := f_est_dchan(int2oct(i,1), 23+i, '00010203040506'O);
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01006020
6021 /* MSC disconnects (RLSD). */
6022 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
6023 }
6024
6025 /* In the buggy behavior, a timeout of 2 seconds happens between above
6026 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
6027 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
6028 f_sleep(4.0);
6029
6030 deactivate(d);
6031 f_shutdown_helper();
6032}
Harald Welte552620d2017-12-16 23:21:36 +01006033
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01006034/* OS#3041: Open and close N connections in a normal fashion, and expect no
6035 * BSSMAP Reset just because of that. Invoke the release by a BSSMAP Clear from
6036 * the MSC. */
6037testcase TC_bssmap_clear_does_not_cause_bssmap_reset() runs on test_CT {
6038 var default d;
6039 var integer i;
6040 var DchanTuple dt;
6041 var BSSAP_N_DATA_ind rx_di;
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01006042 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_CALL_CONTROL;
6043 var BssmapCause cause := enum2int(cause_val);
6044
6045 f_init();
6046
6047 /* Wait for initial BSSMAP Reset to pass */
6048 f_sleep(4.0);
6049
6050 d := activate(no_bssmap_reset());
6051
6052 /* Setup up a number of connections and RLSD them again from the MSC
6053 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
6054 * Let's do it some more times for good measure. */
6055 for (i := 0; i < 8; i := i+1) {
6056 /* Since we're doing a lot of runs, give each one a fresh
6057 * T_guard from the top. */
6058 T_guard.start;
6059
6060 /* Setup a BSSAP connection and clear it right away. This is
6061 * the MSC telling the BSC about a planned release, it's not an
6062 * erratic loss of a connection. */
Harald Weltea1897182018-06-11 13:53:09 +02006063 dt := f_est_dchan(int2oct(i,1), 23+i, '00010203040506'O);
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01006064
6065 /* Instruct BSC to clear channel */
6066 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
6067
6068 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02006069 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01006070 }
6071
6072 /* In the buggy behavior, a timeout of 2 seconds happens between above
6073 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
6074 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
6075 f_sleep(4.0);
6076
6077 deactivate(d);
6078 f_shutdown_helper();
6079}
6080
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01006081/* OS#3041: Open and close N connections in a normal fashion, and expect no
6082 * BSSMAP Reset just because of that. Close connections from the MS side with a
6083 * Release Ind on RSL. */
6084testcase TC_ms_rel_ind_does_not_cause_bssmap_reset() runs on test_CT {
6085 var default d;
6086 var integer i;
6087 var DchanTuple dt;
6088 var BSSAP_N_DATA_ind rx_di;
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01006089 var integer j;
6090
6091 f_init();
6092
6093 /* Wait for initial BSSMAP Reset to pass */
6094 f_sleep(4.0);
6095
6096 d := activate(no_bssmap_reset());
6097
6098 /* Setup up a number of connections and RLSD them again from the MSC
6099 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
6100 * Let's do it some more times for good measure. */
6101 for (i := 0; i < 8; i := i+1) {
6102 /* Since we're doing a lot of runs, give each one a fresh
6103 * T_guard from the top. */
6104 T_guard.start;
6105
6106 /* Setup a BSSAP connection and clear it right away. This is
6107 * the MSC telling the BSC about a planned release, it's not an
6108 * erratic loss of a connection. */
6109 dt := f_est_dchan('23'O, 23, '00010203040506'O);
6110
6111 /* simulate RLL REL IND */
6112 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0))));
6113
6114 /* expect Clear Request on MSC side */
6115 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
6116
6117 /* Instruct BSC to clear channel */
6118 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
6119 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
6120
6121 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02006122 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01006123 }
6124
6125 /* In the buggy behavior, a timeout of 2 seconds happens between above
6126 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
6127 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
6128 f_sleep(4.0);
6129
6130 deactivate(d);
6131 f_shutdown_helper();
6132}
6133
Harald Welte94e0c342018-04-07 11:33:23 +02006134/***********************************************************************
6135 * IPA style dynamic PDCH
6136 ***********************************************************************/
6137
6138private function f_dyn_ipa_pdch_act(integer bts_nr, integer trx_nr, integer ts_nr,
6139 template (omit) RSL_Cause nack := omit)
6140runs on test_CT {
6141 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(ts_nr));
6142 var RSL_Message rsl_unused;
6143 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
6144 f_vty_ts_action("pdch activate", bts_nr, trx_nr, ts_nr);
6145 /* expect the BSC to issue the related RSL command */
6146 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
6147 if (istemplatekind(nack, "omit")) {
6148 /* respond with a related acknowledgement */
6149 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
6150 } else {
6151 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_NACK(chan_nr, valueof(nack)));
6152 }
6153}
6154
6155private function f_dyn_ipa_pdch_deact(integer bts_nr, integer trx_nr, integer ts_nr,
6156 template (omit) RSL_Cause nack := omit)
6157runs on test_CT {
6158 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(ts_nr));
6159 var RSL_Message rsl_unused;
6160 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
6161 f_vty_ts_action("pdch deactivate", bts_nr, trx_nr, ts_nr);
6162 /* expect the BSC to issue the related RSL command */
6163 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_DEACT(chan_nr));
6164 if (istemplatekind(nack, "omit")) {
6165 /* respond with a related acknowledgement */
6166 f_ipa_tx(0, ts_RSL_IPA_PDCH_DEACT_ACK(chan_nr));
6167 } else {
6168 f_ipa_tx(0, ts_RSL_IPA_PDCH_DEACT_NACK(chan_nr, valueof(nack)));
6169 }
6170}
6171
6172private function f_ts_dyn_mode_get(integer bts_nr, integer trx_nr, integer ts_nr)
6173runs on test_CT return charstring {
6174 var charstring cmd, resp;
6175 cmd := "show timeslot "&int2str(bts_nr)&" "&int2str(trx_nr)&" "&int2str(ts_nr);
Stefan Sperlingcff13562018-11-13 15:24:06 +01006176 return f_vty_transceive_match_regexp_retry(BSCVTY, cmd, "*\((*)\)*", 0, 4, 1.0);
Harald Welte94e0c342018-04-07 11:33:23 +02006177}
6178
6179private function f_ts_dyn_mode_assert(integer bts_nr, integer trx_nr, integer ts_nr,
6180 template charstring exp)
6181runs on test_CT {
6182 var charstring mode := f_ts_dyn_mode_get(bts_nr, trx_nr, ts_nr);
6183 if (not match(mode, exp)) {
6184 setverdict(fail, "Unexpected TS Mode: ", mode);
Daniel Willmannafce8662018-07-06 23:11:32 +02006185 mtc.stop;
Harald Welte94e0c342018-04-07 11:33:23 +02006186 }
6187}
6188
6189private function f_ts_set_chcomb(integer bts_nr, integer trx_nr, integer ts_nr, charstring chcomb)
6190runs on test_CT {
6191 f_vty_enter_cfg_ts(BSCVTY, bts_nr, trx_nr, ts_nr);
6192 f_vty_transceive(BSCVTY, "phys_chan_config " & chcomb);
6193 f_vty_transceive(BSCVTY, "end");
6194}
6195
6196private const charstring TCHF_MODE := "TCH/F mode";
6197private const charstring TCHH_MODE := "TCH/H mode";
6198private const charstring PDCH_MODE := "PDCH mode";
6199private const charstring NONE_MODE := "NONE mode";
6200
6201/* Test IPA PDCH activation / deactivation triggered by VTY */
6202testcase TC_dyn_pdch_ipa_act_deact() runs on test_CT {
6203 var RSL_Message rsl_unused;
6204
6205 /* change Timeslot 6 before f_init() starts RSL */
6206 f_init_vty();
6207 f_ts_set_chcomb(0, 0, 6, "TCH/F_PDCH");
6208 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
6209
6210 f_init(1, false);
6211 f_sleep(1.0);
6212
6213 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
6214
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006215 log("TCH/F_PDCH pchan starts out in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02006216 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6217 /* The BSC will activate the dynamic PDCH by default, so confirm that */
6218 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
6219 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
6220 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006221 log("TCH/F_PDCH pchan, PDCH ACT was ACKed, so now in PDCH mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02006222 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
6223
6224 /* De-activate it via VTY */
6225 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
6226 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006227 log("TCH/F_PDCH pchan, PDCH DEACT via VTY, so now back in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02006228 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6229
6230 /* re-activate it via VTY */
6231 f_dyn_ipa_pdch_act(0, 0, chan_nr.tn);
6232 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006233 log("TCH/F_PDCH pchan, PDCH ACT via VTY, so now in PDCH mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02006234 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
6235
6236 /* and finally de-activate it again */
6237 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
6238 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006239 log("TCH/F_PDCH pchan, PDCH DEACT via VTY, so now back in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02006240 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6241
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02006242 /* clean up config */
6243 f_ts_set_chcomb(0, 0, 6, "PDCH");
6244
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006245 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02006246}
6247
6248/* Test IPA PDCH activation NACK */
6249testcase TC_dyn_pdch_ipa_act_nack() runs on test_CT {
6250 var RSL_Message rsl_unused;
6251
6252 /* change Timeslot 6 before f_init() starts RSL */
6253 f_init_vty();
6254 f_ts_set_chcomb(0, 0, 6, "TCH/F_PDCH");
6255 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
6256
6257 f_init(1, false);
6258 f_sleep(1.0);
6259
6260 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
6261
6262 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6263 /* The BSC will activate the dynamic PDCH by default, so confirm that */
6264 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
6265 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
6266 f_sleep(1.0);
6267 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
6268
6269 /* De-activate it via VTY */
6270 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
6271 f_sleep(1.0);
6272 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6273
6274 /* re-activate it via VTY, but fail that; check BSC still assumes TCH/F mode */
6275 f_dyn_ipa_pdch_act(0, 0, chan_nr.tn, RSL_ERR_EQUIPMENT_FAIL);
6276 f_sleep(1.0);
6277 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6278
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02006279 /* clean up config */
6280 f_ts_set_chcomb(0, 0, 6, "PDCH");
6281
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006282 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02006283}
6284
6285
6286/***********************************************************************
6287 * Osmocom style dynamic PDCH
6288 ***********************************************************************/
6289
6290private function f_dyn_osmo_pdch_act(integer bts_nr, integer trx_nr, integer ts_nr,
6291 template (omit) RSL_Cause nack := omit)
6292runs on test_CT {
6293 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(ts_nr));
6294 var RSL_Message rsl_unused;
6295 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
6296 /* FIXME: no VTY command to activate Osmocom PDCH !! */
6297 /* expect the BSC to issue the related RSL command */
6298 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT(chan_nr, ?));
6299 if (istemplatekind(nack, "omit")) {
6300 /* respond with a related acknowledgement */
6301 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342));
6302 } else {
6303 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, valueof(nack)));
6304 }
6305}
6306
6307private function f_dyn_osmo_pdch_deact(integer bts_nr, integer trx_nr, integer ts_nr,
6308 template (omit) RSL_Cause nack := omit)
6309runs on test_CT {
6310 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(ts_nr));
6311 var RSL_Message rsl_unused;
6312 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
6313 /* FIXME: no VTY command to activate Osmocom PDCH !! */
6314 /* expect the BSC to issue the related RSL command */
6315 rsl_unused := f_exp_ipa_rx(0, tr_RSL_RF_CHAN_REL(chan_nr));
6316 if (istemplatekind(nack, "omit")) {
6317 /* respond with a related acknowledgement */
6318 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(chan_nr));
6319 } else {
6320 //f_ipa_tx(0, ts_RSL_RF_CHAN_REL_NACK(chan_nr, valueof(nack)));
6321 }
6322}
6323
6324/* Test Osmocom dyn PDCH activation / deactivation triggered by VTY */
6325testcase TC_dyn_pdch_osmo_act_deact() runs on test_CT {
6326 var RSL_Message rsl_unused;
6327
6328 /* change Timeslot 6 before f_init() starts RSL */
6329 f_init_vty();
6330 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_PDCH");
6331 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
6332
6333 f_init(1, false);
6334 f_sleep(1.0);
6335
6336 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(6));
6337
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006338 log("TCH/F_TCH/H_PDCH pchan starts out in disabled mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02006339 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
6340 /* The BSC will activate the dynamic PDCH by default, so confirm that */
6341 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
6342
6343 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342));
6344 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006345 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 +02006346 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
6347
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02006348 /* clean up config */
6349 f_ts_set_chcomb(0, 0, 6, "PDCH");
6350
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006351 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02006352}
6353
6354/* Test Osmocom dyn PDCH activation NACK behavior */
6355testcase TC_dyn_pdch_osmo_act_nack() runs on test_CT {
6356 var RSL_Message rsl_unused;
6357
6358 /* change Timeslot 6 before f_init() starts RSL */
6359 f_init_vty();
6360 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_PDCH");
6361 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
6362
6363 f_init(1, false);
6364 f_sleep(1.0);
6365
6366 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(6));
6367
6368 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
6369 /* The BSC will activate the dynamic PDCH by default, so confirm that */
6370 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
6371
6372 /* NACK this activation and expect the "show timeslot" mode still to be NONE */
6373 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, RSL_ERR_EQUIPMENT_FAIL));
6374 f_sleep(1.0);
6375 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
6376
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02006377 /* clean up config */
6378 f_ts_set_chcomb(0, 0, 6, "PDCH");
6379
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006380 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02006381}
6382
Stefan Sperling0796a822018-10-05 13:01:39 +02006383testcase TC_chopped_ipa_ping() runs on test_CT {
Stefan Sperling554123f2018-10-09 14:12:30 +02006384 const Integers bsc_ipa_ports := {mp_bsc_rsl_port, mp_bsc_oml_port, mp_bsc_ctrl_port};
Stefan Sperling0796a822018-10-05 13:01:39 +02006385 for (var integer i := 0; i < lengthof(bsc_ipa_ports); i := i + 1) {
6386 IPA_Testing.f_run_TC_chopped_ipa_ping(mp_bsc_ip, bsc_ipa_ports[i], CONNECT_TO_SERVER);
6387 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006388 f_shutdown_helper();
Stefan Sperling0796a822018-10-05 13:01:39 +02006389}
6390
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02006391testcase TC_chopped_ipa_payload() runs on test_CT {
6392 const Integers bsc_ipa_ports := {mp_bsc_rsl_port, mp_bsc_oml_port
6393 /* TODO: mp_bsc_ctrl_port does not work yet */};
6394 for (var integer i := 0; i < lengthof(bsc_ipa_ports); i := i + 1) {
6395 IPA_Testing.f_run_TC_chopped_ipa_payload(mp_bsc_ip, bsc_ipa_ports[i], CONNECT_TO_SERVER);
6396 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006397 f_shutdown_helper();
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02006398}
6399
Pau Espin Pedrol8f773632019-11-05 11:46:53 +01006400/* Verify the BSC sends the MS Power Parameters IE during CHAN ACT to make sure
6401 the BTS does autonomous MS power control loop */
6402testcase TC_assignment_verify_ms_power_params_ie() runs on test_CT {
6403 var MSC_ConnHdlr vc_conn;
6404 var TestHdlrParams pars := f_gen_test_hdlr_pars();
6405 //pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
6406 pars.exp_ms_power_params := true;
6407
6408 f_init(1, true);
6409 f_sleep(1.0);
6410 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
6411 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006412 f_shutdown_helper();
Pau Espin Pedrol8f773632019-11-05 11:46:53 +01006413}
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02006414
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006415/***********************************************************************
6416 * MSC Pooling
6417 ***********************************************************************/
6418
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006419template MobileIdentityLV ts_MI_TMSI_NRI_LV(integer nri_v, integer nri_bitlen := 10) :=
Harald Weltebf397612021-01-14 20:39:46 +01006420 ts_MI_TMSI_LV(tmsi := f_gen_tmsi(suffix := 0, nri_v := nri_v, nri_bitlen := nri_bitlen));
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006421
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02006422private function f_expect_lchan_rel(RSL_DCHAN_PT rsl) runs on MSC_ConnHdlr {
6423 interleave {
6424 [] rsl.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
6425 f_logp(BSCVTY, "Got RSL RR Release");
6426 }
6427 [] rsl.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
6428 f_logp(BSCVTY, "Got RSL Deact SACCH");
6429 }
6430 [] rsl.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
6431 f_logp(BSCVTY, "Got RSL RF Chan Rel, sending Rel Ack");
6432 rsl.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
6433 break;
6434 }
6435 }
6436}
6437
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006438private function f_perform_clear(RSL_DCHAN_PT rsl) runs on MSC_ConnHdlr {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006439 f_logp(BSCVTY, "MSC instructs BSC to clear channel");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006440 BSSAP.send(ts_BSSMAP_ClearCommand(0));
6441 interleave {
6442 [] rsl.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006443 f_logp(BSCVTY, "Got RSL RR Release");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006444 }
6445 [] rsl.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006446 f_logp(BSCVTY, "Got RSL Deact SACCH");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006447 }
6448 [] BSSAP.receive(tr_BSSMAP_ClearComplete) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006449 f_logp(BSCVTY, "Got BSSMAP Clear Complete");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006450 /* Also drop the SCCP connection */
6451 BSSAP.send(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_REQ);
6452 }
6453 [] rsl.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006454 f_logp(BSCVTY, "Got RSL RF Chan Rel, sending Rel Ack");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006455 rsl.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
6456 }
6457 }
6458}
6459
Neels Hofmeyr66e15092020-10-12 18:44:41 +00006460private function f_perform_compl_l3(RSL_DCHAN_PT rsl, template PDU_ML3_MS_NW l3_info, boolean do_clear := true, boolean expect_bssmap_l3 := true)
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006461runs on MSC_ConnHdlr {
6462 timer T := 10.0;
6463 var octetstring l3_enc := enc_PDU_ML3_MS_NW(valueof(l3_info));
6464
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006465 f_logp(BSCVTY, "establish channel, send Complete Layer 3 Info");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006466 f_create_bssmap_exp(l3_enc);
6467
6468 /* RSL_Emulation.f_chan_est() on rsl:
6469 * This is basically code dup with s/RSL/rsl from:
6470 * RSL_Emulation.f_chan_est(g_pars.ra, l3_enc, g_pars.link_id, g_pars.fn);
6471 */
6472 var RSL_Message rx_rsl;
6473 var GsmRrMessage rr;
6474
6475 /* request a channel to be established */
6476 rsl.send(ts_RSLDC_ChanRqd(g_pars.ra, g_pars.fn));
6477 /* expect immediate assignment.
6478 * Code dup with s/RSL/rsl from:
6479 * rx_rsl := f_rx_or_fail(tr_RSL_IMM_ASSIGN);
6480 */
6481 timer Tt := 10.0;
6482
6483 /* request a channel to be established */
6484 Tt.start;
6485 alt {
6486 [] rsl.receive(tr_RSL_IMM_ASSIGN) -> value rx_rsl {
6487 Tt.stop;
6488 }
6489 [] rsl.receive {
6490 setverdict(fail, "Unexpected RSL message on DCHAN");
6491 mtc.stop;
6492 }
6493 [] Tt.timeout {
6494 setverdict(fail, "Timeout waiting for RSL on DCHAN");
6495 mtc.stop;
6496 }
6497 }
6498 rr := dec_GsmRrMessage(rx_rsl.ies[1].body.full_imm_ass_info.payload);
6499 g_chan_nr := rr.payload.imm_ass.chan_desc.chan_nr;
6500 rsl.send(ts_RSL_EST_IND(g_chan_nr, valueof(g_pars.link_id), l3_enc));
6501
6502
Neels Hofmeyr66e15092020-10-12 18:44:41 +00006503 if (expect_bssmap_l3) {
6504 f_logp(BSCVTY, "expect BSSAP Complete Layer 3 Info at MSC");
6505 var template PDU_BSSAP exp_l3_compl;
6506 exp_l3_compl := tr_BSSMAP_ComplL3()
6507 if (g_pars.aoip == false) {
6508 exp_l3_compl.pdu.bssmap.completeLayer3Information.codecList := omit;
6509 } else {
6510 exp_l3_compl.pdu.bssmap.completeLayer3Information.codecList := ?;
6511 }
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006512
Neels Hofmeyr66e15092020-10-12 18:44:41 +00006513 var PDU_BSSAP bssap;
6514 T.start;
6515 alt {
6516 [] BSSAP.receive(exp_l3_compl) -> value bssap {
6517 f_logp(BSCVTY, "received expected Complete Layer 3 Info at MSC");
6518 log("rx exp_l3_compl = ", bssap);
6519 }
6520 [] BSSAP.receive(tr_BSSMAP_ComplL3) {
6521 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received non-matching COMPLETE LAYER 3 INFORMATION");
6522 }
6523 [] T.timeout {
6524 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for COMPLETE LAYER 3 INFORMATION");
6525 }
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006526 }
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006527
Neels Hofmeyr66e15092020-10-12 18:44:41 +00006528 /* start ciphering, if requested */
6529 if (ispresent(g_pars.encr)) {
6530 f_logp(BSCVTY, "start ciphering");
6531 f_cipher_mode(g_pars.encr.enc_alg, g_pars.encr.enc_key);
6532 }
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006533 }
6534
6535 if (do_clear) {
6536 f_perform_clear(rsl);
6537 }
6538 setverdict(pass);
6539 f_sleep(1.0);
6540}
6541
6542private function f_tc_mscpool_compl_l3(charstring id) runs on MSC_ConnHdlr {
6543 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
6544 if (g_pars.mscpool.rsl_idx == 0) {
6545 f_perform_compl_l3(RSL, g_pars.mscpool.l3_info);
6546 } else if (g_pars.mscpool.rsl_idx == 1) {
6547 f_perform_compl_l3(RSL1, g_pars.mscpool.l3_info);
6548 } else if (g_pars.mscpool.rsl_idx == 2) {
6549 f_perform_compl_l3(RSL2, g_pars.mscpool.l3_info);
6550 }
6551}
6552
6553/* Various Complete Layer 3 by IMSI all end up with the first MSC, because the other MSCs are not connected. */
6554private function f_tc_mscpool_L3Compl_on_1_msc(charstring id) runs on MSC_ConnHdlr {
6555 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
6556 f_perform_compl_l3(RSL, ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000001'H)), '00F110'O) );
6557 f_perform_compl_l3(RSL, ts_CM_SERV_REQ(CM_TYPE_MO_SMS, valueof(ts_MI_IMSI_LV('001010000000002'H))) );
6558 f_perform_compl_l3(RSL, ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010000000003'H))) );
6559 f_perform_compl_l3(RSL, ts_ML3_MO_MM_IMSI_DET_Ind(valueof(ts_MI_IMSI_LV('001010000000004'H))) );
6560}
6561testcase TC_mscpool_L3Compl_on_1_msc() runs on test_CT {
6562
6563 f_init(1, true);
6564 f_sleep(1.0);
6565 var MSC_ConnHdlr vc_conn;
6566 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006567
6568 f_ctrs_msc_init();
6569
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006570 vc_conn := f_start_handler(refers(f_tc_mscpool_L3Compl_on_1_msc), pars);
6571 vc_conn.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006572
6573 f_ctrs_msc_expect(0, "mscpool:subscr:new", 4);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006574 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006575}
6576
6577/* Three Layer 3 Complete by IMSI are round-robin'ed across two connected MSCs */
6578/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6579 * just as well using only RSL. */
6580testcase TC_mscpool_L3Complete_by_imsi_round_robin() runs on test_CT {
6581
6582 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6583 f_sleep(1.0);
6584
6585 /* Control which MSC gets chosen next by the round-robin, otherwise
6586 * would be randomly affected by which other tests ran before this. */
6587 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6588
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006589 f_ctrs_msc_init();
6590
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006591 var MSC_ConnHdlr vc_conn1;
6592 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6593 pars1.mscpool.rsl_idx := 0;
6594 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000001'H)), '00F110'O));
6595 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6596 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006597 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006598
6599 var MSC_ConnHdlr vc_conn2;
6600 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6601 pars2.mscpool.rsl_idx := 1;
6602 pars2.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000002'H))));
6603 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6604 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006605 f_ctrs_msc_expect(1, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006606
6607 /* Test round-robin wrap to the first MSC */
6608 var MSC_ConnHdlr vc_conn3;
6609 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6610 pars3.mscpool.rsl_idx := 2;
6611 pars3.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010000000003'H))));
6612 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6613 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006614 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006615 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006616}
6617
6618/* Three LU by TMSI are round-robin'ed across two connected MSCs, because they contain the NULL-NRI 0
6619 * (configured in osmo-bsc.cfg). */
6620/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6621 * just as well using only RSL. */
6622testcase TC_mscpool_LU_by_tmsi_null_nri_0_round_robin() runs on test_CT {
6623
6624 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6625 f_sleep(1.0);
6626
6627 /* Control which MSC gets chosen next by the round-robin, otherwise
6628 * would be randomly affected by which other tests ran before this. */
6629 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6630
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006631 f_ctrs_msc_init();
6632
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006633 var MSC_ConnHdlr vc_conn1;
6634 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6635 pars1.mscpool.rsl_idx := 0;
6636 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(0)), '00F110'O));
6637 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6638 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006639 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006640
6641 var MSC_ConnHdlr vc_conn2;
6642 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6643 pars2.mscpool.rsl_idx := 1;
6644 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(0)), '00F110'O));
6645 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6646 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006647 f_ctrs_msc_expect(1, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006648
6649 /* Test round-robin wrap to the first MSC */
6650 var MSC_ConnHdlr vc_conn3;
6651 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6652 pars3.mscpool.rsl_idx := 2;
6653 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(0)), '00F110'O));
6654 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6655 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006656 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006657 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006658}
6659
6660/* Three LU by TMSI are round-robin'ed across two connected MSCs, because they contain the NULL-NRI 1
6661 * (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
6662 * NULL-NRI setting is stronger than that. */
6663/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6664 * just as well using only RSL. */
6665testcase TC_mscpool_LU_by_tmsi_null_nri_1_round_robin() runs on test_CT {
6666
6667 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6668 f_sleep(1.0);
6669
6670 /* Control which MSC gets chosen next by the round-robin, otherwise
6671 * would be randomly affected by which other tests ran before this. */
6672 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6673
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006674 f_ctrs_msc_init();
6675
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006676 var MSC_ConnHdlr vc_conn1;
6677 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6678 pars1.mscpool.rsl_idx := 0;
6679 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(1)), '00F110'O));
6680 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6681 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006682 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006683
6684 var MSC_ConnHdlr vc_conn2;
6685 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6686 pars2.mscpool.rsl_idx := 1;
6687 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(1)), '00F110'O));
6688 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6689 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006690 f_ctrs_msc_expect(1, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006691
6692 /* Test round-robin wrap to the first MSC */
6693 var MSC_ConnHdlr vc_conn3;
6694 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6695 pars3.mscpool.rsl_idx := 2;
6696 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(1)), '00F110'O));
6697 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6698 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006699 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006700 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006701}
6702
6703/* Three Layer 3 Complete by TMSI are round-robin'ed across two connected MSCs, because they contain an NRI not
6704 * assigned to any MSC (configured in osmo-bsc.cfg). */
6705/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6706 * just as well using only RSL. */
6707testcase TC_mscpool_L3Complete_by_tmsi_unassigned_nri_round_robin() runs on test_CT {
6708
6709 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6710 f_sleep(1.0);
6711
6712 /* Control which MSC gets chosen next by the round-robin, otherwise
6713 * would be randomly affected by which other tests ran before this. */
6714 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6715
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006716 f_ctrs_msc_init();
6717
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006718 var MSC_ConnHdlr vc_conn1;
6719 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6720 pars1.mscpool.rsl_idx := 0;
6721 /* An NRI that is not assigned to any MSC */
6722 pars1.mscpool.l3_info := valueof(ts_ML3_MO_MM_IMSI_DET_Ind(valueof(ts_MI_TMSI_NRI_LV(1023))));
6723 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6724 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006725 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006726
6727 var MSC_ConnHdlr vc_conn2;
6728 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6729 pars2.mscpool.rsl_idx := 1;
6730 /* An NRI that is not assigned to any MSC */
6731 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(768)), '00F110'O));
6732 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6733 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006734 f_ctrs_msc_expect(1, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006735
6736 /* Test round-robin wrap to the first MSC */
6737 var MSC_ConnHdlr vc_conn3;
6738 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6739 pars3.mscpool.rsl_idx := 2;
6740 /* An NRI that is not assigned to any MSC */
6741 pars3.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_SS_ACT, valueof(ts_MI_TMSI_NRI_LV(819))));
6742 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6743 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006744 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006745 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006746}
6747
6748/* Three Layer 3 Complete by TMSI are round-robin'ed across two connected MSCs, because they contain an NRI
6749 * assigned to an MSC that is currently not connected (configured in osmo-bsc.cfg). */
6750/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6751 * just as well using only RSL. */
6752testcase TC_mscpool_L3Complete_by_tmsi_valid_nri_msc_not_connected_round_robin() runs on test_CT {
6753
6754 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6755 f_sleep(1.0);
6756
6757 /* Control which MSC gets chosen next by the round-robin, otherwise
6758 * would be randomly affected by which other tests ran before this. */
6759 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6760
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006761 f_ctrs_msc_init();
6762
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006763 var MSC_ConnHdlr vc_conn1;
6764 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6765 pars1.mscpool.rsl_idx := 0;
6766 /* An NRI that is assigned to an unconnected MSC */
6767 pars1.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(512))));
6768 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6769 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006770 f_ctrs_msc_add(2, "mscpool:subscr:attach_lost");
6771 f_ctrs_msc_add(0, "mscpool:subscr:new");
6772 f_ctrs_msc_verify();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006773
6774 var MSC_ConnHdlr vc_conn2;
6775 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6776 pars2.mscpool.rsl_idx := 1;
6777 /* An NRI that is assigned to an unconnected MSC */
6778 pars2.mscpool.l3_info := valueof(ts_ML3_MO_MM_IMSI_DET_Ind(valueof(ts_MI_TMSI_NRI_LV(767))));
6779 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6780 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006781 f_ctrs_msc_add(2, "mscpool:subscr:attach_lost");
6782 f_ctrs_msc_add(1, "mscpool:subscr:new");
6783 f_ctrs_msc_verify();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006784
6785 /* Test round-robin wrap to the first MSC */
6786 var MSC_ConnHdlr vc_conn3;
6787 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6788 pars3.mscpool.rsl_idx := 2;
6789 /* An NRI that is assigned to an unconnected MSC */
6790 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(750)), '00F110'O));
6791 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6792 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006793 f_ctrs_msc_add(2, "mscpool:subscr:attach_lost");
6794 f_ctrs_msc_add(0, "mscpool:subscr:new");
6795 f_ctrs_msc_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006796 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006797}
6798
6799/* Three Layer 3 Complete by TMSI with valid NRI for the second MSC are all directed to the second MSC (configured in
6800 * osmo-bsc.cfg). */
6801/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6802 * just as well using only RSL. */
6803testcase TC_mscpool_L3Complete_by_tmsi_valid_nri_1() runs on test_CT {
6804
6805 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6806 f_sleep(1.0);
6807
6808 /* All TMSIs in this test point at the second MSC, set the round robin to point at the first MSC to make sure
6809 * this is not using round-robin. */
6810 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6811
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006812 f_ctrs_msc_init();
6813
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006814 var MSC_ConnHdlr vc_conn1;
6815 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 1);
6816 pars1.mscpool.rsl_idx := 0;
6817 /* An NRI of the second MSC's range (256-511) */
6818 pars1.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_SMS, valueof(ts_MI_TMSI_NRI_LV(256))));
6819 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6820 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006821 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006822
6823 var MSC_ConnHdlr vc_conn2;
6824 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6825 pars2.mscpool.rsl_idx := 1;
6826 /* An NRI of the second MSC's range (256-511) */
6827 pars2.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(260))));
6828 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6829 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006830 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006831
6832 var MSC_ConnHdlr vc_conn3;
6833 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 1);
6834 pars3.mscpool.rsl_idx := 2;
6835 /* An NRI of the second MSC's range (256-511) */
6836 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(511)), '00F110'O));
6837 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6838 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006839 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006840 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006841}
6842
6843/* Layer 3 Complete by TMSI with valid NRI for the third MSC are directed to the third MSC (configured in osmo-bsc.cfg),
6844 * while a round-robin remains unaffected by that. */
6845/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6846 * just as well using only RSL. */
6847testcase TC_mscpool_L3Complete_by_tmsi_valid_nri_2() runs on test_CT {
6848
6849 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
6850 f_sleep(1.0);
6851
6852 /* All TMSIs in this test point at the third MSC, set the round robin to point at the second MSC to make sure
6853 * this is not using round-robin. */
6854 f_vty_transceive(BSCVTY, "mscpool roundrobin next 1");
6855
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006856 f_ctrs_msc_init();
6857
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006858 var MSC_ConnHdlr vc_conn1;
6859 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 2);
6860 pars1.mscpool.rsl_idx := 0;
6861 /* An NRI of the third MSC's range (512-767) */
6862 pars1.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_SMS, valueof(ts_MI_TMSI_NRI_LV(512))));
6863 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6864 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006865 f_ctrs_msc_expect(2, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006866
6867 var MSC_ConnHdlr vc_conn2;
6868 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 2);
6869 pars2.mscpool.rsl_idx := 1;
6870 /* An NRI of the third MSC's range (512-767) */
6871 pars2.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(678))));
6872 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6873 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006874 f_ctrs_msc_expect(2, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006875
6876 /* The above forwardings to third MSC have not affected the round robin, which still points at the second MSC */
6877 var MSC_ConnHdlr vc_conn3;
6878 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 1);
6879 pars3.mscpool.rsl_idx := 2;
6880 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000013'H)), '00F110'O));
6881 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6882 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006883 f_ctrs_msc_expect(1, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006884 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006885}
6886
6887/* LU with a TMSI but indicating a different PLMN in its previous LAI: ignore the NRI. */
6888/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6889 * just as well using only RSL. */
6890testcase TC_mscpool_LU_by_tmsi_from_other_PLMN() runs on test_CT {
6891
6892 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
6893 f_sleep(1.0);
6894
6895 /* The TMSIs in this test points at the second MSC, but since it is from a different PLMN, round-robin is used
6896 * instead, and hits msc 0. */
6897 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6898
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006899 f_ctrs_msc_init();
6900
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006901 /* An NRI of the second MSC's range (256-511), but a PLMN that doesn't match with osmo-bsc.cfg */
6902 var MSC_ConnHdlr vc_conn1;
6903 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6904 pars1.mscpool.rsl_idx := 0;
6905 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(260)), '99F999'O));
6906 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6907 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006908 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006909
6910 /* An NRI of the third MSC's range (512-767) and a matching PLMN gets directed by NRI. */
6911 var MSC_ConnHdlr vc_conn2;
6912 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 2);
6913 pars2.mscpool.rsl_idx := 1;
6914 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(555)), '00F110'O));
6915 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6916 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006917 f_ctrs_msc_expect(2, "mscpool:subscr:known");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006918 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006919}
6920
6921/* Make sure that whichever MSC paged a subscriber will also get the Paging Response. Page by IMSI, which would be
6922 * round-robined to another MSC, to make sure the Paging->Response relation is stronger than the NRI->MSC mapping. */
6923private function f_tc_mscpool_paging_imsi(charstring id) runs on MSC_ConnHdlr {
6924 var template BSSMAP_FIELD_CellIdentificationList cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(0) } };
6925 //cid_list := { cIl_allInBSS := ''O };
6926 var RSL_ChanNeeded rsl_chneed := RSL_CHANNEED_SDCCH;
6927 var template BSSMAP_IE_ChannelNeeded bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
6928 var BSSAP_N_UNITDATA_req paging;
6929 var hexstring imsi := '001010000000123'H;
6930
6931 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
6932
Neels Hofmeyr90f80962020-06-12 16:16:55 +02006933 paging := valueof(ts_BSSAP_UNITDATA_req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006934 valueof(ts_BSSMAP_Paging(imsi, cid_list, omit, bssmap_chneed))));
6935 BSSAP.send(paging);
6936
6937 /* Register any RSL conn so that the Paging Command gets received here. With the current RSL_Emulation's main()
6938 * handling of '[bts_role] IPA_PT.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD()))' it doesn't matter at all which
6939 * channel number is picked here. */
6940 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(0, RSL_CHAN_NR_INVALID));
6941 f_rslem_register(0, new_chan_nr);
6942 RSL.receive(tr_RSL_PAGING_CMD(tr_MI_IMSI(imsi)));
6943 f_rslem_unregister(0, new_chan_nr);
6944
6945 /* Despite the round robin pointing at the second MSC ('roundrobin next 1'), the earlier Paging for the same IMSI
6946 * causes this Paging Response to go to the first MSC (bssap_idx := 0). */
6947 f_perform_compl_l3(RSL, ts_PAG_RESP(valueof(ts_MI_IMSI_LV(imsi))) );
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006948 f_sleep(1.0);
6949}
6950testcase TC_mscpool_paging_and_response_imsi() runs on test_CT {
6951 f_init(nr_bts := 1, handler_mode := true, nr_msc := 3);
6952 f_sleep(1.0);
6953
6954 /* Testing a Paging on the first MSC to get a Paging Response back to the first MSC. Set round robin to the
6955 * second MSC to make sure we're getting the Paging logic, not a coincidental round robin match. */
6956 f_vty_transceive(BSCVTY, "mscpool roundrobin next 1");
6957
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006958 f_ctrs_msc_init();
6959
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006960 var MSC_ConnHdlr vc_conn1;
6961 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6962 pars1.mscpool.rsl_idx := 0;
Neels Hofmeyr90f80962020-06-12 16:16:55 +02006963 pars1.sccp_addr_bsc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_peer;
6964 pars1.sccp_addr_msc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_own;
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006965 vc_conn1 := f_start_handler(refers(f_tc_mscpool_paging_imsi), pars1);
6966 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006967 f_ctrs_msc_expect(0, "mscpool:subscr:paged");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006968 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006969}
6970
6971/* Make sure that whichever MSC paged a subscriber will also get the Paging Response. Page by TMSI with an NRI value
6972 * that matches a different MSC, to make sure the Paging->Response relation is stronger than the NRI->MSC mapping. */
6973private function f_tc_mscpool_paging_tmsi(charstring id) runs on MSC_ConnHdlr {
6974 var template BSSMAP_FIELD_CellIdentificationList cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(0) } };
6975 //cid_list := { cIl_allInBSS := ''O };
6976 var RSL_ChanNeeded rsl_chneed := RSL_CHANNEED_SDCCH;
6977 var template BSSMAP_IE_ChannelNeeded bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
6978 var integer nri_v := 300; /* <-- second MSC's NRI */
Harald Weltebf397612021-01-14 20:39:46 +01006979 var octetstring tmsi := f_gen_tmsi(suffix := 0, nri_v := nri_v);
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006980 var BSSAP_N_UNITDATA_req paging;
6981
6982 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
6983
Neels Hofmeyr90f80962020-06-12 16:16:55 +02006984 paging := valueof(ts_BSSAP_UNITDATA_req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006985 valueof(ts_BSSMAP_Paging('001010000000011'H, cid_list, tmsi, bssmap_chneed))));
6986 BSSAP.send(paging);
6987
6988 /* Register any RSL conn so that the Paging Command gets received here. With the current RSL_Emulation's main()
6989 * handling of '[bts_role] IPA_PT.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD()))' it doesn't matter at all which
6990 * channel number is picked here. */
6991 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(0, RSL_CHAN_NR_INVALID));
6992 f_rslem_register(0, new_chan_nr);
6993 RSL.receive(tr_RSL_PAGING_CMD(t_MI_TMSI(tmsi)));
6994 f_rslem_unregister(0, new_chan_nr);
6995
6996 /* Despite the NRI matching the second MSC (NRI from 'msc 1' in osmo-bsc.cfg) and round robin pointing at the
6997 * third MSC ('roundrobin next 2'), the earlier Paging for the same TMSI causes this Paging Response to go to
6998 * the first MSC (bssap_idx := 0). */
6999 f_perform_compl_l3(RSL, ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(nri_v))) );
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007000 f_sleep(1.0);
7001}
7002testcase TC_mscpool_paging_and_response_tmsi() runs on test_CT {
7003 f_init(nr_bts := 1, handler_mode := true, nr_msc := 3);
7004 f_sleep(1.0);
7005
7006 /* Testing a Paging on the first MSC to get a Paging Response back to the first MSC. Set round robin to the
7007 * third MSC to make sure we're getting the Paging logic, not a coincidental round robin match. */
7008 f_vty_transceive(BSCVTY, "mscpool roundrobin next 2");
7009
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007010 f_ctrs_msc_init();
7011
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007012 var MSC_ConnHdlr vc_conn1;
7013 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
7014 pars1.mscpool.rsl_idx := 0;
Neels Hofmeyr90f80962020-06-12 16:16:55 +02007015 pars1.sccp_addr_bsc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_peer;
7016 pars1.sccp_addr_msc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_own;
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007017 vc_conn1 := f_start_handler(refers(f_tc_mscpool_paging_tmsi), pars1);
7018 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007019 f_ctrs_msc_expect(0, "mscpool:subscr:paged");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007020 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007021}
7022
7023/* For round-robin, skip an MSC that has 'no allow-attach' set. */
7024/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
7025 * just as well using only RSL. */
7026testcase TC_mscpool_no_allow_attach_round_robin() runs on test_CT {
7027
7028 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
7029 f_sleep(1.0);
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00007030 /* Mark the second MSC as offloading, round-robin should skip this MSC now. */
7031 f_vty_msc_allow_attach(BSCVTY, {true, false, true});
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007032
7033 /* Control which MSC gets chosen next by the round-robin, otherwise
7034 * would be randomly affected by which other tests ran before this. */
7035 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
7036
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007037 f_ctrs_msc_init();
7038
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007039 var MSC_ConnHdlr vc_conn1;
7040 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
7041 pars1.mscpool.rsl_idx := 0;
7042 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000001'H)), '00F110'O));
7043 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
7044 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007045 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007046
7047 var MSC_ConnHdlr vc_conn2;
7048 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 2);
7049 pars2.mscpool.rsl_idx := 1;
7050 pars2.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000002'H))));
7051 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
7052 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007053 f_ctrs_msc_expect(2, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007054
7055 var MSC_ConnHdlr vc_conn3;
7056 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
7057 pars3.mscpool.rsl_idx := 2;
7058 pars3.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010000000003'H))));
7059 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
7060 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007061 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007062 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007063}
7064
7065/* An MSC that has 'no allow-attach' set should still serve subscribers that are already attached according to their
7066 * TMSI NRI. */
7067testcase TC_mscpool_no_allow_attach_valid_nri() runs on test_CT {
7068
7069 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
7070 f_sleep(1.0);
7071
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00007072 /* Mark the second MSC as offloading, round-robin should skip this MSC now. */
7073 f_vty_msc_allow_attach(BSCVTY, {true, false, true});
7074
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007075 /* Control which MSC gets chosen next by the round-robin, otherwise
7076 * would be randomly affected by which other tests ran before this. */
7077 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
7078
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007079 f_ctrs_msc_init();
7080
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007081 /* Round robin points at msc 0, but the valid NRI directs to msc 1, even though msc 1 has 'no allow-attach'. */
7082 var MSC_ConnHdlr vc_conn1;
7083 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 1);
7084 pars1.mscpool.rsl_idx := 0;
7085 /* An NRI of the second MSC's range (256-511) */
7086 pars1.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_TMSI_NRI_LV(260))));
7087 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
7088 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007089 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007090
7091 var MSC_ConnHdlr vc_conn2;
7092 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 0);
7093 pars2.mscpool.rsl_idx := 1;
7094 pars2.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000002'H))));
7095 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
7096 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007097 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007098
7099 var MSC_ConnHdlr vc_conn3;
7100 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 2);
7101 pars3.mscpool.rsl_idx := 2;
7102 pars3.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000003'H))));
7103 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
7104 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007105 f_ctrs_msc_expect(2, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007106 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007107}
7108
Philipp Maier783681c2020-07-16 16:47:06 +02007109/* Allow/Deny emergency calls globally via VTY */
7110private function f_vty_allow_emerg_msc(boolean allow) runs on test_CT {
7111 f_vty_enter_cfg_msc(BSCVTY, 0);
7112 if (allow) {
7113 f_vty_transceive(BSCVTY, "allow-emergency allow");
7114 } else {
7115 f_vty_transceive(BSCVTY, "allow-emergency deny");
7116 }
7117 f_vty_transceive(BSCVTY, "exit");
7118 f_vty_transceive(BSCVTY, "exit");
7119}
7120
7121/* Allow/Deny emergency calls per BTS via VTY */
7122private function f_vty_allow_emerg_bts(boolean allow, integer bts_nr) runs on test_CT {
7123 f_vty_enter_cfg_bts(BSCVTY, bts_nr);
7124 if (allow) {
7125 f_vty_transceive(BSCVTY, "rach emergency call allowed 1");
7126 } else {
7127 f_vty_transceive(BSCVTY, "rach emergency call allowed 0");
7128 }
7129 f_vty_transceive(BSCVTY, "exit");
7130 f_vty_transceive(BSCVTY, "exit");
Neels Hofmeyrb6ed80c2020-10-12 22:52:39 +00007131 f_vty_transceive(BSCVTY, "exit");
Philipp Maier783681c2020-07-16 16:47:06 +02007132}
7133
7134/* Begin assignmet procedure and send an EMERGENCY SETUP (RR) */
7135private function f_assignment_emerg_setup() runs on MSC_ConnHdlr {
7136 var PDU_ML3_MS_NW emerg_setup;
7137 var octetstring emerg_setup_enc;
7138 var RSL_Message emerg_setup_data_ind;
7139
7140 f_establish_fully(omit, omit);
7141
7142 emerg_setup := valueof(ts_ML3_MO_CC_EMERG_SETUP(1, valueof(ts_Bcap_voice)));
7143 emerg_setup_enc := enc_PDU_ML3_MS_NW(emerg_setup);
7144 emerg_setup_data_ind := valueof(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), emerg_setup_enc));
7145
7146 RSL.send(emerg_setup_data_ind);
7147}
7148
7149/* Test if the EMERGENCY SETUP gets passed on to the MSC via A when EMERGENCY
7150 * CALLS are permitted by the BSC config. */
7151private function f_TC_assignment_emerg_setup_allow(charstring id) runs on MSC_ConnHdlr {
7152 var PDU_BSSAP emerg_setup_data_ind_bssap;
7153 var PDU_ML3_MS_NW emerg_setup;
7154 timer T := 3.0;
7155
7156 f_assignment_emerg_setup()
7157
7158 T.start;
7159 alt {
7160 [] BSSAP.receive(tr_BSSAP_DTAP) -> value emerg_setup_data_ind_bssap {
7161 emerg_setup := dec_PDU_ML3_MS_NW(emerg_setup_data_ind_bssap.pdu.dtap);
7162 if (not isbound(emerg_setup.msgs.cc.emergencySetup)) {
7163 setverdict(fail, "no emergency setup");
7164 }
7165 }
7166 [] BSSAP.receive {
7167 setverdict(fail, "unexpected BSSAP message!");
7168 }
7169 [] T.timeout {
7170 setverdict(fail, "timout waiting for EMERGENCY SETUP!");
7171 }
7172 }
7173
7174 setverdict(pass);
7175}
7176
7177/* Test if the EMERGENCY SETUP gets blocked by the BSC if EMERGENCY CALLS are
7178 * forbidden by the BSC config. */
7179private function f_TC_assignment_emerg_setup_deny(charstring id) runs on MSC_ConnHdlr {
7180 var PDU_BSSAP emerg_setup_data_ind_bssap;
7181 timer T := 3.0;
7182
7183 f_assignment_emerg_setup()
7184
7185 T.start;
7186 alt {
7187 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
7188 setverdict(pass);
7189 }
7190 [] RSL.receive {
7191 setverdict(fail, "unexpected RSL message!");
7192 }
7193 [] T.timeout {
7194 setverdict(fail, "timout waiting for RR CHANNEL RELEASE!");
7195 }
7196 }
7197}
7198
7199/* EMERGENCY CALL situation #1, allowed globally and by BTS */
7200testcase TC_assignment_emerg_setup_allow() runs on test_CT {
7201 var TestHdlrParams pars := f_gen_test_hdlr_pars();
7202 var MSC_ConnHdlr vc_conn;
7203
7204 f_init(1, true);
7205 f_sleep(1.0);
7206
7207 f_vty_allow_emerg_msc(true);
7208 f_vty_allow_emerg_bts(true, 0);
7209 vc_conn := f_start_handler(refers(f_TC_assignment_emerg_setup_allow), pars);
7210 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007211 f_shutdown_helper();
Philipp Maier783681c2020-07-16 16:47:06 +02007212}
7213
7214/* EMERGENCY CALL situation #2, forbidden globally but allowed by BTS */
7215testcase TC_assignment_emerg_setup_deny_msc() runs on test_CT {
7216 var TestHdlrParams pars := f_gen_test_hdlr_pars();
7217 var MSC_ConnHdlr vc_conn;
7218
7219 f_init(1, true);
7220 f_sleep(1.0);
7221
7222 f_vty_allow_emerg_msc(false);
7223 f_vty_allow_emerg_bts(true, 0);
7224 vc_conn := f_start_handler(refers(f_TC_assignment_emerg_setup_deny), pars);
7225 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007226 f_shutdown_helper();
Philipp Maier783681c2020-07-16 16:47:06 +02007227}
7228
7229/* EMERGENCY CALL situation #3, allowed globally but forbidden by BTS */
7230testcase TC_assignment_emerg_setup_deny_bts() runs on test_CT {
7231 var TestHdlrParams pars := f_gen_test_hdlr_pars();
7232 var MSC_ConnHdlr vc_conn;
7233
7234 /* Note: This simulates a spec violation by the MS, correct MS
7235 * implementations would not try to establish an emergency call because
7236 * the system information tells in advance that emergency calls are
7237 * not forbidden */
7238
7239 f_init(1, true);
7240 f_sleep(1.0);
7241
7242 f_vty_allow_emerg_msc(true);
7243 f_vty_allow_emerg_bts(false, 0);
7244 vc_conn := f_start_handler(refers(f_TC_assignment_emerg_setup_deny), pars);
7245 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007246 f_shutdown_helper();
Philipp Maier783681c2020-07-16 16:47:06 +02007247}
7248
Philipp Maier82812002020-08-13 18:48:27 +02007249/* Test what happens when an emergency call arrives while all TCH channels are
7250 * busy, the BSC is expected to terminate one call in favor of the incoming
7251 * emergency call */
7252testcase TC_emerg_premption() runs on test_CT {
7253 var ASP_RSL_Unitdata rsl_ud;
7254 var integer i;
7255 var integer chreq_total, chreq_nochan;
7256 var RSL_Message rx_rsl;
7257 var RslChannelNr chan_nr;
7258
7259 f_init(1);
7260 f_sleep(1.0);
7261
7262 f_vty_allow_emerg_msc(true);
7263 f_vty_allow_emerg_bts(true, 0);
7264
7265 /* Fill up all channels on the BTS */
7266 chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total");
7267 chreq_nochan := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel");
7268 for (i := 0; i < NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS; i := i+1) {
7269 chan_nr := f_chreq_act_ack('33'O, i);
7270 }
7271 IPA_RSL[0].clear;
7272 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total",
7273 chreq_total + NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS);
7274
7275 /* Send Channel request for emegergency call */
7276 f_ipa_tx(0, ts_RSL_CHAN_RQD('A5'O, 23));
7277
7278 /* Expect the BSC to release one (the first) TCH/F on the BTS */
7279 chan_nr := valueof(t_RslChanNr_Bm(1));
7280 f_expect_chan_rel(0, chan_nr, expect_rr_chan_rel := false, expect_rll_rel_req := false);
7281
7282 /* Expect the BSC to send activate/assign the a channel for the emergency call */
7283 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7284 chan_nr := rx_rsl.ies[0].body.chan_nr;
7285 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 33));
7286 rx_rsl := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
Philipp Maier104f4c02020-09-11 18:12:18 +02007287
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007288 f_shutdown_helper();
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007289}
7290
7291/* Hopping parameters per a timeslot */
Vadim Yanitskiybc6654a2020-09-13 01:27:40 +07007292private type record length(0..64) of GsmArfcn ArfcnList;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007293private type record FHParamsTs {
7294 boolean enabled,
7295 uint6_t hsn,
7296 uint6_t maio,
7297 ArfcnList ma
7298};
7299
7300/* Hopping parameters per a transceiver */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007301private type record FHParamsTrx {
7302 GsmArfcn arfcn,
7303 FHParamsTs ts[8]
7304};
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007305
7306/* Randomly generate the hopping parameters for the given timeslot numbers */
7307private function f_TC_fh_params_gen(template integer tr_tn := (1, 3, 5))
7308runs on test_CT return FHParamsTrx {
7309 var FHParamsTrx fhp;
7310
Vadim Yanitskiy3e997362020-09-05 21:08:34 +07007311 /* Generate a random ARFCN, including ARFCN 0 */
7312 fhp.arfcn := f_rnd_int(3);
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007313
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007314 for (var integer tn := 0; tn < 8; tn := tn + 1) {
7315 if (not match(tn, tr_tn)) {
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007316 fhp.ts[tn].enabled := false;
7317 fhp.ts[tn].ma := { };
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007318 continue;
7319 }
7320
7321 /* Random HSN / MAIO values: 0..63 */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007322 fhp.ts[tn].hsn := f_rnd_int(64);
7323 fhp.ts[tn].maio := f_rnd_int(64);
7324 fhp.ts[tn].ma := { };
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007325
7326 /* Random Mobile Allocation (hopping channels) */
7327 var integer ma_len := 2 + f_rnd_int(9); /* 2..10 channels */
7328 var integer step := 3 + f_rnd_int(4); /* 3..6 stepping */
7329 for (var integer i := 1; i <= ma_len; i := i + 1) {
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007330 fhp.ts[tn].ma := fhp.ts[tn].ma & { i * step };
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007331 }
7332
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007333 fhp.ts[tn].enabled := true;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007334 }
7335
7336 log("f_TC_fh_params_gen(): ", fhp);
7337 return fhp;
7338}
7339
7340/* Make sure that the given Channel Description IE matches the hopping configuration */
7341private function f_TC_fh_params_match_chan_desc(in FHParamsTrx fhp, in ChannelDescription cd)
7342{
7343 var template (present) ChannelDescription tr_cd;
7344 var template (present) MaioHsn tr_maio_hsn;
7345 var uint3_t tn := cd.chan_nr.tn;
7346
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007347 if (fhp.ts[tn].enabled) {
7348 tr_maio_hsn := tr_HsnMaio(fhp.ts[tn].hsn, fhp.ts[tn].maio);
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007349 tr_cd := tr_ChanDescH1(cd.chan_nr, tr_maio_hsn);
7350 } else {
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007351 tr_cd := tr_ChanDescH0(cd.chan_nr, fhp.arfcn);
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007352 }
7353
7354 if (not match(cd, tr_cd)) {
7355 setverdict(fail, "Channel Description IE does not match: ",
7356 cd, " vs expected ", tr_cd);
7357 }
7358}
7359
7360/* Make sure that the given Mobile Allocation IE matches the hopping configuration */
7361private function f_TC_fh_params_match_ma(in FHParamsTrx fhp, uint3_t tn,
7362 in MobileAllocationLV ma)
7363{
7364 var template MobileAllocationLV tr_ma := f_TC_fh_params_gen_tr_ma(fhp, tn, ma);
7365
7366 if (not match(ma, tr_ma)) {
7367 setverdict(fail, "Mobile Allocation IE does not match (tn := ",
7368 tn, "): ", ma, " vs expected: ", tr_ma);
7369 } else {
7370 setverdict(pass);
7371 }
7372}
7373
7374private function f_TC_fh_params_gen_tr_ma(in FHParamsTrx fhp, uint3_t tn,
7375 in MobileAllocationLV ma)
7376return template MobileAllocationLV {
7377 /* Mobile Allocation IE is expected to be empty if hopping is not enabled */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007378 if (not fhp.ts[tn].enabled) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007379 return { len := 0, ma := ''B };
7380 }
7381
7382 var bitstring full_mask := f_pad_bit(''B, 1024, '0'B);
7383 var bitstring slot_mask := f_pad_bit(''B, 1024, '0'B);
7384 var bitstring ma_mask := ''B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007385
7386 /* Compose the full bit-mask (all channels, up to 1024 entries) */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007387 for (var integer i := 0; i < lengthof(fhp.ts); i := i + 1) {
7388 for (var integer j := 0; j < lengthof(fhp.ts[i].ma); j := j + 1) {
7389 if (full_mask[fhp.ts[i].ma[j]] == '1'B)
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007390 { continue; }
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007391 full_mask[fhp.ts[i].ma[j]] := '1'B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007392 }
7393 }
7394
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007395 /* Take ARFCN of the TRX itself into account */
7396 full_mask[fhp.arfcn] := '1'B;
7397
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007398 /* Compose a bit-mask for the given timeslot number */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007399 for (var integer i := 0; i < lengthof(fhp.ts[tn].ma); i := i + 1) {
7400 slot_mask[fhp.ts[tn].ma[i]] := '1'B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007401 }
7402
7403 /* Finally, compose the Mobile Allocation bit-mask */
Vadim Yanitskiy3e997362020-09-05 21:08:34 +07007404 for (var integer i := 1; i < lengthof(full_mask); i := i + 1) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007405 if (full_mask[i] != '1'B)
7406 { continue; }
7407
7408 /* FIXME: ma_mask := ma_mask & slot_mask[i]; // triggers a bug in TITAN */
7409 if (slot_mask[i] == '1'B) {
7410 ma_mask := ma_mask & '1'B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007411 } else {
7412 ma_mask := ma_mask & '0'B;
7413 }
7414 }
7415
Vadim Yanitskiy3e997362020-09-05 21:08:34 +07007416 /* ARFCN 0 (if present) goes to the last position of the bit-mask */
7417 if (full_mask[0] == '1'B) {
7418 /* FIXME: ma_mask := ma_mask & slot_mask[0]; // triggers a bug in TITAN */
7419 if (slot_mask[0] == '1'B) {
7420 ma_mask := ma_mask & '1'B;
7421 } else {
7422 ma_mask := ma_mask & '0'B;
7423 }
7424 }
7425
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007426 /* Ensure that ma_mask is octet-aligned */
Vadim Yanitskiy2aa02522020-09-06 14:05:23 +07007427 var integer ma_mask_len := (lengthof(ma_mask) + 8 - 1) / 8;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007428 ma_mask := f_pad_bit(ma_mask, ma_mask_len * 8, '0'B);
7429
7430 return { len := ma_mask_len, ma := ma_mask };
7431}
7432
7433/* Configure the hopping parameters in accordance with the given record */
7434private function f_TC_fh_params_set(in FHParamsTrx fhp,
7435 uint8_t bts_nr := 0,
7436 uint8_t trx_nr := 0)
7437runs on test_CT {
7438 /* Enter the configuration node for the given BTS/TRX numbers */
7439 f_vty_enter_cfg_trx(BSCVTY, bts_nr, trx_nr);
7440
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007441 f_vty_transceive(BSCVTY, "arfcn " & int2str(fhp.arfcn));
7442
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007443 for (var integer tn := 0; tn < lengthof(fhp.ts); tn := tn + 1) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007444 f_vty_transceive(BSCVTY, "timeslot " & int2str(tn));
7445
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007446 if (not fhp.ts[tn].enabled) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007447 f_vty_transceive(BSCVTY, "hopping enabled 0");
7448 f_vty_transceive(BSCVTY, "exit"); /* go back */
7449 continue;
7450 }
7451
7452 /* Configure HSN / MAIO values */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007453 f_vty_transceive(BSCVTY, "hopping sequence-number " & int2str(fhp.ts[tn].hsn));
7454 f_vty_transceive(BSCVTY, "hopping maio " & int2str(fhp.ts[tn].maio));
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007455
7456 /* Configure the Mobile Allocation (hopping channels) */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007457 for (var integer i := 0; i < lengthof(fhp.ts[tn].ma); i := i + 1) {
7458 f_vty_transceive(BSCVTY, "hopping arfcn add " & int2str(fhp.ts[tn].ma[i]));
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007459 }
7460
7461 f_vty_transceive(BSCVTY, "hopping enabled 1");
7462 f_vty_transceive(BSCVTY, "exit"); /* go back */
7463 }
7464
7465 f_vty_transceive(BSCVTY, "end");
7466}
7467
7468/* Disable frequency hopping on all timeslots */
7469private function f_TC_fh_params_unset(in FHParamsTrx fhp,
7470 uint8_t bts_nr := 0,
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007471 uint8_t trx_nr := 0,
7472 GsmArfcn arfcn := 871)
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007473runs on test_CT {
7474 /* Enter the configuration node for the given BTS/TRX numbers */
7475 f_vty_enter_cfg_trx(BSCVTY, bts_nr, trx_nr);
7476
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007477 f_vty_transceive(BSCVTY, "arfcn " & int2str(arfcn));
7478
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007479 for (var integer tn := 0; tn < lengthof(fhp.ts); tn := tn + 1) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007480 f_vty_transceive(BSCVTY, "timeslot " & int2str(tn));
7481
7482 /* Delete all ARFCNs from the Mobile Allocation (if any) */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007483 for (var integer i := 0; i < lengthof(fhp.ts[tn].ma); i := i + 1) {
7484 f_vty_transceive(BSCVTY, "hopping arfcn del " & int2str(fhp.ts[tn].ma[i]));
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007485 }
7486
7487 f_vty_transceive(BSCVTY, "hopping enabled 0");
7488 f_vty_transceive(BSCVTY, "exit"); /* go back */
7489 }
7490
7491 f_vty_transceive(BSCVTY, "end");
7492 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7493}
7494
7495/* Verify presence and correctness of the hopping parameters (HSN, MAIO)
7496 * in the Channel Identification IE of the RSL CHANnel ACTIVation message. */
7497testcase TC_fh_params_chan_activ() runs on test_CT {
7498 var FHParamsTrx fhp := f_TC_fh_params_gen();
7499 var RSL_Message rsl_msg;
7500 var RSL_IE_Body ie;
7501
7502 f_init_vty();
7503
7504 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
7505 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7506
7507 f_init(1);
7508
7509 /* CS domain: 3 (SDCCH/4+CBCH) + 4 (TCH/F) + 2 (TCH/H) channels available */
7510 for (var integer i := 0; i < 9; i := i + 1) {
7511 f_ipa_tx(0, ts_RSL_CHAN_RQD(f_rnd_ra_cs(), 23));
7512 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7513
7514 /* Make sure that Channel Identification IE is present */
7515 if (not f_rsl_find_ie(rsl_msg, RSL_IE_CHAN_IDENT, ie)) {
7516 setverdict(fail, "RSL Channel Identification IE is absent");
7517 continue;
7518 }
7519
7520 /* Make sure that hopping parameters (HSN/MAIO) match */
7521 f_TC_fh_params_match_chan_desc(fhp, ie.chan_ident.ch_desc.v);
7522
7523 /* "Mobile Allocation shall be included but empty" - let's check this */
7524 if (ie.chan_ident.ma.v.len != 0) {
7525 setverdict(fail, "Mobile Allocation IE is not empty: ",
7526 ie.chan_ident.ma, ", despite it shall be");
7527 continue;
7528 }
7529 }
7530
7531 /* Disable frequency hopping */
7532 f_TC_fh_params_unset(fhp);
7533
Vadim Yanitskiy21726312020-09-04 01:45:36 +07007534 f_shutdown_helper();
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007535}
7536
7537/* Verify the hopping parameters (HSN, MAIO, MA) in (RR) Immediate Assignment */
7538testcase TC_fh_params_imm_ass() runs on test_CT {
7539 var FHParamsTrx fhp := f_TC_fh_params_gen();
7540 var RSL_Message rsl_msg;
7541 var RSL_IE_Body ie;
7542
7543 f_init_vty();
7544
7545 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
7546 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7547
7548 f_init(1);
7549
7550 /* CS domain: 3 (SDCCH/4+CBCH) + 4 (TCH/F) + 2 (TCH/H) channels available */
7551 for (var integer i := 0; i < 9; i := i + 1) {
7552 f_ipa_tx(0, ts_RSL_CHAN_RQD(f_rnd_ra_cs(), 23));
7553 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7554
7555 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(rsl_msg.ies[0].body.chan_nr, 33));
7556 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeC(RSL_MT_IMMEDIATE_ASSIGN_CMD));
7557
7558 /* Make sure that Full Immediate Assign Info IE is present */
7559 if (not f_rsl_find_ie(rsl_msg, RSL_IE_FULL_IMM_ASS_INFO, ie)) {
7560 setverdict(fail, "RSL Full Immediate Assign Info IE is absent");
7561 continue;
7562 }
7563
7564 /* Decode the actual Immediate Assignment message */
7565 var GsmRrMessage rr_msg := dec_GsmRrMessage(ie.full_imm_ass_info.payload);
7566 if (not match(rr_msg.header, t_RrHeader(IMMEDIATE_ASSIGNMENT, ?))) {
7567 setverdict(fail, "Failed to match Immediate Assignment: ", rr_msg);
7568 continue;
7569 }
7570
7571 /* Make sure that hopping parameters (HSN/MAIO) match */
7572 f_TC_fh_params_match_chan_desc(fhp, rr_msg.payload.imm_ass.chan_desc);
7573
7574 /* Make sure that the Mobile Allocation IE matches */
7575 f_TC_fh_params_match_ma(fhp, rr_msg.payload.imm_ass.chan_desc.chan_nr.tn,
7576 rr_msg.payload.imm_ass.mobile_allocation);
7577 }
7578
7579 /* Disable frequency hopping */
7580 f_TC_fh_params_unset(fhp);
Philipp Maier82812002020-08-13 18:48:27 +02007581
Vadim Yanitskiy21726312020-09-04 01:45:36 +07007582 f_shutdown_helper();
Philipp Maier82812002020-08-13 18:48:27 +02007583}
7584
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07007585/* Verify the hopping parameters (HSN, MAIO, MA) in (RR) Assignment Command */
7586testcase TC_fh_params_assignment_cmd() runs on test_CT {
7587 var FHParamsTrx fhp := f_TC_fh_params_gen();
7588 var RSL_Message rsl_msg;
7589 var RSL_IE_Body ie;
7590
7591 f_init_vty();
7592
7593 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
7594 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7595
7596 f_init(1);
7597
7598 /* HACK: work around "Couldn't find Expect for CRCX" */
7599 vc_MGCP.stop;
7600
7601 var template PDU_BSSAP ass_cmd := f_gen_ass_req();
7602 ass_cmd.pdu.bssmap.assignmentRequest.codecList := ts_BSSMAP_IE_CodecList({ts_CodecFR});
7603
7604 /* CS domain (TCH): 4 (TCH/F) + 2 (TCH/H) channels available
7605 * NOTE: only 3 SDCCH/4 channels are available on CCCH+SDCCH4+CBCH */
7606 for (var integer i := 0; i < 3; i := i + 1) {
7607 /* Establish a dedicated channel, so we can trigger (late) TCH assignment */
7608 var DchanTuple dt := f_est_dchan(f_rnd_ra_cs(), 23, f_rnd_octstring(16));
7609
7610 /* Send a BSSMAP Assignment Command, expect CHANnel ACTIVation */
7611 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ass_cmd));
7612 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7613
7614 /* ACKnowledge CHANnel ACTIVation, expect RSL DATA REQuest */
7615 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(rsl_msg.ies[0].body.chan_nr, 33));
7616 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeR(RSL_MT_DATA_REQ));
7617
7618 /* Make sure that L3 Information IE is present */
7619 if (not f_rsl_find_ie(rsl_msg, RSL_IE_L3_INFO, ie)) {
7620 setverdict(fail, "RSL L3 Information IE is absent");
7621 continue;
7622 }
7623
7624 /* Decode the L3 message and make sure it is (RR) Assignment Command */
7625 var GsmRrL3Message l3_msg := dec_GsmRrL3Message(ie.l3_info.payload);
7626 if (not match(l3_msg.header, t_RrL3Header(ASSIGNMENT_COMMAND))) {
7627 setverdict(fail, "Failed to match Assignment Command: ", l3_msg);
7628 continue;
7629 }
7630
7631 /* Make sure that hopping parameters (HSN/MAIO) match */
7632 var ChannelDescription chan_desc := l3_msg.payload.ass_cmd.chan_desc;
7633 f_TC_fh_params_match_chan_desc(fhp, chan_desc);
7634
7635 /* Make sure that Cell Channel Description IE is present if FH is enabled */
7636 if (chan_desc.h and not ispresent(l3_msg.payload.ass_cmd.cell_chan_desc)) {
Vadim Yanitskiy38d069d2020-09-02 17:18:57 +07007637 setverdict(fail, "FH enabled, but Cell Channel Description IE is absent");
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07007638 continue;
7639 }
7640
7641 /* Make sure that the Mobile Allocation IE matches (if present) */
7642 var boolean ma_present := ispresent(l3_msg.payload.ass_cmd.mobile_allocation);
7643 if (chan_desc.h and ma_present) {
7644 f_TC_fh_params_match_ma(fhp, chan_desc.chan_nr.tn,
7645 l3_msg.payload.ass_cmd.mobile_allocation.v);
7646 } else if (chan_desc.h and not ma_present) {
7647 setverdict(fail, "FH enabled, but Mobile Allocation IE is absent");
7648 continue;
7649 } else if (not chan_desc.h and ma_present) {
7650 setverdict(fail, "FH disabled, but Mobile Allocation IE is present");
7651 continue;
7652 }
7653 }
7654
7655 /* Give the IUT some time to release all channels */
7656 f_sleep(3.0);
7657
7658 /* Disable frequency hopping */
7659 f_TC_fh_params_unset(fhp);
7660
Vadim Yanitskiy21726312020-09-04 01:45:36 +07007661 f_shutdown_helper();
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07007662}
7663
Vadim Yanitskiy8f5430d2020-09-02 18:51:38 +07007664/* Verify the hopping parameters (HSN, MAIO, MA) in (RR) Handover Command */
7665private function f_TC_fh_params_handover_cmd(in FHParamsTrx fhp)
7666runs on test_CT {
7667 var RSL_Message rsl_msg;
7668 var RSL_IE_Body ie;
7669 var DchanTuple dt;
7670
7671 /* Establish a dedicated channel, so we can trigger handover */
7672 dt := f_est_dchan(f_rnd_ra_cs(), 23, f_rnd_octstring(16));
7673
7674 /* Trigger handover from BTS0 to BTS1 */
7675 f_bts_0_cfg(BSCVTY, { "neighbor bts 1" });
7676 f_vty_handover(BSCVTY, 0, 0, dt.rsl_chan_nr, 1);
7677
7678 /* Expect RSL CHANnel ACTIVation on BTS1/TRX0/TS1 */
7679 rsl_msg := f_exp_ipa_rx(1, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7680
7681 /* ACKnowledge channel activation and expect (RR) Handover Command */
7682 f_ipa_tx(1, ts_RSL_CHAN_ACT_ACK(rsl_msg.ies[0].body.chan_nr, 33));
7683 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeR(RSL_MT_DATA_REQ));
7684
7685 /* Make sure that L3 Information IE is present */
7686 if (not f_rsl_find_ie(rsl_msg, RSL_IE_L3_INFO, ie)) {
7687 setverdict(fail, "RSL L3 Information IE is absent");
7688 return;
7689 }
7690
7691 /* Decode the L3 message and make sure it is (RR) Handover Command */
7692 var GsmRrL3Message l3_msg := dec_GsmRrL3Message(ie.l3_info.payload);
7693 if (not match(l3_msg.header, t_RrL3Header(HANDOVER_COMMAND))) {
7694 setverdict(fail, "Failed to match Handover Command: ", l3_msg);
7695 return;
7696 }
7697
7698 /* Make sure that we've got SDCCH/8 on TS1 (expected to be hopping) */
7699 var ChannelDescription chan_desc := l3_msg.payload.ho_cmd.chan_desc;
7700 if (not match(chan_desc.chan_nr, t_RslChanNr_SDCCH8(1, ?))) {
7701 setverdict(fail, "Unexpected channel number: ", chan_desc.chan_nr);
7702 return;
7703 }
7704
7705 /* Make sure that hopping parameters (HSN/MAIO) match */
7706 f_TC_fh_params_match_chan_desc(fhp, chan_desc);
7707
7708 /* Make sure that Cell Channel Description IE is present */
7709 if (not ispresent(l3_msg.payload.ho_cmd.cell_chan_desc)) {
7710 setverdict(fail, "FH enabled, but Cell Channel Description IE is absent");
7711 return;
7712 }
7713
7714 /* Make sure that the Mobile Allocation (after time) IE is present and matches */
7715 var boolean ma_present := ispresent(l3_msg.payload.ho_cmd.mobile_allocation);
7716 if (ma_present) {
7717 f_TC_fh_params_match_ma(fhp, chan_desc.chan_nr.tn,
7718 l3_msg.payload.ho_cmd.mobile_allocation.v);
7719 } else {
7720 setverdict(fail, "FH enabled, but Mobile Allocation IE is absent");
7721 return;
7722 }
7723}
7724testcase TC_fh_params_handover_cmd() runs on test_CT {
7725 var FHParamsTrx fhp := f_TC_fh_params_gen();
7726
7727 f_init_vty();
7728
7729 /* (Re)configure TS0 as BCCH and TS1 as SDCCH8 on BTS1/TRX0 */
7730 f_vty_enter_cfg_trx(BSCVTY, bts := 1, trx := 0);
7731
7732 f_vty_transceive(BSCVTY, "timeslot 0");
7733 f_vty_transceive(BSCVTY, "phys_chan_config ccch");
7734 f_vty_transceive(BSCVTY, "exit"); /* go back */
7735
7736 f_vty_transceive(BSCVTY, "timeslot 1");
7737 f_vty_transceive(BSCVTY, "phys_chan_config sdcch8");
7738 f_vty_transceive(BSCVTY, "end"); /* we're done */
7739
7740 f_TC_fh_params_set(fhp, 1); /* Enable frequency hopping on BTS1 */
7741 f_vty_transceive(BSCVTY, "drop bts connection 1 oml");
7742
7743 f_init(2);
7744
7745 f_TC_fh_params_handover_cmd(fhp);
7746
7747 /* Disable frequency hopping on BTS1 */
7748 f_TC_fh_params_unset(fhp, 1);
7749
7750 /* (Re)configure TS0 as CCCH+SDCCH4+CBCH and TS1 as TCH/F */
7751 f_vty_enter_cfg_trx(BSCVTY, bts := 1, trx := 0);
7752
7753 f_vty_transceive(BSCVTY, "timeslot 0");
7754 f_vty_transceive(BSCVTY, "phys_chan_config ccch+sdcch4+cbch");
7755 f_vty_transceive(BSCVTY, "exit"); /* go back */
7756
7757 f_vty_transceive(BSCVTY, "timeslot 1");
7758 f_vty_transceive(BSCVTY, "phys_chan_config tch/f");
7759 f_vty_transceive(BSCVTY, "end"); /* we're done */
7760
7761 f_shutdown_helper();
7762}
7763
Vadim Yanitskiyca974032020-09-01 07:20:39 +07007764/* Verify the hopping parameters in System Information Type 4 */
7765testcase TC_fh_params_si4_cbch() runs on test_CT {
7766 var FHParamsTrx fhp := f_TC_fh_params_gen(tr_tn := 1);
7767 var ASP_RSL_Unitdata rx_rsl_ud;
7768 timer T := 5.0;
7769
7770 f_init_vty();
7771
7772 /* (Re)configure TS0 as BCCH and TS1 as SDCCH8+CBCH */
7773 f_vty_enter_cfg_trx(BSCVTY, trx := 0);
7774
7775 f_vty_transceive(BSCVTY, "timeslot 0");
7776 f_vty_transceive(BSCVTY, "phys_chan_config ccch");
7777 f_vty_transceive(BSCVTY, "exit"); /* go back */
7778
7779 f_vty_transceive(BSCVTY, "timeslot 1");
7780 f_vty_transceive(BSCVTY, "phys_chan_config sdcch8+cbch");
7781 f_vty_transceive(BSCVTY, "end"); /* we're done */
7782
7783 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
7784 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7785
7786 f_init(1);
7787
7788 T.start;
7789 alt {
7790 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_BCCH_INFO(RSL_SYSTEM_INFO_4))) -> value rx_rsl_ud {
7791 var RSL_IE_Body ie := rx_rsl_ud.rsl.ies[2].body; /* FULL BCCH Information IE */
7792 var SystemInformation si := dec_SystemInformation(ie.other.payload);
7793
7794 /* Make sure that what we decoded is System Information Type 4 */
7795 if (si.header.message_type != SYSTEM_INFORMATION_TYPE_4) {
7796 setverdict(fail, "RSL FULL BCCH Information IE contains: ", si);
7797 repeat;
7798 }
7799
7800 /* Make sure that CBCH Channel Description IE is present */
7801 if (not ispresent(si.payload.si4.cbch_chan_desc)) {
7802 setverdict(fail, "CBCH Channel Description IE is absent");
7803 break;
7804 }
7805
7806 /* Finally, check the hopping parameters (HSN, MAIO) */
7807 var ChannelDescription chan_desc := si.payload.si4.cbch_chan_desc.v;
7808 f_TC_fh_params_match_chan_desc(fhp, chan_desc);
7809
7810 /* 3GPP TS 44.018, section 9.1.36.2 "CBCH Mobile Allocation":
7811 * The CBCH Mobile Allocation IE *shall* be present if FH is enabled. */
7812 if (chan_desc.h and not ispresent(si.payload.si4.cbch_mobile_alloc)) {
7813 setverdict(fail, "FH enabled, but Mobile Allocation IE is absent");
7814 break;
7815 } else if (chan_desc.h and ispresent(si.payload.si4.cbch_mobile_alloc)) {
7816 f_TC_fh_params_match_ma(fhp, chan_desc.chan_nr.tn,
7817 si.payload.si4.cbch_mobile_alloc.v);
7818 }
7819 }
7820 [] IPA_RSL[0].receive { repeat; }
7821 [] T.timeout {
7822 setverdict(fail, "Timeout waiting for RSL BCCH INFOrmation (SI4)");
7823 }
7824 }
7825
7826 /* Disable frequency hopping */
7827 f_TC_fh_params_unset(fhp);
7828
Vadim Yanitskiy8bc46012020-09-06 12:38:01 +07007829 /* (Re)configure TS0 as CCCH+SDCCH4+CBCH and TS1 as TCH/F */
Vadim Yanitskiyca974032020-09-01 07:20:39 +07007830 f_vty_enter_cfg_trx(BSCVTY, trx := 0);
7831
7832 f_vty_transceive(BSCVTY, "timeslot 0");
Vadim Yanitskiy8bc46012020-09-06 12:38:01 +07007833 f_vty_transceive(BSCVTY, "phys_chan_config ccch+sdcch4+cbch");
Vadim Yanitskiyca974032020-09-01 07:20:39 +07007834 f_vty_transceive(BSCVTY, "exit"); /* go back */
7835
7836 f_vty_transceive(BSCVTY, "timeslot 1");
7837 f_vty_transceive(BSCVTY, "phys_chan_config tch/f");
7838 f_vty_transceive(BSCVTY, "end"); /* we're done */
7839
Vadim Yanitskiy21726312020-09-04 01:45:36 +07007840 f_shutdown_helper();
Vadim Yanitskiyca974032020-09-01 07:20:39 +07007841}
7842
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02007843template (value) PDU_BSSAP_LE ts_BSSMAP_LE_BSSLAP(template (value) BSSLAP_PDU bsslap)
7844 := ts_BSSMAP_LE_ConnInfo(BSSMAP_LE_PROT_BSSLAP, data := enc_BSSLAP_PDU(valueof(bsslap)));
7845
7846private function f_match_bsslap(PDU_BSSAP_LE got_bsslap_msg,
7847 template (present) BSSLAP_PDU expect_bsslap)
7848{
7849 var BSSLAP_PDU bsslap := dec_BSSLAP_PDU(got_bsslap_msg.pdu.bssmap.co_info.bsslap_apdu.data);
7850 if (not match(bsslap, expect_bsslap)) {
7851 log("EXPECTING BSSLAP: ", expect_bsslap);
7852 log("GOT BSSLAP: ", bsslap);
7853 setverdict(fail, "BSSLAP is not as expected");
7854 mtc.stop;
7855 }
7856 setverdict(pass);
7857}
7858
7859/* GAD: this is an Ellipsoid point with uncertainty circle, encoded as in 3GPP TS 23.032 §7.3.2. */
7860const octetstring gad_ell_point_unc_circle := '10b0646d0d5f6627'O;
7861
7862private function f_expect_bsslap(template (present) BSSLAP_PDU expect_rx_bsslap) runs on MSC_ConnHdlr {
7863 var PDU_BSSAP_LE rx_bsslap;
7864 BSSAP_LE.receive(tr_BSSMAP_LE_ConnInfo(BSSMAP_LE_PROT_BSSLAP, ?)) -> value(rx_bsslap);
7865 f_match_bsslap(rx_bsslap, expect_rx_bsslap);
7866}
7867
7868/* With an active lchan, start BSSMAP Perform Location Request on A interface, starting BSSMAP-LE Perform Location
7869 * Request on Lb interface. Either with or without the SMLC doing a BSSLAP TA Request. */
7870private function f_lcs_loc_req_for_active_ms(boolean do_ta_request := false) runs on MSC_ConnHdlr {
7871 f_sleep(1.0);
7872
7873 f_establish_fully(omit, omit);
7874 f_bssap_le_register_imsi(g_pars.imsi, omit);
7875
7876 BSSAP.send(valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
7877 ts_CellId_CGI('262'H, '42'H, 23, 42))));
7878
7879 var PDU_BSSAP_LE plr;
7880 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
7881
7882 if (not do_ta_request) {
7883 /* verify TA Layer 3 in APDU. First the APDU type (BSSLAP), then the BSSLAP data contents. */
7884 var template BSSMAP_LE_IE_APDU expect_apdu := tr_BSSMAP_LE_APDU(BSSMAP_LE_PROT_BSSLAP, ?);
7885 if (not match(plr.pdu.bssmap.perf_loc_req.bsslap_apdu, expect_apdu)) {
7886 log("EXPECTING BSSMAP-LE APDU IE ", expect_apdu);
7887 log("GOT BSSMAP-LE APDU IE ", plr.pdu.bssmap.perf_loc_req.bsslap_apdu);
7888 setverdict(fail, "BSSMAP-LE APDU IE is not as expected");
7889 mtc.stop;
7890 }
7891 var template BSSLAP_PDU expect_ta_layer3 := tr_BSSLAP_TA_Layer3(tr_BSSLAP_IE_TA(0));
7892 var BSSLAP_PDU bsslap := dec_BSSLAP_PDU(plr.pdu.bssmap.perf_loc_req.bsslap_apdu.data);
7893 if (not match(bsslap, expect_ta_layer3)) {
7894 log("EXPECTING BSSLAP TA Layer 3: ", expect_ta_layer3);
7895 log("GOT BSSLAP: ", bsslap);
7896 setverdict(fail, "BSSLAP is not as expected");
7897 mtc.stop;
7898 }
7899 /* OsmoBSC directly sent the TA as BSSLAP APDU in the BSSMAP-LE Perform Location Request to the SMLC. The SMLC
7900 * has no need to request the TA from the BSC and directly responds. */
7901 } else {
7902 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
7903 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
7904 f_expect_bsslap(tr_BSSLAP_TA_Resp(?, ?));
7905 }
7906
7907 /* SMLC got the TA from the BSC, now responds with geo information data. */
7908 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(gad_ell_point_unc_circle, omit));
7909 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
7910 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(tr_BSSMAP_IE_LocationEstimate(gad_ell_point_unc_circle)));
7911
7912 /* The LCS was using an active A-interface conn. It should still remain active after this. */
7913 f_mo_l3_transceive();
7914
7915 f_perform_clear(RSL);
7916
7917 f_sleep(2.0);
7918 setverdict(pass);
7919}
7920
7921/* With an active lchan, start BSSMAP Perform Location Request on A interface, starting BSSMAP-LE Perform Location
7922 * Request on Lb interface. Without the SMLC doing a BSSLAP TA Request. */
7923private function f_tc_lcs_loc_req_for_active_ms(charstring id) runs on MSC_ConnHdlr {
7924 f_lcs_loc_req_for_active_ms(false);
7925}
7926testcase TC_lcs_loc_req_for_active_ms() runs on test_CT {
7927 var MSC_ConnHdlr vc_conn;
7928 var TestHdlrParams pars := f_gen_test_hdlr_pars();
7929
7930 f_init(1, true);
7931 f_sleep(1.0);
7932 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_active_ms), pars);
7933 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01007934 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02007935}
7936
7937/* With an active lchan, start BSSMAP Perform Location Request on A interface, starting BSSMAP-LE Perform Location
7938 * Request on Lb interface. With the SMLC doing a BSSLAP TA Request. */
7939private function f_tc_lcs_loc_req_for_active_ms_ta_req(charstring id) runs on MSC_ConnHdlr {
7940 f_lcs_loc_req_for_active_ms(true);
7941}
7942testcase TC_lcs_loc_req_for_active_ms_ta_req() runs on test_CT {
7943 var MSC_ConnHdlr vc_conn;
7944 var TestHdlrParams pars := f_gen_test_hdlr_pars();
7945
7946 f_init(1, true);
7947 f_sleep(1.0);
7948 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_active_ms_ta_req), pars);
7949 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01007950 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02007951}
7952
7953/* Clear the A-interface conn only, without doing anything on Abis. Useful for LCS, for cases where there is only an A
7954 * conn without an active lchan. */
7955private function f_clear_A_conn() runs on MSC_ConnHdlr
7956{
7957 var BssmapCause cause := 0;
7958 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
7959 BSSAP.receive(tr_BSSMAP_ClearComplete);
7960 BSSAP.send(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_REQ);
7961
7962 timer no_more_bssap := 5.0;
7963 no_more_bssap.start;
7964 alt {
7965 [] no_more_bssap.timeout { break; }
7966 [] BSSAP.receive(tr_BSSAP_BSSMAP) {
7967 setverdict(fail, "Expected no more BSSAP after Clear Complete");
7968 mtc.stop;
7969 }
7970 }
7971 setverdict(pass);
7972}
7973
7974/* Verify that the A-interface connection is still working, and then clear it, without doing anything on Abis. Useful
7975 * for LCS, for cases where there is only an A conn without an active lchan. */
7976private function f_verify_active_A_conn_and_clear() runs on MSC_ConnHdlr
7977{
7978 f_logp(BSCVTY, "f_verify_active_A_conn_and_clear: test A link, then clear");
7979
7980 /* When an lchan is active, we can send some L3 data from the BTS side and verify that it shows up on the other
7981 * side towards the MSC. When there is no lchan, this is not possible. To probe whether the A-interface
7982 * connection is still up, we need something that echos back on the A-interface. Another LCS request! */
7983 BSSAP.send(valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
7984 ts_CellId_CGI('262'H, '42'H, 23, 42))));
7985 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?));
7986
7987 /* Right, the Perform Location Request showed up on Lb, now we can clear the A conn. */
7988 f_clear_A_conn();
7989 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocAbort(BSSMAP_LE_LCS_CAUSE_REQUEST_ABORTED));
7990 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
7991}
7992
7993/* With *no* active lchan, start BSSMAP Perform Location Request on A interface, starting BSSMAP-LE Perform Location
7994 * Request on Lb interface. BSC will Page for the subscriber as soon as we (virtual SMLC) request the TA via BSSLAP.
7995 */
7996private function f_tc_lcs_loc_req_for_idle_ms(charstring id) runs on MSC_ConnHdlr {
7997 f_sleep(1.0);
7998
7999 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
8000 f_bssap_le_register_imsi(g_pars.imsi, omit);
8001
8002 /* Register to receive the Paging Command */
8003 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
8004 g_chan_nr := new_chan_nr;
8005 f_rslem_register(0, g_chan_nr);
8006
8007 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
8008 valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
8009 ts_CellId_CGI('001'H, '01'H, 1, 0)))));
8010 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
8011
8012 var PDU_BSSAP_LE plr;
8013 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
8014
8015 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
8016 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
8017
8018 /* OsmoBSC needs to Page */
8019 RSL.receive(tr_RSL_PAGING_CMD(tr_MI_IMSI(g_pars.imsi)));
8020 f_logp(BSCVTY, "got Paging Command");
8021
8022 /* MS requests channel. Since the Paging was for LCS, the Paging Response does not trigger a Complete Layer 3 to
8023 * the MSC, and releases the lchan directly. */
8024 f_perform_compl_l3(RSL, ts_PAG_RESP(valueof(ts_MI_IMSI_LV(g_pars.imsi))), do_clear := false, expect_bssmap_l3 := false);
8025 f_expect_lchan_rel(RSL);
8026
8027 /* From the Paging Response, the TA is now known to the BSC, and it responds to the SMLC. */
8028
8029 f_expect_bsslap(tr_BSSLAP_TA_Resp(?, ?));
8030
8031 /* SMLC got the TA from the BSC, now responds with geo information data. */
8032 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(gad_ell_point_unc_circle, omit));
8033 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
8034
8035 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(tr_BSSMAP_IE_LocationEstimate(gad_ell_point_unc_circle)));
8036
8037 /* The lchan is gone, the A-interface conn was created for the LCS only.
8038 * Still it is clearly the MSC's job to decide whether to tear down the conn or not. */
8039 f_verify_active_A_conn_and_clear();
8040
8041 f_sleep(2.0);
8042 setverdict(pass);
8043}
8044testcase TC_lcs_loc_req_for_idle_ms() runs on test_CT {
8045 var MSC_ConnHdlr vc_conn;
8046 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8047
8048 f_init(1, true);
8049 f_sleep(1.0);
8050
8051 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
8052 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
8053
8054 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_idle_ms), pars);
8055 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008056 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008057}
8058
8059/* With no active lchan, start BSSMAP Perform Location Request on A interface, but omit IMSI; expect failure response.
8060 */
8061private function f_tc_lcs_loc_req_no_subscriber(charstring id) runs on MSC_ConnHdlr {
8062 f_sleep(1.0);
8063
8064 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
8065 f_bssap_le_register_imsi(g_pars.imsi, omit);
8066
8067 /* provoke an abort by omitting both IMSI and IMEI */
8068 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
8069 valueof(ts_BSSMAP_Perform_Location_Request(omit,
8070 ts_CellId_CGI('262'H, '42'H, 23, 42)))));
8071 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
8072
8073 /* BSC tells MSC about failure */
8074 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(
8075 locationEstimate := omit, positioningData := omit,
8076 lCS_Cause := tr_BSSMAP_LcsCause(BSSMAP_LCS_CAUSE_DATA_MISSING_IN_REQ)));
8077
8078 /* There is no lchan. Still the MSC's job to decide whether to tear down the conn or not. */
8079 f_verify_active_A_conn_and_clear();
8080
8081 f_sleep(2.0);
8082 setverdict(pass);
8083}
8084testcase TC_lcs_loc_req_no_subscriber() runs on test_CT {
8085 var MSC_ConnHdlr vc_conn;
8086 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8087
8088 f_init(1, true);
8089 f_sleep(1.0);
8090
8091 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
8092 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
8093
8094 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_no_subscriber), pars);
8095 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008096 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008097}
8098
8099/* With an active lchan, start a Perform Location Request on the A-interface, but virtual SMLC does not answer with
8100 * BSSMAP-LE Perform Location Response (before or after sending a BSSLAP TA Request) */
8101private function f_lcs_loc_req_for_active_ms_le_timeout(boolean do_ta) runs on MSC_ConnHdlr {
8102 f_sleep(1.0);
8103
8104 f_establish_fully(omit, omit);
8105 f_bssap_le_register_imsi(g_pars.imsi, omit);
8106
8107 BSSAP.send(valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
8108 ts_CellId_CGI('262'H, '42'H, 23, 42))));
8109
8110 var PDU_BSSAP_LE plr;
8111 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
8112
8113 if (do_ta) {
8114 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
8115 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
8116 f_expect_bsslap(tr_BSSLAP_TA_Resp(?, ?));
8117 }
8118
8119 /* SMLC fails to respond, BSC runs into timeout */
8120 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocAbort(BSSMAP_LE_LCS_CAUSE_SYSTEM_FAILURE));
8121 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
8122
8123 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(
8124 locationEstimate := omit, positioningData := omit,
8125 lCS_Cause := tr_BSSMAP_LcsCause(BSSMAP_LCS_CAUSE_SYSTEM_FAILURE)));
8126
8127 /* There is no lchan. Still the MSC's job to decide whether to tear down the conn or not. */
8128 f_verify_active_A_conn_and_clear();
8129
8130 f_sleep(2.0);
8131 setverdict(pass);
8132}
8133
8134/* With an active lchan, start a Perform Location Request on the A-interface, but virtual SMLC does not answer with
8135 * BSSMAP-LE Perform Location Response, without sending a BSSLAP TA Request. */
8136private function f_tc_lcs_loc_req_for_active_ms_le_timeout(charstring id) runs on MSC_ConnHdlr {
8137 f_lcs_loc_req_for_active_ms_le_timeout(false);
8138}
8139
8140testcase TC_lcs_loc_req_for_active_ms_le_timeout() runs on test_CT {
8141 var MSC_ConnHdlr vc_conn;
8142 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8143
8144 f_init(1, true);
8145 f_sleep(1.0);
8146 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_active_ms_le_timeout), pars);
8147 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008148 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008149}
8150
8151/* With an active lchan, start a Perform Location Request on the A-interface, but virtual SMLC does not answer with
8152 * BSSMAP-LE Perform Location Response, after sending a BSSLAP TA Request. */
8153private function f_tc_lcs_loc_req_for_active_ms_le_timeout2(charstring id) runs on MSC_ConnHdlr {
8154 f_lcs_loc_req_for_active_ms_le_timeout(true);
8155}
8156
8157testcase TC_lcs_loc_req_for_active_ms_le_timeout2() runs on test_CT {
8158 var MSC_ConnHdlr vc_conn;
8159 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8160
8161 f_init(1, true);
8162 f_sleep(1.0);
8163 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_active_ms_le_timeout2), pars);
8164 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008165 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008166}
8167
8168/* With *no* active lchan, start a Perform Location Request, expecting that the MS will be Paged. */
8169private function f_tc_lcs_loc_req_for_idle_ms_no_pag_resp(charstring id) runs on MSC_ConnHdlr {
8170 f_sleep(1.0);
8171
8172 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
8173 f_bssap_le_register_imsi(g_pars.imsi, omit);
8174
8175 /* Register to receive the Paging Command */
8176 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
8177 g_chan_nr := new_chan_nr;
8178 f_rslem_register(0, g_chan_nr);
8179
8180 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
8181 valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
8182 ts_CellId_CGI('001'H, '01'H, 1, 0)))));
8183 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
8184
8185 var PDU_BSSAP_LE plr;
8186 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
8187
8188 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
8189 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
8190
8191 /* OsmoBSC needs to Page */
8192 var PDU_BSSAP_LE rx_bsslap;
8193 alt {
8194 [] RSL.receive(tr_RSL_PAGING_CMD(tr_MI_IMSI(g_pars.imsi))) {
8195 f_logp(BSCVTY, "got Paging Command");
8196 repeat;
8197 }
8198 [] BSSAP_LE.receive(tr_BSSMAP_LE_ConnInfo(BSSMAP_LE_PROT_BSSLAP, ?)) -> value(rx_bsslap) {
8199 /* MS does not respond to Paging, TA Req runs into timeout. */
8200 f_match_bsslap(rx_bsslap, tr_BSSLAP_Abort(?));
8201 }
8202 }
8203
8204 /* SMLC responds with failure */
8205 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(omit, BSSMAP_LE_LCS_CAUSE_REQUEST_ABORTED));
8206 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
8207
8208 /* BSC tells MSC about failure */
8209 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(
8210 locationEstimate := omit, positioningData := omit,
8211 lCS_Cause := tr_BSSMAP_LcsCause(BSSMAP_LCS_CAUSE_REQUEST_ABORTED)));
8212
8213 /* There is no lchan. Still the MSC's job to decide whether to tear down the conn or not. */
8214 f_verify_active_A_conn_and_clear();
8215
8216 f_sleep(2.0);
8217 setverdict(pass);
8218}
8219testcase TC_lcs_loc_req_for_idle_ms_no_pag_resp() runs on test_CT {
8220 var MSC_ConnHdlr vc_conn;
8221 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8222
8223 f_init(1, true);
8224 f_sleep(1.0);
8225
8226 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
8227 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
8228
8229 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_idle_ms_no_pag_resp), pars);
8230 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008231 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008232}
8233
8234/* During an ongoing Location Request, the MS sends a CM Service Request. Expect the same A-conn to be re-used / taken
8235 * over. */
8236private function f_tc_cm_service_during_lcs_loc_req(charstring id) runs on MSC_ConnHdlr {
8237 f_sleep(1.0);
8238
8239 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
8240 f_bssap_le_register_imsi(g_pars.imsi, omit);
8241
8242 /* Register to receive the Paging Command */
8243 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
8244 g_chan_nr := new_chan_nr;
8245 f_rslem_register(0, g_chan_nr);
8246
8247 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
8248 valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
8249 ts_CellId_CGI('001'H, '01'H, 1, 0)))));
8250 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
8251
8252 var PDU_BSSAP_LE plr;
8253 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
8254
8255 /* As the A-interface conn was established for LCS, the MS coincidentally decides to issue a CM Service Request
8256 * and establish Layer 3. It should use the existing A-interface conn. */
8257 f_perform_compl_l3(RSL, valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV(g_pars.imsi)))),
8258 do_clear := false, expect_bssmap_l3 := true);
8259
8260 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
8261 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
8262
8263 /* OsmoBSC already has an lchan, no need to Page, just returns the TA */
8264 f_expect_bsslap(tr_BSSLAP_TA_Resp(?, ?));
8265
8266 /* SMLC got the TA from the BSC, now responds with geo information data. */
8267 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(gad_ell_point_unc_circle, omit));
8268 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
8269 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(tr_BSSMAP_IE_LocationEstimate(gad_ell_point_unc_circle)));
8270
8271 /* The lchan should still exist, it was from a CM Service Request. */
8272 f_mo_l3_transceive();
8273
8274 f_perform_clear(RSL);
8275
8276 f_sleep(2.0);
8277 setverdict(pass);
8278}
8279testcase TC_cm_service_during_lcs_loc_req() runs on test_CT {
8280 var MSC_ConnHdlr vc_conn;
8281 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8282
8283 f_init(1, true);
8284 f_sleep(1.0);
8285
8286 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
8287 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
8288
8289 vc_conn := f_start_handler(refers(f_tc_cm_service_during_lcs_loc_req), pars);
8290 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008291 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008292}
8293
8294/* During an ongoing Perform Location Request, do a Handover, an expect a BSSLAP Reset message from the BSC to indicate
8295 * the new lchan after handover. */
8296private function f_tc_ho_during_lcs_loc_req(charstring id) runs on MSC_ConnHdlr {
8297 f_sleep(1.0);
8298
8299 f_establish_fully(omit, omit);
8300 f_bssap_le_register_imsi(g_pars.imsi, omit);
8301
8302 BSSAP.send(valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
8303 ts_CellId_CGI('262'H, '42'H, 23, 42))));
8304
8305 var PDU_BSSAP_LE plr;
8306 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
8307
8308 /* SMLC ponders the Location Request, in the meantime the BSC decides to handover */
8309 f_bts_0_cfg(BSCVTY, {"neighbor bts 1"});
8310
8311 var HandoverState hs := {
8312 rr_ho_cmpl_seen := false,
8313 handover_done := false,
8314 old_chan_nr := -
8315 };
8316 /* issue hand-over command on VTY */
8317 f_vty_handover(BSCVTY, 0, 0, g_chan_nr, 1);
8318 /* temporarily suspend DChan processing on BTS1 to avoid race with RSLEM_register */
8319 f_rslem_suspend(RSL1_PROC);
8320
8321 /* From the MGW perspective, a handover is is characterized by
8322 * performing one MDCX operation with the MGW. So we expect to see
8323 * one more MDCX during handover. */
8324 g_media.mgcp_conn[0].mdcx_seen_exp := g_media.mgcp_conn[0].crcx_seen_exp + 1;
8325
8326 alt {
8327 [] as_handover(hs);
8328 }
8329
8330 var PDU_BSSAP_LE rx_bsslap;
8331
8332 interleave {
8333 /* Expect the BSC to inform the MSC about the handover */
8334 [] BSSAP.receive(tr_BSSMAP_HandoverPerformed);
8335
8336 /* Expect the BSC to inform the SMLC about the handover */
8337 [] BSSAP_LE.receive(tr_BSSMAP_LE_ConnInfo(BSSMAP_LE_PROT_BSSLAP, ?)) -> value(rx_bsslap) {
8338 f_match_bsslap(rx_bsslap, tr_BSSLAP_Reset(BSSLAP_CAUSE_INTRA_BSS_HO));
8339 }
8340 }
8341
8342 /* SMLC now responds with geo information data. */
8343 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(gad_ell_point_unc_circle, omit));
8344 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
8345 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(tr_BSSMAP_IE_LocationEstimate(gad_ell_point_unc_circle)));
8346
8347 /* lchan still active */
8348 f_mo_l3_transceive(RSL1);
8349
8350 /* MSC decides it is done now. */
8351 f_perform_clear(RSL1);
8352
8353 f_sleep(2.0);
8354 setverdict(pass);
8355}
8356testcase TC_ho_during_lcs_loc_req() runs on test_CT {
8357 var MSC_ConnHdlr vc_conn;
8358 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8359
8360 f_init(2, true);
8361 f_sleep(1.0);
8362 vc_conn := f_start_handler(refers(f_tc_ho_during_lcs_loc_req), pars);
8363 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008364 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008365}
8366
Neels Hofmeyrbf037052020-10-28 22:52:02 +00008367/* Attempt Complete Layer 3 without any MSC available (OS#4832) */
8368private function f_tc_no_msc(charstring id) runs on MSC_ConnHdlr {
8369 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
8370
8371 /* Also disable attach for the single connected MSC */
8372 f_vty_msc_allow_attach(BSCVTY, { false });
8373
8374 var octetstring l3_enc := enc_PDU_ML3_MS_NW(valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000100001'H)), '00F110'O) ));
8375 f_chan_est(g_pars.ra, l3_enc, g_pars.link_id, g_pars.fn);
8376
8377 /* No MSC is found, expecting a proper release on RSL */
8378 interleave {
8379 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
8380 f_logp(BSCVTY, "Got RSL RR Release");
8381 }
8382 [] RSL.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
8383 f_logp(BSCVTY, "Got RSL Deact SACCH");
8384 }
8385 [] RSL.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
8386 f_logp(BSCVTY, "Got RSL RF Chan Rel, sending Rel Ack");
8387 RSL.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
8388 }
8389 }
8390 setverdict(pass);
8391}
8392testcase TC_no_msc() runs on test_CT {
8393
8394 f_init(1, true);
8395 f_sleep(1.0);
8396 var MSC_ConnHdlr vc_conn;
8397 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8398
8399 f_ctrs_bsc_init(counternames_bsc_mscpool);
8400
8401 vc_conn := f_start_handler(refers(f_tc_no_msc), pars);
8402 vc_conn.done;
8403
8404 f_ctrs_bsc_add("mscpool:subscr:no_msc");
8405 f_ctrs_bsc_verify();
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008406 f_shutdown_helper();
Neels Hofmeyrbf037052020-10-28 22:52:02 +00008407}
8408
Harald Welte0ea2d5e2018-04-07 21:40:29 +02008409/* Dyn PDCH todo:
8410 * activate OSMO as TCH/F
8411 * activate OSMO as TCH/H
8412 * does the BSC-located PCU socket get the updated INFO?
8413 * what if no PCU is connected at the time?
8414 * is the info correct on delayed PCU (re)connect?
8415 */
Harald Welte94e0c342018-04-07 11:33:23 +02008416
Harald Welte28d943e2017-11-25 15:00:50 +01008417control {
Harald Welte898113b2018-01-31 18:32:21 +01008418 /* CTRL interface testing */
Harald Welte4003d112017-12-09 22:35:39 +01008419 execute( TC_ctrl_msc_connection_status() );
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01008420 execute( TC_ctrl_msc0_connection_status() );
Harald Welte96c94412017-12-09 03:12:45 +01008421 execute( TC_ctrl() );
Neels Hofmeyrf246a922020-05-13 02:27:10 +02008422 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_SCCPlite_SERVER) {
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +02008423 execute( TC_ctrl_location() );
8424 }
Harald Welte898113b2018-01-31 18:32:21 +01008425
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02008426 execute( TC_si_default() );
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02008427 execute( TC_si2quater_2_earfcns() );
8428 execute( TC_si2quater_3_earfcns() );
8429 execute( TC_si2quater_4_earfcns() );
8430 execute( TC_si2quater_5_earfcns() );
8431 execute( TC_si2quater_6_earfcns() );
Neels Hofmeyrad132f22020-07-08 02:20:16 +02008432 execute( TC_si2quater_12_earfcns() );
8433 execute( TC_si2quater_23_earfcns() );
8434 execute( TC_si2quater_32_earfcns() );
8435 execute( TC_si2quater_33_earfcns() );
8436 execute( TC_si2quater_42_earfcns() );
8437 execute( TC_si2quater_48_earfcns() );
8438 execute( TC_si2quater_49_earfcns() );
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02008439 execute( TC_si_acc_rotate() );
Alexander Couzens4ad3a352020-09-10 22:29:12 +02008440 execute( TC_si_acc_ramp_rotate() );
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02008441
Harald Welte898113b2018-01-31 18:32:21 +01008442 /* RSL DCHAN Channel ACtivation / Deactivation */
Harald Welteae026692017-12-09 01:03:01 +01008443 execute( TC_chan_act_noreply() );
Harald Welte4003d112017-12-09 22:35:39 +01008444 execute( TC_chan_act_counter() );
Harald Welteae026692017-12-09 01:03:01 +01008445 execute( TC_chan_act_ack_noest() );
Philipp Maier9c60a622020-07-09 15:08:46 +02008446 execute( TC_chan_act_ack_noest_emerg() );
Philipp Maier606f07d2020-08-12 17:21:58 +02008447 execute( TC_chan_rqd_emerg_deny() );
Harald Welteae026692017-12-09 01:03:01 +01008448 execute( TC_chan_act_ack_est_ind_noreply() );
8449 execute( TC_chan_act_ack_est_ind_refused() );
Harald Welte618ef642017-12-14 14:58:20 +01008450 execute( TC_chan_act_nack() );
Harald Welte799c97b2017-12-14 17:50:30 +01008451 execute( TC_chan_exhaustion() );
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07008452 execute( TC_chan_deact_silence() );
Harald Welte4003d112017-12-09 22:35:39 +01008453 execute( TC_chan_rel_rll_rel_ind() );
8454 execute( TC_chan_rel_conn_fail() );
8455 execute( TC_chan_rel_hard_clear() );
Harald Welte99787102019-02-04 10:41:36 +01008456 execute( TC_chan_rel_hard_clear_csfb() );
Harald Welted8c36cd2017-12-09 23:05:31 +01008457 execute( TC_chan_rel_hard_rlsd() );
Harald Welte550daf92018-06-11 19:22:13 +02008458 execute( TC_chan_rel_hard_rlsd_ms_dead() );
Harald Welte85804d42017-12-10 14:11:58 +01008459 execute( TC_chan_rel_a_reset() );
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01008460 execute( TC_chan_rel_sccp_tiar_timeout() );
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02008461 execute( TC_chan_rel_rr_cause() );
Harald Welte6f521d82017-12-11 19:52:02 +01008462
Harald Weltecfe2c962017-12-15 12:09:32 +01008463 execute( TC_outbound_connect() );
Harald Welte898113b2018-01-31 18:32:21 +01008464
8465 /* Assignment related */
Harald Welte16a4adf2017-12-14 18:54:01 +01008466 execute( TC_assignment_cic_only() );
Harald Welte235ebf12017-12-15 14:18:16 +01008467 execute( TC_assignment_csd() );
8468 execute( TC_assignment_ctm() );
8469 execute( TC_assignment_sign() );
Pau Espin Pedrol07866632020-09-03 19:10:55 +02008470 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
8471 execute( TC_assignment_aoip_tla_v6() );
8472 }
Harald Welte235ebf12017-12-15 14:18:16 +01008473 execute( TC_assignment_fr_a5_0() );
8474 execute( TC_assignment_fr_a5_1() );
Neels Hofmeyrf246a922020-05-13 02:27:10 +02008475 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welte8f67d1d2018-05-25 20:38:42 +02008476 execute( TC_assignment_fr_a5_1_codec_missing() );
8477 }
Harald Welte235ebf12017-12-15 14:18:16 +01008478 execute( TC_assignment_fr_a5_3() );
8479 execute( TC_assignment_fr_a5_4() );
Harald Welte3c86ea02018-05-10 22:28:05 +02008480 execute( TC_ciph_mode_a5_0() );
8481 execute( TC_ciph_mode_a5_1() );
8482 execute( TC_ciph_mode_a5_3() );
Harald Welte16a4adf2017-12-14 18:54:01 +01008483
Harald Welte60aa5762018-03-21 19:33:13 +01008484 execute( TC_assignment_codec_fr() );
8485 execute( TC_assignment_codec_hr() );
8486 execute( TC_assignment_codec_efr() );
8487 execute( TC_assignment_codec_amr_f() );
8488 execute( TC_assignment_codec_amr_h() );
Philipp Maier8a581d22019-03-26 18:32:48 +01008489
Neels Hofmeyrf246a922020-05-13 02:27:10 +02008490 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Philipp Maier8a581d22019-03-26 18:32:48 +01008491 execute( TC_assignment_codec_amr_f_S1() );
8492 execute( TC_assignment_codec_amr_h_S1() );
8493 execute( TC_assignment_codec_amr_f_S124() );
8494 execute( TC_assignment_codec_amr_h_S124() );
8495 execute( TC_assignment_codec_amr_f_S0() );
8496 execute( TC_assignment_codec_amr_f_S02() );
8497 execute( TC_assignment_codec_amr_f_S024() );
8498 execute( TC_assignment_codec_amr_f_S0247() );
8499 execute( TC_assignment_codec_amr_h_S0() );
8500 execute( TC_assignment_codec_amr_h_S02() );
8501 execute( TC_assignment_codec_amr_h_S024() );
8502 execute( TC_assignment_codec_amr_h_S0247() );
8503 execute( TC_assignment_codec_amr_f_S01234567() );
8504 execute( TC_assignment_codec_amr_f_S0234567() );
8505 execute( TC_assignment_codec_amr_f_zero() );
8506 execute( TC_assignment_codec_amr_f_unsupp() );
8507 execute( TC_assignment_codec_amr_h_S7() );
Neels Hofmeyr21863562020-11-26 00:34:33 +00008508 execute( TC_assignment_codec_amr_f_start_mode_auto() );
8509 execute( TC_assignment_codec_amr_h_start_mode_auto() );
Neels Hofmeyr3eb94562020-11-26 02:40:26 +00008510 execute( TC_assignment_codec_amr_f_start_mode_4() );
8511 execute( TC_assignment_codec_amr_h_start_mode_4() );
Neels Hofmeyr454d7922020-11-26 02:24:57 +00008512 execute( TC_assignment_codec_amr_startmode_cruft() );
Philipp Maier8a581d22019-03-26 18:32:48 +01008513 }
Harald Welte60aa5762018-03-21 19:33:13 +01008514
Philipp Maierac09bfc2019-01-08 13:41:39 +01008515 execute( TC_assignment_codec_fr_exhausted_req_hr() );
8516 execute( TC_assignment_codec_fr_exhausted_req_fr() );
8517 execute( TC_assignment_codec_fr_exhausted_req_fr_hr() );
8518 execute( TC_assignment_codec_fr_exhausted_req_hr_fr() );
8519 execute( TC_assignment_codec_hr_exhausted_req_fr() );
8520 execute( TC_assignment_codec_hr_exhausted_req_hr() );
8521 execute( TC_assignment_codec_hr_exhausted_req_hr_fr() );
8522 execute( TC_assignment_codec_hr_exhausted_req_fr_hr() );
8523 execute( TC_assignment_codec_req_hr_fr() );
8524 execute( TC_assignment_codec_req_fr_hr() );
8525
Pau Espin Pedrol58cf6822019-05-28 18:11:33 +02008526 if (mp_enable_osmux_test) {
8527 execute( TC_assignment_osmux() );
8528 }
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02008529
Harald Welte898113b2018-01-31 18:32:21 +01008530 /* RLL Establish Indication on inactive DCHAN / SAPI */
Harald Welte5cd20ed2017-12-13 21:03:20 +01008531 execute( TC_rll_est_ind_inact_lchan() );
8532 execute( TC_rll_est_ind_inval_sapi1() );
8533 execute( TC_rll_est_ind_inval_sapi3() );
8534 execute( TC_rll_est_ind_inval_sacch() );
8535
Vadim Yanitskiy61f784a2020-10-01 21:12:19 +07008536 /* DLCI / RSL Link ID conversion for MO/MT messages on SAPI0/SAPI3 */
8537 execute( TC_tch_dlci_link_id_sapi() );
8538
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07008539 /* SAPI N Reject triggered by RLL establishment failures */
8540 execute( TC_rll_rel_ind_sapi_n_reject() );
8541 execute( TC_rll_err_ind_sapi_n_reject() );
8542 execute( TC_rll_timeout_sapi_n_reject() );
8543
Harald Welte898113b2018-01-31 18:32:21 +01008544 /* Paging related tests */
Harald Welte6f521d82017-12-11 19:52:02 +01008545 execute( TC_paging_imsi_nochan() );
8546 execute( TC_paging_tmsi_nochan() );
8547 execute( TC_paging_tmsi_any() );
8548 execute( TC_paging_tmsi_sdcch() );
8549 execute( TC_paging_tmsi_tch_f() );
8550 execute( TC_paging_tmsi_tch_hf() );
8551 execute( TC_paging_imsi_nochan_cgi() );
8552 execute( TC_paging_imsi_nochan_lac_ci() );
8553 execute( TC_paging_imsi_nochan_ci() );
8554 execute( TC_paging_imsi_nochan_lai() );
8555 execute( TC_paging_imsi_nochan_lac() );
8556 execute( TC_paging_imsi_nochan_all() );
Harald Welte751d3eb2018-01-31 15:51:06 +01008557 execute( TC_paging_imsi_nochan_plmn_lac_rnc() );
8558 execute( TC_paging_imsi_nochan_rnc() );
8559 execute( TC_paging_imsi_nochan_lac_rnc() );
8560 execute( TC_paging_imsi_nochan_lacs() );
8561 execute( TC_paging_imsi_nochan_lacs_empty() );
Stefan Sperling049a86e2018-03-20 15:51:00 +01008562 execute( TC_paging_imsi_nochan_cgi_unknown_cid() );
Harald Welte10985002017-12-12 09:29:15 +01008563 execute( TC_paging_imsi_a_reset() );
Harald Weltee65d40e2017-12-13 00:09:06 +01008564 execute( TC_paging_imsi_load() );
Philipp Maier779a7922018-02-16 11:00:37 +01008565 execute( TC_paging_counter() );
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01008566 execute( TC_paging_resp_unsol() );
Harald Welte4e9b9cc2017-12-14 18:31:02 +01008567
8568 execute( TC_rsl_drop_counter() );
Stefan Sperling830dc9d2018-02-12 21:08:28 +01008569 execute( TC_rsl_unknown_unit_id() );
8570
8571 execute( TC_oml_unknown_unit_id() );
Harald Welte898113b2018-01-31 18:32:21 +01008572
8573 execute( TC_classmark() );
Harald Welteeddf0e92020-06-21 19:42:15 +02008574 execute( TC_common_id() );
Harald Welte898113b2018-01-31 18:32:21 +01008575 execute( TC_unsol_ass_fail() );
Harald Welteea99a002018-01-31 20:46:43 +01008576 execute( TC_unsol_ass_compl() );
Harald Weltefbf9b5e2018-01-31 20:41:23 +01008577 execute( TC_unsol_ho_fail() );
Harald Weltee3bd6582018-01-31 22:51:25 +01008578 execute( TC_err_82_short_msg() );
Harald Weltee9e02e42018-01-31 23:36:25 +01008579 execute( TC_err_84_unknown_msg() );
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01008580
Harald Welte261af4b2018-02-12 21:20:39 +01008581 execute( TC_ho_int() );
Neels Hofmeyr5f144212020-11-03 15:41:58 +00008582 execute( TC_ho_int_radio_link_failure() );
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01008583
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01008584 execute( TC_ho_out_of_this_bsc() );
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02008585 execute( TC_ho_out_fail_no_msc_response() );
8586 execute( TC_ho_out_fail_rr_ho_failure() );
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02008587 execute( TC_ho_out_fail_no_result_after_ho_cmd() );
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01008588
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01008589 execute( TC_ho_into_this_bsc() );
Pau Espin Pedrol07866632020-09-03 19:10:55 +02008590 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
8591 execute( TC_ho_into_this_bsc_tla_v6() );
8592 }
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01008593 execute( TC_ho_in_fail_msc_clears() );
8594 execute( TC_ho_in_fail_msc_clears_after_ho_detect() );
8595 execute( TC_ho_in_fail_no_detect() );
8596 execute( TC_ho_in_fail_no_detect2() );
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01008597
Neels Hofmeyr91401012019-07-11 00:42:35 +02008598 execute( TC_ho_neighbor_config_1() );
8599 execute( TC_ho_neighbor_config_2() );
8600 execute( TC_ho_neighbor_config_3() );
8601 execute( TC_ho_neighbor_config_4() );
8602 execute( TC_ho_neighbor_config_5() );
8603 execute( TC_ho_neighbor_config_6() );
8604 execute( TC_ho_neighbor_config_7() );
8605
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01008606 execute( TC_bssap_rlsd_does_not_cause_bssmap_reset() );
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01008607 execute( TC_bssmap_clear_does_not_cause_bssmap_reset() );
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01008608 execute( TC_ms_rel_ind_does_not_cause_bssmap_reset() );
Harald Welte94e0c342018-04-07 11:33:23 +02008609
8610 execute( TC_dyn_pdch_ipa_act_deact() );
8611 execute( TC_dyn_pdch_ipa_act_nack() );
8612 execute( TC_dyn_pdch_osmo_act_deact() );
8613 execute( TC_dyn_pdch_osmo_act_nack() );
Harald Welte99f3ca02018-06-14 13:40:29 +02008614
Stefan Sperling0796a822018-10-05 13:01:39 +02008615 execute( TC_chopped_ipa_ping() );
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02008616 execute( TC_chopped_ipa_payload() );
Stefan Sperling0796a822018-10-05 13:01:39 +02008617
Pau Espin Pedrol8f773632019-11-05 11:46:53 +01008618 /* Power control related */
8619 execute( TC_assignment_verify_ms_power_params_ie() );
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008620
8621 /* MSC pooling */
8622 /* FIXME: in SCCPlite, indicating how many MSCs should be connected does currently not work. Since
8623 * RESET->RESET-ACK is unconditionally negotiated for all configured MSCs, they always all appear as connected
8624 * to osmo-bsc. The MSC pooling tests however require disconnecting selected MSCs, and hence don't work out as
8625 * intended on SCCPlite. So for now, run these only for SCCP/M3UA. */
8626 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
8627 execute( TC_mscpool_L3Compl_on_1_msc() );
8628 execute( TC_mscpool_L3Complete_by_imsi_round_robin() );
8629 execute( TC_mscpool_LU_by_tmsi_null_nri_0_round_robin() );
8630 execute( TC_mscpool_LU_by_tmsi_null_nri_1_round_robin() );
8631 execute( TC_mscpool_L3Complete_by_tmsi_unassigned_nri_round_robin() );
8632 execute( TC_mscpool_L3Complete_by_tmsi_valid_nri_msc_not_connected_round_robin() );
8633 execute( TC_mscpool_L3Complete_by_tmsi_valid_nri_1() );
8634 execute( TC_mscpool_L3Complete_by_tmsi_valid_nri_2() );
8635 execute( TC_mscpool_LU_by_tmsi_from_other_PLMN() );
8636 execute( TC_mscpool_paging_and_response_imsi() );
8637 execute( TC_mscpool_paging_and_response_tmsi() );
8638 execute( TC_mscpool_no_allow_attach_round_robin() );
8639 execute( TC_mscpool_no_allow_attach_valid_nri() );
8640 }
8641
Harald Welte99f3ca02018-06-14 13:40:29 +02008642 /* at bottom as they might crash OsmoBSC before OS#3182 is fixed */
8643 execute( TC_early_conn_fail() );
8644 execute( TC_late_conn_fail() );
8645
Philipp Maier783681c2020-07-16 16:47:06 +02008646 /* Emergency call handling (deny / allow) */
8647 execute( TC_assignment_emerg_setup_allow() );
8648 execute( TC_assignment_emerg_setup_deny_msc() );
8649 execute( TC_assignment_emerg_setup_deny_bts() );
Philipp Maier82812002020-08-13 18:48:27 +02008650 execute( TC_emerg_premption() );
8651
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008652 /* Frequency hopping parameters handling */
8653 execute( TC_fh_params_chan_activ() );
8654 execute( TC_fh_params_imm_ass() );
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07008655 execute( TC_fh_params_assignment_cmd() );
Vadim Yanitskiy8f5430d2020-09-02 18:51:38 +07008656 execute( TC_fh_params_handover_cmd() );
Vadim Yanitskiyca974032020-09-01 07:20:39 +07008657 execute( TC_fh_params_si4_cbch() );
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008658
8659 if (mp_enable_lcs_tests) {
8660 execute( TC_lcs_loc_req_for_active_ms() );
8661 execute( TC_lcs_loc_req_for_active_ms_ta_req() );
8662 execute( TC_lcs_loc_req_for_idle_ms() );
8663 execute( TC_lcs_loc_req_no_subscriber() );
8664 execute( TC_lcs_loc_req_for_active_ms_le_timeout() );
8665 execute( TC_lcs_loc_req_for_active_ms_le_timeout2() );
8666 execute( TC_lcs_loc_req_for_idle_ms_no_pag_resp() );
8667 execute( TC_cm_service_during_lcs_loc_req() );
8668 execute( TC_ho_during_lcs_loc_req() );
8669 }
Neels Hofmeyrbf037052020-10-28 22:52:02 +00008670
8671 execute( TC_no_msc() );
Harald Welte28d943e2017-11-25 15:00:50 +01008672}
8673
8674}