blob: bc243b1fdd86a451e414e44b80879b191e04623a [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 Pedrolc08d5522021-04-16 15:40:38 +02001504function f_gen_handover_req(integer bssap_idx := 0, charstring aoip_tla := "1.2.3.4",
1505 template (omit) BSSMAP_oldToNewBSSIEs oldToNewBSSIEs := omit) return PDU_BSSAP {
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01001506 var PDU_BSSAP ho_req;
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001507 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01001508 var BSSMAP_IE_AoIP_TransportLayerAddress tla :=
Pau Espin Pedrol07866632020-09-03 19:10:55 +02001509 valueof(f_ts_BSSMAP_IE_AoIP_TLA(aoip_tla, 2342));
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02001510 ho_req := valueof(ts_BSSMAP_HandoverRequest(omit, tla, oldToNewBSSIEs := oldToNewBSSIEs));
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01001511 } else {
1512 var BSSMAP_IE_CircuitIdentityCode cic := valueof(ts_BSSMAP_IE_CIC(0,1));
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02001513 ho_req := valueof(ts_BSSMAP_HandoverRequest(cic, omit, oldToNewBSSIEs := oldToNewBSSIEs));
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01001514 }
1515 return ho_req;
1516}
1517
Harald Welteed848512018-05-24 22:27:58 +02001518/* generate an assignment complete template for either AoIP or SCCPlite */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001519function f_gen_exp_compl(boolean expect_osmux := false, integer bssap_idx := 0) return template PDU_BSSAP {
Harald Welteed848512018-05-24 22:27:58 +02001520 var template PDU_BSSAP exp_compl;
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001521 var BSSMAP_IE_Osmo_OsmuxCID osmux_cid := valueof(ts_OsmuxCID(0));
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001522 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001523 if (expect_osmux) {
1524 exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?, osmux_cid);
1525 } else {
1526 exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?, omit);
1527 }
Harald Welteed848512018-05-24 22:27:58 +02001528 } else {
1529 /* CIC is optional "*" as the MSC allocated it */
Pau Espin Pedrol096d73d2019-06-06 12:49:17 +02001530 exp_compl := tr_BSSMAP_AssignmentComplete(*, omit);
Harald Welteed848512018-05-24 22:27:58 +02001531 }
1532 return exp_compl;
1533}
1534
Harald Welte235ebf12017-12-15 14:18:16 +01001535/* Run everything required up to sending a caller-specified assignment command and expect response */
1536function f_assignment_exp(PDU_BSSAP ass_cmd, template PDU_BSSAP exp, charstring fail_text)
1537runs on test_CT {
1538 var BSSAP_N_CONNECT_ind rx_c_ind;
1539 var RSL_Message rx_rsl;
1540 var DchanTuple dt;
1541
Harald Welte89d42e82017-12-17 16:42:41 +01001542 f_init(1);
Harald Welte235ebf12017-12-15 14:18:16 +01001543
1544 dt := f_est_dchan('23'O, 23, '00000000'O);
1545 /* send assignment without AoIP IEs */
1546 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ass_cmd));
1547 alt {
1548 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentComplete)) {
1549 if (ischosen(exp.pdu.bssmap.assignmentComplete)) {
1550 setverdict(pass);
1551 } else {
1552 setverdict(fail, fail_text);
1553 }
1554 }
1555 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentFail)) {
1556 if (ischosen(exp.pdu.bssmap.assignmentFailure)) {
1557 setverdict(pass);
1558 } else {
1559 setverdict(fail, fail_text);
1560 }
1561 }
1562 [] BSSAP.receive { repeat; }
1563 }
1564}
1565testcase TC_assignment_csd() runs on test_CT {
1566 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +02001567 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte235ebf12017-12-15 14:18:16 +01001568 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeCSD);
1569 //exp_fail.pdu.bssmap.assignmentFailure.cause.causeValue := int2bit(enum2int(GSM0808_CAUSE_REQ_CODEC_TYPE_OR_CONFIG_UNAVAIL), 7);
1570 f_assignment_exp(ass_cmd, exp_fail, "BSC accepted Assignment for CSD");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001571 f_shutdown_helper();
Harald Welte235ebf12017-12-15 14:18:16 +01001572}
1573
1574testcase TC_assignment_ctm() runs on test_CT {
1575 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +02001576 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte235ebf12017-12-15 14:18:16 +01001577 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeCTM);
1578 //exp_fail.pdu.bssmap.assignmentFailure.cause.causeValue := int2bit(enum2int(GSM0808_CAUSE_REQ_CODEC_TYPE_OR_CONFIG_UNAVAIL), 7);
1579 f_assignment_exp(ass_cmd, exp_fail, "BSC accepted Assignment for Speech+CTM");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001580 f_shutdown_helper();
Harald Welte235ebf12017-12-15 14:18:16 +01001581}
1582
Harald Welte4003d112017-12-09 22:35:39 +01001583type record DchanTuple {
1584 integer sccp_conn_id,
1585 RslChannelNr rsl_chan_nr
Harald Weltea5d2ab22017-12-09 14:21:42 +01001586}
1587
Harald Welted6939652017-12-13 21:02:46 +01001588/* Send CHAN RQD and wait for allocation; acknowledge it */
1589private function f_chreq_act_ack(OCT1 ra := '23'O, GsmFrameNumber fn := 23)
1590runs on test_CT return RslChannelNr {
1591 var RSL_Message rx_rsl;
1592 f_ipa_tx(0, ts_RSL_CHAN_RQD(ra, fn));
1593 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
1594 var RslChannelNr chan_nr := rx_rsl.ies[0].body.chan_nr;
1595 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, fn+10));
Daniel Willmannf4ac4ce2018-08-02 14:06:30 +02001596 rx_rsl := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
Harald Welted6939652017-12-13 21:02:46 +01001597 return chan_nr;
1598}
1599
Harald Welte4003d112017-12-09 22:35:39 +01001600/* helper function to establish a dedicated channel via BTS and MSC */
1601function f_est_dchan(OCT1 ra, GsmFrameNumber fn, octetstring l3)
1602runs on test_CT return DchanTuple {
1603 var BSSAP_N_CONNECT_ind rx_c_ind;
Harald Welte4003d112017-12-09 22:35:39 +01001604 var DchanTuple dt;
Harald Weltea5d2ab22017-12-09 14:21:42 +01001605
Harald Welte4003d112017-12-09 22:35:39 +01001606 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +01001607 dt.rsl_chan_nr := f_chreq_act_ack(ra, fn);
Harald Welte4003d112017-12-09 22:35:39 +01001608
1609 f_ipa_tx(0, ts_RSL_EST_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
1610
1611 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
1612 dt.sccp_conn_id := rx_c_ind.connectionId;
1613 BSSAP.send(ts_BSSAP_CONNECT_res(dt.sccp_conn_id));
1614
1615 return dt;
Harald Weltea5d2ab22017-12-09 14:21:42 +01001616}
1617
Harald Welte641fcbe2018-06-14 10:58:35 +02001618/* expect RF CAN REL from BTS, acknowledge it and clear the MSC side */
1619private function f_exp_chan_rel_and_clear(DchanTuple dt, integer bts_nr := 0) runs on test_CT {
1620 var RSL_Message rx_rsl;
1621 /* expect BSC to disable the channel */
1622 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX);
1623 /* respond with CHAN REL ACK */
1624 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
1625
1626 /* expect Clear Complete from BSC */
1627 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete));
1628
1629 /* MSC disconnects as instructed. */
1630 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1631}
1632
Harald Welte4003d112017-12-09 22:35:39 +01001633/* Test behavior of channel release after unilateral RLL REL IND (DISC from MS) */
1634testcase TC_chan_rel_rll_rel_ind() runs on test_CT {
Neels Hofmeyr27f64362018-03-12 01:44:00 +01001635 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +01001636 var DchanTuple dt;
Harald Welte96c94412017-12-09 03:12:45 +01001637
Harald Welte89d42e82017-12-17 16:42:41 +01001638 f_init(1);
Harald Welte96c94412017-12-09 03:12:45 +01001639
Harald Welte4003d112017-12-09 22:35:39 +01001640 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1641
1642 /* simulate RLL REL IND */
1643 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0))));
1644
Neels Hofmeyr27f64362018-03-12 01:44:00 +01001645 /* expect Clear Request on MSC side */
1646 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
1647
1648 /* Instruct BSC to clear channel */
1649 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
1650 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
1651
Harald Welte4003d112017-12-09 22:35:39 +01001652 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02001653 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyr27f64362018-03-12 01:44:00 +01001654
1655 /* wait for SCCP emulation to do its job */
1656 f_sleep(1.0);
Harald Welte4003d112017-12-09 22:35:39 +01001657
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001658 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01001659}
1660
1661/* Test behavior of channel release after CONN FAIL IND from BTS */
1662testcase TC_chan_rel_conn_fail() runs on test_CT {
1663 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +01001664 var DchanTuple dt;
1665
Harald Welte89d42e82017-12-17 16:42:41 +01001666 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01001667
1668 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1669
1670 /* simulate CONN FAIL IND */
Harald Weltea8ed9062017-12-14 09:46:01 +01001671 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 +01001672 /* TODO: different cause values? */
1673
Harald Welte4003d112017-12-09 22:35:39 +01001674 /* expect Clear Request from BSC */
1675 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
1676
1677 /* Instruct BSC to clear channel */
1678 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
1679 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
1680
Harald Welte6ff76ea2018-01-28 13:08:01 +01001681 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02001682 f_exp_chan_rel_and_clear(dt, 0);
Harald Welte4003d112017-12-09 22:35:39 +01001683
1684 /* wait for SCCP emulation to do its job */
1685 f_sleep(1.0);
1686
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001687 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01001688}
1689
Harald Welte99f3ca02018-06-14 13:40:29 +02001690/* Test behavior of early CONN FAIL IND from BTS (before EST IND!) */
1691/* See also https://www.osmocom.org/issues/3182 */
1692testcase TC_early_conn_fail() runs on test_CT {
1693 var RSL_Message rx_rsl;
1694 var DchanTuple dt;
1695
1696 f_init(1);
1697
1698 /* BTS->BSC: Send CHAN RQD and wait for allocation; acknowledge it */
Harald Weltec46ea3c2020-10-10 18:46:12 +02001699 dt.rsl_chan_nr := f_chreq_act_ack(f_rnd_ra_cs(), 23);
Harald Welte99f3ca02018-06-14 13:40:29 +02001700
1701 /* BTS->BSC: simulate CONN FAIL IND */
1702 f_ipa_tx(0, ts_RSL_CONN_FAIL_IND(dt.rsl_chan_nr, RSL_ERR_RADIO_LINK_FAIL));
1703
1704 /* BTS->BSC: Expect RF channel release from BSC on Abis */
1705 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), 10.0);
1706
1707 /* BTS<-BSC: respond with CHAN REL ACK */
1708 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
1709
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001710 f_shutdown_helper();
Harald Welte99f3ca02018-06-14 13:40:29 +02001711}
1712
1713/* Test behavior of late CONN FAIL IND from BTS (ater REL IND!) */
1714/* See also https://www.osmocom.org/issues/3182 */
1715testcase TC_late_conn_fail() runs on test_CT {
1716 var RSL_Message rx_rsl;
1717 var DchanTuple dt;
1718
1719 f_init(1);
1720
1721 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1722
1723 /* BSC<-MSC: Instruct BSC to clear connection */
1724 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(0)));
1725
1726 /* BTS->BSC: expect BSC to deactivate SACCH */
1727 rx_rsl := f_exp_ipa_rx(0, tr_RSL_DEACT_SACCH(dt.rsl_chan_nr));
1728
1729 /* BTS->BSC: simulate a late CONN FAIL IND from BTS */
1730 f_ipa_tx(0, ts_RSL_CONN_FAIL_IND(dt.rsl_chan_nr, RSL_ERR_RADIO_LINK_FAIL));
1731
1732 /* BTS<-BSC: Expect RF channel release from BSC on Abis */
1733 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), 10.0);
1734 /* BTS->BSC: respond with CHAN REL ACK */
1735 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
1736
1737 /* BSC->MSC: expect Clear Complete from BSC */
1738 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete));
1739
1740 /* BSC<-MSC: MSC disconnects as requested. */
1741 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1742
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001743 f_shutdown_helper();
Harald Welte99f3ca02018-06-14 13:40:29 +02001744}
1745
Neels Hofmeyrf44ccd12018-11-05 19:15:23 +01001746function f_expect_chan_rel(integer bts_nr, RslChannelNr rsl_chan_nr,
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001747 boolean expect_deact_sacch := true,
1748 boolean expect_rr_chan_rel := true,
1749 boolean expect_rll_rel_req := true,
Harald Welte99787102019-02-04 10:41:36 +01001750 boolean handle_rll_rel := true,
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 Pedrol841b90d2021-04-15 16:42:52 +02001770 [not istemplatekind(expect_cells, "omit")] 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 }
Pau Espin Pedrol841b90d2021-04-15 16:42:52 +02001804 [istemplatekind(expect_cells, "omit")] 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
Pau Espin Pedrol841b90d2021-04-15 16:42:52 +02001880function f_TC_chan_rel_last_eutran_plmn_hard_clear(boolean tx_csfb_ind) runs on test_CT {
1881 var BSSAP_N_DATA_ind rx_di;
1882 var DchanTuple dt;
1883
1884 f_init(1);
1885
1886 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1887 /* Send CommonID with some random PLMN (BSC doesn't take it into account
1888 /* yet when generating the EUTRAN neigh list in RR CHannel Release) */
1889 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_CommonId('001019876543210'H, '323454'O)));
1890
1891 /* Instruct BSC to clear channel */
1892 var BssmapCause cause := 0;
1893 if (tx_csfb_ind) {
1894 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommandCSFB(cause)));
1895 } else {
1896 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
1897 }
1898
1899 /* expect Clear Complete from BSC on A */
1900 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
1901 /* release the SCCP connection */
1902 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1903 }
1904
1905 /* 1 neighbor is added by default in osmo-bts.cfg and
1906 SystemInformationConfig_default, use that: */
1907 var template CellSelIndValue exp_cells := f_tr_rr_chan_rel_earfcns(1);
1908
1909 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false, expect_cells := exp_cells);
1910 f_shutdown_helper();
1911}
1912
1913/* Test behavior of RR Channel rRelease after Clear Command without CSFB indicator
1914 from MSC, previously receiving any CommonID containing the "Last Used E-UTRAN
1915 PLMN Id". According to spec (3GPP TS 48.008 sec 3.1.30) that's the bit requesting
1916 EUTRAN neighbor list sent later on by BSC in RR Channel, so receiving CSFB
1917 Indicator or not shouldn't matter at all. */
1918testcase TC_chan_rel_last_eutran_plmn_hard_clear_no_csfb() runs on test_CT {
1919 f_TC_chan_rel_last_eutran_plmn_hard_clear(false);
1920}
1921
1922/* Test behavior of RR Channel rRelease after Clear Command with CSFB indicator from
1923 MSC, previously receiving any CommonID containing the "Last Used E-UTRAN PLMN
1924 Id". According to spec (3GPP TS 48.008 sec 3.1.30) that's the bit requesting
1925 EUTRAN neighbor list sent later on by BSC in RR Channel. */
1926testcase TC_chan_rel_last_eutran_plmn_hard_clear_csfb() runs on test_CT {
1927 f_TC_chan_rel_last_eutran_plmn_hard_clear(true);
1928}
1929
1930/* Test behavior of RR Channel Release after Clear Command with CSFB indicator from
1931 MSC, without receiving any CommonID containing the "Last Used E-UTRAN PLMN
1932 Id". According to spec (TS 48.008 version 16.0.0 Release 16 "3.2.1.21") the
1933 CSFB Indicator should not be used anymore, and hence, there should be no
1934 EUTRAN neighbor list sent by BSC in RR Channel release since no CommonId with
1935 Last Used E-UTRAN PLMN Id" IE was sent for this conn. */
Harald Welte99787102019-02-04 10:41:36 +01001936testcase TC_chan_rel_hard_clear_csfb() runs on test_CT {
1937 var BSSAP_N_DATA_ind rx_di;
1938 var DchanTuple dt;
1939
1940 f_init(1);
1941
1942 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1943
1944 /* Instruct BSC to clear channel */
1945 var BssmapCause cause := 0;
1946 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommandCSFB(cause)));
1947
1948 /* expect Clear Complete from BSC on A */
1949 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
1950 /* release the SCCP connection */
1951 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1952 }
1953
Pau Espin Pedrol841b90d2021-04-15 16:42:52 +02001954 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001955 f_shutdown_helper();
Harald Welte99787102019-02-04 10:41:36 +01001956}
1957
Harald Welted8c36cd2017-12-09 23:05:31 +01001958/* Test behavior of channel release after hard RLSD from MSC */
1959testcase TC_chan_rel_hard_rlsd() runs on test_CT {
Harald Welted8c36cd2017-12-09 23:05:31 +01001960 var DchanTuple dt;
Harald Welted8c36cd2017-12-09 23:05:31 +01001961
Harald Welte89d42e82017-12-17 16:42:41 +01001962 f_init(1);
Harald Welted8c36cd2017-12-09 23:05:31 +01001963
1964 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1965
1966 /* release the SCCP connection */
1967 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1968
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001969 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001970 f_shutdown_helper();
Harald Welted8c36cd2017-12-09 23:05:31 +01001971}
1972
Harald Welte550daf92018-06-11 19:22:13 +02001973/* Test behavior of channel release after hard RLSD from MSC and MS is not responding to RLL REL REQ */
1974testcase TC_chan_rel_hard_rlsd_ms_dead() runs on test_CT {
1975 var DchanTuple dt;
1976
1977 f_init(1);
1978
1979 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1980
1981 /* release the SCCP connection */
1982 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1983
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001984 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001985 f_shutdown_helper();
Harald Welte550daf92018-06-11 19:22:13 +02001986}
1987
Harald Welte85804d42017-12-10 14:11:58 +01001988/* Test behavior of channel release after BSSMAP RESET from MSC */
1989testcase TC_chan_rel_a_reset() runs on test_CT {
Harald Welte85804d42017-12-10 14:11:58 +01001990 var DchanTuple dt;
Harald Welte85804d42017-12-10 14:11:58 +01001991
Harald Welte89d42e82017-12-17 16:42:41 +01001992 f_init(1);
Harald Welte85804d42017-12-10 14:11:58 +01001993
1994 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1995
1996 /* Clear the queue, it might still contain stuff like IMMEDIATE ASSIGN */
1997 IPA_RSL[0].clear;
1998
1999 /* perform BSSAP RESET, expect RESET ACK and DISC.ind on connection */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02002000 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 +01002001 interleave {
Neels Hofmeyrf246a922020-05-13 02:27:10 +02002002 [] 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 +01002003 [] BSSAP.receive(tr_BSSAP_DISC_ind(dt.sccp_conn_id, ?, ?)) { }
2004 }
2005
Neels Hofmeyra5302c82018-11-04 23:09:58 +01002006 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002007 f_shutdown_helper();
Harald Welte85804d42017-12-10 14:11:58 +01002008}
2009
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01002010/* Verify T(iar) triggers and releases the channel */
2011testcase TC_chan_rel_sccp_tiar_timeout() runs on test_CT {
2012 var DchanTuple dt;
2013
2014 /* Set T(iar) in BSC low enough that it will trigger before other side
2015 has time to keep alive with a T(ias). Keep recommended ratio of
2016 T(iar) >= T(ias)*2 */
2017 g_bsc_sccp_timer_ias := 2;
2018 g_bsc_sccp_timer_iar := 5;
2019
2020 f_init(1);
2021
2022 dt := f_est_dchan('23'O, 23, '00010203040506'O);
2023 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002024 f_shutdown_helper();
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01002025}
2026
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02002027private function f_tc_chan_rel_rr_cause(myBSSMAP_Cause clear_cmd_cause, template RR_Cause expect_rr_cause)
2028runs on test_CT
2029{
2030 var DchanTuple dt;
2031
2032 dt := f_est_dchan('23'O, 23, '00010203040506'O);
2033 var BssmapCause cause := 0;
2034 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(enum2int(clear_cmd_cause))));
2035 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
2036 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2037 }
2038
2039 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 +02002040}
2041
2042/* Test that Clear Command cause codes affect the RR Channel Release cause code */
2043testcase TC_chan_rel_rr_cause() runs on test_CT {
2044 f_init(1);
2045
2046 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_CALL_CONTROL, GSM48_RR_CAUSE_NORMAL);
2047 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_HANDOVER_SUCCESSFUL, GSM48_RR_CAUSE_NORMAL);
2048 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_PREEMPTION, GSM48_RR_CAUSE_PREMPTIVE_REL);
2049 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_RADIO_INTERFACE_MESSAGE_FAILURE, GSM48_RR_CAUSE_PROT_ERROR_UNSPC);
2050 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_RADIO_INTERFACE_FAILURE, GSM48_RR_CAUSE_ABNORMAL_UNSPEC);
2051 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_EQUIPMENT_FAILURE, GSM48_RR_CAUSE_ABNORMAL_UNSPEC);
Vadim Yanitskiye18aebb2021-01-03 13:10:43 +01002052
2053 f_shutdown_helper();
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02002054}
2055
Harald Welte5cd20ed2017-12-13 21:03:20 +01002056/* Test behavior if RSL EST IND for non-active channel */
2057testcase TC_rll_est_ind_inact_lchan() runs on test_CT {
2058 timer T := 2.0;
2059
Harald Welte89d42e82017-12-17 16:42:41 +01002060 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01002061
2062 var octetstring l3 := '00010203040506'O;
2063 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
2064 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
2065
2066 T.start;
2067 alt {
2068 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
2069 setverdict(fail, "MSC received COMPL L3 for non-active lchan");
2070 }
2071 [] BSSAP.receive {}
2072 [] IPA_RSL[0].receive {}
2073 [] T.timeout {}
2074 }
2075
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002076 f_shutdown_helper();
Harald Welte5cd20ed2017-12-13 21:03:20 +01002077}
2078
2079/* Test behavior if RSL EST IND for invalid SAPI */
2080testcase TC_rll_est_ind_inval_sapi1() runs on test_CT {
2081 var RslChannelNr chan_nr;
2082
Harald Welte89d42e82017-12-17 16:42:41 +01002083 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01002084
2085 chan_nr := f_chreq_act_ack()
2086
2087 var octetstring l3 := '00010203040506'O;
2088 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(1)), l3));
2089
2090 timer T := 2.0;
2091 T.start;
2092 alt {
2093 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
2094 setverdict(fail, "MSC received COMPL L3 for invalid SAPI 1");
2095 }
2096 [] BSSAP.receive { repeat; }
2097 [] IPA_RSL[0].receive { repeat; }
2098 [] T.timeout {}
2099 }
2100
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002101 f_shutdown_helper();
Harald Welte5cd20ed2017-12-13 21:03:20 +01002102}
2103
2104/* Test behavior if RSL EST IND for invalid SAPI */
2105testcase TC_rll_est_ind_inval_sapi3() runs on test_CT {
2106 timer T := 2.0;
2107
Harald Welte89d42e82017-12-17 16:42:41 +01002108 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01002109
2110 var RslChannelNr chan_nr := f_chreq_act_ack();
2111
2112 var octetstring l3 := '00010203040506'O;
2113 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(3)), l3));
2114
2115 T.start;
2116 alt {
2117 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
2118 setverdict(fail, "MSC received COMPL L3 for invalid SAPI 3");
2119 }
2120 [] BSSAP.receive { repeat; }
2121 [] IPA_RSL[0].receive { repeat; }
2122 [] T.timeout {}
2123 }
2124
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002125 f_shutdown_helper();
Harald Welte5cd20ed2017-12-13 21:03:20 +01002126}
2127
2128/* Test behavior if RSL EST IND for invalid SACCH */
2129testcase TC_rll_est_ind_inval_sacch() runs on test_CT {
2130 timer T := 2.0;
2131
Harald Welte89d42e82017-12-17 16:42:41 +01002132 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01002133
2134 var RslChannelNr chan_nr := f_chreq_act_ack();
2135
2136 var octetstring l3 := '00010203040506'O;
2137 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_SACCH(0)), l3));
2138
2139 T.start;
2140 alt {
2141 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
2142 setverdict(fail, "MSC received COMPL L3 for invalid Link SACCH");
2143 }
2144 [] BSSAP.receive { repeat; }
2145 [] IPA_RSL[0].receive { repeat; }
2146 [] T.timeout {}
2147 }
2148
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002149 f_shutdown_helper();
Harald Welte5cd20ed2017-12-13 21:03:20 +01002150}
2151
Vadim Yanitskiy61f784a2020-10-01 21:12:19 +07002152/* Verify DLCI / RSL Link ID conversion for MO/MT messages on SAPI0/SAPI3 */
2153private function f_TC_tch_dlci_link_id_sapi(charstring id) runs on MSC_ConnHdlr {
2154 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2155 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2156
2157 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2158 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
2159
2160 f_establish_fully(ass_cmd, exp_compl);
2161
2162 /* SAPI0 has already been established by f_establish_fully(), establish SAPI3 */
2163 RSL.send(ts_RSL_EST_IND(g_chan_nr, ts_RslLinkID_SACCH(3), '0904'O));
2164 /* Expect BSSAP/DTAP on SAPI3 (DLCI IE) */
2165 BSSAP.receive(PDU_BSSAP:{
2166 discriminator := '1'B,
2167 spare := '0000000'B,
2168 dlci := 'C3'O,
2169 lengthIndicator := ?,
2170 pdu := { dtap := '0904'O }
2171 });
2172
2173 /* Send messages on DCCH/SAPI0 and ACCH/SAPI3 */
2174 for (var integer i := 0; i < 32; i := i + 1) {
2175 var octetstring l3 := '09'O & f_rnd_octstring(14);
2176 var template (value) RslLinkId link_id;
2177 var template (value) OCT1 dlci;
2178
2179 if (i mod 2 == 0) {
2180 /* SAPI0 on FACCH or SDCCH */
2181 link_id := ts_RslLinkID_DCCH(0);
2182 dlci := '80'O;
2183 } else {
2184 /* SAPI3 on SACCH */
2185 link_id := ts_RslLinkID_SACCH(3);
2186 dlci := 'C3'O;
2187 }
2188
2189 /* Send MO message: RSL -> BSSAP */
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00002190 f_mo_l3_transceive(RSL, link_id, dlci, l3);
Vadim Yanitskiy61f784a2020-10-01 21:12:19 +07002191 /* Send MT message: BSSAP -> RSL */
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00002192 f_mt_l3_transceive(RSL, link_id, dlci, l3);
Vadim Yanitskiy61f784a2020-10-01 21:12:19 +07002193 }
2194}
2195testcase TC_tch_dlci_link_id_sapi() runs on test_CT {
2196 var TestHdlrParams pars := f_gen_test_hdlr_pars();
2197 var MSC_ConnHdlr vc_conn;
2198
2199 f_init(1, true);
2200 f_sleep(1.0);
2201
2202 vc_conn := f_start_handler(refers(f_TC_tch_dlci_link_id_sapi), pars);
2203 vc_conn.done;
2204
2205 f_shutdown_helper();
2206}
2207
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07002208private function f_exp_sapi_n_reject(template (present) GsmSapi sapi := ?,
2209 template myBSSMAP_Cause cause := ?,
2210 float T_val := 2.0)
2211runs on test_CT {
2212 var BSSAP_N_DATA_ind rx_di;
2213 timer T;
2214
2215 var template BSSMAP_IE_Cause tr_cause := tr_BSSMAP_IE_Cause(cause);
2216 var template PDU_BSSAP tr_pdu := tr_BSSMAP_SAPInReject(sapi);
2217
2218 T.start(T_val);
2219 alt {
2220 [] BSSAP.receive(tr_BSSAP_DATA_ind(?, tr_pdu)) -> value rx_di {
2221 var BSSMAP_IE_Cause rx_cause := rx_di.userData.pdu.bssmap.sAPInReject.cause;
2222 if (not match(rx_cause, tr_cause)) {
2223 setverdict(fail, "Rx unexpected Cause IE: ",
2224 rx_cause, " vs expected ", tr_cause);
2225 }
2226 setverdict(pass);
2227 }
2228 [] BSSAP.receive(BSSAP_N_DATA_ind:?) -> value rx_di {
2229 setverdict(fail, "Rx unexpected BSSAP PDU: ", rx_di);
2230 }
2231 [] T.timeout {
2232 setverdict(fail, "Timeout waiting for BSSMAP SAPI N Reject");
2233 }
2234 }
2235}
2236
2237/* Check if we get SAPI N Reject on receipt of unexpected RLL RELease INDication */
2238testcase TC_rll_rel_ind_sapi_n_reject() runs on test_CT {
2239 var octetstring rnd_data := f_rnd_octstring(16);
2240 var RSL_Message rx_rsl;
2241 var DchanTuple dt;
2242
2243 f_init(1);
2244
2245 /* MS establishes a SAPI=0 link on DCCH */
2246 dt := f_est_dchan(f_rnd_ra_cs(), 23, rnd_data);
2247
2248 /* MSC sends some data on (not yet established) SAPI=3 link */
2249 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSAP_DTAP(rnd_data, '03'O)));
2250 /* BSC attempts to establish a SAPI=3 link on DCCH */
2251 rx_rsl := f_exp_ipa_rx(0, tr_RSL_EST_REQ(dt.rsl_chan_nr, tr_RslLinkID_DCCH(3)));
2252
2253 /* MS sends unexpected RELease INDication on SAPI=3 */
2254 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, ts_RslLinkID_DCCH(3)));
2255 /* We expect to receive BSSMAP SAPI N Reject message from the BSC */
2256 f_exp_sapi_n_reject(3, GSM0808_CAUSE_MS_NOT_EQUIPPED);
2257
2258 /* Clean up the connection */
2259 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2260 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
2261
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002262 f_shutdown_helper();
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07002263}
2264
2265/* Check if we get SAPI N Reject on receipt of unexpected RLL ERROR INDication */
2266testcase TC_rll_err_ind_sapi_n_reject() runs on test_CT {
2267 var octetstring rnd_data := f_rnd_octstring(16);
2268 var RSL_Message rx_rsl;
2269 var DchanTuple dt;
2270
2271 f_init(1);
2272
2273 /* MS establishes a SAPI=0 link on DCCH */
2274 dt := f_est_dchan(f_rnd_ra_cs(), 23, rnd_data);
2275
2276 /* MSC sends some data on (not yet established) SAPI=3 link */
2277 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSAP_DTAP(rnd_data, '03'O)));
2278 /* BSC attempts to establish a SAPI=3 link on DCCH */
2279 rx_rsl := f_exp_ipa_rx(0, tr_RSL_EST_REQ(dt.rsl_chan_nr, tr_RslLinkID_DCCH(3)));
2280
2281 /* BTS sends unexpected ERROR INDication on SAPI=3 */
2282 f_ipa_tx(0, ts_RSL_ERROR_IND(dt.rsl_chan_nr, ts_RslLinkID_DCCH(3), ''O));
2283 /* We expect to receive BSSMAP SAPI N Reject message from the BSC */
2284 f_exp_sapi_n_reject(3, GSM0808_CAUSE_BSS_NOT_EQUIPPED);
2285
2286 /* Clean up the connection */
2287 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2288 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
2289
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002290 f_shutdown_helper();
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07002291}
2292
2293/* Check if we get SAPI N Reject due to a SAPI=3 link establishment timeout */
2294testcase TC_rll_timeout_sapi_n_reject() runs on test_CT {
2295 var octetstring rnd_data := f_rnd_octstring(16);
2296 var RSL_Message rx_rsl;
2297 var DchanTuple dt;
2298
2299 f_init(1);
2300
2301 /* MS establishes a SAPI=0 link on DCCH */
2302 dt := f_est_dchan(f_rnd_ra_cs(), 23, rnd_data);
2303
2304 /* MSC sends some data on (not yet established) SAPI=3 link */
2305 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSAP_DTAP(rnd_data, '03'O)));
2306 /* BSC attempts to establish a SAPI=3 link on DCCH */
2307 rx_rsl := f_exp_ipa_rx(0, tr_RSL_EST_REQ(dt.rsl_chan_nr, tr_RslLinkID_DCCH(3)));
2308
2309 /* MS does not respond, so the link establishment timeout triggers SAPI N Reject */
2310 f_exp_sapi_n_reject(3, GSM0808_CAUSE_BSS_NOT_EQUIPPED, T_val := 8.0);
2311
2312 /* Clean up the connection */
2313 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2314 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
2315
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002316 f_shutdown_helper();
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07002317}
2318
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02002319testcase TC_si_default() runs on test_CT {
2320 f_init(0);
2321 f_init_bts_and_check_sysinfo(0, expect_si := SystemInformationConfig_default);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002322 f_shutdown_helper();
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02002323}
Harald Welte4003d112017-12-09 22:35:39 +01002324
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002325/* We're testing SI2quater with lists of EARFCNs. Instead of just incrementing EARFCNs, also pick some from the edges of
2326 * the entire value range. This function provides the same EARFCN numbers for the same earfcn_index */
2327private function f_test_si2quater_earfcn_by_idx(integer earfcn_index) return uint16_t
2328{
2329 select (earfcn_index) {
2330 case (0) {
2331 /* E-ARFCN 111 is already added in the osmo-bsc.cfg */
2332 return 111;
2333 }
2334 case (1) {
2335 return 1;
2336 }
2337 case (2) {
2338 return 0;
2339 }
2340 case (3) {
2341 return 65535;
2342 }
2343 case else {
2344 return 23 * (earfcn_index - 3);
2345 }
2346 }
2347}
2348
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002349function f_test_si2quater(integer total_earfcns, template SystemInformationConfig expect_si,
2350 template CellSelIndValue expect_cells := omit) runs on test_CT {
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002351
2352 f_init(0);
2353
2354 /* E-ARFCN 111 is already added in the osmo-bsc.cfg, so only add more arfcns if total_earfcns > 1 */
2355 for (var integer i := 1; i < total_earfcns; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002356 f_bts_0_cfg(BSCVTY, {"si2quater neighbor-list add earfcn " & int2str(f_test_si2quater_earfcn_by_idx(i))
2357 & " thresh-hi 20 thresh-lo 10 prio 3 qrxlv 22 meas 3"});
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002358 }
2359
2360 f_init_bts_and_check_sysinfo(0, expect_si := expect_si);
2361
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002362 if (not istemplatekind(expect_cells, "omit")) {
2363 /* Also check that RR Channel Release contains these EARFCNs.
2364 * (copied code from TC_chan_rel_hard_clear_csfb) */
2365 var BSSAP_N_DATA_ind rx_di;
2366 var DchanTuple dt;
2367
2368 dt := f_est_dchan('23'O, 23, '00010203040506'O);
Pau Espin Pedrold0046312021-04-19 16:35:58 +02002369 /* Send CommonID with some random PLMN (BSC doesn't take it into account
2370 * yet when generating the EUTRAN neigh list in RR CHannel Release) */
2371 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_CommonId('001019876543210'H, '323454'O)));
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002372
2373 /* Instruct BSC to clear channel */
2374 var BssmapCause cause := 0;
2375 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommandCSFB(cause)));
2376
2377 /* expect Clear Complete from BSC on A */
2378 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
2379 /* release the SCCP connection */
2380 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2381 }
2382
Pau Espin Pedrol841b90d2021-04-15 16:42:52 +02002383 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false, expect_cells := expect_cells);
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002384 }
2385
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002386 for (var integer i := 1; i < total_earfcns; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002387 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 +02002388 }
2389}
2390
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002391private function f_tr_si2quater_earfcns(integer count) return template SI2quaterRestOctetsList
2392{
2393 var template SI2quaterRestOctetsList si2quater := {};
2394 var integer si2quater_count := (count + 2) / 3;
2395
2396 for (var integer i := 0; i < count; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002397 var integer earfcn := f_test_si2quater_earfcn_by_idx(i);
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002398 var integer index := i / 3;
2399 var integer earfcn_index := i mod 3;
2400 if (index >= lengthof(si2quater)) {
2401 si2quater[index] := tr_SI2quaterRestOctets_EUTRAN(index := index, count := si2quater_count - 1);
2402 }
2403 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);
2404 }
2405
2406 return si2quater;
2407}
2408
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002409private function f_tr_rr_chan_rel_earfcns(integer count) return template CellSelIndValue
2410{
2411 var template CellSelIndValue_EUTRAN_Descrs cells := {};
2412
Alexander Couzensf74b5cb2020-09-10 22:28:40 +02002413 /* the lte neighbors must match the config & vty to pass this test */
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002414 for (var integer i := 0; i < count; i := i + 1) {
2415 var integer earfcn := f_test_si2quater_earfcn_by_idx(i);
Alexander Couzensf74b5cb2020-09-10 22:28:40 +02002416 cells[i] := tr_CellSelIndValue_EUTRAN_Descr(earfcn, '1'B, 3);
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002417 }
2418
2419 return tr_CellSelIndValue_EUTRAN(cells);
2420}
2421
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002422private function f_tc_si2quater_n_earfcns(integer n) runs on test_CT
2423{
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002424 var template SystemInformationConfig sic := SystemInformationConfig_default;
Pau Espin Pedrol8ab62e42020-12-18 16:19:11 +01002425 sic.si2quater := f_tr_si2quater_earfcns(n);
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002426 var template CellSelIndValue cells := f_tr_rr_chan_rel_earfcns(n);
2427 f_test_si2quater(n, sic, cells);
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002428}
2429
2430testcase TC_si2quater_2_earfcns() runs on test_CT {
2431 f_tc_si2quater_n_earfcns(2);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002432 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002433}
2434
2435testcase TC_si2quater_3_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002436 f_tc_si2quater_n_earfcns(3);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002437 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002438}
2439
2440testcase TC_si2quater_4_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002441 f_tc_si2quater_n_earfcns(4);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002442 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002443}
2444
2445testcase TC_si2quater_5_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002446 f_tc_si2quater_n_earfcns(5);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002447 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002448}
2449
2450testcase TC_si2quater_6_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002451 f_tc_si2quater_n_earfcns(6);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002452 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002453}
2454
2455testcase TC_si2quater_12_earfcns() runs on test_CT {
2456 f_tc_si2quater_n_earfcns(12);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002457 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002458}
2459
2460testcase TC_si2quater_23_earfcns() runs on test_CT {
2461 f_tc_si2quater_n_earfcns(23);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002462 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002463}
2464
2465testcase TC_si2quater_32_earfcns() runs on test_CT {
2466 f_tc_si2quater_n_earfcns(32);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002467 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002468}
2469
2470testcase TC_si2quater_33_earfcns() runs on test_CT {
2471 f_tc_si2quater_n_earfcns(33);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002472 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002473}
2474
2475testcase TC_si2quater_42_earfcns() runs on test_CT {
2476 f_tc_si2quater_n_earfcns(42);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002477 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002478}
2479
2480testcase TC_si2quater_48_earfcns() runs on test_CT {
2481 f_tc_si2quater_n_earfcns(48);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002482 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002483}
2484
2485/* verify the VTY error response when adding too many EARFCNs, and showing that osmo-bsc still sends 16 SI2quater with
2486 * 48 EARFCNs. */
2487testcase TC_si2quater_49_earfcns() runs on test_CT {
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002488 var template SystemInformationConfig sic := SystemInformationConfig_default;
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002489 sic.si2quater := f_tr_si2quater_earfcns(48); /* 48, not 49! */
2490 f_init(0);
2491
2492 for (var integer i := 1; i < 48; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002493 f_bts_0_cfg(BSCVTY, {"si2quater neighbor-list add earfcn " & int2str(f_test_si2quater_earfcn_by_idx(i))
2494 & " thresh-hi 20 thresh-lo 10 prio 3 qrxlv 22 meas 3"});
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002495 }
2496
2497 /* The 49th EARFCN no longer fits, expect VTY error */
2498 f_vty_enter_cfg_bts(BSCVTY, 0);
2499 var charstring vty_error;
2500 vty_error := f_vty_transceive_ret(BSCVTY,
2501 "si2quater neighbor-list add earfcn 70 thresh-hi 20 thresh-lo 10 prio 3 qrxlv 22 meas 3")
2502 f_vty_transceive(BSCVTY, "end");
2503
2504 if (f_strstr(vty_error, "Unable to add ARFCN 70") >= 0) {
2505 log("Got expected VTY error: ", vty_error);
2506 setverdict(pass);
2507 } else {
2508 setverdict(fail, "Expected the 49th EUTRAN ARFCN to be rejected by vty config, got: ", vty_error);
2509 }
2510
2511 f_init_bts_and_check_sysinfo(0, expect_si := sic);
2512
2513 for (var integer i := 1; i < 48; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002514 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 +02002515 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002516 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002517}
2518
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002519private function f_acc09_count_allowed(AccessControlClass acc) return uint8_t
2520{
2521 var uint8_t count := 0;
2522 for (var integer i := 5; i < 16; i := i + 1) {
2523 if (acc[i] == '0'B) { /* the list marks barred, we count allowed */
2524 count := count + 1;
2525 }
2526 }
2527 return count;
2528}
2529
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002530private function f_recv_next_si1(integer rsl_idx := 0) runs on test_CT return SystemInformationType1
2531{
2532 var ASP_RSL_Unitdata rx_rsl_ud;
2533 var SystemInformationType1 last_si1;
2534
2535 timer T := 30.0;
2536 T.start;
2537 alt {
2538 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD((tr_RSL_NO_BCCH_INFO,
2539 tr_RSL_BCCH_INFO,
2540 tr_RSL_NO_SACCH_FILL,
2541 tr_RSL_SACCH_FILL))
2542 ) -> value rx_rsl_ud {
2543 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
2544 if (g_system_information[rsl_idx].si1 == omit) {
2545 repeat;
2546 }
2547 last_si1 := g_system_information[rsl_idx].si1;
2548 g_system_information[rsl_idx].si1 := omit;
2549 T.stop;
2550 }
Vadim Yanitskiy79ebd5e2021-01-04 00:12:55 +01002551 [] IPA_RSL[rsl_idx].receive { repeat; }
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002552 [] T.timeout { setverdict(fail, "Timeout receiving next SI1"); }
2553 }
2554 return last_si1;
2555}
2556
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002557/* verify ACC rotate feature */
2558testcase TC_si_acc_rotate() runs on test_CT {
2559 var template SystemInformationConfig sic := SystemInformationConfig_default;
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002560 var SystemInformationType1 last_si1;
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002561 var AccessControlClass acc;
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002562 var uint8_t count;
2563 var integer times_allowed[10] := { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
2564
2565 f_init(0, guard_timeout := 60.0);
2566
2567 f_bts_0_cfg(BSCVTY, {"rach access-control-class 5 barred",
2568 "access-control-class-rotate 3",
2569 "access-control-class-rotate-quantum 1"});
2570
2571 /* Init and get first sysinfo */
2572 f_init_bts_and_check_sysinfo(0, expect_si := ?);
2573
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002574 for (var integer i:= 0; i < 20; i := i + 1) {
2575 last_si1 := f_recv_next_si1(0);
2576 acc := last_si1.rach_control.acc;
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002577 count := f_acc09_count_allowed(acc);
2578 log("RSL: GOT SI1 ACC len=", count, ": ", acc);
2579
2580 if (count != 3) {
2581 log("RSL: EXPECTED SI ACC len=3");
2582 setverdict(fail, "received SI does not match expectations");
2583 break;
2584 }
2585
2586 for (var integer j := 0; j < 10; j := j + 1) {
2587 if (acc[16 - 1 - j] == '0'B) { /* the list marks barred, we count allowed */
2588 times_allowed[j] := times_allowed[j] + 1;
2589 }
2590 }
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002591 }
2592
2593 for (var integer j := 0; j < 10; j := j + 1) {
2594 log("ACC", j, " allowed ", times_allowed[j], " times" );
2595 if (j != 5 and times_allowed[j] < 3) {
2596 setverdict(fail, "ACC", j, " ERROR: allowed ", times_allowed[j], " < 1 times");
2597 } else if (j == 5 and times_allowed[j] > 0) {
2598 setverdict(fail, "ACC", j, " ERROR: allowed ", times_allowed[j], " > 0 times");
2599 }
2600 }
2601
2602 f_bts_0_cfg(BSCVTY, {"access-control-class-rotate 10",
2603 "rach access-control-class 5 allowed"});
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002604 f_shutdown_helper();
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002605}
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002606
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002607/* verify ACC startup ramp+rotate feature */
2608testcase TC_si_acc_ramp_rotate() runs on test_CT {
2609 var template SystemInformationConfig sic := SystemInformationConfig_default;
2610 var SystemInformationType1 last_si1;
2611 var AccessControlClass acc;
2612 var ASP_RSL_Unitdata rx_rsl_ud;
2613 var uint8_t count;
2614 var uint8_t prev_count;
2615 var integer times_allowed[10] := { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
2616
2617 f_init(0, guard_timeout := 80.0);
2618
2619 f_bts_0_cfg(BSCVTY, {"rach access-control-class 4 barred",
2620 "access-control-class-rotate 0",
2621 "access-control-class-rotate-quantum 1",
2622 "access-control-class-ramping",
2623 "access-control-class-ramping-step-interval 5",
2624 "access-control-class-ramping-step-size 5"});
2625
2626 /* Init and get first sysinfo */
2627 f_init_bts_and_check_sysinfo(0, expect_si := ?);
2628 last_si1 := g_system_information[0].si1;
2629 acc := last_si1.rach_control.acc;
2630 count := f_acc09_count_allowed(acc);
2631 /* Adm subset size was set to 0 above, so wait until all ACC are barred */
2632 while (count > 0) {
2633 last_si1 := f_recv_next_si1(0);
2634 acc := last_si1.rach_control.acc;
2635 count := f_acc09_count_allowed(acc);
2636 log("RSL: wait len()=0: GOT SI1 ACC len=", count, ": ", acc);
2637 }
2638
2639 /* Increase adm subset size, we should see ramping start up */
2640 f_bts_0_cfg(BSCVTY, {"access-control-class-rotate 10"});
2641 prev_count := 0;
2642 while (true) {
2643 last_si1 := f_recv_next_si1(0);
2644 acc := last_si1.rach_control.acc;
2645 count := f_acc09_count_allowed(acc);
2646 log("RSL: GOT SI1 ACC len=", count, ": ", acc);
2647
2648 if (prev_count > count) {
2649 setverdict(fail, "ACC allowed count dropped while expecting grow: ", prev_count, " -> ", count);
2650 break;
2651 }
2652
2653 if (count == 9) {
2654 break; /* Maximum reached (10 - 1 perm barred), done here */
2655 }
2656
2657 prev_count := count;
2658 }
2659
2660 setverdict(pass);
2661
2662 f_bts_0_cfg(BSCVTY, {"access-control-class-rotate 10",
2663 "rach access-control-class 4 allowed",
2664 "no access-control-class-ramping"});
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002665 f_shutdown_helper();
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002666}
2667
Harald Welte4003d112017-12-09 22:35:39 +01002668testcase TC_ctrl_msc_connection_status() runs on test_CT {
2669 var charstring ctrl_resp;
2670
Harald Welte89d42e82017-12-17 16:42:41 +01002671 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01002672
2673 /* See https://osmocom.org/issues/2729 */
2674 f_ctrl_get_exp(IPA_CTRL, "msc_connection_status", "connected");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002675 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01002676}
2677
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01002678testcase TC_ctrl_msc0_connection_status() runs on test_CT {
2679 var charstring ctrl_resp;
2680
2681 f_init(1);
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01002682
2683 f_ctrl_get_exp(IPA_CTRL, "msc.0.connection_status", "connected");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002684 f_shutdown_helper();
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01002685}
2686
Harald Welte4003d112017-12-09 22:35:39 +01002687testcase TC_ctrl() runs on test_CT {
2688 var charstring ctrl_resp;
2689
Harald Welte89d42e82017-12-17 16:42:41 +01002690 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01002691
2692 /* all below values must match the osmo-bsc.cfg config file used */
2693
Harald Welte6a129692018-03-17 17:30:14 +01002694 f_ctrl_get_exp(IPA_CTRL, "mcc", "001");
2695 f_ctrl_get_exp(IPA_CTRL, "mnc", "01");
Oliver Smith75aa0202019-08-19 14:17:50 +02002696 f_ctrl_get_exp(IPA_CTRL, "number-of-bts", "4");
Harald Welte4003d112017-12-09 22:35:39 +01002697
2698 var integer bts_nr := 0;
2699 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "location-area-code", "1");
2700 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "cell-identity", "0");
2701 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "oml-connection-state", "connected");
2702 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "gprs-mode", "gprs");
2703 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "rf_state", "operational,unlocked,on");
2704 f_ctrl_get_exp_trx(IPA_CTRL, bts_nr, 0, "arfcn", "871");
2705 f_ctrl_get_exp_trx(IPA_CTRL, bts_nr, 0, "max-power-reduction", "20");
2706
2707 var integer uptime := str2int(f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-uptime"));
2708 f_sleep(2.0);
2709 if (str2int(f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-uptime")) < uptime+1) {
2710 setverdict(fail, "oml-uptime not incrementing as expected");
2711 }
2712 /* TODO: Disconnect RSL, imply that OML is disconnected and check for uptime zero? */
2713
2714 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted", 0);
2715
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002716 f_shutdown_helper();
Harald Welte96c94412017-12-09 03:12:45 +01002717}
2718
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +02002719/* Verify that Upon receival of SET "location", BSC forwards a TRAP
2720 "location-state" over the SCCPlite IPA conn */
2721testcase TC_ctrl_location() runs on test_CT {
2722 var MSC_ConnHdlr vc_conn;
2723 var integer bts_nr := 0;
2724
2725 f_init(1, true);
2726 f_sleep(1.0);
2727
2728 f_ctrl_set_bts(IPA_CTRL, bts_nr, "location", "1234567,fix3d,0.340000,0.560000,0.780000");
2729 f_ctrl_exp_trap(SCCPLITE_IPA_CTRL, "bts." & int2str(bts_nr) & ".location-state",
2730 "1234567,fix3d,0.340000,0.560000,0.780000,operational,unlocked,on,001,01");
2731
2732 f_ctrl_set(SCCPLITE_IPA_CTRL, "rf_locked", "1");
2733 f_sleep(2.0);
2734
2735 f_ctrl_set_bts(IPA_CTRL, bts_nr, "location", "1234888,fix3d,0.350000,0.570000,0.790000");
2736 f_ctrl_exp_trap(SCCPLITE_IPA_CTRL, "bts." & int2str(bts_nr) & ".location-state",
2737 "1234888,fix3d,0.350000,0.570000,0.790000,operational,locked,off,001,01");
2738
2739 /* should match the one from config */
2740 f_ctrl_set(SCCPLITE_IPA_CTRL, "rf_locked", "0");
2741
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002742 f_shutdown_helper();
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +02002743}
2744
Harald Welte6f521d82017-12-11 19:52:02 +01002745
2746/***********************************************************************
2747 * Paging Testing
2748 ***********************************************************************/
2749
2750type record Cell_Identity {
2751 GsmMcc mcc,
2752 GsmMnc mnc,
2753 GsmLac lac,
2754 GsmCellId ci
2755};
Harald Welte24135bd2018-03-17 19:27:53 +01002756private const Cell_Identity cid := { '001'H, '01'H, 1, 0 };
Stefan Sperling049a86e2018-03-20 15:51:00 +01002757private const Cell_Identity unknown_cid := { '678'H, 'f90'H, 1, 0 };
Harald Welte6f521d82017-12-11 19:52:02 +01002758
Harald Welte5d1a2202017-12-13 19:51:29 +01002759type set of integer BtsIdList;
2760
2761private function f_bts_in_list(integer bts_id, BtsIdList bts_ids) return boolean {
2762 for (var integer j := 0; j < sizeof(bts_ids); j := j + 1) {
2763 if (bts_id == bts_ids[j]) {
2764 return true;
2765 }
2766 }
2767 return false;
2768}
Harald Welte6f521d82017-12-11 19:52:02 +01002769
2770/* core paging test helper function; used by most paging test cases */
2771private function f_pageing_helper(hexstring imsi,
2772 template BSSMAP_FIELD_CellIdentificationList cid_list,
Harald Welte5d1a2202017-12-13 19:51:29 +01002773 BtsIdList bts_ids := { 0 },
Harald Welte6f521d82017-12-11 19:52:02 +01002774 template RSL_ChanNeeded rsl_chneed := omit,
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002775 template (omit) OCT4 tmsi := omit) runs on test_CT
Harald Welte6f521d82017-12-11 19:52:02 +01002776{
2777 var template BSSMAP_IE_ChannelNeeded bssmap_chneed;
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002778 var template MobileIdentityV mi;
Harald Welte6f521d82017-12-11 19:52:02 +01002779 var RSL_Message rx_rsl;
2780 var integer paging_group := hex2int(imsi[lengthof(imsi)-1]);
Harald Welte5d1a2202017-12-13 19:51:29 +01002781 var integer i;
Harald Welte6f521d82017-12-11 19:52:02 +01002782
2783 f_init();
Harald Welte6f521d82017-12-11 19:52:02 +01002784
2785 /* Clear the queue, it might still contain stuff like BCCH FILLING */
Harald Weltec3068592018-03-17 19:55:31 +01002786 for (i := 0; i < NUM_BTS; i := i + 1) {
2787 IPA_RSL[i].clear;
Harald Welte5d1a2202017-12-13 19:51:29 +01002788 }
Harald Welte6f521d82017-12-11 19:52:02 +01002789
2790 if (isvalue(rsl_chneed)) {
2791 /* The values of 08.08 3.2.2.36 and 08.58 9.3.40 are luckily identical */
2792 bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
2793 } else {
2794 bssmap_chneed := omit;
2795 }
2796
Neels Hofmeyrf246a922020-05-13 02:27:10 +02002797 BSSAP.send(ts_BSSAP_UNITDATA_req(g_bssap[0].sccp_addr_peer, g_bssap[0].sccp_addr_own,
2798 ts_BSSMAP_Paging(imsi, cid_list, tmsi, bssmap_chneed)));
Harald Welte6f521d82017-12-11 19:52:02 +01002799
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002800 if (not istemplatekind(tmsi, "omit")) {
2801 mi := t_MI_TMSI(tmsi);
Harald Welte6f521d82017-12-11 19:52:02 +01002802 } else {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002803 mi := tr_MI_IMSI(imsi);
Harald Welte6f521d82017-12-11 19:52:02 +01002804 }
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002805
Harald Welte5d1a2202017-12-13 19:51:29 +01002806 for (i := 0; i < sizeof(bts_ids); i := i + 1) {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002807 rx_rsl := f_exp_ipa_rx(bts_ids[i], tr_RSL_PAGING_CMD(mi));
Harald Welte5d1a2202017-12-13 19:51:29 +01002808 /* check channel type, paging group */
2809 if (rx_rsl.ies[1].body.paging_group != paging_group) {
2810 setverdict(fail, "Paging for wrong paging group");
2811 }
2812 if (ispresent(rsl_chneed) and
2813 rx_rsl.ies[3].body.chan_needed.chan_needed != valueof(rsl_chneed)) {
2814 setverdict(fail, "RSL Channel Needed != BSSMAP Channel Needed");
2815 }
Harald Welte6f521d82017-12-11 19:52:02 +01002816 }
Harald Welte2fccd982018-01-31 15:48:19 +01002817 f_sleep(2.0);
Harald Welte5d1a2202017-12-13 19:51:29 +01002818 /* do a quick check on all not-included BTSs if they received paging */
2819 for (i := 0; i < NUM_BTS; i := i + 1) {
2820 timer T := 0.1;
2821 if (f_bts_in_list(i, bts_ids)) {
2822 continue;
2823 }
2824 T.start;
2825 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07002826 [] IPA_RSL[i].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(mi))) {
Harald Welte5d1a2202017-12-13 19:51:29 +01002827 setverdict(fail, "Paging on BTS ", i, " which is not part of ", bts_ids);
2828 }
2829 [] IPA_RSL[i].receive { repeat; }
2830 [] T.timeout { }
2831 }
Harald Welte6f521d82017-12-11 19:52:02 +01002832 }
2833
2834 setverdict(pass);
2835}
2836
Harald Welte5d1a2202017-12-13 19:51:29 +01002837const BtsIdList c_BtsId_all := { 0, 1, 2 };
Harald Welte751d3eb2018-01-31 15:51:06 +01002838const BtsIdList c_BtsId_none := { };
Harald Welte5d1a2202017-12-13 19:51:29 +01002839const BtsIdList c_BtsId_LAC1 := { 0, 1 };
2840const BtsIdList c_BtsId_LAC2 := { 2 };
2841
Harald Welte6f521d82017-12-11 19:52:02 +01002842/* PAGING by IMSI + TMSI */
2843testcase TC_paging_imsi_nochan() runs on test_CT {
2844 var BSSMAP_FIELD_CellIdentificationList cid_list;
2845 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Philipp Maier8c04b0a2018-02-23 13:48:48 +01002846 f_pageing_helper('001010100000001'H, cid_list, c_BtsId_all, omit, omit);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002847 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002848}
2849
2850/* PAGING by IMSI + TMSI */
2851testcase TC_paging_tmsi_nochan() runs on test_CT {
2852 var BSSMAP_FIELD_CellIdentificationList cid_list;
2853 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002854 f_pageing_helper('001010100000001'H, cid_list, c_BtsId_all, omit, 'A1B2C301'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002855 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002856}
2857
2858/* Paging with different "channel needed' values */
2859testcase TC_paging_tmsi_any() runs on test_CT {
2860 var BSSMAP_FIELD_CellIdentificationList cid_list;
2861 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002862 f_pageing_helper('001010100000002'H, cid_list, c_BtsId_all, RSL_CHANNEED_ANY, 'A1B2C302'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002863 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002864}
2865testcase TC_paging_tmsi_sdcch() runs on test_CT {
2866 var BSSMAP_FIELD_CellIdentificationList cid_list;
2867 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002868 f_pageing_helper('001010100000003'H, cid_list, c_BtsId_all, RSL_CHANNEED_SDCCH, 'A1B2C303'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002869 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002870}
2871testcase TC_paging_tmsi_tch_f() runs on test_CT {
2872 var BSSMAP_FIELD_CellIdentificationList cid_list;
2873 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002874 f_pageing_helper('001010000000004'H, cid_list, c_BtsId_all, RSL_CHANNEED_TCH_F, 'A1B2C304'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002875 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002876}
2877testcase TC_paging_tmsi_tch_hf() runs on test_CT {
2878 var BSSMAP_FIELD_CellIdentificationList cid_list;
2879 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002880 f_pageing_helper('001010000000005'H, cid_list, c_BtsId_all, RSL_CHANNEED_TCH_ForH, 'A1B2C305'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002881 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002882}
2883
2884/* Paging by CGI */
2885testcase TC_paging_imsi_nochan_cgi() runs on test_CT {
2886 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2887 cid_list := { cIl_CGI := { ts_BSSMAP_CI_CGI(cid.mcc, cid.mnc, cid.lac, cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002888 f_pageing_helper('001010000000006'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01002889 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002890}
2891
2892/* Paging by LAC+CI */
2893testcase TC_paging_imsi_nochan_lac_ci() runs on test_CT {
2894 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2895 cid_list := { cIl_LAC_CI := { ts_BSSMAP_CI_LAC_CI(cid.lac, cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002896 f_pageing_helper('001010000000007'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01002897 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002898}
2899
2900/* Paging by CI */
2901testcase TC_paging_imsi_nochan_ci() runs on test_CT {
2902 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2903 cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002904 f_pageing_helper('001010000000008'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01002905 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002906}
2907
2908/* Paging by LAI */
2909testcase TC_paging_imsi_nochan_lai() runs on test_CT {
2910 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2911 cid_list := { cIl_LAI := { ts_BSSMAP_CI_LAI(cid.mcc, cid.mnc, cid.lac) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002912 f_pageing_helper('001010000000009'H, cid_list, c_BtsId_LAC1);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002913 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002914}
2915
2916/* Paging by LAC */
2917testcase TC_paging_imsi_nochan_lac() runs on test_CT {
2918 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2919 cid_list := { cIl_LAC := { ts_BSSMAP_CI_LAC(cid.lac) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002920 f_pageing_helper('001010000000010'H, cid_list, c_BtsId_LAC1);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002921 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002922}
2923
2924/* Paging by "all in BSS" */
2925testcase TC_paging_imsi_nochan_all() runs on test_CT {
2926 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2927 cid_list := { cIl_allInBSS := ''O };
Harald Welte5d1a2202017-12-13 19:51:29 +01002928 f_pageing_helper('001010000000011'H, cid_list, c_BtsId_all);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002929 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002930}
2931
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002932/* Paging by PLMN+LAC+RNC; We do not implement this; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01002933testcase TC_paging_imsi_nochan_plmn_lac_rnc() runs on test_CT {
2934 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2935 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 +01002936 f_pageing_helper('001010000000012'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002937 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002938}
Harald Welte6f521d82017-12-11 19:52:02 +01002939
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002940/* Paging by RNC; We do not implement this; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01002941testcase TC_paging_imsi_nochan_rnc() runs on test_CT {
2942 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2943 cid_list := { cIl_RNC := { int2oct(13, 2) } };
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002944 f_pageing_helper('001010000000013'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002945 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002946}
2947
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002948/* Paging by LAC+RNC; We do not implement; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01002949testcase TC_paging_imsi_nochan_lac_rnc() runs on test_CT {
2950 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2951 cid_list := { cIl_LAC_RNC := { ts_BSSMAP_CI_LAC_RNC(cid.lac, 14) } };
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002952 f_pageing_helper('001010000000014'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002953 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002954}
2955
Harald Welte6f521d82017-12-11 19:52:02 +01002956/* Paging on multiple cells (multiple entries in list): Verify all of them page */
Harald Welte751d3eb2018-01-31 15:51:06 +01002957testcase TC_paging_imsi_nochan_lacs() runs on test_CT {
2958 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2959 cid_list := { cIl_LAC := { ts_BSSMAP_CI_LAC(1), ts_BSSMAP_CI_LAC(2) } };
2960 f_pageing_helper('001010000000015'H, cid_list, c_BtsId_all);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002961 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002962}
2963
2964/* Paging on empty list: Verify none of them page */
2965testcase TC_paging_imsi_nochan_lacs_empty() runs on test_CT {
2966 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2967 cid_list := { cIl_LAC := { } };
2968 f_pageing_helper('001010000000016'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002969 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002970}
2971
Stefan Sperling049a86e2018-03-20 15:51:00 +01002972/* Paging by CGI with unknown MCC/MNC: Verify nothing is paged. */
2973testcase TC_paging_imsi_nochan_cgi_unknown_cid() runs on test_CT {
2974 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2975 cid_list := { cIl_CGI := { ts_BSSMAP_CI_CGI(unknown_cid.mcc, unknown_cid.mnc, unknown_cid.lac, unknown_cid.ci) } };
2976 f_pageing_helper('001010000000006'H, cid_list, c_BtsId_none);
2977 f_shutdown_helper();
2978}
2979
Harald Welte6f521d82017-12-11 19:52:02 +01002980/* Verify paging retransmission interval + count */
2981/* Verify paging stops after channel establishment */
Harald Welte6f521d82017-12-11 19:52:02 +01002982/* Test behavior under paging overload */
Harald Welteae026692017-12-09 01:03:01 +01002983
Harald Weltee65d40e2017-12-13 00:09:06 +01002984/* Verify PCH load */
2985testcase TC_paging_imsi_load() runs on test_CT {
2986 var BSSMAP_FIELD_CellIdentificationList cid_list;
2987 timer T := 4.0;
Harald Welte2caa1062018-03-17 18:19:05 +01002988 timer T_retrans := 1.0;
Harald Weltee65d40e2017-12-13 00:09:06 +01002989 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002990 f_pageing_helper('001010123456789'H, cid_list, c_BtsId_all);
Harald Weltee65d40e2017-12-13 00:09:06 +01002991
2992 /* tell BSC there is no paging space anymore */
2993 f_ipa_tx(0, ts_RSL_PAGING_LOAD_IND(0));
Harald Welte3b57ab52018-03-17 18:01:10 +01002994 f_sleep(0.2);
2995 IPA_RSL[0].clear;
Harald Weltee65d40e2017-12-13 00:09:06 +01002996
2997 /* Wait for 4 seconds if any more PAGING CMD are received on RSL. Normally,
2998 * there would be 8 retransmissions during 4 seconds */
2999 T.start;
Harald Welte2caa1062018-03-17 18:19:05 +01003000 T_retrans.start;
Harald Weltee65d40e2017-12-13 00:09:06 +01003001 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07003002 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Weltee65d40e2017-12-13 00:09:06 +01003003 setverdict(fail, "Received PAGING after LOAD_IND(0)");
Daniel Willmannafce8662018-07-06 23:11:32 +02003004 mtc.stop;
Harald Weltee65d40e2017-12-13 00:09:06 +01003005 }
Harald Welte2caa1062018-03-17 18:19:05 +01003006 [] T_retrans.timeout {
3007 /* re-trnsmit the zero-space LOAD IND to avoid BSC 'auto credit' */
3008 f_ipa_tx(0, ts_RSL_PAGING_LOAD_IND(0));
3009 T_retrans.start;
3010 repeat;
3011 }
Harald Weltee65d40e2017-12-13 00:09:06 +01003012 [] T.timeout {
3013 setverdict(pass);
3014 }
3015 }
Philipp Maier282ca4b2018-02-27 17:17:00 +01003016
3017 f_shutdown_helper();
Harald Weltee65d40e2017-12-13 00:09:06 +01003018}
3019
Harald Welte235ebf12017-12-15 14:18:16 +01003020/* Verify Paging Counter */
Harald Welte1ff69992017-12-14 12:31:17 +01003021testcase TC_paging_counter() runs on test_CT {
3022 var BSSMAP_FIELD_CellIdentificationList cid_list;
3023 timer T := 4.0;
3024 var integer i;
3025 var integer paging_attempted_bsc;
3026 var integer paging_attempted_bts[NUM_BTS];
3027 var integer paging_expired_bts[NUM_BTS];
3028 cid_list := valueof(ts_BSSMAP_CIL_noCell);
3029
3030 f_init();
3031
3032 /* read counters before paging */
3033 paging_attempted_bsc := f_ctrl_get_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted");
3034 for (i := 0; i < NUM_BTS; i := i+1) {
3035 paging_attempted_bts[i] := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", i, "paging:attempted");
3036 paging_expired_bts[i] := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", i, "paging:expired");
3037 }
3038
3039 f_pageing_helper('001230000000001'H, cid_list, c_BtsId_all);
3040
3041 /* expect the attempted pages on BSC and each BTSs to have incremented by one */
3042 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted", paging_attempted_bsc+1);
3043 for (i := 0; i < NUM_BTS; i := i+1) {
3044 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", i, "paging:attempted",
3045 paging_attempted_bts[i]+1);
3046 }
3047
3048 /* assume that 12s later the paging on all BTSs have expired and hence incremented by 1 */
3049 f_sleep(12.0);
3050 for (i := 0; i < NUM_BTS; i := i+1) {
3051 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", i, "paging:expired",
3052 paging_expired_bts[i]+1);
3053 }
Harald Welte1ff69992017-12-14 12:31:17 +01003054
Philipp Maier282ca4b2018-02-27 17:17:00 +01003055 f_shutdown_helper();
Harald Welte1ff69992017-12-14 12:31:17 +01003056}
3057
3058
Harald Welte10985002017-12-12 09:29:15 +01003059/* Verify paging stops after A-RESET */
3060testcase TC_paging_imsi_a_reset() runs on test_CT {
3061 var BSSMAP_FIELD_CellIdentificationList cid_list;
3062 timer T := 3.0;
3063 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01003064 f_pageing_helper('001010123456789'H, cid_list, c_BtsId_all);
Harald Welte10985002017-12-12 09:29:15 +01003065
3066 /* Perform a BSSMAP Reset and wait for ACK */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003067 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 +01003068 alt {
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003069 [] 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 +01003070 [] BSSAP.receive { repeat; }
3071 }
3072
Daniel Willmanncbef3982018-07-30 09:22:40 +02003073 /* Wait to avoid a possible race condition if a paging message is
3074 * received right before the reset ACK. */
3075 f_sleep(0.2);
3076
Harald Welte10985002017-12-12 09:29:15 +01003077 /* Clear the queue, it might still contain stuff like BCCH FILLING */
Philipp Maier1e6b4422018-02-23 14:02:13 +01003078 for (var integer i := 0; i < sizeof(IPA_RSL); i := i+1) {
3079 IPA_RSL[i].clear;
3080 }
Harald Welte10985002017-12-12 09:29:15 +01003081
3082 /* Wait for 3 seconds if any more PAGING CMD are received on RSL */
3083 T.start;
3084 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07003085 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Welte10985002017-12-12 09:29:15 +01003086 setverdict(fail, "Received PAGING after A-RESET");
Daniel Willmannafce8662018-07-06 23:11:32 +02003087 mtc.stop;
Harald Welte10985002017-12-12 09:29:15 +01003088 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07003089 [] IPA_RSL[1].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Welte5d1a2202017-12-13 19:51:29 +01003090 setverdict(fail, "Received PAGING after A-RESET");
Daniel Willmannafce8662018-07-06 23:11:32 +02003091 mtc.stop;
Harald Welte5d1a2202017-12-13 19:51:29 +01003092 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07003093 [] IPA_RSL[2].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Welte5d1a2202017-12-13 19:51:29 +01003094 setverdict(fail, "Received PAGING after A-RESET");
Daniel Willmannafce8662018-07-06 23:11:32 +02003095 mtc.stop;
Harald Welte5d1a2202017-12-13 19:51:29 +01003096 }
Harald Welte10985002017-12-12 09:29:15 +01003097 [] T.timeout {
3098 setverdict(pass);
3099 }
3100 }
Philipp Maier282ca4b2018-02-27 17:17:00 +01003101
3102 f_shutdown_helper();
Harald Welte10985002017-12-12 09:29:15 +01003103}
Harald Welteae026692017-12-09 01:03:01 +01003104
Philipp Maierf45824a2019-08-14 14:44:10 +02003105/* Verify how we handle unsolicited Paging Response. In case of an unsolicit
3106 * paging response we can not know which MSC is in charge, so we will blindly
3107 * pick the first configured MSC. This behavior is required in order to make
3108 * MT-CSFB calls working because in those cases the BSC can not know that the
3109 * MSC has already paged the subscriver via SGs. So any MT-CSFB call will look
3110 * like an unsolicited Paging Response to the MSC.
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003111 */
3112testcase TC_paging_resp_unsol() runs on test_CT {
3113
3114 f_init(1);
Philipp Maierf45824a2019-08-14 14:44:10 +02003115 timer T := 5.0;
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003116
3117 var BSSAP_N_CONNECT_ind rx_c_ind;
3118 var DchanTuple dt;
3119 var PDU_ML3_MS_NW l3 := valueof(ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010008880018'H))));
Philipp Maierf45824a2019-08-14 14:44:10 +02003120 var octetstring rr_pag_resp := enc_PDU_ML3_MS_NW(l3);
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003121
3122 /* Send CHAN RQD and wait for allocation; acknowledge it */
3123 dt.rsl_chan_nr := f_chreq_act_ack();
3124
3125 /* Send unsolicited Paging response (no matching Paging CMD stored in BSC) */
3126 f_ipa_tx(0, ts_RSL_EST_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)), enc_PDU_ML3_MS_NW(l3)));
3127
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003128
Philipp Maierf45824a2019-08-14 14:44:10 +02003129 /* Expevct a CR with a matching Paging response on the A-Interface */
3130 T.start;
3131 alt {
3132 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(rr_pag_resp))) {
3133 setverdict(pass);
3134 }
3135 [] BSSAP.receive {
3136 setverdict(fail, "Received unexpected message on A-Interface!");
3137 }
3138 [] T.timeout {
3139 setverdict(fail, "Received nothing on A-Interface!");
3140 }
3141 }
3142
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003143 f_shutdown_helper();
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003144}
3145
Harald Welte4e9b9cc2017-12-14 18:31:02 +01003146/* Test RSL link drop causes counter increment */
3147testcase TC_rsl_drop_counter() runs on test_CT {
3148 var integer rsl_fail;
3149
Harald Welte89d42e82017-12-17 16:42:41 +01003150 f_init(1);
Harald Welte4e9b9cc2017-12-14 18:31:02 +01003151
3152 rsl_fail := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "rsl_fail");
3153
3154 bts[0].rsl.vc_IPA.stop;
3155
3156 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "rsl_fail", rsl_fail+1);
3157
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003158 f_shutdown_helper();
Harald Welte4e9b9cc2017-12-14 18:31:02 +01003159}
3160
3161/* TODO: Test OML link drop causes counter increment */
3162
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003163/* The body of TC_rsl_unknown_unit_id() and TC_oml_unknown_unit_id() tests. */
3164function f_ipa_unknown_unit_id(integer mp_bsc_ipa_port) runs on test_CT return boolean {
3165 timer T := 10.0;
3166
3167 bts[0].rsl.id := "IPA-0-RSL";
3168 bts[0].rsl.vc_IPA := IPA_Emulation_CT.create(bts[0].rsl.id & "-IPA");
3169 bts[0].rsl.ccm_pars := c_IPA_default_ccm_pars;
3170 bts[0].rsl.ccm_pars.name := "Osmocom TTCN-3 BTS Simulator";
Oliver Smith92c2bdb2019-08-20 15:11:24 +02003171 bts[0].rsl.ccm_pars.unit_id := "99/0/0"; /* value which is unknown at BTS */
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003172
Pau Espin Pedrol9a5b8ff2021-01-04 19:01:31 +01003173 f_ipa_ctrl_start_client(mp_bsc_ip, mp_bsc_ctrl_port);
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003174
3175 f_init_mgcp("VirtMSC");
3176
3177 /* start RSL/OML connection (XXX re-uses RSL port/protocol definitions for OML) */
3178 map(bts[0].rsl.vc_IPA:IPA_PORT, system:IPA);
3179 connect(bts[0].rsl.vc_IPA:IPA_RSL_PORT, self:IPA_RSL[0]);
3180 bts[0].rsl.vc_IPA.start(IPA_Emulation.main_client(mp_bsc_ip, mp_bsc_ipa_port, "", 10000, bts[0].rsl.ccm_pars));
3181
3182 /* wait for IPA OML link to connect and then disconnect */
3183 T.start;
3184 alt {
Vadim Yanitskiya2afacc2020-05-18 21:16:19 +07003185 [] IPA_RSL[0].receive(tr_ASP_IPA_EV(ASP_IPA_EVENT_DOWN)) {
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003186 T.stop;
3187 return true;
3188 }
3189 [] IPA_RSL[0].receive { repeat }
3190 [] T.timeout {
Daniel Willmannafce8662018-07-06 23:11:32 +02003191 return false;
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003192 }
3193 }
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003194 return false;
3195}
3196
3197/* BSC should close an RSL connection from a BTS with unknown unit ID (OS#2714). */
3198testcase TC_rsl_unknown_unit_id() runs on test_CT {
3199 if (f_ipa_unknown_unit_id(mp_bsc_rsl_port)) {
3200 setverdict(pass);
3201 } else {
3202 setverdict(fail, "Timeout RSL waiting for connection to close");
3203 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003204 f_shutdown_helper();
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003205}
3206
3207
3208/* BSC should close an RSL connection from a BTS with unknown unit ID (OS#2714). */
3209testcase TC_oml_unknown_unit_id() runs on test_CT {
3210 if (f_ipa_unknown_unit_id(mp_bsc_oml_port)) {
3211 setverdict(pass);
3212 } else {
3213 setverdict(fail, "Timeout OML waiting for connection to close");
3214 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003215 f_shutdown_helper();
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003216}
3217
3218
Harald Weltec1a2fff2017-12-17 11:06:19 +01003219/***********************************************************************
Harald Welte6811d102019-04-14 22:23:14 +02003220 * "New world" test cases using RSL_Emulation + RAN_Emulation
Harald Weltec1a2fff2017-12-17 11:06:19 +01003221 ***********************************************************************/
3222
Harald Welte6811d102019-04-14 22:23:14 +02003223import from RAN_Emulation all;
Harald Welte47cd0e32020-08-21 12:39:11 +02003224import from BSSAP_LE_Emulation all;
Harald Weltec1a2fff2017-12-17 11:06:19 +01003225import from RSL_Emulation all;
3226import from MSC_ConnectionHandler all;
3227
3228type function void_fn(charstring id) runs on MSC_ConnHdlr;
3229
Harald Welte336820c2018-05-31 20:34:52 +02003230/* helper function to create and connect a MSC_ConnHdlr component */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003231private function f_connect_handler(inout MSC_ConnHdlr vc_conn, integer bssap_idx := 0) runs on test_CT {
3232 connect(vc_conn:RAN, g_bssap[bssap_idx].vc_RAN:PROC);
Daniel Willmann191e0d92018-01-17 12:44:35 +01003233 connect(vc_conn:MGCP_PROC, vc_MGCP:MGCP_PROC);
Harald Weltec1a2fff2017-12-17 11:06:19 +01003234 connect(vc_conn:RSL, bts[0].rsl.vc_RSL:CLIENT_PT);
Harald Weltef70df652018-01-29 22:00:23 +01003235 connect(vc_conn:RSL_PROC, bts[0].rsl.vc_RSL:RSL_PROC);
Philipp Maier88f4ae82018-03-01 14:00:58 +01003236 if (isvalue(bts[1])) {
Philipp Maier956a92f2018-02-16 10:58:07 +01003237 connect(vc_conn:RSL1, bts[1].rsl.vc_RSL:CLIENT_PT);
3238 connect(vc_conn:RSL1_PROC, bts[1].rsl.vc_RSL:RSL_PROC);
3239 }
Neels Hofmeyr91401012019-07-11 00:42:35 +02003240 if (isvalue(bts[2])) {
3241 connect(vc_conn:RSL2, bts[2].rsl.vc_RSL:CLIENT_PT);
3242 connect(vc_conn:RSL2_PROC, bts[2].rsl.vc_RSL:RSL_PROC);
3243 }
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003244 connect(vc_conn:BSSAP, g_bssap[bssap_idx].vc_RAN:CLIENT);
Neels Hofmeyrcfe44062020-10-15 02:28:08 +02003245 if (mp_enable_lcs_tests) {
3246 connect(vc_conn:BSSAP_LE, g_bssap_le.vc_BSSAP_LE:CLIENT);
3247 connect(vc_conn:BSSAP_LE_PROC, g_bssap_le.vc_BSSAP_LE:PROC);
3248 }
Daniel Willmann191e0d92018-01-17 12:44:35 +01003249 connect(vc_conn:MGCP, vc_MGCP:MGCP_CLIENT);
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02003250 connect(vc_conn:MGCP_MULTI, vc_MGCP:MGCP_CLIENT_MULTI);
Daniel Willmannebdecc02020-08-12 15:30:17 +02003251 connect(vc_conn:STATSD_PROC, vc_STATSD:STATSD_PROC);
Harald Welte336820c2018-05-31 20:34:52 +02003252}
3253
3254function f_start_handler(void_fn fn, template (omit) TestHdlrParams pars := omit)
3255runs on test_CT return MSC_ConnHdlr {
3256 var charstring id := testcasename();
3257 var MSC_ConnHdlr vc_conn;
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003258 var integer bssap_idx := 0;
3259 if (isvalue(pars)) {
3260 bssap_idx := valueof(pars).mscpool.bssap_idx;
3261 }
Harald Welte336820c2018-05-31 20:34:52 +02003262 vc_conn := MSC_ConnHdlr.create(id);
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003263 f_connect_handler(vc_conn, bssap_idx);
Neels Hofmeyr1708d1b2020-10-10 16:56:48 +02003264 /* Emit a marker to appear in the SUT's own logging output */
3265 f_logp(BSCVTY, testcasename() & "() start");
Harald Weltea0630032018-03-20 21:09:55 +01003266 vc_conn.start(f_handler_init(fn, id, pars));
Harald Weltec1a2fff2017-12-17 11:06:19 +01003267 return vc_conn;
3268}
3269
Harald Weltea0630032018-03-20 21:09:55 +01003270/* first function inside ConnHdlr component; sets g_pars + starts function */
3271private function f_handler_init(void_fn fn, charstring id, template (omit) TestHdlrParams pars := omit)
3272runs on MSC_ConnHdlr {
3273 if (isvalue(pars)) {
3274 g_pars := valueof(pars);
3275 }
3276 fn.apply(id);
3277}
3278
Harald Welte3c86ea02018-05-10 22:28:05 +02003279/* Establish signalling channel (non-assignment case) followed by cipher mode */
3280private function f_tc_ciph_mode_a5(charstring id) runs on MSC_ConnHdlr {
Harald Welteed848512018-05-24 22:27:58 +02003281 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3282 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte3c86ea02018-05-10 22:28:05 +02003283 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeSIGNAL);
Philipp Maier23000732018-05-18 11:25:37 +02003284 ass_cmd.pdu.bssmap.assignmentRequest.circuitIdentityCode := omit;
3285 ass_cmd.pdu.bssmap.assignmentRequest.aoIPTransportLayer := omit;
3286 exp_compl.pdu.bssmap.assignmentComplete.circuitIdentityCode := omit;
3287 exp_compl.pdu.bssmap.assignmentComplete.aoIPTransportLayer := omit;
Harald Welte3c86ea02018-05-10 22:28:05 +02003288
Philipp Maier23000732018-05-18 11:25:37 +02003289 f_establish_fully(ass_cmd, exp_compl);
Harald Welte3c86ea02018-05-10 22:28:05 +02003290}
3291testcase TC_ciph_mode_a5_0() runs on test_CT {
3292 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003293 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02003294 pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
3295
3296 f_init(1, true);
3297 f_sleep(1.0);
3298 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
3299 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003300 f_shutdown_helper();
Harald Welte3c86ea02018-05-10 22:28:05 +02003301}
3302testcase TC_ciph_mode_a5_1() runs on test_CT {
3303 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003304 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02003305 pars.encr := valueof(t_EncrParams('02'O, f_rnd_octstring(8)));
3306
3307 f_init(1, true);
3308 f_sleep(1.0);
3309 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
3310 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003311 f_shutdown_helper();
Harald Welte3c86ea02018-05-10 22:28:05 +02003312}
3313testcase TC_ciph_mode_a5_3() runs on test_CT {
3314 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003315 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02003316 pars.encr := valueof(t_EncrParams('08'O, f_rnd_octstring(8)));
3317
3318 f_init(1, true);
3319 f_sleep(1.0);
3320 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
3321 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003322 f_shutdown_helper();
Harald Welte3c86ea02018-05-10 22:28:05 +02003323}
3324
Pau Espin Pedrol07866632020-09-03 19:10:55 +02003325/* establish initial channel, enable ciphering followed by assignment to ciphered channel */
3326private function f_tc_assignment_aoip_tla_v6(charstring id) runs on MSC_ConnHdlr {
3327 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3328 var PDU_BSSAP ass_cmd := f_gen_ass_req(aoip_tla := "::3");
3329 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3330 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
3331
3332 f_establish_fully(ass_cmd, exp_compl);
3333}
3334testcase TC_assignment_aoip_tla_v6() runs on test_CT {
3335 var MSC_ConnHdlr vc_conn;
3336 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3337
3338 f_init(1, true);
3339 f_sleep(1.0);
3340 vc_conn := f_start_handler(refers(f_tc_assignment_aoip_tla_v6), pars);
3341 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003342 f_shutdown_helper();
Pau Espin Pedrol07866632020-09-03 19:10:55 +02003343}
3344
Harald Welte3c86ea02018-05-10 22:28:05 +02003345
3346/* establish initial channel, enable ciphering followed by assignment to ciphered channel */
Harald Welte651fcdc2018-05-10 20:23:16 +02003347private function f_tc_assignment_fr_a5(charstring id) runs on MSC_ConnHdlr {
Harald Welteed848512018-05-24 22:27:58 +02003348 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3349 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Weltec1a2fff2017-12-17 11:06:19 +01003350
Harald Welte552620d2017-12-16 23:21:36 +01003351 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3352 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Welte73cd2712017-12-17 00:44:52 +01003353
Harald Weltea0630032018-03-20 21:09:55 +01003354 f_establish_fully(ass_cmd, exp_compl);
Harald Welte552620d2017-12-16 23:21:36 +01003355}
Harald Welte552620d2017-12-16 23:21:36 +01003356testcase TC_assignment_fr_a5_0() runs on test_CT {
3357 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003358 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02003359 pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
Harald Welte552620d2017-12-16 23:21:36 +01003360
Harald Welte89d42e82017-12-17 16:42:41 +01003361 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01003362 f_sleep(1.0);
Harald Welte651fcdc2018-05-10 20:23:16 +02003363 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
Harald Welte552620d2017-12-16 23:21:36 +01003364 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003365 f_shutdown_helper();
Harald Welte552620d2017-12-16 23:21:36 +01003366}
Harald Welte552620d2017-12-16 23:21:36 +01003367testcase TC_assignment_fr_a5_1() runs on test_CT {
Harald Weltec1a2fff2017-12-17 11:06:19 +01003368 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003369 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02003370 pars.encr := valueof(t_EncrParams('02'O, f_rnd_octstring(8)));
Harald Weltec1a2fff2017-12-17 11:06:19 +01003371
Harald Welte89d42e82017-12-17 16:42:41 +01003372 f_init(1, true);
Harald Weltec1a2fff2017-12-17 11:06:19 +01003373 f_sleep(1.0);
Harald Welte651fcdc2018-05-10 20:23:16 +02003374 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
3375 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003376 f_shutdown_helper();
Harald Welte651fcdc2018-05-10 20:23:16 +02003377}
3378testcase TC_assignment_fr_a5_3() runs on test_CT {
3379 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003380 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02003381 pars.encr := valueof(t_EncrParams('08'O, f_rnd_octstring(8)));
Harald Weltec1a2fff2017-12-17 11:06:19 +01003382
Harald Welte651fcdc2018-05-10 20:23:16 +02003383 f_init(1, true);
3384 f_sleep(1.0);
3385 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
Harald Weltec1a2fff2017-12-17 11:06:19 +01003386 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003387 f_shutdown_helper();
Harald Weltec1a2fff2017-12-17 11:06:19 +01003388}
3389
Harald Welte552620d2017-12-16 23:21:36 +01003390/* Expect ASSIGNMENT FAIL if mandatory IE is missing */
3391private function f_tc_assignment_fr_a5_1_codec_missing(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02003392 g_pars := f_gen_test_hdlr_pars();
Harald Welte552620d2017-12-16 23:21:36 +01003393 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +02003394 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte552620d2017-12-16 23:21:36 +01003395 const OCT8 kc := '0001020304050607'O;
3396
3397 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02003398 /* Omit: ass_cmd.pdu.bssmap.assignmentRequest.codecList */
3399
Harald Weltea0630032018-03-20 21:09:55 +01003400 f_establish_fully(ass_cmd, exp_fail);
Harald Welte552620d2017-12-16 23:21:36 +01003401}
Harald Welte552620d2017-12-16 23:21:36 +01003402testcase TC_assignment_fr_a5_1_codec_missing() runs on test_CT {
3403 var MSC_ConnHdlr vc_conn;
3404
Harald Welte89d42e82017-12-17 16:42:41 +01003405 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01003406 f_sleep(1.0);
3407
Harald Welte8863fa12018-05-10 20:15:27 +02003408 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5_1_codec_missing));
Harald Welte552620d2017-12-16 23:21:36 +01003409 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003410 f_shutdown_helper();
Harald Welte552620d2017-12-16 23:21:36 +01003411}
3412
Harald Welte552620d2017-12-16 23:21:36 +01003413private function f_tc_assignment_fr_a5_4(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02003414 g_pars := f_gen_test_hdlr_pars();
Harald Welteed848512018-05-24 22:27:58 +02003415 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3416 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte552620d2017-12-16 23:21:36 +01003417 const OCT8 kc := '0001020304050607'O;
3418 const OCT16 kc128 := kc & kc;
3419
3420 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3421 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Weltea0630032018-03-20 21:09:55 +01003422 f_establish_fully(ass_cmd, exp_compl);
Harald Welte38b2a102017-12-23 02:42:58 +01003423 f_cipher_mode('10'O, kc, kc128, true);
Harald Welte552620d2017-12-16 23:21:36 +01003424 /* TODO: expect GSM0808_CAUSE_CIPHERING_ALGORITHM_NOT_SUPPORTED cause value */
Harald Welte552620d2017-12-16 23:21:36 +01003425}
Harald Welte552620d2017-12-16 23:21:36 +01003426testcase TC_assignment_fr_a5_4() runs on test_CT {
3427 var MSC_ConnHdlr vc_conn;
3428
Harald Welte89d42e82017-12-17 16:42:41 +01003429 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01003430 f_sleep(1.0);
3431
Harald Welte8863fa12018-05-10 20:15:27 +02003432 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5_4));
Harald Welte552620d2017-12-16 23:21:36 +01003433 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003434 f_shutdown_helper();
Harald Welte552620d2017-12-16 23:21:36 +01003435}
3436
3437
Harald Welte4532e0a2017-12-23 02:05:44 +01003438private function f_tc_assignment_sign(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02003439 g_pars := f_gen_test_hdlr_pars();
Harald Welte4532e0a2017-12-23 02:05:44 +01003440 var template PDU_BSSAP exp_compl := tr_BSSMAP_AssignmentComplete(omit, omit);
Philipp Maier48604732018-10-09 15:00:37 +02003441 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte4532e0a2017-12-23 02:05:44 +01003442 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeSIGNAL);
Daniel Willmannebdecc02020-08-12 15:30:17 +02003443
3444 f_statsd_reset();
Harald Weltea0630032018-03-20 21:09:55 +01003445 f_establish_fully(ass_cmd, exp_compl);
Daniel Willmannebdecc02020-08-12 15:30:17 +02003446
3447 var StatsDExpects expect := {
Daniel Willmannc5398f72020-09-21 10:41:35 +02003448 { name := "TTCN3.bts.0.chreq.total", mtype := "c", min := 1, max := 1},
3449 { name := "TTCN3.bts.0.chreq.successful", mtype := "c", min := 1, max := 1},
Daniel Willmannebdecc02020-08-12 15:30:17 +02003450 { name := "TTCN3.bsc.0.assignment.attempted", mtype := "c", min := 1, max := 1},
3451 { name := "TTCN3.bsc.0.assignment.completed", mtype := "c", min := 1, max := 1}
3452 };
3453 f_statsd_expect(expect);
Harald Welte4532e0a2017-12-23 02:05:44 +01003454}
3455
3456testcase TC_assignment_sign() runs on test_CT {
3457 var MSC_ConnHdlr vc_conn;
3458
3459 f_init(1, true);
3460 f_sleep(1.0);
3461
Harald Welte8863fa12018-05-10 20:15:27 +02003462 vc_conn := f_start_handler(refers(f_tc_assignment_sign));
Harald Welte4532e0a2017-12-23 02:05:44 +01003463 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003464 f_shutdown_helper();
Harald Welte4532e0a2017-12-23 02:05:44 +01003465}
3466
Harald Welte60aa5762018-03-21 19:33:13 +01003467/***********************************************************************
3468 * Codec (list) testing
3469 ***********************************************************************/
3470
3471/* check if the given rsl_mode is compatible with the a_elem */
3472private function f_match_codec(BSSMAP_FIELD_CodecElement a_elem, RSL_IE_ChannelMode rsl_mode)
3473return boolean {
3474 select (a_elem.codecType) {
3475 case (GSM_FR) {
3476 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM1))) {
3477 return true;
3478 }
3479 }
3480 case (GSM_HR) {
3481 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1))) {
3482 return true;
3483 }
3484 }
3485 case (GSM_EFR) {
3486 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM2))) {
3487 return true;
3488 }
3489 }
3490 case (FR_AMR) {
3491 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM3))) {
3492 return true;
3493 }
3494 }
3495 case (HR_AMR) {
3496 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM3))) {
3497 return true;
3498 }
3499 }
3500 case else { }
3501 }
3502 return false;
3503}
3504
3505/* check if the given rsl_mode is compatible with the a_list */
3506private function f_match_codecs(BSSMAP_IE_SpeechCodecList a_list, RSL_IE_ChannelMode rsl_mode)
3507return boolean {
3508 for (var integer i := 0; i < sizeof(a_list); i := i+1) {
3509 if (f_match_codec(a_list.codecElements[i], rsl_mode)) {
3510 return true;
3511 }
3512 }
3513 return false;
3514}
3515
3516/* determine BSSMAP_IE_ChannelType from *first* element of BSSMAP_FIELD_CodecElement */
Philipp Maier61f6b572018-07-06 14:03:38 +02003517function f_BSSMAP_chtype_from_codec(BSSMAP_FIELD_CodecElement a_elem)
Harald Welte60aa5762018-03-21 19:33:13 +01003518return BSSMAP_IE_ChannelType {
3519 /* FIXME: actually look at all elements of BSSMAP_IE_SpeechCodecList */
3520 var BSSMAP_IE_ChannelType ret := valueof(ts_BSSMAP_IE_ChannelType);
3521 select (a_elem.codecType) {
3522 case (GSM_FR) {
3523 ret.channelRateAndType := ChRate_TCHF;
3524 ret.speechId_DataIndicator := Spdi_TCHF_FR;
3525 }
3526 case (GSM_HR) {
3527 ret.channelRateAndType := ChRate_TCHH;
3528 ret.speechId_DataIndicator := Spdi_TCHH_HR;
3529 }
3530 case (GSM_EFR) {
3531 ret.channelRateAndType := ChRate_TCHF;
3532 ret.speechId_DataIndicator := Spdi_TCHF_EFR;
3533 }
3534 case (FR_AMR) {
3535 ret.channelRateAndType := ChRate_TCHF;
3536 ret.speechId_DataIndicator := Spdi_TCHF_AMR;
3537 }
3538 case (HR_AMR) {
3539 ret.channelRateAndType := ChRate_TCHH;
3540 ret.speechId_DataIndicator := Spdi_TCHH_AMR;
3541 }
3542 case else {
3543 setverdict(fail, "Unsupported codec ", a_elem);
Daniel Willmannafce8662018-07-06 23:11:32 +02003544 mtc.stop;
Harald Welte60aa5762018-03-21 19:33:13 +01003545 }
3546 }
3547 return ret;
3548}
3549
Harald Weltea63b9102018-03-22 20:36:16 +01003550private function f_rsl_chmod_tmpl_from_codec(BSSMAP_FIELD_CodecElement a_elem)
3551return template RSL_IE_Body {
3552 var template RSL_IE_Body mode_ie := {
3553 chan_mode := {
3554 len := ?,
3555 reserved := ?,
3556 dtx_d := ?,
3557 dtx_u := ?,
3558 spd_ind := RSL_SPDI_SPEECH,
3559 ch_rate_type := -,
3560 coding_alg_rate := -
3561 }
3562 }
3563
3564 select (a_elem.codecType) {
3565 case (GSM_FR) {
3566 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
3567 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM1;
3568 }
3569 case (GSM_HR) {
3570 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_H;
3571 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM1;
3572 }
3573 case (GSM_EFR) {
3574 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
3575 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM2;
3576 }
3577 case (FR_AMR) {
3578 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
3579 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM3;
3580 }
3581 case (HR_AMR) {
3582 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_H;
3583 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM3;
3584 }
3585 }
3586 return mode_ie;
3587}
3588
Harald Welte60aa5762018-03-21 19:33:13 +01003589type record CodecListTest {
3590 BSSMAP_IE_SpeechCodecList codec_list,
3591 charstring id
3592}
3593type record of CodecListTest CodecListTests
3594
3595private function f_TC_assignment_codec(charstring id) runs on MSC_ConnHdlr {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02003596 var PDU_BSSAP ass_cmd := f_gen_ass_req(g_pars.use_osmux);
3597 var template PDU_BSSAP exp_compl := f_gen_exp_compl(g_pars.use_osmux);
Harald Welte60aa5762018-03-21 19:33:13 +01003598
3599 /* puzzle together the ASSIGNMENT REQ for given codec[s] */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003600 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welte79f3f542018-05-25 20:02:37 +02003601 ass_cmd.pdu.bssmap.assignmentRequest.codecList := g_pars.ass_codec_list;
3602 exp_compl.pdu.bssmap.assignmentComplete.speechCodec.codecElements[0] :=
3603 g_pars.ass_codec_list.codecElements[0];
Philipp Maierd0e64b02019-03-13 14:15:23 +01003604 if (isvalue(g_pars.expect_mr_s0_s7)) {
3605 exp_compl.pdu.bssmap.assignmentComplete.speechCodec.codecElements[0].s0_7 :=
3606 g_pars.expect_mr_s0_s7;
3607 }
Harald Welte79f3f542018-05-25 20:02:37 +02003608 }
Harald Welte60aa5762018-03-21 19:33:13 +01003609 ass_cmd.pdu.bssmap.assignmentRequest.channelType :=
3610 f_BSSMAP_chtype_from_codec(g_pars.ass_codec_list.codecElements[0]);
Harald Welte60aa5762018-03-21 19:33:13 +01003611 log("expecting ASS COMPL like this: ", exp_compl);
3612
3613 f_establish_fully(ass_cmd, exp_compl);
Harald Weltea63b9102018-03-22 20:36:16 +01003614
3615 /* Verify that the RSL-side activation actually matches our expectations */
3616 var RSL_Message rsl := f_rslem_get_last_act(RSL_PROC, 0, g_chan_nr);
3617
3618 var RSL_IE_Body mode_ie;
3619 if (f_rsl_find_ie(rsl, RSL_IE_CHAN_MODE, mode_ie) == false) {
3620 setverdict(fail, "Couldn't find CHAN_MODE IE");
Daniel Willmannafce8662018-07-06 23:11:32 +02003621 mtc.stop;
Harald Weltea63b9102018-03-22 20:36:16 +01003622 }
3623 var template RSL_IE_Body t_mode_ie := f_rsl_chmod_tmpl_from_codec(g_pars.ass_codec_list.codecElements[0]);
3624 if (not match(mode_ie, t_mode_ie)) {
3625 setverdict(fail, "RSL Channel Mode IE doesn't match expectation");
3626 }
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003627
3628 var RSL_IE_Body mr_conf;
3629 if (g_pars.expect_mr_conf_ie != omit) {
3630 if (f_rsl_find_ie(rsl, RSL_IE_MR_CONFIG, mr_conf) == false) {
3631 setverdict(fail, "Missing MR CONFIG IE in RSL Chan Activ");
Daniel Willmannafce8662018-07-06 23:11:32 +02003632 mtc.stop;
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003633 }
3634 log("found RSL MR CONFIG IE: ", mr_conf);
3635
3636 if (not match(mr_conf, g_pars.expect_mr_conf_ie)) {
3637 setverdict(fail, "RSL MR CONFIG IE does not match expectation. Expected: ",
3638 g_pars.expect_mr_conf_ie);
3639 }
3640 } else {
3641 if (f_rsl_find_ie(rsl, RSL_IE_MR_CONFIG, mr_conf) == true) {
3642 log("found RSL MR CONFIG IE: ", mr_conf);
3643 setverdict(fail, "Found MR CONFIG IE in RSL Chan Activ, expecting omit");
Daniel Willmannafce8662018-07-06 23:11:32 +02003644 mtc.stop;
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003645 }
3646 }
Harald Welte60aa5762018-03-21 19:33:13 +01003647}
3648
Philipp Maierd0e64b02019-03-13 14:15:23 +01003649private function f_TC_assignment_codec_fail(charstring id) runs on MSC_ConnHdlr {
3650
3651 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3652 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
3653
3654 /* puzzle together the ASSIGNMENT REQ for given codec[s] */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003655 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Philipp Maierd0e64b02019-03-13 14:15:23 +01003656 ass_cmd.pdu.bssmap.assignmentRequest.codecList := g_pars.ass_codec_list;
3657 }
3658 ass_cmd.pdu.bssmap.assignmentRequest.channelType :=
3659 f_BSSMAP_chtype_from_codec(g_pars.ass_codec_list.codecElements[0]);
3660 log("expecting ASS FAIL like this: ", exp_fail);
3661
3662 f_establish_fully(ass_cmd, exp_fail);
3663}
3664
Harald Welte60aa5762018-03-21 19:33:13 +01003665testcase TC_assignment_codec_fr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003666 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003667 var MSC_ConnHdlr vc_conn;
3668
3669 f_init(1, true);
3670 f_sleep(1.0);
3671
3672 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Welte8863fa12018-05-10 20:15:27 +02003673 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003674 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003675 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01003676}
3677
3678testcase TC_assignment_codec_hr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003679 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003680 var MSC_ConnHdlr vc_conn;
3681
3682 f_init(1, true);
3683 f_sleep(1.0);
3684
3685 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
Harald Welte8863fa12018-05-10 20:15:27 +02003686 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003687 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003688 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01003689}
3690
3691testcase TC_assignment_codec_efr() 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;
3694
3695 f_init(1, true);
3696 f_sleep(1.0);
3697
3698 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecEFR}));
Harald Welte8863fa12018-05-10 20:15:27 +02003699 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003700 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003701 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01003702}
3703
Philipp Maierd0e64b02019-03-13 14:15:23 +01003704/* Allow 5,90k only (current default config) */
3705private function f_allow_amr_rate_5_90k() runs on test_CT {
Neels Hofmeyr2a5670b2020-11-25 23:39:57 +00003706 f_vty_cfg_msc(BSCVTY, 0, {
3707 "amr-config 12_2k forbidden",
3708 "amr-config 10_2k forbidden",
3709 "amr-config 7_95k forbidden",
3710 "amr-config 7_40k forbidden",
3711 "amr-config 6_70k forbidden",
3712 "amr-config 5_90k allowed",
3713 "amr-config 5_15k forbidden",
3714 "amr-config 4_75k forbidden"
3715 });
Philipp Maierd0e64b02019-03-13 14:15:23 +01003716}
3717
3718/* Allow 4,75k, 5,90k, 4,70k and 12,2k, which are the most common rates
3719 * ("Config-NB-Code = 1") */
3720private function f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k() runs on test_CT {
Neels Hofmeyr2a5670b2020-11-25 23:39:57 +00003721 f_vty_cfg_msc(BSCVTY, 0, {
3722 "amr-config 12_2k allowed",
3723 "amr-config 10_2k forbidden",
3724 "amr-config 7_95k forbidden",
3725 "amr-config 7_40k allowed",
3726 "amr-config 6_70k forbidden",
3727 "amr-config 5_90k allowed",
3728 "amr-config 5_15k forbidden",
3729 "amr-config 4_75k allowed"
3730 });
Philipp Maierd0e64b02019-03-13 14:15:23 +01003731}
3732
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003733private function f_vty_amr_start_mode_set(boolean fr, charstring startmode) runs on test_CT {
3734 var charstring tch;
3735 if (fr) {
3736 tch := "tch-f";
3737 } else {
3738 tch := "tch-h";
3739 }
3740 f_vty_cfg_bts(BSCVTY, 0, { "amr " & tch & " start-mode " & startmode });
3741}
3742
3743/* Set the AMR start-mode for this TCH back to the default configuration. */
3744private function f_vty_amr_start_mode_restore(boolean fr) runs on test_CT {
3745 f_vty_amr_start_mode_set(fr, "auto");
3746}
3747
Harald Welte60aa5762018-03-21 19:33:13 +01003748testcase TC_assignment_codec_amr_f() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003749 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003750 var MSC_ConnHdlr vc_conn;
Philipp Maier7695a0d2018-09-27 17:52:14 +02003751
3752 /* Note: This setups the codec configuration. The parameter payload in
3753 * mr_conf must be consistant with the parameter codecElements in pars
3754 * and also must match the amr-config in osmo-bsc.cfg! */
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003755 var RSL_IE_Body mr_conf := {
3756 other := {
3757 len := 2,
3758 payload := '2804'O
3759 }
3760 };
Harald Welte60aa5762018-03-21 19:33:13 +01003761
Philipp Maier7695a0d2018-09-27 17:52:14 +02003762 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
Philipp Maier806f8f12019-03-12 12:13:41 +01003763 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
Philipp Maier7695a0d2018-09-27 17:52:14 +02003764 pars.ass_codec_list.codecElements[0].s8_15 := '01010111'B;
3765 pars.expect_mr_conf_ie := mr_conf;
3766
Harald Welte60aa5762018-03-21 19:33:13 +01003767 f_init(1, true);
3768 f_sleep(1.0);
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003769 f_vty_amr_start_mode_set(true, "1");
Harald Welte60aa5762018-03-21 19:33:13 +01003770
Harald Welte8863fa12018-05-10 20:15:27 +02003771 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003772 vc_conn.done;
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003773
3774 f_vty_amr_start_mode_restore(true);
Vadim Yanitskiy292e5962021-01-03 14:18:47 +01003775 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01003776}
3777
3778testcase TC_assignment_codec_amr_h() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003779 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003780 var MSC_ConnHdlr vc_conn;
Philipp Maier7695a0d2018-09-27 17:52:14 +02003781
3782 /* See note above */
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003783 var RSL_IE_Body mr_conf := {
3784 other := {
3785 len := 2,
3786 payload := '2804'O
3787 }
3788 };
Harald Welte60aa5762018-03-21 19:33:13 +01003789
Philipp Maier7695a0d2018-09-27 17:52:14 +02003790 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
Philipp Maier806f8f12019-03-12 12:13:41 +01003791 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
Philipp Maier7695a0d2018-09-27 17:52:14 +02003792 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
3793 pars.expect_mr_conf_ie := mr_conf;
3794
Harald Welte60aa5762018-03-21 19:33:13 +01003795 f_init(1, true);
3796 f_sleep(1.0);
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003797 f_vty_amr_start_mode_set(false, "1");
Harald Welte60aa5762018-03-21 19:33:13 +01003798
Harald Welte8863fa12018-05-10 20:15:27 +02003799 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003800 vc_conn.done;
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003801
3802 f_vty_amr_start_mode_restore(false);
Vadim Yanitskiy292e5962021-01-03 14:18:47 +01003803 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01003804}
3805
Neels Hofmeyr454d7922020-11-26 02:24:57 +00003806/* 'amr start-mode auto' should not keep the (unused) 'smod' bits from previous configuration */
3807testcase TC_assignment_codec_amr_startmode_cruft() runs on test_CT {
3808 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3809 var MSC_ConnHdlr vc_conn;
3810
3811 var RSL_IE_Body mr_conf := {
3812 other := {
3813 len := 2,
3814 payload := '2004'O /* <- expect ICMI=0, smod=00 */
3815 }
3816 };
3817
3818 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
3819 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
3820 pars.ass_codec_list.codecElements[0].s8_15 := '01010111'B;
3821 pars.expect_mr_conf_ie := mr_conf;
3822
3823 f_init(1, true);
3824 f_sleep(1.0);
3825
3826 /* First set nonzero start mode bits */
3827 f_vty_amr_start_mode_set(true, "4");
3828 /* Now set to auto, and expect the startmode bits to be zero in the message, i.e. ensure that osmo-bsc does not
3829 * let the startmode bits stick around and has deterministic MultiRate config for 'start-mode auto'; that is
3830 * ensured by above '2004'O, where 'x0xx'O indicates ICMI = 0, spare = 0, smod = 00. */
3831 f_vty_amr_start_mode_set(true, "auto");
3832
3833 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
3834 vc_conn.done;
Neels Hofmeyr454d7922020-11-26 02:24:57 +00003835
3836 /* Clear the startmode bits to not affect subsequent tests, in case the bits should indeed stick around. */
3837 f_vty_amr_start_mode_set(true, "1");
3838 f_vty_amr_start_mode_restore(true);
Vadim Yanitskiy292e5962021-01-03 14:18:47 +01003839 f_shutdown_helper();
Neels Hofmeyr454d7922020-11-26 02:24:57 +00003840}
3841
Neels Hofmeyr21863562020-11-26 00:34:33 +00003842function f_TC_assignment_codec_amr(boolean fr, octetstring mrconf, bitstring s8_s0, bitstring exp_s8_s0,
3843 charstring start_mode := "1")
Philipp Maierd0e64b02019-03-13 14:15:23 +01003844runs on test_CT {
3845
3846 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3847 var MSC_ConnHdlr vc_conn;
3848
3849 /* See note above */
3850 var RSL_IE_Body mr_conf := {
3851 other := {
3852 len := lengthof(mrconf),
3853 payload := mrconf
3854 }
3855 };
3856
3857 if (fr) {
3858 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
3859 } else {
3860 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
3861 }
3862 pars.ass_codec_list.codecElements[0].s0_7 := s8_s0;
3863 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
3864 pars.expect_mr_conf_ie := mr_conf;
3865 pars.expect_mr_s0_s7 := exp_s8_s0;
3866
3867 f_init(1, true);
3868 f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k();
Neels Hofmeyr21863562020-11-26 00:34:33 +00003869 f_vty_amr_start_mode_set(fr, start_mode);
Philipp Maierd0e64b02019-03-13 14:15:23 +01003870 f_sleep(1.0);
3871
3872 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
3873 vc_conn.done;
3874 f_allow_amr_rate_5_90k();
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003875 f_vty_amr_start_mode_restore(fr);
Philipp Maierd0e64b02019-03-13 14:15:23 +01003876}
3877
3878function f_TC_assignment_codec_amr_fail(boolean fr, bitstring s8_s0)
3879runs on test_CT {
3880
3881 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3882 var MSC_ConnHdlr vc_conn;
3883
3884 if (fr) {
3885 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
3886 } else {
3887 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
3888 }
3889 pars.ass_codec_list.codecElements[0].s0_7 := s8_s0;
3890 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
3891
3892 f_init(1, true);
3893 f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k();
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003894 f_vty_amr_start_mode_set(fr, "1");
Philipp Maierd0e64b02019-03-13 14:15:23 +01003895 f_sleep(1.0);
3896
3897 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fail), pars);
3898 vc_conn.done;
3899 f_allow_amr_rate_5_90k();
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003900 f_vty_amr_start_mode_restore(fr);
Philipp Maierd0e64b02019-03-13 14:15:23 +01003901}
3902
3903
3904/* Set S1, we expect an AMR multirate configuration IE with all four rates
3905 * set. */
3906testcase TC_assignment_codec_amr_f_S1() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003907 f_TC_assignment_codec_amr(true, '289520882208'O, '00000010'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003908 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003909}
3910
3911/* Set S1, we expect an AMR multirate configuration IE with the lower three
3912 * rates set. */
3913testcase TC_assignment_codec_amr_h_S1() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003914 f_TC_assignment_codec_amr(false, '2815208820'O, '00000010'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003915 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003916}
3917
3918/* Set S1 and two other rates, we expect an AMR MULTIRATE CONFIGURATION IE with
3919 * all four rates (and only S1 set in the ASSIGNMENT COMPLETE) */
3920testcase TC_assignment_codec_amr_f_S124() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003921 f_TC_assignment_codec_amr(true, '289520882208'O, '00010110'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003922 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003923}
3924
3925/* Set S1 and two other rates, we expect an AMR MULTIRATE CONFIGURATION IE with
3926 * all four rates (and only S1 set in the ASSIGNMENT COMPLETE) */
3927testcase TC_assignment_codec_amr_h_S124() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003928 f_TC_assignment_codec_amr(false, '2815208820'O, '00010110'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003929 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003930}
3931
3932/* The following block of tests selects more and more rates until all four
3933 * possible rates are in the active set (full rate) */
3934testcase TC_assignment_codec_amr_f_S0() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003935 f_TC_assignment_codec_amr(true, '2801'O, '00000001'B, '00000001'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003936 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003937}
3938
3939testcase TC_assignment_codec_amr_f_S02() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003940 f_TC_assignment_codec_amr(true, '28052080'O, '00000101'B, '00000101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003941 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003942}
3943
3944testcase TC_assignment_codec_amr_f_S024() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003945 f_TC_assignment_codec_amr(true, '2815208820'O, '00010101'B, '00010101'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_S0247() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003950 f_TC_assignment_codec_amr(true, '289520882208'O, '10010101'B, '10010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003951 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003952}
3953
3954/* The following block of tests selects more and more rates until all three
3955 * possible rates are in the active set (half rate) */
3956testcase TC_assignment_codec_amr_h_S0() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003957 f_TC_assignment_codec_amr(false, '2801'O, '00000001'B, '00000001'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003958 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003959}
3960
3961testcase TC_assignment_codec_amr_h_S02() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003962 f_TC_assignment_codec_amr(false, '28052080'O, '00000101'B, '00000101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003963 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003964}
3965
3966testcase TC_assignment_codec_amr_h_S024() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003967 f_TC_assignment_codec_amr(false, '2815208820'O, '00010101'B, '00010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003968 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003969}
3970
3971/* The following block tests what happens when the MSC does offer rate
3972 * configurations that are not supported by the BSC. Normally such situations
3973 * should not happen because the MSC gets informed by the BSC in advance via
3974 * the L3 COMPLETE message which rates are applicable. The MSC should not try
3975 * to offer rates that are not applicable anyway. */
3976
3977testcase TC_assignment_codec_amr_h_S0247() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003978 /* Try to include 12,2k in into the active set even though the channel
3979 * is half rate only. The BSC is expected to remove the 12,0k */
3980 f_TC_assignment_codec_amr(false, '2815208820'O, '10010101'B, '00010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003981 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003982}
3983
3984testcase TC_assignment_codec_amr_f_S01234567() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003985 /* See what happens when all rates are selected at once. Since then
3986 * Also S1 is selected, this setting will be prefered and we should
3987 * get 12.2k, 7,40k, 5,90k, and 4,75k in the active set. */
3988 f_TC_assignment_codec_amr(true, '289520882208'O, '11111111'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003989 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003990}
3991
3992testcase TC_assignment_codec_amr_f_S0234567() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003993 /* Same as above, but with S1 missing, the MSC is then expected to
3994 * select the currently supported rates, which are also 12.2k, 7,40k,
3995 * 5,90k, and 4,75k, into the active set. */
3996 f_TC_assignment_codec_amr(true, '289520882208'O, '11111101'B, '10010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003997 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003998}
3999
4000testcase TC_assignment_codec_amr_f_zero() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004001 /* Try to select no rates at all */
4002 f_TC_assignment_codec_amr_fail(true, '00000000'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004003 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004004}
4005
4006testcase TC_assignment_codec_amr_f_unsupp() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004007 /* Try to select only unsupported rates */
4008 f_TC_assignment_codec_amr_fail(true, '01101000'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004009 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004010}
4011
4012testcase TC_assignment_codec_amr_h_S7() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004013 /* Try to select 12,2k for half rate */
4014 f_TC_assignment_codec_amr_fail(false, '10000000'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004015 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004016}
4017
Neels Hofmeyr21863562020-11-26 00:34:33 +00004018testcase TC_assignment_codec_amr_f_start_mode_auto() runs on test_CT {
4019 f_TC_assignment_codec_amr(true, '209520882208'O, '11111111'B, '00000010'B,
4020 start_mode := "auto");
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01004021 f_shutdown_helper();
Neels Hofmeyr21863562020-11-26 00:34:33 +00004022}
4023
4024testcase TC_assignment_codec_amr_h_start_mode_auto() runs on test_CT {
4025 f_TC_assignment_codec_amr(false, '2015208820'O, '10010101'B, '00010101'B,
4026 start_mode := "auto");
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01004027 f_shutdown_helper();
Neels Hofmeyr21863562020-11-26 00:34:33 +00004028}
4029
Neels Hofmeyr3eb94562020-11-26 02:40:26 +00004030testcase TC_assignment_codec_amr_f_start_mode_4() runs on test_CT {
Vadim Yanitskiy7815f482021-01-03 17:07:37 +01004031 /* "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 +00004032 f_TC_assignment_codec_amr(true, '2b9520882208'O, '11111111'B, '00000010'B,
4033 start_mode := "4");
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01004034 f_shutdown_helper();
Neels Hofmeyr3eb94562020-11-26 02:40:26 +00004035}
4036
4037testcase TC_assignment_codec_amr_h_start_mode_4() runs on test_CT {
Vadim Yanitskiy7815f482021-01-03 17:07:37 +01004038 /* "amr tch-h modes 0 2 4" => total 3 modes and start mode 4 => '10'B on the wire */
4039 f_TC_assignment_codec_amr(false, '2a15208820'O, '10010101'B, '00010101'B,
Neels Hofmeyr3eb94562020-11-26 02:40:26 +00004040 start_mode := "4");
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01004041 f_shutdown_helper();
Neels Hofmeyr3eb94562020-11-26 02:40:26 +00004042}
4043
Philipp Maierac09bfc2019-01-08 13:41:39 +01004044private function f_disable_all_tch_f() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01004045 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 1 sub-slot 0 borken");
4046 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 2 sub-slot 0 borken");
4047 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 3 sub-slot 0 borken");
4048 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 4 sub-slot 0 borken");
Philipp Maierac09bfc2019-01-08 13:41:39 +01004049}
4050
4051private function f_disable_all_tch_h() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01004052 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 0 borken");
4053 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 1 borken");
Philipp Maierac09bfc2019-01-08 13:41:39 +01004054}
4055
4056private function f_enable_all_tch() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01004057 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 1 sub-slot 0 unused");
4058 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 2 sub-slot 0 unused");
4059 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 3 sub-slot 0 unused");
4060 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 4 sub-slot 0 unused");
4061 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 0 unused");
4062 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 1 unused");
Philipp Maierac09bfc2019-01-08 13:41:39 +01004063}
4064
4065/* Allow HR only */
4066private function f_TC_assignment_codec_xr_exhausted_req_hr(charstring id) runs on MSC_ConnHdlr {
4067 g_pars := f_gen_test_hdlr_pars();
4068 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4069 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4070 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4071 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '09'O;
4072 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '05'O;
4073 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
4074 f_establish_fully(ass_cmd, exp_compl);
4075}
4076
4077/* Allow FR only */
4078private function f_TC_assignment_codec_xr_exhausted_req_fr(charstring id) runs on MSC_ConnHdlr {
4079 g_pars := f_gen_test_hdlr_pars();
4080 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4081 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4082 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4083 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '08'O;
4084 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '01'O;
4085 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4086 f_establish_fully(ass_cmd, exp_compl);
4087}
4088
4089/* Allow HR only (expect assignment failure) */
4090private function f_TC_assignment_codec_xr_exhausted_req_hr_fail(charstring id) runs on MSC_ConnHdlr {
4091 g_pars := f_gen_test_hdlr_pars();
4092 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4093 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
4094 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4095 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '09'O;
4096 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '05'O;
4097 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
4098 f_establish_fully(ass_cmd, exp_fail);
4099}
4100
4101/* Allow FR only (expect assignment failure) */
4102private function f_TC_assignment_codec_xr_exhausted_req_fr_fail(charstring id) runs on MSC_ConnHdlr {
4103 g_pars := f_gen_test_hdlr_pars();
4104 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4105 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
4106 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4107 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '08'O;
4108 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '01'O;
4109 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4110 f_establish_fully(ass_cmd, exp_fail);
4111}
4112
4113/* Allow FR and HR, but prefer FR */
4114private function f_TC_assignment_codec_fr_exhausted_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
4115 g_pars := f_gen_test_hdlr_pars();
4116 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4117 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4118 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4119 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
4120 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
4121 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
4122 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
4123 f_establish_fully(ass_cmd, exp_compl);
4124}
4125
4126/* Allow FR and HR, but prefer HR */
4127private function f_TC_assignment_codec_fr_exhausted_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
4128 g_pars := f_gen_test_hdlr_pars();
4129 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4130 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4131 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4132 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
4133 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
4134 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
4135 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
4136 f_establish_fully(ass_cmd, exp_compl);
4137}
4138
4139/* Allow FR and HR, but prefer FR */
4140private function f_TC_assignment_codec_hr_exhausted_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
4141 g_pars := f_gen_test_hdlr_pars();
4142 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4143 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4144 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4145 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
4146 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
4147 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
4148 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
4149 f_establish_fully(ass_cmd, exp_compl);
4150}
4151
4152/* Allow FR and HR, but prefer HR */
4153private function f_TC_assignment_codec_hr_exhausted_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
4154 g_pars := f_gen_test_hdlr_pars();
4155 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4156 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4157 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4158 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
4159 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
4160 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
4161 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
4162 f_establish_fully(ass_cmd, exp_compl);
4163}
4164
4165/* Request a HR channel while all FR channels are exhausted, this is expected
4166 * to work without conflicts */
4167testcase TC_assignment_codec_fr_exhausted_req_hr() runs on test_CT {
4168 var MSC_ConnHdlr vc_conn;
4169 f_init(1, true);
4170 f_sleep(1.0);
4171 f_enable_all_tch();
4172 f_disable_all_tch_f();
4173 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_hr));
4174 vc_conn.done;
4175 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004176 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004177}
4178
4179/* Request a FR channel while all FR channels are exhausted, this is expected
4180 * to fail. */
4181testcase TC_assignment_codec_fr_exhausted_req_fr() runs on test_CT {
4182 var MSC_ConnHdlr vc_conn;
4183 f_init(1, true);
4184 f_sleep(1.0);
4185 f_enable_all_tch();
4186 f_disable_all_tch_f();
4187 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_fr_fail));
4188 vc_conn.done;
4189 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004190 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004191}
4192
4193/* Request a FR (prefered) or alternatively a HR channel while all FR channels
4194 * are exhausted, this is expected to be resolved by selecting a HR channel. */
4195testcase TC_assignment_codec_fr_exhausted_req_fr_hr() runs on test_CT {
4196 var MSC_ConnHdlr vc_conn;
4197 f_init(1, true);
4198 f_sleep(1.0);
4199 f_enable_all_tch();
4200 f_disable_all_tch_f();
4201 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fr_exhausted_req_fr_hr));
4202 vc_conn.done;
4203 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004204 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004205}
4206
4207/* Request a HR (prefered) or alternatively a FR channel while all FR channels
4208 * are exhausted, this is expected to work without conflicts. */
4209testcase TC_assignment_codec_fr_exhausted_req_hr_fr() runs on test_CT {
4210 var MSC_ConnHdlr vc_conn;
4211 f_init(1, true);
4212 f_sleep(1.0);
4213 f_enable_all_tch();
4214 f_disable_all_tch_f();
4215 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fr_exhausted_req_hr_fr));
4216 vc_conn.done;
4217 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004218 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004219}
4220
4221/* Request a FR channel while all HR channels are exhausted, this is expected
4222 * to work without conflicts */
4223testcase TC_assignment_codec_hr_exhausted_req_fr() runs on test_CT {
4224 var MSC_ConnHdlr vc_conn;
4225 f_init(1, true);
4226 f_sleep(1.0);
4227 f_enable_all_tch();
4228 f_disable_all_tch_h();
4229 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_fr));
4230 vc_conn.done;
4231 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004232 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004233}
4234
4235/* Request a HR channel while all HR channels are exhausted, this is expected
4236 * to fail. */
4237testcase TC_assignment_codec_hr_exhausted_req_hr() runs on test_CT {
4238 var MSC_ConnHdlr vc_conn;
4239 f_init(1, true);
4240 f_sleep(1.0);
4241 f_enable_all_tch();
4242 f_disable_all_tch_h();
4243 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_hr_fail));
4244 vc_conn.done;
4245 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004246 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004247}
4248
4249/* Request a HR (prefered) or alternatively a FR channel while all HR channels
4250 * are exhausted, this is expected to be resolved by selecting a FR channel. */
4251testcase TC_assignment_codec_hr_exhausted_req_hr_fr() runs on test_CT {
4252 var MSC_ConnHdlr vc_conn;
4253 f_init(1, true);
4254 f_sleep(1.0);
4255 f_enable_all_tch();
4256 f_disable_all_tch_h();
4257 vc_conn := f_start_handler(refers(f_TC_assignment_codec_hr_exhausted_req_hr_fr));
4258 vc_conn.done;
4259 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004260 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004261}
4262
4263/* Request a FR (prefered) or alternatively a HR channel while all HR channels
4264 * are exhausted, this is expected to work without conflicts. */
4265testcase TC_assignment_codec_hr_exhausted_req_fr_hr() runs on test_CT {
4266 var MSC_ConnHdlr vc_conn;
4267 f_init(1, true);
4268 f_sleep(1.0);
4269 f_enable_all_tch();
4270 f_disable_all_tch_h();
4271 vc_conn := f_start_handler(refers(f_TC_assignment_codec_hr_exhausted_req_fr_hr));
4272 vc_conn.done;
4273 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004274 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004275}
4276
4277/* Allow FR and HR, but prefer HR */
4278private function f_TC_assignment_codec_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
4279 g_pars := f_gen_test_hdlr_pars();
4280 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4281 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4282 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4283 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
4284 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
4285 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
4286 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
4287 f_establish_fully(ass_cmd, exp_compl);
4288}
4289
4290/* Allow FR and HR, but prefer FR */
4291private function f_TC_assignment_codec_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
4292 g_pars := f_gen_test_hdlr_pars();
4293 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4294 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4295 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4296 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
4297 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
4298 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
4299 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
4300 f_establish_fully(ass_cmd, exp_compl);
4301}
4302
4303/* Request a HR (prefered) or alternatively a FR channel, it is expected that
4304 * HR, which is the prefered type, is selected. */
4305testcase TC_assignment_codec_req_hr_fr() runs on test_CT {
4306 var MSC_ConnHdlr vc_conn;
4307 f_init(1, true);
4308 f_sleep(1.0);
4309 f_enable_all_tch();
4310 vc_conn := f_start_handler(refers(f_TC_assignment_codec_req_hr_fr));
4311 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004312 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004313}
4314
4315/* Request a FR (prefered) or alternatively a HR channel, it is expected that
4316 * FR, which is the prefered type, is selected. */
4317testcase TC_assignment_codec_req_fr_hr() runs on test_CT {
4318 var MSC_ConnHdlr vc_conn;
4319 f_init(1, true);
4320 f_sleep(1.0);
4321 f_enable_all_tch();
4322 vc_conn := f_start_handler(refers(f_TC_assignment_codec_req_fr_hr));
4323 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004324 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004325}
4326
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02004327testcase TC_assignment_osmux() runs on test_CT {
4328 var TestHdlrParams pars := f_gen_test_hdlr_pars();
4329 var MSC_ConnHdlr vc_conn;
4330
4331 /* See note above */
4332 var RSL_IE_Body mr_conf := {
4333 other := {
4334 len := 2,
4335 payload := '2804'O
4336 }
4337 };
4338
4339 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
4340 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
4341 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
4342 pars.expect_mr_conf_ie := mr_conf;
4343 pars.use_osmux := true;
4344
4345 f_init(1, true, true);
4346 f_sleep(1.0);
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00004347 f_vty_amr_start_mode_set(false, "1");
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02004348
4349 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
4350 vc_conn.done;
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00004351
4352 f_vty_amr_start_mode_restore(false);
Vadim Yanitskiy292e5962021-01-03 14:18:47 +01004353 f_shutdown_helper();
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02004354}
4355
Neels Hofmeyr92b12b72018-09-18 14:30:23 +02004356/* test the procedure of the MSC requesting a Classmark Update:
4357 * a) BSSMAP Classmark Request should result in RR CLASSMARK ENQUIRY,
4358 * b) L3 RR CLASSMARK CHANGE should result in BSSMAP CLASSMARK UPDATE */
Harald Welte898113b2018-01-31 18:32:21 +01004359private function f_tc_classmark(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004360 g_pars := f_gen_test_hdlr_pars();
4361
Harald Weltea0630032018-03-20 21:09:55 +01004362 f_create_chan_and_exp();
Harald Welte898113b2018-01-31 18:32:21 +01004363 /* we should now have a COMPL_L3 at the MSC */
4364 BSSAP.receive(tr_BSSMAP_ComplL3);
4365
Neels Hofmeyr92b12b72018-09-18 14:30:23 +02004366 BSSAP.send(ts_BSSMAP_ClassmarkRequest);
4367 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_CM_ENQUIRY));
4368
Harald Welte898113b2018-01-31 18:32:21 +01004369 f_rsl_send_l3(ts_RRM_CM_CHG(valueof(ts_CM2)));
4370 BSSAP.receive(tr_BSSMAP_ClassmarkUpd(?, omit));
4371 setverdict(pass);
4372}
4373testcase TC_classmark() runs on test_CT {
4374 var MSC_ConnHdlr vc_conn;
4375 f_init(1, true);
4376 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004377 vc_conn := f_start_handler(refers(f_tc_classmark));
Harald Welte898113b2018-01-31 18:32:21 +01004378 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004379 f_shutdown_helper();
Harald Welte898113b2018-01-31 18:32:21 +01004380}
4381
Harald Welteeddf0e92020-06-21 19:42:15 +02004382/* Send a CommonID from the simulated MSC and verify that the information is used to
4383 * fill BSC-internal data structures (specifically, bsc_subscr associated with subscr_conn) */
4384private function f_tc_common_id(charstring id) runs on MSC_ConnHdlr {
4385 g_pars := f_gen_test_hdlr_pars();
4386 f_MscConnHdlr_init_vty();
4387
4388 f_create_chan_and_exp();
4389 /* we should now have a COMPL_L3 at the MSC */
4390 BSSAP.receive(tr_BSSMAP_ComplL3);
4391
4392 /* Send CommonID */
4393 BSSAP.send(ts_BSSMAP_CommonId(g_pars.imsi));
4394
4395 /* Use VTY to verify that the IMSI of the subscr_conn is set */
4396 var charstring regex := "*(IMSI: " & hex2str(g_pars.imsi) & ")*";
4397 f_vty_transceive_match_regexp_retry(BSCVTY, "show conns", regex, 0, 4, 1.0);
4398
4399 setverdict(pass);
4400}
4401testcase TC_common_id() runs on test_CT {
4402 var MSC_ConnHdlr vc_conn;
4403 f_init(1, true);
4404 f_sleep(1.0);
4405 vc_conn := f_start_handler(refers(f_tc_common_id));
4406 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004407 f_shutdown_helper();
Harald Welteeddf0e92020-06-21 19:42:15 +02004408}
4409
Harald Weltee3bd6582018-01-31 22:51:25 +01004410private function f_est_single_l3(template PDU_ML3_MS_NW l3) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004411 g_pars := f_gen_test_hdlr_pars();
Harald Weltea0630032018-03-20 21:09:55 +01004412 f_create_chan_and_exp();
Harald Welte898113b2018-01-31 18:32:21 +01004413 /* we should now have a COMPL_L3 at the MSC */
4414 BSSAP.receive(tr_BSSMAP_ComplL3);
4415
Harald Weltee3bd6582018-01-31 22:51:25 +01004416 /* send the single message we want to send */
4417 f_rsl_send_l3(l3);
4418}
4419
4420private function f_bssap_expect_nothing(float sec := 5.00) runs on MSC_ConnHdlr {
4421 timer T := sec;
4422 var PDU_BSSAP bssap;
Harald Welte898113b2018-01-31 18:32:21 +01004423 T.start;
4424 alt {
Harald Weltee3bd6582018-01-31 22:51:25 +01004425 [] BSSAP.receive(PDU_BSSAP:?) -> value bssap {
4426 setverdict(fail, "Unexpected BSSMAP ", bssap);
Daniel Willmannafce8662018-07-06 23:11:32 +02004427 mtc.stop;
Harald Welte898113b2018-01-31 18:32:21 +01004428 }
4429 [] T.timeout {
4430 setverdict(pass);
4431 }
4432 }
4433}
4434
Harald Weltee3bd6582018-01-31 22:51:25 +01004435/* unsolicited ASSIGNMENT FAIL (without ASSIGN) from MS shouldn't bring BSC down */
4436private function f_tc_unsol_ass_fail(charstring id) runs on MSC_ConnHdlr {
4437 f_est_single_l3(ts_RRM_AssignmentFailure('00'O));
4438 f_bssap_expect_nothing();
4439}
Harald Welte898113b2018-01-31 18:32:21 +01004440testcase TC_unsol_ass_fail() runs on test_CT {
4441 var MSC_ConnHdlr vc_conn;
4442 f_init(1, true);
4443 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004444 vc_conn := f_start_handler(refers(f_tc_unsol_ass_fail));
Harald Welte898113b2018-01-31 18:32:21 +01004445 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004446 f_shutdown_helper();
Harald Welte898113b2018-01-31 18:32:21 +01004447}
Harald Welte552620d2017-12-16 23:21:36 +01004448
Harald Welteea99a002018-01-31 20:46:43 +01004449
4450/* unsolicited ASSIGNMENT COMPLETE (without ASSIGN) from MS shouldn't bring BSC down */
4451private function f_tc_unsol_ass_compl(charstring id) runs on MSC_ConnHdlr {
Harald Weltee3bd6582018-01-31 22:51:25 +01004452 f_est_single_l3(ts_RRM_AssignmentComplete('00'O));
4453 f_bssap_expect_nothing();
Harald Welteea99a002018-01-31 20:46:43 +01004454}
4455testcase TC_unsol_ass_compl() runs on test_CT {
4456 var MSC_ConnHdlr vc_conn;
4457 f_init(1, true);
4458 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004459 vc_conn := f_start_handler(refers(f_tc_unsol_ass_compl));
Harald Welteea99a002018-01-31 20:46:43 +01004460 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004461 f_shutdown_helper();
Harald Welteea99a002018-01-31 20:46:43 +01004462}
4463
4464
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004465/* unsolicited HANDOVER FAIL (without ASSIGN) from MS shouldn't bring BSC down */
4466private function f_tc_unsol_ho_fail(charstring id) runs on MSC_ConnHdlr {
Harald Weltee3bd6582018-01-31 22:51:25 +01004467 f_est_single_l3(ts_RRM_HandoverFailure('00'O));
4468 f_bssap_expect_nothing();
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004469}
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004470testcase TC_unsol_ho_fail() runs on test_CT {
4471 var MSC_ConnHdlr vc_conn;
4472 f_init(1, true);
4473 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004474 vc_conn := f_start_handler(refers(f_tc_unsol_ho_fail));
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004475 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004476 f_shutdown_helper();
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004477}
4478
4479
Harald Weltee3bd6582018-01-31 22:51:25 +01004480/* short message from MS should be ignored */
4481private function f_tc_err_82_short_msg(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004482 g_pars := f_gen_test_hdlr_pars();
Harald Weltea0630032018-03-20 21:09:55 +01004483 f_create_chan_and_exp();
Harald Weltee3bd6582018-01-31 22:51:25 +01004484 /* we should now have a COMPL_L3 at the MSC */
4485 BSSAP.receive(tr_BSSMAP_ComplL3);
4486
4487 /* send short message */
4488 RSL.send(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), ''O));
4489 f_bssap_expect_nothing();
4490}
4491testcase TC_err_82_short_msg() runs on test_CT {
4492 var MSC_ConnHdlr vc_conn;
4493 f_init(1, true);
4494 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004495 vc_conn := f_start_handler(refers(f_tc_err_82_short_msg));
Harald Weltee3bd6582018-01-31 22:51:25 +01004496 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004497 f_shutdown_helper();
Harald Weltee3bd6582018-01-31 22:51:25 +01004498}
4499
4500
Harald Weltee9e02e42018-01-31 23:36:25 +01004501/* 24.008 8.4 Unknown message must trigger RR STATUS */
4502private function f_tc_err_84_unknown_msg(charstring id) runs on MSC_ConnHdlr {
4503 f_est_single_l3(ts_RRM_UL_REL('00'O));
4504 timer T := 3.0
4505 alt {
4506 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_STATUS)) {
4507 setverdict(pass);
4508 }
4509 [] BSSAP.receive { setverdict(fail, "unexpected BSSAP"); }
Harald Welte458fd372018-03-21 11:26:23 +01004510 [] T.timeout { setverdict(fail, "Timeout waiting for RR STATUS"); }
Harald Weltee9e02e42018-01-31 23:36:25 +01004511 }
4512}
4513testcase TC_err_84_unknown_msg() runs on test_CT {
4514 var MSC_ConnHdlr vc_conn;
4515 f_init(1, true);
4516 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004517 vc_conn := f_start_handler(refers(f_tc_err_84_unknown_msg));
Harald Weltee9e02e42018-01-31 23:36:25 +01004518 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004519 f_shutdown_helper();
Harald Weltee9e02e42018-01-31 23:36:25 +01004520}
4521
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004522/***********************************************************************
4523 * Handover
4524 ***********************************************************************/
4525
Harald Welte94e0c342018-04-07 11:33:23 +02004526/* execute a "bts <0-255> trx <0-255> timeslot <0-7> " command on given Dchan */
4527private function f_vty_ts_action(charstring suffix, integer bts_nr, integer trx_nr, integer ts_nr)
4528runs on test_CT {
4529 var charstring cmd := "bts "&int2str(bts_nr)&" trx "&int2str(trx_nr)&
4530 " timeslot "&int2str(ts_nr)&" ";
4531 f_vty_transceive(BSCVTY, cmd & suffix);
4532}
4533
Harald Welte261af4b2018-02-12 21:20:39 +01004534/* 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 +07004535private function f_vty_ss_action(TELNETasp_PT pt, charstring suffix,
4536 uint8_t bts_nr, uint8_t trx_nr,
4537 in RslChannelNr chan_nr)
4538{
Harald Welte261af4b2018-02-12 21:20:39 +01004539 /* FIXME: resolve those from component-global state */
4540 var integer ts_nr := chan_nr.tn;
4541 var integer ss_nr;
4542 if (ischosen(chan_nr.u.ch0)) {
4543 ss_nr := 0;
4544 } else if (ischosen(chan_nr.u.lm)) {
4545 ss_nr := chan_nr.u.lm.sub_chan;
4546 } else if (ischosen(chan_nr.u.sdcch4)) {
4547 ss_nr := chan_nr.u.sdcch4.sub_chan;
4548 } else if (ischosen(chan_nr.u.sdcch8)) {
4549 ss_nr := chan_nr.u.sdcch8.sub_chan;
4550 } else {
4551 setverdict(fail, "Invalid ChanNr ", chan_nr);
Daniel Willmannafce8662018-07-06 23:11:32 +02004552 mtc.stop;
Harald Welte261af4b2018-02-12 21:20:39 +01004553 }
4554
4555 var charstring cmd := "bts "&int2str(bts_nr)&" trx "&int2str(trx_nr)&
4556 " timeslot "&int2str(ts_nr)&" sub-slot "&int2str(ss_nr)&" ";
Vadim Yanitskiy00070722020-09-02 17:27:57 +07004557 f_vty_transceive(pt, cmd & suffix);
Harald Welte261af4b2018-02-12 21:20:39 +01004558}
4559
Neels Hofmeyr91401012019-07-11 00:42:35 +02004560/* Even though the VTY command to trigger handover takes a new BTS number as argument, behind the scenes osmo-bsc always
4561 * translates that to a target ARFCN+BSIC first. See bsc_vty.c trigger_ho_or_as(), which puts the selected BTS' neighbor
4562 * ident key (ARFCN + BSIC) in the struct passed on to handover_request(). handover_start() then resolves that to a
4563 * viable actual neighbor cell. So from the internal osmo-bsc perspective, we always request handover to an ARFCN + BSIC
4564 * pair, not really to a specific BTS number. */
Vadim Yanitskiy00070722020-09-02 17:27:57 +07004565private function f_vty_handover(TELNETasp_PT pt, uint8_t bts_nr, uint8_t trx_nr,
4566 in RslChannelNr chan_nr, uint8_t new_bts_nr)
4567{
4568 f_vty_ss_action(pt, "handover " & int2str(new_bts_nr), bts_nr, trx_nr, chan_nr);
Harald Welte261af4b2018-02-12 21:20:39 +01004569}
4570
4571/* intra-BSC hand-over between BTS0 and BTS1 */
4572private function f_tc_ho_int(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004573 g_pars := f_gen_test_hdlr_pars();
Harald Welteed848512018-05-24 22:27:58 +02004574 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4575 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte261af4b2018-02-12 21:20:39 +01004576 const OCT8 kc := '0001020304050607'O;
4577
4578 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4579 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4580
Harald Weltea0630032018-03-20 21:09:55 +01004581 f_establish_fully(ass_cmd, exp_compl);
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004582 f_bts_0_cfg(BSCVTY, {"neighbor bts 1"});
Harald Welte261af4b2018-02-12 21:20:39 +01004583
4584 var HandoverState hs := {
4585 rr_ho_cmpl_seen := false,
4586 handover_done := false,
4587 old_chan_nr := -
4588 };
4589 /* issue hand-over command on VTY */
Vadim Yanitskiy00070722020-09-02 17:27:57 +07004590 f_vty_handover(BSCVTY, 0, 0, g_chan_nr, 1);
Harald Welte261af4b2018-02-12 21:20:39 +01004591 /* temporarily suspend DChan processing on BTS1 to avoid race with RSLEM_register */
4592 f_rslem_suspend(RSL1_PROC);
Philipp Maier3e2af5d2018-07-11 17:01:05 +02004593
4594 /* From the MGW perspective, a handover is is characterized by
4595 * performing one MDCX operation with the MGW. So we expect to see
4596 * one more MDCX during handover. */
4597 g_media.mgcp_conn[0].mdcx_seen_exp := g_media.mgcp_conn[0].crcx_seen_exp + 1;
4598
Harald Welte261af4b2018-02-12 21:20:39 +01004599 alt {
4600 [] as_handover(hs);
Harald Welte261af4b2018-02-12 21:20:39 +01004601 }
Philipp Maier3e2af5d2018-07-11 17:01:05 +02004602
Philipp Maier4dae0652018-11-12 12:03:26 +01004603 /* Since this is an internal handover we expect the BSC to inform the
4604 * MSC about the event */
4605 BSSAP.receive(tr_BSSMAP_HandoverPerformed);
4606
Philipp Maier3e2af5d2018-07-11 17:01:05 +02004607 /* Check the amount of MGCP transactions is still consistant with the
4608 * test expectation */
4609 f_check_mgcp_expectations()
Neels Hofmeyr861a4c12018-11-07 01:23:17 +01004610 f_sleep(0.5);
Harald Welte261af4b2018-02-12 21:20:39 +01004611}
4612
4613testcase TC_ho_int() runs on test_CT {
4614 var MSC_ConnHdlr vc_conn;
4615 f_init(2, true);
4616 f_sleep(1.0);
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004617
4618 f_ctrs_bsc_and_bts_init();
4619
Harald Welte8863fa12018-05-10 20:15:27 +02004620 vc_conn := f_start_handler(refers(f_tc_ho_int));
Harald Welte261af4b2018-02-12 21:20:39 +01004621 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004622
4623 /* from f_establish_fully() */
4624 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4625 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4626 /* from handover */
4627 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4628 f_ctrs_bsc_and_bts_add(0, "handover:completed");
4629 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
4630 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:completed");
4631 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004632 f_shutdown_helper();
Harald Welte261af4b2018-02-12 21:20:39 +01004633}
Harald Weltee9e02e42018-01-31 23:36:25 +01004634
Neels Hofmeyr5f144212020-11-03 15:41:58 +00004635/* intra-BSC hand-over with CONNection FAILure and cause Radio Link Failure: check RR release cause */
4636private function f_tc_ho_int_radio_link_failure(charstring id) runs on MSC_ConnHdlr {
4637 g_pars := f_gen_test_hdlr_pars();
4638 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4639 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4640 const OCT8 kc := '0001020304050607'O;
4641
4642 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4643 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4644
4645 f_establish_fully(ass_cmd, exp_compl);
4646 f_bts_0_cfg(BSCVTY, {"neighbor bts 1"});
4647
4648 var HandoverState hs := {
4649 rr_ho_cmpl_seen := false,
4650 handover_done := false,
4651 old_chan_nr := -
4652 };
4653 /* issue hand-over command on VTY */
4654 f_vty_handover(BSCVTY, 0, 0, g_chan_nr, 1);
4655 /* temporarily suspend DChan processing on BTS1 to avoid race with RSLEM_register */
4656 f_rslem_suspend(RSL1_PROC);
4657
4658 /* From the MGW perspective, a handover is is characterized by
4659 * performing one MDCX operation with the MGW. So we expect to see
4660 * one more MDCX during handover. */
4661 g_media.mgcp_conn[0].mdcx_seen_exp := g_media.mgcp_conn[0].crcx_seen_exp + 1;
4662
4663 var RSL_Message rsl;
4664 var PDU_ML3_NW_MS l3;
4665 var RslChannelNr new_chan_nr;
4666 var GsmArfcn arfcn;
4667 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr)) -> value rsl {
4668 l3 := dec_PDU_ML3_NW_MS(rsl.ies[2].body.l3_info.payload);
4669 if (not ischosen(l3.msgs.rrm.handoverCommand)) {
4670 setverdict(fail, "Expected handoverCommand");
4671 mtc.stop;
4672 }
4673 }
4674 f_ChDesc2RslChanNr(l3.msgs.rrm.handoverCommand.channelDescription2,
4675 new_chan_nr, arfcn);
4676
4677 f_rslem_register(0, new_chan_nr, RSL1_PROC);
4678
4679 /* resume processing of RSL DChan messages, which was temporarily suspended
4680 * before performing a hand-over */
4681 f_rslem_resume(RSL1_PROC);
4682 RSL1.receive(tr_RSL_IPA_CRCX(new_chan_nr));
4683
4684 f_sleep(1.0);
4685
4686 /* Handover fails because no HANDO DET appears on the new lchan,
4687 * and the old lchan reports a Radio Link Failure. */
4688 RSL.send(ts_RSL_CONN_FAIL_IND(g_chan_nr, RSL_ERR_RADIO_LINK_FAIL));
4689
4690 var PDU_BSSAP rx_clear_request;
4691 BSSAP.receive(tr_BSSMAP_ClearRequest) -> value rx_clear_request;
4692 var BssmapCause cause := bit2int(rx_clear_request.pdu.bssmap.clearRequest.cause.causeValue);
4693 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
4694
4695 var RR_Cause rr_cause := GSM48_RR_CAUSE_ABNORMAL_UNSPEC;
4696
4697 var MgcpCommand mgcp;
4698 interleave {
4699 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE(int2oct(enum2int(rr_cause), 1)))) {}
4700 [] RSL.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {}
4701 [] RSL.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
4702 RSL.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
4703 }
4704 [] RSL1.receive(tr_RSL_DEACT_SACCH(new_chan_nr)) {}
4705 [] RSL1.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
4706 RSL1.send(ts_RSL_RF_CHAN_REL_ACK(new_chan_nr));
4707 }
4708 [] BSSAP.receive(tr_BSSMAP_ClearComplete) {}
4709 }
4710
4711 f_sleep(0.5);
4712 setverdict(pass);
4713}
4714testcase TC_ho_int_radio_link_failure() runs on test_CT {
4715 var MSC_ConnHdlr vc_conn;
4716 f_init(2, true);
4717 f_sleep(1.0);
4718
4719 f_ctrs_bsc_and_bts_init();
4720
4721 vc_conn := f_start_handler(refers(f_tc_ho_int_radio_link_failure));
4722 vc_conn.done;
4723
4724 /* from f_establish_fully() */
4725 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4726 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4727 /* from handover */
4728 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4729 f_ctrs_bsc_and_bts_add(0, "handover:stopped");
4730 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
4731 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:stopped");
4732 f_ctrs_bsc_and_bts_verify();
4733 f_shutdown_helper();
4734}
4735
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004736/* Expecting MGCP to DLCX the endpoint's two connections: towards BTS and towards MSC */
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004737private function f_expect_dlcx_conns() runs on MSC_ConnHdlr {
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004738 var MgcpCommand mgcp;
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02004739 var template MgcpResponse mgcp_resp;
4740 var MGCP_RecvFrom mrf;
4741 var template MgcpMessage msg_resp;
4742 var template MgcpMessage msg_dlcx := {
4743 command := tr_DLCX()
4744 }
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004745
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02004746 if (g_pars.aoip) {
4747 MGCP.receive(tr_DLCX()) -> value mgcp {
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004748 log("Got first DLCX: ", mgcp);
4749 MGCP.send(ts_DLCX_ACK2(mgcp.line.trans_id));
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02004750 };
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004751
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004752 MGCP.receive(tr_DLCX()) -> value mgcp {
4753 log("Got second DLCX: ", mgcp);
4754 MGCP.send(ts_DLCX_ACK2(mgcp.line.trans_id));
4755 };
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02004756 } else {
4757 /* For SCCPLite, BSC doesn't handle the MSC-side */
4758 MGCP_MULTI.receive(tr_MGCP_RecvFrom_any(msg_dlcx)) -> value mrf {
4759 log("Got first DLCX: ", mrf.msg.command);
4760 msg_resp := {
4761 response := ts_DLCX_ACK2(mrf.msg.command.line.trans_id)
4762 }
4763 MGCP_MULTI.send(t_MGCP_SendToMrf(mrf, msg_resp));
4764 };
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004765 }
4766
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004767 BSSAP.receive(tr_BSSMAP_ClearComplete);
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004768}
4769
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02004770private function f_ho_out_of_this_bsc(template (omit) BSSMAP_oldToNewBSSIEs exp_oldToNewBSSIEs := omit) runs on MSC_ConnHdlr {
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004771
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004772 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004773 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
4774
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02004775 BSSAP.receive(tr_BSSMAP_HandoverRequired(exp_oldToNewBSSIEs));
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004776
4777 f_sleep(0.5);
4778 /* The MSC negotiates Handover Request and Handover Request Ack with
4779 * the other BSS and comes back with a BSSMAP Handover Command
4780 * containing an RR Handover Command coming from the target BSS... */
4781
4782 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
4783 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
4784 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
4785 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
4786 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
4787
4788 /* expect the Handover Command to go out on RR */
4789 var RSL_Message rsl_ho_cmd
4790 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
4791 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
4792 var RSL_IE_Body rsl_ho_cmd_l3;
4793 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
4794 log("RSL message contains no L3 Info IE, expected RR Handover Command");
4795 setverdict(fail);
4796 } else {
4797 log("Found L3 Info: ", rsl_ho_cmd_l3);
4798 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
4799 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
4800 setverdict(fail);
4801 } else {
4802 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
4803 setverdict(pass);
4804 }
4805 }
4806
4807 /* When the other BSS has reported a completed handover, this side is
4808 * torn down. */
4809
4810 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_HANDOVER_SUCCESSFUL;
4811 var BssmapCause cause := enum2int(cause_val);
4812 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
4813
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004814 f_expect_dlcx_conns();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004815 setverdict(pass);
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02004816}
4817
4818private function f_tc_ho_out_of_this_bsc(charstring id) runs on MSC_ConnHdlr {
4819 g_pars := f_gen_test_hdlr_pars();
4820 var PDU_BSSAP ass_req := f_gen_ass_req();
4821 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4822 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4823 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4824 f_establish_fully(ass_req, exp_compl);
4825
4826 f_ho_out_of_this_bsc();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004827 f_sleep(1.0);
4828}
4829testcase TC_ho_out_of_this_bsc() runs on test_CT {
4830 var MSC_ConnHdlr vc_conn;
4831
4832 f_init(1, true);
4833 f_sleep(1.0);
4834
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004835 f_ctrs_bsc_and_bts_init();
4836
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004837 vc_conn := f_start_handler(refers(f_tc_ho_out_of_this_bsc));
4838 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004839
4840 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4841 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4842 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4843 f_ctrs_bsc_and_bts_add(0, "handover:completed");
4844 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
4845 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:completed");
4846 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004847 f_shutdown_helper();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004848}
4849
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00004850private function f_mo_l3_transceive(RSL_DCHAN_PT rsl := RSL,
4851 template (value) RslLinkId link_id := ts_RslLinkID_DCCH(0),
Vadim Yanitskiy2ef6a2f2020-10-08 23:17:32 +07004852 template (present) OCT1 dlci := ?,
Vadim Yanitskiyb93aa432020-10-01 14:23:11 +07004853 octetstring l3 := '0123456789'O)
4854runs on MSC_ConnHdlr {
Neels Hofmeyr43654812020-09-25 01:35:35 +02004855 /* The old lchan and conn should still be active. See that arbitrary L3
4856 * is still going through. */
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00004857 rsl.send(ts_RSL_DATA_IND(g_chan_nr, link_id, l3));
Neels Hofmeyr43654812020-09-25 01:35:35 +02004858 var template PDU_BSSAP exp_data := {
4859 discriminator := '1'B,
4860 spare := '0000000'B,
Vadim Yanitskiyb93aa432020-10-01 14:23:11 +07004861 dlci := dlci,
4862 lengthIndicator := lengthof(l3),
Neels Hofmeyr43654812020-09-25 01:35:35 +02004863 pdu := {
4864 dtap := l3
4865 }
4866 };
4867 BSSAP.receive(exp_data);
4868 setverdict(pass);
4869}
4870
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00004871private function f_mt_l3_transceive(RSL_DCHAN_PT rsl := RSL,
4872 template (present) RslLinkId link_id := tr_RslLinkID_DCCH(0),
Vadim Yanitskiy0033a3b2020-10-01 22:21:16 +07004873 template (value) OCT1 dlci := '00'O,
4874 octetstring l3 := '0123456789'O)
4875runs on MSC_ConnHdlr {
4876 BSSAP.send(PDU_BSSAP:{
4877 discriminator := '1'B,
4878 spare := '0000000'B,
4879 dlci := dlci,
4880 lengthIndicator := lengthof(l3),
4881 pdu := {
4882 dtap := l3
4883 }
4884 });
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00004885 rsl.receive(tr_RSL_DATA_REQ(g_chan_nr, link_id, l3));
Vadim Yanitskiy0033a3b2020-10-01 22:21:16 +07004886 setverdict(pass);
4887}
4888
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004889/* BSC asks for inter-BSC HO, but the MSC decides that it won't happen and
4890 * simply never sends a BSSMAP Handover Command. */
4891private function f_tc_ho_out_fail_no_msc_response(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01004892 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004893
4894 var PDU_BSSAP ass_req := f_gen_ass_req();
4895 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4896 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4897 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4898 f_establish_fully(ass_req, exp_compl);
4899
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004900 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004901 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
4902
4903 BSSAP.receive(tr_BSSMAP_HandoverRequired);
4904
4905 /* osmo-bsc should time out 10 seconds after the handover started.
4906 * Let's give it a bit extra. */
4907 f_sleep(15.0);
4908
Vadim Yanitskiy74ae5eb2020-10-01 22:13:29 +07004909 f_mo_l3_transceive();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004910 f_sleep(1.0);
4911}
4912testcase TC_ho_out_fail_no_msc_response() runs on test_CT {
4913 var MSC_ConnHdlr vc_conn;
4914
4915 f_init(1, true);
4916 f_sleep(1.0);
4917
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004918 f_ctrs_bsc_and_bts_init();
4919
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004920 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_no_msc_response));
4921 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004922
4923 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4924 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4925 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4926 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
4927 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
4928 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
4929 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004930 f_shutdown_helper();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004931}
4932
4933/* BSC asks for inter-BSC HO, receives BSSMAP Handover Command, but MS reports
4934 * RR Handover Failure. */
4935private function f_tc_ho_out_fail_rr_ho_failure(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01004936 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004937
4938 var PDU_BSSAP ass_req := f_gen_ass_req();
4939 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4940 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4941 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4942 f_establish_fully(ass_req, exp_compl);
4943
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004944 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004945 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
4946
4947 BSSAP.receive(tr_BSSMAP_HandoverRequired);
4948
4949 f_sleep(0.5);
4950 /* The MSC negotiates Handover Request and Handover Request Ack with
4951 * the other BSS and comes back with a BSSMAP Handover Command
4952 * containing an RR Handover Command coming from the target BSS... */
4953
4954 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
4955 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
4956 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
4957 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
4958 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
4959
4960 /* expect the Handover Command to go out on RR */
4961 var RSL_Message rsl_ho_cmd
4962 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
4963 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
4964 var RSL_IE_Body rsl_ho_cmd_l3;
4965 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
4966 log("RSL message contains no L3 Info IE, expected RR Handover Command");
4967 setverdict(fail);
4968 } else {
4969 log("Found L3 Info: ", rsl_ho_cmd_l3);
4970 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
4971 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
4972 setverdict(fail);
4973 } else {
4974 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
4975 setverdict(pass);
4976 }
4977 }
4978
4979 f_sleep(0.2);
4980 f_rsl_send_l3(ts_RRM_HandoverFailure('00'O));
4981
4982 /* Should tell the MSC about the failure */
4983 BSSAP.receive(tr_BSSMAP_HandoverFailure);
4984
4985 f_sleep(1.0);
4986
Vadim Yanitskiy74ae5eb2020-10-01 22:13:29 +07004987 f_mo_l3_transceive();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004988 f_sleep(1.0);
4989
4990 setverdict(pass);
4991 f_sleep(1.0);
4992}
4993testcase TC_ho_out_fail_rr_ho_failure() runs on test_CT {
4994 var MSC_ConnHdlr vc_conn;
4995
4996 f_init(1, true);
4997 f_sleep(1.0);
4998
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004999 f_ctrs_bsc_and_bts_init();
5000
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005001 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_rr_ho_failure));
5002 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005003
5004 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5005 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5006 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5007 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5008 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
5009 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:failed");
5010 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005011 f_shutdown_helper();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005012}
5013
Neels Hofmeyr10f2bfa2019-07-09 19:33:29 +02005014/* BSC asks for inter-BSC-out HO, receives BSSMAP Handover Command, but then no reply is received about HO outcome
5015 * (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 +02005016 * and the lchan is released. */
5017private function f_tc_ho_out_fail_no_result_after_ho_cmd(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01005018 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005019
5020 var PDU_BSSAP ass_req := f_gen_ass_req();
5021 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
5022 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
5023 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
5024 f_establish_fully(ass_req, exp_compl);
5025
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005026 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005027 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
5028
5029 BSSAP.receive(tr_BSSMAP_HandoverRequired);
5030
5031 f_sleep(0.5);
5032 /* The MSC negotiates Handover Request and Handover Request Ack with
5033 * the other BSS and comes back with a BSSMAP Handover Command
5034 * containing an RR Handover Command coming from the target BSS... */
5035
5036 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
5037 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
5038 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
5039 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
5040 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
5041
5042 /* expect the Handover Command to go out on RR */
5043 var RSL_Message rsl_ho_cmd
5044 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
5045 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
5046 var RSL_IE_Body rsl_ho_cmd_l3;
5047 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
5048 log("RSL message contains no L3 Info IE, expected RR Handover Command");
5049 setverdict(fail);
5050 } else {
5051 log("Found L3 Info: ", rsl_ho_cmd_l3);
5052 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
5053 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
5054 setverdict(fail);
5055 } else {
5056 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
5057 setverdict(pass);
5058 }
5059 }
5060
Neels Hofmeyr10f2bfa2019-07-09 19:33:29 +02005061 /* We get neither success nor failure report from the remote BSS. Eventually T8 times out and we run into 3GPP
5062 * TS 48.008 3.1.5.3.3 "Abnormal Conditions": Clear Request should go to the MSC, and RR should be released
5063 * after Clear Command */
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005064
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005065 var PDU_BSSAP rx_clear_request;
Neels Hofmeyre1797aa2019-07-09 19:34:04 +02005066 BSSAP.receive(tr_BSSMAP_ClearRequest) -> value rx_clear_request;
5067 log("Got BSSMAP Clear Request");
5068 /* Instruct BSC to clear channel */
5069 var BssmapCause cause := bit2int(rx_clear_request.pdu.bssmap.clearRequest.cause.causeValue);
5070 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5071
5072 var MgcpCommand mgcp;
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005073 interleave {
Neels Hofmeyr861a4c12018-11-07 01:23:17 +01005074 [] RSL.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
5075 log("Got Deact SACCH");
5076 }
Harald Welte924b6ea2019-02-04 01:05:34 +01005077 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
Neels Hofmeyr211169d2018-11-07 00:37:29 +01005078 log("Got RR Release");
5079 }
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005080 [] RSL.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
5081 log("Got RF Chan Rel");
5082 RSL.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
5083 }
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005084 }
5085
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005086 f_expect_dlcx_conns();
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02005087
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005088 setverdict(pass);
5089 f_sleep(1.0);
5090}
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02005091testcase TC_ho_out_fail_no_result_after_ho_cmd() runs on test_CT {
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005092 var MSC_ConnHdlr vc_conn;
5093
5094 f_init(1, true);
5095 f_sleep(1.0);
5096
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005097 f_ctrs_bsc_and_bts_init();
5098
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02005099 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_no_result_after_ho_cmd));
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005100 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005101
5102 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5103 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5104 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5105 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
5106 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
5107 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
5108 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005109 f_shutdown_helper();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005110}
5111
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005112private function f_ho_into_this_bsc(charstring id, template (omit) BSSMAP_oldToNewBSSIEs oldToNewBSSIEs := omit) runs on MSC_ConnHdlr {
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005113 /* Hack: the proper way would be to wait for the BSSMAP Handover Request ACK and extract the
5114 * actual assigned chan_nr from its L3 (RR Handover Command) message. But osmo-bsc starts acting
5115 * on the lchan even before we get a chance to evaluate the BSSMAP Handover Request ACK. So we
5116 * need to assume that osmo-bsc will activate TS 1 and already set up this lchan's RSL emulation
5117 * before we get started. */
5118 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
5119 f_rslem_register(0, new_chan_nr);
5120 g_chan_nr := new_chan_nr;
5121 f_sleep(1.0);
5122
5123 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
5124 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5125 activate(as_Media());
5126
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005127 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02005128 f_gen_handover_req(aoip_tla := g_pars.host_aoip_tla,
5129 oldToNewBSSIEs := oldToNewBSSIEs)));
Harald Welte6811d102019-04-14 22:23:14 +02005130 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005131
5132 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
5133
5134 var PDU_BSSAP rx_bssap;
5135 var octetstring ho_command_str;
5136
5137 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
Pau Espin Pedrol76ba5412019-06-10 11:00:33 +02005138
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005139 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
5140 log("Received L3 Info in HO Request Ack: ", ho_command_str);
5141 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
5142 log("L3 Info in HO Request Ack is ", ho_command);
5143
5144 var GsmArfcn arfcn;
5145 var RslChannelNr actual_new_chan_nr;
5146 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
5147 actual_new_chan_nr, arfcn);
5148
5149 if (actual_new_chan_nr != new_chan_nr) {
5150 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
5151 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
5152 setverdict(fail);
5153 return;
5154 }
5155 log("Handover Command chan_nr is", actual_new_chan_nr);
5156
5157 /* Now the MSC forwards the RR Handover Command to the other BSC, which
5158 * tells the MS to handover to the new lchan. Here comes the new MS on
5159 * the new lchan with a Handover RACH: */
5160
5161 /* send handover detect */
5162
5163 RSL.send(ts_RSL_HANDO_DET(new_chan_nr));
5164
5165 BSSAP.receive(tr_BSSMAP_HandoverDetect);
5166
5167 /* send handover complete over the new channel */
5168
5169 var PDU_ML3_MS_NW l3_tx := valueof(ts_RRM_HandoverComplete('00'O));
5170 RSL.send(ts_RSL_EST_IND(new_chan_nr, valueof(ts_RslLinkID_DCCH(0)),
5171 enc_PDU_ML3_MS_NW(l3_tx)));
5172
5173 BSSAP.receive(tr_BSSMAP_HandoverComplete);
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005174 setverdict(pass);
5175}
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02005176
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005177private function f_tc_ho_into_this_bsc(charstring id) runs on MSC_ConnHdlr {
5178 var template PDU_ML3_NW_MS exp_rr_rel_tmpl := tr_RRM_RR_RELEASE;
5179 var template (omit) BSSMAP_oldToNewBSSIEs oldToNewBSSIEs := omit;
5180 if (not istemplatekind(g_pars.last_used_eutran_plmn, "omit")) {
5181 oldToNewBSSIEs := f_ts_BSSMAP_oldToNewBSSIEs(ts_BSSMAP_LastUsedEUTRANPLMNId(g_pars.last_used_eutran_plmn));
5182 exp_rr_rel_tmpl := tr_RRM_RR_RELEASE_CellSelectInd;
5183 }
5184 f_ho_into_this_bsc(id, oldToNewBSSIEs);
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02005185 f_perform_clear(RSL, exp_rr_rel_tmpl);
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005186 setverdict(pass);
5187}
Pau Espin Pedrol07866632020-09-03 19:10:55 +02005188function f_tc_ho_into_this_bsc_main(TestHdlrParams pars) runs on test_CT {
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005189 var MSC_ConnHdlr vc_conn;
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005190
5191 f_init(1, true);
5192 f_sleep(1.0);
5193
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005194 f_ctrs_bsc_and_bts_init();
5195
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005196 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5197 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005198
5199 vc_conn := f_start_handler(refers(f_tc_ho_into_this_bsc), pars);
5200 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005201
5202 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5203 f_ctrs_bsc_and_bts_add(0, "handover:completed");
5204 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
5205 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:completed");
5206 f_ctrs_bsc_and_bts_verify();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005207}
5208
Pau Espin Pedrol07866632020-09-03 19:10:55 +02005209testcase TC_ho_into_this_bsc() runs on test_CT {
5210 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5211 f_tc_ho_into_this_bsc_main(pars);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005212 f_shutdown_helper();
Pau Espin Pedrol07866632020-09-03 19:10:55 +02005213}
5214
5215testcase TC_ho_into_this_bsc_tla_v6() runs on test_CT {
5216 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5217 pars.host_aoip_tla := "::6";
5218 f_tc_ho_into_this_bsc_main(pars);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005219 f_shutdown_helper();
Pau Espin Pedrol07866632020-09-03 19:10:55 +02005220}
5221
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02005222/* Similar to TC_ho_into_this_bsc, but when in SRVCC, HO Req contains "Old BSS
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005223 to New BSS Information" IE with "Last Used E-UTRAN PLMN Id", which, when the
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02005224 channel is later released (RR CHannel Release), should trigger inclusion of
5225 IE "Cell Selection Indicator after Release of all TCH and SDCCH" with E-UTRAN
5226 neighbors. */
5227testcase TC_srvcc_eutran_to_geran() runs on test_CT {
5228 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5229 pars.last_used_eutran_plmn := '323454'O;
5230 f_tc_ho_into_this_bsc_main(pars);
5231 f_shutdown_helper();
5232}
5233
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005234private function f_tc_srvcc_eutran_to_geran_ho_out(charstring id) runs on MSC_ConnHdlr {
5235 var template (omit) BSSMAP_oldToNewBSSIEs oldToNewBSSIEs;
5236 oldToNewBSSIEs := f_ts_BSSMAP_oldToNewBSSIEs(ts_BSSMAP_LastUsedEUTRANPLMNId(g_pars.last_used_eutran_plmn));
5237 f_ho_into_this_bsc(id, oldToNewBSSIEs);
5238 f_ho_out_of_this_bsc(oldToNewBSSIEs);
5239 setverdict(pass);
5240}
5241/* First, HO into BSC from EUTRAN (SRVCC): HO Request contains "Old BSS to New
5242 BSS Information" IE with "Last Used E-UTRAN PLMN Id".
5243 Second, HO to another BSC: HO Required contains "Old BSS to New BSS Information"
5244 IE with "Last Used E-UTRAN PLMN Id" from first step. */
5245testcase TC_srvcc_eutran_to_geran_ho_out() runs on test_CT {
5246 var MSC_ConnHdlr vc_conn;
5247 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5248
5249 f_init(1, true);
5250 f_sleep(1.0);
5251
5252 f_ctrs_bsc_and_bts_init();
5253
5254 pars.last_used_eutran_plmn := '323454'O;
5255 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5256 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
5257
5258 vc_conn := f_start_handler(refers(f_tc_srvcc_eutran_to_geran_ho_out), pars);
5259 vc_conn.done;
5260
5261 f_ctrs_bsc_and_bts_add(0, "handover:attempted", 2);
5262 f_ctrs_bsc_and_bts_add(0, "handover:completed", 2);
5263 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted", 1);
5264 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:completed", 1);
5265 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted", 1);
5266 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:completed", 1);
5267 f_ctrs_bsc_and_bts_verify();
5268 f_shutdown_helper();
5269}
5270
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005271private function f_tc_ho_in_fail_msc_clears(charstring id) runs on MSC_ConnHdlr {
5272 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
5273 f_rslem_register(0, new_chan_nr);
5274 g_chan_nr := new_chan_nr;
5275 f_sleep(1.0);
5276
5277 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
5278 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5279 activate(as_Media());
5280
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005281 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005282 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02005283 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005284
5285 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
5286
5287 var PDU_BSSAP rx_bssap;
5288 var octetstring ho_command_str;
5289
5290 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
5291
5292 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
5293 log("Received L3 Info in HO Request Ack: ", ho_command_str);
5294 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
5295 log("L3 Info in HO Request Ack is ", ho_command);
5296
5297 var GsmArfcn arfcn;
5298 var RslChannelNr actual_new_chan_nr;
5299 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
5300 actual_new_chan_nr, arfcn);
5301
5302 if (actual_new_chan_nr != new_chan_nr) {
5303 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
5304 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
5305 setverdict(fail);
5306 return;
5307 }
5308 log("Handover Command chan_nr is", actual_new_chan_nr);
5309
Neels Hofmeyr61ca08d2019-05-06 23:52:22 +02005310 /* For deterministic test results, give some time for the MGW endpoint to be configured */
5311 f_sleep(1.0);
5312
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005313 /* Now the MSC forwards the RR Handover Command to the other BSC, which
5314 * tells the MS to handover to the new lchan. In this case, the MS
5315 * reports a Handover Failure to the old BSS, which forwards a BSSMAP
5316 * Handover Failure to the MSC. The procedure according to 3GPP TS
5317 * 48.008 3.1.5.3.2 "Handover Failure" is then that the MSC sends a
5318 * BSSMAP Clear Command: */
5319
5320 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
5321 var BssmapCause cause := enum2int(cause_val);
5322 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5323
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005324 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005325 setverdict(pass);
5326 f_sleep(1.0);
5327
5328 setverdict(pass);
5329}
5330testcase TC_ho_in_fail_msc_clears() runs on test_CT {
5331 var MSC_ConnHdlr vc_conn;
5332 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5333
5334 f_init(1, true);
5335 f_sleep(1.0);
5336
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005337 f_ctrs_bsc_and_bts_init();
5338
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005339 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5340 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005341
5342 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_msc_clears), pars);
5343 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005344
5345 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5346 f_ctrs_bsc_and_bts_add(0, "handover:stopped");
5347 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
5348 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:stopped");
5349 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005350 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005351}
5352
5353private function f_tc_ho_in_fail_msc_clears_after_ho_detect(charstring id) runs on MSC_ConnHdlr {
5354 /* Hack: the proper way would be to wait for the BSSMAP Handover Request ACK and extract the
5355 * actual assigned chan_nr from its L3 (RR Handover Command) message. But osmo-bsc starts acting
5356 * on the lchan even before we get a chance to evaluate the BSSMAP Handover Request ACK. So we
5357 * need to assume that osmo-bsc will activate TS 1 and already set up this lchan's RSL emulation
5358 * before we get started. */
5359 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
5360 f_rslem_register(0, new_chan_nr);
5361 g_chan_nr := new_chan_nr;
5362 f_sleep(1.0);
5363
5364 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
5365 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5366 activate(as_Media());
5367
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005368 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005369 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02005370 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005371
5372 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
5373
5374 var PDU_BSSAP rx_bssap;
5375 var octetstring ho_command_str;
5376
5377 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
5378
5379 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
5380 log("Received L3 Info in HO Request Ack: ", ho_command_str);
5381 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
5382 log("L3 Info in HO Request Ack is ", ho_command);
5383
5384 var GsmArfcn arfcn;
5385 var RslChannelNr actual_new_chan_nr;
5386 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
5387 actual_new_chan_nr, arfcn);
5388
5389 if (actual_new_chan_nr != new_chan_nr) {
5390 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
5391 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
5392 setverdict(fail);
5393 return;
5394 }
5395 log("Handover Command chan_nr is", actual_new_chan_nr);
5396
5397 /* Now the MSC forwards the RR Handover Command to the other BSC, which
5398 * tells the MS to handover to the new lchan. Here comes the new MS on
5399 * the new lchan with a Handover RACH: */
5400
5401 /* send handover detect */
5402
5403 RSL.send(ts_RSL_HANDO_DET(new_chan_nr));
5404
5405 BSSAP.receive(tr_BSSMAP_HandoverDetect);
5406
5407 /* The MSC chooses to clear the connection now, maybe we got the
5408 * Handover RACH on the new cell but the MS still signaled Handover
5409 * Failure to the old BSS? */
5410
5411 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
5412 var BssmapCause cause := enum2int(cause_val);
5413 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5414
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005415 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005416 f_sleep(1.0);
5417}
5418testcase TC_ho_in_fail_msc_clears_after_ho_detect() runs on test_CT {
5419 var MSC_ConnHdlr vc_conn;
5420 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5421
5422 f_init(1, true);
5423 f_sleep(1.0);
5424
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005425 f_ctrs_bsc_and_bts_init();
5426
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005427 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5428 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005429
5430 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_msc_clears_after_ho_detect), pars);
5431 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005432
5433 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5434 f_ctrs_bsc_and_bts_add(0, "handover:stopped");
5435 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
5436 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:stopped");
5437 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005438 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005439}
5440
5441/* The new BSS's lchan times out before the MSC decides that handover failed. */
5442private function f_tc_ho_in_fail_no_detect(charstring id) runs on MSC_ConnHdlr {
5443 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
5444 f_rslem_register(0, new_chan_nr);
5445 g_chan_nr := new_chan_nr;
5446 f_sleep(1.0);
5447
5448 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
5449 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5450 activate(as_Media());
5451
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005452 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005453 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02005454 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005455
5456 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
5457
5458 var PDU_BSSAP rx_bssap;
5459 var octetstring ho_command_str;
5460
5461 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
5462
5463 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
5464 log("Received L3 Info in HO Request Ack: ", ho_command_str);
5465 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
5466 log("L3 Info in HO Request Ack is ", ho_command);
5467
5468 var GsmArfcn arfcn;
5469 var RslChannelNr actual_new_chan_nr;
5470 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
5471 actual_new_chan_nr, arfcn);
5472
5473 if (actual_new_chan_nr != new_chan_nr) {
5474 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
5475 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
5476 setverdict(fail);
5477 return;
5478 }
5479 log("Handover Command chan_nr is", actual_new_chan_nr);
5480
5481 /* Now the MSC forwards the RR Handover Command to the other BSC, which
5482 * tells the MS to handover to the new lchan. But the MS never shows up
5483 * on the new lchan. */
5484
5485 BSSAP.receive(tr_BSSMAP_HandoverFailure);
5486
5487 /* Did osmo-bsc also send a Clear Request? */
5488 timer T := 0.5;
5489 T.start;
5490 alt {
5491 [] BSSAP.receive(tr_BSSMAP_ClearRequest);
5492 [] T.timeout { }
5493 }
5494
5495 /* MSC plays along with a Clear Command (no matter whether osmo-bsc
5496 * asked for it, this is a Handover Failure after all). */
5497
5498 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
5499 var BssmapCause cause := enum2int(cause_val);
5500 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5501
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005502 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005503 f_sleep(1.0);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005504}
5505testcase TC_ho_in_fail_no_detect() runs on test_CT {
5506 var MSC_ConnHdlr vc_conn;
5507 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5508
5509 f_init(1, true);
5510 f_sleep(1.0);
5511
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005512 f_ctrs_bsc_and_bts_init();
5513
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005514 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5515 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005516
5517 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_no_detect), pars);
5518 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005519
5520 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5521 f_ctrs_bsc_and_bts_add(0, "handover:error");
5522 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
5523 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:error");
5524 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005525 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005526}
5527
5528/* Same as f_tc_ho_in_fail_no_detect, but MSC fails to send a Clear Command */
5529private function f_tc_ho_in_fail_no_detect2(charstring id) runs on MSC_ConnHdlr {
5530 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
5531 f_rslem_register(0, new_chan_nr);
5532 g_chan_nr := new_chan_nr;
5533 f_sleep(1.0);
5534
5535 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
5536 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5537 activate(as_Media());
5538
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005539 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005540 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02005541 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005542
5543 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
5544
5545 var PDU_BSSAP rx_bssap;
5546 var octetstring ho_command_str;
5547
5548 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
5549
5550 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
5551 log("Received L3 Info in HO Request Ack: ", ho_command_str);
5552 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
5553 log("L3 Info in HO Request Ack is ", ho_command);
5554
5555 var GsmArfcn arfcn;
5556 var RslChannelNr actual_new_chan_nr;
5557 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
5558 actual_new_chan_nr, arfcn);
5559
5560 if (actual_new_chan_nr != new_chan_nr) {
5561 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
5562 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
5563 setverdict(fail);
5564 return;
5565 }
5566 log("Handover Command chan_nr is", actual_new_chan_nr);
5567
5568 /* Now the MSC forwards the RR Handover Command to the other BSC, which
5569 * tells the MS to handover to the new lchan. But the MS never shows up
5570 * on the new lchan. */
5571
5572 BSSAP.receive(tr_BSSMAP_HandoverFailure);
5573
5574 /* MSC plays dumb and sends no Clear Command */
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005575 var PDU_BSSAP rx_clear_request;
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02005576
5577 BSSAP.receive(tr_BSSMAP_ClearRequest) -> value rx_clear_request {
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005578 var BssmapCause cause := bit2int(rx_clear_request.pdu.bssmap.clearRequest.cause.causeValue);
5579 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5580 };
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005581 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005582 f_sleep(1.0);
5583}
5584testcase TC_ho_in_fail_no_detect2() runs on test_CT {
5585 var MSC_ConnHdlr vc_conn;
5586 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5587
5588 f_init(1, true);
5589 f_sleep(1.0);
5590
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005591 f_ctrs_bsc_and_bts_init();
5592
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005593 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5594 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005595
5596 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_no_detect2), pars);
5597 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005598
5599 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5600 f_ctrs_bsc_and_bts_add(0, "handover:error");
5601 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
5602 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:error");
5603 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005604 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005605}
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005606
Neels Hofmeyr91401012019-07-11 00:42:35 +02005607type record of charstring Commands;
5608
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005609private function f_bts_0_cfg(TELNETasp_PT pt, Commands cmds := {})
Neels Hofmeyr91401012019-07-11 00:42:35 +02005610{
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005611 f_vty_enter_cfg_bts(pt, 0);
Neels Hofmeyr91401012019-07-11 00:42:35 +02005612 for (var integer i := 0; i < sizeof(cmds); i := i+1) {
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005613 f_vty_transceive(pt, cmds[i]);
Neels Hofmeyr91401012019-07-11 00:42:35 +02005614 }
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005615 f_vty_transceive(pt, "end");
Neels Hofmeyr91401012019-07-11 00:42:35 +02005616}
5617
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01005618private function f_cs7_inst_0_cfg(TELNETasp_PT pt, Commands cmds := {})
5619{
5620 f_vty_enter_cfg_cs7_inst(pt, 0);
5621 for (var integer i := 0; i < sizeof(cmds); i := i+1) {
5622 f_vty_transceive(pt, cmds[i]);
5623 }
5624 f_vty_transceive(pt, "end");
5625}
5626
Neels Hofmeyr91401012019-07-11 00:42:35 +02005627private function f_probe_for_handover(charstring log_label,
5628 charstring log_descr,
5629 charstring handover_vty_cmd,
5630 boolean expect_handover,
5631 boolean is_inter_bsc_handover := false)
5632runs on MSC_ConnHdlr
5633{
Neels Hofmeyrb3fc8982020-05-11 00:16:42 +02005634 /* We're going to thwart any and all handover attempts, just be ready to handle (and ignore) handover target
5635 * lchans to be established on bts 1 or bts 2. */
5636 f_rslem_suspend(RSL1_PROC);
5637 f_rslem_suspend(RSL2_PROC);
5638
Neels Hofmeyr91401012019-07-11 00:42:35 +02005639 var RSL_Message rsl;
5640
5641 var charstring log_msg := " (expecting handover)"
5642 if (not expect_handover) {
5643 log_msg := " (expecting NO handover)";
5644 }
5645 log("f_probe_for_handover starting: " & log_label & ": " & log_descr & log_msg);
5646 f_vty_transceive(BSCVTY, handover_vty_cmd);
5647
Neels Hofmeyr91401012019-07-11 00:42:35 +02005648 timer T := 2.0;
5649 T.start;
5650
5651 alt {
5652 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr)) -> value rsl {
5653 var PDU_ML3_NW_MS l3 := dec_PDU_ML3_NW_MS(rsl.ies[2].body.l3_info.payload);
5654 log("Rx L3 from net: ", l3);
5655 if (ischosen(l3.msgs.rrm.handoverCommand)) {
5656 var RslChannelNr new_chan_nr;
5657 var GsmArfcn arfcn;
5658 f_ChDesc2RslChanNr(l3.msgs.rrm.handoverCommand.channelDescription2,
5659 new_chan_nr, arfcn);
5660 log("Handover to new chan ", new_chan_nr, " on ARFCN ", arfcn);
5661 log(l3.msgs.rrm.handoverCommand);
5662
5663 /* Need to register for new lchan on new BTS -- it's either bts 1 or bts 2. It doesn't really
5664 * matter on which BTS it really is, we're not going to follow through an entire handover
5665 * anyway. */
5666 f_rslem_register(0, new_chan_nr, RSL1_PROC);
5667 f_rslem_resume(RSL1_PROC);
5668 f_rslem_register(0, new_chan_nr, RSL2_PROC);
5669 f_rslem_resume(RSL2_PROC);
5670
5671 if (expect_handover and not is_inter_bsc_handover) {
5672 setverdict(pass);
5673 log("f_probe_for_handover(" & log_label & "): Got RSL Handover Command as expected.");
5674 } else {
5675 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected none, but got RSL Handover Command. "
5676 & log_label & ": " & log_descr);
5677 }
5678
5679 log("f_probe_for_handover(" & log_label & "): Ending the test: Handover Failure stops the procedure.");
5680 /* osmo-bsc has triggered Handover. That's all we need to know for this test, reply with
5681 * Handover Failure. */
5682 f_rsl_send_l3(ts_RRM_HandoverFailure('00'O));
5683
5684 /* target BTS is told to release lchan again; don't care which BTS nor what messages. */
5685 f_sleep(0.5);
5686 RSL1.clear;
5687 RSL2.clear;
5688 log("f_probe_for_handover(" & log_label & "): done (got RSL Handover Command)");
5689 break;
5690 } else {
5691 repeat;
5692 }
5693 }
5694 [] BSSAP.receive(tr_BSSMAP_HandoverRequired) {
5695 if (expect_handover and is_inter_bsc_handover) {
5696 setverdict(pass);
5697 log("f_probe_for_handover(" & log_label & "): Got BSSMAP Handover Required as expected.");
5698 } else {
5699 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected none, but got BSSMAP Handover Required. "
5700 & log_label & ": " & log_descr);
5701 }
5702
5703 log("f_probe_for_handover(" & log_label & "): done (got BSSMAP Handover Required)");
5704
5705 /* Note: f_tc_ho_neighbor_config_start() sets T7, the timeout for BSSMAP Handover Required, to
5706 * 1 second. There is no legal way to quickly abort a handover after a BSSMAP Handover Required,
5707 * setting a short timeout and waiting is the only way. */
5708 log("f_probe_for_handover(" & log_label & "): waiting for inter-BSC HO to time out...");
5709 f_sleep(1.5);
5710 log("f_probe_for_handover(" & log_label & "): ...done");
5711
5712 break;
5713 }
5714 [] T.timeout {
5715 if (expect_handover) {
5716 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected Handover, but got none. "
5717 & log_label & ": " & log_descr);
5718 } else {
5719 setverdict(pass);
5720 log("f_probe_for_handover(" & log_label & "): Got no Handover, as expected.");
5721 }
5722 log("f_probe_for_handover(" & log_label & "): done (got no Handover)");
5723 break;
5724 }
5725 }
5726
5727 f_rslem_resume(RSL1_PROC);
5728 f_rslem_resume(RSL2_PROC);
5729 f_sleep(3.0);
5730 RSL.clear;
5731
5732 log("f_probe_for_handover(" & log_label & "): done clearing");
5733}
5734
5735/* Test the effect of various neighbor configuration scenarios:
5736 *
5737 * To avoid complexity, block off any actual handover operation, and always remain on the lchan at bts 0.
5738 * Reconfigure the neighbors for bts 0, trigger a Handover, and probe whether osmo-bsc does or doesn't start HO.
5739 */
5740private function f_tc_ho_neighbor_config_start() runs on MSC_ConnHdlr {
5741 g_pars := f_gen_test_hdlr_pars();
5742 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
5743 var PDU_BSSAP ass_cmd := f_gen_ass_req();
5744 const OCT8 kc := '0001020304050607'O;
5745
5746 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
5747 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
5748
5749 /* Establish lchan at bts 0 */
5750 f_establish_fully(ass_cmd, exp_compl);
5751
5752 /* Shorten the inter-BSC Handover timeout, to not wait so long for inter-BSC Handovers */
5753 f_vty_enter_cfg_network(BSCVTY);
5754 f_vty_transceive(BSCVTY, "timer T7 1");
5755 f_vty_transceive(BSCVTY, "end");
5756}
5757
5758private function f_tc_ho_neighbor_config_1(charstring id) runs on MSC_ConnHdlr {
5759 f_tc_ho_neighbor_config_start();
5760
5761 /*
5762 * bts 0 ARFCN 871 BSIC 10
5763 * bts 1 ARFCN 871 BSIC 11
5764 * bts 2 ARFCN 871 BSIC 12
5765 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5766 */
5767
5768 log("f_tc_ho_neighbor_config: 1. No 'neighbor' config");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005769 f_bts_0_cfg(BSCVTY, {"no neighbors"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005770 f_probe_for_handover("1.a", "HO to bts 1 works, implicitly listed as neighbor (legacy behavior when none are configured)",
5771 "handover any to arfcn 871 bsic 11",
5772 true);
5773
5774 f_probe_for_handover("1.b", "HO to unknown cell does not start",
5775 "handover any to arfcn 13 bsic 39",
5776 false);
5777
5778 f_probe_for_handover("1.c", "HO to 871-12 is ambiguous = error",
5779 "handover any to arfcn 871 bsic 12",
5780 false);
5781
5782 f_probe_for_handover("1.d", "HO to 871-11 still works (verify that this test properly cleans up)",
5783 "handover any to arfcn 871 bsic 11",
5784 true);
5785}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005786testcase TC_ho_neighbor_config_1() runs on test_CT {
5787 var MSC_ConnHdlr vc_conn;
5788 f_init(3, true, guard_timeout := 60.0);
5789 f_sleep(1.0);
5790 f_ctrs_bsc_and_bts_init();
5791 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_1));
5792 vc_conn.done;
5793
5794 /* f_tc_ho_neighbor_config_start() */
5795 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5796 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5797
5798 /* 1.a */
5799 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
5800 * handover quickly by sending a Handover Failure message. */
5801 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5802 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5803 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5804 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
5805
5806 /* 1.b */
5807 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5808 f_ctrs_bsc_and_bts_add(0, "handover:error");
5809
5810 /* 1.c */
5811 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5812 f_ctrs_bsc_and_bts_add(0, "handover:error");
5813
5814 /* 1.d */
5815 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5816 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5817 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5818 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
5819
5820 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005821 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005822}
5823
Neels Hofmeyr91401012019-07-11 00:42:35 +02005824private function f_tc_ho_neighbor_config_2(charstring id) runs on MSC_ConnHdlr {
5825 f_tc_ho_neighbor_config_start();
5826
5827 /*
5828 * bts 0 ARFCN 871 BSIC 10
5829 * bts 1 ARFCN 871 BSIC 11
5830 * bts 2 ARFCN 871 BSIC 12
5831 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5832 */
5833
5834 log("f_tc_ho_neighbor_config: 2. explicit local neighbor: 'neighbor bts 1'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005835 f_bts_0_cfg(BSCVTY, {"neighbor bts 1"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005836 f_sleep(0.5);
5837
5838 f_probe_for_handover("2.a", "HO to bts 1 works, explicitly listed as neighbor",
5839 "handover any to arfcn 871 bsic 11",
5840 true);
5841
5842 f_probe_for_handover("2.b", "HO to bts 2 doesn't work, not listed as neighbor",
5843 "handover any to arfcn 871 bsic 12",
5844 false);
5845}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005846testcase TC_ho_neighbor_config_2() runs on test_CT {
5847 var MSC_ConnHdlr vc_conn;
5848 f_init(3, true, guard_timeout := 50.0);
5849 f_sleep(1.0);
5850 f_ctrs_bsc_and_bts_init();
5851 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_2));
5852 vc_conn.done;
5853
5854 /* f_tc_ho_neighbor_config_start() */
5855 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5856 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5857
5858 /* 2.a */
5859 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
5860 * handover quickly by sending a Handover Failure message. */
5861 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5862 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5863 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5864 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
5865
5866 /* 2.b */
5867 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5868 f_ctrs_bsc_and_bts_add(0, "handover:error");
5869
5870 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005871 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005872}
5873
Neels Hofmeyr91401012019-07-11 00:42:35 +02005874private function f_tc_ho_neighbor_config_3(charstring id) runs on MSC_ConnHdlr {
5875 f_tc_ho_neighbor_config_start();
5876
5877 /*
5878 * bts 0 ARFCN 871 BSIC 10
5879 * bts 1 ARFCN 871 BSIC 11
5880 * bts 2 ARFCN 871 BSIC 12
5881 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5882 */
5883
5884 log("f_tc_ho_neighbor_config: 3. explicit local neighbor: 'neighbor bts 2'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005885 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor bts 2"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005886 f_sleep(0.5);
5887
5888 f_probe_for_handover("3.a", "HO to bts 1 doesn't work, not listed as neighbor",
5889 "handover any to arfcn 871 bsic 11",
5890 false);
5891 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",
5892 "handover any to arfcn 871 bsic 12",
5893 true);
5894}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005895testcase TC_ho_neighbor_config_3() runs on test_CT {
5896 var MSC_ConnHdlr vc_conn;
5897 f_init(3, true, guard_timeout := 50.0);
5898 f_sleep(1.0);
5899 f_ctrs_bsc_and_bts_init();
5900 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_3));
5901 vc_conn.done;
5902
5903 /* f_tc_ho_neighbor_config_start() */
5904 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5905 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5906
5907 /* 3.a */
5908 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5909 f_ctrs_bsc_and_bts_add(0, "handover:error");
5910
5911 /* 3.b */
5912 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
5913 * handover quickly by sending a Handover Failure message. */
5914 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5915 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5916 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5917 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
5918
5919 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005920 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005921}
5922
Neels Hofmeyr91401012019-07-11 00:42:35 +02005923private function f_tc_ho_neighbor_config_4(charstring id) runs on MSC_ConnHdlr {
5924 f_tc_ho_neighbor_config_start();
5925
5926 /*
5927 * bts 0 ARFCN 871 BSIC 10
5928 * bts 1 ARFCN 871 BSIC 11
5929 * bts 2 ARFCN 871 BSIC 12
5930 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5931 */
5932
5933 log("f_tc_ho_neighbor_config: 4. explicit remote neighbor: 'neighbor lac 99 arfcn 123 bsic 45'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005934 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor lac 99 arfcn 123 bsic 45"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005935 f_sleep(0.5);
5936
5937 f_probe_for_handover("4.a", "HO to bts 1 doesn't work, not listed as neighbor",
5938 "handover any to arfcn 871 bsic 11",
5939 false);
5940 f_probe_for_handover("4.b", "HO to bts 2 doesn't work, not listed as neighbor",
5941 "handover any to arfcn 871 bsic 12",
5942 false);
5943 f_probe_for_handover("4.c", "HO to 123-45 triggers inter-BSC HO",
5944 "handover any to arfcn 123 bsic 45",
5945 true, true);
5946}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005947testcase TC_ho_neighbor_config_4() runs on test_CT {
5948 var MSC_ConnHdlr vc_conn;
5949 f_init(3, true, guard_timeout := 50.0);
5950 f_sleep(1.0);
5951 f_ctrs_bsc_and_bts_init();
5952 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_4));
5953 vc_conn.done;
5954
5955 /* f_tc_ho_neighbor_config_start() */
5956 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5957 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5958
5959 /* 4.a */
5960 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5961 f_ctrs_bsc_and_bts_add(0, "handover:error");
5962
5963 /* 4.b */
5964 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5965 f_ctrs_bsc_and_bts_add(0, "handover:error");
5966
5967 /* 4.c */
5968 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
5969 * handover quickly by timing out after the Handover Required message */
5970 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5971 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
5972 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
5973 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
5974
5975 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005976 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005977}
5978
Neels Hofmeyr91401012019-07-11 00:42:35 +02005979private function f_tc_ho_neighbor_config_5(charstring id) runs on MSC_ConnHdlr {
5980 f_tc_ho_neighbor_config_start();
5981
5982 /*
5983 * bts 0 ARFCN 871 BSIC 10
5984 * bts 1 ARFCN 871 BSIC 11
5985 * bts 2 ARFCN 871 BSIC 12
5986 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5987 */
5988
5989 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 +02005990 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor lac 99 arfcn 871 bsic 12"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005991 f_sleep(0.5);
5992
5993 f_probe_for_handover("5.a", "HO to 871-12 triggers inter-BSC HO (ignoring local cells with same ARFCN+BSIC)",
5994 "handover any to arfcn 871 bsic 12",
5995 true, true);
5996}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005997testcase TC_ho_neighbor_config_5() runs on test_CT {
5998 var MSC_ConnHdlr vc_conn;
5999 f_init(3, true);
6000 f_sleep(1.0);
6001 f_ctrs_bsc_and_bts_init();
6002 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_5));
6003 vc_conn.done;
6004
6005 /* f_tc_ho_neighbor_config_start() */
6006 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
6007 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
6008
6009 /* 5 */
6010 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
6011 * handover quickly by timing out after the Handover Required message */
6012 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6013 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
6014 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
6015 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
6016
6017 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006018 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006019}
6020
Neels Hofmeyr91401012019-07-11 00:42:35 +02006021private function f_tc_ho_neighbor_config_6(charstring id) runs on MSC_ConnHdlr {
6022 f_tc_ho_neighbor_config_start();
6023
6024 /*
6025 * bts 0 ARFCN 871 BSIC 10
6026 * bts 1 ARFCN 871 BSIC 11
6027 * bts 2 ARFCN 871 BSIC 12
6028 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
6029 */
6030
6031 log("f_tc_ho_neighbor_config: 6. config error: explicit local and remote neighbors with ambiguous ARFCN+BSIC:"
6032 & " 'neighbor bts 2; neighbor lac 99 arfcn 871 bsic 12'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02006033 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor bts 2", "neighbor lac 99 arfcn 871 bsic 12"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02006034 f_sleep(0.5);
6035
6036 f_probe_for_handover("6.a", "HO to 871-12 is ambiguous = error",
6037 "handover any to arfcn 871 bsic 12",
6038 false);
6039}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006040testcase TC_ho_neighbor_config_6() runs on test_CT {
6041 var MSC_ConnHdlr vc_conn;
6042 f_init(3, true);
6043 f_sleep(1.0);
6044 f_ctrs_bsc_and_bts_init();
6045 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_6));
6046 vc_conn.done;
6047
6048 /* f_tc_ho_neighbor_config_start() */
6049 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
6050 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
6051
6052 /* 6.a */
6053 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
6054 * handover quickly by timing out after the Handover Required message */
6055 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6056 f_ctrs_bsc_and_bts_add(0, "handover:error");
6057
6058 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006059 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006060}
6061
Neels Hofmeyr91401012019-07-11 00:42:35 +02006062private function f_tc_ho_neighbor_config_7(charstring id) runs on MSC_ConnHdlr {
6063 f_tc_ho_neighbor_config_start();
6064
6065 /*
6066 * bts 0 ARFCN 871 BSIC 10
6067 * bts 1 ARFCN 871 BSIC 11
6068 * bts 2 ARFCN 871 BSIC 12
6069 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
6070 */
6071
6072 log("f_tc_ho_neighbor_config: 7. explicit local and remote neighbors:"
6073 & " 'neighbor bts 2; neighbor lac 99 arfcn 123 bsic 45'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02006074 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor bts 2", "neighbor lac 99 arfcn 123 bsic 45"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02006075 f_sleep(0.5);
6076
6077 f_probe_for_handover("7.a", "HO to 871-12 does HO to bts 2",
6078 "handover any to arfcn 871 bsic 12",
6079 true);
6080 f_probe_for_handover("7.b", "HO to 123-45 triggers inter-BSC HO",
6081 "handover any to arfcn 123 bsic 45",
6082 true, true);
6083}
Neels Hofmeyr91401012019-07-11 00:42:35 +02006084testcase TC_ho_neighbor_config_7() runs on test_CT {
6085 var MSC_ConnHdlr vc_conn;
Neels Hofmeyrf2b88032020-06-16 00:35:04 +02006086 f_init(3, true, guard_timeout := 50.0);
Neels Hofmeyr91401012019-07-11 00:42:35 +02006087 f_sleep(1.0);
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006088 f_ctrs_bsc_and_bts_init();
Neels Hofmeyr91401012019-07-11 00:42:35 +02006089 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_7));
6090 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006091
6092 /* f_tc_ho_neighbor_config_start() */
6093 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
6094 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
6095
6096 /* 7.a */
6097 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
6098 * handover quickly by sending a Handover Failure message. */
6099 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6100 f_ctrs_bsc_and_bts_add(0, "handover:failed");
6101 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
6102 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
6103
6104 /* 7.b */
6105 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
6106 * handover quickly by timing out after the Handover Required message */
6107 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6108 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
6109 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
6110 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
6111
6112 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006113 f_shutdown_helper();
Neels Hofmeyr91401012019-07-11 00:42:35 +02006114}
6115
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01006116/* OS#3041: Open and close N connections in a normal fashion, and expect no
6117 * BSSMAP Reset just because of that. */
6118testcase TC_bssap_rlsd_does_not_cause_bssmap_reset() runs on test_CT {
6119 var default d;
6120 var integer i;
6121 var DchanTuple dt;
6122
6123 f_init();
6124
6125 /* Wait for initial BSSMAP Reset to pass */
6126 f_sleep(4.0);
6127
6128 d := activate(no_bssmap_reset());
6129
6130 /* Setup up a number of connections and RLSD them again from the MSC
6131 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
6132 * Let's do it some more times for good measure. */
Harald Weltec3260d92018-06-11 17:48:16 +02006133 for (i := 0; i < 4; i := i+1) {
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01006134 /* Since we're doing a lot of runs, give each one a fresh
6135 * T_guard from the top. */
6136 T_guard.start;
6137
6138 /* Setup a BSSAP connection and clear it right away. This is
6139 * the MSC telling the BSC about a planned release, it's not an
6140 * erratic loss of a connection. */
Harald Weltea1897182018-06-11 13:53:09 +02006141 dt := f_est_dchan(int2oct(i,1), 23+i, '00010203040506'O);
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01006142
6143 /* MSC disconnects (RLSD). */
6144 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
6145 }
6146
6147 /* In the buggy behavior, a timeout of 2 seconds happens between above
6148 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
6149 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
6150 f_sleep(4.0);
6151
6152 deactivate(d);
6153 f_shutdown_helper();
6154}
Harald Welte552620d2017-12-16 23:21:36 +01006155
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01006156/* OS#3041: Open and close N connections in a normal fashion, and expect no
6157 * BSSMAP Reset just because of that. Invoke the release by a BSSMAP Clear from
6158 * the MSC. */
6159testcase TC_bssmap_clear_does_not_cause_bssmap_reset() runs on test_CT {
6160 var default d;
6161 var integer i;
6162 var DchanTuple dt;
6163 var BSSAP_N_DATA_ind rx_di;
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01006164 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_CALL_CONTROL;
6165 var BssmapCause cause := enum2int(cause_val);
6166
6167 f_init();
6168
6169 /* Wait for initial BSSMAP Reset to pass */
6170 f_sleep(4.0);
6171
6172 d := activate(no_bssmap_reset());
6173
6174 /* Setup up a number of connections and RLSD them again from the MSC
6175 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
6176 * Let's do it some more times for good measure. */
6177 for (i := 0; i < 8; i := i+1) {
6178 /* Since we're doing a lot of runs, give each one a fresh
6179 * T_guard from the top. */
6180 T_guard.start;
6181
6182 /* Setup a BSSAP connection and clear it right away. This is
6183 * the MSC telling the BSC about a planned release, it's not an
6184 * erratic loss of a connection. */
Harald Weltea1897182018-06-11 13:53:09 +02006185 dt := f_est_dchan(int2oct(i,1), 23+i, '00010203040506'O);
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01006186
6187 /* Instruct BSC to clear channel */
6188 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
6189
6190 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02006191 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01006192 }
6193
6194 /* In the buggy behavior, a timeout of 2 seconds happens between above
6195 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
6196 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
6197 f_sleep(4.0);
6198
6199 deactivate(d);
6200 f_shutdown_helper();
6201}
6202
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01006203/* OS#3041: Open and close N connections in a normal fashion, and expect no
6204 * BSSMAP Reset just because of that. Close connections from the MS side with a
6205 * Release Ind on RSL. */
6206testcase TC_ms_rel_ind_does_not_cause_bssmap_reset() runs on test_CT {
6207 var default d;
6208 var integer i;
6209 var DchanTuple dt;
6210 var BSSAP_N_DATA_ind rx_di;
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01006211 var integer j;
6212
6213 f_init();
6214
6215 /* Wait for initial BSSMAP Reset to pass */
6216 f_sleep(4.0);
6217
6218 d := activate(no_bssmap_reset());
6219
6220 /* Setup up a number of connections and RLSD them again from the MSC
6221 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
6222 * Let's do it some more times for good measure. */
6223 for (i := 0; i < 8; i := i+1) {
6224 /* Since we're doing a lot of runs, give each one a fresh
6225 * T_guard from the top. */
6226 T_guard.start;
6227
6228 /* Setup a BSSAP connection and clear it right away. This is
6229 * the MSC telling the BSC about a planned release, it's not an
6230 * erratic loss of a connection. */
6231 dt := f_est_dchan('23'O, 23, '00010203040506'O);
6232
6233 /* simulate RLL REL IND */
6234 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0))));
6235
6236 /* expect Clear Request on MSC side */
6237 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
6238
6239 /* Instruct BSC to clear channel */
6240 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
6241 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
6242
6243 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02006244 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01006245 }
6246
6247 /* In the buggy behavior, a timeout of 2 seconds happens between above
6248 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
6249 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
6250 f_sleep(4.0);
6251
6252 deactivate(d);
6253 f_shutdown_helper();
6254}
6255
Harald Welte94e0c342018-04-07 11:33:23 +02006256/***********************************************************************
6257 * IPA style dynamic PDCH
6258 ***********************************************************************/
6259
6260private function f_dyn_ipa_pdch_act(integer bts_nr, integer trx_nr, integer ts_nr,
6261 template (omit) RSL_Cause nack := omit)
6262runs on test_CT {
6263 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(ts_nr));
6264 var RSL_Message rsl_unused;
6265 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
6266 f_vty_ts_action("pdch activate", bts_nr, trx_nr, ts_nr);
6267 /* expect the BSC to issue the related RSL command */
6268 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
6269 if (istemplatekind(nack, "omit")) {
6270 /* respond with a related acknowledgement */
6271 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
6272 } else {
6273 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_NACK(chan_nr, valueof(nack)));
6274 }
6275}
6276
6277private function f_dyn_ipa_pdch_deact(integer bts_nr, integer trx_nr, integer ts_nr,
6278 template (omit) RSL_Cause nack := omit)
6279runs on test_CT {
6280 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(ts_nr));
6281 var RSL_Message rsl_unused;
6282 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
6283 f_vty_ts_action("pdch deactivate", bts_nr, trx_nr, ts_nr);
6284 /* expect the BSC to issue the related RSL command */
6285 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_DEACT(chan_nr));
6286 if (istemplatekind(nack, "omit")) {
6287 /* respond with a related acknowledgement */
6288 f_ipa_tx(0, ts_RSL_IPA_PDCH_DEACT_ACK(chan_nr));
6289 } else {
6290 f_ipa_tx(0, ts_RSL_IPA_PDCH_DEACT_NACK(chan_nr, valueof(nack)));
6291 }
6292}
6293
6294private function f_ts_dyn_mode_get(integer bts_nr, integer trx_nr, integer ts_nr)
6295runs on test_CT return charstring {
6296 var charstring cmd, resp;
6297 cmd := "show timeslot "&int2str(bts_nr)&" "&int2str(trx_nr)&" "&int2str(ts_nr);
Stefan Sperlingcff13562018-11-13 15:24:06 +01006298 return f_vty_transceive_match_regexp_retry(BSCVTY, cmd, "*\((*)\)*", 0, 4, 1.0);
Harald Welte94e0c342018-04-07 11:33:23 +02006299}
6300
6301private function f_ts_dyn_mode_assert(integer bts_nr, integer trx_nr, integer ts_nr,
6302 template charstring exp)
6303runs on test_CT {
6304 var charstring mode := f_ts_dyn_mode_get(bts_nr, trx_nr, ts_nr);
6305 if (not match(mode, exp)) {
6306 setverdict(fail, "Unexpected TS Mode: ", mode);
Daniel Willmannafce8662018-07-06 23:11:32 +02006307 mtc.stop;
Harald Welte94e0c342018-04-07 11:33:23 +02006308 }
6309}
6310
6311private function f_ts_set_chcomb(integer bts_nr, integer trx_nr, integer ts_nr, charstring chcomb)
6312runs on test_CT {
6313 f_vty_enter_cfg_ts(BSCVTY, bts_nr, trx_nr, ts_nr);
6314 f_vty_transceive(BSCVTY, "phys_chan_config " & chcomb);
6315 f_vty_transceive(BSCVTY, "end");
6316}
6317
6318private const charstring TCHF_MODE := "TCH/F mode";
6319private const charstring TCHH_MODE := "TCH/H mode";
6320private const charstring PDCH_MODE := "PDCH mode";
6321private const charstring NONE_MODE := "NONE mode";
6322
6323/* Test IPA PDCH activation / deactivation triggered by VTY */
6324testcase TC_dyn_pdch_ipa_act_deact() runs on test_CT {
6325 var RSL_Message rsl_unused;
6326
6327 /* change Timeslot 6 before f_init() starts RSL */
6328 f_init_vty();
6329 f_ts_set_chcomb(0, 0, 6, "TCH/F_PDCH");
6330 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
6331
6332 f_init(1, false);
6333 f_sleep(1.0);
6334
6335 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
6336
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006337 log("TCH/F_PDCH pchan starts out in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02006338 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6339 /* The BSC will activate the dynamic PDCH by default, so confirm that */
6340 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
6341 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
6342 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006343 log("TCH/F_PDCH pchan, PDCH ACT was ACKed, so now in PDCH mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02006344 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
6345
6346 /* De-activate it via VTY */
6347 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
6348 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006349 log("TCH/F_PDCH pchan, PDCH DEACT via VTY, so now back in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02006350 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6351
6352 /* re-activate it via VTY */
6353 f_dyn_ipa_pdch_act(0, 0, chan_nr.tn);
6354 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006355 log("TCH/F_PDCH pchan, PDCH ACT via VTY, so now in PDCH mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02006356 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
6357
6358 /* and finally de-activate it again */
6359 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
6360 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006361 log("TCH/F_PDCH pchan, PDCH DEACT via VTY, so now back in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02006362 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6363
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02006364 /* clean up config */
6365 f_ts_set_chcomb(0, 0, 6, "PDCH");
6366
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006367 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02006368}
6369
6370/* Test IPA PDCH activation NACK */
6371testcase TC_dyn_pdch_ipa_act_nack() runs on test_CT {
6372 var RSL_Message rsl_unused;
6373
6374 /* change Timeslot 6 before f_init() starts RSL */
6375 f_init_vty();
6376 f_ts_set_chcomb(0, 0, 6, "TCH/F_PDCH");
6377 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
6378
6379 f_init(1, false);
6380 f_sleep(1.0);
6381
6382 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
6383
6384 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6385 /* The BSC will activate the dynamic PDCH by default, so confirm that */
6386 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
6387 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
6388 f_sleep(1.0);
6389 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
6390
6391 /* De-activate it via VTY */
6392 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
6393 f_sleep(1.0);
6394 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6395
6396 /* re-activate it via VTY, but fail that; check BSC still assumes TCH/F mode */
6397 f_dyn_ipa_pdch_act(0, 0, chan_nr.tn, RSL_ERR_EQUIPMENT_FAIL);
6398 f_sleep(1.0);
6399 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6400
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02006401 /* clean up config */
6402 f_ts_set_chcomb(0, 0, 6, "PDCH");
6403
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006404 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02006405}
6406
6407
6408/***********************************************************************
6409 * Osmocom style dynamic PDCH
6410 ***********************************************************************/
6411
6412private function f_dyn_osmo_pdch_act(integer bts_nr, integer trx_nr, integer ts_nr,
6413 template (omit) RSL_Cause nack := omit)
6414runs on test_CT {
6415 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(ts_nr));
6416 var RSL_Message rsl_unused;
6417 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
6418 /* FIXME: no VTY command to activate Osmocom PDCH !! */
6419 /* expect the BSC to issue the related RSL command */
6420 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT(chan_nr, ?));
6421 if (istemplatekind(nack, "omit")) {
6422 /* respond with a related acknowledgement */
6423 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342));
6424 } else {
6425 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, valueof(nack)));
6426 }
6427}
6428
6429private function f_dyn_osmo_pdch_deact(integer bts_nr, integer trx_nr, integer ts_nr,
6430 template (omit) RSL_Cause nack := omit)
6431runs on test_CT {
6432 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(ts_nr));
6433 var RSL_Message rsl_unused;
6434 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
6435 /* FIXME: no VTY command to activate Osmocom PDCH !! */
6436 /* expect the BSC to issue the related RSL command */
6437 rsl_unused := f_exp_ipa_rx(0, tr_RSL_RF_CHAN_REL(chan_nr));
6438 if (istemplatekind(nack, "omit")) {
6439 /* respond with a related acknowledgement */
6440 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(chan_nr));
6441 } else {
6442 //f_ipa_tx(0, ts_RSL_RF_CHAN_REL_NACK(chan_nr, valueof(nack)));
6443 }
6444}
6445
6446/* Test Osmocom dyn PDCH activation / deactivation triggered by VTY */
6447testcase TC_dyn_pdch_osmo_act_deact() runs on test_CT {
6448 var RSL_Message rsl_unused;
6449
6450 /* change Timeslot 6 before f_init() starts RSL */
6451 f_init_vty();
6452 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_PDCH");
6453 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
6454
6455 f_init(1, false);
6456 f_sleep(1.0);
6457
6458 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(6));
6459
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006460 log("TCH/F_TCH/H_PDCH pchan starts out in disabled mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02006461 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
6462 /* The BSC will activate the dynamic PDCH by default, so confirm that */
6463 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
6464
6465 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342));
6466 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006467 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 +02006468 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
6469
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02006470 /* clean up config */
6471 f_ts_set_chcomb(0, 0, 6, "PDCH");
6472
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006473 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02006474}
6475
6476/* Test Osmocom dyn PDCH activation NACK behavior */
6477testcase TC_dyn_pdch_osmo_act_nack() runs on test_CT {
6478 var RSL_Message rsl_unused;
6479
6480 /* change Timeslot 6 before f_init() starts RSL */
6481 f_init_vty();
6482 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_PDCH");
6483 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
6484
6485 f_init(1, false);
6486 f_sleep(1.0);
6487
6488 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(6));
6489
6490 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
6491 /* The BSC will activate the dynamic PDCH by default, so confirm that */
6492 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
6493
6494 /* NACK this activation and expect the "show timeslot" mode still to be NONE */
6495 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, RSL_ERR_EQUIPMENT_FAIL));
6496 f_sleep(1.0);
6497 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
6498
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02006499 /* clean up config */
6500 f_ts_set_chcomb(0, 0, 6, "PDCH");
6501
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006502 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02006503}
6504
Stefan Sperling0796a822018-10-05 13:01:39 +02006505testcase TC_chopped_ipa_ping() runs on test_CT {
Stefan Sperling554123f2018-10-09 14:12:30 +02006506 const Integers bsc_ipa_ports := {mp_bsc_rsl_port, mp_bsc_oml_port, mp_bsc_ctrl_port};
Stefan Sperling0796a822018-10-05 13:01:39 +02006507 for (var integer i := 0; i < lengthof(bsc_ipa_ports); i := i + 1) {
6508 IPA_Testing.f_run_TC_chopped_ipa_ping(mp_bsc_ip, bsc_ipa_ports[i], CONNECT_TO_SERVER);
6509 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006510 f_shutdown_helper();
Stefan Sperling0796a822018-10-05 13:01:39 +02006511}
6512
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02006513testcase TC_chopped_ipa_payload() runs on test_CT {
6514 const Integers bsc_ipa_ports := {mp_bsc_rsl_port, mp_bsc_oml_port
6515 /* TODO: mp_bsc_ctrl_port does not work yet */};
6516 for (var integer i := 0; i < lengthof(bsc_ipa_ports); i := i + 1) {
6517 IPA_Testing.f_run_TC_chopped_ipa_payload(mp_bsc_ip, bsc_ipa_ports[i], CONNECT_TO_SERVER);
6518 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006519 f_shutdown_helper();
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02006520}
6521
Pau Espin Pedrol8f773632019-11-05 11:46:53 +01006522/* Verify the BSC sends the MS Power Parameters IE during CHAN ACT to make sure
6523 the BTS does autonomous MS power control loop */
6524testcase TC_assignment_verify_ms_power_params_ie() runs on test_CT {
6525 var MSC_ConnHdlr vc_conn;
6526 var TestHdlrParams pars := f_gen_test_hdlr_pars();
6527 //pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
6528 pars.exp_ms_power_params := true;
6529
6530 f_init(1, true);
6531 f_sleep(1.0);
6532 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
6533 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006534 f_shutdown_helper();
Pau Espin Pedrol8f773632019-11-05 11:46:53 +01006535}
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02006536
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006537/***********************************************************************
6538 * MSC Pooling
6539 ***********************************************************************/
6540
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006541template MobileIdentityLV ts_MI_TMSI_NRI_LV(integer nri_v, integer nri_bitlen := 10) :=
Harald Weltebf397612021-01-14 20:39:46 +01006542 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 +02006543
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02006544private function f_expect_lchan_rel(RSL_DCHAN_PT rsl, template PDU_ML3_NW_MS exp_rr_rel_tmpl := tr_RRM_RR_RELEASE)
6545runs on MSC_ConnHdlr {
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02006546 interleave {
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02006547 [] rsl.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch exp_rr_rel_tmpl)) {
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02006548 f_logp(BSCVTY, "Got RSL RR Release");
6549 }
6550 [] rsl.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
6551 f_logp(BSCVTY, "Got RSL Deact SACCH");
6552 }
6553 [] rsl.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
6554 f_logp(BSCVTY, "Got RSL RF Chan Rel, sending Rel Ack");
6555 rsl.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
6556 break;
6557 }
6558 }
6559}
6560
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02006561private function f_perform_clear(RSL_DCHAN_PT rsl, template PDU_ML3_NW_MS exp_rr_rel_tmpl := tr_RRM_RR_RELEASE)
6562runs on MSC_ConnHdlr {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006563 f_logp(BSCVTY, "MSC instructs BSC to clear channel");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006564 BSSAP.send(ts_BSSMAP_ClearCommand(0));
6565 interleave {
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02006566 [] rsl.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch exp_rr_rel_tmpl)) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006567 f_logp(BSCVTY, "Got RSL RR Release");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006568 }
6569 [] rsl.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006570 f_logp(BSCVTY, "Got RSL Deact SACCH");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006571 }
6572 [] BSSAP.receive(tr_BSSMAP_ClearComplete) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006573 f_logp(BSCVTY, "Got BSSMAP Clear Complete");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006574 /* Also drop the SCCP connection */
6575 BSSAP.send(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_REQ);
6576 }
6577 [] rsl.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006578 f_logp(BSCVTY, "Got RSL RF Chan Rel, sending Rel Ack");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006579 rsl.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
6580 }
6581 }
6582}
6583
Neels Hofmeyr66e15092020-10-12 18:44:41 +00006584private 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 +02006585runs on MSC_ConnHdlr {
6586 timer T := 10.0;
6587 var octetstring l3_enc := enc_PDU_ML3_MS_NW(valueof(l3_info));
6588
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006589 f_logp(BSCVTY, "establish channel, send Complete Layer 3 Info");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006590 f_create_bssmap_exp(l3_enc);
6591
6592 /* RSL_Emulation.f_chan_est() on rsl:
6593 * This is basically code dup with s/RSL/rsl from:
6594 * RSL_Emulation.f_chan_est(g_pars.ra, l3_enc, g_pars.link_id, g_pars.fn);
6595 */
6596 var RSL_Message rx_rsl;
6597 var GsmRrMessage rr;
6598
6599 /* request a channel to be established */
6600 rsl.send(ts_RSLDC_ChanRqd(g_pars.ra, g_pars.fn));
6601 /* expect immediate assignment.
6602 * Code dup with s/RSL/rsl from:
6603 * rx_rsl := f_rx_or_fail(tr_RSL_IMM_ASSIGN);
6604 */
6605 timer Tt := 10.0;
6606
6607 /* request a channel to be established */
6608 Tt.start;
6609 alt {
6610 [] rsl.receive(tr_RSL_IMM_ASSIGN) -> value rx_rsl {
6611 Tt.stop;
6612 }
6613 [] rsl.receive {
6614 setverdict(fail, "Unexpected RSL message on DCHAN");
6615 mtc.stop;
6616 }
6617 [] Tt.timeout {
6618 setverdict(fail, "Timeout waiting for RSL on DCHAN");
6619 mtc.stop;
6620 }
6621 }
6622 rr := dec_GsmRrMessage(rx_rsl.ies[1].body.full_imm_ass_info.payload);
6623 g_chan_nr := rr.payload.imm_ass.chan_desc.chan_nr;
6624 rsl.send(ts_RSL_EST_IND(g_chan_nr, valueof(g_pars.link_id), l3_enc));
6625
6626
Neels Hofmeyr66e15092020-10-12 18:44:41 +00006627 if (expect_bssmap_l3) {
6628 f_logp(BSCVTY, "expect BSSAP Complete Layer 3 Info at MSC");
6629 var template PDU_BSSAP exp_l3_compl;
6630 exp_l3_compl := tr_BSSMAP_ComplL3()
6631 if (g_pars.aoip == false) {
6632 exp_l3_compl.pdu.bssmap.completeLayer3Information.codecList := omit;
6633 } else {
6634 exp_l3_compl.pdu.bssmap.completeLayer3Information.codecList := ?;
6635 }
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006636
Neels Hofmeyr66e15092020-10-12 18:44:41 +00006637 var PDU_BSSAP bssap;
6638 T.start;
6639 alt {
6640 [] BSSAP.receive(exp_l3_compl) -> value bssap {
6641 f_logp(BSCVTY, "received expected Complete Layer 3 Info at MSC");
6642 log("rx exp_l3_compl = ", bssap);
6643 }
6644 [] BSSAP.receive(tr_BSSMAP_ComplL3) {
6645 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received non-matching COMPLETE LAYER 3 INFORMATION");
6646 }
6647 [] T.timeout {
6648 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for COMPLETE LAYER 3 INFORMATION");
6649 }
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006650 }
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006651
Neels Hofmeyr66e15092020-10-12 18:44:41 +00006652 /* start ciphering, if requested */
6653 if (ispresent(g_pars.encr)) {
6654 f_logp(BSCVTY, "start ciphering");
6655 f_cipher_mode(g_pars.encr.enc_alg, g_pars.encr.enc_key);
6656 }
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006657 }
6658
6659 if (do_clear) {
6660 f_perform_clear(rsl);
6661 }
6662 setverdict(pass);
6663 f_sleep(1.0);
6664}
6665
6666private function f_tc_mscpool_compl_l3(charstring id) runs on MSC_ConnHdlr {
6667 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
6668 if (g_pars.mscpool.rsl_idx == 0) {
6669 f_perform_compl_l3(RSL, g_pars.mscpool.l3_info);
6670 } else if (g_pars.mscpool.rsl_idx == 1) {
6671 f_perform_compl_l3(RSL1, g_pars.mscpool.l3_info);
6672 } else if (g_pars.mscpool.rsl_idx == 2) {
6673 f_perform_compl_l3(RSL2, g_pars.mscpool.l3_info);
6674 }
6675}
6676
6677/* Various Complete Layer 3 by IMSI all end up with the first MSC, because the other MSCs are not connected. */
6678private function f_tc_mscpool_L3Compl_on_1_msc(charstring id) runs on MSC_ConnHdlr {
6679 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
6680 f_perform_compl_l3(RSL, ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000001'H)), '00F110'O) );
6681 f_perform_compl_l3(RSL, ts_CM_SERV_REQ(CM_TYPE_MO_SMS, valueof(ts_MI_IMSI_LV('001010000000002'H))) );
6682 f_perform_compl_l3(RSL, ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010000000003'H))) );
6683 f_perform_compl_l3(RSL, ts_ML3_MO_MM_IMSI_DET_Ind(valueof(ts_MI_IMSI_LV('001010000000004'H))) );
6684}
6685testcase TC_mscpool_L3Compl_on_1_msc() runs on test_CT {
6686
6687 f_init(1, true);
6688 f_sleep(1.0);
6689 var MSC_ConnHdlr vc_conn;
6690 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006691
6692 f_ctrs_msc_init();
6693
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006694 vc_conn := f_start_handler(refers(f_tc_mscpool_L3Compl_on_1_msc), pars);
6695 vc_conn.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006696
6697 f_ctrs_msc_expect(0, "mscpool:subscr:new", 4);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006698 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006699}
6700
6701/* Three Layer 3 Complete by IMSI are round-robin'ed across two connected MSCs */
6702/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6703 * just as well using only RSL. */
6704testcase TC_mscpool_L3Complete_by_imsi_round_robin() runs on test_CT {
6705
6706 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6707 f_sleep(1.0);
6708
6709 /* Control which MSC gets chosen next by the round-robin, otherwise
6710 * would be randomly affected by which other tests ran before this. */
6711 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6712
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006713 f_ctrs_msc_init();
6714
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006715 var MSC_ConnHdlr vc_conn1;
6716 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6717 pars1.mscpool.rsl_idx := 0;
6718 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000001'H)), '00F110'O));
6719 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6720 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006721 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006722
6723 var MSC_ConnHdlr vc_conn2;
6724 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6725 pars2.mscpool.rsl_idx := 1;
6726 pars2.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000002'H))));
6727 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6728 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006729 f_ctrs_msc_expect(1, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006730
6731 /* Test round-robin wrap to the first MSC */
6732 var MSC_ConnHdlr vc_conn3;
6733 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6734 pars3.mscpool.rsl_idx := 2;
6735 pars3.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010000000003'H))));
6736 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6737 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006738 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006739 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006740}
6741
6742/* Three LU by TMSI are round-robin'ed across two connected MSCs, because they contain the NULL-NRI 0
6743 * (configured in osmo-bsc.cfg). */
6744/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6745 * just as well using only RSL. */
6746testcase TC_mscpool_LU_by_tmsi_null_nri_0_round_robin() runs on test_CT {
6747
6748 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6749 f_sleep(1.0);
6750
6751 /* Control which MSC gets chosen next by the round-robin, otherwise
6752 * would be randomly affected by which other tests ran before this. */
6753 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6754
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006755 f_ctrs_msc_init();
6756
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006757 var MSC_ConnHdlr vc_conn1;
6758 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6759 pars1.mscpool.rsl_idx := 0;
6760 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(0)), '00F110'O));
6761 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6762 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006763 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006764
6765 var MSC_ConnHdlr vc_conn2;
6766 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6767 pars2.mscpool.rsl_idx := 1;
6768 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(0)), '00F110'O));
6769 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6770 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006771 f_ctrs_msc_expect(1, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006772
6773 /* Test round-robin wrap to the first MSC */
6774 var MSC_ConnHdlr vc_conn3;
6775 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6776 pars3.mscpool.rsl_idx := 2;
6777 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(0)), '00F110'O));
6778 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6779 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006780 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006781 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006782}
6783
6784/* Three LU by TMSI are round-robin'ed across two connected MSCs, because they contain the NULL-NRI 1
6785 * (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
6786 * NULL-NRI setting is stronger than that. */
6787/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6788 * just as well using only RSL. */
6789testcase TC_mscpool_LU_by_tmsi_null_nri_1_round_robin() runs on test_CT {
6790
6791 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6792 f_sleep(1.0);
6793
6794 /* Control which MSC gets chosen next by the round-robin, otherwise
6795 * would be randomly affected by which other tests ran before this. */
6796 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6797
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006798 f_ctrs_msc_init();
6799
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006800 var MSC_ConnHdlr vc_conn1;
6801 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6802 pars1.mscpool.rsl_idx := 0;
6803 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(1)), '00F110'O));
6804 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6805 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006806 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006807
6808 var MSC_ConnHdlr vc_conn2;
6809 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6810 pars2.mscpool.rsl_idx := 1;
6811 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(1)), '00F110'O));
6812 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6813 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006814 f_ctrs_msc_expect(1, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006815
6816 /* Test round-robin wrap to the first MSC */
6817 var MSC_ConnHdlr vc_conn3;
6818 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6819 pars3.mscpool.rsl_idx := 2;
6820 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(1)), '00F110'O));
6821 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6822 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006823 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006824 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006825}
6826
6827/* Three Layer 3 Complete by TMSI are round-robin'ed across two connected MSCs, because they contain an NRI not
6828 * assigned to any MSC (configured in osmo-bsc.cfg). */
6829/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6830 * just as well using only RSL. */
6831testcase TC_mscpool_L3Complete_by_tmsi_unassigned_nri_round_robin() runs on test_CT {
6832
6833 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6834 f_sleep(1.0);
6835
6836 /* Control which MSC gets chosen next by the round-robin, otherwise
6837 * would be randomly affected by which other tests ran before this. */
6838 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6839
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006840 f_ctrs_msc_init();
6841
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006842 var MSC_ConnHdlr vc_conn1;
6843 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6844 pars1.mscpool.rsl_idx := 0;
6845 /* An NRI that is not assigned to any MSC */
6846 pars1.mscpool.l3_info := valueof(ts_ML3_MO_MM_IMSI_DET_Ind(valueof(ts_MI_TMSI_NRI_LV(1023))));
6847 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6848 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006849 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006850
6851 var MSC_ConnHdlr vc_conn2;
6852 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6853 pars2.mscpool.rsl_idx := 1;
6854 /* An NRI that is not assigned to any MSC */
6855 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(768)), '00F110'O));
6856 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6857 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006858 f_ctrs_msc_expect(1, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006859
6860 /* Test round-robin wrap to the first MSC */
6861 var MSC_ConnHdlr vc_conn3;
6862 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6863 pars3.mscpool.rsl_idx := 2;
6864 /* An NRI that is not assigned to any MSC */
6865 pars3.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_SS_ACT, valueof(ts_MI_TMSI_NRI_LV(819))));
6866 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6867 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006868 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006869 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006870}
6871
6872/* Three Layer 3 Complete by TMSI are round-robin'ed across two connected MSCs, because they contain an NRI
6873 * assigned to an MSC that is currently not connected (configured in osmo-bsc.cfg). */
6874/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6875 * just as well using only RSL. */
6876testcase TC_mscpool_L3Complete_by_tmsi_valid_nri_msc_not_connected_round_robin() runs on test_CT {
6877
6878 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6879 f_sleep(1.0);
6880
6881 /* Control which MSC gets chosen next by the round-robin, otherwise
6882 * would be randomly affected by which other tests ran before this. */
6883 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6884
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006885 f_ctrs_msc_init();
6886
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006887 var MSC_ConnHdlr vc_conn1;
6888 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6889 pars1.mscpool.rsl_idx := 0;
6890 /* An NRI that is assigned to an unconnected MSC */
6891 pars1.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(512))));
6892 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6893 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006894 f_ctrs_msc_add(2, "mscpool:subscr:attach_lost");
6895 f_ctrs_msc_add(0, "mscpool:subscr:new");
6896 f_ctrs_msc_verify();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006897
6898 var MSC_ConnHdlr vc_conn2;
6899 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6900 pars2.mscpool.rsl_idx := 1;
6901 /* An NRI that is assigned to an unconnected MSC */
6902 pars2.mscpool.l3_info := valueof(ts_ML3_MO_MM_IMSI_DET_Ind(valueof(ts_MI_TMSI_NRI_LV(767))));
6903 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6904 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006905 f_ctrs_msc_add(2, "mscpool:subscr:attach_lost");
6906 f_ctrs_msc_add(1, "mscpool:subscr:new");
6907 f_ctrs_msc_verify();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006908
6909 /* Test round-robin wrap to the first MSC */
6910 var MSC_ConnHdlr vc_conn3;
6911 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6912 pars3.mscpool.rsl_idx := 2;
6913 /* An NRI that is assigned to an unconnected MSC */
6914 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(750)), '00F110'O));
6915 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6916 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006917 f_ctrs_msc_add(2, "mscpool:subscr:attach_lost");
6918 f_ctrs_msc_add(0, "mscpool:subscr:new");
6919 f_ctrs_msc_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006920 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006921}
6922
6923/* Three Layer 3 Complete by TMSI with valid NRI for the second MSC are all directed to the second MSC (configured in
6924 * osmo-bsc.cfg). */
6925/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6926 * just as well using only RSL. */
6927testcase TC_mscpool_L3Complete_by_tmsi_valid_nri_1() runs on test_CT {
6928
6929 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6930 f_sleep(1.0);
6931
6932 /* All TMSIs in this test point at the second MSC, set the round robin to point at the first MSC to make sure
6933 * this is not using round-robin. */
6934 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6935
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006936 f_ctrs_msc_init();
6937
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006938 var MSC_ConnHdlr vc_conn1;
6939 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 1);
6940 pars1.mscpool.rsl_idx := 0;
6941 /* An NRI of the second MSC's range (256-511) */
6942 pars1.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_SMS, valueof(ts_MI_TMSI_NRI_LV(256))));
6943 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6944 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006945 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006946
6947 var MSC_ConnHdlr vc_conn2;
6948 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6949 pars2.mscpool.rsl_idx := 1;
6950 /* An NRI of the second MSC's range (256-511) */
6951 pars2.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(260))));
6952 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6953 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006954 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006955
6956 var MSC_ConnHdlr vc_conn3;
6957 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 1);
6958 pars3.mscpool.rsl_idx := 2;
6959 /* An NRI of the second MSC's range (256-511) */
6960 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(511)), '00F110'O));
6961 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6962 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006963 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006964 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006965}
6966
6967/* Layer 3 Complete by TMSI with valid NRI for the third MSC are directed to the third MSC (configured in osmo-bsc.cfg),
6968 * while a round-robin remains unaffected by that. */
6969/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6970 * just as well using only RSL. */
6971testcase TC_mscpool_L3Complete_by_tmsi_valid_nri_2() runs on test_CT {
6972
6973 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
6974 f_sleep(1.0);
6975
6976 /* All TMSIs in this test point at the third MSC, set the round robin to point at the second MSC to make sure
6977 * this is not using round-robin. */
6978 f_vty_transceive(BSCVTY, "mscpool roundrobin next 1");
6979
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006980 f_ctrs_msc_init();
6981
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006982 var MSC_ConnHdlr vc_conn1;
6983 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 2);
6984 pars1.mscpool.rsl_idx := 0;
6985 /* An NRI of the third MSC's range (512-767) */
6986 pars1.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_SMS, valueof(ts_MI_TMSI_NRI_LV(512))));
6987 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6988 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006989 f_ctrs_msc_expect(2, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006990
6991 var MSC_ConnHdlr vc_conn2;
6992 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 2);
6993 pars2.mscpool.rsl_idx := 1;
6994 /* An NRI of the third MSC's range (512-767) */
6995 pars2.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(678))));
6996 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6997 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006998 f_ctrs_msc_expect(2, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006999
7000 /* The above forwardings to third MSC have not affected the round robin, which still points at the second MSC */
7001 var MSC_ConnHdlr vc_conn3;
7002 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 1);
7003 pars3.mscpool.rsl_idx := 2;
7004 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000013'H)), '00F110'O));
7005 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
7006 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007007 f_ctrs_msc_expect(1, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007008 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007009}
7010
7011/* LU with a TMSI but indicating a different PLMN in its previous LAI: ignore the NRI. */
7012/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
7013 * just as well using only RSL. */
7014testcase TC_mscpool_LU_by_tmsi_from_other_PLMN() runs on test_CT {
7015
7016 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
7017 f_sleep(1.0);
7018
7019 /* The TMSIs in this test points at the second MSC, but since it is from a different PLMN, round-robin is used
7020 * instead, and hits msc 0. */
7021 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
7022
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007023 f_ctrs_msc_init();
7024
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007025 /* An NRI of the second MSC's range (256-511), but a PLMN that doesn't match with osmo-bsc.cfg */
7026 var MSC_ConnHdlr vc_conn1;
7027 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
7028 pars1.mscpool.rsl_idx := 0;
7029 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(260)), '99F999'O));
7030 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
7031 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007032 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007033
7034 /* An NRI of the third MSC's range (512-767) and a matching PLMN gets directed by NRI. */
7035 var MSC_ConnHdlr vc_conn2;
7036 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 2);
7037 pars2.mscpool.rsl_idx := 1;
7038 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(555)), '00F110'O));
7039 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
7040 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007041 f_ctrs_msc_expect(2, "mscpool:subscr:known");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007042 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007043}
7044
7045/* Make sure that whichever MSC paged a subscriber will also get the Paging Response. Page by IMSI, which would be
7046 * round-robined to another MSC, to make sure the Paging->Response relation is stronger than the NRI->MSC mapping. */
7047private function f_tc_mscpool_paging_imsi(charstring id) runs on MSC_ConnHdlr {
7048 var template BSSMAP_FIELD_CellIdentificationList cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(0) } };
7049 //cid_list := { cIl_allInBSS := ''O };
7050 var RSL_ChanNeeded rsl_chneed := RSL_CHANNEED_SDCCH;
7051 var template BSSMAP_IE_ChannelNeeded bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
7052 var BSSAP_N_UNITDATA_req paging;
7053 var hexstring imsi := '001010000000123'H;
7054
7055 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
7056
Neels Hofmeyr90f80962020-06-12 16:16:55 +02007057 paging := valueof(ts_BSSAP_UNITDATA_req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007058 valueof(ts_BSSMAP_Paging(imsi, cid_list, omit, bssmap_chneed))));
7059 BSSAP.send(paging);
7060
7061 /* Register any RSL conn so that the Paging Command gets received here. With the current RSL_Emulation's main()
7062 * handling of '[bts_role] IPA_PT.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD()))' it doesn't matter at all which
7063 * channel number is picked here. */
7064 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(0, RSL_CHAN_NR_INVALID));
7065 f_rslem_register(0, new_chan_nr);
7066 RSL.receive(tr_RSL_PAGING_CMD(tr_MI_IMSI(imsi)));
7067 f_rslem_unregister(0, new_chan_nr);
7068
7069 /* Despite the round robin pointing at the second MSC ('roundrobin next 1'), the earlier Paging for the same IMSI
7070 * causes this Paging Response to go to the first MSC (bssap_idx := 0). */
7071 f_perform_compl_l3(RSL, ts_PAG_RESP(valueof(ts_MI_IMSI_LV(imsi))) );
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007072 f_sleep(1.0);
7073}
7074testcase TC_mscpool_paging_and_response_imsi() runs on test_CT {
7075 f_init(nr_bts := 1, handler_mode := true, nr_msc := 3);
7076 f_sleep(1.0);
7077
7078 /* Testing a Paging on the first MSC to get a Paging Response back to the first MSC. Set round robin to the
7079 * second MSC to make sure we're getting the Paging logic, not a coincidental round robin match. */
7080 f_vty_transceive(BSCVTY, "mscpool roundrobin next 1");
7081
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007082 f_ctrs_msc_init();
7083
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007084 var MSC_ConnHdlr vc_conn1;
7085 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
7086 pars1.mscpool.rsl_idx := 0;
Neels Hofmeyr90f80962020-06-12 16:16:55 +02007087 pars1.sccp_addr_bsc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_peer;
7088 pars1.sccp_addr_msc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_own;
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007089 vc_conn1 := f_start_handler(refers(f_tc_mscpool_paging_imsi), pars1);
7090 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007091 f_ctrs_msc_expect(0, "mscpool:subscr:paged");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007092 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007093}
7094
7095/* Make sure that whichever MSC paged a subscriber will also get the Paging Response. Page by TMSI with an NRI value
7096 * that matches a different MSC, to make sure the Paging->Response relation is stronger than the NRI->MSC mapping. */
7097private function f_tc_mscpool_paging_tmsi(charstring id) runs on MSC_ConnHdlr {
7098 var template BSSMAP_FIELD_CellIdentificationList cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(0) } };
7099 //cid_list := { cIl_allInBSS := ''O };
7100 var RSL_ChanNeeded rsl_chneed := RSL_CHANNEED_SDCCH;
7101 var template BSSMAP_IE_ChannelNeeded bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
7102 var integer nri_v := 300; /* <-- second MSC's NRI */
Harald Weltebf397612021-01-14 20:39:46 +01007103 var octetstring tmsi := f_gen_tmsi(suffix := 0, nri_v := nri_v);
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007104 var BSSAP_N_UNITDATA_req paging;
7105
7106 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
7107
Neels Hofmeyr90f80962020-06-12 16:16:55 +02007108 paging := valueof(ts_BSSAP_UNITDATA_req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007109 valueof(ts_BSSMAP_Paging('001010000000011'H, cid_list, tmsi, bssmap_chneed))));
7110 BSSAP.send(paging);
7111
7112 /* Register any RSL conn so that the Paging Command gets received here. With the current RSL_Emulation's main()
7113 * handling of '[bts_role] IPA_PT.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD()))' it doesn't matter at all which
7114 * channel number is picked here. */
7115 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(0, RSL_CHAN_NR_INVALID));
7116 f_rslem_register(0, new_chan_nr);
7117 RSL.receive(tr_RSL_PAGING_CMD(t_MI_TMSI(tmsi)));
7118 f_rslem_unregister(0, new_chan_nr);
7119
7120 /* Despite the NRI matching the second MSC (NRI from 'msc 1' in osmo-bsc.cfg) and round robin pointing at the
7121 * third MSC ('roundrobin next 2'), the earlier Paging for the same TMSI causes this Paging Response to go to
7122 * the first MSC (bssap_idx := 0). */
7123 f_perform_compl_l3(RSL, ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(nri_v))) );
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007124 f_sleep(1.0);
7125}
7126testcase TC_mscpool_paging_and_response_tmsi() runs on test_CT {
7127 f_init(nr_bts := 1, handler_mode := true, nr_msc := 3);
7128 f_sleep(1.0);
7129
7130 /* Testing a Paging on the first MSC to get a Paging Response back to the first MSC. Set round robin to the
7131 * third MSC to make sure we're getting the Paging logic, not a coincidental round robin match. */
7132 f_vty_transceive(BSCVTY, "mscpool roundrobin next 2");
7133
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007134 f_ctrs_msc_init();
7135
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007136 var MSC_ConnHdlr vc_conn1;
7137 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
7138 pars1.mscpool.rsl_idx := 0;
Neels Hofmeyr90f80962020-06-12 16:16:55 +02007139 pars1.sccp_addr_bsc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_peer;
7140 pars1.sccp_addr_msc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_own;
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007141 vc_conn1 := f_start_handler(refers(f_tc_mscpool_paging_tmsi), pars1);
7142 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007143 f_ctrs_msc_expect(0, "mscpool:subscr:paged");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007144 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007145}
7146
7147/* For round-robin, skip an MSC that has 'no allow-attach' set. */
7148/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
7149 * just as well using only RSL. */
7150testcase TC_mscpool_no_allow_attach_round_robin() runs on test_CT {
7151
7152 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
7153 f_sleep(1.0);
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00007154 /* Mark the second MSC as offloading, round-robin should skip this MSC now. */
7155 f_vty_msc_allow_attach(BSCVTY, {true, false, true});
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007156
7157 /* Control which MSC gets chosen next by the round-robin, otherwise
7158 * would be randomly affected by which other tests ran before this. */
7159 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
7160
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007161 f_ctrs_msc_init();
7162
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007163 var MSC_ConnHdlr vc_conn1;
7164 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
7165 pars1.mscpool.rsl_idx := 0;
7166 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000001'H)), '00F110'O));
7167 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
7168 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007169 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007170
7171 var MSC_ConnHdlr vc_conn2;
7172 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 2);
7173 pars2.mscpool.rsl_idx := 1;
7174 pars2.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000002'H))));
7175 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
7176 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007177 f_ctrs_msc_expect(2, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007178
7179 var MSC_ConnHdlr vc_conn3;
7180 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
7181 pars3.mscpool.rsl_idx := 2;
7182 pars3.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010000000003'H))));
7183 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
7184 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007185 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007186 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007187}
7188
7189/* An MSC that has 'no allow-attach' set should still serve subscribers that are already attached according to their
7190 * TMSI NRI. */
7191testcase TC_mscpool_no_allow_attach_valid_nri() runs on test_CT {
7192
7193 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
7194 f_sleep(1.0);
7195
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00007196 /* Mark the second MSC as offloading, round-robin should skip this MSC now. */
7197 f_vty_msc_allow_attach(BSCVTY, {true, false, true});
7198
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007199 /* Control which MSC gets chosen next by the round-robin, otherwise
7200 * would be randomly affected by which other tests ran before this. */
7201 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
7202
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007203 f_ctrs_msc_init();
7204
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007205 /* Round robin points at msc 0, but the valid NRI directs to msc 1, even though msc 1 has 'no allow-attach'. */
7206 var MSC_ConnHdlr vc_conn1;
7207 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 1);
7208 pars1.mscpool.rsl_idx := 0;
7209 /* An NRI of the second MSC's range (256-511) */
7210 pars1.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_TMSI_NRI_LV(260))));
7211 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
7212 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007213 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007214
7215 var MSC_ConnHdlr vc_conn2;
7216 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 0);
7217 pars2.mscpool.rsl_idx := 1;
7218 pars2.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000002'H))));
7219 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
7220 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007221 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007222
7223 var MSC_ConnHdlr vc_conn3;
7224 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 2);
7225 pars3.mscpool.rsl_idx := 2;
7226 pars3.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000003'H))));
7227 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
7228 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007229 f_ctrs_msc_expect(2, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007230 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007231}
7232
Philipp Maier783681c2020-07-16 16:47:06 +02007233/* Allow/Deny emergency calls globally via VTY */
7234private function f_vty_allow_emerg_msc(boolean allow) runs on test_CT {
7235 f_vty_enter_cfg_msc(BSCVTY, 0);
7236 if (allow) {
7237 f_vty_transceive(BSCVTY, "allow-emergency allow");
7238 } else {
7239 f_vty_transceive(BSCVTY, "allow-emergency deny");
7240 }
7241 f_vty_transceive(BSCVTY, "exit");
7242 f_vty_transceive(BSCVTY, "exit");
7243}
7244
7245/* Allow/Deny emergency calls per BTS via VTY */
7246private function f_vty_allow_emerg_bts(boolean allow, integer bts_nr) runs on test_CT {
7247 f_vty_enter_cfg_bts(BSCVTY, bts_nr);
7248 if (allow) {
7249 f_vty_transceive(BSCVTY, "rach emergency call allowed 1");
7250 } else {
7251 f_vty_transceive(BSCVTY, "rach emergency call allowed 0");
7252 }
7253 f_vty_transceive(BSCVTY, "exit");
7254 f_vty_transceive(BSCVTY, "exit");
Neels Hofmeyrb6ed80c2020-10-12 22:52:39 +00007255 f_vty_transceive(BSCVTY, "exit");
Philipp Maier783681c2020-07-16 16:47:06 +02007256}
7257
7258/* Begin assignmet procedure and send an EMERGENCY SETUP (RR) */
7259private function f_assignment_emerg_setup() runs on MSC_ConnHdlr {
7260 var PDU_ML3_MS_NW emerg_setup;
7261 var octetstring emerg_setup_enc;
7262 var RSL_Message emerg_setup_data_ind;
7263
7264 f_establish_fully(omit, omit);
7265
7266 emerg_setup := valueof(ts_ML3_MO_CC_EMERG_SETUP(1, valueof(ts_Bcap_voice)));
7267 emerg_setup_enc := enc_PDU_ML3_MS_NW(emerg_setup);
7268 emerg_setup_data_ind := valueof(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), emerg_setup_enc));
7269
7270 RSL.send(emerg_setup_data_ind);
7271}
7272
7273/* Test if the EMERGENCY SETUP gets passed on to the MSC via A when EMERGENCY
7274 * CALLS are permitted by the BSC config. */
7275private function f_TC_assignment_emerg_setup_allow(charstring id) runs on MSC_ConnHdlr {
7276 var PDU_BSSAP emerg_setup_data_ind_bssap;
7277 var PDU_ML3_MS_NW emerg_setup;
7278 timer T := 3.0;
7279
7280 f_assignment_emerg_setup()
7281
7282 T.start;
7283 alt {
7284 [] BSSAP.receive(tr_BSSAP_DTAP) -> value emerg_setup_data_ind_bssap {
7285 emerg_setup := dec_PDU_ML3_MS_NW(emerg_setup_data_ind_bssap.pdu.dtap);
7286 if (not isbound(emerg_setup.msgs.cc.emergencySetup)) {
7287 setverdict(fail, "no emergency setup");
7288 }
7289 }
7290 [] BSSAP.receive {
7291 setverdict(fail, "unexpected BSSAP message!");
7292 }
7293 [] T.timeout {
7294 setverdict(fail, "timout waiting for EMERGENCY SETUP!");
7295 }
7296 }
7297
7298 setverdict(pass);
7299}
7300
7301/* Test if the EMERGENCY SETUP gets blocked by the BSC if EMERGENCY CALLS are
7302 * forbidden by the BSC config. */
7303private function f_TC_assignment_emerg_setup_deny(charstring id) runs on MSC_ConnHdlr {
7304 var PDU_BSSAP emerg_setup_data_ind_bssap;
7305 timer T := 3.0;
7306
7307 f_assignment_emerg_setup()
7308
7309 T.start;
7310 alt {
7311 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
7312 setverdict(pass);
7313 }
7314 [] RSL.receive {
7315 setverdict(fail, "unexpected RSL message!");
7316 }
7317 [] T.timeout {
7318 setverdict(fail, "timout waiting for RR CHANNEL RELEASE!");
7319 }
7320 }
7321}
7322
7323/* EMERGENCY CALL situation #1, allowed globally and by BTS */
7324testcase TC_assignment_emerg_setup_allow() runs on test_CT {
7325 var TestHdlrParams pars := f_gen_test_hdlr_pars();
7326 var MSC_ConnHdlr vc_conn;
7327
7328 f_init(1, true);
7329 f_sleep(1.0);
7330
7331 f_vty_allow_emerg_msc(true);
7332 f_vty_allow_emerg_bts(true, 0);
7333 vc_conn := f_start_handler(refers(f_TC_assignment_emerg_setup_allow), pars);
7334 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007335 f_shutdown_helper();
Philipp Maier783681c2020-07-16 16:47:06 +02007336}
7337
7338/* EMERGENCY CALL situation #2, forbidden globally but allowed by BTS */
7339testcase TC_assignment_emerg_setup_deny_msc() runs on test_CT {
7340 var TestHdlrParams pars := f_gen_test_hdlr_pars();
7341 var MSC_ConnHdlr vc_conn;
7342
7343 f_init(1, true);
7344 f_sleep(1.0);
7345
7346 f_vty_allow_emerg_msc(false);
7347 f_vty_allow_emerg_bts(true, 0);
7348 vc_conn := f_start_handler(refers(f_TC_assignment_emerg_setup_deny), pars);
7349 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007350 f_shutdown_helper();
Philipp Maier783681c2020-07-16 16:47:06 +02007351}
7352
7353/* EMERGENCY CALL situation #3, allowed globally but forbidden by BTS */
7354testcase TC_assignment_emerg_setup_deny_bts() runs on test_CT {
7355 var TestHdlrParams pars := f_gen_test_hdlr_pars();
7356 var MSC_ConnHdlr vc_conn;
7357
7358 /* Note: This simulates a spec violation by the MS, correct MS
7359 * implementations would not try to establish an emergency call because
7360 * the system information tells in advance that emergency calls are
7361 * not forbidden */
7362
7363 f_init(1, true);
7364 f_sleep(1.0);
7365
7366 f_vty_allow_emerg_msc(true);
7367 f_vty_allow_emerg_bts(false, 0);
7368 vc_conn := f_start_handler(refers(f_TC_assignment_emerg_setup_deny), pars);
7369 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007370 f_shutdown_helper();
Philipp Maier783681c2020-07-16 16:47:06 +02007371}
7372
Philipp Maier82812002020-08-13 18:48:27 +02007373/* Test what happens when an emergency call arrives while all TCH channels are
7374 * busy, the BSC is expected to terminate one call in favor of the incoming
7375 * emergency call */
7376testcase TC_emerg_premption() runs on test_CT {
7377 var ASP_RSL_Unitdata rsl_ud;
7378 var integer i;
7379 var integer chreq_total, chreq_nochan;
7380 var RSL_Message rx_rsl;
7381 var RslChannelNr chan_nr;
7382
7383 f_init(1);
7384 f_sleep(1.0);
7385
7386 f_vty_allow_emerg_msc(true);
7387 f_vty_allow_emerg_bts(true, 0);
7388
7389 /* Fill up all channels on the BTS */
7390 chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total");
7391 chreq_nochan := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel");
7392 for (i := 0; i < NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS; i := i+1) {
7393 chan_nr := f_chreq_act_ack('33'O, i);
7394 }
7395 IPA_RSL[0].clear;
7396 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total",
7397 chreq_total + NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS);
7398
7399 /* Send Channel request for emegergency call */
7400 f_ipa_tx(0, ts_RSL_CHAN_RQD('A5'O, 23));
7401
7402 /* Expect the BSC to release one (the first) TCH/F on the BTS */
7403 chan_nr := valueof(t_RslChanNr_Bm(1));
7404 f_expect_chan_rel(0, chan_nr, expect_rr_chan_rel := false, expect_rll_rel_req := false);
7405
7406 /* Expect the BSC to send activate/assign the a channel for the emergency call */
7407 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7408 chan_nr := rx_rsl.ies[0].body.chan_nr;
7409 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 33));
7410 rx_rsl := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
Philipp Maier104f4c02020-09-11 18:12:18 +02007411
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007412 f_shutdown_helper();
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007413}
7414
7415/* Hopping parameters per a timeslot */
Vadim Yanitskiybc6654a2020-09-13 01:27:40 +07007416private type record length(0..64) of GsmArfcn ArfcnList;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007417private type record FHParamsTs {
7418 boolean enabled,
7419 uint6_t hsn,
7420 uint6_t maio,
7421 ArfcnList ma
7422};
7423
7424/* Hopping parameters per a transceiver */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007425private type record FHParamsTrx {
7426 GsmArfcn arfcn,
7427 FHParamsTs ts[8]
7428};
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007429
7430/* Randomly generate the hopping parameters for the given timeslot numbers */
7431private function f_TC_fh_params_gen(template integer tr_tn := (1, 3, 5))
7432runs on test_CT return FHParamsTrx {
7433 var FHParamsTrx fhp;
7434
Vadim Yanitskiy3e997362020-09-05 21:08:34 +07007435 /* Generate a random ARFCN, including ARFCN 0 */
7436 fhp.arfcn := f_rnd_int(3);
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007437
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007438 for (var integer tn := 0; tn < 8; tn := tn + 1) {
7439 if (not match(tn, tr_tn)) {
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007440 fhp.ts[tn].enabled := false;
7441 fhp.ts[tn].ma := { };
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007442 continue;
7443 }
7444
7445 /* Random HSN / MAIO values: 0..63 */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007446 fhp.ts[tn].hsn := f_rnd_int(64);
7447 fhp.ts[tn].maio := f_rnd_int(64);
7448 fhp.ts[tn].ma := { };
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007449
7450 /* Random Mobile Allocation (hopping channels) */
7451 var integer ma_len := 2 + f_rnd_int(9); /* 2..10 channels */
7452 var integer step := 3 + f_rnd_int(4); /* 3..6 stepping */
7453 for (var integer i := 1; i <= ma_len; i := i + 1) {
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007454 fhp.ts[tn].ma := fhp.ts[tn].ma & { i * step };
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007455 }
7456
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007457 fhp.ts[tn].enabled := true;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007458 }
7459
7460 log("f_TC_fh_params_gen(): ", fhp);
7461 return fhp;
7462}
7463
7464/* Make sure that the given Channel Description IE matches the hopping configuration */
7465private function f_TC_fh_params_match_chan_desc(in FHParamsTrx fhp, in ChannelDescription cd)
7466{
7467 var template (present) ChannelDescription tr_cd;
7468 var template (present) MaioHsn tr_maio_hsn;
7469 var uint3_t tn := cd.chan_nr.tn;
7470
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007471 if (fhp.ts[tn].enabled) {
7472 tr_maio_hsn := tr_HsnMaio(fhp.ts[tn].hsn, fhp.ts[tn].maio);
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007473 tr_cd := tr_ChanDescH1(cd.chan_nr, tr_maio_hsn);
7474 } else {
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007475 tr_cd := tr_ChanDescH0(cd.chan_nr, fhp.arfcn);
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007476 }
7477
7478 if (not match(cd, tr_cd)) {
7479 setverdict(fail, "Channel Description IE does not match: ",
7480 cd, " vs expected ", tr_cd);
7481 }
7482}
7483
7484/* Make sure that the given Mobile Allocation IE matches the hopping configuration */
7485private function f_TC_fh_params_match_ma(in FHParamsTrx fhp, uint3_t tn,
7486 in MobileAllocationLV ma)
7487{
7488 var template MobileAllocationLV tr_ma := f_TC_fh_params_gen_tr_ma(fhp, tn, ma);
7489
7490 if (not match(ma, tr_ma)) {
7491 setverdict(fail, "Mobile Allocation IE does not match (tn := ",
7492 tn, "): ", ma, " vs expected: ", tr_ma);
7493 } else {
7494 setverdict(pass);
7495 }
7496}
7497
7498private function f_TC_fh_params_gen_tr_ma(in FHParamsTrx fhp, uint3_t tn,
7499 in MobileAllocationLV ma)
7500return template MobileAllocationLV {
7501 /* Mobile Allocation IE is expected to be empty if hopping is not enabled */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007502 if (not fhp.ts[tn].enabled) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007503 return { len := 0, ma := ''B };
7504 }
7505
7506 var bitstring full_mask := f_pad_bit(''B, 1024, '0'B);
7507 var bitstring slot_mask := f_pad_bit(''B, 1024, '0'B);
7508 var bitstring ma_mask := ''B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007509
7510 /* Compose the full bit-mask (all channels, up to 1024 entries) */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007511 for (var integer i := 0; i < lengthof(fhp.ts); i := i + 1) {
7512 for (var integer j := 0; j < lengthof(fhp.ts[i].ma); j := j + 1) {
7513 if (full_mask[fhp.ts[i].ma[j]] == '1'B)
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007514 { continue; }
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007515 full_mask[fhp.ts[i].ma[j]] := '1'B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007516 }
7517 }
7518
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007519 /* Take ARFCN of the TRX itself into account */
7520 full_mask[fhp.arfcn] := '1'B;
7521
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007522 /* Compose a bit-mask for the given timeslot number */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007523 for (var integer i := 0; i < lengthof(fhp.ts[tn].ma); i := i + 1) {
7524 slot_mask[fhp.ts[tn].ma[i]] := '1'B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007525 }
7526
7527 /* Finally, compose the Mobile Allocation bit-mask */
Vadim Yanitskiy3e997362020-09-05 21:08:34 +07007528 for (var integer i := 1; i < lengthof(full_mask); i := i + 1) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007529 if (full_mask[i] != '1'B)
7530 { continue; }
7531
7532 /* FIXME: ma_mask := ma_mask & slot_mask[i]; // triggers a bug in TITAN */
7533 if (slot_mask[i] == '1'B) {
7534 ma_mask := ma_mask & '1'B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007535 } else {
7536 ma_mask := ma_mask & '0'B;
7537 }
7538 }
7539
Vadim Yanitskiy3e997362020-09-05 21:08:34 +07007540 /* ARFCN 0 (if present) goes to the last position of the bit-mask */
7541 if (full_mask[0] == '1'B) {
7542 /* FIXME: ma_mask := ma_mask & slot_mask[0]; // triggers a bug in TITAN */
7543 if (slot_mask[0] == '1'B) {
7544 ma_mask := ma_mask & '1'B;
7545 } else {
7546 ma_mask := ma_mask & '0'B;
7547 }
7548 }
7549
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007550 /* Ensure that ma_mask is octet-aligned */
Vadim Yanitskiy2aa02522020-09-06 14:05:23 +07007551 var integer ma_mask_len := (lengthof(ma_mask) + 8 - 1) / 8;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007552 ma_mask := f_pad_bit(ma_mask, ma_mask_len * 8, '0'B);
7553
7554 return { len := ma_mask_len, ma := ma_mask };
7555}
7556
7557/* Configure the hopping parameters in accordance with the given record */
7558private function f_TC_fh_params_set(in FHParamsTrx fhp,
7559 uint8_t bts_nr := 0,
7560 uint8_t trx_nr := 0)
7561runs on test_CT {
7562 /* Enter the configuration node for the given BTS/TRX numbers */
7563 f_vty_enter_cfg_trx(BSCVTY, bts_nr, trx_nr);
7564
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007565 f_vty_transceive(BSCVTY, "arfcn " & int2str(fhp.arfcn));
7566
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007567 for (var integer tn := 0; tn < lengthof(fhp.ts); tn := tn + 1) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007568 f_vty_transceive(BSCVTY, "timeslot " & int2str(tn));
7569
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007570 if (not fhp.ts[tn].enabled) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007571 f_vty_transceive(BSCVTY, "hopping enabled 0");
7572 f_vty_transceive(BSCVTY, "exit"); /* go back */
7573 continue;
7574 }
7575
7576 /* Configure HSN / MAIO values */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007577 f_vty_transceive(BSCVTY, "hopping sequence-number " & int2str(fhp.ts[tn].hsn));
7578 f_vty_transceive(BSCVTY, "hopping maio " & int2str(fhp.ts[tn].maio));
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007579
7580 /* Configure the Mobile Allocation (hopping channels) */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007581 for (var integer i := 0; i < lengthof(fhp.ts[tn].ma); i := i + 1) {
7582 f_vty_transceive(BSCVTY, "hopping arfcn add " & int2str(fhp.ts[tn].ma[i]));
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007583 }
7584
7585 f_vty_transceive(BSCVTY, "hopping enabled 1");
7586 f_vty_transceive(BSCVTY, "exit"); /* go back */
7587 }
7588
7589 f_vty_transceive(BSCVTY, "end");
7590}
7591
7592/* Disable frequency hopping on all timeslots */
7593private function f_TC_fh_params_unset(in FHParamsTrx fhp,
7594 uint8_t bts_nr := 0,
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007595 uint8_t trx_nr := 0,
7596 GsmArfcn arfcn := 871)
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007597runs on test_CT {
7598 /* Enter the configuration node for the given BTS/TRX numbers */
7599 f_vty_enter_cfg_trx(BSCVTY, bts_nr, trx_nr);
7600
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007601 f_vty_transceive(BSCVTY, "arfcn " & int2str(arfcn));
7602
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007603 for (var integer tn := 0; tn < lengthof(fhp.ts); tn := tn + 1) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007604 f_vty_transceive(BSCVTY, "timeslot " & int2str(tn));
7605
7606 /* Delete all ARFCNs from the Mobile Allocation (if any) */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007607 for (var integer i := 0; i < lengthof(fhp.ts[tn].ma); i := i + 1) {
7608 f_vty_transceive(BSCVTY, "hopping arfcn del " & int2str(fhp.ts[tn].ma[i]));
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007609 }
7610
7611 f_vty_transceive(BSCVTY, "hopping enabled 0");
7612 f_vty_transceive(BSCVTY, "exit"); /* go back */
7613 }
7614
7615 f_vty_transceive(BSCVTY, "end");
7616 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7617}
7618
7619/* Verify presence and correctness of the hopping parameters (HSN, MAIO)
7620 * in the Channel Identification IE of the RSL CHANnel ACTIVation message. */
7621testcase TC_fh_params_chan_activ() runs on test_CT {
7622 var FHParamsTrx fhp := f_TC_fh_params_gen();
7623 var RSL_Message rsl_msg;
7624 var RSL_IE_Body ie;
7625
7626 f_init_vty();
7627
7628 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
7629 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7630
7631 f_init(1);
7632
7633 /* CS domain: 3 (SDCCH/4+CBCH) + 4 (TCH/F) + 2 (TCH/H) channels available */
7634 for (var integer i := 0; i < 9; i := i + 1) {
7635 f_ipa_tx(0, ts_RSL_CHAN_RQD(f_rnd_ra_cs(), 23));
7636 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7637
7638 /* Make sure that Channel Identification IE is present */
7639 if (not f_rsl_find_ie(rsl_msg, RSL_IE_CHAN_IDENT, ie)) {
7640 setverdict(fail, "RSL Channel Identification IE is absent");
7641 continue;
7642 }
7643
7644 /* Make sure that hopping parameters (HSN/MAIO) match */
7645 f_TC_fh_params_match_chan_desc(fhp, ie.chan_ident.ch_desc.v);
7646
7647 /* "Mobile Allocation shall be included but empty" - let's check this */
7648 if (ie.chan_ident.ma.v.len != 0) {
7649 setverdict(fail, "Mobile Allocation IE is not empty: ",
7650 ie.chan_ident.ma, ", despite it shall be");
7651 continue;
7652 }
7653 }
7654
7655 /* Disable frequency hopping */
7656 f_TC_fh_params_unset(fhp);
7657
Vadim Yanitskiy21726312020-09-04 01:45:36 +07007658 f_shutdown_helper();
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007659}
7660
7661/* Verify the hopping parameters (HSN, MAIO, MA) in (RR) Immediate Assignment */
7662testcase TC_fh_params_imm_ass() runs on test_CT {
7663 var FHParamsTrx fhp := f_TC_fh_params_gen();
7664 var RSL_Message rsl_msg;
7665 var RSL_IE_Body ie;
7666
7667 f_init_vty();
7668
7669 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
7670 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7671
7672 f_init(1);
7673
7674 /* CS domain: 3 (SDCCH/4+CBCH) + 4 (TCH/F) + 2 (TCH/H) channels available */
7675 for (var integer i := 0; i < 9; i := i + 1) {
7676 f_ipa_tx(0, ts_RSL_CHAN_RQD(f_rnd_ra_cs(), 23));
7677 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7678
7679 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(rsl_msg.ies[0].body.chan_nr, 33));
7680 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeC(RSL_MT_IMMEDIATE_ASSIGN_CMD));
7681
7682 /* Make sure that Full Immediate Assign Info IE is present */
7683 if (not f_rsl_find_ie(rsl_msg, RSL_IE_FULL_IMM_ASS_INFO, ie)) {
7684 setverdict(fail, "RSL Full Immediate Assign Info IE is absent");
7685 continue;
7686 }
7687
7688 /* Decode the actual Immediate Assignment message */
7689 var GsmRrMessage rr_msg := dec_GsmRrMessage(ie.full_imm_ass_info.payload);
7690 if (not match(rr_msg.header, t_RrHeader(IMMEDIATE_ASSIGNMENT, ?))) {
7691 setverdict(fail, "Failed to match Immediate Assignment: ", rr_msg);
7692 continue;
7693 }
7694
7695 /* Make sure that hopping parameters (HSN/MAIO) match */
7696 f_TC_fh_params_match_chan_desc(fhp, rr_msg.payload.imm_ass.chan_desc);
7697
7698 /* Make sure that the Mobile Allocation IE matches */
7699 f_TC_fh_params_match_ma(fhp, rr_msg.payload.imm_ass.chan_desc.chan_nr.tn,
7700 rr_msg.payload.imm_ass.mobile_allocation);
7701 }
7702
7703 /* Disable frequency hopping */
7704 f_TC_fh_params_unset(fhp);
Philipp Maier82812002020-08-13 18:48:27 +02007705
Vadim Yanitskiy21726312020-09-04 01:45:36 +07007706 f_shutdown_helper();
Philipp Maier82812002020-08-13 18:48:27 +02007707}
7708
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07007709/* Verify the hopping parameters (HSN, MAIO, MA) in (RR) Assignment Command */
7710testcase TC_fh_params_assignment_cmd() runs on test_CT {
7711 var FHParamsTrx fhp := f_TC_fh_params_gen();
7712 var RSL_Message rsl_msg;
7713 var RSL_IE_Body ie;
7714
7715 f_init_vty();
7716
7717 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
7718 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7719
7720 f_init(1);
7721
7722 /* HACK: work around "Couldn't find Expect for CRCX" */
7723 vc_MGCP.stop;
7724
7725 var template PDU_BSSAP ass_cmd := f_gen_ass_req();
7726 ass_cmd.pdu.bssmap.assignmentRequest.codecList := ts_BSSMAP_IE_CodecList({ts_CodecFR});
7727
7728 /* CS domain (TCH): 4 (TCH/F) + 2 (TCH/H) channels available
7729 * NOTE: only 3 SDCCH/4 channels are available on CCCH+SDCCH4+CBCH */
7730 for (var integer i := 0; i < 3; i := i + 1) {
7731 /* Establish a dedicated channel, so we can trigger (late) TCH assignment */
7732 var DchanTuple dt := f_est_dchan(f_rnd_ra_cs(), 23, f_rnd_octstring(16));
7733
7734 /* Send a BSSMAP Assignment Command, expect CHANnel ACTIVation */
7735 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ass_cmd));
7736 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7737
7738 /* ACKnowledge CHANnel ACTIVation, expect RSL DATA REQuest */
7739 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(rsl_msg.ies[0].body.chan_nr, 33));
7740 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeR(RSL_MT_DATA_REQ));
7741
7742 /* Make sure that L3 Information IE is present */
7743 if (not f_rsl_find_ie(rsl_msg, RSL_IE_L3_INFO, ie)) {
7744 setverdict(fail, "RSL L3 Information IE is absent");
7745 continue;
7746 }
7747
7748 /* Decode the L3 message and make sure it is (RR) Assignment Command */
7749 var GsmRrL3Message l3_msg := dec_GsmRrL3Message(ie.l3_info.payload);
7750 if (not match(l3_msg.header, t_RrL3Header(ASSIGNMENT_COMMAND))) {
7751 setverdict(fail, "Failed to match Assignment Command: ", l3_msg);
7752 continue;
7753 }
7754
7755 /* Make sure that hopping parameters (HSN/MAIO) match */
7756 var ChannelDescription chan_desc := l3_msg.payload.ass_cmd.chan_desc;
7757 f_TC_fh_params_match_chan_desc(fhp, chan_desc);
7758
7759 /* Make sure that Cell Channel Description IE is present if FH is enabled */
7760 if (chan_desc.h and not ispresent(l3_msg.payload.ass_cmd.cell_chan_desc)) {
Vadim Yanitskiy38d069d2020-09-02 17:18:57 +07007761 setverdict(fail, "FH enabled, but Cell Channel Description IE is absent");
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07007762 continue;
7763 }
7764
7765 /* Make sure that the Mobile Allocation IE matches (if present) */
7766 var boolean ma_present := ispresent(l3_msg.payload.ass_cmd.mobile_allocation);
7767 if (chan_desc.h and ma_present) {
7768 f_TC_fh_params_match_ma(fhp, chan_desc.chan_nr.tn,
7769 l3_msg.payload.ass_cmd.mobile_allocation.v);
7770 } else if (chan_desc.h and not ma_present) {
7771 setverdict(fail, "FH enabled, but Mobile Allocation IE is absent");
7772 continue;
7773 } else if (not chan_desc.h and ma_present) {
7774 setverdict(fail, "FH disabled, but Mobile Allocation IE is present");
7775 continue;
7776 }
7777 }
7778
7779 /* Give the IUT some time to release all channels */
7780 f_sleep(3.0);
7781
7782 /* Disable frequency hopping */
7783 f_TC_fh_params_unset(fhp);
7784
Vadim Yanitskiy21726312020-09-04 01:45:36 +07007785 f_shutdown_helper();
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07007786}
7787
Vadim Yanitskiy8f5430d2020-09-02 18:51:38 +07007788/* Verify the hopping parameters (HSN, MAIO, MA) in (RR) Handover Command */
7789private function f_TC_fh_params_handover_cmd(in FHParamsTrx fhp)
7790runs on test_CT {
7791 var RSL_Message rsl_msg;
7792 var RSL_IE_Body ie;
7793 var DchanTuple dt;
7794
7795 /* Establish a dedicated channel, so we can trigger handover */
7796 dt := f_est_dchan(f_rnd_ra_cs(), 23, f_rnd_octstring(16));
7797
7798 /* Trigger handover from BTS0 to BTS1 */
7799 f_bts_0_cfg(BSCVTY, { "neighbor bts 1" });
7800 f_vty_handover(BSCVTY, 0, 0, dt.rsl_chan_nr, 1);
7801
7802 /* Expect RSL CHANnel ACTIVation on BTS1/TRX0/TS1 */
7803 rsl_msg := f_exp_ipa_rx(1, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7804
7805 /* ACKnowledge channel activation and expect (RR) Handover Command */
7806 f_ipa_tx(1, ts_RSL_CHAN_ACT_ACK(rsl_msg.ies[0].body.chan_nr, 33));
7807 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeR(RSL_MT_DATA_REQ));
7808
7809 /* Make sure that L3 Information IE is present */
7810 if (not f_rsl_find_ie(rsl_msg, RSL_IE_L3_INFO, ie)) {
7811 setverdict(fail, "RSL L3 Information IE is absent");
7812 return;
7813 }
7814
7815 /* Decode the L3 message and make sure it is (RR) Handover Command */
7816 var GsmRrL3Message l3_msg := dec_GsmRrL3Message(ie.l3_info.payload);
7817 if (not match(l3_msg.header, t_RrL3Header(HANDOVER_COMMAND))) {
7818 setverdict(fail, "Failed to match Handover Command: ", l3_msg);
7819 return;
7820 }
7821
7822 /* Make sure that we've got SDCCH/8 on TS1 (expected to be hopping) */
7823 var ChannelDescription chan_desc := l3_msg.payload.ho_cmd.chan_desc;
7824 if (not match(chan_desc.chan_nr, t_RslChanNr_SDCCH8(1, ?))) {
7825 setverdict(fail, "Unexpected channel number: ", chan_desc.chan_nr);
7826 return;
7827 }
7828
7829 /* Make sure that hopping parameters (HSN/MAIO) match */
7830 f_TC_fh_params_match_chan_desc(fhp, chan_desc);
7831
7832 /* Make sure that Cell Channel Description IE is present */
7833 if (not ispresent(l3_msg.payload.ho_cmd.cell_chan_desc)) {
7834 setverdict(fail, "FH enabled, but Cell Channel Description IE is absent");
7835 return;
7836 }
7837
7838 /* Make sure that the Mobile Allocation (after time) IE is present and matches */
7839 var boolean ma_present := ispresent(l3_msg.payload.ho_cmd.mobile_allocation);
7840 if (ma_present) {
7841 f_TC_fh_params_match_ma(fhp, chan_desc.chan_nr.tn,
7842 l3_msg.payload.ho_cmd.mobile_allocation.v);
7843 } else {
7844 setverdict(fail, "FH enabled, but Mobile Allocation IE is absent");
7845 return;
7846 }
7847}
7848testcase TC_fh_params_handover_cmd() runs on test_CT {
7849 var FHParamsTrx fhp := f_TC_fh_params_gen();
7850
7851 f_init_vty();
7852
7853 /* (Re)configure TS0 as BCCH and TS1 as SDCCH8 on BTS1/TRX0 */
7854 f_vty_enter_cfg_trx(BSCVTY, bts := 1, trx := 0);
7855
7856 f_vty_transceive(BSCVTY, "timeslot 0");
7857 f_vty_transceive(BSCVTY, "phys_chan_config ccch");
7858 f_vty_transceive(BSCVTY, "exit"); /* go back */
7859
7860 f_vty_transceive(BSCVTY, "timeslot 1");
7861 f_vty_transceive(BSCVTY, "phys_chan_config sdcch8");
7862 f_vty_transceive(BSCVTY, "end"); /* we're done */
7863
7864 f_TC_fh_params_set(fhp, 1); /* Enable frequency hopping on BTS1 */
7865 f_vty_transceive(BSCVTY, "drop bts connection 1 oml");
7866
7867 f_init(2);
7868
7869 f_TC_fh_params_handover_cmd(fhp);
7870
7871 /* Disable frequency hopping on BTS1 */
7872 f_TC_fh_params_unset(fhp, 1);
7873
7874 /* (Re)configure TS0 as CCCH+SDCCH4+CBCH and TS1 as TCH/F */
7875 f_vty_enter_cfg_trx(BSCVTY, bts := 1, trx := 0);
7876
7877 f_vty_transceive(BSCVTY, "timeslot 0");
7878 f_vty_transceive(BSCVTY, "phys_chan_config ccch+sdcch4+cbch");
7879 f_vty_transceive(BSCVTY, "exit"); /* go back */
7880
7881 f_vty_transceive(BSCVTY, "timeslot 1");
7882 f_vty_transceive(BSCVTY, "phys_chan_config tch/f");
7883 f_vty_transceive(BSCVTY, "end"); /* we're done */
7884
7885 f_shutdown_helper();
7886}
7887
Vadim Yanitskiyca974032020-09-01 07:20:39 +07007888/* Verify the hopping parameters in System Information Type 4 */
7889testcase TC_fh_params_si4_cbch() runs on test_CT {
7890 var FHParamsTrx fhp := f_TC_fh_params_gen(tr_tn := 1);
7891 var ASP_RSL_Unitdata rx_rsl_ud;
7892 timer T := 5.0;
7893
7894 f_init_vty();
7895
7896 /* (Re)configure TS0 as BCCH and TS1 as SDCCH8+CBCH */
7897 f_vty_enter_cfg_trx(BSCVTY, trx := 0);
7898
7899 f_vty_transceive(BSCVTY, "timeslot 0");
7900 f_vty_transceive(BSCVTY, "phys_chan_config ccch");
7901 f_vty_transceive(BSCVTY, "exit"); /* go back */
7902
7903 f_vty_transceive(BSCVTY, "timeslot 1");
7904 f_vty_transceive(BSCVTY, "phys_chan_config sdcch8+cbch");
7905 f_vty_transceive(BSCVTY, "end"); /* we're done */
7906
7907 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
7908 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7909
7910 f_init(1);
7911
7912 T.start;
7913 alt {
7914 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_BCCH_INFO(RSL_SYSTEM_INFO_4))) -> value rx_rsl_ud {
7915 var RSL_IE_Body ie := rx_rsl_ud.rsl.ies[2].body; /* FULL BCCH Information IE */
7916 var SystemInformation si := dec_SystemInformation(ie.other.payload);
7917
7918 /* Make sure that what we decoded is System Information Type 4 */
7919 if (si.header.message_type != SYSTEM_INFORMATION_TYPE_4) {
7920 setverdict(fail, "RSL FULL BCCH Information IE contains: ", si);
7921 repeat;
7922 }
7923
7924 /* Make sure that CBCH Channel Description IE is present */
7925 if (not ispresent(si.payload.si4.cbch_chan_desc)) {
7926 setverdict(fail, "CBCH Channel Description IE is absent");
7927 break;
7928 }
7929
7930 /* Finally, check the hopping parameters (HSN, MAIO) */
7931 var ChannelDescription chan_desc := si.payload.si4.cbch_chan_desc.v;
7932 f_TC_fh_params_match_chan_desc(fhp, chan_desc);
7933
7934 /* 3GPP TS 44.018, section 9.1.36.2 "CBCH Mobile Allocation":
7935 * The CBCH Mobile Allocation IE *shall* be present if FH is enabled. */
7936 if (chan_desc.h and not ispresent(si.payload.si4.cbch_mobile_alloc)) {
7937 setverdict(fail, "FH enabled, but Mobile Allocation IE is absent");
7938 break;
7939 } else if (chan_desc.h and ispresent(si.payload.si4.cbch_mobile_alloc)) {
7940 f_TC_fh_params_match_ma(fhp, chan_desc.chan_nr.tn,
7941 si.payload.si4.cbch_mobile_alloc.v);
7942 }
7943 }
7944 [] IPA_RSL[0].receive { repeat; }
7945 [] T.timeout {
7946 setverdict(fail, "Timeout waiting for RSL BCCH INFOrmation (SI4)");
7947 }
7948 }
7949
7950 /* Disable frequency hopping */
7951 f_TC_fh_params_unset(fhp);
7952
Vadim Yanitskiy8bc46012020-09-06 12:38:01 +07007953 /* (Re)configure TS0 as CCCH+SDCCH4+CBCH and TS1 as TCH/F */
Vadim Yanitskiyca974032020-09-01 07:20:39 +07007954 f_vty_enter_cfg_trx(BSCVTY, trx := 0);
7955
7956 f_vty_transceive(BSCVTY, "timeslot 0");
Vadim Yanitskiy8bc46012020-09-06 12:38:01 +07007957 f_vty_transceive(BSCVTY, "phys_chan_config ccch+sdcch4+cbch");
Vadim Yanitskiyca974032020-09-01 07:20:39 +07007958 f_vty_transceive(BSCVTY, "exit"); /* go back */
7959
7960 f_vty_transceive(BSCVTY, "timeslot 1");
7961 f_vty_transceive(BSCVTY, "phys_chan_config tch/f");
7962 f_vty_transceive(BSCVTY, "end"); /* we're done */
7963
Vadim Yanitskiy21726312020-09-04 01:45:36 +07007964 f_shutdown_helper();
Vadim Yanitskiyca974032020-09-01 07:20:39 +07007965}
7966
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02007967template (value) PDU_BSSAP_LE ts_BSSMAP_LE_BSSLAP(template (value) BSSLAP_PDU bsslap)
7968 := ts_BSSMAP_LE_ConnInfo(BSSMAP_LE_PROT_BSSLAP, data := enc_BSSLAP_PDU(valueof(bsslap)));
7969
7970private function f_match_bsslap(PDU_BSSAP_LE got_bsslap_msg,
7971 template (present) BSSLAP_PDU expect_bsslap)
7972{
7973 var BSSLAP_PDU bsslap := dec_BSSLAP_PDU(got_bsslap_msg.pdu.bssmap.co_info.bsslap_apdu.data);
7974 if (not match(bsslap, expect_bsslap)) {
7975 log("EXPECTING BSSLAP: ", expect_bsslap);
7976 log("GOT BSSLAP: ", bsslap);
7977 setverdict(fail, "BSSLAP is not as expected");
7978 mtc.stop;
7979 }
7980 setverdict(pass);
7981}
7982
7983/* GAD: this is an Ellipsoid point with uncertainty circle, encoded as in 3GPP TS 23.032 §7.3.2. */
7984const octetstring gad_ell_point_unc_circle := '10b0646d0d5f6627'O;
7985
7986private function f_expect_bsslap(template (present) BSSLAP_PDU expect_rx_bsslap) runs on MSC_ConnHdlr {
7987 var PDU_BSSAP_LE rx_bsslap;
7988 BSSAP_LE.receive(tr_BSSMAP_LE_ConnInfo(BSSMAP_LE_PROT_BSSLAP, ?)) -> value(rx_bsslap);
7989 f_match_bsslap(rx_bsslap, expect_rx_bsslap);
7990}
7991
7992/* With an active lchan, start BSSMAP Perform Location Request on A interface, starting BSSMAP-LE Perform Location
7993 * Request on Lb interface. Either with or without the SMLC doing a BSSLAP TA Request. */
7994private function f_lcs_loc_req_for_active_ms(boolean do_ta_request := false) runs on MSC_ConnHdlr {
7995 f_sleep(1.0);
7996
7997 f_establish_fully(omit, omit);
7998 f_bssap_le_register_imsi(g_pars.imsi, omit);
7999
8000 BSSAP.send(valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
8001 ts_CellId_CGI('262'H, '42'H, 23, 42))));
8002
8003 var PDU_BSSAP_LE plr;
8004 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
8005
8006 if (not do_ta_request) {
8007 /* verify TA Layer 3 in APDU. First the APDU type (BSSLAP), then the BSSLAP data contents. */
8008 var template BSSMAP_LE_IE_APDU expect_apdu := tr_BSSMAP_LE_APDU(BSSMAP_LE_PROT_BSSLAP, ?);
8009 if (not match(plr.pdu.bssmap.perf_loc_req.bsslap_apdu, expect_apdu)) {
8010 log("EXPECTING BSSMAP-LE APDU IE ", expect_apdu);
8011 log("GOT BSSMAP-LE APDU IE ", plr.pdu.bssmap.perf_loc_req.bsslap_apdu);
8012 setverdict(fail, "BSSMAP-LE APDU IE is not as expected");
8013 mtc.stop;
8014 }
8015 var template BSSLAP_PDU expect_ta_layer3 := tr_BSSLAP_TA_Layer3(tr_BSSLAP_IE_TA(0));
8016 var BSSLAP_PDU bsslap := dec_BSSLAP_PDU(plr.pdu.bssmap.perf_loc_req.bsslap_apdu.data);
8017 if (not match(bsslap, expect_ta_layer3)) {
8018 log("EXPECTING BSSLAP TA Layer 3: ", expect_ta_layer3);
8019 log("GOT BSSLAP: ", bsslap);
8020 setverdict(fail, "BSSLAP is not as expected");
8021 mtc.stop;
8022 }
8023 /* OsmoBSC directly sent the TA as BSSLAP APDU in the BSSMAP-LE Perform Location Request to the SMLC. The SMLC
8024 * has no need to request the TA from the BSC and directly responds. */
8025 } else {
8026 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
8027 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
8028 f_expect_bsslap(tr_BSSLAP_TA_Resp(?, ?));
8029 }
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 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(tr_BSSMAP_IE_LocationEstimate(gad_ell_point_unc_circle)));
8035
8036 /* The LCS was using an active A-interface conn. It should still remain active after this. */
8037 f_mo_l3_transceive();
8038
8039 f_perform_clear(RSL);
8040
8041 f_sleep(2.0);
8042 setverdict(pass);
8043}
8044
8045/* With an active lchan, start BSSMAP Perform Location Request on A interface, starting BSSMAP-LE Perform Location
8046 * Request on Lb interface. Without the SMLC doing a BSSLAP TA Request. */
8047private function f_tc_lcs_loc_req_for_active_ms(charstring id) runs on MSC_ConnHdlr {
8048 f_lcs_loc_req_for_active_ms(false);
8049}
8050testcase TC_lcs_loc_req_for_active_ms() runs on test_CT {
8051 var MSC_ConnHdlr vc_conn;
8052 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8053
8054 f_init(1, true);
8055 f_sleep(1.0);
8056 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_active_ms), pars);
8057 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008058 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008059}
8060
8061/* With an active lchan, start BSSMAP Perform Location Request on A interface, starting BSSMAP-LE Perform Location
8062 * Request on Lb interface. With the SMLC doing a BSSLAP TA Request. */
8063private function f_tc_lcs_loc_req_for_active_ms_ta_req(charstring id) runs on MSC_ConnHdlr {
8064 f_lcs_loc_req_for_active_ms(true);
8065}
8066testcase TC_lcs_loc_req_for_active_ms_ta_req() runs on test_CT {
8067 var MSC_ConnHdlr vc_conn;
8068 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8069
8070 f_init(1, true);
8071 f_sleep(1.0);
8072 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_active_ms_ta_req), pars);
8073 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008074 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008075}
8076
8077/* Clear the A-interface conn only, without doing anything on Abis. Useful for LCS, for cases where there is only an A
8078 * conn without an active lchan. */
8079private function f_clear_A_conn() runs on MSC_ConnHdlr
8080{
8081 var BssmapCause cause := 0;
8082 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
8083 BSSAP.receive(tr_BSSMAP_ClearComplete);
8084 BSSAP.send(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_REQ);
8085
8086 timer no_more_bssap := 5.0;
8087 no_more_bssap.start;
8088 alt {
8089 [] no_more_bssap.timeout { break; }
8090 [] BSSAP.receive(tr_BSSAP_BSSMAP) {
8091 setverdict(fail, "Expected no more BSSAP after Clear Complete");
8092 mtc.stop;
8093 }
8094 }
8095 setverdict(pass);
8096}
8097
8098/* Verify that the A-interface connection is still working, and then clear it, without doing anything on Abis. Useful
8099 * for LCS, for cases where there is only an A conn without an active lchan. */
8100private function f_verify_active_A_conn_and_clear() runs on MSC_ConnHdlr
8101{
8102 f_logp(BSCVTY, "f_verify_active_A_conn_and_clear: test A link, then clear");
8103
8104 /* When an lchan is active, we can send some L3 data from the BTS side and verify that it shows up on the other
8105 * side towards the MSC. When there is no lchan, this is not possible. To probe whether the A-interface
8106 * connection is still up, we need something that echos back on the A-interface. Another LCS request! */
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 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?));
8110
8111 /* Right, the Perform Location Request showed up on Lb, now we can clear the A conn. */
8112 f_clear_A_conn();
8113 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocAbort(BSSMAP_LE_LCS_CAUSE_REQUEST_ABORTED));
8114 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
8115}
8116
8117/* With *no* active lchan, start BSSMAP Perform Location Request on A interface, starting BSSMAP-LE Perform Location
8118 * Request on Lb interface. BSC will Page for the subscriber as soon as we (virtual SMLC) request the TA via BSSLAP.
8119 */
8120private function f_tc_lcs_loc_req_for_idle_ms(charstring id) runs on MSC_ConnHdlr {
8121 f_sleep(1.0);
8122
8123 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
8124 f_bssap_le_register_imsi(g_pars.imsi, omit);
8125
8126 /* Register to receive the Paging Command */
8127 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
8128 g_chan_nr := new_chan_nr;
8129 f_rslem_register(0, g_chan_nr);
8130
8131 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
8132 valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
8133 ts_CellId_CGI('001'H, '01'H, 1, 0)))));
8134 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
8135
8136 var PDU_BSSAP_LE plr;
8137 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
8138
8139 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
8140 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
8141
8142 /* OsmoBSC needs to Page */
8143 RSL.receive(tr_RSL_PAGING_CMD(tr_MI_IMSI(g_pars.imsi)));
8144 f_logp(BSCVTY, "got Paging Command");
8145
8146 /* MS requests channel. Since the Paging was for LCS, the Paging Response does not trigger a Complete Layer 3 to
8147 * the MSC, and releases the lchan directly. */
8148 f_perform_compl_l3(RSL, ts_PAG_RESP(valueof(ts_MI_IMSI_LV(g_pars.imsi))), do_clear := false, expect_bssmap_l3 := false);
8149 f_expect_lchan_rel(RSL);
8150
8151 /* From the Paging Response, the TA is now known to the BSC, and it responds to the SMLC. */
8152
8153 f_expect_bsslap(tr_BSSLAP_TA_Resp(?, ?));
8154
8155 /* SMLC got the TA from the BSC, now responds with geo information data. */
8156 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(gad_ell_point_unc_circle, omit));
8157 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
8158
8159 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(tr_BSSMAP_IE_LocationEstimate(gad_ell_point_unc_circle)));
8160
8161 /* The lchan is gone, the A-interface conn was created for the LCS only.
8162 * Still it is clearly the MSC's job to decide whether to tear down the conn or not. */
8163 f_verify_active_A_conn_and_clear();
8164
8165 f_sleep(2.0);
8166 setverdict(pass);
8167}
8168testcase TC_lcs_loc_req_for_idle_ms() runs on test_CT {
8169 var MSC_ConnHdlr vc_conn;
8170 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8171
8172 f_init(1, true);
8173 f_sleep(1.0);
8174
8175 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
8176 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
8177
8178 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_idle_ms), pars);
8179 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008180 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008181}
8182
8183/* With no active lchan, start BSSMAP Perform Location Request on A interface, but omit IMSI; expect failure response.
8184 */
8185private function f_tc_lcs_loc_req_no_subscriber(charstring id) runs on MSC_ConnHdlr {
8186 f_sleep(1.0);
8187
8188 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
8189 f_bssap_le_register_imsi(g_pars.imsi, omit);
8190
8191 /* provoke an abort by omitting both IMSI and IMEI */
8192 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
8193 valueof(ts_BSSMAP_Perform_Location_Request(omit,
8194 ts_CellId_CGI('262'H, '42'H, 23, 42)))));
8195 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
8196
8197 /* BSC tells MSC about failure */
8198 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(
8199 locationEstimate := omit, positioningData := omit,
8200 lCS_Cause := tr_BSSMAP_LcsCause(BSSMAP_LCS_CAUSE_DATA_MISSING_IN_REQ)));
8201
8202 /* There is no lchan. Still the MSC's job to decide whether to tear down the conn or not. */
8203 f_verify_active_A_conn_and_clear();
8204
8205 f_sleep(2.0);
8206 setverdict(pass);
8207}
8208testcase TC_lcs_loc_req_no_subscriber() runs on test_CT {
8209 var MSC_ConnHdlr vc_conn;
8210 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8211
8212 f_init(1, true);
8213 f_sleep(1.0);
8214
8215 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
8216 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
8217
8218 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_no_subscriber), pars);
8219 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008220 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008221}
8222
8223/* With an active lchan, start a Perform Location Request on the A-interface, but virtual SMLC does not answer with
8224 * BSSMAP-LE Perform Location Response (before or after sending a BSSLAP TA Request) */
8225private function f_lcs_loc_req_for_active_ms_le_timeout(boolean do_ta) runs on MSC_ConnHdlr {
8226 f_sleep(1.0);
8227
8228 f_establish_fully(omit, omit);
8229 f_bssap_le_register_imsi(g_pars.imsi, omit);
8230
8231 BSSAP.send(valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
8232 ts_CellId_CGI('262'H, '42'H, 23, 42))));
8233
8234 var PDU_BSSAP_LE plr;
8235 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
8236
8237 if (do_ta) {
8238 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
8239 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
8240 f_expect_bsslap(tr_BSSLAP_TA_Resp(?, ?));
8241 }
8242
8243 /* SMLC fails to respond, BSC runs into timeout */
8244 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocAbort(BSSMAP_LE_LCS_CAUSE_SYSTEM_FAILURE));
8245 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
8246
8247 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(
8248 locationEstimate := omit, positioningData := omit,
8249 lCS_Cause := tr_BSSMAP_LcsCause(BSSMAP_LCS_CAUSE_SYSTEM_FAILURE)));
8250
8251 /* There is no lchan. Still the MSC's job to decide whether to tear down the conn or not. */
8252 f_verify_active_A_conn_and_clear();
8253
8254 f_sleep(2.0);
8255 setverdict(pass);
8256}
8257
8258/* With an active lchan, start a Perform Location Request on the A-interface, but virtual SMLC does not answer with
8259 * BSSMAP-LE Perform Location Response, without sending a BSSLAP TA Request. */
8260private function f_tc_lcs_loc_req_for_active_ms_le_timeout(charstring id) runs on MSC_ConnHdlr {
8261 f_lcs_loc_req_for_active_ms_le_timeout(false);
8262}
8263
8264testcase TC_lcs_loc_req_for_active_ms_le_timeout() runs on test_CT {
8265 var MSC_ConnHdlr vc_conn;
8266 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8267
8268 f_init(1, true);
8269 f_sleep(1.0);
8270 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_active_ms_le_timeout), pars);
8271 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008272 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008273}
8274
8275/* With an active lchan, start a Perform Location Request on the A-interface, but virtual SMLC does not answer with
8276 * BSSMAP-LE Perform Location Response, after sending a BSSLAP TA Request. */
8277private function f_tc_lcs_loc_req_for_active_ms_le_timeout2(charstring id) runs on MSC_ConnHdlr {
8278 f_lcs_loc_req_for_active_ms_le_timeout(true);
8279}
8280
8281testcase TC_lcs_loc_req_for_active_ms_le_timeout2() runs on test_CT {
8282 var MSC_ConnHdlr vc_conn;
8283 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8284
8285 f_init(1, true);
8286 f_sleep(1.0);
8287 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_active_ms_le_timeout2), pars);
8288 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008289 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008290}
8291
8292/* With *no* active lchan, start a Perform Location Request, expecting that the MS will be Paged. */
8293private function f_tc_lcs_loc_req_for_idle_ms_no_pag_resp(charstring id) runs on MSC_ConnHdlr {
8294 f_sleep(1.0);
8295
8296 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
8297 f_bssap_le_register_imsi(g_pars.imsi, omit);
8298
8299 /* Register to receive the Paging Command */
8300 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
8301 g_chan_nr := new_chan_nr;
8302 f_rslem_register(0, g_chan_nr);
8303
8304 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
8305 valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
8306 ts_CellId_CGI('001'H, '01'H, 1, 0)))));
8307 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
8308
8309 var PDU_BSSAP_LE plr;
8310 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
8311
8312 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
8313 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
8314
8315 /* OsmoBSC needs to Page */
8316 var PDU_BSSAP_LE rx_bsslap;
8317 alt {
8318 [] RSL.receive(tr_RSL_PAGING_CMD(tr_MI_IMSI(g_pars.imsi))) {
8319 f_logp(BSCVTY, "got Paging Command");
8320 repeat;
8321 }
8322 [] BSSAP_LE.receive(tr_BSSMAP_LE_ConnInfo(BSSMAP_LE_PROT_BSSLAP, ?)) -> value(rx_bsslap) {
8323 /* MS does not respond to Paging, TA Req runs into timeout. */
8324 f_match_bsslap(rx_bsslap, tr_BSSLAP_Abort(?));
8325 }
8326 }
8327
8328 /* SMLC responds with failure */
8329 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(omit, BSSMAP_LE_LCS_CAUSE_REQUEST_ABORTED));
8330 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
8331
8332 /* BSC tells MSC about failure */
8333 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(
8334 locationEstimate := omit, positioningData := omit,
8335 lCS_Cause := tr_BSSMAP_LcsCause(BSSMAP_LCS_CAUSE_REQUEST_ABORTED)));
8336
8337 /* There is no lchan. Still the MSC's job to decide whether to tear down the conn or not. */
8338 f_verify_active_A_conn_and_clear();
8339
8340 f_sleep(2.0);
8341 setverdict(pass);
8342}
8343testcase TC_lcs_loc_req_for_idle_ms_no_pag_resp() runs on test_CT {
8344 var MSC_ConnHdlr vc_conn;
8345 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8346
8347 f_init(1, true);
8348 f_sleep(1.0);
8349
8350 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
8351 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
8352
8353 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_idle_ms_no_pag_resp), pars);
8354 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008355 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008356}
8357
8358/* During an ongoing Location Request, the MS sends a CM Service Request. Expect the same A-conn to be re-used / taken
8359 * over. */
8360private function f_tc_cm_service_during_lcs_loc_req(charstring id) runs on MSC_ConnHdlr {
8361 f_sleep(1.0);
8362
8363 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
8364 f_bssap_le_register_imsi(g_pars.imsi, omit);
8365
8366 /* Register to receive the Paging Command */
8367 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
8368 g_chan_nr := new_chan_nr;
8369 f_rslem_register(0, g_chan_nr);
8370
8371 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
8372 valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
8373 ts_CellId_CGI('001'H, '01'H, 1, 0)))));
8374 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
8375
8376 var PDU_BSSAP_LE plr;
8377 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
8378
8379 /* As the A-interface conn was established for LCS, the MS coincidentally decides to issue a CM Service Request
8380 * and establish Layer 3. It should use the existing A-interface conn. */
8381 f_perform_compl_l3(RSL, valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV(g_pars.imsi)))),
8382 do_clear := false, expect_bssmap_l3 := true);
8383
8384 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
8385 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
8386
8387 /* OsmoBSC already has an lchan, no need to Page, just returns the TA */
8388 f_expect_bsslap(tr_BSSLAP_TA_Resp(?, ?));
8389
8390 /* SMLC got the TA from the BSC, now responds with geo information data. */
8391 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(gad_ell_point_unc_circle, omit));
8392 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
8393 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(tr_BSSMAP_IE_LocationEstimate(gad_ell_point_unc_circle)));
8394
8395 /* The lchan should still exist, it was from a CM Service Request. */
8396 f_mo_l3_transceive();
8397
8398 f_perform_clear(RSL);
8399
8400 f_sleep(2.0);
8401 setverdict(pass);
8402}
8403testcase TC_cm_service_during_lcs_loc_req() runs on test_CT {
8404 var MSC_ConnHdlr vc_conn;
8405 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8406
8407 f_init(1, true);
8408 f_sleep(1.0);
8409
8410 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
8411 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
8412
8413 vc_conn := f_start_handler(refers(f_tc_cm_service_during_lcs_loc_req), pars);
8414 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008415 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008416}
8417
8418/* During an ongoing Perform Location Request, do a Handover, an expect a BSSLAP Reset message from the BSC to indicate
8419 * the new lchan after handover. */
8420private function f_tc_ho_during_lcs_loc_req(charstring id) runs on MSC_ConnHdlr {
8421 f_sleep(1.0);
8422
8423 f_establish_fully(omit, omit);
8424 f_bssap_le_register_imsi(g_pars.imsi, omit);
8425
8426 BSSAP.send(valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
8427 ts_CellId_CGI('262'H, '42'H, 23, 42))));
8428
8429 var PDU_BSSAP_LE plr;
8430 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
8431
8432 /* SMLC ponders the Location Request, in the meantime the BSC decides to handover */
8433 f_bts_0_cfg(BSCVTY, {"neighbor bts 1"});
8434
8435 var HandoverState hs := {
8436 rr_ho_cmpl_seen := false,
8437 handover_done := false,
8438 old_chan_nr := -
8439 };
8440 /* issue hand-over command on VTY */
8441 f_vty_handover(BSCVTY, 0, 0, g_chan_nr, 1);
8442 /* temporarily suspend DChan processing on BTS1 to avoid race with RSLEM_register */
8443 f_rslem_suspend(RSL1_PROC);
8444
8445 /* From the MGW perspective, a handover is is characterized by
8446 * performing one MDCX operation with the MGW. So we expect to see
8447 * one more MDCX during handover. */
8448 g_media.mgcp_conn[0].mdcx_seen_exp := g_media.mgcp_conn[0].crcx_seen_exp + 1;
8449
8450 alt {
8451 [] as_handover(hs);
8452 }
8453
8454 var PDU_BSSAP_LE rx_bsslap;
8455
8456 interleave {
8457 /* Expect the BSC to inform the MSC about the handover */
8458 [] BSSAP.receive(tr_BSSMAP_HandoverPerformed);
8459
8460 /* Expect the BSC to inform the SMLC about the handover */
8461 [] BSSAP_LE.receive(tr_BSSMAP_LE_ConnInfo(BSSMAP_LE_PROT_BSSLAP, ?)) -> value(rx_bsslap) {
8462 f_match_bsslap(rx_bsslap, tr_BSSLAP_Reset(BSSLAP_CAUSE_INTRA_BSS_HO));
8463 }
8464 }
8465
8466 /* SMLC now responds with geo information data. */
8467 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(gad_ell_point_unc_circle, omit));
8468 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
8469 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(tr_BSSMAP_IE_LocationEstimate(gad_ell_point_unc_circle)));
8470
8471 /* lchan still active */
8472 f_mo_l3_transceive(RSL1);
8473
8474 /* MSC decides it is done now. */
8475 f_perform_clear(RSL1);
8476
8477 f_sleep(2.0);
8478 setverdict(pass);
8479}
8480testcase TC_ho_during_lcs_loc_req() runs on test_CT {
8481 var MSC_ConnHdlr vc_conn;
8482 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8483
8484 f_init(2, true);
8485 f_sleep(1.0);
8486 vc_conn := f_start_handler(refers(f_tc_ho_during_lcs_loc_req), pars);
8487 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008488 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008489}
8490
Neels Hofmeyrbf037052020-10-28 22:52:02 +00008491/* Attempt Complete Layer 3 without any MSC available (OS#4832) */
8492private function f_tc_no_msc(charstring id) runs on MSC_ConnHdlr {
8493 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
8494
8495 /* Also disable attach for the single connected MSC */
8496 f_vty_msc_allow_attach(BSCVTY, { false });
8497
8498 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) ));
8499 f_chan_est(g_pars.ra, l3_enc, g_pars.link_id, g_pars.fn);
8500
8501 /* No MSC is found, expecting a proper release on RSL */
8502 interleave {
8503 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
8504 f_logp(BSCVTY, "Got RSL RR Release");
8505 }
8506 [] RSL.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
8507 f_logp(BSCVTY, "Got RSL Deact SACCH");
8508 }
8509 [] RSL.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
8510 f_logp(BSCVTY, "Got RSL RF Chan Rel, sending Rel Ack");
8511 RSL.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
8512 }
8513 }
8514 setverdict(pass);
8515}
8516testcase TC_no_msc() runs on test_CT {
8517
8518 f_init(1, true);
8519 f_sleep(1.0);
8520 var MSC_ConnHdlr vc_conn;
8521 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8522
8523 f_ctrs_bsc_init(counternames_bsc_mscpool);
8524
8525 vc_conn := f_start_handler(refers(f_tc_no_msc), pars);
8526 vc_conn.done;
8527
8528 f_ctrs_bsc_add("mscpool:subscr:no_msc");
8529 f_ctrs_bsc_verify();
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008530 f_shutdown_helper();
Neels Hofmeyrbf037052020-10-28 22:52:02 +00008531}
8532
Harald Welte0ea2d5e2018-04-07 21:40:29 +02008533/* Dyn PDCH todo:
8534 * activate OSMO as TCH/F
8535 * activate OSMO as TCH/H
8536 * does the BSC-located PCU socket get the updated INFO?
8537 * what if no PCU is connected at the time?
8538 * is the info correct on delayed PCU (re)connect?
8539 */
Harald Welte94e0c342018-04-07 11:33:23 +02008540
Harald Welte28d943e2017-11-25 15:00:50 +01008541control {
Harald Welte898113b2018-01-31 18:32:21 +01008542 /* CTRL interface testing */
Harald Welte4003d112017-12-09 22:35:39 +01008543 execute( TC_ctrl_msc_connection_status() );
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01008544 execute( TC_ctrl_msc0_connection_status() );
Harald Welte96c94412017-12-09 03:12:45 +01008545 execute( TC_ctrl() );
Neels Hofmeyrf246a922020-05-13 02:27:10 +02008546 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_SCCPlite_SERVER) {
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +02008547 execute( TC_ctrl_location() );
8548 }
Harald Welte898113b2018-01-31 18:32:21 +01008549
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02008550 execute( TC_si_default() );
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02008551 execute( TC_si2quater_2_earfcns() );
8552 execute( TC_si2quater_3_earfcns() );
8553 execute( TC_si2quater_4_earfcns() );
8554 execute( TC_si2quater_5_earfcns() );
8555 execute( TC_si2quater_6_earfcns() );
Neels Hofmeyrad132f22020-07-08 02:20:16 +02008556 execute( TC_si2quater_12_earfcns() );
8557 execute( TC_si2quater_23_earfcns() );
8558 execute( TC_si2quater_32_earfcns() );
8559 execute( TC_si2quater_33_earfcns() );
8560 execute( TC_si2quater_42_earfcns() );
8561 execute( TC_si2quater_48_earfcns() );
8562 execute( TC_si2quater_49_earfcns() );
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02008563 execute( TC_si_acc_rotate() );
Alexander Couzens4ad3a352020-09-10 22:29:12 +02008564 execute( TC_si_acc_ramp_rotate() );
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02008565
Harald Welte898113b2018-01-31 18:32:21 +01008566 /* RSL DCHAN Channel ACtivation / Deactivation */
Harald Welteae026692017-12-09 01:03:01 +01008567 execute( TC_chan_act_noreply() );
Harald Welte4003d112017-12-09 22:35:39 +01008568 execute( TC_chan_act_counter() );
Harald Welteae026692017-12-09 01:03:01 +01008569 execute( TC_chan_act_ack_noest() );
Philipp Maier9c60a622020-07-09 15:08:46 +02008570 execute( TC_chan_act_ack_noest_emerg() );
Philipp Maier606f07d2020-08-12 17:21:58 +02008571 execute( TC_chan_rqd_emerg_deny() );
Harald Welteae026692017-12-09 01:03:01 +01008572 execute( TC_chan_act_ack_est_ind_noreply() );
8573 execute( TC_chan_act_ack_est_ind_refused() );
Harald Welte618ef642017-12-14 14:58:20 +01008574 execute( TC_chan_act_nack() );
Harald Welte799c97b2017-12-14 17:50:30 +01008575 execute( TC_chan_exhaustion() );
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07008576 execute( TC_chan_deact_silence() );
Harald Welte4003d112017-12-09 22:35:39 +01008577 execute( TC_chan_rel_rll_rel_ind() );
8578 execute( TC_chan_rel_conn_fail() );
8579 execute( TC_chan_rel_hard_clear() );
Pau Espin Pedrol841b90d2021-04-15 16:42:52 +02008580 execute( TC_chan_rel_last_eutran_plmn_hard_clear_no_csfb() );
8581 execute( TC_chan_rel_last_eutran_plmn_hard_clear_csfb() );
Harald Welte99787102019-02-04 10:41:36 +01008582 execute( TC_chan_rel_hard_clear_csfb() );
Harald Welted8c36cd2017-12-09 23:05:31 +01008583 execute( TC_chan_rel_hard_rlsd() );
Harald Welte550daf92018-06-11 19:22:13 +02008584 execute( TC_chan_rel_hard_rlsd_ms_dead() );
Harald Welte85804d42017-12-10 14:11:58 +01008585 execute( TC_chan_rel_a_reset() );
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01008586 execute( TC_chan_rel_sccp_tiar_timeout() );
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02008587 execute( TC_chan_rel_rr_cause() );
Harald Welte6f521d82017-12-11 19:52:02 +01008588
Harald Weltecfe2c962017-12-15 12:09:32 +01008589 execute( TC_outbound_connect() );
Harald Welte898113b2018-01-31 18:32:21 +01008590
8591 /* Assignment related */
Harald Welte16a4adf2017-12-14 18:54:01 +01008592 execute( TC_assignment_cic_only() );
Harald Welte235ebf12017-12-15 14:18:16 +01008593 execute( TC_assignment_csd() );
8594 execute( TC_assignment_ctm() );
8595 execute( TC_assignment_sign() );
Pau Espin Pedrol07866632020-09-03 19:10:55 +02008596 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
8597 execute( TC_assignment_aoip_tla_v6() );
8598 }
Harald Welte235ebf12017-12-15 14:18:16 +01008599 execute( TC_assignment_fr_a5_0() );
8600 execute( TC_assignment_fr_a5_1() );
Neels Hofmeyrf246a922020-05-13 02:27:10 +02008601 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welte8f67d1d2018-05-25 20:38:42 +02008602 execute( TC_assignment_fr_a5_1_codec_missing() );
8603 }
Harald Welte235ebf12017-12-15 14:18:16 +01008604 execute( TC_assignment_fr_a5_3() );
8605 execute( TC_assignment_fr_a5_4() );
Harald Welte3c86ea02018-05-10 22:28:05 +02008606 execute( TC_ciph_mode_a5_0() );
8607 execute( TC_ciph_mode_a5_1() );
8608 execute( TC_ciph_mode_a5_3() );
Harald Welte16a4adf2017-12-14 18:54:01 +01008609
Harald Welte60aa5762018-03-21 19:33:13 +01008610 execute( TC_assignment_codec_fr() );
8611 execute( TC_assignment_codec_hr() );
8612 execute( TC_assignment_codec_efr() );
8613 execute( TC_assignment_codec_amr_f() );
8614 execute( TC_assignment_codec_amr_h() );
Philipp Maier8a581d22019-03-26 18:32:48 +01008615
Neels Hofmeyrf246a922020-05-13 02:27:10 +02008616 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Philipp Maier8a581d22019-03-26 18:32:48 +01008617 execute( TC_assignment_codec_amr_f_S1() );
8618 execute( TC_assignment_codec_amr_h_S1() );
8619 execute( TC_assignment_codec_amr_f_S124() );
8620 execute( TC_assignment_codec_amr_h_S124() );
8621 execute( TC_assignment_codec_amr_f_S0() );
8622 execute( TC_assignment_codec_amr_f_S02() );
8623 execute( TC_assignment_codec_amr_f_S024() );
8624 execute( TC_assignment_codec_amr_f_S0247() );
8625 execute( TC_assignment_codec_amr_h_S0() );
8626 execute( TC_assignment_codec_amr_h_S02() );
8627 execute( TC_assignment_codec_amr_h_S024() );
8628 execute( TC_assignment_codec_amr_h_S0247() );
8629 execute( TC_assignment_codec_amr_f_S01234567() );
8630 execute( TC_assignment_codec_amr_f_S0234567() );
8631 execute( TC_assignment_codec_amr_f_zero() );
8632 execute( TC_assignment_codec_amr_f_unsupp() );
8633 execute( TC_assignment_codec_amr_h_S7() );
Neels Hofmeyr21863562020-11-26 00:34:33 +00008634 execute( TC_assignment_codec_amr_f_start_mode_auto() );
8635 execute( TC_assignment_codec_amr_h_start_mode_auto() );
Neels Hofmeyr3eb94562020-11-26 02:40:26 +00008636 execute( TC_assignment_codec_amr_f_start_mode_4() );
8637 execute( TC_assignment_codec_amr_h_start_mode_4() );
Neels Hofmeyr454d7922020-11-26 02:24:57 +00008638 execute( TC_assignment_codec_amr_startmode_cruft() );
Philipp Maier8a581d22019-03-26 18:32:48 +01008639 }
Harald Welte60aa5762018-03-21 19:33:13 +01008640
Philipp Maierac09bfc2019-01-08 13:41:39 +01008641 execute( TC_assignment_codec_fr_exhausted_req_hr() );
8642 execute( TC_assignment_codec_fr_exhausted_req_fr() );
8643 execute( TC_assignment_codec_fr_exhausted_req_fr_hr() );
8644 execute( TC_assignment_codec_fr_exhausted_req_hr_fr() );
8645 execute( TC_assignment_codec_hr_exhausted_req_fr() );
8646 execute( TC_assignment_codec_hr_exhausted_req_hr() );
8647 execute( TC_assignment_codec_hr_exhausted_req_hr_fr() );
8648 execute( TC_assignment_codec_hr_exhausted_req_fr_hr() );
8649 execute( TC_assignment_codec_req_hr_fr() );
8650 execute( TC_assignment_codec_req_fr_hr() );
8651
Pau Espin Pedrol58cf6822019-05-28 18:11:33 +02008652 if (mp_enable_osmux_test) {
8653 execute( TC_assignment_osmux() );
8654 }
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02008655
Harald Welte898113b2018-01-31 18:32:21 +01008656 /* RLL Establish Indication on inactive DCHAN / SAPI */
Harald Welte5cd20ed2017-12-13 21:03:20 +01008657 execute( TC_rll_est_ind_inact_lchan() );
8658 execute( TC_rll_est_ind_inval_sapi1() );
8659 execute( TC_rll_est_ind_inval_sapi3() );
8660 execute( TC_rll_est_ind_inval_sacch() );
8661
Vadim Yanitskiy61f784a2020-10-01 21:12:19 +07008662 /* DLCI / RSL Link ID conversion for MO/MT messages on SAPI0/SAPI3 */
8663 execute( TC_tch_dlci_link_id_sapi() );
8664
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07008665 /* SAPI N Reject triggered by RLL establishment failures */
8666 execute( TC_rll_rel_ind_sapi_n_reject() );
8667 execute( TC_rll_err_ind_sapi_n_reject() );
8668 execute( TC_rll_timeout_sapi_n_reject() );
8669
Harald Welte898113b2018-01-31 18:32:21 +01008670 /* Paging related tests */
Harald Welte6f521d82017-12-11 19:52:02 +01008671 execute( TC_paging_imsi_nochan() );
8672 execute( TC_paging_tmsi_nochan() );
8673 execute( TC_paging_tmsi_any() );
8674 execute( TC_paging_tmsi_sdcch() );
8675 execute( TC_paging_tmsi_tch_f() );
8676 execute( TC_paging_tmsi_tch_hf() );
8677 execute( TC_paging_imsi_nochan_cgi() );
8678 execute( TC_paging_imsi_nochan_lac_ci() );
8679 execute( TC_paging_imsi_nochan_ci() );
8680 execute( TC_paging_imsi_nochan_lai() );
8681 execute( TC_paging_imsi_nochan_lac() );
8682 execute( TC_paging_imsi_nochan_all() );
Harald Welte751d3eb2018-01-31 15:51:06 +01008683 execute( TC_paging_imsi_nochan_plmn_lac_rnc() );
8684 execute( TC_paging_imsi_nochan_rnc() );
8685 execute( TC_paging_imsi_nochan_lac_rnc() );
8686 execute( TC_paging_imsi_nochan_lacs() );
8687 execute( TC_paging_imsi_nochan_lacs_empty() );
Stefan Sperling049a86e2018-03-20 15:51:00 +01008688 execute( TC_paging_imsi_nochan_cgi_unknown_cid() );
Harald Welte10985002017-12-12 09:29:15 +01008689 execute( TC_paging_imsi_a_reset() );
Harald Weltee65d40e2017-12-13 00:09:06 +01008690 execute( TC_paging_imsi_load() );
Philipp Maier779a7922018-02-16 11:00:37 +01008691 execute( TC_paging_counter() );
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01008692 execute( TC_paging_resp_unsol() );
Harald Welte4e9b9cc2017-12-14 18:31:02 +01008693
8694 execute( TC_rsl_drop_counter() );
Stefan Sperling830dc9d2018-02-12 21:08:28 +01008695 execute( TC_rsl_unknown_unit_id() );
8696
8697 execute( TC_oml_unknown_unit_id() );
Harald Welte898113b2018-01-31 18:32:21 +01008698
8699 execute( TC_classmark() );
Harald Welteeddf0e92020-06-21 19:42:15 +02008700 execute( TC_common_id() );
Harald Welte898113b2018-01-31 18:32:21 +01008701 execute( TC_unsol_ass_fail() );
Harald Welteea99a002018-01-31 20:46:43 +01008702 execute( TC_unsol_ass_compl() );
Harald Weltefbf9b5e2018-01-31 20:41:23 +01008703 execute( TC_unsol_ho_fail() );
Harald Weltee3bd6582018-01-31 22:51:25 +01008704 execute( TC_err_82_short_msg() );
Harald Weltee9e02e42018-01-31 23:36:25 +01008705 execute( TC_err_84_unknown_msg() );
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01008706
Harald Welte261af4b2018-02-12 21:20:39 +01008707 execute( TC_ho_int() );
Neels Hofmeyr5f144212020-11-03 15:41:58 +00008708 execute( TC_ho_int_radio_link_failure() );
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01008709
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01008710 execute( TC_ho_out_of_this_bsc() );
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02008711 execute( TC_ho_out_fail_no_msc_response() );
8712 execute( TC_ho_out_fail_rr_ho_failure() );
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02008713 execute( TC_ho_out_fail_no_result_after_ho_cmd() );
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01008714
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01008715 execute( TC_ho_into_this_bsc() );
Pau Espin Pedrol07866632020-09-03 19:10:55 +02008716 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
8717 execute( TC_ho_into_this_bsc_tla_v6() );
8718 }
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02008719 execute( TC_srvcc_eutran_to_geran() );
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02008720 execute( TC_srvcc_eutran_to_geran_ho_out() );
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01008721 execute( TC_ho_in_fail_msc_clears() );
8722 execute( TC_ho_in_fail_msc_clears_after_ho_detect() );
8723 execute( TC_ho_in_fail_no_detect() );
8724 execute( TC_ho_in_fail_no_detect2() );
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01008725
Neels Hofmeyr91401012019-07-11 00:42:35 +02008726 execute( TC_ho_neighbor_config_1() );
8727 execute( TC_ho_neighbor_config_2() );
8728 execute( TC_ho_neighbor_config_3() );
8729 execute( TC_ho_neighbor_config_4() );
8730 execute( TC_ho_neighbor_config_5() );
8731 execute( TC_ho_neighbor_config_6() );
8732 execute( TC_ho_neighbor_config_7() );
8733
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01008734 execute( TC_bssap_rlsd_does_not_cause_bssmap_reset() );
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01008735 execute( TC_bssmap_clear_does_not_cause_bssmap_reset() );
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01008736 execute( TC_ms_rel_ind_does_not_cause_bssmap_reset() );
Harald Welte94e0c342018-04-07 11:33:23 +02008737
8738 execute( TC_dyn_pdch_ipa_act_deact() );
8739 execute( TC_dyn_pdch_ipa_act_nack() );
8740 execute( TC_dyn_pdch_osmo_act_deact() );
8741 execute( TC_dyn_pdch_osmo_act_nack() );
Harald Welte99f3ca02018-06-14 13:40:29 +02008742
Stefan Sperling0796a822018-10-05 13:01:39 +02008743 execute( TC_chopped_ipa_ping() );
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02008744 execute( TC_chopped_ipa_payload() );
Stefan Sperling0796a822018-10-05 13:01:39 +02008745
Pau Espin Pedrol8f773632019-11-05 11:46:53 +01008746 /* Power control related */
8747 execute( TC_assignment_verify_ms_power_params_ie() );
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008748
8749 /* MSC pooling */
8750 /* FIXME: in SCCPlite, indicating how many MSCs should be connected does currently not work. Since
8751 * RESET->RESET-ACK is unconditionally negotiated for all configured MSCs, they always all appear as connected
8752 * to osmo-bsc. The MSC pooling tests however require disconnecting selected MSCs, and hence don't work out as
8753 * intended on SCCPlite. So for now, run these only for SCCP/M3UA. */
8754 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
8755 execute( TC_mscpool_L3Compl_on_1_msc() );
8756 execute( TC_mscpool_L3Complete_by_imsi_round_robin() );
8757 execute( TC_mscpool_LU_by_tmsi_null_nri_0_round_robin() );
8758 execute( TC_mscpool_LU_by_tmsi_null_nri_1_round_robin() );
8759 execute( TC_mscpool_L3Complete_by_tmsi_unassigned_nri_round_robin() );
8760 execute( TC_mscpool_L3Complete_by_tmsi_valid_nri_msc_not_connected_round_robin() );
8761 execute( TC_mscpool_L3Complete_by_tmsi_valid_nri_1() );
8762 execute( TC_mscpool_L3Complete_by_tmsi_valid_nri_2() );
8763 execute( TC_mscpool_LU_by_tmsi_from_other_PLMN() );
8764 execute( TC_mscpool_paging_and_response_imsi() );
8765 execute( TC_mscpool_paging_and_response_tmsi() );
8766 execute( TC_mscpool_no_allow_attach_round_robin() );
8767 execute( TC_mscpool_no_allow_attach_valid_nri() );
8768 }
8769
Harald Welte99f3ca02018-06-14 13:40:29 +02008770 /* at bottom as they might crash OsmoBSC before OS#3182 is fixed */
8771 execute( TC_early_conn_fail() );
8772 execute( TC_late_conn_fail() );
8773
Philipp Maier783681c2020-07-16 16:47:06 +02008774 /* Emergency call handling (deny / allow) */
8775 execute( TC_assignment_emerg_setup_allow() );
8776 execute( TC_assignment_emerg_setup_deny_msc() );
8777 execute( TC_assignment_emerg_setup_deny_bts() );
Philipp Maier82812002020-08-13 18:48:27 +02008778 execute( TC_emerg_premption() );
8779
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008780 /* Frequency hopping parameters handling */
8781 execute( TC_fh_params_chan_activ() );
8782 execute( TC_fh_params_imm_ass() );
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07008783 execute( TC_fh_params_assignment_cmd() );
Vadim Yanitskiy8f5430d2020-09-02 18:51:38 +07008784 execute( TC_fh_params_handover_cmd() );
Vadim Yanitskiyca974032020-09-01 07:20:39 +07008785 execute( TC_fh_params_si4_cbch() );
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008786
8787 if (mp_enable_lcs_tests) {
8788 execute( TC_lcs_loc_req_for_active_ms() );
8789 execute( TC_lcs_loc_req_for_active_ms_ta_req() );
8790 execute( TC_lcs_loc_req_for_idle_ms() );
8791 execute( TC_lcs_loc_req_no_subscriber() );
8792 execute( TC_lcs_loc_req_for_active_ms_le_timeout() );
8793 execute( TC_lcs_loc_req_for_active_ms_le_timeout2() );
8794 execute( TC_lcs_loc_req_for_idle_ms_no_pag_resp() );
8795 execute( TC_cm_service_during_lcs_loc_req() );
8796 execute( TC_ho_during_lcs_loc_req() );
8797 }
Neels Hofmeyrbf037052020-10-28 22:52:02 +00008798
8799 execute( TC_no_msc() );
Harald Welte28d943e2017-11-25 15:00:50 +01008800}
8801
8802}