blob: f0622741057347fd353be1144ece7967dac83216 [file] [log] [blame]
Harald Welte28d943e2017-11-25 15:00:50 +01001module BSC_Tests {
2
Harald Welte21b46bd2017-12-17 19:46:32 +01003/* Integration Tests for OsmoBSC
Harald Weltea0630032018-03-20 21:09:55 +01004 * (C) 2017-2018 by Harald Welte <laforge@gnumonks.org>
Harald Welte21b46bd2017-12-17 19:46:32 +01005 * All rights reserved.
6 *
7 * Released under the terms of GNU General Public License, Version 2 or
8 * (at your option) any later version.
9 *
Harald Welte34b5a952019-05-27 11:54:11 +020010 * SPDX-License-Identifier: GPL-2.0-or-later
11 *
Harald Welte21b46bd2017-12-17 19:46:32 +010012 * This test suite tests OsmoBSC while emulating both multiple BTS + MS as
13 * well as the MSC. See README for more details.
14 *
15 * There are test cases that run in so-called 'handler mode' and test cases
16 * that run directly on top of the BSSAP and RSL CodecPorts. The "handler mode"
17 * tests abstract the multiplexing/demultiplexing of multiple SCCP connections
18 * and/or RSL channels and are hence suitable for higher-level test cases, while
19 * the "raw" tests directly on top of the CodecPorts are more suitable for lower-
20 * level testing.
21 */
22
Neels Hofmeyr4f118412020-06-04 15:25:10 +020023import from Misc_Helpers all;
Harald Welte4003d112017-12-09 22:35:39 +010024import from General_Types all;
Harald Welte28d943e2017-11-25 15:00:50 +010025import from Osmocom_Types all;
Harald Welteae026692017-12-09 01:03:01 +010026import from GSM_Types all;
Harald Welte28d943e2017-11-25 15:00:50 +010027import from IPL4asp_Types all;
28
Harald Welte6f521d82017-12-11 19:52:02 +010029import from BSSAP_Types all;
Harald Welte6811d102019-04-14 22:23:14 +020030import from RAN_Adapter all;
Harald Welte47cd0e32020-08-21 12:39:11 +020031import from BSSAP_LE_Adapter all;
32import from BSSAP_LE_CodecPort all;
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +020033import from BSSAP_LE_Types all;
34import from BSSLAP_Types all;
Harald Welteae026692017-12-09 01:03:01 +010035import from BSSAP_CodecPort all;
36import from BSSMAP_Templates all;
Harald Welte28d943e2017-11-25 15:00:50 +010037import from IPA_Emulation all;
Stefan Sperling830dc9d2018-02-12 21:08:28 +010038import from IPA_CodecPort all;
Harald Welteae026692017-12-09 01:03:01 +010039import from IPA_Types all;
Stefan Sperling0796a822018-10-05 13:01:39 +020040import from IPA_Testing all;
Harald Welteae026692017-12-09 01:03:01 +010041import from RSL_Types all;
Harald Welte624f9632017-12-16 19:26:04 +010042import from RSL_Emulation all;
Daniel Willmann191e0d92018-01-17 12:44:35 +010043import from MGCP_Emulation all;
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +010044import from MGCP_Templates all;
45import from MGCP_Types all;
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +020046import from MGCP_CodecPort all;
Harald Welte28d943e2017-11-25 15:00:50 +010047
Harald Welte96c94412017-12-09 03:12:45 +010048import from Osmocom_CTRL_Functions all;
Harald Weltea5d2ab22017-12-09 14:21:42 +010049import from Osmocom_CTRL_Types all;
Harald Welteffe55fc2018-01-17 22:39:54 +010050import from Osmocom_CTRL_Adapter all;
Harald Welte96c94412017-12-09 03:12:45 +010051
Daniel Willmannebdecc02020-08-12 15:30:17 +020052import from StatsD_Types all;
53import from StatsD_CodecPort all;
54import from StatsD_CodecPort_CtrlFunct all;
55import from StatsD_Checker all;
56
Harald Weltebc03c762018-02-12 18:09:38 +010057import from Osmocom_VTY_Functions all;
58import from TELNETasp_PortType all;
59
Harald Welte6f521d82017-12-11 19:52:02 +010060import from MobileL3_CommonIE_Types all;
Harald Weltee3bd6582018-01-31 22:51:25 +010061import from MobileL3_Types all;
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +010062import from MobileL3_RRM_Types all;
Harald Welte6f521d82017-12-11 19:52:02 +010063import from L3_Templates all;
64import from GSM_RR_Types all;
65
Stefan Sperlingc307e682018-06-14 15:15:46 +020066import from SCCP_Templates all;
Neels Hofmeyr4ff93282018-03-12 04:25:35 +010067import from BSSMAP_Templates all;
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +020068import from BSSMAP_LE_Templates all;
Neels Hofmeyr4ff93282018-03-12 04:25:35 +010069
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +010070import from SCCPasp_Types all;
71
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +020072import from GSM_SystemInformation all;
73import from GSM_RestOctets all;
Neels Hofmeyrad132f22020-07-08 02:20:16 +020074import from TCCConversion_Functions all;
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +020075
Harald Welte5d1a2202017-12-13 19:51:29 +010076const integer NUM_BTS := 3;
Neels Hofmeyrf246a922020-05-13 02:27:10 +020077const integer NUM_MSC := 3;
Harald Welteae026692017-12-09 01:03:01 +010078const float T3101_MAX := 12.0;
Harald Welte28d943e2017-11-25 15:00:50 +010079
Harald Welte799c97b2017-12-14 17:50:30 +010080/* make sure to sync this with the osmo-bts.cfg you're using */
Philipp Maiercb6cc482018-03-26 13:08:00 +020081const integer NUM_TCHH_PER_BTS := 2;
82const integer NUM_TCHF_PER_BTS := 4;
Neels Hofmeyr74083c22020-07-29 00:43:01 +020083const integer NUM_SDCCH_PER_BTS := 3;
Harald Welte799c97b2017-12-14 17:50:30 +010084
Harald Welte4003d112017-12-09 22:35:39 +010085
Harald Welte21b46bd2017-12-17 19:46:32 +010086/* per-BTS state which we keep */
Harald Welte96c94412017-12-09 03:12:45 +010087type record BTS_State {
Harald Welte21b46bd2017-12-17 19:46:32 +010088 /* component reference to the IPA_Client component used for RSL */
Harald Weltea5d2ab22017-12-09 14:21:42 +010089 IPA_Client rsl
Harald Welte96c94412017-12-09 03:12:45 +010090}
91
Neels Hofmeyr22c3f792020-06-17 02:49:28 +020092/* Default list of counters for an 'msc' entity. */
93const CounterNameVals counternames_msc_mscpool := {
94 { "mscpool:subscr:new", 0 },
95 { "mscpool:subscr:known", 0 },
96 { "mscpool:subscr:reattach", 0 },
97 { "mscpool:subscr:attach_lost", 0 },
98 { "mscpool:subscr:paged", 0 }
99};
100
Neels Hofmeyrbf037052020-10-28 22:52:02 +0000101/* List of global mscpool counters, not related to a specific 'msc' entity. */
102const CounterNameVals counternames_bsc_mscpool := {
103 { "mscpool:subscr:no_msc", 0 }
104};
105
Neels Hofmeyr12941bd2020-08-29 03:21:26 +0000106/* Default list of counters for 'bsc' and 'bts' entities. */
107const CounterNameVals counternames_bsc_bts_handover := {
108 { "assignment:attempted", 0 },
109 { "assignment:completed", 0 },
110 { "assignment:stopped", 0 },
111 { "assignment:no_channel", 0 },
112 { "assignment:timeout", 0 },
113 { "assignment:failed", 0 },
114 { "assignment:error", 0 },
115
116 { "handover:attempted", 0 },
117 { "handover:completed", 0 },
118 { "handover:stopped", 0 },
119 { "handover:no_channel", 0 },
120 { "handover:timeout", 0 },
121 { "handover:failed", 0 },
122 { "handover:error", 0 },
123
124 { "intra_cell_ho:attempted", 0 },
125 { "intra_cell_ho:completed", 0 },
126 { "intra_cell_ho:stopped", 0 },
127 { "intra_cell_ho:no_channel", 0 },
128 { "intra_cell_ho:timeout", 0 },
129 { "intra_cell_ho:failed", 0 },
130 { "intra_cell_ho:error", 0 },
131
132 { "intra_bsc_ho:attempted", 0 },
133 { "intra_bsc_ho:completed", 0 },
134 { "intra_bsc_ho:stopped", 0 },
135 { "intra_bsc_ho:no_channel", 0 },
136 { "intra_bsc_ho:timeout", 0 },
137 { "intra_bsc_ho:failed", 0 },
138 { "intra_bsc_ho:error", 0 },
139
140 { "interbsc_ho_out:attempted", 0 },
141 { "interbsc_ho_out:completed", 0 },
142 { "interbsc_ho_out:stopped", 0 },
143 { "interbsc_ho_out:timeout", 0 },
144 { "interbsc_ho_out:failed", 0 },
145 { "interbsc_ho_out:error", 0 },
146
147 { "interbsc_ho_in:attempted", 0 },
148 { "interbsc_ho_in:completed", 0 },
149 { "interbsc_ho_in:stopped", 0 },
150 { "interbsc_ho_in:no_channel", 0 },
151 { "interbsc_ho_in:timeout", 0 },
152 { "interbsc_ho_in:failed", 0 },
153 { "interbsc_ho_in:error", 0 }
154};
155
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200156/* Set of all System Information received during one RSL port's startup.
157 * Note that some System Information may be sent on RSL, but lacking actual SI data, to indicate that the BTS should not
158 * broadcast that SI type. That will be reflected as 'omit' here.
159 */
160type record SystemInformationConfig {
161 SystemInformationType1 si1 optional,
162 SystemInformationType2 si2 optional,
163 SystemInformationType2bis si2bis optional,
164 SystemInformationType2ter si2ter optional,
Neels Hofmeyrad132f22020-07-08 02:20:16 +0200165 SI2quaterRestOctetsList si2quater optional,
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200166 SystemInformationType3 si3 optional,
167 SystemInformationType4 si4 optional,
Pau Espin Pedrol28652d82021-02-09 20:20:17 +0100168 SystemInformationType13 si13 optional,
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200169 SystemInformationType5 si5 optional,
170 SystemInformationType5bis si5bis optional,
171 SystemInformationType5ter si5ter optional,
172 SystemInformationType6 si6 optional
173};
174
175const SystemInformationConfig SystemInformationConfig_omit := {
176 si1 := omit,
177 si2 := omit,
178 si2bis := omit,
179 si2ter := omit,
180 si2quater := omit,
181 si3 := omit,
182 si4 := omit,
183 si13 := omit,
184 si5 := omit,
185 si5bis := omit,
186 si5ter := omit,
187 si6 := omit
188};
189
190/* tr_EUTRAN_CellDesc with defaults used in BSC_Tests.ttcn */
191template EUTRAN_CellDesc tr_EUTRAN_CellDesc_default(template (present) uint16_t e_arfcn := ?,
192 template uint3_t meas_bw := 3)
193:= tr_EUTRAN_CellDesc(e_arfcn := e_arfcn,
194 meas_bw_presence := '1'B,
195 meas_bw := meas_bw);
196
197/* tr_EUTRAN_NeighbourCells with defaults used in BSC_Tests.ttcn */
Harald Welte65e419a2020-08-21 12:38:33 +0200198template EUTRAN_NeighbourCells tr_EUTRAN_NeighbourCells_default(template (present) EUTRAN_CellDescs cell_desc_list := { tr_EUTRAN_CellDesc_default },
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200199 template uint3_t prio := 3,
200 template (present) uint5_t thresh_high := 20,
201 template uint5_t thresh_low := 10,
202 template uint5_t qrxlevmin := 22)
203:= tr_EUTRAN_NeighbourCells(
204 cell_desc_list := cell_desc_list,
205 prio_presence := '1'B,
206 prio := prio,
207 thresh_high := thresh_high,
208 thresh_low_presence := '1'B,
209 thresh_low := thresh_low,
210 qrxlevmin_presence := '1'B,
211 qrxlevmin := qrxlevmin);
212
213template SystemInformationConfig SystemInformationConfig_default := {
214 si1 := {
215 cell_chan_desc := '8FB38000000000000000000000000000'O,
216 rach_control := {
217 max_retrans := RACH_MAX_RETRANS_7,
218 tx_integer := '1001'B,
219 cell_barr_access := false,
220 re_not_allowed := true,
221 acc := '0000010000000000'B
222 },
223 rest_octets := ?
224 },
225 si2 := {
226 bcch_freq_list := '00000000000000000000000000000000'O,
227 ncc_permitted := '11111111'B,
228 rach_control := {
229 max_retrans := RACH_MAX_RETRANS_7,
230 tx_integer := '1001'B,
231 cell_barr_access := false,
232 re_not_allowed := true,
233 acc := '0000010000000000'B
234 }
235 },
236 si2bis := omit,
237 si2ter := {
238 extd_bcch_freq_list := '8E320000000000000000000000000800'O,
239 rest_octets := ?
240 },
241 si2quater := {
242 tr_SI2quaterRestOctets_EUTRAN( repeated_neigh_cells := { tr_EUTRAN_NeighbourCells_default } )
243 },
244 si3 := {
245 cell_id := 0,
246 lai := {
247 mcc_mnc := '001F01'H,
248 lac := 1
249 },
250 ctrl_chan_desc := {
251 msc_r99 := true,
252 att := true,
253 bs_ag_blks_res := 1,
254 ccch_conf := CCHAN_DESC_1CCCH_COMBINED,
255 si22ind := false,
256 cbq3 := CBQ3_IU_MODE_NOT_SUPPORTED,
257 spare := '00'B,
258 bs_pa_mfrms := 3,
259 t3212 := 30
260 },
261 cell_options := {
262 dn_ind := false,
263 pwrc := false,
264 dtx := MS_SHALL_USE_UL_DTX,
265 radio_link_tout_div4 := 7
266 },
267 cell_sel_par := {
268 cell_resel_hyst_2dB := 2,
269 ms_txpwr_max_cch := 7,
270 acs := '0'B,
271 neci := true,
272 rxlev_access_min := 0
273 },
274 rach_control := {
275 max_retrans := RACH_MAX_RETRANS_7,
276 tx_integer := '1001'B,
277 cell_barr_access := false,
278 re_not_allowed := true,
279 acc := '0000010000000000'B
280 },
281 rest_octets := {
282 sel_params := {
283 presence := '0'B,
284 params := omit
285 },
286 pwr_offset := {
287 presence := '0'B,
288 offset := omit
289 },
290 si_2ter_ind := '1'B,
291 early_cm_ind := '0'B,
292 sched_where := {
293 presence := '0'B,
294 where := omit
295 },
296 gprs_ind := {
297 presence := '1'B,
298 ind := {
299 ra_colour := 0,
300 si13_pos := '0'B
301 }
302 },
303 umts_early_cm_ind := '1'B,
304 si2_quater_ind := {
305 presence := '1'B,
306 ind := '0'B
307 },
308 iu_mode_ind := omit,
309 si21_ind := {
310 presence := '0'B,
311 pos := omit
312 }
313 }
314 },
315 si4 := {
316 lai := {
317 mcc_mnc := '001F01'H,
318 lac := 1
319 },
320 cell_sel_par := {
321 cell_resel_hyst_2dB := 2,
322 ms_txpwr_max_cch := 7,
323 acs := '0'B,
324 neci := true,
325 rxlev_access_min := 0
326 },
327 rach_control := {
328 max_retrans := RACH_MAX_RETRANS_7,
329 tx_integer := '1001'B,
330 cell_barr_access := false,
331 re_not_allowed := true,
332 acc := '0000010000000000'B
333 },
Neels Hofmeyr74083c22020-07-29 00:43:01 +0200334 cbch_chan_desc := {
335 iei := '64'O,
336 v := {
337 chan_nr := {
338 u := {
339 sdcch4 := {
340 tag := '001'B,
341 sub_chan := 2
342 }
343 },
344 tn := 0
345 },
346 tsc := 2,
347 h := false,
348 arfcn := 871,
349 maio_hsn := omit
350 }
351 },
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200352 cbch_mobile_alloc := omit,
353 rest_octets := {
354 sel_params := {
355 presence := '0'B,
356 params := omit
357 },
358 pwr_offset := {
359 presence := '0'B,
360 offset := omit
361 },
362 gprs_ind := {
363 presence := '1'B,
364 ind := {
365 ra_colour := 0,
366 si13_pos := '0'B
367 }
368 },
369 s_presence := '0'B,
370 s := omit
371 }
372 },
Pau Espin Pedrol28652d82021-02-09 20:20:17 +0100373 si13 := {
374 rest_octets := {
375 presence := '1'B,
376 bcch_change_mark := ?,
377 si_change_field := '0000'B,
378 presence2 := '0'B,
379 si13_change_mark := omit,
380 gprs_ma := omit,
381 zero := '0'B, /* PBCCH not present in cell */
382 rac := 0,
383 spgc_ccch_sup := '0'B,
384 priority_access_thr := '110'B,
385 network_control_order := '00'B,
386 gprs_cell_opts := {
387 nmo := '01'B,
388 t3168 := '011'B,
389 t3192 := '010'B,
390 drx_timer_max := '011'B,
391 access_burst_type := '0'B,
392 control_ack_type := '1'B,
393 bs_cv_max := 15,
394 pan_presence := '1'B,
395 pan_dec := 1,
396 pan_inc := 1,
397 pan_max := '111'B,
398 ext_info_presence := ?,
399 ext_info_length := *,
400 ext_info := *
401 },
402 gprs_pwr_ctrl_params := {
403 alpha := 0,
404 t_avg_w := '10000'B,
405 t_avg_t := '10000'B,
406 pc_meas_chan := '0'B,
407 n_avg_i := '1000'B
408 }
409 }
410 },
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200411 si5 := {
412 bcch_freq_list := '10000000000000000000000000000000'O
413 },
414 si5bis := omit,
415 si5ter := {
416 extd_bcch_freq_list := '9E050020000000000000000000000000'O
417 },
418 si6 := {
419 cell_id := 0,
420 lai := {
421 mcc_mnc := '001F01'H,
422 lac := 1
423 },
424 cell_options := {
425 dtx_ext := '1'B,
426 pwrc := false,
427 dtx := '01'B,
428 radio_link_timeout := '0111'B
429 },
430 ncc_permitted := '11111111'B,
431 rest_octets := ?
432 }
433 };
434
435
436/* List of all the System Information received on all RSL ports */
437type record of SystemInformationConfig SystemInformationConfig_list;
438
439function f_sysinfo_dec_raw(inout SystemInformationConfig si, RSL_Message rsl)
440{
441 var RSL_IE_Body sysinfo_type_ie;
442 var RSL_IE_SysinfoType si_type;
443 var octetstring data;
444
445 if (f_rsl_find_ie(rsl, RSL_IE_SYSINFO_TYPE, sysinfo_type_ie) == false) {
446 setverdict(fail, "Cannot find RSL_IE_SYSINFO_TYPE");
447 mtc.stop;
448 }
449 si_type := sysinfo_type_ie.sysinfo_type;
450
451 if (rsl.msg_type == RSL_MT_BCCH_INFO) {
452 var RSL_IE_Body bcch_ie;
453 if (f_rsl_find_ie(rsl, RSL_IE_FULL_BCCH_INFO, bcch_ie)) {
454 data := bcch_ie.other.payload;
455 }
456 } else if (rsl.msg_type == RSL_MT_SACCH_FILL) {
457 var RSL_IE_Body l3_ie;
458 if (f_rsl_find_ie(rsl, RSL_IE_L3_INFO, l3_ie)) {
459 data := l3_ie.l3_info.payload;
460 }
461 } else {
462 setverdict(fail, "Don't understand this System Information message");
463 mtc.stop;
464 }
465
466 var boolean handled := false;
467
468 if (rsl.msg_type == RSL_MT_BCCH_INFO) {
469 handled := true;
470
471 if (si_type == RSL_SYSTEM_INFO_1) {
472 if (not isbound(data)) {
473 si.si1 := omit;
474 } else {
475 si.si1 := dec_SystemInformation(data).payload.si1;
476 }
477 } else if (si_type == RSL_SYSTEM_INFO_2) {
478 if (not isbound(data)) {
479 si.si2 := omit;
480 } else {
481 si.si2 := dec_SystemInformation(data).payload.si2;
482 }
483 } else if (si_type == RSL_SYSTEM_INFO_2bis) {
484 if (not isbound(data)) {
485 si.si2bis := omit;
486 } else {
487 si.si2bis := dec_SystemInformation(data).payload.si2bis;
488 }
489 } else if (si_type == RSL_SYSTEM_INFO_2ter) {
490 if (not isbound(data)) {
491 si.si2ter := omit;
492 } else {
493 si.si2ter := dec_SystemInformation(data).payload.si2ter;
494 }
495 } else if (si_type == RSL_SYSTEM_INFO_2quater) {
496 if (not isbound(data)) {
497 si.si2quater := {};
498 } else {
499 var SystemInformationType2quater decoded := dec_SystemInformation(data).payload.si2quater;
500 /* this is a *record* of SI2quaterRestOctets! (multiplexed) */
501 si.si2quater[decoded.rest_octets.si2quater_index] := decoded.rest_octets;
502 }
503 } else if (si_type == RSL_SYSTEM_INFO_3) {
504 if (not isbound(data)) {
505 si.si3 := omit;
506 } else {
507 si.si3 := dec_SystemInformation(data).payload.si3;
508 }
509 } else if (si_type == RSL_SYSTEM_INFO_4) {
510 if (not isbound(data)) {
511 si.si4 := omit;
512 } else {
513 si.si4 := dec_SystemInformation(data).payload.si4;
514 }
515 } else if (si_type == RSL_SYSTEM_INFO_13) {
516 if (not isbound(data)) {
517 si.si13 := omit;
518 } else {
Pau Espin Pedrol28652d82021-02-09 20:20:17 +0100519 si.si13 := dec_SystemInformation(data).payload.si13;
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200520 }
521 } else {
522 handled := false;
523 }
524 } else if (rsl.msg_type == RSL_MT_SACCH_FILL) {
525 handled := true;
526
527 if (si_type == RSL_SYSTEM_INFO_5) {
528 if (not isbound(data)) {
529 si.si5 := omit;
530 } else {
531 si.si5 := dec_SystemInformation(data).payload.si5;
532 }
533 } else if (si_type == RSL_SYSTEM_INFO_5bis) {
534 if (not isbound(data)) {
535 si.si5bis := omit;
536 } else {
537 si.si5bis := dec_SystemInformation(data).payload.si5bis;
538 }
539 } else if (si_type == RSL_SYSTEM_INFO_5ter) {
540 if (not isbound(data)) {
541 si.si5ter := omit;
542 } else {
543 si.si5ter := dec_SystemInformation(data).payload.si5ter;
544 }
545 } else if (si_type == RSL_SYSTEM_INFO_6) {
546 if (not isbound(data)) {
547 si.si6 := omit;
548 } else {
549 si.si6 := dec_SystemInformation(data).payload.si6;
550 }
551 } else {
552 handled := false;
553 }
554 }
555
556 if (not handled) {
557 setverdict(fail, "Unexpected SI type in ", rsl.msg_type, " message: ", si_type);
558 }
559}
560
Harald Weltea4ca4462018-02-09 00:17:14 +0100561type component test_CT extends CTRL_Adapter_CT {
Harald Welte21b46bd2017-12-17 19:46:32 +0100562 /* Array of per-BTS state */
Harald Welte96c94412017-12-09 03:12:45 +0100563 var BTS_State bts[NUM_BTS];
Harald Welte89ab1912018-02-23 18:56:29 +0100564 /* RSL common Channel Port (for RSL_Emulation) */
565 port RSL_CCHAN_PT RSL_CCHAN[NUM_BTS];
Harald Welte21b46bd2017-12-17 19:46:32 +0100566 /* array of per-BTS RSL test ports */
Harald Welteae026692017-12-09 01:03:01 +0100567 port IPA_RSL_PT IPA_RSL[NUM_BTS];
Stefan Sperling830dc9d2018-02-12 21:08:28 +0100568 port IPA_CODEC_PT IPA; /* Required for compilation of TC_rsl_unknown_unit_id() */
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +0200569 /* CTRL muxed over IPA in SCCPlite conn BSC<->MSC (or BSC-NAT) */
570 port IPA_CTRL_PT SCCPLITE_IPA_CTRL;
Harald Weltea5d2ab22017-12-09 14:21:42 +0100571
Daniel Willmann191e0d92018-01-17 12:44:35 +0100572 var MGCP_Emulation_CT vc_MGCP;
Harald Weltebc03c762018-02-12 18:09:38 +0100573 port TELNETasp_PT BSCVTY;
Daniel Willmann191e0d92018-01-17 12:44:35 +0100574
Daniel Willmannebdecc02020-08-12 15:30:17 +0200575 /* StatsD */
576 var StatsD_Checker_CT vc_STATSD;
577
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200578 var RAN_Adapter g_bssap[NUM_MSC];
Harald Welte47cd0e32020-08-21 12:39:11 +0200579 var BSSAP_LE_Adapter g_bssap_le;
Harald Weltea4ca4462018-02-09 00:17:14 +0100580 /* for old legacy-tests only */
581 port BSSAP_CODEC_PT BSSAP;
Harald Welte47cd0e32020-08-21 12:39:11 +0200582 port BSSAP_LE_CODEC_PT BSSAP_LE;
Harald Weltea4ca4462018-02-09 00:17:14 +0100583
Harald Welte21b46bd2017-12-17 19:46:32 +0100584 /* are we initialized yet */
Harald Welte28d943e2017-11-25 15:00:50 +0100585 var boolean g_initialized := false;
Harald Welte21b46bd2017-12-17 19:46:32 +0100586
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200587 /* Osmux is enabled through VTY */
588 var boolean g_osmux_enabled := false;
589
Pau Espin Pedrolc675b612020-01-09 19:55:40 +0100590 /*Configure T(tias) over VTY, seconds */
591 var integer g_bsc_sccp_timer_ias := 7 * 60;
592 /*Configure T(tiar) over VTY, seconds */
593 var integer g_bsc_sccp_timer_iar := 15 * 60;
594
Neels Hofmeyr4fbad7f2020-06-16 00:30:47 +0200595 /* global test case guard timer (actual timeout value is set in f_init()) */
Harald Welteae026692017-12-09 01:03:01 +0100596 timer T_guard := 30.0;
597
Neels Hofmeyr22c3f792020-06-17 02:49:28 +0200598 var CounterNameValsList g_ctr_msc;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +0000599 var CounterNameValsList g_ctr_bsc;
600 var CounterNameValsList g_ctr_bts;
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200601
602 /* System Information bytes as received during RSL startup, for each RSL[idx]. */
603 var SystemInformationConfig_list g_system_information := {};
Harald Welte28d943e2017-11-25 15:00:50 +0100604}
605
606modulepar {
Harald Welte21b46bd2017-12-17 19:46:32 +0100607 /* IP address at which the BSC can be reached */
Harald Welte696ddb62017-12-08 14:01:43 +0100608 charstring mp_bsc_ip := "127.0.0.1";
Stefan Sperling830dc9d2018-02-12 21:08:28 +0100609 /* port number to which to establish the IPA OML connections */
610 integer mp_bsc_oml_port := 3002;
Harald Welte21b46bd2017-12-17 19:46:32 +0100611 /* port number to which to establish the IPA RSL connections */
Harald Welte696ddb62017-12-08 14:01:43 +0100612 integer mp_bsc_rsl_port := 3003;
Harald Welte21b46bd2017-12-17 19:46:32 +0100613 /* port number to which to establish the IPA CTRL connection */
Harald Welte96c94412017-12-09 03:12:45 +0100614 integer mp_bsc_ctrl_port := 4249;
Daniel Willmannebdecc02020-08-12 15:30:17 +0200615 /* port number to which to listen for STATSD metrics */
616 integer mp_bsc_statsd_port := 8125;
Daniel Willmann191e0d92018-01-17 12:44:35 +0100617 /* IP address at which the test binds */
618 charstring mp_test_ip := "127.0.0.1";
Harald Weltea4ca4462018-02-09 00:17:14 +0100619
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200620 RAN_Configurations mp_bssap_cfg := {
621 {
622 transport := BSSAP_TRANSPORT_AoIP,
623 sccp_service_type := "mtp3_itu",
624 sctp_addr := { 23905, "127.0.0.1", 2905, "127.0.0.1" },
625 own_pc := 185, /* 0.23.1 first MSC emulation */
626 own_ssn := 254,
627 peer_pc := 187, /* 0.23.3 osmo-bsc */
628 peer_ssn := 254,
629 sio := '83'O,
Harald Weltecb0cc432020-06-21 19:42:31 +0200630 rctx := 1
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200631 },
632 {
633 transport := BSSAP_TRANSPORT_AoIP,
634 sccp_service_type := "mtp3_itu",
635 sctp_addr := { 23906, "127.0.0.1", 2905, "127.0.0.1" },
636 own_pc := 2, /* 0.0.2 second MSC emulation */
637 own_ssn := 254,
638 peer_pc := 187, /* 0.23.3 osmo-bsc */
639 peer_ssn := 254,
640 sio := '83'O,
641 rctx := 2
642 },
643 {
644 transport := BSSAP_TRANSPORT_AoIP,
645 sccp_service_type := "mtp3_itu",
646 sctp_addr := { 23907, "127.0.0.1", 2905, "127.0.0.1" },
647 own_pc := 3, /* 0.0.3 third MSC emulation */
648 own_ssn := 254,
649 peer_pc := 187, /* 0.23.3 osmo-bsc */
650 peer_ssn := 254,
651 sio := '83'O,
652 rctx := 3
653 }
Harald Weltea4ca4462018-02-09 00:17:14 +0100654 };
Pau Espin Pedrol58cf6822019-05-28 18:11:33 +0200655
Harald Welte47cd0e32020-08-21 12:39:11 +0200656 BSSAP_LE_Configuration mp_bssap_le_cfg := {
657 sccp_service_type := "mtp3_itu",
658 sctp_addr := { 23908, "127.0.0.1", 2905, "127.0.0.1" },
Neels Hofmeyrac086c12020-09-18 23:46:42 +0200659 own_pc := 190, /* 0.23.6 SMLC emulation */
Harald Welte47cd0e32020-08-21 12:39:11 +0200660 own_ssn := 252, /* SMLC side SSN */
661 peer_pc := 187, /* 0.23.3 osmo-bsc */
662 peer_ssn := 250, /* BSC side SSN */
663 sio := '83'O,
664 rctx := 6
665 };
Neels Hofmeyrcfe44062020-10-15 02:28:08 +0200666 boolean mp_enable_lcs_tests := true;
Harald Welte47cd0e32020-08-21 12:39:11 +0200667
Pau Espin Pedrol58cf6822019-05-28 18:11:33 +0200668 /* Whether to enable osmux tests. Can be dropped completely and enable
669 unconditionally once new version of osmo-bsc is released (current
670 version: 1.4.1) */
671 boolean mp_enable_osmux_test := true;
Pau Espin Pedrol8f30ccd2019-11-01 17:30:57 +0100672 /* Value set in osmo-bsc.cfg "ms max power" */
673 uint8_t mp_exp_ms_power_level := 7;
Harald Weltea4ca4462018-02-09 00:17:14 +0100674}
675
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200676private function f_gen_test_hdlr_pars(integer bssap_idx := 0) return TestHdlrParams {
Philipp Maier48604732018-10-09 15:00:37 +0200677
678 var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200679 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Philipp Maier48604732018-10-09 15:00:37 +0200680 pars.aoip := true;
681 } else {
682 pars.aoip := false;
683 }
Pau Espin Pedrol8f30ccd2019-11-01 17:30:57 +0100684 pars.exp_ms_power_level := mp_exp_ms_power_level;
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200685 pars.mscpool.bssap_idx := bssap_idx;
Philipp Maier48604732018-10-09 15:00:37 +0200686
687 return pars;
688}
689
Neels Hofmeyr22c3f792020-06-17 02:49:28 +0200690/* Convenience functions for rate counters using g_ctr_msc. */
691
692private function f_ctrs_msc_init(integer mscs_count := NUM_MSC, CounterNameVals counternames := counternames_msc_mscpool) runs on test_CT {
693 g_ctr_msc := f_counter_name_vals_get_n(IPA_CTRL, "msc", mscs_count, counternames);
694 log("initial msc rate counters: ", g_ctr_msc);
695}
696
697private function f_ctrs_msc_add(integer msc_nr, charstring countername, integer val := 1) runs on test_CT {
Neels Hofmeyr9656e922020-06-30 01:27:01 +0200698 f_counter_name_vals_list_add(g_ctr_msc, msc_nr, countername, val);
Neels Hofmeyr22c3f792020-06-17 02:49:28 +0200699}
700
701/* f_ctrs_msc_init();
702 * f_do_thing(on_msc := 0);
703 * f_do_thing(on_msc := 0);
704 * f_do_other(on_msc := 1);
705 * f_ctrs_msc_add(0, "thing", 2);
706 * f_ctrs_msc_add(1, "other");
707 * f_ctrs_msc_verify();
708 */
709private function f_ctrs_msc_verify() runs on test_CT {
710 log("verifying msc rate counters: ", g_ctr_msc);
711 f_counter_name_vals_expect_n(IPA_CTRL, "msc", g_ctr_msc);
712}
713
714/* convenience: f_ctrs_msc_add() and f_ctrs_msc_verify() in one call.
715 * f_ctrs_msc_init();
716 * f_do_thing(on_msc := 0);
717 * f_do_thing(on_msc := 0);
718 * f_do_thing(on_msc := 0);
719 * f_ctrs_msc_expect(0, "thing", 3);
720 */
721private function f_ctrs_msc_expect(integer msc_nr, charstring countername, integer val := 1) runs on test_CT {
722 f_ctrs_msc_add(msc_nr, countername, val);
723 f_ctrs_msc_verify();
724}
725
Neels Hofmeyr12941bd2020-08-29 03:21:26 +0000726/* Convenience functions for rate counters using g_ctr_bts, always also including g_ctr_bsc. */
727
728private function f_ctrs_bsc_and_bts_init(integer bts_count := NUM_BTS, CounterNameVals counternames := counternames_bsc_bts_handover) runs on test_CT {
729 g_ctr_bts := f_counter_name_vals_get_n(IPA_CTRL, "bts", bts_count, counternames);
730 log("initial bts rate counters: ", g_ctr_bts);
731 f_ctrs_bsc_init(counternames);
732}
733
734private function f_ctrs_bsc_and_bts_add(integer bts_nr, charstring countername, integer val := 1) runs on test_CT {
735 f_counter_name_vals_list_add(g_ctr_bts, bts_nr, countername, val);
736 f_ctrs_bsc_add(countername, val);
737}
738
739/* f_ctrs_bsc_and_bts_init();
740 * f_do_thing(on_bts := 0);
741 * f_do_thing(on_bts := 0);
742 * f_do_other(on_bts := 1);
743 * f_ctrs_bsc_and_bts_add(0, "thing", 2);
744 * f_ctrs_bsc_and_bts_add(1, "other");
745 * f_ctrs_bsc_and_bts_verify();
746 */
747private function f_ctrs_bsc_and_bts_verify() runs on test_CT {
748 f_counter_name_vals_expect_n(IPA_CTRL, "bts", g_ctr_bts);
749 f_ctrs_bsc_verify();
750}
751
752/* convenience: f_ctrs_bsc_and_bts_add() and f_ctrs_bsc_and_bts_verify() in one call.
753 * f_ctrs_bsc_and_bts_init();
754 * f_do_thing(on_bts := 0);
755 * f_do_thing(on_bts := 0);
756 * f_do_thing(on_bts := 0);
757 * f_ctrs_bsc_and_bts_expect(0, "thing", 3);
758 */
759private function f_ctrs_bsc_and_bts_expect(integer bts_nr, charstring countername, integer val := 1) runs on test_CT {
760 f_ctrs_bsc_and_bts_add(bts_nr, countername, val);
761 f_ctrs_bsc_and_bts_verify();
762}
763
764
765/* Convenience functions for rate counters using g_ctr_bsc. */
766
767private function f_ctrs_bsc_init(CounterNameVals counternames := counternames_bsc_bts_handover) runs on test_CT {
768 g_ctr_bsc := f_counter_name_vals_get_n(IPA_CTRL, "bsc", 1, counternames);
769 log("initial bsc rate counters: ", g_ctr_bsc);
770}
771
772private function f_ctrs_bsc_add(charstring countername, integer val := 1) runs on test_CT {
773 f_counter_name_vals_list_add(g_ctr_bsc, 0, countername, val);
774}
775
776/* f_ctrs_bsc_init();
777 * f_do_thing();
778 * f_do_thing();
779 * f_do_other();
780 * f_ctrs_bsc_add("thing", 2);
781 * f_ctrs_bsc_add("other");
782 * f_ctrs_bsc_verify();
783 */
784private function f_ctrs_bsc_verify() runs on test_CT {
785 f_counter_name_vals_expect_n(IPA_CTRL, "bsc", g_ctr_bsc);
786}
787
788/* convenience: f_ctrs_bsc_add() and f_ctrs_bsc_verify() in one call.
789 * f_ctrs_bsc_init();
790 * f_do_thing();
791 * f_ctrs_bsc_expect("thing", 1);
792 */
793private function f_ctrs_bsc_expect(charstring countername, integer val := 1) runs on test_CT {
794 f_ctrs_bsc_add(countername, val);
795 f_ctrs_bsc_verify();
796}
797
Neels Hofmeyr22c3f792020-06-17 02:49:28 +0200798
Philipp Maier282ca4b2018-02-27 17:17:00 +0100799private function f_shutdown_helper() runs on test_CT {
Daniel Willmann637ef6c2018-07-25 10:49:09 +0200800 all component.stop;
Philipp Maier282ca4b2018-02-27 17:17:00 +0100801 setverdict(pass);
Daniel Willmannafce8662018-07-06 23:11:32 +0200802 mtc.stop;
Philipp Maier282ca4b2018-02-27 17:17:00 +0100803}
804
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200805private function f_legacy_bssap_reset(integer bssap_idx := 0) runs on test_CT {
Harald Weltea4ca4462018-02-09 00:17:14 +0100806 var BSSAP_N_UNITDATA_ind ud_ind;
Pau Espin Pedrol24c05992020-09-01 12:54:12 +0200807 var boolean reset_received := false;
Harald Weltea4ca4462018-02-09 00:17:14 +0100808 timer T := 5.0;
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200809 BSSAP.send(ts_BSSAP_UNITDATA_req(g_bssap[bssap_idx].sccp_addr_peer, g_bssap[bssap_idx].sccp_addr_own,
810 ts_BSSMAP_Reset(0, g_osmux_enabled)));
Harald Weltea4ca4462018-02-09 00:17:14 +0100811 T.start;
812 alt {
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200813 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(g_bssap[bssap_idx].sccp_addr_own, g_bssap[bssap_idx].sccp_addr_peer,
814 tr_BSSMAP_ResetAck(g_osmux_enabled))) {
Neels Hofmeyr4f5d7be2020-10-16 16:28:16 +0200815 log("BSSMAP: Received RESET-ACK in response to RESET, we're ready to go!");
Harald Weltea4ca4462018-02-09 00:17:14 +0100816 }
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200817 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset(g_osmux_enabled))) -> value ud_ind {
Neels Hofmeyr4f5d7be2020-10-16 16:28:16 +0200818 log("BSSMAP: Respoding to inbound RESET with RESET-ACK");
Harald Weltea4ca4462018-02-09 00:17:14 +0100819 BSSAP.send(ts_BSSAP_UNITDATA_req(ud_ind.callingAddress, ud_ind.calledAddress,
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200820 ts_BSSMAP_ResetAck(g_osmux_enabled)));
Pau Espin Pedrol24c05992020-09-01 12:54:12 +0200821 reset_received := true;
Harald Weltea4ca4462018-02-09 00:17:14 +0100822 repeat;
823 }
824 [] BSSAP.receive { repeat; }
Pau Espin Pedrol24c05992020-09-01 12:54:12 +0200825 [] T.timeout {
Neels Hofmeyr4f5d7be2020-10-16 16:28:16 +0200826 log("BSSMAP: Timeout waiting for RESET-ACK after sending RESET");
Pau Espin Pedrol24c05992020-09-01 12:54:12 +0200827 /* If we received a RESET after ours was sent, it
828 may be a race condition where the other peer beacame
829 available after we sent it, but we are in a desired
830 state anyway, so go forward. */
831 if (not reset_received) {
832 setverdict(fail);
833 }
834 }
Harald Weltea4ca4462018-02-09 00:17:14 +0100835 }
Harald Welte28d943e2017-11-25 15:00:50 +0100836}
837
Harald Welteae026692017-12-09 01:03:01 +0100838type record IPA_Client {
Harald Welte21b46bd2017-12-17 19:46:32 +0100839 /* IPA Emulation component reference */
Harald Welteae026692017-12-09 01:03:01 +0100840 IPA_Emulation_CT vc_IPA,
Harald Welte21b46bd2017-12-17 19:46:32 +0100841 /* Unit-ID and other CCM parameters to use for IPA client emulation */
Harald Welteae026692017-12-09 01:03:01 +0100842 IPA_CCM_Parameters ccm_pars,
Harald Welte21b46bd2017-12-17 19:46:32 +0100843 /* String identifier for this IPA Client */
Harald Welte624f9632017-12-16 19:26:04 +0100844 charstring id,
Harald Welte21b46bd2017-12-17 19:46:32 +0100845 /* Associated RSL Emulation Component (if any). Only used in "Handler mode" */
Harald Welte624f9632017-12-16 19:26:04 +0100846 RSL_Emulation_CT vc_RSL optional
Harald Welte28d943e2017-11-25 15:00:50 +0100847}
848
Harald Welte21b46bd2017-12-17 19:46:32 +0100849/*! Start the IPA/RSL related bits for one IPA_Client.
850 * \param clnt IPA_Client for which to establish
851 * \param bsc_host IP address / hostname of the BSC
852 * \param bsc_port TCP port number of the BSC
853 * \param i number identifying this BTS
854 * \param handler_mode Start an RSL_Emulation_CT component (true) or not (false) */
Harald Welte624f9632017-12-16 19:26:04 +0100855function f_ipa_rsl_start(inout IPA_Client clnt, charstring bsc_host, PortNumber bsc_port, integer i,
856 boolean handler_mode := false)
Harald Welte28d943e2017-11-25 15:00:50 +0100857runs on test_CT {
Harald Welteae026692017-12-09 01:03:01 +0100858 timer T := 10.0;
859
Harald Welte96c94412017-12-09 03:12:45 +0100860 clnt.id := "IPA" & int2str(i) & "-RSL";
Harald Welteae026692017-12-09 01:03:01 +0100861 clnt.vc_IPA := IPA_Emulation_CT.create(clnt.id & "-IPA");
862 clnt.ccm_pars := c_IPA_default_ccm_pars;
863 clnt.ccm_pars.name := "Osmocom TTCN-3 BTS Simulator";
864 clnt.ccm_pars.unit_id := int2str(1234+i) & "/0/0";
Harald Welte624f9632017-12-16 19:26:04 +0100865 if (handler_mode) {
866 clnt.vc_RSL := RSL_Emulation_CT.create(clnt.id & "-RSL");
Harald Welte89ab1912018-02-23 18:56:29 +0100867 connect(clnt.vc_RSL:CCHAN_PT, self:RSL_CCHAN[i]);
Harald Welte624f9632017-12-16 19:26:04 +0100868 }
Harald Welteae026692017-12-09 01:03:01 +0100869
870 map(clnt.vc_IPA:IPA_PORT, system:IPA_CODEC_PT);
Harald Welte624f9632017-12-16 19:26:04 +0100871 if (handler_mode) {
872 connect(clnt.vc_IPA:IPA_RSL_PORT, clnt.vc_RSL:IPA_PT);
873 } else {
874 connect(clnt.vc_IPA:IPA_RSL_PORT, self:IPA_RSL[i]);
875 }
Harald Welteae026692017-12-09 01:03:01 +0100876
Harald Welte5d1a2202017-12-13 19:51:29 +0100877 clnt.vc_IPA.start(IPA_Emulation.main_client(bsc_host, bsc_port, "", 10000+i, clnt.ccm_pars));
Harald Welte624f9632017-12-16 19:26:04 +0100878 if (handler_mode) {
879 clnt.vc_RSL.start(RSL_Emulation.main());
880 return;
881 }
Harald Welteae026692017-12-09 01:03:01 +0100882
883 /* wait for IPA RSL link to connect and send ID ACK */
884 T.start;
885 alt {
Vadim Yanitskiya2afacc2020-05-18 21:16:19 +0700886 [] IPA_RSL[i].receive(tr_ASP_IPA_EV(ASP_IPA_EVENT_ID_ACK)) {
Harald Welteae026692017-12-09 01:03:01 +0100887 T.stop;
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +0700888 IPA_RSL[i].send(ts_ASP_RSL_UD(ts_RSL_PAGING_LOAD_IND(23)));
Harald Welteae026692017-12-09 01:03:01 +0100889 }
Harald Welte60e823a2017-12-10 14:10:59 +0100890 [] IPA_RSL[i].receive(ASP_IPA_Event:?) { repeat }
Harald Welteae026692017-12-09 01:03:01 +0100891 [] IPA_RSL[i].receive { repeat }
892 [] T.timeout {
Harald Welte96c94412017-12-09 03:12:45 +0100893 setverdict(fail, "Timeout RSL waiting for ASP_IPA_EVENT_ID_ACK");
Daniel Willmannafce8662018-07-06 23:11:32 +0200894 mtc.stop;
Harald Welteae026692017-12-09 01:03:01 +0100895 }
896 }
897}
898
Harald Welte12055472018-03-17 20:10:08 +0100899function f_ipa_rsl_stop(inout IPA_Client clnt) runs on test_CT {
900 if (not isbound(clnt) or not isbound(clnt.vc_IPA)) {
901 return;
902 }
903 clnt.vc_IPA.stop;
904 if (isbound(clnt.vc_RSL)) {
905 clnt.vc_RSL.stop;
906 }
907}
908
Harald Welte21b46bd2017-12-17 19:46:32 +0100909/* Wait for the OML connection to be brought up by the external osmo-bts-omldummy */
Harald Weltea5d2ab22017-12-09 14:21:42 +0100910function f_wait_oml(integer bts_nr, charstring status, float secs_max) runs on test_CT {
911 timer T := secs_max;
912 T.start;
913 while (true) {
914 if (f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-connection-state") == status) {
915 T.stop;
Harald Weltebd868bd2017-12-10 18:28:40 +0100916 /* the 'degraded' state exists from OML connection time, and we have to wait
917 * until all MO's are initialized */
918 T.start(1.0);
919 T.timeout;
Harald Weltea5d2ab22017-12-09 14:21:42 +0100920 return;
921 }
Harald Weltef0d6ac62017-12-17 17:02:21 +0100922 f_sleep(0.1);
Harald Weltea5d2ab22017-12-09 14:21:42 +0100923 if (not T.running) {
Max99253902018-11-16 17:57:39 +0100924 setverdict(fail, "Timeout waiting for BTS" & int2str(bts_nr) & " oml-connection-state ", status);
Daniel Willmannafce8662018-07-06 23:11:32 +0200925 mtc.stop;
Harald Weltea5d2ab22017-12-09 14:21:42 +0100926 }
927 }
928}
929
Harald Welte21b46bd2017-12-17 19:46:32 +0100930/* global altstep for global guard timer; also takes care of responding RESET witH RESET-ACK */
Harald Welteae026692017-12-09 01:03:01 +0100931altstep as_Tguard() runs on test_CT {
Harald Welte60e823a2017-12-10 14:10:59 +0100932 var BSSAP_N_UNITDATA_ind ud_ind;
Neels Hofmeyrcc3f76a2018-03-12 01:43:25 +0100933 [] T_guard.timeout {
934 setverdict(fail, "Timeout of T_guard");
Daniel Willmannafce8662018-07-06 23:11:32 +0200935 mtc.stop;
Neels Hofmeyrcc3f76a2018-03-12 01:43:25 +0100936 }
Harald Welte60e823a2017-12-10 14:10:59 +0100937 /* always respond with RESET ACK to RESET */
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200938 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset(g_osmux_enabled))) -> value ud_ind {
Harald Welte60e823a2017-12-10 14:10:59 +0100939 BSSAP.send(ts_BSSAP_UNITDATA_req(ud_ind.callingAddress, ud_ind.calledAddress,
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200940 ts_BSSMAP_ResetAck(g_osmux_enabled)));
Harald Welte69c1c262017-12-13 21:02:08 +0100941 repeat;
Harald Welte60e823a2017-12-10 14:10:59 +0100942 }
Harald Welte28d943e2017-11-25 15:00:50 +0100943}
944
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +0100945altstep no_bssmap_reset() runs on test_CT {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200946 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset(g_osmux_enabled))) {
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +0100947 setverdict(fail, "unexpected BSSMAP Reset");
Daniel Willmannafce8662018-07-06 23:11:32 +0200948 mtc.stop;
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +0100949 }
950}
951
Daniel Willmann191e0d92018-01-17 12:44:35 +0100952function f_init_mgcp(charstring id) runs on test_CT {
953 id := id & "-MGCP";
954
955 var MGCPOps ops := {
956 create_cb := refers(MGCP_Emulation.ExpectedCreateCallback),
957 unitdata_cb := refers(MGCP_Emulation.DummyUnitdataCallback)
958 };
959 var MGCP_conn_parameters mgcp_pars := {
960 callagent_ip := mp_bsc_ip,
Harald Welte9e4273e2018-01-29 22:01:22 +0100961 callagent_udp_port := -1,
Daniel Willmann191e0d92018-01-17 12:44:35 +0100962 mgw_ip := mp_test_ip,
Pau Espin Pedrol1a026a52019-06-18 17:21:52 +0200963 mgw_udp_port := 2427,
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +0200964 /* Enable it for SCCPlite, since we have 2 MGCP sockets towards MGW (UDP one +
965 the on with MGCP over IPA forwarded from MSC one) */
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200966 multi_conn_mode := (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_SCCPlite_SERVER)
Daniel Willmann191e0d92018-01-17 12:44:35 +0100967 };
968
969 vc_MGCP := MGCP_Emulation_CT.create(id);
970 vc_MGCP.start(MGCP_Emulation.main(ops, mgcp_pars, id));
971}
972
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200973/* Enable or disable (current default) Osmux. When enabling, BSSMAP Reset
974 * contains extra IE (OsmuxSupport) and osmo-bsc will handle AssignReq with
975 * OsmuxCID IE.
976 */
977private function f_vty_allow_osmux(boolean allow) runs on test_CT {
978 f_vty_enter_cfg_msc(BSCVTY, 0);
979 if (allow) {
980 f_vty_transceive(BSCVTY, "osmux on");
981 } else {
982 f_vty_transceive(BSCVTY, "osmux off");
983 }
984 f_vty_transceive(BSCVTY, "exit");
985 f_vty_transceive(BSCVTY, "exit");
986 g_osmux_enabled := allow;
987}
988
Max2253c0b2018-11-06 19:28:05 +0100989function f_init_vty(charstring id := "foo") runs on test_CT {
Harald Welte94e0c342018-04-07 11:33:23 +0200990 if (BSCVTY.checkstate("Mapped")) {
991 /* skip initialization if already executed once */
992 return;
993 }
Harald Weltebc03c762018-02-12 18:09:38 +0100994 map(self:BSCVTY, system:BSCVTY);
995 f_vty_set_prompts(BSCVTY);
996 f_vty_transceive(BSCVTY, "enable");
Pau Espin Pedrolc675b612020-01-09 19:55:40 +0100997 f_cs7_inst_0_cfg(BSCVTY, {"sccp-timer ias " & int2str(g_bsc_sccp_timer_ias),
998 "sccp-timer iar " & int2str(g_bsc_sccp_timer_iar)});
Harald Weltebc03c762018-02-12 18:09:38 +0100999}
1000
Neels Hofmeyr767548a2020-08-09 20:26:07 +00001001private function f_logp(TELNETasp_PT pt, charstring log_msg)
Neels Hofmeyr4f118412020-06-04 15:25:10 +02001002{
1003 // log on TTCN3 log output
1004 log(log_msg);
1005 // log in stderr log
Neels Hofmeyr767548a2020-08-09 20:26:07 +00001006 f_vty_transceive(pt, "logp lglobal notice TTCN3 f_logp(): " & log_msg);
Neels Hofmeyr4f118412020-06-04 15:25:10 +02001007}
1008
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02001009private function f_sysinfo_seen(integer rsl_idx, RSL_Message rsl) runs on test_CT
1010{
1011 if (rsl_idx >= lengthof(g_system_information)) {
1012 g_system_information[rsl_idx] := SystemInformationConfig_omit
1013 }
1014 f_sysinfo_dec_raw(g_system_information[rsl_idx], rsl);
1015}
1016
1017altstep as_catch_RSL_sysinfo(integer rsl_idx) runs on test_CT {
1018 var ASP_RSL_Unitdata rx_rsl_ud;
1019
1020 /* For handler_mode := false, receiving the RSL bootstrap messages directly on IPA_RSL */
1021 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_NO_BCCH_INFO)) -> value rx_rsl_ud {
1022 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1023 repeat;
1024 }
1025 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_BCCH_INFO)) -> value rx_rsl_ud {
1026 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1027 repeat;
1028 }
1029 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_NO_SACCH_FILL)) -> value rx_rsl_ud {
1030 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1031 repeat;
1032 }
1033 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_SACCH_FILL)) -> value rx_rsl_ud {
1034 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1035 repeat;
1036 }
1037
1038 /* For handler_mode := true, receiving the RSL bootstrap messages via RSL_Emulation */
1039 [] RSL_CCHAN[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_NO_BCCH_INFO)) -> value rx_rsl_ud {
1040 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1041 repeat;
1042 }
1043 [] RSL_CCHAN[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_BCCH_INFO)) -> value rx_rsl_ud {
1044 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1045 repeat;
1046 }
1047 [] RSL_CCHAN[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_NO_SACCH_FILL)) -> value rx_rsl_ud {
1048 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1049 repeat;
1050 }
1051 [] RSL_CCHAN[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_SACCH_FILL)) -> value rx_rsl_ud {
1052 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1053 repeat;
1054 }
1055}
1056
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001057/* TODO: use BooleanList from COMMON/src/General_Types.ttcn */
1058private type record of boolean my_BooleanList;
1059
1060private function f_vty_msc_allow_attach(TELNETasp_PT pt, my_BooleanList allow_attach_list)
1061{
Neels Hofmeyr8f576712020-08-12 22:49:53 +00001062 var charstring config := f_vty_transceive_ret(pt, "show running-config");
1063
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001064 for (var integer msc_nr := 0; msc_nr < sizeof(allow_attach_list); msc_nr := msc_nr+1) {
Neels Hofmeyr8f576712020-08-12 22:49:53 +00001065 if (f_strstr(config, "\nmsc " & int2str(msc_nr) & "\n") < 0) {
1066 /* There is no 'msc N' for this msc_nr in the running config, so don't create an empty msc by
1067 * stepping into that config node. */
1068 log("msc ", msc_nr, " is not configured, skipping");
1069 continue;
1070 }
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001071 f_vty_enter_cfg_msc(pt, msc_nr);
1072 if (allow_attach_list[msc_nr]) {
1073 /* strict := false: ignore if osmo-bsc does not support this config option (latest build) */
1074 f_vty_transceive(pt, "allow-attach", strict := false);
1075 } else {
1076 f_vty_transceive(pt, "no allow-attach", strict := false);
1077 }
1078 f_vty_transceive(pt, "exit");
1079 f_vty_transceive(pt, "exit");
1080 }
1081}
1082
Harald Welte21b46bd2017-12-17 19:46:32 +01001083/* global initialization function
1084 * \param nr_bts Number of BTSs we should start/bring up
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001085 * \param handler_mode Start an RSL_Emulation_CT component (true) or not (false).
1086 * \param nr_msc Number of virtual MSCs to bring up to connect to osmo-bsc.
1087 */
1088function f_init(integer nr_bts := NUM_BTS, boolean handler_mode := false, boolean allow_osmux := false,
Neels Hofmeyr4fbad7f2020-06-16 00:30:47 +02001089 integer nr_msc := 1, float guard_timeout := 30.0) runs on test_CT {
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001090 var integer bssap_idx;
Harald Welte28d943e2017-11-25 15:00:50 +01001091
Harald Welteae026692017-12-09 01:03:01 +01001092 if (g_initialized) {
1093 return;
Harald Welte28d943e2017-11-25 15:00:50 +01001094 }
Harald Welteae026692017-12-09 01:03:01 +01001095 g_initialized := true;
1096
Neels Hofmeyr4fbad7f2020-06-16 00:30:47 +02001097 T_guard.start(guard_timeout);
Daniel Willmanne68f9272018-11-27 15:15:28 +01001098 activate(as_Tguard());
1099
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001100 f_init_vty("VirtMSC");
Pau Espin Pedrol58cf6822019-05-28 18:11:33 +02001101 if (mp_enable_osmux_test) {
1102 f_vty_allow_osmux(allow_osmux);
1103 }
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001104
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001105 var my_BooleanList allow_attach := { false, false, false };
Daniel Willmannebdecc02020-08-12 15:30:17 +02001106 f_init_statsd("VirtMSC", vc_STATSD, mp_test_ip, mp_bsc_statsd_port);
1107
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001108 for (bssap_idx := 0; bssap_idx < nr_msc; bssap_idx := bssap_idx+1) {
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001109 allow_attach[bssap_idx] := true;
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001110 /* Call a function of our 'parent component' RAN_Adapter_CT to start the
1111 * MSC-side BSSAP emulation */
1112 if (handler_mode) {
1113 var RanOps ranops := MSC_RanOps;
1114 ranops.use_osmux := g_osmux_enabled;
1115 f_ran_adapter_init(g_bssap[bssap_idx], mp_bssap_cfg[bssap_idx], "VirtMSC", ranops);
1116 connect(self:SCCPLITE_IPA_CTRL, g_bssap[bssap_idx].vc_RAN:CTRL_CLIENT);
1117 f_ran_adapter_start(g_bssap[bssap_idx]);
1118 } else {
1119 f_ran_adapter_init(g_bssap[bssap_idx], mp_bssap_cfg[bssap_idx], "VirtMSC", omit);
1120 connect(self:BSSAP, g_bssap[bssap_idx].vc_SCCP:SCCP_SP_PORT);
1121 f_ran_adapter_start(g_bssap[bssap_idx]);
1122 f_legacy_bssap_reset();
1123 }
Harald Welte67089ee2018-01-17 22:19:03 +01001124 }
Harald Welted5833a82018-05-27 16:52:56 +02001125
Neels Hofmeyrcfe44062020-10-15 02:28:08 +02001126 if (mp_enable_lcs_tests) {
1127 if (handler_mode) {
1128 f_bssap_le_adapter_init(g_bssap_le, mp_bssap_le_cfg, "VirtSMLC", SMLC_BssapLeOps);
1129 } else {
1130 f_bssap_le_adapter_init(g_bssap_le, mp_bssap_le_cfg, "VirtSMLC", omit);
1131 connect(self:BSSAP_LE, g_bssap_le.vc_SCCP:SCCP_SP_PORT);
1132 }
1133 f_bssap_le_adapter_start(g_bssap_le);
Harald Welte47cd0e32020-08-21 12:39:11 +02001134 }
Harald Welte47cd0e32020-08-21 12:39:11 +02001135
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001136 /* start the test with exactly all enabled MSCs allowed to attach */
1137 f_vty_msc_allow_attach(BSCVTY, allow_attach);
1138
Pau Espin Pedrol9a5b8ff2021-01-04 19:01:31 +01001139 f_ipa_ctrl_start_client(mp_bsc_ip, mp_bsc_ctrl_port);
Harald Welte28d943e2017-11-25 15:00:50 +01001140
Daniel Willmann191e0d92018-01-17 12:44:35 +01001141 f_init_mgcp("VirtMSC");
1142
Neels Hofmeyr0b7365b2020-07-04 00:52:34 +02001143 for (var integer i := 0; i < nr_bts; i := i+1) {
1144 f_init_bts(i, handler_mode);
Harald Welte696ddb62017-12-08 14:01:43 +01001145 }
Neels Hofmeyr0b7365b2020-07-04 00:52:34 +02001146}
Harald Welte696ddb62017-12-08 14:01:43 +01001147
Neels Hofmeyr0b7365b2020-07-04 00:52:34 +02001148function f_init_bts(integer bts_idx := 0, boolean handler_mode := false)
1149runs on test_CT {
1150 /* wait until osmo-bts-omldummy has respawned */
1151 f_wait_oml(bts_idx, "degraded", 5.0);
1152
1153 /* start RSL connection */
1154 f_ipa_rsl_start(bts[bts_idx].rsl, mp_bsc_ip, mp_bsc_rsl_port, bts_idx, handler_mode);
1155 /* wait until BSC tells us "connected" */
1156 f_wait_oml(bts_idx, "connected", 5.0);
Harald Welte28d943e2017-11-25 15:00:50 +01001157}
1158
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02001159function f_init_bts_and_check_sysinfo(integer bts_idx := 0, boolean handler_mode := false,
1160 template SystemInformationConfig expect_si)
1161runs on test_CT {
1162 var default sysinfo := activate(as_catch_RSL_sysinfo(bts_idx));
1163
1164 f_init_bts(bts_idx, handler_mode);
1165
1166 /* Give some time to (hopefully/most likely) collect all system informations from RSL startup.
1167 * We could stop as soon as all expected SI are received, but then we might miss SI that we don't expect and
1168 * that might be sent afterwards. So rather give a generous timeout and be quite sure to catch all SI.
1169 */
1170 f_sleep(5.0);
1171 log("RSL ", bts_idx, " SYSTEM INFORMATION: ", g_system_information[bts_idx]);
1172
1173 deactivate(sysinfo);
1174
1175 if (match(g_system_information[bts_idx], expect_si)) {
1176 setverdict(pass);
1177 } else {
1178 log("RSL ", bts_idx, ": EXPECTED SI: ", expect_si);
1179 log("RSL ", bts_idx, ": GOT SI: ", g_system_information[bts_idx]);
1180 setverdict(fail, "received SI does not match expectations");
1181 return;
1182 }
1183}
1184
Maxd4e56962018-10-31 19:08:25 +01001185/* expect to receive a RSL message matching a specified template on a given BTS / stream */
Harald Welte65e419a2020-08-21 12:38:33 +02001186function f_exp_ipa_rx(integer bts_nr, template (present) RSL_Message t_rx, float t_secs := 2.0, IpaStreamId sid := IPAC_PROTO_RSL_TRX0)
Harald Welteae026692017-12-09 01:03:01 +01001187runs on test_CT return RSL_Message {
1188 var ASP_RSL_Unitdata rx_rsl_ud;
1189 timer T := t_secs;
1190
1191 T.start;
1192 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001193 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(t_rx, sid)) -> value rx_rsl_ud {
Harald Welteae026692017-12-09 01:03:01 +01001194 T.stop;
1195 }
1196 [] IPA_RSL[bts_nr].receive { repeat; }
Harald Welteb2917702017-12-10 15:48:52 +01001197 [] T.timeout {
1198 setverdict(fail, "Timeout expecting ", t_rx);
Daniel Willmannafce8662018-07-06 23:11:32 +02001199 mtc.stop;
Harald Welteb2917702017-12-10 15:48:52 +01001200 }
Harald Welteae026692017-12-09 01:03:01 +01001201 }
1202 return rx_rsl_ud.rsl;
1203}
1204
Harald Welte21b46bd2017-12-17 19:46:32 +01001205/* helper function to transmit RSL on a given BTS/stream */
Harald Welte65e419a2020-08-21 12:38:33 +02001206function f_ipa_tx(integer bts_nr, template (value) RSL_Message t_tx, IpaStreamId sid := IPAC_PROTO_RSL_TRX0)
Harald Welteae026692017-12-09 01:03:01 +01001207runs on test_CT {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001208 IPA_RSL[bts_nr].send(ts_ASP_RSL_UD(t_tx, sid));
Harald Welteae026692017-12-09 01:03:01 +01001209}
1210
1211
Harald Welte4003d112017-12-09 22:35:39 +01001212/* verify we get a CHAN_ACT after CHAN RQD */
Harald Welteae026692017-12-09 01:03:01 +01001213testcase TC_chan_act_noreply() runs on test_CT {
1214 var BSSAP_N_UNITDATA_ind ud_ind;
Harald Welte930d0a72018-03-22 22:08:40 +01001215 var RSL_Message rsl_unused;
Harald Welte28d943e2017-11-25 15:00:50 +01001216
Harald Welte89d42e82017-12-17 16:42:41 +01001217 f_init(1);
Harald Welte28d943e2017-11-25 15:00:50 +01001218
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001219 IPA_RSL[0].send(ts_ASP_RSL_UD(ts_RSL_CHAN_RQD('23'O, 23)));
Harald Welte930d0a72018-03-22 22:08:40 +01001220 rsl_unused := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001221 f_shutdown_helper();
Harald Welte28d943e2017-11-25 15:00:50 +01001222}
1223
Harald Welte4003d112017-12-09 22:35:39 +01001224/* verify if the "chreq:total" counter increments as expected */
1225testcase TC_chan_act_counter() runs on test_CT {
1226 var BSSAP_N_UNITDATA_ind ud_ind;
1227 var integer chreq_total;
Harald Welte930d0a72018-03-22 22:08:40 +01001228 var RSL_Message rsl_unused;
Harald Welte4003d112017-12-09 22:35:39 +01001229
Harald Welte89d42e82017-12-17 16:42:41 +01001230 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01001231
1232 chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total");
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001233 IPA_RSL[0].send(ts_ASP_RSL_UD(ts_RSL_CHAN_RQD('23'O, 23)));
Harald Welte930d0a72018-03-22 22:08:40 +01001234 rsl_unused := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
Harald Welte4003d112017-12-09 22:35:39 +01001235 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total", chreq_total+1);
1236
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001237 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01001238}
1239
Harald Welteae026692017-12-09 01:03:01 +01001240/* CHAN RQD -> CHAN ACT -> CHAN ACT ACK -> RF CHAN REL */
Philipp Maier9c60a622020-07-09 15:08:46 +02001241private function f_TC_chan_act_ack_noest(OCT1 ra := '23'O) runs on test_CT {
Harald Welteae026692017-12-09 01:03:01 +01001242 var RSL_Message rx_rsl;
1243
Harald Welteae026692017-12-09 01:03:01 +01001244 /* Send CHAN RQD and wait for allocation; acknowledge it */
Philipp Maier9c60a622020-07-09 15:08:46 +02001245 var RslChannelNr chan_nr := f_chreq_act_ack(ra);
Harald Welteae026692017-12-09 01:03:01 +01001246
1247 /* expect BSC to disable the channel again if there's no RLL EST IND */
1248 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX);
1249
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001250 f_shutdown_helper();
Harald Welteae026692017-12-09 01:03:01 +01001251}
1252
Philipp Maier9c60a622020-07-09 15:08:46 +02001253/* Normal variant */
1254testcase TC_chan_act_ack_noest() runs on test_CT {
Philipp Maieraf58db22020-08-12 17:24:40 +02001255 f_init(1);
Philipp Maier9c60a622020-07-09 15:08:46 +02001256 f_TC_chan_act_ack_noest();
1257}
1258
1259/* Emergency call variant */
1260testcase TC_chan_act_ack_noest_emerg() runs on test_CT {
1261 /* See also: 3GPP TS 04.08, Table 9.9, ra=101xxxxx */
Philipp Maieraf58db22020-08-12 17:24:40 +02001262 f_init(1);
1263 f_vty_allow_emerg_bts(true, 0);
Philipp Maier9c60a622020-07-09 15:08:46 +02001264 f_TC_chan_act_ack_noest(ra := 'A5'O);
1265}
1266
Philipp Maier606f07d2020-08-12 17:21:58 +02001267/* Emergency call variant, but emergency calls are not allowed */
1268testcase TC_chan_rqd_emerg_deny() runs on test_CT {
1269 /* See also: 3GPP TS 04.08, Table 9.9, ra=101xxxxx */
1270
1271 var RSL_Message rx_rsl;
1272 var GsmRrMessage rr;
1273
1274 f_init(1);
1275 f_vty_allow_emerg_bts(false, 0);
1276
1277 IPA_RSL[0].clear;
1278 f_ipa_tx(0, ts_RSL_CHAN_RQD('A5'O, 23));
1279
1280 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeC(RSL_MT_IMMEDIATE_ASSIGN_CMD));
1281 rr := dec_GsmRrMessage(rx_rsl.ies[1].body.full_imm_ass_info.payload);
1282 if (rr.header.message_type == IMMEDIATE_ASSIGNMENT_REJECT) {
1283 setverdict(pass);
1284 } else {
1285 setverdict(fail, "immediate assignment not rejected");
1286 }
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01001287
1288 f_shutdown_helper();
Philipp Maier606f07d2020-08-12 17:21:58 +02001289}
1290
Harald Welteae026692017-12-09 01:03:01 +01001291/* Test behavior if MSC never answers to CR */
1292testcase TC_chan_act_ack_est_ind_noreply() runs on test_CT {
Harald Weltef77aef62018-01-28 15:35:42 +01001293 var RslLinkId main_dcch := valueof(ts_RslLinkID_DCCH(0));
1294 var IpaStreamId sid := IPAC_PROTO_RSL_TRX0;
Harald Welteae026692017-12-09 01:03:01 +01001295 var RSL_Message rx_rsl;
Harald Weltef77aef62018-01-28 15:35:42 +01001296 var ASP_RSL_Unitdata rx_rsl_ud;
Harald Welteae026692017-12-09 01:03:01 +01001297
Harald Welte89d42e82017-12-17 16:42:41 +01001298 f_init(1);
Harald Welteae026692017-12-09 01:03:01 +01001299
1300 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +01001301 var RslChannelNr chan_nr := f_chreq_act_ack();
Harald Welteae026692017-12-09 01:03:01 +01001302
1303 var octetstring l3 := '00010203040506'O
1304 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
1305
1306 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3)));
1307
1308 /* expect BSC to disable the channel again if there's no response from MSC */
Harald Weltef77aef62018-01-28 15:35:42 +01001309 /* MS waits 20s (T3210) at LU; 10s (T3230) at CM SERV REQ and 5s (T3220) AT detach */
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001310 f_expect_chan_rel(0, chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001311 f_shutdown_helper();
Harald Welteae026692017-12-09 01:03:01 +01001312}
1313
1314/* Test behavior if MSC answers with CREF to CR */
1315testcase TC_chan_act_ack_est_ind_refused() runs on test_CT {
1316 var BSSAP_N_CONNECT_ind rx_c_ind;
1317 var RSL_Message rx_rsl;
1318
Harald Welte89d42e82017-12-17 16:42:41 +01001319 f_init(1);
Harald Welteae026692017-12-09 01:03:01 +01001320
1321 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +01001322 var RslChannelNr chan_nr := f_chreq_act_ack();
Harald Welteae026692017-12-09 01:03:01 +01001323
1324 var octetstring l3 := '00010203040506'O
1325 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
1326
1327 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
1328 BSSAP.send(ts_BSSAP_DISC_req(rx_c_ind.connectionId, 0));
1329
1330 /* expect BSC to disable the channel */
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001331 f_expect_chan_rel(0, chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001332 f_shutdown_helper();
Harald Welteae026692017-12-09 01:03:01 +01001333}
1334
Harald Welte618ef642017-12-14 14:58:20 +01001335/* CHAN RQD -> CHAN ACT -> CHAN ACT NACK -> RF CHAN REL */
1336testcase TC_chan_act_nack() runs on test_CT {
1337 var RSL_Message rx_rsl;
1338 var integer chact_nack;
1339
Harald Welte89d42e82017-12-17 16:42:41 +01001340 f_init(1);
Harald Welte618ef642017-12-14 14:58:20 +01001341
1342 chact_nack := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chan_act:nack");
1343
1344 f_ipa_tx(0, ts_RSL_CHAN_RQD('33'O, 33));
1345 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
1346 var RslChannelNr chan_nr := rx_rsl.ies[0].body.chan_nr;
1347
1348 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, RSL_ERR_EQUIPMENT_FAIL));
1349
1350 /* wait for some time to hope the NACK arrives before the CTRL GET below */
1351 f_sleep(0.5);
1352
1353 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chan_act:nack", chact_nack+1);
1354
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001355 f_shutdown_helper();
Harald Welte618ef642017-12-14 14:58:20 +01001356}
1357
Harald Welte799c97b2017-12-14 17:50:30 +01001358/* Test for channel exhaustion due to RACH overload */
1359testcase TC_chan_exhaustion() runs on test_CT {
1360 var ASP_RSL_Unitdata rsl_ud;
1361 var integer i;
1362 var integer chreq_total, chreq_nochan;
1363
Harald Welte89d42e82017-12-17 16:42:41 +01001364 f_init(1);
Harald Welte799c97b2017-12-14 17:50:30 +01001365
1366 chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total");
1367 chreq_nochan := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel");
1368
Pau Espin Pedrolfe200d72018-12-10 12:41:04 +01001369 /* GSM 04.08 Table 9.9a:
1370 * RA = '33'O -> Establishment cause = 0011xxxx (MS dual rate capable and asks for "TCH/H or TCH/F").
1371 * With current setup, expect 4xSDCCH + 4xTCH/F + 1xTCH/H to succeed */
Philipp Maiercb6cc482018-03-26 13:08:00 +02001372 for (i := 0; i < NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS; i := i+1) {
Pau Espin Pedrolfe200d72018-12-10 12:41:04 +01001373 var RslChannelNr chan_nr := f_chreq_act_ack('33'O, i);
Harald Welte799c97b2017-12-14 17:50:30 +01001374 }
1375
1376 IPA_RSL[0].clear;
1377
Harald Weltedd8cbf32018-01-28 12:07:52 +01001378 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total",
Philipp Maiercb6cc482018-03-26 13:08:00 +02001379 chreq_total + NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS);
Harald Welte799c97b2017-12-14 17:50:30 +01001380
1381 /* now expect additional channel activations to fail */
1382 f_ipa_tx(0, ts_RSL_CHAN_RQD('42'O, 42));
1383
1384 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001385 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV))) {
Harald Welte799c97b2017-12-14 17:50:30 +01001386 setverdict(fail, "Received CHAN ACT ACK without resources?!?");
1387 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001388 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_IMM_ASSIGN(?))) -> value rsl_ud {
Harald Welte799c97b2017-12-14 17:50:30 +01001389 var GsmRrMessage rr;
1390 /* match on IMM ASS REJ */
1391 rr := dec_GsmRrMessage(rsl_ud.rsl.ies[1].body.full_imm_ass_info.payload);
1392 if (rr.header.message_type == IMMEDIATE_ASSIGNMENT_REJECT) {
1393 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total",
Philipp Maiercb6cc482018-03-26 13:08:00 +02001394 chreq_total + NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS+1);
Harald Welte799c97b2017-12-14 17:50:30 +01001395 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel",
1396 chreq_nochan+1);
1397 setverdict(pass);
1398 } else {
1399 repeat;
1400 }
1401 }
1402 [] IPA_RSL[0].receive { repeat; }
1403 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001404 f_shutdown_helper();
Harald Welte799c97b2017-12-14 17:50:30 +01001405}
1406
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07001407/* Test channel deactivation due to silence from MS */
1408testcase TC_chan_deact_silence() runs on test_CT {
1409 var RslChannelNr chan_nr;
1410
1411 f_init(1);
1412
1413 /* Request for a dedicated channel */
1414 chan_nr := f_chreq_act_ack('23'O);
1415
1416 /* Wait some time until the channel is released */
1417 f_sleep(2.0);
1418
1419 /* Expect CHANnel RELease */
1420 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001421 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL))) {
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07001422 log("Received CHANnel RELease");
1423 setverdict(pass);
1424 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001425 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_IMM_ASSIGN(?))) {
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07001426 /* See OS#3709, OsmoBSC should not send Immediate
1427 * Assignment Reject since a dedicated channel was
1428 * already allocated, and Immediate Assignment was
1429 * already sent. */
1430 setverdict(fail, "Unexpected Immediate Assignment!");
1431 }
1432 [] IPA_RSL[0].receive {
1433 setverdict(fail, "Unexpected RSL message!");
1434 }
1435 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001436 f_shutdown_helper();
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07001437}
1438
Harald Weltecfe2c962017-12-15 12:09:32 +01001439/***********************************************************************
1440 * Assignment Testing
1441 ***********************************************************************/
1442
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02001443/* Verify that the BSC refuses any BSSAP connection from the MSC (They are all BSC->MSC direction,
1444 * except for the inter-BSC handover, MT side) */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001445testcase TC_outbound_connect(integer bssap_idx := 0) runs on test_CT {
Harald Welte89d42e82017-12-17 16:42:41 +01001446 f_init(1);
Harald Weltecfe2c962017-12-15 12:09:32 +01001447
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001448 BSSAP.send(ts_BSSAP_CONNECT_req(g_bssap[bssap_idx].sccp_addr_peer, g_bssap[bssap_idx].sccp_addr_own,
1449 2342, ts_BSSMAP_AssignmentReq));
Harald Weltecfe2c962017-12-15 12:09:32 +01001450 BSSAP.receive(tr_BSSAP_DISC_ind(2342, ?, ?));
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001451 f_shutdown_helper();
Harald Weltecfe2c962017-12-15 12:09:32 +01001452}
1453
Harald Welte16a4adf2017-12-14 18:54:01 +01001454/* Test behavior if MSC answers with CREF to CR */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001455testcase TC_assignment_cic_only(integer bssap_idx := 0) runs on test_CT {
Harald Welte16a4adf2017-12-14 18:54:01 +01001456 var BSSAP_N_CONNECT_ind rx_c_ind;
1457 var RSL_Message rx_rsl;
1458 var DchanTuple dt;
1459
Harald Welte89d42e82017-12-17 16:42:41 +01001460 f_init(1);
Harald Welte16a4adf2017-12-14 18:54:01 +01001461
1462 dt := f_est_dchan('23'O, 23, '00000000'O);
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001463 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welte17b27da2018-05-25 20:33:53 +02001464 /* send assignment without AoIP IEs */
1465 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_AssignmentReq(ts_BSSMAP_IE_CIC(0, 1))));
1466 } else {
1467 /* Send assignmetn without CIC in IPA case */
1468 var BSSMAP_IE_AoIP_TransportLayerAddress tla :=
1469 valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342));
1470 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_AssignmentReq(omit, tla)));
1471 }
Harald Welte16a4adf2017-12-14 18:54:01 +01001472 alt {
1473 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentComplete)) {
1474 setverdict(fail, "AoIP BSC cannot accept ASSIGNMENT without AoIP Transport IE");
1475 }
Harald Welte235ebf12017-12-15 14:18:16 +01001476 /* TODO: Actually expect GSM0808_CAUSE_REQ_A_IF_TYPE_NOT_SUPP */
Harald Welte16a4adf2017-12-14 18:54:01 +01001477 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentFail)) {
1478 setverdict(pass);
1479 }
1480 [] BSSAP.receive { repeat; }
1481 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001482 f_shutdown_helper();
Harald Welte16a4adf2017-12-14 18:54:01 +01001483}
1484
Harald Welteed848512018-05-24 22:27:58 +02001485/* generate an assignment request for either AoIP or SCCPlite */
Pau Espin Pedrol07866632020-09-03 19:10:55 +02001486function f_gen_ass_req(boolean osmux_enabled := false, integer bssap_idx := 0, charstring aoip_tla := "1.2.3.4") return PDU_BSSAP {
Harald Welteed848512018-05-24 22:27:58 +02001487 var PDU_BSSAP ass_cmd;
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001488 var BSSMAP_IE_Osmo_OsmuxCID osmux_cid := valueof(ts_OsmuxCID(0));
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001489 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welteed848512018-05-24 22:27:58 +02001490 var BSSMAP_IE_AoIP_TransportLayerAddress tla :=
Pau Espin Pedrol07866632020-09-03 19:10:55 +02001491 valueof(f_ts_BSSMAP_IE_AoIP_TLA(aoip_tla, 2342));
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001492 if (osmux_enabled) {
1493 ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla, osmux_cid));
1494 } else {
1495 ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla));
1496 }
Harald Welteed848512018-05-24 22:27:58 +02001497 } else {
1498 var BSSMAP_IE_CircuitIdentityCode cic := valueof(ts_BSSMAP_IE_CIC(0,1));
Pau Espin Pedrol096d73d2019-06-06 12:49:17 +02001499 ass_cmd := valueof(ts_BSSMAP_AssignmentReq(cic, omit));
Harald Welteed848512018-05-24 22:27:58 +02001500 }
1501 return ass_cmd;
1502}
1503
Pau Espin Pedrol07866632020-09-03 19:10:55 +02001504function f_gen_handover_req(integer bssap_idx := 0, charstring aoip_tla := "1.2.3.4") return PDU_BSSAP {
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01001505 var PDU_BSSAP ho_req;
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001506 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01001507 var BSSMAP_IE_AoIP_TransportLayerAddress tla :=
Pau Espin Pedrol07866632020-09-03 19:10:55 +02001508 valueof(f_ts_BSSMAP_IE_AoIP_TLA(aoip_tla, 2342));
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01001509 ho_req := valueof(ts_BSSMAP_HandoverRequest(omit, tla));
1510 } else {
1511 var BSSMAP_IE_CircuitIdentityCode cic := valueof(ts_BSSMAP_IE_CIC(0,1));
1512 ho_req := valueof(ts_BSSMAP_HandoverRequest(cic, omit));
1513 }
1514 return ho_req;
1515}
1516
Harald Welteed848512018-05-24 22:27:58 +02001517/* generate an assignment complete template for either AoIP or SCCPlite */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001518function f_gen_exp_compl(boolean expect_osmux := false, integer bssap_idx := 0) return template PDU_BSSAP {
Harald Welteed848512018-05-24 22:27:58 +02001519 var template PDU_BSSAP exp_compl;
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001520 var BSSMAP_IE_Osmo_OsmuxCID osmux_cid := valueof(ts_OsmuxCID(0));
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001521 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001522 if (expect_osmux) {
1523 exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?, osmux_cid);
1524 } else {
1525 exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?, omit);
1526 }
Harald Welteed848512018-05-24 22:27:58 +02001527 } else {
1528 /* CIC is optional "*" as the MSC allocated it */
Pau Espin Pedrol096d73d2019-06-06 12:49:17 +02001529 exp_compl := tr_BSSMAP_AssignmentComplete(*, omit);
Harald Welteed848512018-05-24 22:27:58 +02001530 }
1531 return exp_compl;
1532}
1533
Harald Welte235ebf12017-12-15 14:18:16 +01001534/* Run everything required up to sending a caller-specified assignment command and expect response */
1535function f_assignment_exp(PDU_BSSAP ass_cmd, template PDU_BSSAP exp, charstring fail_text)
1536runs on test_CT {
1537 var BSSAP_N_CONNECT_ind rx_c_ind;
1538 var RSL_Message rx_rsl;
1539 var DchanTuple dt;
1540
Harald Welte89d42e82017-12-17 16:42:41 +01001541 f_init(1);
Harald Welte235ebf12017-12-15 14:18:16 +01001542
1543 dt := f_est_dchan('23'O, 23, '00000000'O);
1544 /* send assignment without AoIP IEs */
1545 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ass_cmd));
1546 alt {
1547 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentComplete)) {
1548 if (ischosen(exp.pdu.bssmap.assignmentComplete)) {
1549 setverdict(pass);
1550 } else {
1551 setverdict(fail, fail_text);
1552 }
1553 }
1554 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentFail)) {
1555 if (ischosen(exp.pdu.bssmap.assignmentFailure)) {
1556 setverdict(pass);
1557 } else {
1558 setverdict(fail, fail_text);
1559 }
1560 }
1561 [] BSSAP.receive { repeat; }
1562 }
1563}
1564testcase TC_assignment_csd() runs on test_CT {
1565 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +02001566 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte235ebf12017-12-15 14:18:16 +01001567 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeCSD);
1568 //exp_fail.pdu.bssmap.assignmentFailure.cause.causeValue := int2bit(enum2int(GSM0808_CAUSE_REQ_CODEC_TYPE_OR_CONFIG_UNAVAIL), 7);
1569 f_assignment_exp(ass_cmd, exp_fail, "BSC accepted Assignment for CSD");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001570 f_shutdown_helper();
Harald Welte235ebf12017-12-15 14:18:16 +01001571}
1572
1573testcase TC_assignment_ctm() runs on test_CT {
1574 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +02001575 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte235ebf12017-12-15 14:18:16 +01001576 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeCTM);
1577 //exp_fail.pdu.bssmap.assignmentFailure.cause.causeValue := int2bit(enum2int(GSM0808_CAUSE_REQ_CODEC_TYPE_OR_CONFIG_UNAVAIL), 7);
1578 f_assignment_exp(ass_cmd, exp_fail, "BSC accepted Assignment for Speech+CTM");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001579 f_shutdown_helper();
Harald Welte235ebf12017-12-15 14:18:16 +01001580}
1581
Harald Welte4003d112017-12-09 22:35:39 +01001582type record DchanTuple {
1583 integer sccp_conn_id,
1584 RslChannelNr rsl_chan_nr
Harald Weltea5d2ab22017-12-09 14:21:42 +01001585}
1586
Harald Welted6939652017-12-13 21:02:46 +01001587/* Send CHAN RQD and wait for allocation; acknowledge it */
1588private function f_chreq_act_ack(OCT1 ra := '23'O, GsmFrameNumber fn := 23)
1589runs on test_CT return RslChannelNr {
1590 var RSL_Message rx_rsl;
1591 f_ipa_tx(0, ts_RSL_CHAN_RQD(ra, fn));
1592 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
1593 var RslChannelNr chan_nr := rx_rsl.ies[0].body.chan_nr;
1594 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, fn+10));
Daniel Willmannf4ac4ce2018-08-02 14:06:30 +02001595 rx_rsl := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
Harald Welted6939652017-12-13 21:02:46 +01001596 return chan_nr;
1597}
1598
Harald Welte4003d112017-12-09 22:35:39 +01001599/* helper function to establish a dedicated channel via BTS and MSC */
1600function f_est_dchan(OCT1 ra, GsmFrameNumber fn, octetstring l3)
1601runs on test_CT return DchanTuple {
1602 var BSSAP_N_CONNECT_ind rx_c_ind;
Harald Welte4003d112017-12-09 22:35:39 +01001603 var DchanTuple dt;
Harald Weltea5d2ab22017-12-09 14:21:42 +01001604
Harald Welte4003d112017-12-09 22:35:39 +01001605 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +01001606 dt.rsl_chan_nr := f_chreq_act_ack(ra, fn);
Harald Welte4003d112017-12-09 22:35:39 +01001607
1608 f_ipa_tx(0, ts_RSL_EST_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
1609
1610 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
1611 dt.sccp_conn_id := rx_c_ind.connectionId;
1612 BSSAP.send(ts_BSSAP_CONNECT_res(dt.sccp_conn_id));
1613
1614 return dt;
Harald Weltea5d2ab22017-12-09 14:21:42 +01001615}
1616
Harald Welte641fcbe2018-06-14 10:58:35 +02001617/* expect RF CAN REL from BTS, acknowledge it and clear the MSC side */
1618private function f_exp_chan_rel_and_clear(DchanTuple dt, integer bts_nr := 0) runs on test_CT {
1619 var RSL_Message rx_rsl;
1620 /* expect BSC to disable the channel */
1621 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX);
1622 /* respond with CHAN REL ACK */
1623 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
1624
1625 /* expect Clear Complete from BSC */
1626 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete));
1627
1628 /* MSC disconnects as instructed. */
1629 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1630}
1631
Harald Welte4003d112017-12-09 22:35:39 +01001632/* Test behavior of channel release after unilateral RLL REL IND (DISC from MS) */
1633testcase TC_chan_rel_rll_rel_ind() runs on test_CT {
Neels Hofmeyr27f64362018-03-12 01:44:00 +01001634 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +01001635 var DchanTuple dt;
Harald Welte96c94412017-12-09 03:12:45 +01001636
Harald Welte89d42e82017-12-17 16:42:41 +01001637 f_init(1);
Harald Welte96c94412017-12-09 03:12:45 +01001638
Harald Welte4003d112017-12-09 22:35:39 +01001639 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1640
1641 /* simulate RLL REL IND */
1642 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0))));
1643
Neels Hofmeyr27f64362018-03-12 01:44:00 +01001644 /* expect Clear Request on MSC side */
1645 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
1646
1647 /* Instruct BSC to clear channel */
1648 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
1649 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
1650
Harald Welte4003d112017-12-09 22:35:39 +01001651 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02001652 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyr27f64362018-03-12 01:44:00 +01001653
1654 /* wait for SCCP emulation to do its job */
1655 f_sleep(1.0);
Harald Welte4003d112017-12-09 22:35:39 +01001656
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001657 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01001658}
1659
1660/* Test behavior of channel release after CONN FAIL IND from BTS */
1661testcase TC_chan_rel_conn_fail() runs on test_CT {
1662 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +01001663 var DchanTuple dt;
1664
Harald Welte89d42e82017-12-17 16:42:41 +01001665 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01001666
1667 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1668
1669 /* simulate CONN FAIL IND */
Harald Weltea8ed9062017-12-14 09:46:01 +01001670 f_ipa_tx(0, ts_RSL_CONN_FAIL_IND(dt.rsl_chan_nr, RSL_ERR_RADIO_LINK_FAIL));
Harald Welte4003d112017-12-09 22:35:39 +01001671 /* TODO: different cause values? */
1672
Harald Welte4003d112017-12-09 22:35:39 +01001673 /* expect Clear Request from BSC */
1674 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
1675
1676 /* Instruct BSC to clear channel */
1677 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
1678 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
1679
Harald Welte6ff76ea2018-01-28 13:08:01 +01001680 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02001681 f_exp_chan_rel_and_clear(dt, 0);
Harald Welte4003d112017-12-09 22:35:39 +01001682
1683 /* wait for SCCP emulation to do its job */
1684 f_sleep(1.0);
1685
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001686 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01001687}
1688
Harald Welte99f3ca02018-06-14 13:40:29 +02001689/* Test behavior of early CONN FAIL IND from BTS (before EST IND!) */
1690/* See also https://www.osmocom.org/issues/3182 */
1691testcase TC_early_conn_fail() runs on test_CT {
1692 var RSL_Message rx_rsl;
1693 var DchanTuple dt;
1694
1695 f_init(1);
1696
1697 /* BTS->BSC: Send CHAN RQD and wait for allocation; acknowledge it */
Harald Weltec46ea3c2020-10-10 18:46:12 +02001698 dt.rsl_chan_nr := f_chreq_act_ack(f_rnd_ra_cs(), 23);
Harald Welte99f3ca02018-06-14 13:40:29 +02001699
1700 /* BTS->BSC: simulate CONN FAIL IND */
1701 f_ipa_tx(0, ts_RSL_CONN_FAIL_IND(dt.rsl_chan_nr, RSL_ERR_RADIO_LINK_FAIL));
1702
1703 /* BTS->BSC: Expect RF channel release from BSC on Abis */
1704 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), 10.0);
1705
1706 /* BTS<-BSC: respond with CHAN REL ACK */
1707 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
1708
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001709 f_shutdown_helper();
Harald Welte99f3ca02018-06-14 13:40:29 +02001710}
1711
1712/* Test behavior of late CONN FAIL IND from BTS (ater REL IND!) */
1713/* See also https://www.osmocom.org/issues/3182 */
1714testcase TC_late_conn_fail() runs on test_CT {
1715 var RSL_Message rx_rsl;
1716 var DchanTuple dt;
1717
1718 f_init(1);
1719
1720 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1721
1722 /* BSC<-MSC: Instruct BSC to clear connection */
1723 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(0)));
1724
1725 /* BTS->BSC: expect BSC to deactivate SACCH */
1726 rx_rsl := f_exp_ipa_rx(0, tr_RSL_DEACT_SACCH(dt.rsl_chan_nr));
1727
1728 /* BTS->BSC: simulate a late CONN FAIL IND from BTS */
1729 f_ipa_tx(0, ts_RSL_CONN_FAIL_IND(dt.rsl_chan_nr, RSL_ERR_RADIO_LINK_FAIL));
1730
1731 /* BTS<-BSC: Expect RF channel release from BSC on Abis */
1732 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), 10.0);
1733 /* BTS->BSC: respond with CHAN REL ACK */
1734 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
1735
1736 /* BSC->MSC: expect Clear Complete from BSC */
1737 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete));
1738
1739 /* BSC<-MSC: MSC disconnects as requested. */
1740 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1741
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001742 f_shutdown_helper();
Harald Welte99f3ca02018-06-14 13:40:29 +02001743}
1744
Neels Hofmeyrf44ccd12018-11-05 19:15:23 +01001745function f_expect_chan_rel(integer bts_nr, RslChannelNr rsl_chan_nr,
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001746 boolean expect_deact_sacch := true,
1747 boolean expect_rr_chan_rel := true,
1748 boolean expect_rll_rel_req := true,
Harald Welte99787102019-02-04 10:41:36 +01001749 boolean handle_rll_rel := true,
Pau Espin Pedrol36bd4fa2021-04-15 13:00:24 +02001750 template CellSelIndValue expect_cells := omit,
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001751 template RR_Cause expect_rr_cause := ?
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001752 ) runs on test_CT {
Harald Welte91d54a52018-01-28 15:35:07 +01001753
1754 var RslLinkId main_dcch := valueof(ts_RslLinkID_DCCH(0));
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001755 var boolean got_deact_sacch := false;
1756 var boolean got_rr_chan_rel := false;
1757 var boolean got_rll_rel_req := false;
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001758 var ASP_RSL_Unitdata ud;
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001759 var RSL_IE_Body l3_ie;
1760 var PDU_ML3_NW_MS l3;
1761 var RR_Cause got_cause;
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001762 log("f_expect_chan_rel() expecting: expect_deact_sacch=", expect_deact_sacch, " expect_rr_chan_rel=", expect_rr_chan_rel,
1763 " expect_rll_rel_req=", expect_rll_rel_req);
Harald Welte91d54a52018-01-28 15:35:07 +01001764 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001765 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_DEACT_SACCH(rsl_chan_nr))) {
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001766 got_deact_sacch := true;
Harald Welte91d54a52018-01-28 15:35:07 +01001767 repeat;
1768 }
Pau Espin Pedrol841b90d2021-04-15 16:42:52 +02001769 [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 +01001770 got_rr_chan_rel := true;
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001771
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001772 if (f_rsl_find_ie(ud.rsl, RSL_IE_L3_INFO, l3_ie) == false) {
1773 setverdict(fail, "cannot find L3");
1774 mtc.stop;
1775 }
1776 l3 := dec_PDU_ML3_NW_MS(l3_ie.l3_info.payload);
1777
Pau Espin Pedrol36bd4fa2021-04-15 13:00:24 +02001778 if (not istemplatekind(expect_cells, "omit")) {
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001779 var CellSelIndValue cells := dec_CellSelIndValue(
1780 l3.msgs.rrm.channelRelease.cellSelectionIndicator.cellSelectionIndicatorValue);
1781
Pau Espin Pedrol36bd4fa2021-04-15 13:00:24 +02001782 log("GOT RR CHANNEL RELEASE WITH CELLS: ", cells);
1783 if (match(cells, expect_cells)) {
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001784 setverdict(pass);
1785 } else {
Pau Espin Pedrol36bd4fa2021-04-15 13:00:24 +02001786 log("EXPECTED CELLS: ", expect_cells);
1787 setverdict(fail, "Received cells list on RR Channel Release does not match expectations");
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001788 }
1789 }
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001790
1791 if (not istemplatekind(expect_rr_cause, "omit")) {
1792 int2enum(oct2int(l3.msgs.rrm.channelRelease.rRCause.valuePart), got_cause);
1793 log("GOT CAUSE CODE: ", l3.msgs.rrm.channelRelease.rRCause.valuePart, " = ", got_cause);
1794 if (match(got_cause, expect_rr_cause)) {
1795 setverdict(pass);
1796 } else {
1797 log("EXPECTED CAUSE CODE: ", expect_rr_cause);
1798 setverdict(fail, "Received RR Channel Release Cause code does not match expectations");
1799 }
1800 }
Harald Welte99787102019-02-04 10:41:36 +01001801 repeat;
1802 }
Pau Espin Pedrol841b90d2021-04-15 16:42:52 +02001803 [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 +01001804 got_rr_chan_rel := true;
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001805
1806 if (not istemplatekind(expect_rr_cause, "omit")) {
1807 if (f_rsl_find_ie(ud.rsl, RSL_IE_L3_INFO, l3_ie) == false) {
1808 setverdict(fail, "cannot find L3");
1809 mtc.stop;
1810 }
1811 l3 := dec_PDU_ML3_NW_MS(l3_ie.l3_info.payload);
1812
1813 int2enum(oct2int(l3.msgs.rrm.channelRelease.rRCause.valuePart), got_cause);
1814 log("GOT CAUSE CODE: ", l3.msgs.rrm.channelRelease.rRCause.valuePart, " = ", got_cause);
1815 if (match(got_cause, expect_rr_cause)) {
1816 setverdict(pass);
1817 } else {
1818 log("EXPECTED CAUSE CODE: ", expect_rr_cause);
1819 setverdict(fail, "Received RR Channel Release Cause code does not match expectations");
1820 }
1821 }
Neels Hofmeyr211169d2018-11-07 00:37:29 +01001822 repeat;
1823 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001824 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_REL_REQ(rsl_chan_nr, ?))) {
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001825 got_rll_rel_req := true;
Harald Welte91d54a52018-01-28 15:35:07 +01001826 /* FIXME: Why are we getting this for LinkID SACCH? */
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001827 if (handle_rll_rel) {
1828 f_ipa_tx(0, ts_RSL_REL_CONF(rsl_chan_nr, main_dcch));
1829 }
Harald Welte91d54a52018-01-28 15:35:07 +01001830 repeat;
1831 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001832 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL))) {
Harald Welte91d54a52018-01-28 15:35:07 +01001833 /* respond with CHAN REL ACK */
1834 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(rsl_chan_nr));
1835 }
1836 /* ignore any user data */
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001837 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeR(?))) {
Harald Welte91d54a52018-01-28 15:35:07 +01001838 repeat;
1839 }
1840 }
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001841
1842 log("f_expect_chan_rel() summary: got_deact_sacch=", got_deact_sacch, " got_rr_chan_rel=", got_rr_chan_rel,
1843 " got_rll_rel_req=", got_rll_rel_req);
1844
1845 if (expect_deact_sacch != got_deact_sacch) {
1846 setverdict(fail, "f_expect_chan_rel(): expect_deact_sacch=", expect_deact_sacch, " got_deact_sacch=", got_deact_sacch);
1847 }
1848 if (expect_rr_chan_rel != got_rr_chan_rel) {
1849 setverdict(fail, "f_expect_chan_rel(): expect_rr_chan_rel=", expect_rr_chan_rel, " got_rr_chan_rel=", got_rr_chan_rel);
1850 }
1851 if (expect_rll_rel_req != got_rll_rel_req) {
1852 setverdict(fail, "f_expect_chan_rel(): expect_rll_rel_req=", expect_rll_rel_req, " got_rll_rel_req=", got_rll_rel_req);
1853 }
Harald Welte91d54a52018-01-28 15:35:07 +01001854}
1855
Harald Welte4003d112017-12-09 22:35:39 +01001856/* Test behavior of channel release after hard Clear Command from MSC */
1857testcase TC_chan_rel_hard_clear() runs on test_CT {
1858 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +01001859 var DchanTuple dt;
Harald Welte4003d112017-12-09 22:35:39 +01001860
Harald Welte89d42e82017-12-17 16:42:41 +01001861 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01001862
1863 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1864
1865 /* Instruct BSC to clear channel */
1866 var BssmapCause cause := 0;
1867 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
1868
1869 /* expect Clear Complete from BSC on A */
1870 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
1871 /* release the SCCP connection */
1872 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1873 }
1874
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001875 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001876 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01001877}
1878
Pau Espin Pedrol841b90d2021-04-15 16:42:52 +02001879function f_TC_chan_rel_last_eutran_plmn_hard_clear(boolean tx_csfb_ind) runs on test_CT {
1880 var BSSAP_N_DATA_ind rx_di;
1881 var DchanTuple dt;
1882
1883 f_init(1);
1884
1885 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1886 /* Send CommonID with some random PLMN (BSC doesn't take it into account
1887 /* yet when generating the EUTRAN neigh list in RR CHannel Release) */
1888 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_CommonId('001019876543210'H, '323454'O)));
1889
1890 /* Instruct BSC to clear channel */
1891 var BssmapCause cause := 0;
1892 if (tx_csfb_ind) {
1893 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommandCSFB(cause)));
1894 } else {
1895 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
1896 }
1897
1898 /* expect Clear Complete from BSC on A */
1899 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
1900 /* release the SCCP connection */
1901 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1902 }
1903
1904 /* 1 neighbor is added by default in osmo-bts.cfg and
1905 SystemInformationConfig_default, use that: */
1906 var template CellSelIndValue exp_cells := f_tr_rr_chan_rel_earfcns(1);
1907
1908 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false, expect_cells := exp_cells);
1909 f_shutdown_helper();
1910}
1911
1912/* Test behavior of RR Channel rRelease after Clear Command without CSFB indicator
1913 from MSC, previously receiving any CommonID containing the "Last Used E-UTRAN
1914 PLMN Id". According to spec (3GPP TS 48.008 sec 3.1.30) that's the bit requesting
1915 EUTRAN neighbor list sent later on by BSC in RR Channel, so receiving CSFB
1916 Indicator or not shouldn't matter at all. */
1917testcase TC_chan_rel_last_eutran_plmn_hard_clear_no_csfb() runs on test_CT {
1918 f_TC_chan_rel_last_eutran_plmn_hard_clear(false);
1919}
1920
1921/* Test behavior of RR Channel rRelease after Clear Command with CSFB indicator from
1922 MSC, previously receiving any CommonID containing the "Last Used E-UTRAN PLMN
1923 Id". According to spec (3GPP TS 48.008 sec 3.1.30) that's the bit requesting
1924 EUTRAN neighbor list sent later on by BSC in RR Channel. */
1925testcase TC_chan_rel_last_eutran_plmn_hard_clear_csfb() runs on test_CT {
1926 f_TC_chan_rel_last_eutran_plmn_hard_clear(true);
1927}
1928
1929/* Test behavior of RR Channel Release after Clear Command with CSFB indicator from
1930 MSC, without receiving any CommonID containing the "Last Used E-UTRAN PLMN
1931 Id". According to spec (TS 48.008 version 16.0.0 Release 16 "3.2.1.21") the
1932 CSFB Indicator should not be used anymore, and hence, there should be no
1933 EUTRAN neighbor list sent by BSC in RR Channel release since no CommonId with
1934 Last Used E-UTRAN PLMN Id" IE was sent for this conn. */
Harald Welte99787102019-02-04 10:41:36 +01001935testcase TC_chan_rel_hard_clear_csfb() runs on test_CT {
1936 var BSSAP_N_DATA_ind rx_di;
1937 var DchanTuple dt;
1938
1939 f_init(1);
1940
1941 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1942
1943 /* Instruct BSC to clear channel */
1944 var BssmapCause cause := 0;
1945 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommandCSFB(cause)));
1946
1947 /* expect Clear Complete from BSC on A */
1948 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
1949 /* release the SCCP connection */
1950 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1951 }
1952
Pau Espin Pedrol841b90d2021-04-15 16:42:52 +02001953 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001954 f_shutdown_helper();
Harald Welte99787102019-02-04 10:41:36 +01001955}
1956
Harald Welted8c36cd2017-12-09 23:05:31 +01001957/* Test behavior of channel release after hard RLSD from MSC */
1958testcase TC_chan_rel_hard_rlsd() runs on test_CT {
Harald Welted8c36cd2017-12-09 23:05:31 +01001959 var DchanTuple dt;
Harald Welted8c36cd2017-12-09 23:05:31 +01001960
Harald Welte89d42e82017-12-17 16:42:41 +01001961 f_init(1);
Harald Welted8c36cd2017-12-09 23:05:31 +01001962
1963 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1964
1965 /* release the SCCP connection */
1966 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1967
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001968 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001969 f_shutdown_helper();
Harald Welted8c36cd2017-12-09 23:05:31 +01001970}
1971
Harald Welte550daf92018-06-11 19:22:13 +02001972/* Test behavior of channel release after hard RLSD from MSC and MS is not responding to RLL REL REQ */
1973testcase TC_chan_rel_hard_rlsd_ms_dead() runs on test_CT {
1974 var DchanTuple dt;
1975
1976 f_init(1);
1977
1978 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1979
1980 /* release the SCCP connection */
1981 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1982
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001983 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001984 f_shutdown_helper();
Harald Welte550daf92018-06-11 19:22:13 +02001985}
1986
Harald Welte85804d42017-12-10 14:11:58 +01001987/* Test behavior of channel release after BSSMAP RESET from MSC */
1988testcase TC_chan_rel_a_reset() runs on test_CT {
Harald Welte85804d42017-12-10 14:11:58 +01001989 var DchanTuple dt;
Harald Welte85804d42017-12-10 14:11:58 +01001990
Harald Welte89d42e82017-12-17 16:42:41 +01001991 f_init(1);
Harald Welte85804d42017-12-10 14:11:58 +01001992
1993 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1994
1995 /* Clear the queue, it might still contain stuff like IMMEDIATE ASSIGN */
1996 IPA_RSL[0].clear;
1997
1998 /* perform BSSAP RESET, expect RESET ACK and DISC.ind on connection */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001999 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 +01002000 interleave {
Neels Hofmeyrf246a922020-05-13 02:27:10 +02002001 [] 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 +01002002 [] BSSAP.receive(tr_BSSAP_DISC_ind(dt.sccp_conn_id, ?, ?)) { }
2003 }
2004
Neels Hofmeyra5302c82018-11-04 23:09:58 +01002005 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002006 f_shutdown_helper();
Harald Welte85804d42017-12-10 14:11:58 +01002007}
2008
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01002009/* Verify T(iar) triggers and releases the channel */
2010testcase TC_chan_rel_sccp_tiar_timeout() runs on test_CT {
2011 var DchanTuple dt;
2012
2013 /* Set T(iar) in BSC low enough that it will trigger before other side
2014 has time to keep alive with a T(ias). Keep recommended ratio of
2015 T(iar) >= T(ias)*2 */
2016 g_bsc_sccp_timer_ias := 2;
2017 g_bsc_sccp_timer_iar := 5;
2018
2019 f_init(1);
2020
2021 dt := f_est_dchan('23'O, 23, '00010203040506'O);
2022 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002023 f_shutdown_helper();
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01002024}
2025
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02002026private function f_tc_chan_rel_rr_cause(myBSSMAP_Cause clear_cmd_cause, template RR_Cause expect_rr_cause)
2027runs on test_CT
2028{
2029 var DchanTuple dt;
2030
2031 dt := f_est_dchan('23'O, 23, '00010203040506'O);
2032 var BssmapCause cause := 0;
2033 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(enum2int(clear_cmd_cause))));
2034 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
2035 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2036 }
2037
2038 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 +02002039}
2040
2041/* Test that Clear Command cause codes affect the RR Channel Release cause code */
2042testcase TC_chan_rel_rr_cause() runs on test_CT {
2043 f_init(1);
2044
2045 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_CALL_CONTROL, GSM48_RR_CAUSE_NORMAL);
2046 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_HANDOVER_SUCCESSFUL, GSM48_RR_CAUSE_NORMAL);
2047 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_PREEMPTION, GSM48_RR_CAUSE_PREMPTIVE_REL);
2048 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_RADIO_INTERFACE_MESSAGE_FAILURE, GSM48_RR_CAUSE_PROT_ERROR_UNSPC);
2049 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_RADIO_INTERFACE_FAILURE, GSM48_RR_CAUSE_ABNORMAL_UNSPEC);
2050 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_EQUIPMENT_FAILURE, GSM48_RR_CAUSE_ABNORMAL_UNSPEC);
Vadim Yanitskiye18aebb2021-01-03 13:10:43 +01002051
2052 f_shutdown_helper();
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02002053}
2054
Harald Welte5cd20ed2017-12-13 21:03:20 +01002055/* Test behavior if RSL EST IND for non-active channel */
2056testcase TC_rll_est_ind_inact_lchan() runs on test_CT {
2057 timer T := 2.0;
2058
Harald Welte89d42e82017-12-17 16:42:41 +01002059 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01002060
2061 var octetstring l3 := '00010203040506'O;
2062 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
2063 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
2064
2065 T.start;
2066 alt {
2067 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
2068 setverdict(fail, "MSC received COMPL L3 for non-active lchan");
2069 }
2070 [] BSSAP.receive {}
2071 [] IPA_RSL[0].receive {}
2072 [] T.timeout {}
2073 }
2074
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002075 f_shutdown_helper();
Harald Welte5cd20ed2017-12-13 21:03:20 +01002076}
2077
2078/* Test behavior if RSL EST IND for invalid SAPI */
2079testcase TC_rll_est_ind_inval_sapi1() runs on test_CT {
2080 var RslChannelNr chan_nr;
2081
Harald Welte89d42e82017-12-17 16:42:41 +01002082 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01002083
2084 chan_nr := f_chreq_act_ack()
2085
2086 var octetstring l3 := '00010203040506'O;
2087 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(1)), l3));
2088
2089 timer T := 2.0;
2090 T.start;
2091 alt {
2092 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
2093 setverdict(fail, "MSC received COMPL L3 for invalid SAPI 1");
2094 }
2095 [] BSSAP.receive { repeat; }
2096 [] IPA_RSL[0].receive { repeat; }
2097 [] T.timeout {}
2098 }
2099
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002100 f_shutdown_helper();
Harald Welte5cd20ed2017-12-13 21:03:20 +01002101}
2102
2103/* Test behavior if RSL EST IND for invalid SAPI */
2104testcase TC_rll_est_ind_inval_sapi3() runs on test_CT {
2105 timer T := 2.0;
2106
Harald Welte89d42e82017-12-17 16:42:41 +01002107 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01002108
2109 var RslChannelNr chan_nr := f_chreq_act_ack();
2110
2111 var octetstring l3 := '00010203040506'O;
2112 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(3)), l3));
2113
2114 T.start;
2115 alt {
2116 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
2117 setverdict(fail, "MSC received COMPL L3 for invalid SAPI 3");
2118 }
2119 [] BSSAP.receive { repeat; }
2120 [] IPA_RSL[0].receive { repeat; }
2121 [] T.timeout {}
2122 }
2123
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002124 f_shutdown_helper();
Harald Welte5cd20ed2017-12-13 21:03:20 +01002125}
2126
2127/* Test behavior if RSL EST IND for invalid SACCH */
2128testcase TC_rll_est_ind_inval_sacch() runs on test_CT {
2129 timer T := 2.0;
2130
Harald Welte89d42e82017-12-17 16:42:41 +01002131 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01002132
2133 var RslChannelNr chan_nr := f_chreq_act_ack();
2134
2135 var octetstring l3 := '00010203040506'O;
2136 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_SACCH(0)), l3));
2137
2138 T.start;
2139 alt {
2140 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
2141 setverdict(fail, "MSC received COMPL L3 for invalid Link SACCH");
2142 }
2143 [] BSSAP.receive { repeat; }
2144 [] IPA_RSL[0].receive { repeat; }
2145 [] T.timeout {}
2146 }
2147
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002148 f_shutdown_helper();
Harald Welte5cd20ed2017-12-13 21:03:20 +01002149}
2150
Vadim Yanitskiy61f784a2020-10-01 21:12:19 +07002151/* Verify DLCI / RSL Link ID conversion for MO/MT messages on SAPI0/SAPI3 */
2152private function f_TC_tch_dlci_link_id_sapi(charstring id) runs on MSC_ConnHdlr {
2153 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2154 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2155
2156 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2157 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
2158
2159 f_establish_fully(ass_cmd, exp_compl);
2160
2161 /* SAPI0 has already been established by f_establish_fully(), establish SAPI3 */
2162 RSL.send(ts_RSL_EST_IND(g_chan_nr, ts_RslLinkID_SACCH(3), '0904'O));
2163 /* Expect BSSAP/DTAP on SAPI3 (DLCI IE) */
2164 BSSAP.receive(PDU_BSSAP:{
2165 discriminator := '1'B,
2166 spare := '0000000'B,
2167 dlci := 'C3'O,
2168 lengthIndicator := ?,
2169 pdu := { dtap := '0904'O }
2170 });
2171
2172 /* Send messages on DCCH/SAPI0 and ACCH/SAPI3 */
2173 for (var integer i := 0; i < 32; i := i + 1) {
2174 var octetstring l3 := '09'O & f_rnd_octstring(14);
2175 var template (value) RslLinkId link_id;
2176 var template (value) OCT1 dlci;
2177
2178 if (i mod 2 == 0) {
2179 /* SAPI0 on FACCH or SDCCH */
2180 link_id := ts_RslLinkID_DCCH(0);
2181 dlci := '80'O;
2182 } else {
2183 /* SAPI3 on SACCH */
2184 link_id := ts_RslLinkID_SACCH(3);
2185 dlci := 'C3'O;
2186 }
2187
2188 /* Send MO message: RSL -> BSSAP */
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00002189 f_mo_l3_transceive(RSL, link_id, dlci, l3);
Vadim Yanitskiy61f784a2020-10-01 21:12:19 +07002190 /* Send MT message: BSSAP -> RSL */
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00002191 f_mt_l3_transceive(RSL, link_id, dlci, l3);
Vadim Yanitskiy61f784a2020-10-01 21:12:19 +07002192 }
2193}
2194testcase TC_tch_dlci_link_id_sapi() runs on test_CT {
2195 var TestHdlrParams pars := f_gen_test_hdlr_pars();
2196 var MSC_ConnHdlr vc_conn;
2197
2198 f_init(1, true);
2199 f_sleep(1.0);
2200
2201 vc_conn := f_start_handler(refers(f_TC_tch_dlci_link_id_sapi), pars);
2202 vc_conn.done;
2203
2204 f_shutdown_helper();
2205}
2206
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07002207private function f_exp_sapi_n_reject(template (present) GsmSapi sapi := ?,
2208 template myBSSMAP_Cause cause := ?,
2209 float T_val := 2.0)
2210runs on test_CT {
2211 var BSSAP_N_DATA_ind rx_di;
2212 timer T;
2213
2214 var template BSSMAP_IE_Cause tr_cause := tr_BSSMAP_IE_Cause(cause);
2215 var template PDU_BSSAP tr_pdu := tr_BSSMAP_SAPInReject(sapi);
2216
2217 T.start(T_val);
2218 alt {
2219 [] BSSAP.receive(tr_BSSAP_DATA_ind(?, tr_pdu)) -> value rx_di {
2220 var BSSMAP_IE_Cause rx_cause := rx_di.userData.pdu.bssmap.sAPInReject.cause;
2221 if (not match(rx_cause, tr_cause)) {
2222 setverdict(fail, "Rx unexpected Cause IE: ",
2223 rx_cause, " vs expected ", tr_cause);
2224 }
2225 setverdict(pass);
2226 }
2227 [] BSSAP.receive(BSSAP_N_DATA_ind:?) -> value rx_di {
2228 setverdict(fail, "Rx unexpected BSSAP PDU: ", rx_di);
2229 }
2230 [] T.timeout {
2231 setverdict(fail, "Timeout waiting for BSSMAP SAPI N Reject");
2232 }
2233 }
2234}
2235
2236/* Check if we get SAPI N Reject on receipt of unexpected RLL RELease INDication */
2237testcase TC_rll_rel_ind_sapi_n_reject() runs on test_CT {
2238 var octetstring rnd_data := f_rnd_octstring(16);
2239 var RSL_Message rx_rsl;
2240 var DchanTuple dt;
2241
2242 f_init(1);
2243
2244 /* MS establishes a SAPI=0 link on DCCH */
2245 dt := f_est_dchan(f_rnd_ra_cs(), 23, rnd_data);
2246
2247 /* MSC sends some data on (not yet established) SAPI=3 link */
2248 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSAP_DTAP(rnd_data, '03'O)));
2249 /* BSC attempts to establish a SAPI=3 link on DCCH */
2250 rx_rsl := f_exp_ipa_rx(0, tr_RSL_EST_REQ(dt.rsl_chan_nr, tr_RslLinkID_DCCH(3)));
2251
2252 /* MS sends unexpected RELease INDication on SAPI=3 */
2253 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, ts_RslLinkID_DCCH(3)));
2254 /* We expect to receive BSSMAP SAPI N Reject message from the BSC */
2255 f_exp_sapi_n_reject(3, GSM0808_CAUSE_MS_NOT_EQUIPPED);
2256
2257 /* Clean up the connection */
2258 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2259 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
2260
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002261 f_shutdown_helper();
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07002262}
2263
2264/* Check if we get SAPI N Reject on receipt of unexpected RLL ERROR INDication */
2265testcase TC_rll_err_ind_sapi_n_reject() runs on test_CT {
2266 var octetstring rnd_data := f_rnd_octstring(16);
2267 var RSL_Message rx_rsl;
2268 var DchanTuple dt;
2269
2270 f_init(1);
2271
2272 /* MS establishes a SAPI=0 link on DCCH */
2273 dt := f_est_dchan(f_rnd_ra_cs(), 23, rnd_data);
2274
2275 /* MSC sends some data on (not yet established) SAPI=3 link */
2276 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSAP_DTAP(rnd_data, '03'O)));
2277 /* BSC attempts to establish a SAPI=3 link on DCCH */
2278 rx_rsl := f_exp_ipa_rx(0, tr_RSL_EST_REQ(dt.rsl_chan_nr, tr_RslLinkID_DCCH(3)));
2279
2280 /* BTS sends unexpected ERROR INDication on SAPI=3 */
2281 f_ipa_tx(0, ts_RSL_ERROR_IND(dt.rsl_chan_nr, ts_RslLinkID_DCCH(3), ''O));
2282 /* We expect to receive BSSMAP SAPI N Reject message from the BSC */
2283 f_exp_sapi_n_reject(3, GSM0808_CAUSE_BSS_NOT_EQUIPPED);
2284
2285 /* Clean up the connection */
2286 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2287 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
2288
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002289 f_shutdown_helper();
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07002290}
2291
2292/* Check if we get SAPI N Reject due to a SAPI=3 link establishment timeout */
2293testcase TC_rll_timeout_sapi_n_reject() runs on test_CT {
2294 var octetstring rnd_data := f_rnd_octstring(16);
2295 var RSL_Message rx_rsl;
2296 var DchanTuple dt;
2297
2298 f_init(1);
2299
2300 /* MS establishes a SAPI=0 link on DCCH */
2301 dt := f_est_dchan(f_rnd_ra_cs(), 23, rnd_data);
2302
2303 /* MSC sends some data on (not yet established) SAPI=3 link */
2304 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSAP_DTAP(rnd_data, '03'O)));
2305 /* BSC attempts to establish a SAPI=3 link on DCCH */
2306 rx_rsl := f_exp_ipa_rx(0, tr_RSL_EST_REQ(dt.rsl_chan_nr, tr_RslLinkID_DCCH(3)));
2307
2308 /* MS does not respond, so the link establishment timeout triggers SAPI N Reject */
2309 f_exp_sapi_n_reject(3, GSM0808_CAUSE_BSS_NOT_EQUIPPED, T_val := 8.0);
2310
2311 /* Clean up the connection */
2312 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2313 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
2314
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002315 f_shutdown_helper();
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07002316}
2317
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02002318testcase TC_si_default() runs on test_CT {
2319 f_init(0);
2320 f_init_bts_and_check_sysinfo(0, expect_si := SystemInformationConfig_default);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002321 f_shutdown_helper();
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02002322}
Harald Welte4003d112017-12-09 22:35:39 +01002323
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002324/* We're testing SI2quater with lists of EARFCNs. Instead of just incrementing EARFCNs, also pick some from the edges of
2325 * the entire value range. This function provides the same EARFCN numbers for the same earfcn_index */
2326private function f_test_si2quater_earfcn_by_idx(integer earfcn_index) return uint16_t
2327{
2328 select (earfcn_index) {
2329 case (0) {
2330 /* E-ARFCN 111 is already added in the osmo-bsc.cfg */
2331 return 111;
2332 }
2333 case (1) {
2334 return 1;
2335 }
2336 case (2) {
2337 return 0;
2338 }
2339 case (3) {
2340 return 65535;
2341 }
2342 case else {
2343 return 23 * (earfcn_index - 3);
2344 }
2345 }
2346}
2347
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002348function f_test_si2quater(integer total_earfcns, template SystemInformationConfig expect_si,
2349 template CellSelIndValue expect_cells := omit) runs on test_CT {
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002350
2351 f_init(0);
2352
2353 /* E-ARFCN 111 is already added in the osmo-bsc.cfg, so only add more arfcns if total_earfcns > 1 */
2354 for (var integer i := 1; i < total_earfcns; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002355 f_bts_0_cfg(BSCVTY, {"si2quater neighbor-list add earfcn " & int2str(f_test_si2quater_earfcn_by_idx(i))
2356 & " thresh-hi 20 thresh-lo 10 prio 3 qrxlv 22 meas 3"});
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002357 }
2358
2359 f_init_bts_and_check_sysinfo(0, expect_si := expect_si);
2360
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002361 if (not istemplatekind(expect_cells, "omit")) {
2362 /* Also check that RR Channel Release contains these EARFCNs.
2363 * (copied code from TC_chan_rel_hard_clear_csfb) */
2364 var BSSAP_N_DATA_ind rx_di;
2365 var DchanTuple dt;
2366
2367 dt := f_est_dchan('23'O, 23, '00010203040506'O);
2368
2369 /* Instruct BSC to clear channel */
2370 var BssmapCause cause := 0;
2371 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommandCSFB(cause)));
2372
2373 /* expect Clear Complete from BSC on A */
2374 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
2375 /* release the SCCP connection */
2376 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2377 }
2378
Pau Espin Pedrol841b90d2021-04-15 16:42:52 +02002379 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 +02002380 }
2381
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002382 for (var integer i := 1; i < total_earfcns; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002383 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 +02002384 }
2385}
2386
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002387private function f_tr_si2quater_earfcns(integer count) return template SI2quaterRestOctetsList
2388{
2389 var template SI2quaterRestOctetsList si2quater := {};
2390 var integer si2quater_count := (count + 2) / 3;
2391
2392 for (var integer i := 0; i < count; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002393 var integer earfcn := f_test_si2quater_earfcn_by_idx(i);
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002394 var integer index := i / 3;
2395 var integer earfcn_index := i mod 3;
2396 if (index >= lengthof(si2quater)) {
2397 si2quater[index] := tr_SI2quaterRestOctets_EUTRAN(index := index, count := si2quater_count - 1);
2398 }
2399 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);
2400 }
2401
2402 return si2quater;
2403}
2404
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002405private function f_tr_rr_chan_rel_earfcns(integer count) return template CellSelIndValue
2406{
2407 var template CellSelIndValue_EUTRAN_Descrs cells := {};
2408
Alexander Couzensf74b5cb2020-09-10 22:28:40 +02002409 /* the lte neighbors must match the config & vty to pass this test */
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002410 for (var integer i := 0; i < count; i := i + 1) {
2411 var integer earfcn := f_test_si2quater_earfcn_by_idx(i);
Alexander Couzensf74b5cb2020-09-10 22:28:40 +02002412 cells[i] := tr_CellSelIndValue_EUTRAN_Descr(earfcn, '1'B, 3);
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002413 }
2414
2415 return tr_CellSelIndValue_EUTRAN(cells);
2416}
2417
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002418private function f_tc_si2quater_n_earfcns(integer n) runs on test_CT
2419{
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002420 var template SystemInformationConfig sic := SystemInformationConfig_default;
Pau Espin Pedrol8ab62e42020-12-18 16:19:11 +01002421 sic.si2quater := f_tr_si2quater_earfcns(n);
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002422 var template CellSelIndValue cells := f_tr_rr_chan_rel_earfcns(n);
2423 f_test_si2quater(n, sic, cells);
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002424}
2425
2426testcase TC_si2quater_2_earfcns() runs on test_CT {
2427 f_tc_si2quater_n_earfcns(2);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002428 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002429}
2430
2431testcase TC_si2quater_3_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002432 f_tc_si2quater_n_earfcns(3);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002433 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002434}
2435
2436testcase TC_si2quater_4_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002437 f_tc_si2quater_n_earfcns(4);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002438 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002439}
2440
2441testcase TC_si2quater_5_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002442 f_tc_si2quater_n_earfcns(5);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002443 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002444}
2445
2446testcase TC_si2quater_6_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002447 f_tc_si2quater_n_earfcns(6);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002448 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002449}
2450
2451testcase TC_si2quater_12_earfcns() runs on test_CT {
2452 f_tc_si2quater_n_earfcns(12);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002453 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002454}
2455
2456testcase TC_si2quater_23_earfcns() runs on test_CT {
2457 f_tc_si2quater_n_earfcns(23);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002458 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002459}
2460
2461testcase TC_si2quater_32_earfcns() runs on test_CT {
2462 f_tc_si2quater_n_earfcns(32);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002463 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002464}
2465
2466testcase TC_si2quater_33_earfcns() runs on test_CT {
2467 f_tc_si2quater_n_earfcns(33);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002468 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002469}
2470
2471testcase TC_si2quater_42_earfcns() runs on test_CT {
2472 f_tc_si2quater_n_earfcns(42);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002473 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002474}
2475
2476testcase TC_si2quater_48_earfcns() runs on test_CT {
2477 f_tc_si2quater_n_earfcns(48);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002478 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002479}
2480
2481/* verify the VTY error response when adding too many EARFCNs, and showing that osmo-bsc still sends 16 SI2quater with
2482 * 48 EARFCNs. */
2483testcase TC_si2quater_49_earfcns() runs on test_CT {
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002484 var template SystemInformationConfig sic := SystemInformationConfig_default;
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002485 sic.si2quater := f_tr_si2quater_earfcns(48); /* 48, not 49! */
2486 f_init(0);
2487
2488 for (var integer i := 1; i < 48; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002489 f_bts_0_cfg(BSCVTY, {"si2quater neighbor-list add earfcn " & int2str(f_test_si2quater_earfcn_by_idx(i))
2490 & " thresh-hi 20 thresh-lo 10 prio 3 qrxlv 22 meas 3"});
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002491 }
2492
2493 /* The 49th EARFCN no longer fits, expect VTY error */
2494 f_vty_enter_cfg_bts(BSCVTY, 0);
2495 var charstring vty_error;
2496 vty_error := f_vty_transceive_ret(BSCVTY,
2497 "si2quater neighbor-list add earfcn 70 thresh-hi 20 thresh-lo 10 prio 3 qrxlv 22 meas 3")
2498 f_vty_transceive(BSCVTY, "end");
2499
2500 if (f_strstr(vty_error, "Unable to add ARFCN 70") >= 0) {
2501 log("Got expected VTY error: ", vty_error);
2502 setverdict(pass);
2503 } else {
2504 setverdict(fail, "Expected the 49th EUTRAN ARFCN to be rejected by vty config, got: ", vty_error);
2505 }
2506
2507 f_init_bts_and_check_sysinfo(0, expect_si := sic);
2508
2509 for (var integer i := 1; i < 48; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002510 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 +02002511 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002512 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002513}
2514
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002515private function f_acc09_count_allowed(AccessControlClass acc) return uint8_t
2516{
2517 var uint8_t count := 0;
2518 for (var integer i := 5; i < 16; i := i + 1) {
2519 if (acc[i] == '0'B) { /* the list marks barred, we count allowed */
2520 count := count + 1;
2521 }
2522 }
2523 return count;
2524}
2525
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002526private function f_recv_next_si1(integer rsl_idx := 0) runs on test_CT return SystemInformationType1
2527{
2528 var ASP_RSL_Unitdata rx_rsl_ud;
2529 var SystemInformationType1 last_si1;
2530
2531 timer T := 30.0;
2532 T.start;
2533 alt {
2534 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD((tr_RSL_NO_BCCH_INFO,
2535 tr_RSL_BCCH_INFO,
2536 tr_RSL_NO_SACCH_FILL,
2537 tr_RSL_SACCH_FILL))
2538 ) -> value rx_rsl_ud {
2539 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
2540 if (g_system_information[rsl_idx].si1 == omit) {
2541 repeat;
2542 }
2543 last_si1 := g_system_information[rsl_idx].si1;
2544 g_system_information[rsl_idx].si1 := omit;
2545 T.stop;
2546 }
Vadim Yanitskiy79ebd5e2021-01-04 00:12:55 +01002547 [] IPA_RSL[rsl_idx].receive { repeat; }
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002548 [] T.timeout { setverdict(fail, "Timeout receiving next SI1"); }
2549 }
2550 return last_si1;
2551}
2552
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002553/* verify ACC rotate feature */
2554testcase TC_si_acc_rotate() runs on test_CT {
2555 var template SystemInformationConfig sic := SystemInformationConfig_default;
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002556 var SystemInformationType1 last_si1;
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002557 var AccessControlClass acc;
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002558 var uint8_t count;
2559 var integer times_allowed[10] := { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
2560
2561 f_init(0, guard_timeout := 60.0);
2562
2563 f_bts_0_cfg(BSCVTY, {"rach access-control-class 5 barred",
2564 "access-control-class-rotate 3",
2565 "access-control-class-rotate-quantum 1"});
2566
2567 /* Init and get first sysinfo */
2568 f_init_bts_and_check_sysinfo(0, expect_si := ?);
2569
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002570 for (var integer i:= 0; i < 20; i := i + 1) {
2571 last_si1 := f_recv_next_si1(0);
2572 acc := last_si1.rach_control.acc;
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002573 count := f_acc09_count_allowed(acc);
2574 log("RSL: GOT SI1 ACC len=", count, ": ", acc);
2575
2576 if (count != 3) {
2577 log("RSL: EXPECTED SI ACC len=3");
2578 setverdict(fail, "received SI does not match expectations");
2579 break;
2580 }
2581
2582 for (var integer j := 0; j < 10; j := j + 1) {
2583 if (acc[16 - 1 - j] == '0'B) { /* the list marks barred, we count allowed */
2584 times_allowed[j] := times_allowed[j] + 1;
2585 }
2586 }
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002587 }
2588
2589 for (var integer j := 0; j < 10; j := j + 1) {
2590 log("ACC", j, " allowed ", times_allowed[j], " times" );
2591 if (j != 5 and times_allowed[j] < 3) {
2592 setverdict(fail, "ACC", j, " ERROR: allowed ", times_allowed[j], " < 1 times");
2593 } else if (j == 5 and times_allowed[j] > 0) {
2594 setverdict(fail, "ACC", j, " ERROR: allowed ", times_allowed[j], " > 0 times");
2595 }
2596 }
2597
2598 f_bts_0_cfg(BSCVTY, {"access-control-class-rotate 10",
2599 "rach access-control-class 5 allowed"});
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002600 f_shutdown_helper();
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002601}
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002602
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002603/* verify ACC startup ramp+rotate feature */
2604testcase TC_si_acc_ramp_rotate() runs on test_CT {
2605 var template SystemInformationConfig sic := SystemInformationConfig_default;
2606 var SystemInformationType1 last_si1;
2607 var AccessControlClass acc;
2608 var ASP_RSL_Unitdata rx_rsl_ud;
2609 var uint8_t count;
2610 var uint8_t prev_count;
2611 var integer times_allowed[10] := { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
2612
2613 f_init(0, guard_timeout := 80.0);
2614
2615 f_bts_0_cfg(BSCVTY, {"rach access-control-class 4 barred",
2616 "access-control-class-rotate 0",
2617 "access-control-class-rotate-quantum 1",
2618 "access-control-class-ramping",
2619 "access-control-class-ramping-step-interval 5",
2620 "access-control-class-ramping-step-size 5"});
2621
2622 /* Init and get first sysinfo */
2623 f_init_bts_and_check_sysinfo(0, expect_si := ?);
2624 last_si1 := g_system_information[0].si1;
2625 acc := last_si1.rach_control.acc;
2626 count := f_acc09_count_allowed(acc);
2627 /* Adm subset size was set to 0 above, so wait until all ACC are barred */
2628 while (count > 0) {
2629 last_si1 := f_recv_next_si1(0);
2630 acc := last_si1.rach_control.acc;
2631 count := f_acc09_count_allowed(acc);
2632 log("RSL: wait len()=0: GOT SI1 ACC len=", count, ": ", acc);
2633 }
2634
2635 /* Increase adm subset size, we should see ramping start up */
2636 f_bts_0_cfg(BSCVTY, {"access-control-class-rotate 10"});
2637 prev_count := 0;
2638 while (true) {
2639 last_si1 := f_recv_next_si1(0);
2640 acc := last_si1.rach_control.acc;
2641 count := f_acc09_count_allowed(acc);
2642 log("RSL: GOT SI1 ACC len=", count, ": ", acc);
2643
2644 if (prev_count > count) {
2645 setverdict(fail, "ACC allowed count dropped while expecting grow: ", prev_count, " -> ", count);
2646 break;
2647 }
2648
2649 if (count == 9) {
2650 break; /* Maximum reached (10 - 1 perm barred), done here */
2651 }
2652
2653 prev_count := count;
2654 }
2655
2656 setverdict(pass);
2657
2658 f_bts_0_cfg(BSCVTY, {"access-control-class-rotate 10",
2659 "rach access-control-class 4 allowed",
2660 "no access-control-class-ramping"});
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002661 f_shutdown_helper();
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002662}
2663
Harald Welte4003d112017-12-09 22:35:39 +01002664testcase TC_ctrl_msc_connection_status() runs on test_CT {
2665 var charstring ctrl_resp;
2666
Harald Welte89d42e82017-12-17 16:42:41 +01002667 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01002668
2669 /* See https://osmocom.org/issues/2729 */
2670 f_ctrl_get_exp(IPA_CTRL, "msc_connection_status", "connected");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002671 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01002672}
2673
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01002674testcase TC_ctrl_msc0_connection_status() runs on test_CT {
2675 var charstring ctrl_resp;
2676
2677 f_init(1);
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01002678
2679 f_ctrl_get_exp(IPA_CTRL, "msc.0.connection_status", "connected");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002680 f_shutdown_helper();
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01002681}
2682
Harald Welte4003d112017-12-09 22:35:39 +01002683testcase TC_ctrl() runs on test_CT {
2684 var charstring ctrl_resp;
2685
Harald Welte89d42e82017-12-17 16:42:41 +01002686 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01002687
2688 /* all below values must match the osmo-bsc.cfg config file used */
2689
Harald Welte6a129692018-03-17 17:30:14 +01002690 f_ctrl_get_exp(IPA_CTRL, "mcc", "001");
2691 f_ctrl_get_exp(IPA_CTRL, "mnc", "01");
Oliver Smith75aa0202019-08-19 14:17:50 +02002692 f_ctrl_get_exp(IPA_CTRL, "number-of-bts", "4");
Harald Welte4003d112017-12-09 22:35:39 +01002693
2694 var integer bts_nr := 0;
2695 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "location-area-code", "1");
2696 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "cell-identity", "0");
2697 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "oml-connection-state", "connected");
2698 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "gprs-mode", "gprs");
2699 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "rf_state", "operational,unlocked,on");
2700 f_ctrl_get_exp_trx(IPA_CTRL, bts_nr, 0, "arfcn", "871");
2701 f_ctrl_get_exp_trx(IPA_CTRL, bts_nr, 0, "max-power-reduction", "20");
2702
2703 var integer uptime := str2int(f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-uptime"));
2704 f_sleep(2.0);
2705 if (str2int(f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-uptime")) < uptime+1) {
2706 setverdict(fail, "oml-uptime not incrementing as expected");
2707 }
2708 /* TODO: Disconnect RSL, imply that OML is disconnected and check for uptime zero? */
2709
2710 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted", 0);
2711
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002712 f_shutdown_helper();
Harald Welte96c94412017-12-09 03:12:45 +01002713}
2714
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +02002715/* Verify that Upon receival of SET "location", BSC forwards a TRAP
2716 "location-state" over the SCCPlite IPA conn */
2717testcase TC_ctrl_location() runs on test_CT {
2718 var MSC_ConnHdlr vc_conn;
2719 var integer bts_nr := 0;
2720
2721 f_init(1, true);
2722 f_sleep(1.0);
2723
2724 f_ctrl_set_bts(IPA_CTRL, bts_nr, "location", "1234567,fix3d,0.340000,0.560000,0.780000");
2725 f_ctrl_exp_trap(SCCPLITE_IPA_CTRL, "bts." & int2str(bts_nr) & ".location-state",
2726 "1234567,fix3d,0.340000,0.560000,0.780000,operational,unlocked,on,001,01");
2727
2728 f_ctrl_set(SCCPLITE_IPA_CTRL, "rf_locked", "1");
2729 f_sleep(2.0);
2730
2731 f_ctrl_set_bts(IPA_CTRL, bts_nr, "location", "1234888,fix3d,0.350000,0.570000,0.790000");
2732 f_ctrl_exp_trap(SCCPLITE_IPA_CTRL, "bts." & int2str(bts_nr) & ".location-state",
2733 "1234888,fix3d,0.350000,0.570000,0.790000,operational,locked,off,001,01");
2734
2735 /* should match the one from config */
2736 f_ctrl_set(SCCPLITE_IPA_CTRL, "rf_locked", "0");
2737
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002738 f_shutdown_helper();
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +02002739}
2740
Harald Welte6f521d82017-12-11 19:52:02 +01002741
2742/***********************************************************************
2743 * Paging Testing
2744 ***********************************************************************/
2745
2746type record Cell_Identity {
2747 GsmMcc mcc,
2748 GsmMnc mnc,
2749 GsmLac lac,
2750 GsmCellId ci
2751};
Harald Welte24135bd2018-03-17 19:27:53 +01002752private const Cell_Identity cid := { '001'H, '01'H, 1, 0 };
Stefan Sperling049a86e2018-03-20 15:51:00 +01002753private const Cell_Identity unknown_cid := { '678'H, 'f90'H, 1, 0 };
Harald Welte6f521d82017-12-11 19:52:02 +01002754
Harald Welte5d1a2202017-12-13 19:51:29 +01002755type set of integer BtsIdList;
2756
2757private function f_bts_in_list(integer bts_id, BtsIdList bts_ids) return boolean {
2758 for (var integer j := 0; j < sizeof(bts_ids); j := j + 1) {
2759 if (bts_id == bts_ids[j]) {
2760 return true;
2761 }
2762 }
2763 return false;
2764}
Harald Welte6f521d82017-12-11 19:52:02 +01002765
2766/* core paging test helper function; used by most paging test cases */
2767private function f_pageing_helper(hexstring imsi,
2768 template BSSMAP_FIELD_CellIdentificationList cid_list,
Harald Welte5d1a2202017-12-13 19:51:29 +01002769 BtsIdList bts_ids := { 0 },
Harald Welte6f521d82017-12-11 19:52:02 +01002770 template RSL_ChanNeeded rsl_chneed := omit,
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002771 template (omit) OCT4 tmsi := omit) runs on test_CT
Harald Welte6f521d82017-12-11 19:52:02 +01002772{
2773 var template BSSMAP_IE_ChannelNeeded bssmap_chneed;
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002774 var template MobileIdentityV mi;
Harald Welte6f521d82017-12-11 19:52:02 +01002775 var RSL_Message rx_rsl;
2776 var integer paging_group := hex2int(imsi[lengthof(imsi)-1]);
Harald Welte5d1a2202017-12-13 19:51:29 +01002777 var integer i;
Harald Welte6f521d82017-12-11 19:52:02 +01002778
2779 f_init();
Harald Welte6f521d82017-12-11 19:52:02 +01002780
2781 /* Clear the queue, it might still contain stuff like BCCH FILLING */
Harald Weltec3068592018-03-17 19:55:31 +01002782 for (i := 0; i < NUM_BTS; i := i + 1) {
2783 IPA_RSL[i].clear;
Harald Welte5d1a2202017-12-13 19:51:29 +01002784 }
Harald Welte6f521d82017-12-11 19:52:02 +01002785
2786 if (isvalue(rsl_chneed)) {
2787 /* The values of 08.08 3.2.2.36 and 08.58 9.3.40 are luckily identical */
2788 bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
2789 } else {
2790 bssmap_chneed := omit;
2791 }
2792
Neels Hofmeyrf246a922020-05-13 02:27:10 +02002793 BSSAP.send(ts_BSSAP_UNITDATA_req(g_bssap[0].sccp_addr_peer, g_bssap[0].sccp_addr_own,
2794 ts_BSSMAP_Paging(imsi, cid_list, tmsi, bssmap_chneed)));
Harald Welte6f521d82017-12-11 19:52:02 +01002795
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002796 if (not istemplatekind(tmsi, "omit")) {
2797 mi := t_MI_TMSI(tmsi);
Harald Welte6f521d82017-12-11 19:52:02 +01002798 } else {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002799 mi := tr_MI_IMSI(imsi);
Harald Welte6f521d82017-12-11 19:52:02 +01002800 }
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002801
Harald Welte5d1a2202017-12-13 19:51:29 +01002802 for (i := 0; i < sizeof(bts_ids); i := i + 1) {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002803 rx_rsl := f_exp_ipa_rx(bts_ids[i], tr_RSL_PAGING_CMD(mi));
Harald Welte5d1a2202017-12-13 19:51:29 +01002804 /* check channel type, paging group */
2805 if (rx_rsl.ies[1].body.paging_group != paging_group) {
2806 setverdict(fail, "Paging for wrong paging group");
2807 }
2808 if (ispresent(rsl_chneed) and
2809 rx_rsl.ies[3].body.chan_needed.chan_needed != valueof(rsl_chneed)) {
2810 setverdict(fail, "RSL Channel Needed != BSSMAP Channel Needed");
2811 }
Harald Welte6f521d82017-12-11 19:52:02 +01002812 }
Harald Welte2fccd982018-01-31 15:48:19 +01002813 f_sleep(2.0);
Harald Welte5d1a2202017-12-13 19:51:29 +01002814 /* do a quick check on all not-included BTSs if they received paging */
2815 for (i := 0; i < NUM_BTS; i := i + 1) {
2816 timer T := 0.1;
2817 if (f_bts_in_list(i, bts_ids)) {
2818 continue;
2819 }
2820 T.start;
2821 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07002822 [] IPA_RSL[i].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(mi))) {
Harald Welte5d1a2202017-12-13 19:51:29 +01002823 setverdict(fail, "Paging on BTS ", i, " which is not part of ", bts_ids);
2824 }
2825 [] IPA_RSL[i].receive { repeat; }
2826 [] T.timeout { }
2827 }
Harald Welte6f521d82017-12-11 19:52:02 +01002828 }
2829
2830 setverdict(pass);
2831}
2832
Harald Welte5d1a2202017-12-13 19:51:29 +01002833const BtsIdList c_BtsId_all := { 0, 1, 2 };
Harald Welte751d3eb2018-01-31 15:51:06 +01002834const BtsIdList c_BtsId_none := { };
Harald Welte5d1a2202017-12-13 19:51:29 +01002835const BtsIdList c_BtsId_LAC1 := { 0, 1 };
2836const BtsIdList c_BtsId_LAC2 := { 2 };
2837
Harald Welte6f521d82017-12-11 19:52:02 +01002838/* PAGING by IMSI + TMSI */
2839testcase TC_paging_imsi_nochan() runs on test_CT {
2840 var BSSMAP_FIELD_CellIdentificationList cid_list;
2841 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Philipp Maier8c04b0a2018-02-23 13:48:48 +01002842 f_pageing_helper('001010100000001'H, cid_list, c_BtsId_all, omit, omit);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002843 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002844}
2845
2846/* PAGING by IMSI + TMSI */
2847testcase TC_paging_tmsi_nochan() runs on test_CT {
2848 var BSSMAP_FIELD_CellIdentificationList cid_list;
2849 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002850 f_pageing_helper('001010100000001'H, cid_list, c_BtsId_all, omit, 'A1B2C301'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002851 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002852}
2853
2854/* Paging with different "channel needed' values */
2855testcase TC_paging_tmsi_any() runs on test_CT {
2856 var BSSMAP_FIELD_CellIdentificationList cid_list;
2857 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002858 f_pageing_helper('001010100000002'H, cid_list, c_BtsId_all, RSL_CHANNEED_ANY, 'A1B2C302'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002859 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002860}
2861testcase TC_paging_tmsi_sdcch() runs on test_CT {
2862 var BSSMAP_FIELD_CellIdentificationList cid_list;
2863 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002864 f_pageing_helper('001010100000003'H, cid_list, c_BtsId_all, RSL_CHANNEED_SDCCH, 'A1B2C303'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002865 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002866}
2867testcase TC_paging_tmsi_tch_f() runs on test_CT {
2868 var BSSMAP_FIELD_CellIdentificationList cid_list;
2869 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002870 f_pageing_helper('001010000000004'H, cid_list, c_BtsId_all, RSL_CHANNEED_TCH_F, 'A1B2C304'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002871 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002872}
2873testcase TC_paging_tmsi_tch_hf() runs on test_CT {
2874 var BSSMAP_FIELD_CellIdentificationList cid_list;
2875 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002876 f_pageing_helper('001010000000005'H, cid_list, c_BtsId_all, RSL_CHANNEED_TCH_ForH, 'A1B2C305'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002877 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002878}
2879
2880/* Paging by CGI */
2881testcase TC_paging_imsi_nochan_cgi() runs on test_CT {
2882 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2883 cid_list := { cIl_CGI := { ts_BSSMAP_CI_CGI(cid.mcc, cid.mnc, cid.lac, cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002884 f_pageing_helper('001010000000006'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01002885 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002886}
2887
2888/* Paging by LAC+CI */
2889testcase TC_paging_imsi_nochan_lac_ci() runs on test_CT {
2890 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2891 cid_list := { cIl_LAC_CI := { ts_BSSMAP_CI_LAC_CI(cid.lac, cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002892 f_pageing_helper('001010000000007'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01002893 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002894}
2895
2896/* Paging by CI */
2897testcase TC_paging_imsi_nochan_ci() runs on test_CT {
2898 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2899 cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002900 f_pageing_helper('001010000000008'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01002901 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002902}
2903
2904/* Paging by LAI */
2905testcase TC_paging_imsi_nochan_lai() runs on test_CT {
2906 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2907 cid_list := { cIl_LAI := { ts_BSSMAP_CI_LAI(cid.mcc, cid.mnc, cid.lac) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002908 f_pageing_helper('001010000000009'H, cid_list, c_BtsId_LAC1);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002909 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002910}
2911
2912/* Paging by LAC */
2913testcase TC_paging_imsi_nochan_lac() runs on test_CT {
2914 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2915 cid_list := { cIl_LAC := { ts_BSSMAP_CI_LAC(cid.lac) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002916 f_pageing_helper('001010000000010'H, cid_list, c_BtsId_LAC1);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002917 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002918}
2919
2920/* Paging by "all in BSS" */
2921testcase TC_paging_imsi_nochan_all() runs on test_CT {
2922 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2923 cid_list := { cIl_allInBSS := ''O };
Harald Welte5d1a2202017-12-13 19:51:29 +01002924 f_pageing_helper('001010000000011'H, cid_list, c_BtsId_all);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002925 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002926}
2927
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002928/* Paging by PLMN+LAC+RNC; We do not implement this; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01002929testcase TC_paging_imsi_nochan_plmn_lac_rnc() runs on test_CT {
2930 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2931 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 +01002932 f_pageing_helper('001010000000012'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002933 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002934}
Harald Welte6f521d82017-12-11 19:52:02 +01002935
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002936/* Paging by RNC; We do not implement this; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01002937testcase TC_paging_imsi_nochan_rnc() runs on test_CT {
2938 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2939 cid_list := { cIl_RNC := { int2oct(13, 2) } };
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002940 f_pageing_helper('001010000000013'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002941 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002942}
2943
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002944/* Paging by LAC+RNC; We do not implement; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01002945testcase TC_paging_imsi_nochan_lac_rnc() runs on test_CT {
2946 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2947 cid_list := { cIl_LAC_RNC := { ts_BSSMAP_CI_LAC_RNC(cid.lac, 14) } };
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002948 f_pageing_helper('001010000000014'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002949 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002950}
2951
Harald Welte6f521d82017-12-11 19:52:02 +01002952/* Paging on multiple cells (multiple entries in list): Verify all of them page */
Harald Welte751d3eb2018-01-31 15:51:06 +01002953testcase TC_paging_imsi_nochan_lacs() runs on test_CT {
2954 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2955 cid_list := { cIl_LAC := { ts_BSSMAP_CI_LAC(1), ts_BSSMAP_CI_LAC(2) } };
2956 f_pageing_helper('001010000000015'H, cid_list, c_BtsId_all);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002957 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002958}
2959
2960/* Paging on empty list: Verify none of them page */
2961testcase TC_paging_imsi_nochan_lacs_empty() runs on test_CT {
2962 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2963 cid_list := { cIl_LAC := { } };
2964 f_pageing_helper('001010000000016'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002965 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002966}
2967
Stefan Sperling049a86e2018-03-20 15:51:00 +01002968/* Paging by CGI with unknown MCC/MNC: Verify nothing is paged. */
2969testcase TC_paging_imsi_nochan_cgi_unknown_cid() runs on test_CT {
2970 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2971 cid_list := { cIl_CGI := { ts_BSSMAP_CI_CGI(unknown_cid.mcc, unknown_cid.mnc, unknown_cid.lac, unknown_cid.ci) } };
2972 f_pageing_helper('001010000000006'H, cid_list, c_BtsId_none);
2973 f_shutdown_helper();
2974}
2975
Harald Welte6f521d82017-12-11 19:52:02 +01002976/* Verify paging retransmission interval + count */
2977/* Verify paging stops after channel establishment */
Harald Welte6f521d82017-12-11 19:52:02 +01002978/* Test behavior under paging overload */
Harald Welteae026692017-12-09 01:03:01 +01002979
Harald Weltee65d40e2017-12-13 00:09:06 +01002980/* Verify PCH load */
2981testcase TC_paging_imsi_load() runs on test_CT {
2982 var BSSMAP_FIELD_CellIdentificationList cid_list;
2983 timer T := 4.0;
Harald Welte2caa1062018-03-17 18:19:05 +01002984 timer T_retrans := 1.0;
Harald Weltee65d40e2017-12-13 00:09:06 +01002985 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002986 f_pageing_helper('001010123456789'H, cid_list, c_BtsId_all);
Harald Weltee65d40e2017-12-13 00:09:06 +01002987
2988 /* tell BSC there is no paging space anymore */
2989 f_ipa_tx(0, ts_RSL_PAGING_LOAD_IND(0));
Harald Welte3b57ab52018-03-17 18:01:10 +01002990 f_sleep(0.2);
2991 IPA_RSL[0].clear;
Harald Weltee65d40e2017-12-13 00:09:06 +01002992
2993 /* Wait for 4 seconds if any more PAGING CMD are received on RSL. Normally,
2994 * there would be 8 retransmissions during 4 seconds */
2995 T.start;
Harald Welte2caa1062018-03-17 18:19:05 +01002996 T_retrans.start;
Harald Weltee65d40e2017-12-13 00:09:06 +01002997 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07002998 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Weltee65d40e2017-12-13 00:09:06 +01002999 setverdict(fail, "Received PAGING after LOAD_IND(0)");
Daniel Willmannafce8662018-07-06 23:11:32 +02003000 mtc.stop;
Harald Weltee65d40e2017-12-13 00:09:06 +01003001 }
Harald Welte2caa1062018-03-17 18:19:05 +01003002 [] T_retrans.timeout {
3003 /* re-trnsmit the zero-space LOAD IND to avoid BSC 'auto credit' */
3004 f_ipa_tx(0, ts_RSL_PAGING_LOAD_IND(0));
3005 T_retrans.start;
3006 repeat;
3007 }
Harald Weltee65d40e2017-12-13 00:09:06 +01003008 [] T.timeout {
3009 setverdict(pass);
3010 }
3011 }
Philipp Maier282ca4b2018-02-27 17:17:00 +01003012
3013 f_shutdown_helper();
Harald Weltee65d40e2017-12-13 00:09:06 +01003014}
3015
Harald Welte235ebf12017-12-15 14:18:16 +01003016/* Verify Paging Counter */
Harald Welte1ff69992017-12-14 12:31:17 +01003017testcase TC_paging_counter() runs on test_CT {
3018 var BSSMAP_FIELD_CellIdentificationList cid_list;
3019 timer T := 4.0;
3020 var integer i;
3021 var integer paging_attempted_bsc;
3022 var integer paging_attempted_bts[NUM_BTS];
3023 var integer paging_expired_bts[NUM_BTS];
3024 cid_list := valueof(ts_BSSMAP_CIL_noCell);
3025
3026 f_init();
3027
3028 /* read counters before paging */
3029 paging_attempted_bsc := f_ctrl_get_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted");
3030 for (i := 0; i < NUM_BTS; i := i+1) {
3031 paging_attempted_bts[i] := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", i, "paging:attempted");
3032 paging_expired_bts[i] := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", i, "paging:expired");
3033 }
3034
3035 f_pageing_helper('001230000000001'H, cid_list, c_BtsId_all);
3036
3037 /* expect the attempted pages on BSC and each BTSs to have incremented by one */
3038 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted", paging_attempted_bsc+1);
3039 for (i := 0; i < NUM_BTS; i := i+1) {
3040 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", i, "paging:attempted",
3041 paging_attempted_bts[i]+1);
3042 }
3043
3044 /* assume that 12s later the paging on all BTSs have expired and hence incremented by 1 */
3045 f_sleep(12.0);
3046 for (i := 0; i < NUM_BTS; i := i+1) {
3047 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", i, "paging:expired",
3048 paging_expired_bts[i]+1);
3049 }
Harald Welte1ff69992017-12-14 12:31:17 +01003050
Philipp Maier282ca4b2018-02-27 17:17:00 +01003051 f_shutdown_helper();
Harald Welte1ff69992017-12-14 12:31:17 +01003052}
3053
3054
Harald Welte10985002017-12-12 09:29:15 +01003055/* Verify paging stops after A-RESET */
3056testcase TC_paging_imsi_a_reset() runs on test_CT {
3057 var BSSMAP_FIELD_CellIdentificationList cid_list;
3058 timer T := 3.0;
3059 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01003060 f_pageing_helper('001010123456789'H, cid_list, c_BtsId_all);
Harald Welte10985002017-12-12 09:29:15 +01003061
3062 /* Perform a BSSMAP Reset and wait for ACK */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003063 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 +01003064 alt {
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003065 [] 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 +01003066 [] BSSAP.receive { repeat; }
3067 }
3068
Daniel Willmanncbef3982018-07-30 09:22:40 +02003069 /* Wait to avoid a possible race condition if a paging message is
3070 * received right before the reset ACK. */
3071 f_sleep(0.2);
3072
Harald Welte10985002017-12-12 09:29:15 +01003073 /* Clear the queue, it might still contain stuff like BCCH FILLING */
Philipp Maier1e6b4422018-02-23 14:02:13 +01003074 for (var integer i := 0; i < sizeof(IPA_RSL); i := i+1) {
3075 IPA_RSL[i].clear;
3076 }
Harald Welte10985002017-12-12 09:29:15 +01003077
3078 /* Wait for 3 seconds if any more PAGING CMD are received on RSL */
3079 T.start;
3080 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07003081 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Welte10985002017-12-12 09:29:15 +01003082 setverdict(fail, "Received PAGING after A-RESET");
Daniel Willmannafce8662018-07-06 23:11:32 +02003083 mtc.stop;
Harald Welte10985002017-12-12 09:29:15 +01003084 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07003085 [] IPA_RSL[1].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Welte5d1a2202017-12-13 19:51:29 +01003086 setverdict(fail, "Received PAGING after A-RESET");
Daniel Willmannafce8662018-07-06 23:11:32 +02003087 mtc.stop;
Harald Welte5d1a2202017-12-13 19:51:29 +01003088 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07003089 [] IPA_RSL[2].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 }
Harald Welte10985002017-12-12 09:29:15 +01003093 [] T.timeout {
3094 setverdict(pass);
3095 }
3096 }
Philipp Maier282ca4b2018-02-27 17:17:00 +01003097
3098 f_shutdown_helper();
Harald Welte10985002017-12-12 09:29:15 +01003099}
Harald Welteae026692017-12-09 01:03:01 +01003100
Philipp Maierf45824a2019-08-14 14:44:10 +02003101/* Verify how we handle unsolicited Paging Response. In case of an unsolicit
3102 * paging response we can not know which MSC is in charge, so we will blindly
3103 * pick the first configured MSC. This behavior is required in order to make
3104 * MT-CSFB calls working because in those cases the BSC can not know that the
3105 * MSC has already paged the subscriver via SGs. So any MT-CSFB call will look
3106 * like an unsolicited Paging Response to the MSC.
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003107 */
3108testcase TC_paging_resp_unsol() runs on test_CT {
3109
3110 f_init(1);
Philipp Maierf45824a2019-08-14 14:44:10 +02003111 timer T := 5.0;
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003112
3113 var BSSAP_N_CONNECT_ind rx_c_ind;
3114 var DchanTuple dt;
3115 var PDU_ML3_MS_NW l3 := valueof(ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010008880018'H))));
Philipp Maierf45824a2019-08-14 14:44:10 +02003116 var octetstring rr_pag_resp := enc_PDU_ML3_MS_NW(l3);
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003117
3118 /* Send CHAN RQD and wait for allocation; acknowledge it */
3119 dt.rsl_chan_nr := f_chreq_act_ack();
3120
3121 /* Send unsolicited Paging response (no matching Paging CMD stored in BSC) */
3122 f_ipa_tx(0, ts_RSL_EST_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)), enc_PDU_ML3_MS_NW(l3)));
3123
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003124
Philipp Maierf45824a2019-08-14 14:44:10 +02003125 /* Expevct a CR with a matching Paging response on the A-Interface */
3126 T.start;
3127 alt {
3128 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(rr_pag_resp))) {
3129 setverdict(pass);
3130 }
3131 [] BSSAP.receive {
3132 setverdict(fail, "Received unexpected message on A-Interface!");
3133 }
3134 [] T.timeout {
3135 setverdict(fail, "Received nothing on A-Interface!");
3136 }
3137 }
3138
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003139 f_shutdown_helper();
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003140}
3141
Harald Welte4e9b9cc2017-12-14 18:31:02 +01003142/* Test RSL link drop causes counter increment */
3143testcase TC_rsl_drop_counter() runs on test_CT {
3144 var integer rsl_fail;
3145
Harald Welte89d42e82017-12-17 16:42:41 +01003146 f_init(1);
Harald Welte4e9b9cc2017-12-14 18:31:02 +01003147
3148 rsl_fail := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "rsl_fail");
3149
3150 bts[0].rsl.vc_IPA.stop;
3151
3152 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "rsl_fail", rsl_fail+1);
3153
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003154 f_shutdown_helper();
Harald Welte4e9b9cc2017-12-14 18:31:02 +01003155}
3156
3157/* TODO: Test OML link drop causes counter increment */
3158
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003159/* The body of TC_rsl_unknown_unit_id() and TC_oml_unknown_unit_id() tests. */
3160function f_ipa_unknown_unit_id(integer mp_bsc_ipa_port) runs on test_CT return boolean {
3161 timer T := 10.0;
3162
3163 bts[0].rsl.id := "IPA-0-RSL";
3164 bts[0].rsl.vc_IPA := IPA_Emulation_CT.create(bts[0].rsl.id & "-IPA");
3165 bts[0].rsl.ccm_pars := c_IPA_default_ccm_pars;
3166 bts[0].rsl.ccm_pars.name := "Osmocom TTCN-3 BTS Simulator";
Oliver Smith92c2bdb2019-08-20 15:11:24 +02003167 bts[0].rsl.ccm_pars.unit_id := "99/0/0"; /* value which is unknown at BTS */
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003168
Pau Espin Pedrol9a5b8ff2021-01-04 19:01:31 +01003169 f_ipa_ctrl_start_client(mp_bsc_ip, mp_bsc_ctrl_port);
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003170
3171 f_init_mgcp("VirtMSC");
3172
3173 /* start RSL/OML connection (XXX re-uses RSL port/protocol definitions for OML) */
3174 map(bts[0].rsl.vc_IPA:IPA_PORT, system:IPA);
3175 connect(bts[0].rsl.vc_IPA:IPA_RSL_PORT, self:IPA_RSL[0]);
3176 bts[0].rsl.vc_IPA.start(IPA_Emulation.main_client(mp_bsc_ip, mp_bsc_ipa_port, "", 10000, bts[0].rsl.ccm_pars));
3177
3178 /* wait for IPA OML link to connect and then disconnect */
3179 T.start;
3180 alt {
Vadim Yanitskiya2afacc2020-05-18 21:16:19 +07003181 [] IPA_RSL[0].receive(tr_ASP_IPA_EV(ASP_IPA_EVENT_DOWN)) {
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003182 T.stop;
3183 return true;
3184 }
3185 [] IPA_RSL[0].receive { repeat }
3186 [] T.timeout {
Daniel Willmannafce8662018-07-06 23:11:32 +02003187 return false;
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003188 }
3189 }
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003190 return false;
3191}
3192
3193/* BSC should close an RSL connection from a BTS with unknown unit ID (OS#2714). */
3194testcase TC_rsl_unknown_unit_id() runs on test_CT {
3195 if (f_ipa_unknown_unit_id(mp_bsc_rsl_port)) {
3196 setverdict(pass);
3197 } else {
3198 setverdict(fail, "Timeout RSL waiting for connection to close");
3199 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003200 f_shutdown_helper();
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003201}
3202
3203
3204/* BSC should close an RSL connection from a BTS with unknown unit ID (OS#2714). */
3205testcase TC_oml_unknown_unit_id() runs on test_CT {
3206 if (f_ipa_unknown_unit_id(mp_bsc_oml_port)) {
3207 setverdict(pass);
3208 } else {
3209 setverdict(fail, "Timeout OML waiting for connection to close");
3210 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003211 f_shutdown_helper();
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003212}
3213
3214
Harald Weltec1a2fff2017-12-17 11:06:19 +01003215/***********************************************************************
Harald Welte6811d102019-04-14 22:23:14 +02003216 * "New world" test cases using RSL_Emulation + RAN_Emulation
Harald Weltec1a2fff2017-12-17 11:06:19 +01003217 ***********************************************************************/
3218
Harald Welte6811d102019-04-14 22:23:14 +02003219import from RAN_Emulation all;
Harald Welte47cd0e32020-08-21 12:39:11 +02003220import from BSSAP_LE_Emulation all;
Harald Weltec1a2fff2017-12-17 11:06:19 +01003221import from RSL_Emulation all;
3222import from MSC_ConnectionHandler all;
3223
3224type function void_fn(charstring id) runs on MSC_ConnHdlr;
3225
Harald Welte336820c2018-05-31 20:34:52 +02003226/* helper function to create and connect a MSC_ConnHdlr component */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003227private function f_connect_handler(inout MSC_ConnHdlr vc_conn, integer bssap_idx := 0) runs on test_CT {
3228 connect(vc_conn:RAN, g_bssap[bssap_idx].vc_RAN:PROC);
Daniel Willmann191e0d92018-01-17 12:44:35 +01003229 connect(vc_conn:MGCP_PROC, vc_MGCP:MGCP_PROC);
Harald Weltec1a2fff2017-12-17 11:06:19 +01003230 connect(vc_conn:RSL, bts[0].rsl.vc_RSL:CLIENT_PT);
Harald Weltef70df652018-01-29 22:00:23 +01003231 connect(vc_conn:RSL_PROC, bts[0].rsl.vc_RSL:RSL_PROC);
Philipp Maier88f4ae82018-03-01 14:00:58 +01003232 if (isvalue(bts[1])) {
Philipp Maier956a92f2018-02-16 10:58:07 +01003233 connect(vc_conn:RSL1, bts[1].rsl.vc_RSL:CLIENT_PT);
3234 connect(vc_conn:RSL1_PROC, bts[1].rsl.vc_RSL:RSL_PROC);
3235 }
Neels Hofmeyr91401012019-07-11 00:42:35 +02003236 if (isvalue(bts[2])) {
3237 connect(vc_conn:RSL2, bts[2].rsl.vc_RSL:CLIENT_PT);
3238 connect(vc_conn:RSL2_PROC, bts[2].rsl.vc_RSL:RSL_PROC);
3239 }
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003240 connect(vc_conn:BSSAP, g_bssap[bssap_idx].vc_RAN:CLIENT);
Neels Hofmeyrcfe44062020-10-15 02:28:08 +02003241 if (mp_enable_lcs_tests) {
3242 connect(vc_conn:BSSAP_LE, g_bssap_le.vc_BSSAP_LE:CLIENT);
3243 connect(vc_conn:BSSAP_LE_PROC, g_bssap_le.vc_BSSAP_LE:PROC);
3244 }
Daniel Willmann191e0d92018-01-17 12:44:35 +01003245 connect(vc_conn:MGCP, vc_MGCP:MGCP_CLIENT);
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02003246 connect(vc_conn:MGCP_MULTI, vc_MGCP:MGCP_CLIENT_MULTI);
Daniel Willmannebdecc02020-08-12 15:30:17 +02003247 connect(vc_conn:STATSD_PROC, vc_STATSD:STATSD_PROC);
Harald Welte336820c2018-05-31 20:34:52 +02003248}
3249
3250function f_start_handler(void_fn fn, template (omit) TestHdlrParams pars := omit)
3251runs on test_CT return MSC_ConnHdlr {
3252 var charstring id := testcasename();
3253 var MSC_ConnHdlr vc_conn;
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003254 var integer bssap_idx := 0;
3255 if (isvalue(pars)) {
3256 bssap_idx := valueof(pars).mscpool.bssap_idx;
3257 }
Harald Welte336820c2018-05-31 20:34:52 +02003258 vc_conn := MSC_ConnHdlr.create(id);
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003259 f_connect_handler(vc_conn, bssap_idx);
Neels Hofmeyr1708d1b2020-10-10 16:56:48 +02003260 /* Emit a marker to appear in the SUT's own logging output */
3261 f_logp(BSCVTY, testcasename() & "() start");
Harald Weltea0630032018-03-20 21:09:55 +01003262 vc_conn.start(f_handler_init(fn, id, pars));
Harald Weltec1a2fff2017-12-17 11:06:19 +01003263 return vc_conn;
3264}
3265
Harald Weltea0630032018-03-20 21:09:55 +01003266/* first function inside ConnHdlr component; sets g_pars + starts function */
3267private function f_handler_init(void_fn fn, charstring id, template (omit) TestHdlrParams pars := omit)
3268runs on MSC_ConnHdlr {
3269 if (isvalue(pars)) {
3270 g_pars := valueof(pars);
3271 }
3272 fn.apply(id);
3273}
3274
Harald Welte3c86ea02018-05-10 22:28:05 +02003275/* Establish signalling channel (non-assignment case) followed by cipher mode */
3276private function f_tc_ciph_mode_a5(charstring id) runs on MSC_ConnHdlr {
Harald Welteed848512018-05-24 22:27:58 +02003277 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3278 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte3c86ea02018-05-10 22:28:05 +02003279 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeSIGNAL);
Philipp Maier23000732018-05-18 11:25:37 +02003280 ass_cmd.pdu.bssmap.assignmentRequest.circuitIdentityCode := omit;
3281 ass_cmd.pdu.bssmap.assignmentRequest.aoIPTransportLayer := omit;
3282 exp_compl.pdu.bssmap.assignmentComplete.circuitIdentityCode := omit;
3283 exp_compl.pdu.bssmap.assignmentComplete.aoIPTransportLayer := omit;
Harald Welte3c86ea02018-05-10 22:28:05 +02003284
Philipp Maier23000732018-05-18 11:25:37 +02003285 f_establish_fully(ass_cmd, exp_compl);
Harald Welte3c86ea02018-05-10 22:28:05 +02003286}
3287testcase TC_ciph_mode_a5_0() runs on test_CT {
3288 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003289 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02003290 pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
3291
3292 f_init(1, true);
3293 f_sleep(1.0);
3294 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
3295 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003296 f_shutdown_helper();
Harald Welte3c86ea02018-05-10 22:28:05 +02003297}
3298testcase TC_ciph_mode_a5_1() runs on test_CT {
3299 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003300 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02003301 pars.encr := valueof(t_EncrParams('02'O, f_rnd_octstring(8)));
3302
3303 f_init(1, true);
3304 f_sleep(1.0);
3305 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
3306 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003307 f_shutdown_helper();
Harald Welte3c86ea02018-05-10 22:28:05 +02003308}
3309testcase TC_ciph_mode_a5_3() runs on test_CT {
3310 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003311 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02003312 pars.encr := valueof(t_EncrParams('08'O, f_rnd_octstring(8)));
3313
3314 f_init(1, true);
3315 f_sleep(1.0);
3316 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
3317 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003318 f_shutdown_helper();
Harald Welte3c86ea02018-05-10 22:28:05 +02003319}
3320
Pau Espin Pedrol07866632020-09-03 19:10:55 +02003321/* establish initial channel, enable ciphering followed by assignment to ciphered channel */
3322private function f_tc_assignment_aoip_tla_v6(charstring id) runs on MSC_ConnHdlr {
3323 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3324 var PDU_BSSAP ass_cmd := f_gen_ass_req(aoip_tla := "::3");
3325 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3326 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
3327
3328 f_establish_fully(ass_cmd, exp_compl);
3329}
3330testcase TC_assignment_aoip_tla_v6() runs on test_CT {
3331 var MSC_ConnHdlr vc_conn;
3332 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3333
3334 f_init(1, true);
3335 f_sleep(1.0);
3336 vc_conn := f_start_handler(refers(f_tc_assignment_aoip_tla_v6), pars);
3337 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003338 f_shutdown_helper();
Pau Espin Pedrol07866632020-09-03 19:10:55 +02003339}
3340
Harald Welte3c86ea02018-05-10 22:28:05 +02003341
3342/* establish initial channel, enable ciphering followed by assignment to ciphered channel */
Harald Welte651fcdc2018-05-10 20:23:16 +02003343private function f_tc_assignment_fr_a5(charstring id) runs on MSC_ConnHdlr {
Harald Welteed848512018-05-24 22:27:58 +02003344 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3345 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Weltec1a2fff2017-12-17 11:06:19 +01003346
Harald Welte552620d2017-12-16 23:21:36 +01003347 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3348 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Welte73cd2712017-12-17 00:44:52 +01003349
Harald Weltea0630032018-03-20 21:09:55 +01003350 f_establish_fully(ass_cmd, exp_compl);
Harald Welte552620d2017-12-16 23:21:36 +01003351}
Harald Welte552620d2017-12-16 23:21:36 +01003352testcase TC_assignment_fr_a5_0() runs on test_CT {
3353 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003354 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02003355 pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
Harald Welte552620d2017-12-16 23:21:36 +01003356
Harald Welte89d42e82017-12-17 16:42:41 +01003357 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01003358 f_sleep(1.0);
Harald Welte651fcdc2018-05-10 20:23:16 +02003359 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
Harald Welte552620d2017-12-16 23:21:36 +01003360 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003361 f_shutdown_helper();
Harald Welte552620d2017-12-16 23:21:36 +01003362}
Harald Welte552620d2017-12-16 23:21:36 +01003363testcase TC_assignment_fr_a5_1() runs on test_CT {
Harald Weltec1a2fff2017-12-17 11:06:19 +01003364 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003365 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02003366 pars.encr := valueof(t_EncrParams('02'O, f_rnd_octstring(8)));
Harald Weltec1a2fff2017-12-17 11:06:19 +01003367
Harald Welte89d42e82017-12-17 16:42:41 +01003368 f_init(1, true);
Harald Weltec1a2fff2017-12-17 11:06:19 +01003369 f_sleep(1.0);
Harald Welte651fcdc2018-05-10 20:23:16 +02003370 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
3371 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003372 f_shutdown_helper();
Harald Welte651fcdc2018-05-10 20:23:16 +02003373}
3374testcase TC_assignment_fr_a5_3() runs on test_CT {
3375 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003376 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02003377 pars.encr := valueof(t_EncrParams('08'O, f_rnd_octstring(8)));
Harald Weltec1a2fff2017-12-17 11:06:19 +01003378
Harald Welte651fcdc2018-05-10 20:23:16 +02003379 f_init(1, true);
3380 f_sleep(1.0);
3381 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
Harald Weltec1a2fff2017-12-17 11:06:19 +01003382 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003383 f_shutdown_helper();
Harald Weltec1a2fff2017-12-17 11:06:19 +01003384}
3385
Harald Welte552620d2017-12-16 23:21:36 +01003386/* Expect ASSIGNMENT FAIL if mandatory IE is missing */
3387private function f_tc_assignment_fr_a5_1_codec_missing(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02003388 g_pars := f_gen_test_hdlr_pars();
Harald Welte552620d2017-12-16 23:21:36 +01003389 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +02003390 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte552620d2017-12-16 23:21:36 +01003391 const OCT8 kc := '0001020304050607'O;
3392
3393 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02003394 /* Omit: ass_cmd.pdu.bssmap.assignmentRequest.codecList */
3395
Harald Weltea0630032018-03-20 21:09:55 +01003396 f_establish_fully(ass_cmd, exp_fail);
Harald Welte552620d2017-12-16 23:21:36 +01003397}
Harald Welte552620d2017-12-16 23:21:36 +01003398testcase TC_assignment_fr_a5_1_codec_missing() runs on test_CT {
3399 var MSC_ConnHdlr vc_conn;
3400
Harald Welte89d42e82017-12-17 16:42:41 +01003401 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01003402 f_sleep(1.0);
3403
Harald Welte8863fa12018-05-10 20:15:27 +02003404 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5_1_codec_missing));
Harald Welte552620d2017-12-16 23:21:36 +01003405 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003406 f_shutdown_helper();
Harald Welte552620d2017-12-16 23:21:36 +01003407}
3408
Harald Welte552620d2017-12-16 23:21:36 +01003409private function f_tc_assignment_fr_a5_4(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02003410 g_pars := f_gen_test_hdlr_pars();
Harald Welteed848512018-05-24 22:27:58 +02003411 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3412 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte552620d2017-12-16 23:21:36 +01003413 const OCT8 kc := '0001020304050607'O;
3414 const OCT16 kc128 := kc & kc;
3415
3416 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3417 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Weltea0630032018-03-20 21:09:55 +01003418 f_establish_fully(ass_cmd, exp_compl);
Harald Welte38b2a102017-12-23 02:42:58 +01003419 f_cipher_mode('10'O, kc, kc128, true);
Harald Welte552620d2017-12-16 23:21:36 +01003420 /* TODO: expect GSM0808_CAUSE_CIPHERING_ALGORITHM_NOT_SUPPORTED cause value */
Harald Welte552620d2017-12-16 23:21:36 +01003421}
Harald Welte552620d2017-12-16 23:21:36 +01003422testcase TC_assignment_fr_a5_4() runs on test_CT {
3423 var MSC_ConnHdlr vc_conn;
3424
Harald Welte89d42e82017-12-17 16:42:41 +01003425 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01003426 f_sleep(1.0);
3427
Harald Welte8863fa12018-05-10 20:15:27 +02003428 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5_4));
Harald Welte552620d2017-12-16 23:21:36 +01003429 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003430 f_shutdown_helper();
Harald Welte552620d2017-12-16 23:21:36 +01003431}
3432
3433
Harald Welte4532e0a2017-12-23 02:05:44 +01003434private function f_tc_assignment_sign(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02003435 g_pars := f_gen_test_hdlr_pars();
Harald Welte4532e0a2017-12-23 02:05:44 +01003436 var template PDU_BSSAP exp_compl := tr_BSSMAP_AssignmentComplete(omit, omit);
Philipp Maier48604732018-10-09 15:00:37 +02003437 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte4532e0a2017-12-23 02:05:44 +01003438 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeSIGNAL);
Daniel Willmannebdecc02020-08-12 15:30:17 +02003439
3440 f_statsd_reset();
Harald Weltea0630032018-03-20 21:09:55 +01003441 f_establish_fully(ass_cmd, exp_compl);
Daniel Willmannebdecc02020-08-12 15:30:17 +02003442
3443 var StatsDExpects expect := {
Daniel Willmannc5398f72020-09-21 10:41:35 +02003444 { name := "TTCN3.bts.0.chreq.total", mtype := "c", min := 1, max := 1},
3445 { name := "TTCN3.bts.0.chreq.successful", mtype := "c", min := 1, max := 1},
Daniel Willmannebdecc02020-08-12 15:30:17 +02003446 { name := "TTCN3.bsc.0.assignment.attempted", mtype := "c", min := 1, max := 1},
3447 { name := "TTCN3.bsc.0.assignment.completed", mtype := "c", min := 1, max := 1}
3448 };
3449 f_statsd_expect(expect);
Harald Welte4532e0a2017-12-23 02:05:44 +01003450}
3451
3452testcase TC_assignment_sign() runs on test_CT {
3453 var MSC_ConnHdlr vc_conn;
3454
3455 f_init(1, true);
3456 f_sleep(1.0);
3457
Harald Welte8863fa12018-05-10 20:15:27 +02003458 vc_conn := f_start_handler(refers(f_tc_assignment_sign));
Harald Welte4532e0a2017-12-23 02:05:44 +01003459 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003460 f_shutdown_helper();
Harald Welte4532e0a2017-12-23 02:05:44 +01003461}
3462
Harald Welte60aa5762018-03-21 19:33:13 +01003463/***********************************************************************
3464 * Codec (list) testing
3465 ***********************************************************************/
3466
3467/* check if the given rsl_mode is compatible with the a_elem */
3468private function f_match_codec(BSSMAP_FIELD_CodecElement a_elem, RSL_IE_ChannelMode rsl_mode)
3469return boolean {
3470 select (a_elem.codecType) {
3471 case (GSM_FR) {
3472 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM1))) {
3473 return true;
3474 }
3475 }
3476 case (GSM_HR) {
3477 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1))) {
3478 return true;
3479 }
3480 }
3481 case (GSM_EFR) {
3482 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM2))) {
3483 return true;
3484 }
3485 }
3486 case (FR_AMR) {
3487 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM3))) {
3488 return true;
3489 }
3490 }
3491 case (HR_AMR) {
3492 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM3))) {
3493 return true;
3494 }
3495 }
3496 case else { }
3497 }
3498 return false;
3499}
3500
3501/* check if the given rsl_mode is compatible with the a_list */
3502private function f_match_codecs(BSSMAP_IE_SpeechCodecList a_list, RSL_IE_ChannelMode rsl_mode)
3503return boolean {
3504 for (var integer i := 0; i < sizeof(a_list); i := i+1) {
3505 if (f_match_codec(a_list.codecElements[i], rsl_mode)) {
3506 return true;
3507 }
3508 }
3509 return false;
3510}
3511
3512/* determine BSSMAP_IE_ChannelType from *first* element of BSSMAP_FIELD_CodecElement */
Philipp Maier61f6b572018-07-06 14:03:38 +02003513function f_BSSMAP_chtype_from_codec(BSSMAP_FIELD_CodecElement a_elem)
Harald Welte60aa5762018-03-21 19:33:13 +01003514return BSSMAP_IE_ChannelType {
3515 /* FIXME: actually look at all elements of BSSMAP_IE_SpeechCodecList */
3516 var BSSMAP_IE_ChannelType ret := valueof(ts_BSSMAP_IE_ChannelType);
3517 select (a_elem.codecType) {
3518 case (GSM_FR) {
3519 ret.channelRateAndType := ChRate_TCHF;
3520 ret.speechId_DataIndicator := Spdi_TCHF_FR;
3521 }
3522 case (GSM_HR) {
3523 ret.channelRateAndType := ChRate_TCHH;
3524 ret.speechId_DataIndicator := Spdi_TCHH_HR;
3525 }
3526 case (GSM_EFR) {
3527 ret.channelRateAndType := ChRate_TCHF;
3528 ret.speechId_DataIndicator := Spdi_TCHF_EFR;
3529 }
3530 case (FR_AMR) {
3531 ret.channelRateAndType := ChRate_TCHF;
3532 ret.speechId_DataIndicator := Spdi_TCHF_AMR;
3533 }
3534 case (HR_AMR) {
3535 ret.channelRateAndType := ChRate_TCHH;
3536 ret.speechId_DataIndicator := Spdi_TCHH_AMR;
3537 }
3538 case else {
3539 setverdict(fail, "Unsupported codec ", a_elem);
Daniel Willmannafce8662018-07-06 23:11:32 +02003540 mtc.stop;
Harald Welte60aa5762018-03-21 19:33:13 +01003541 }
3542 }
3543 return ret;
3544}
3545
Harald Weltea63b9102018-03-22 20:36:16 +01003546private function f_rsl_chmod_tmpl_from_codec(BSSMAP_FIELD_CodecElement a_elem)
3547return template RSL_IE_Body {
3548 var template RSL_IE_Body mode_ie := {
3549 chan_mode := {
3550 len := ?,
3551 reserved := ?,
3552 dtx_d := ?,
3553 dtx_u := ?,
3554 spd_ind := RSL_SPDI_SPEECH,
3555 ch_rate_type := -,
3556 coding_alg_rate := -
3557 }
3558 }
3559
3560 select (a_elem.codecType) {
3561 case (GSM_FR) {
3562 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
3563 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM1;
3564 }
3565 case (GSM_HR) {
3566 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_H;
3567 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM1;
3568 }
3569 case (GSM_EFR) {
3570 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
3571 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM2;
3572 }
3573 case (FR_AMR) {
3574 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
3575 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM3;
3576 }
3577 case (HR_AMR) {
3578 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_H;
3579 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM3;
3580 }
3581 }
3582 return mode_ie;
3583}
3584
Harald Welte60aa5762018-03-21 19:33:13 +01003585type record CodecListTest {
3586 BSSMAP_IE_SpeechCodecList codec_list,
3587 charstring id
3588}
3589type record of CodecListTest CodecListTests
3590
3591private function f_TC_assignment_codec(charstring id) runs on MSC_ConnHdlr {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02003592 var PDU_BSSAP ass_cmd := f_gen_ass_req(g_pars.use_osmux);
3593 var template PDU_BSSAP exp_compl := f_gen_exp_compl(g_pars.use_osmux);
Harald Welte60aa5762018-03-21 19:33:13 +01003594
3595 /* puzzle together the ASSIGNMENT REQ for given codec[s] */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003596 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welte79f3f542018-05-25 20:02:37 +02003597 ass_cmd.pdu.bssmap.assignmentRequest.codecList := g_pars.ass_codec_list;
3598 exp_compl.pdu.bssmap.assignmentComplete.speechCodec.codecElements[0] :=
3599 g_pars.ass_codec_list.codecElements[0];
Philipp Maierd0e64b02019-03-13 14:15:23 +01003600 if (isvalue(g_pars.expect_mr_s0_s7)) {
3601 exp_compl.pdu.bssmap.assignmentComplete.speechCodec.codecElements[0].s0_7 :=
3602 g_pars.expect_mr_s0_s7;
3603 }
Harald Welte79f3f542018-05-25 20:02:37 +02003604 }
Harald Welte60aa5762018-03-21 19:33:13 +01003605 ass_cmd.pdu.bssmap.assignmentRequest.channelType :=
3606 f_BSSMAP_chtype_from_codec(g_pars.ass_codec_list.codecElements[0]);
Harald Welte60aa5762018-03-21 19:33:13 +01003607 log("expecting ASS COMPL like this: ", exp_compl);
3608
3609 f_establish_fully(ass_cmd, exp_compl);
Harald Weltea63b9102018-03-22 20:36:16 +01003610
3611 /* Verify that the RSL-side activation actually matches our expectations */
3612 var RSL_Message rsl := f_rslem_get_last_act(RSL_PROC, 0, g_chan_nr);
3613
3614 var RSL_IE_Body mode_ie;
3615 if (f_rsl_find_ie(rsl, RSL_IE_CHAN_MODE, mode_ie) == false) {
3616 setverdict(fail, "Couldn't find CHAN_MODE IE");
Daniel Willmannafce8662018-07-06 23:11:32 +02003617 mtc.stop;
Harald Weltea63b9102018-03-22 20:36:16 +01003618 }
3619 var template RSL_IE_Body t_mode_ie := f_rsl_chmod_tmpl_from_codec(g_pars.ass_codec_list.codecElements[0]);
3620 if (not match(mode_ie, t_mode_ie)) {
3621 setverdict(fail, "RSL Channel Mode IE doesn't match expectation");
3622 }
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003623
3624 var RSL_IE_Body mr_conf;
3625 if (g_pars.expect_mr_conf_ie != omit) {
3626 if (f_rsl_find_ie(rsl, RSL_IE_MR_CONFIG, mr_conf) == false) {
3627 setverdict(fail, "Missing MR CONFIG IE in RSL Chan Activ");
Daniel Willmannafce8662018-07-06 23:11:32 +02003628 mtc.stop;
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003629 }
3630 log("found RSL MR CONFIG IE: ", mr_conf);
3631
3632 if (not match(mr_conf, g_pars.expect_mr_conf_ie)) {
3633 setverdict(fail, "RSL MR CONFIG IE does not match expectation. Expected: ",
3634 g_pars.expect_mr_conf_ie);
3635 }
3636 } else {
3637 if (f_rsl_find_ie(rsl, RSL_IE_MR_CONFIG, mr_conf) == true) {
3638 log("found RSL MR CONFIG IE: ", mr_conf);
3639 setverdict(fail, "Found MR CONFIG IE in RSL Chan Activ, expecting omit");
Daniel Willmannafce8662018-07-06 23:11:32 +02003640 mtc.stop;
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003641 }
3642 }
Harald Welte60aa5762018-03-21 19:33:13 +01003643}
3644
Philipp Maierd0e64b02019-03-13 14:15:23 +01003645private function f_TC_assignment_codec_fail(charstring id) runs on MSC_ConnHdlr {
3646
3647 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3648 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
3649
3650 /* puzzle together the ASSIGNMENT REQ for given codec[s] */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003651 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Philipp Maierd0e64b02019-03-13 14:15:23 +01003652 ass_cmd.pdu.bssmap.assignmentRequest.codecList := g_pars.ass_codec_list;
3653 }
3654 ass_cmd.pdu.bssmap.assignmentRequest.channelType :=
3655 f_BSSMAP_chtype_from_codec(g_pars.ass_codec_list.codecElements[0]);
3656 log("expecting ASS FAIL like this: ", exp_fail);
3657
3658 f_establish_fully(ass_cmd, exp_fail);
3659}
3660
Harald Welte60aa5762018-03-21 19:33:13 +01003661testcase TC_assignment_codec_fr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003662 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003663 var MSC_ConnHdlr vc_conn;
3664
3665 f_init(1, true);
3666 f_sleep(1.0);
3667
3668 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Welte8863fa12018-05-10 20:15:27 +02003669 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003670 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003671 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01003672}
3673
3674testcase TC_assignment_codec_hr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003675 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003676 var MSC_ConnHdlr vc_conn;
3677
3678 f_init(1, true);
3679 f_sleep(1.0);
3680
3681 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
Harald Welte8863fa12018-05-10 20:15:27 +02003682 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003683 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003684 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01003685}
3686
3687testcase TC_assignment_codec_efr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003688 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003689 var MSC_ConnHdlr vc_conn;
3690
3691 f_init(1, true);
3692 f_sleep(1.0);
3693
3694 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecEFR}));
Harald Welte8863fa12018-05-10 20:15:27 +02003695 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003696 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003697 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01003698}
3699
Philipp Maierd0e64b02019-03-13 14:15:23 +01003700/* Allow 5,90k only (current default config) */
3701private function f_allow_amr_rate_5_90k() runs on test_CT {
Neels Hofmeyr2a5670b2020-11-25 23:39:57 +00003702 f_vty_cfg_msc(BSCVTY, 0, {
3703 "amr-config 12_2k forbidden",
3704 "amr-config 10_2k forbidden",
3705 "amr-config 7_95k forbidden",
3706 "amr-config 7_40k forbidden",
3707 "amr-config 6_70k forbidden",
3708 "amr-config 5_90k allowed",
3709 "amr-config 5_15k forbidden",
3710 "amr-config 4_75k forbidden"
3711 });
Philipp Maierd0e64b02019-03-13 14:15:23 +01003712}
3713
3714/* Allow 4,75k, 5,90k, 4,70k and 12,2k, which are the most common rates
3715 * ("Config-NB-Code = 1") */
3716private function f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k() runs on test_CT {
Neels Hofmeyr2a5670b2020-11-25 23:39:57 +00003717 f_vty_cfg_msc(BSCVTY, 0, {
3718 "amr-config 12_2k allowed",
3719 "amr-config 10_2k forbidden",
3720 "amr-config 7_95k forbidden",
3721 "amr-config 7_40k allowed",
3722 "amr-config 6_70k forbidden",
3723 "amr-config 5_90k allowed",
3724 "amr-config 5_15k forbidden",
3725 "amr-config 4_75k allowed"
3726 });
Philipp Maierd0e64b02019-03-13 14:15:23 +01003727}
3728
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003729private function f_vty_amr_start_mode_set(boolean fr, charstring startmode) runs on test_CT {
3730 var charstring tch;
3731 if (fr) {
3732 tch := "tch-f";
3733 } else {
3734 tch := "tch-h";
3735 }
3736 f_vty_cfg_bts(BSCVTY, 0, { "amr " & tch & " start-mode " & startmode });
3737}
3738
3739/* Set the AMR start-mode for this TCH back to the default configuration. */
3740private function f_vty_amr_start_mode_restore(boolean fr) runs on test_CT {
3741 f_vty_amr_start_mode_set(fr, "auto");
3742}
3743
Harald Welte60aa5762018-03-21 19:33:13 +01003744testcase TC_assignment_codec_amr_f() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003745 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003746 var MSC_ConnHdlr vc_conn;
Philipp Maier7695a0d2018-09-27 17:52:14 +02003747
3748 /* Note: This setups the codec configuration. The parameter payload in
3749 * mr_conf must be consistant with the parameter codecElements in pars
3750 * and also must match the amr-config in osmo-bsc.cfg! */
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003751 var RSL_IE_Body mr_conf := {
3752 other := {
3753 len := 2,
3754 payload := '2804'O
3755 }
3756 };
Harald Welte60aa5762018-03-21 19:33:13 +01003757
Philipp Maier7695a0d2018-09-27 17:52:14 +02003758 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
Philipp Maier806f8f12019-03-12 12:13:41 +01003759 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
Philipp Maier7695a0d2018-09-27 17:52:14 +02003760 pars.ass_codec_list.codecElements[0].s8_15 := '01010111'B;
3761 pars.expect_mr_conf_ie := mr_conf;
3762
Harald Welte60aa5762018-03-21 19:33:13 +01003763 f_init(1, true);
3764 f_sleep(1.0);
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003765 f_vty_amr_start_mode_set(true, "1");
Harald Welte60aa5762018-03-21 19:33:13 +01003766
Harald Welte8863fa12018-05-10 20:15:27 +02003767 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003768 vc_conn.done;
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003769
3770 f_vty_amr_start_mode_restore(true);
Vadim Yanitskiy292e5962021-01-03 14:18:47 +01003771 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01003772}
3773
3774testcase TC_assignment_codec_amr_h() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003775 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003776 var MSC_ConnHdlr vc_conn;
Philipp Maier7695a0d2018-09-27 17:52:14 +02003777
3778 /* See note above */
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003779 var RSL_IE_Body mr_conf := {
3780 other := {
3781 len := 2,
3782 payload := '2804'O
3783 }
3784 };
Harald Welte60aa5762018-03-21 19:33:13 +01003785
Philipp Maier7695a0d2018-09-27 17:52:14 +02003786 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
Philipp Maier806f8f12019-03-12 12:13:41 +01003787 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
Philipp Maier7695a0d2018-09-27 17:52:14 +02003788 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
3789 pars.expect_mr_conf_ie := mr_conf;
3790
Harald Welte60aa5762018-03-21 19:33:13 +01003791 f_init(1, true);
3792 f_sleep(1.0);
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003793 f_vty_amr_start_mode_set(false, "1");
Harald Welte60aa5762018-03-21 19:33:13 +01003794
Harald Welte8863fa12018-05-10 20:15:27 +02003795 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003796 vc_conn.done;
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003797
3798 f_vty_amr_start_mode_restore(false);
Vadim Yanitskiy292e5962021-01-03 14:18:47 +01003799 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01003800}
3801
Neels Hofmeyr454d7922020-11-26 02:24:57 +00003802/* 'amr start-mode auto' should not keep the (unused) 'smod' bits from previous configuration */
3803testcase TC_assignment_codec_amr_startmode_cruft() runs on test_CT {
3804 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3805 var MSC_ConnHdlr vc_conn;
3806
3807 var RSL_IE_Body mr_conf := {
3808 other := {
3809 len := 2,
3810 payload := '2004'O /* <- expect ICMI=0, smod=00 */
3811 }
3812 };
3813
3814 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
3815 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
3816 pars.ass_codec_list.codecElements[0].s8_15 := '01010111'B;
3817 pars.expect_mr_conf_ie := mr_conf;
3818
3819 f_init(1, true);
3820 f_sleep(1.0);
3821
3822 /* First set nonzero start mode bits */
3823 f_vty_amr_start_mode_set(true, "4");
3824 /* Now set to auto, and expect the startmode bits to be zero in the message, i.e. ensure that osmo-bsc does not
3825 * let the startmode bits stick around and has deterministic MultiRate config for 'start-mode auto'; that is
3826 * ensured by above '2004'O, where 'x0xx'O indicates ICMI = 0, spare = 0, smod = 00. */
3827 f_vty_amr_start_mode_set(true, "auto");
3828
3829 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
3830 vc_conn.done;
Neels Hofmeyr454d7922020-11-26 02:24:57 +00003831
3832 /* Clear the startmode bits to not affect subsequent tests, in case the bits should indeed stick around. */
3833 f_vty_amr_start_mode_set(true, "1");
3834 f_vty_amr_start_mode_restore(true);
Vadim Yanitskiy292e5962021-01-03 14:18:47 +01003835 f_shutdown_helper();
Neels Hofmeyr454d7922020-11-26 02:24:57 +00003836}
3837
Neels Hofmeyr21863562020-11-26 00:34:33 +00003838function f_TC_assignment_codec_amr(boolean fr, octetstring mrconf, bitstring s8_s0, bitstring exp_s8_s0,
3839 charstring start_mode := "1")
Philipp Maierd0e64b02019-03-13 14:15:23 +01003840runs on test_CT {
3841
3842 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3843 var MSC_ConnHdlr vc_conn;
3844
3845 /* See note above */
3846 var RSL_IE_Body mr_conf := {
3847 other := {
3848 len := lengthof(mrconf),
3849 payload := mrconf
3850 }
3851 };
3852
3853 if (fr) {
3854 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
3855 } else {
3856 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
3857 }
3858 pars.ass_codec_list.codecElements[0].s0_7 := s8_s0;
3859 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
3860 pars.expect_mr_conf_ie := mr_conf;
3861 pars.expect_mr_s0_s7 := exp_s8_s0;
3862
3863 f_init(1, true);
3864 f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k();
Neels Hofmeyr21863562020-11-26 00:34:33 +00003865 f_vty_amr_start_mode_set(fr, start_mode);
Philipp Maierd0e64b02019-03-13 14:15:23 +01003866 f_sleep(1.0);
3867
3868 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
3869 vc_conn.done;
3870 f_allow_amr_rate_5_90k();
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003871 f_vty_amr_start_mode_restore(fr);
Philipp Maierd0e64b02019-03-13 14:15:23 +01003872}
3873
3874function f_TC_assignment_codec_amr_fail(boolean fr, bitstring s8_s0)
3875runs on test_CT {
3876
3877 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3878 var MSC_ConnHdlr vc_conn;
3879
3880 if (fr) {
3881 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
3882 } else {
3883 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
3884 }
3885 pars.ass_codec_list.codecElements[0].s0_7 := s8_s0;
3886 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
3887
3888 f_init(1, true);
3889 f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k();
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003890 f_vty_amr_start_mode_set(fr, "1");
Philipp Maierd0e64b02019-03-13 14:15:23 +01003891 f_sleep(1.0);
3892
3893 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fail), pars);
3894 vc_conn.done;
3895 f_allow_amr_rate_5_90k();
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003896 f_vty_amr_start_mode_restore(fr);
Philipp Maierd0e64b02019-03-13 14:15:23 +01003897}
3898
3899
3900/* Set S1, we expect an AMR multirate configuration IE with all four rates
3901 * set. */
3902testcase TC_assignment_codec_amr_f_S1() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003903 f_TC_assignment_codec_amr(true, '289520882208'O, '00000010'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003904 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003905}
3906
3907/* Set S1, we expect an AMR multirate configuration IE with the lower three
3908 * rates set. */
3909testcase TC_assignment_codec_amr_h_S1() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003910 f_TC_assignment_codec_amr(false, '2815208820'O, '00000010'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003911 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003912}
3913
3914/* Set S1 and two other rates, we expect an AMR MULTIRATE CONFIGURATION IE with
3915 * all four rates (and only S1 set in the ASSIGNMENT COMPLETE) */
3916testcase TC_assignment_codec_amr_f_S124() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003917 f_TC_assignment_codec_amr(true, '289520882208'O, '00010110'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003918 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003919}
3920
3921/* Set S1 and two other rates, we expect an AMR MULTIRATE CONFIGURATION IE with
3922 * all four rates (and only S1 set in the ASSIGNMENT COMPLETE) */
3923testcase TC_assignment_codec_amr_h_S124() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003924 f_TC_assignment_codec_amr(false, '2815208820'O, '00010110'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003925 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003926}
3927
3928/* The following block of tests selects more and more rates until all four
3929 * possible rates are in the active set (full rate) */
3930testcase TC_assignment_codec_amr_f_S0() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003931 f_TC_assignment_codec_amr(true, '2801'O, '00000001'B, '00000001'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003932 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003933}
3934
3935testcase TC_assignment_codec_amr_f_S02() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003936 f_TC_assignment_codec_amr(true, '28052080'O, '00000101'B, '00000101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003937 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003938}
3939
3940testcase TC_assignment_codec_amr_f_S024() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003941 f_TC_assignment_codec_amr(true, '2815208820'O, '00010101'B, '00010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003942 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003943}
3944
3945testcase TC_assignment_codec_amr_f_S0247() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003946 f_TC_assignment_codec_amr(true, '289520882208'O, '10010101'B, '10010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003947 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003948}
3949
3950/* The following block of tests selects more and more rates until all three
3951 * possible rates are in the active set (half rate) */
3952testcase TC_assignment_codec_amr_h_S0() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003953 f_TC_assignment_codec_amr(false, '2801'O, '00000001'B, '00000001'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003954 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003955}
3956
3957testcase TC_assignment_codec_amr_h_S02() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003958 f_TC_assignment_codec_amr(false, '28052080'O, '00000101'B, '00000101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003959 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003960}
3961
3962testcase TC_assignment_codec_amr_h_S024() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003963 f_TC_assignment_codec_amr(false, '2815208820'O, '00010101'B, '00010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003964 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003965}
3966
3967/* The following block tests what happens when the MSC does offer rate
3968 * configurations that are not supported by the BSC. Normally such situations
3969 * should not happen because the MSC gets informed by the BSC in advance via
3970 * the L3 COMPLETE message which rates are applicable. The MSC should not try
3971 * to offer rates that are not applicable anyway. */
3972
3973testcase TC_assignment_codec_amr_h_S0247() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003974 /* Try to include 12,2k in into the active set even though the channel
3975 * is half rate only. The BSC is expected to remove the 12,0k */
3976 f_TC_assignment_codec_amr(false, '2815208820'O, '10010101'B, '00010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003977 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003978}
3979
3980testcase TC_assignment_codec_amr_f_S01234567() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003981 /* See what happens when all rates are selected at once. Since then
3982 * Also S1 is selected, this setting will be prefered and we should
3983 * get 12.2k, 7,40k, 5,90k, and 4,75k in the active set. */
3984 f_TC_assignment_codec_amr(true, '289520882208'O, '11111111'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003985 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003986}
3987
3988testcase TC_assignment_codec_amr_f_S0234567() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003989 /* Same as above, but with S1 missing, the MSC is then expected to
3990 * select the currently supported rates, which are also 12.2k, 7,40k,
3991 * 5,90k, and 4,75k, into the active set. */
3992 f_TC_assignment_codec_amr(true, '289520882208'O, '11111101'B, '10010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003993 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003994}
3995
3996testcase TC_assignment_codec_amr_f_zero() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003997 /* Try to select no rates at all */
3998 f_TC_assignment_codec_amr_fail(true, '00000000'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003999 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004000}
4001
4002testcase TC_assignment_codec_amr_f_unsupp() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004003 /* Try to select only unsupported rates */
4004 f_TC_assignment_codec_amr_fail(true, '01101000'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004005 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004006}
4007
4008testcase TC_assignment_codec_amr_h_S7() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004009 /* Try to select 12,2k for half rate */
4010 f_TC_assignment_codec_amr_fail(false, '10000000'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004011 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004012}
4013
Neels Hofmeyr21863562020-11-26 00:34:33 +00004014testcase TC_assignment_codec_amr_f_start_mode_auto() runs on test_CT {
4015 f_TC_assignment_codec_amr(true, '209520882208'O, '11111111'B, '00000010'B,
4016 start_mode := "auto");
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01004017 f_shutdown_helper();
Neels Hofmeyr21863562020-11-26 00:34:33 +00004018}
4019
4020testcase TC_assignment_codec_amr_h_start_mode_auto() runs on test_CT {
4021 f_TC_assignment_codec_amr(false, '2015208820'O, '10010101'B, '00010101'B,
4022 start_mode := "auto");
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01004023 f_shutdown_helper();
Neels Hofmeyr21863562020-11-26 00:34:33 +00004024}
4025
Neels Hofmeyr3eb94562020-11-26 02:40:26 +00004026testcase TC_assignment_codec_amr_f_start_mode_4() runs on test_CT {
Vadim Yanitskiy7815f482021-01-03 17:07:37 +01004027 /* "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 +00004028 f_TC_assignment_codec_amr(true, '2b9520882208'O, '11111111'B, '00000010'B,
4029 start_mode := "4");
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01004030 f_shutdown_helper();
Neels Hofmeyr3eb94562020-11-26 02:40:26 +00004031}
4032
4033testcase TC_assignment_codec_amr_h_start_mode_4() runs on test_CT {
Vadim Yanitskiy7815f482021-01-03 17:07:37 +01004034 /* "amr tch-h modes 0 2 4" => total 3 modes and start mode 4 => '10'B on the wire */
4035 f_TC_assignment_codec_amr(false, '2a15208820'O, '10010101'B, '00010101'B,
Neels Hofmeyr3eb94562020-11-26 02:40:26 +00004036 start_mode := "4");
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01004037 f_shutdown_helper();
Neels Hofmeyr3eb94562020-11-26 02:40:26 +00004038}
4039
Philipp Maierac09bfc2019-01-08 13:41:39 +01004040private function f_disable_all_tch_f() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01004041 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 1 sub-slot 0 borken");
4042 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 2 sub-slot 0 borken");
4043 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 3 sub-slot 0 borken");
4044 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 4 sub-slot 0 borken");
Philipp Maierac09bfc2019-01-08 13:41:39 +01004045}
4046
4047private function f_disable_all_tch_h() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01004048 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 0 borken");
4049 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 1 borken");
Philipp Maierac09bfc2019-01-08 13:41:39 +01004050}
4051
4052private function f_enable_all_tch() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01004053 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 1 sub-slot 0 unused");
4054 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 2 sub-slot 0 unused");
4055 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 3 sub-slot 0 unused");
4056 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 4 sub-slot 0 unused");
4057 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 0 unused");
4058 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 1 unused");
Philipp Maierac09bfc2019-01-08 13:41:39 +01004059}
4060
4061/* Allow HR only */
4062private function f_TC_assignment_codec_xr_exhausted_req_hr(charstring id) runs on MSC_ConnHdlr {
4063 g_pars := f_gen_test_hdlr_pars();
4064 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4065 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4066 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4067 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '09'O;
4068 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '05'O;
4069 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
4070 f_establish_fully(ass_cmd, exp_compl);
4071}
4072
4073/* Allow FR only */
4074private function f_TC_assignment_codec_xr_exhausted_req_fr(charstring id) runs on MSC_ConnHdlr {
4075 g_pars := f_gen_test_hdlr_pars();
4076 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4077 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4078 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4079 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '08'O;
4080 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '01'O;
4081 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4082 f_establish_fully(ass_cmd, exp_compl);
4083}
4084
4085/* Allow HR only (expect assignment failure) */
4086private function f_TC_assignment_codec_xr_exhausted_req_hr_fail(charstring id) runs on MSC_ConnHdlr {
4087 g_pars := f_gen_test_hdlr_pars();
4088 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4089 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
4090 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4091 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '09'O;
4092 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '05'O;
4093 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
4094 f_establish_fully(ass_cmd, exp_fail);
4095}
4096
4097/* Allow FR only (expect assignment failure) */
4098private function f_TC_assignment_codec_xr_exhausted_req_fr_fail(charstring id) runs on MSC_ConnHdlr {
4099 g_pars := f_gen_test_hdlr_pars();
4100 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4101 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
4102 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4103 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '08'O;
4104 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '01'O;
4105 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4106 f_establish_fully(ass_cmd, exp_fail);
4107}
4108
4109/* Allow FR and HR, but prefer FR */
4110private function f_TC_assignment_codec_fr_exhausted_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
4111 g_pars := f_gen_test_hdlr_pars();
4112 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4113 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4114 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4115 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
4116 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
4117 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
4118 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
4119 f_establish_fully(ass_cmd, exp_compl);
4120}
4121
4122/* Allow FR and HR, but prefer HR */
4123private function f_TC_assignment_codec_fr_exhausted_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
4124 g_pars := f_gen_test_hdlr_pars();
4125 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4126 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4127 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4128 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
4129 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
4130 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
4131 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
4132 f_establish_fully(ass_cmd, exp_compl);
4133}
4134
4135/* Allow FR and HR, but prefer FR */
4136private function f_TC_assignment_codec_hr_exhausted_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
4137 g_pars := f_gen_test_hdlr_pars();
4138 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4139 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4140 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4141 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
4142 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
4143 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
4144 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
4145 f_establish_fully(ass_cmd, exp_compl);
4146}
4147
4148/* Allow FR and HR, but prefer HR */
4149private function f_TC_assignment_codec_hr_exhausted_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
4150 g_pars := f_gen_test_hdlr_pars();
4151 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4152 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4153 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4154 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
4155 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
4156 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
4157 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
4158 f_establish_fully(ass_cmd, exp_compl);
4159}
4160
4161/* Request a HR channel while all FR channels are exhausted, this is expected
4162 * to work without conflicts */
4163testcase TC_assignment_codec_fr_exhausted_req_hr() runs on test_CT {
4164 var MSC_ConnHdlr vc_conn;
4165 f_init(1, true);
4166 f_sleep(1.0);
4167 f_enable_all_tch();
4168 f_disable_all_tch_f();
4169 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_hr));
4170 vc_conn.done;
4171 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004172 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004173}
4174
4175/* Request a FR channel while all FR channels are exhausted, this is expected
4176 * to fail. */
4177testcase TC_assignment_codec_fr_exhausted_req_fr() runs on test_CT {
4178 var MSC_ConnHdlr vc_conn;
4179 f_init(1, true);
4180 f_sleep(1.0);
4181 f_enable_all_tch();
4182 f_disable_all_tch_f();
4183 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_fr_fail));
4184 vc_conn.done;
4185 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004186 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004187}
4188
4189/* Request a FR (prefered) or alternatively a HR channel while all FR channels
4190 * are exhausted, this is expected to be resolved by selecting a HR channel. */
4191testcase TC_assignment_codec_fr_exhausted_req_fr_hr() runs on test_CT {
4192 var MSC_ConnHdlr vc_conn;
4193 f_init(1, true);
4194 f_sleep(1.0);
4195 f_enable_all_tch();
4196 f_disable_all_tch_f();
4197 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fr_exhausted_req_fr_hr));
4198 vc_conn.done;
4199 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004200 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004201}
4202
4203/* Request a HR (prefered) or alternatively a FR channel while all FR channels
4204 * are exhausted, this is expected to work without conflicts. */
4205testcase TC_assignment_codec_fr_exhausted_req_hr_fr() runs on test_CT {
4206 var MSC_ConnHdlr vc_conn;
4207 f_init(1, true);
4208 f_sleep(1.0);
4209 f_enable_all_tch();
4210 f_disable_all_tch_f();
4211 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fr_exhausted_req_hr_fr));
4212 vc_conn.done;
4213 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004214 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004215}
4216
4217/* Request a FR channel while all HR channels are exhausted, this is expected
4218 * to work without conflicts */
4219testcase TC_assignment_codec_hr_exhausted_req_fr() runs on test_CT {
4220 var MSC_ConnHdlr vc_conn;
4221 f_init(1, true);
4222 f_sleep(1.0);
4223 f_enable_all_tch();
4224 f_disable_all_tch_h();
4225 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_fr));
4226 vc_conn.done;
4227 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004228 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004229}
4230
4231/* Request a HR channel while all HR channels are exhausted, this is expected
4232 * to fail. */
4233testcase TC_assignment_codec_hr_exhausted_req_hr() runs on test_CT {
4234 var MSC_ConnHdlr vc_conn;
4235 f_init(1, true);
4236 f_sleep(1.0);
4237 f_enable_all_tch();
4238 f_disable_all_tch_h();
4239 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_hr_fail));
4240 vc_conn.done;
4241 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004242 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004243}
4244
4245/* Request a HR (prefered) or alternatively a FR channel while all HR channels
4246 * are exhausted, this is expected to be resolved by selecting a FR channel. */
4247testcase TC_assignment_codec_hr_exhausted_req_hr_fr() runs on test_CT {
4248 var MSC_ConnHdlr vc_conn;
4249 f_init(1, true);
4250 f_sleep(1.0);
4251 f_enable_all_tch();
4252 f_disable_all_tch_h();
4253 vc_conn := f_start_handler(refers(f_TC_assignment_codec_hr_exhausted_req_hr_fr));
4254 vc_conn.done;
4255 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004256 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004257}
4258
4259/* Request a FR (prefered) or alternatively a HR channel while all HR channels
4260 * are exhausted, this is expected to work without conflicts. */
4261testcase TC_assignment_codec_hr_exhausted_req_fr_hr() runs on test_CT {
4262 var MSC_ConnHdlr vc_conn;
4263 f_init(1, true);
4264 f_sleep(1.0);
4265 f_enable_all_tch();
4266 f_disable_all_tch_h();
4267 vc_conn := f_start_handler(refers(f_TC_assignment_codec_hr_exhausted_req_fr_hr));
4268 vc_conn.done;
4269 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004270 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004271}
4272
4273/* Allow FR and HR, but prefer HR */
4274private function f_TC_assignment_codec_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
4275 g_pars := f_gen_test_hdlr_pars();
4276 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4277 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4278 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4279 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
4280 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
4281 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
4282 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
4283 f_establish_fully(ass_cmd, exp_compl);
4284}
4285
4286/* Allow FR and HR, but prefer FR */
4287private function f_TC_assignment_codec_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
4288 g_pars := f_gen_test_hdlr_pars();
4289 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4290 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4291 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4292 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
4293 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
4294 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
4295 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
4296 f_establish_fully(ass_cmd, exp_compl);
4297}
4298
4299/* Request a HR (prefered) or alternatively a FR channel, it is expected that
4300 * HR, which is the prefered type, is selected. */
4301testcase TC_assignment_codec_req_hr_fr() runs on test_CT {
4302 var MSC_ConnHdlr vc_conn;
4303 f_init(1, true);
4304 f_sleep(1.0);
4305 f_enable_all_tch();
4306 vc_conn := f_start_handler(refers(f_TC_assignment_codec_req_hr_fr));
4307 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004308 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004309}
4310
4311/* Request a FR (prefered) or alternatively a HR channel, it is expected that
4312 * FR, which is the prefered type, is selected. */
4313testcase TC_assignment_codec_req_fr_hr() runs on test_CT {
4314 var MSC_ConnHdlr vc_conn;
4315 f_init(1, true);
4316 f_sleep(1.0);
4317 f_enable_all_tch();
4318 vc_conn := f_start_handler(refers(f_TC_assignment_codec_req_fr_hr));
4319 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004320 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004321}
4322
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02004323testcase TC_assignment_osmux() runs on test_CT {
4324 var TestHdlrParams pars := f_gen_test_hdlr_pars();
4325 var MSC_ConnHdlr vc_conn;
4326
4327 /* See note above */
4328 var RSL_IE_Body mr_conf := {
4329 other := {
4330 len := 2,
4331 payload := '2804'O
4332 }
4333 };
4334
4335 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
4336 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
4337 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
4338 pars.expect_mr_conf_ie := mr_conf;
4339 pars.use_osmux := true;
4340
4341 f_init(1, true, true);
4342 f_sleep(1.0);
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00004343 f_vty_amr_start_mode_set(false, "1");
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02004344
4345 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
4346 vc_conn.done;
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00004347
4348 f_vty_amr_start_mode_restore(false);
Vadim Yanitskiy292e5962021-01-03 14:18:47 +01004349 f_shutdown_helper();
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02004350}
4351
Neels Hofmeyr92b12b72018-09-18 14:30:23 +02004352/* test the procedure of the MSC requesting a Classmark Update:
4353 * a) BSSMAP Classmark Request should result in RR CLASSMARK ENQUIRY,
4354 * b) L3 RR CLASSMARK CHANGE should result in BSSMAP CLASSMARK UPDATE */
Harald Welte898113b2018-01-31 18:32:21 +01004355private function f_tc_classmark(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004356 g_pars := f_gen_test_hdlr_pars();
4357
Harald Weltea0630032018-03-20 21:09:55 +01004358 f_create_chan_and_exp();
Harald Welte898113b2018-01-31 18:32:21 +01004359 /* we should now have a COMPL_L3 at the MSC */
4360 BSSAP.receive(tr_BSSMAP_ComplL3);
4361
Neels Hofmeyr92b12b72018-09-18 14:30:23 +02004362 BSSAP.send(ts_BSSMAP_ClassmarkRequest);
4363 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_CM_ENQUIRY));
4364
Harald Welte898113b2018-01-31 18:32:21 +01004365 f_rsl_send_l3(ts_RRM_CM_CHG(valueof(ts_CM2)));
4366 BSSAP.receive(tr_BSSMAP_ClassmarkUpd(?, omit));
4367 setverdict(pass);
4368}
4369testcase TC_classmark() runs on test_CT {
4370 var MSC_ConnHdlr vc_conn;
4371 f_init(1, true);
4372 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004373 vc_conn := f_start_handler(refers(f_tc_classmark));
Harald Welte898113b2018-01-31 18:32:21 +01004374 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004375 f_shutdown_helper();
Harald Welte898113b2018-01-31 18:32:21 +01004376}
4377
Harald Welteeddf0e92020-06-21 19:42:15 +02004378/* Send a CommonID from the simulated MSC and verify that the information is used to
4379 * fill BSC-internal data structures (specifically, bsc_subscr associated with subscr_conn) */
4380private function f_tc_common_id(charstring id) runs on MSC_ConnHdlr {
4381 g_pars := f_gen_test_hdlr_pars();
4382 f_MscConnHdlr_init_vty();
4383
4384 f_create_chan_and_exp();
4385 /* we should now have a COMPL_L3 at the MSC */
4386 BSSAP.receive(tr_BSSMAP_ComplL3);
4387
4388 /* Send CommonID */
4389 BSSAP.send(ts_BSSMAP_CommonId(g_pars.imsi));
4390
4391 /* Use VTY to verify that the IMSI of the subscr_conn is set */
4392 var charstring regex := "*(IMSI: " & hex2str(g_pars.imsi) & ")*";
4393 f_vty_transceive_match_regexp_retry(BSCVTY, "show conns", regex, 0, 4, 1.0);
4394
4395 setverdict(pass);
4396}
4397testcase TC_common_id() runs on test_CT {
4398 var MSC_ConnHdlr vc_conn;
4399 f_init(1, true);
4400 f_sleep(1.0);
4401 vc_conn := f_start_handler(refers(f_tc_common_id));
4402 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004403 f_shutdown_helper();
Harald Welteeddf0e92020-06-21 19:42:15 +02004404}
4405
Harald Weltee3bd6582018-01-31 22:51:25 +01004406private function f_est_single_l3(template PDU_ML3_MS_NW l3) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004407 g_pars := f_gen_test_hdlr_pars();
Harald Weltea0630032018-03-20 21:09:55 +01004408 f_create_chan_and_exp();
Harald Welte898113b2018-01-31 18:32:21 +01004409 /* we should now have a COMPL_L3 at the MSC */
4410 BSSAP.receive(tr_BSSMAP_ComplL3);
4411
Harald Weltee3bd6582018-01-31 22:51:25 +01004412 /* send the single message we want to send */
4413 f_rsl_send_l3(l3);
4414}
4415
4416private function f_bssap_expect_nothing(float sec := 5.00) runs on MSC_ConnHdlr {
4417 timer T := sec;
4418 var PDU_BSSAP bssap;
Harald Welte898113b2018-01-31 18:32:21 +01004419 T.start;
4420 alt {
Harald Weltee3bd6582018-01-31 22:51:25 +01004421 [] BSSAP.receive(PDU_BSSAP:?) -> value bssap {
4422 setverdict(fail, "Unexpected BSSMAP ", bssap);
Daniel Willmannafce8662018-07-06 23:11:32 +02004423 mtc.stop;
Harald Welte898113b2018-01-31 18:32:21 +01004424 }
4425 [] T.timeout {
4426 setverdict(pass);
4427 }
4428 }
4429}
4430
Harald Weltee3bd6582018-01-31 22:51:25 +01004431/* unsolicited ASSIGNMENT FAIL (without ASSIGN) from MS shouldn't bring BSC down */
4432private function f_tc_unsol_ass_fail(charstring id) runs on MSC_ConnHdlr {
4433 f_est_single_l3(ts_RRM_AssignmentFailure('00'O));
4434 f_bssap_expect_nothing();
4435}
Harald Welte898113b2018-01-31 18:32:21 +01004436testcase TC_unsol_ass_fail() runs on test_CT {
4437 var MSC_ConnHdlr vc_conn;
4438 f_init(1, true);
4439 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004440 vc_conn := f_start_handler(refers(f_tc_unsol_ass_fail));
Harald Welte898113b2018-01-31 18:32:21 +01004441 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004442 f_shutdown_helper();
Harald Welte898113b2018-01-31 18:32:21 +01004443}
Harald Welte552620d2017-12-16 23:21:36 +01004444
Harald Welteea99a002018-01-31 20:46:43 +01004445
4446/* unsolicited ASSIGNMENT COMPLETE (without ASSIGN) from MS shouldn't bring BSC down */
4447private function f_tc_unsol_ass_compl(charstring id) runs on MSC_ConnHdlr {
Harald Weltee3bd6582018-01-31 22:51:25 +01004448 f_est_single_l3(ts_RRM_AssignmentComplete('00'O));
4449 f_bssap_expect_nothing();
Harald Welteea99a002018-01-31 20:46:43 +01004450}
4451testcase TC_unsol_ass_compl() runs on test_CT {
4452 var MSC_ConnHdlr vc_conn;
4453 f_init(1, true);
4454 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004455 vc_conn := f_start_handler(refers(f_tc_unsol_ass_compl));
Harald Welteea99a002018-01-31 20:46:43 +01004456 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004457 f_shutdown_helper();
Harald Welteea99a002018-01-31 20:46:43 +01004458}
4459
4460
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004461/* unsolicited HANDOVER FAIL (without ASSIGN) from MS shouldn't bring BSC down */
4462private function f_tc_unsol_ho_fail(charstring id) runs on MSC_ConnHdlr {
Harald Weltee3bd6582018-01-31 22:51:25 +01004463 f_est_single_l3(ts_RRM_HandoverFailure('00'O));
4464 f_bssap_expect_nothing();
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004465}
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004466testcase TC_unsol_ho_fail() runs on test_CT {
4467 var MSC_ConnHdlr vc_conn;
4468 f_init(1, true);
4469 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004470 vc_conn := f_start_handler(refers(f_tc_unsol_ho_fail));
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004471 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004472 f_shutdown_helper();
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004473}
4474
4475
Harald Weltee3bd6582018-01-31 22:51:25 +01004476/* short message from MS should be ignored */
4477private function f_tc_err_82_short_msg(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004478 g_pars := f_gen_test_hdlr_pars();
Harald Weltea0630032018-03-20 21:09:55 +01004479 f_create_chan_and_exp();
Harald Weltee3bd6582018-01-31 22:51:25 +01004480 /* we should now have a COMPL_L3 at the MSC */
4481 BSSAP.receive(tr_BSSMAP_ComplL3);
4482
4483 /* send short message */
4484 RSL.send(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), ''O));
4485 f_bssap_expect_nothing();
4486}
4487testcase TC_err_82_short_msg() runs on test_CT {
4488 var MSC_ConnHdlr vc_conn;
4489 f_init(1, true);
4490 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004491 vc_conn := f_start_handler(refers(f_tc_err_82_short_msg));
Harald Weltee3bd6582018-01-31 22:51:25 +01004492 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004493 f_shutdown_helper();
Harald Weltee3bd6582018-01-31 22:51:25 +01004494}
4495
4496
Harald Weltee9e02e42018-01-31 23:36:25 +01004497/* 24.008 8.4 Unknown message must trigger RR STATUS */
4498private function f_tc_err_84_unknown_msg(charstring id) runs on MSC_ConnHdlr {
4499 f_est_single_l3(ts_RRM_UL_REL('00'O));
4500 timer T := 3.0
4501 alt {
4502 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_STATUS)) {
4503 setverdict(pass);
4504 }
4505 [] BSSAP.receive { setverdict(fail, "unexpected BSSAP"); }
Harald Welte458fd372018-03-21 11:26:23 +01004506 [] T.timeout { setverdict(fail, "Timeout waiting for RR STATUS"); }
Harald Weltee9e02e42018-01-31 23:36:25 +01004507 }
4508}
4509testcase TC_err_84_unknown_msg() runs on test_CT {
4510 var MSC_ConnHdlr vc_conn;
4511 f_init(1, true);
4512 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004513 vc_conn := f_start_handler(refers(f_tc_err_84_unknown_msg));
Harald Weltee9e02e42018-01-31 23:36:25 +01004514 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004515 f_shutdown_helper();
Harald Weltee9e02e42018-01-31 23:36:25 +01004516}
4517
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004518/***********************************************************************
4519 * Handover
4520 ***********************************************************************/
4521
Harald Welte94e0c342018-04-07 11:33:23 +02004522/* execute a "bts <0-255> trx <0-255> timeslot <0-7> " command on given Dchan */
4523private function f_vty_ts_action(charstring suffix, integer bts_nr, integer trx_nr, integer ts_nr)
4524runs on test_CT {
4525 var charstring cmd := "bts "&int2str(bts_nr)&" trx "&int2str(trx_nr)&
4526 " timeslot "&int2str(ts_nr)&" ";
4527 f_vty_transceive(BSCVTY, cmd & suffix);
4528}
4529
Harald Welte261af4b2018-02-12 21:20:39 +01004530/* 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 +07004531private function f_vty_ss_action(TELNETasp_PT pt, charstring suffix,
4532 uint8_t bts_nr, uint8_t trx_nr,
4533 in RslChannelNr chan_nr)
4534{
Harald Welte261af4b2018-02-12 21:20:39 +01004535 /* FIXME: resolve those from component-global state */
4536 var integer ts_nr := chan_nr.tn;
4537 var integer ss_nr;
4538 if (ischosen(chan_nr.u.ch0)) {
4539 ss_nr := 0;
4540 } else if (ischosen(chan_nr.u.lm)) {
4541 ss_nr := chan_nr.u.lm.sub_chan;
4542 } else if (ischosen(chan_nr.u.sdcch4)) {
4543 ss_nr := chan_nr.u.sdcch4.sub_chan;
4544 } else if (ischosen(chan_nr.u.sdcch8)) {
4545 ss_nr := chan_nr.u.sdcch8.sub_chan;
4546 } else {
4547 setverdict(fail, "Invalid ChanNr ", chan_nr);
Daniel Willmannafce8662018-07-06 23:11:32 +02004548 mtc.stop;
Harald Welte261af4b2018-02-12 21:20:39 +01004549 }
4550
4551 var charstring cmd := "bts "&int2str(bts_nr)&" trx "&int2str(trx_nr)&
4552 " timeslot "&int2str(ts_nr)&" sub-slot "&int2str(ss_nr)&" ";
Vadim Yanitskiy00070722020-09-02 17:27:57 +07004553 f_vty_transceive(pt, cmd & suffix);
Harald Welte261af4b2018-02-12 21:20:39 +01004554}
4555
Neels Hofmeyr91401012019-07-11 00:42:35 +02004556/* Even though the VTY command to trigger handover takes a new BTS number as argument, behind the scenes osmo-bsc always
4557 * translates that to a target ARFCN+BSIC first. See bsc_vty.c trigger_ho_or_as(), which puts the selected BTS' neighbor
4558 * ident key (ARFCN + BSIC) in the struct passed on to handover_request(). handover_start() then resolves that to a
4559 * viable actual neighbor cell. So from the internal osmo-bsc perspective, we always request handover to an ARFCN + BSIC
4560 * pair, not really to a specific BTS number. */
Vadim Yanitskiy00070722020-09-02 17:27:57 +07004561private function f_vty_handover(TELNETasp_PT pt, uint8_t bts_nr, uint8_t trx_nr,
4562 in RslChannelNr chan_nr, uint8_t new_bts_nr)
4563{
4564 f_vty_ss_action(pt, "handover " & int2str(new_bts_nr), bts_nr, trx_nr, chan_nr);
Harald Welte261af4b2018-02-12 21:20:39 +01004565}
4566
4567/* intra-BSC hand-over between BTS0 and BTS1 */
4568private function f_tc_ho_int(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004569 g_pars := f_gen_test_hdlr_pars();
Harald Welteed848512018-05-24 22:27:58 +02004570 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4571 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte261af4b2018-02-12 21:20:39 +01004572 const OCT8 kc := '0001020304050607'O;
4573
4574 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4575 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4576
Harald Weltea0630032018-03-20 21:09:55 +01004577 f_establish_fully(ass_cmd, exp_compl);
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004578 f_bts_0_cfg(BSCVTY, {"neighbor bts 1"});
Harald Welte261af4b2018-02-12 21:20:39 +01004579
4580 var HandoverState hs := {
4581 rr_ho_cmpl_seen := false,
4582 handover_done := false,
4583 old_chan_nr := -
4584 };
4585 /* issue hand-over command on VTY */
Vadim Yanitskiy00070722020-09-02 17:27:57 +07004586 f_vty_handover(BSCVTY, 0, 0, g_chan_nr, 1);
Harald Welte261af4b2018-02-12 21:20:39 +01004587 /* temporarily suspend DChan processing on BTS1 to avoid race with RSLEM_register */
4588 f_rslem_suspend(RSL1_PROC);
Philipp Maier3e2af5d2018-07-11 17:01:05 +02004589
4590 /* From the MGW perspective, a handover is is characterized by
4591 * performing one MDCX operation with the MGW. So we expect to see
4592 * one more MDCX during handover. */
4593 g_media.mgcp_conn[0].mdcx_seen_exp := g_media.mgcp_conn[0].crcx_seen_exp + 1;
4594
Harald Welte261af4b2018-02-12 21:20:39 +01004595 alt {
4596 [] as_handover(hs);
Harald Welte261af4b2018-02-12 21:20:39 +01004597 }
Philipp Maier3e2af5d2018-07-11 17:01:05 +02004598
Philipp Maier4dae0652018-11-12 12:03:26 +01004599 /* Since this is an internal handover we expect the BSC to inform the
4600 * MSC about the event */
4601 BSSAP.receive(tr_BSSMAP_HandoverPerformed);
4602
Philipp Maier3e2af5d2018-07-11 17:01:05 +02004603 /* Check the amount of MGCP transactions is still consistant with the
4604 * test expectation */
4605 f_check_mgcp_expectations()
Neels Hofmeyr861a4c12018-11-07 01:23:17 +01004606 f_sleep(0.5);
Harald Welte261af4b2018-02-12 21:20:39 +01004607}
4608
4609testcase TC_ho_int() runs on test_CT {
4610 var MSC_ConnHdlr vc_conn;
4611 f_init(2, true);
4612 f_sleep(1.0);
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004613
4614 f_ctrs_bsc_and_bts_init();
4615
Harald Welte8863fa12018-05-10 20:15:27 +02004616 vc_conn := f_start_handler(refers(f_tc_ho_int));
Harald Welte261af4b2018-02-12 21:20:39 +01004617 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004618
4619 /* from f_establish_fully() */
4620 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4621 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4622 /* from handover */
4623 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4624 f_ctrs_bsc_and_bts_add(0, "handover:completed");
4625 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
4626 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:completed");
4627 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004628 f_shutdown_helper();
Harald Welte261af4b2018-02-12 21:20:39 +01004629}
Harald Weltee9e02e42018-01-31 23:36:25 +01004630
Neels Hofmeyr5f144212020-11-03 15:41:58 +00004631/* intra-BSC hand-over with CONNection FAILure and cause Radio Link Failure: check RR release cause */
4632private function f_tc_ho_int_radio_link_failure(charstring id) runs on MSC_ConnHdlr {
4633 g_pars := f_gen_test_hdlr_pars();
4634 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4635 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4636 const OCT8 kc := '0001020304050607'O;
4637
4638 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4639 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4640
4641 f_establish_fully(ass_cmd, exp_compl);
4642 f_bts_0_cfg(BSCVTY, {"neighbor bts 1"});
4643
4644 var HandoverState hs := {
4645 rr_ho_cmpl_seen := false,
4646 handover_done := false,
4647 old_chan_nr := -
4648 };
4649 /* issue hand-over command on VTY */
4650 f_vty_handover(BSCVTY, 0, 0, g_chan_nr, 1);
4651 /* temporarily suspend DChan processing on BTS1 to avoid race with RSLEM_register */
4652 f_rslem_suspend(RSL1_PROC);
4653
4654 /* From the MGW perspective, a handover is is characterized by
4655 * performing one MDCX operation with the MGW. So we expect to see
4656 * one more MDCX during handover. */
4657 g_media.mgcp_conn[0].mdcx_seen_exp := g_media.mgcp_conn[0].crcx_seen_exp + 1;
4658
4659 var RSL_Message rsl;
4660 var PDU_ML3_NW_MS l3;
4661 var RslChannelNr new_chan_nr;
4662 var GsmArfcn arfcn;
4663 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr)) -> value rsl {
4664 l3 := dec_PDU_ML3_NW_MS(rsl.ies[2].body.l3_info.payload);
4665 if (not ischosen(l3.msgs.rrm.handoverCommand)) {
4666 setverdict(fail, "Expected handoverCommand");
4667 mtc.stop;
4668 }
4669 }
4670 f_ChDesc2RslChanNr(l3.msgs.rrm.handoverCommand.channelDescription2,
4671 new_chan_nr, arfcn);
4672
4673 f_rslem_register(0, new_chan_nr, RSL1_PROC);
4674
4675 /* resume processing of RSL DChan messages, which was temporarily suspended
4676 * before performing a hand-over */
4677 f_rslem_resume(RSL1_PROC);
4678 RSL1.receive(tr_RSL_IPA_CRCX(new_chan_nr));
4679
4680 f_sleep(1.0);
4681
4682 /* Handover fails because no HANDO DET appears on the new lchan,
4683 * and the old lchan reports a Radio Link Failure. */
4684 RSL.send(ts_RSL_CONN_FAIL_IND(g_chan_nr, RSL_ERR_RADIO_LINK_FAIL));
4685
4686 var PDU_BSSAP rx_clear_request;
4687 BSSAP.receive(tr_BSSMAP_ClearRequest) -> value rx_clear_request;
4688 var BssmapCause cause := bit2int(rx_clear_request.pdu.bssmap.clearRequest.cause.causeValue);
4689 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
4690
4691 var RR_Cause rr_cause := GSM48_RR_CAUSE_ABNORMAL_UNSPEC;
4692
4693 var MgcpCommand mgcp;
4694 interleave {
4695 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE(int2oct(enum2int(rr_cause), 1)))) {}
4696 [] RSL.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {}
4697 [] RSL.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
4698 RSL.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
4699 }
4700 [] RSL1.receive(tr_RSL_DEACT_SACCH(new_chan_nr)) {}
4701 [] RSL1.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
4702 RSL1.send(ts_RSL_RF_CHAN_REL_ACK(new_chan_nr));
4703 }
4704 [] BSSAP.receive(tr_BSSMAP_ClearComplete) {}
4705 }
4706
4707 f_sleep(0.5);
4708 setverdict(pass);
4709}
4710testcase TC_ho_int_radio_link_failure() runs on test_CT {
4711 var MSC_ConnHdlr vc_conn;
4712 f_init(2, true);
4713 f_sleep(1.0);
4714
4715 f_ctrs_bsc_and_bts_init();
4716
4717 vc_conn := f_start_handler(refers(f_tc_ho_int_radio_link_failure));
4718 vc_conn.done;
4719
4720 /* from f_establish_fully() */
4721 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4722 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4723 /* from handover */
4724 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4725 f_ctrs_bsc_and_bts_add(0, "handover:stopped");
4726 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
4727 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:stopped");
4728 f_ctrs_bsc_and_bts_verify();
4729 f_shutdown_helper();
4730}
4731
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004732/* Expecting MGCP to DLCX the endpoint's two connections: towards BTS and towards MSC */
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004733private function f_expect_dlcx_conns() runs on MSC_ConnHdlr {
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004734 var MgcpCommand mgcp;
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02004735 var template MgcpResponse mgcp_resp;
4736 var MGCP_RecvFrom mrf;
4737 var template MgcpMessage msg_resp;
4738 var template MgcpMessage msg_dlcx := {
4739 command := tr_DLCX()
4740 }
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004741
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02004742 if (g_pars.aoip) {
4743 MGCP.receive(tr_DLCX()) -> value mgcp {
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004744 log("Got first DLCX: ", mgcp);
4745 MGCP.send(ts_DLCX_ACK2(mgcp.line.trans_id));
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02004746 };
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004747
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004748 MGCP.receive(tr_DLCX()) -> value mgcp {
4749 log("Got second DLCX: ", mgcp);
4750 MGCP.send(ts_DLCX_ACK2(mgcp.line.trans_id));
4751 };
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02004752 } else {
4753 /* For SCCPLite, BSC doesn't handle the MSC-side */
4754 MGCP_MULTI.receive(tr_MGCP_RecvFrom_any(msg_dlcx)) -> value mrf {
4755 log("Got first DLCX: ", mrf.msg.command);
4756 msg_resp := {
4757 response := ts_DLCX_ACK2(mrf.msg.command.line.trans_id)
4758 }
4759 MGCP_MULTI.send(t_MGCP_SendToMrf(mrf, msg_resp));
4760 };
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004761 }
4762
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004763 BSSAP.receive(tr_BSSMAP_ClearComplete);
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004764}
4765
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004766private function f_tc_ho_out_of_this_bsc(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004767 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004768
4769 var PDU_BSSAP ass_req := f_gen_ass_req();
4770 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4771 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4772 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4773 f_establish_fully(ass_req, exp_compl);
4774
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004775 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004776 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
4777
4778 BSSAP.receive(tr_BSSMAP_HandoverRequired);
4779
4780 f_sleep(0.5);
4781 /* The MSC negotiates Handover Request and Handover Request Ack with
4782 * the other BSS and comes back with a BSSMAP Handover Command
4783 * containing an RR Handover Command coming from the target BSS... */
4784
4785 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
4786 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
4787 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
4788 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
4789 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
4790
4791 /* expect the Handover Command to go out on RR */
4792 var RSL_Message rsl_ho_cmd
4793 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
4794 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
4795 var RSL_IE_Body rsl_ho_cmd_l3;
4796 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
4797 log("RSL message contains no L3 Info IE, expected RR Handover Command");
4798 setverdict(fail);
4799 } else {
4800 log("Found L3 Info: ", rsl_ho_cmd_l3);
4801 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
4802 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
4803 setverdict(fail);
4804 } else {
4805 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
4806 setverdict(pass);
4807 }
4808 }
4809
4810 /* When the other BSS has reported a completed handover, this side is
4811 * torn down. */
4812
4813 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_HANDOVER_SUCCESSFUL;
4814 var BssmapCause cause := enum2int(cause_val);
4815 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
4816
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004817 f_expect_dlcx_conns();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004818 setverdict(pass);
4819 f_sleep(1.0);
4820}
4821testcase TC_ho_out_of_this_bsc() runs on test_CT {
4822 var MSC_ConnHdlr vc_conn;
4823
4824 f_init(1, true);
4825 f_sleep(1.0);
4826
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004827 f_ctrs_bsc_and_bts_init();
4828
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004829 vc_conn := f_start_handler(refers(f_tc_ho_out_of_this_bsc));
4830 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004831
4832 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4833 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4834 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4835 f_ctrs_bsc_and_bts_add(0, "handover:completed");
4836 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
4837 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:completed");
4838 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004839 f_shutdown_helper();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004840}
4841
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00004842private function f_mo_l3_transceive(RSL_DCHAN_PT rsl := RSL,
4843 template (value) RslLinkId link_id := ts_RslLinkID_DCCH(0),
Vadim Yanitskiy2ef6a2f2020-10-08 23:17:32 +07004844 template (present) OCT1 dlci := ?,
Vadim Yanitskiyb93aa432020-10-01 14:23:11 +07004845 octetstring l3 := '0123456789'O)
4846runs on MSC_ConnHdlr {
Neels Hofmeyr43654812020-09-25 01:35:35 +02004847 /* The old lchan and conn should still be active. See that arbitrary L3
4848 * is still going through. */
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00004849 rsl.send(ts_RSL_DATA_IND(g_chan_nr, link_id, l3));
Neels Hofmeyr43654812020-09-25 01:35:35 +02004850 var template PDU_BSSAP exp_data := {
4851 discriminator := '1'B,
4852 spare := '0000000'B,
Vadim Yanitskiyb93aa432020-10-01 14:23:11 +07004853 dlci := dlci,
4854 lengthIndicator := lengthof(l3),
Neels Hofmeyr43654812020-09-25 01:35:35 +02004855 pdu := {
4856 dtap := l3
4857 }
4858 };
4859 BSSAP.receive(exp_data);
4860 setverdict(pass);
4861}
4862
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00004863private function f_mt_l3_transceive(RSL_DCHAN_PT rsl := RSL,
4864 template (present) RslLinkId link_id := tr_RslLinkID_DCCH(0),
Vadim Yanitskiy0033a3b2020-10-01 22:21:16 +07004865 template (value) OCT1 dlci := '00'O,
4866 octetstring l3 := '0123456789'O)
4867runs on MSC_ConnHdlr {
4868 BSSAP.send(PDU_BSSAP:{
4869 discriminator := '1'B,
4870 spare := '0000000'B,
4871 dlci := dlci,
4872 lengthIndicator := lengthof(l3),
4873 pdu := {
4874 dtap := l3
4875 }
4876 });
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00004877 rsl.receive(tr_RSL_DATA_REQ(g_chan_nr, link_id, l3));
Vadim Yanitskiy0033a3b2020-10-01 22:21:16 +07004878 setverdict(pass);
4879}
4880
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004881/* BSC asks for inter-BSC HO, but the MSC decides that it won't happen and
4882 * simply never sends a BSSMAP Handover Command. */
4883private function f_tc_ho_out_fail_no_msc_response(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01004884 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004885
4886 var PDU_BSSAP ass_req := f_gen_ass_req();
4887 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4888 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4889 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4890 f_establish_fully(ass_req, exp_compl);
4891
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004892 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004893 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
4894
4895 BSSAP.receive(tr_BSSMAP_HandoverRequired);
4896
4897 /* osmo-bsc should time out 10 seconds after the handover started.
4898 * Let's give it a bit extra. */
4899 f_sleep(15.0);
4900
Vadim Yanitskiy74ae5eb2020-10-01 22:13:29 +07004901 f_mo_l3_transceive();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004902 f_sleep(1.0);
4903}
4904testcase TC_ho_out_fail_no_msc_response() runs on test_CT {
4905 var MSC_ConnHdlr vc_conn;
4906
4907 f_init(1, true);
4908 f_sleep(1.0);
4909
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004910 f_ctrs_bsc_and_bts_init();
4911
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004912 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_no_msc_response));
4913 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004914
4915 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4916 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4917 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4918 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
4919 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
4920 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
4921 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004922 f_shutdown_helper();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004923}
4924
4925/* BSC asks for inter-BSC HO, receives BSSMAP Handover Command, but MS reports
4926 * RR Handover Failure. */
4927private function f_tc_ho_out_fail_rr_ho_failure(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01004928 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004929
4930 var PDU_BSSAP ass_req := f_gen_ass_req();
4931 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4932 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4933 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4934 f_establish_fully(ass_req, exp_compl);
4935
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004936 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004937 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
4938
4939 BSSAP.receive(tr_BSSMAP_HandoverRequired);
4940
4941 f_sleep(0.5);
4942 /* The MSC negotiates Handover Request and Handover Request Ack with
4943 * the other BSS and comes back with a BSSMAP Handover Command
4944 * containing an RR Handover Command coming from the target BSS... */
4945
4946 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
4947 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
4948 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
4949 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
4950 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
4951
4952 /* expect the Handover Command to go out on RR */
4953 var RSL_Message rsl_ho_cmd
4954 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
4955 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
4956 var RSL_IE_Body rsl_ho_cmd_l3;
4957 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
4958 log("RSL message contains no L3 Info IE, expected RR Handover Command");
4959 setverdict(fail);
4960 } else {
4961 log("Found L3 Info: ", rsl_ho_cmd_l3);
4962 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
4963 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
4964 setverdict(fail);
4965 } else {
4966 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
4967 setverdict(pass);
4968 }
4969 }
4970
4971 f_sleep(0.2);
4972 f_rsl_send_l3(ts_RRM_HandoverFailure('00'O));
4973
4974 /* Should tell the MSC about the failure */
4975 BSSAP.receive(tr_BSSMAP_HandoverFailure);
4976
4977 f_sleep(1.0);
4978
Vadim Yanitskiy74ae5eb2020-10-01 22:13:29 +07004979 f_mo_l3_transceive();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004980 f_sleep(1.0);
4981
4982 setverdict(pass);
4983 f_sleep(1.0);
4984}
4985testcase TC_ho_out_fail_rr_ho_failure() runs on test_CT {
4986 var MSC_ConnHdlr vc_conn;
4987
4988 f_init(1, true);
4989 f_sleep(1.0);
4990
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004991 f_ctrs_bsc_and_bts_init();
4992
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004993 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_rr_ho_failure));
4994 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004995
4996 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4997 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4998 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4999 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5000 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
5001 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:failed");
5002 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005003 f_shutdown_helper();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005004}
5005
Neels Hofmeyr10f2bfa2019-07-09 19:33:29 +02005006/* BSC asks for inter-BSC-out HO, receives BSSMAP Handover Command, but then no reply is received about HO outcome
5007 * (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 +02005008 * and the lchan is released. */
5009private function f_tc_ho_out_fail_no_result_after_ho_cmd(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01005010 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005011
5012 var PDU_BSSAP ass_req := f_gen_ass_req();
5013 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
5014 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
5015 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
5016 f_establish_fully(ass_req, exp_compl);
5017
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005018 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005019 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
5020
5021 BSSAP.receive(tr_BSSMAP_HandoverRequired);
5022
5023 f_sleep(0.5);
5024 /* The MSC negotiates Handover Request and Handover Request Ack with
5025 * the other BSS and comes back with a BSSMAP Handover Command
5026 * containing an RR Handover Command coming from the target BSS... */
5027
5028 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
5029 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
5030 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
5031 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
5032 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
5033
5034 /* expect the Handover Command to go out on RR */
5035 var RSL_Message rsl_ho_cmd
5036 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
5037 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
5038 var RSL_IE_Body rsl_ho_cmd_l3;
5039 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
5040 log("RSL message contains no L3 Info IE, expected RR Handover Command");
5041 setverdict(fail);
5042 } else {
5043 log("Found L3 Info: ", rsl_ho_cmd_l3);
5044 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
5045 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
5046 setverdict(fail);
5047 } else {
5048 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
5049 setverdict(pass);
5050 }
5051 }
5052
Neels Hofmeyr10f2bfa2019-07-09 19:33:29 +02005053 /* We get neither success nor failure report from the remote BSS. Eventually T8 times out and we run into 3GPP
5054 * TS 48.008 3.1.5.3.3 "Abnormal Conditions": Clear Request should go to the MSC, and RR should be released
5055 * after Clear Command */
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005056
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005057 var PDU_BSSAP rx_clear_request;
Neels Hofmeyre1797aa2019-07-09 19:34:04 +02005058 BSSAP.receive(tr_BSSMAP_ClearRequest) -> value rx_clear_request;
5059 log("Got BSSMAP Clear Request");
5060 /* Instruct BSC to clear channel */
5061 var BssmapCause cause := bit2int(rx_clear_request.pdu.bssmap.clearRequest.cause.causeValue);
5062 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5063
5064 var MgcpCommand mgcp;
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005065 interleave {
Neels Hofmeyr861a4c12018-11-07 01:23:17 +01005066 [] RSL.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
5067 log("Got Deact SACCH");
5068 }
Harald Welte924b6ea2019-02-04 01:05:34 +01005069 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
Neels Hofmeyr211169d2018-11-07 00:37:29 +01005070 log("Got RR Release");
5071 }
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005072 [] RSL.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
5073 log("Got RF Chan Rel");
5074 RSL.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
5075 }
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005076 }
5077
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005078 f_expect_dlcx_conns();
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02005079
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005080 setverdict(pass);
5081 f_sleep(1.0);
5082}
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02005083testcase TC_ho_out_fail_no_result_after_ho_cmd() runs on test_CT {
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005084 var MSC_ConnHdlr vc_conn;
5085
5086 f_init(1, true);
5087 f_sleep(1.0);
5088
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005089 f_ctrs_bsc_and_bts_init();
5090
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02005091 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_no_result_after_ho_cmd));
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005092 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005093
5094 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5095 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5096 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5097 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
5098 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
5099 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
5100 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005101 f_shutdown_helper();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005102}
5103
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005104private function f_tc_ho_into_this_bsc(charstring id) runs on MSC_ConnHdlr {
5105 /* Hack: the proper way would be to wait for the BSSMAP Handover Request ACK and extract the
5106 * actual assigned chan_nr from its L3 (RR Handover Command) message. But osmo-bsc starts acting
5107 * on the lchan even before we get a chance to evaluate the BSSMAP Handover Request ACK. So we
5108 * need to assume that osmo-bsc will activate TS 1 and already set up this lchan's RSL emulation
5109 * before we get started. */
5110 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
5111 f_rslem_register(0, new_chan_nr);
5112 g_chan_nr := new_chan_nr;
5113 f_sleep(1.0);
5114
5115 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
5116 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5117 activate(as_Media());
5118
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005119 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Pau Espin Pedrol07866632020-09-03 19:10:55 +02005120 f_gen_handover_req(aoip_tla := g_pars.host_aoip_tla)));
Harald Welte6811d102019-04-14 22:23:14 +02005121 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005122
5123 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
5124
5125 var PDU_BSSAP rx_bssap;
5126 var octetstring ho_command_str;
5127
5128 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
Pau Espin Pedrol76ba5412019-06-10 11:00:33 +02005129
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005130 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
5131 log("Received L3 Info in HO Request Ack: ", ho_command_str);
5132 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
5133 log("L3 Info in HO Request Ack is ", ho_command);
5134
5135 var GsmArfcn arfcn;
5136 var RslChannelNr actual_new_chan_nr;
5137 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
5138 actual_new_chan_nr, arfcn);
5139
5140 if (actual_new_chan_nr != new_chan_nr) {
5141 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
5142 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
5143 setverdict(fail);
5144 return;
5145 }
5146 log("Handover Command chan_nr is", actual_new_chan_nr);
5147
5148 /* Now the MSC forwards the RR Handover Command to the other BSC, which
5149 * tells the MS to handover to the new lchan. Here comes the new MS on
5150 * the new lchan with a Handover RACH: */
5151
5152 /* send handover detect */
5153
5154 RSL.send(ts_RSL_HANDO_DET(new_chan_nr));
5155
5156 BSSAP.receive(tr_BSSMAP_HandoverDetect);
5157
5158 /* send handover complete over the new channel */
5159
5160 var PDU_ML3_MS_NW l3_tx := valueof(ts_RRM_HandoverComplete('00'O));
5161 RSL.send(ts_RSL_EST_IND(new_chan_nr, valueof(ts_RslLinkID_DCCH(0)),
5162 enc_PDU_ML3_MS_NW(l3_tx)));
5163
5164 BSSAP.receive(tr_BSSMAP_HandoverComplete);
5165 setverdict(pass);
5166}
Pau Espin Pedrol07866632020-09-03 19:10:55 +02005167function f_tc_ho_into_this_bsc_main(TestHdlrParams pars) runs on test_CT {
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005168 var MSC_ConnHdlr vc_conn;
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005169
5170 f_init(1, true);
5171 f_sleep(1.0);
5172
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005173 f_ctrs_bsc_and_bts_init();
5174
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005175 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5176 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005177
5178 vc_conn := f_start_handler(refers(f_tc_ho_into_this_bsc), pars);
5179 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005180
5181 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5182 f_ctrs_bsc_and_bts_add(0, "handover:completed");
5183 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
5184 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:completed");
5185 f_ctrs_bsc_and_bts_verify();
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01005186 f_shutdown_helper();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005187}
5188
Pau Espin Pedrol07866632020-09-03 19:10:55 +02005189testcase TC_ho_into_this_bsc() runs on test_CT {
5190 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5191 f_tc_ho_into_this_bsc_main(pars);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005192 f_shutdown_helper();
Pau Espin Pedrol07866632020-09-03 19:10:55 +02005193}
5194
5195testcase TC_ho_into_this_bsc_tla_v6() runs on test_CT {
5196 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5197 pars.host_aoip_tla := "::6";
5198 f_tc_ho_into_this_bsc_main(pars);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005199 f_shutdown_helper();
Pau Espin Pedrol07866632020-09-03 19:10:55 +02005200}
5201
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005202private function f_tc_ho_in_fail_msc_clears(charstring id) runs on MSC_ConnHdlr {
5203 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
5204 f_rslem_register(0, new_chan_nr);
5205 g_chan_nr := new_chan_nr;
5206 f_sleep(1.0);
5207
5208 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
5209 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5210 activate(as_Media());
5211
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005212 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005213 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02005214 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005215
5216 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
5217
5218 var PDU_BSSAP rx_bssap;
5219 var octetstring ho_command_str;
5220
5221 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
5222
5223 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
5224 log("Received L3 Info in HO Request Ack: ", ho_command_str);
5225 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
5226 log("L3 Info in HO Request Ack is ", ho_command);
5227
5228 var GsmArfcn arfcn;
5229 var RslChannelNr actual_new_chan_nr;
5230 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
5231 actual_new_chan_nr, arfcn);
5232
5233 if (actual_new_chan_nr != new_chan_nr) {
5234 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
5235 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
5236 setverdict(fail);
5237 return;
5238 }
5239 log("Handover Command chan_nr is", actual_new_chan_nr);
5240
Neels Hofmeyr61ca08d2019-05-06 23:52:22 +02005241 /* For deterministic test results, give some time for the MGW endpoint to be configured */
5242 f_sleep(1.0);
5243
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005244 /* Now the MSC forwards the RR Handover Command to the other BSC, which
5245 * tells the MS to handover to the new lchan. In this case, the MS
5246 * reports a Handover Failure to the old BSS, which forwards a BSSMAP
5247 * Handover Failure to the MSC. The procedure according to 3GPP TS
5248 * 48.008 3.1.5.3.2 "Handover Failure" is then that the MSC sends a
5249 * BSSMAP Clear Command: */
5250
5251 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
5252 var BssmapCause cause := enum2int(cause_val);
5253 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5254
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005255 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005256 setverdict(pass);
5257 f_sleep(1.0);
5258
5259 setverdict(pass);
5260}
5261testcase TC_ho_in_fail_msc_clears() runs on test_CT {
5262 var MSC_ConnHdlr vc_conn;
5263 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5264
5265 f_init(1, true);
5266 f_sleep(1.0);
5267
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005268 f_ctrs_bsc_and_bts_init();
5269
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005270 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5271 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005272
5273 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_msc_clears), pars);
5274 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005275
5276 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5277 f_ctrs_bsc_and_bts_add(0, "handover:stopped");
5278 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
5279 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:stopped");
5280 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005281 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005282}
5283
5284private function f_tc_ho_in_fail_msc_clears_after_ho_detect(charstring id) runs on MSC_ConnHdlr {
5285 /* Hack: the proper way would be to wait for the BSSMAP Handover Request ACK and extract the
5286 * actual assigned chan_nr from its L3 (RR Handover Command) message. But osmo-bsc starts acting
5287 * on the lchan even before we get a chance to evaluate the BSSMAP Handover Request ACK. So we
5288 * need to assume that osmo-bsc will activate TS 1 and already set up this lchan's RSL emulation
5289 * before we get started. */
5290 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
5291 f_rslem_register(0, new_chan_nr);
5292 g_chan_nr := new_chan_nr;
5293 f_sleep(1.0);
5294
5295 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
5296 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5297 activate(as_Media());
5298
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005299 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005300 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02005301 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005302
5303 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
5304
5305 var PDU_BSSAP rx_bssap;
5306 var octetstring ho_command_str;
5307
5308 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
5309
5310 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
5311 log("Received L3 Info in HO Request Ack: ", ho_command_str);
5312 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
5313 log("L3 Info in HO Request Ack is ", ho_command);
5314
5315 var GsmArfcn arfcn;
5316 var RslChannelNr actual_new_chan_nr;
5317 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
5318 actual_new_chan_nr, arfcn);
5319
5320 if (actual_new_chan_nr != new_chan_nr) {
5321 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
5322 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
5323 setverdict(fail);
5324 return;
5325 }
5326 log("Handover Command chan_nr is", actual_new_chan_nr);
5327
5328 /* Now the MSC forwards the RR Handover Command to the other BSC, which
5329 * tells the MS to handover to the new lchan. Here comes the new MS on
5330 * the new lchan with a Handover RACH: */
5331
5332 /* send handover detect */
5333
5334 RSL.send(ts_RSL_HANDO_DET(new_chan_nr));
5335
5336 BSSAP.receive(tr_BSSMAP_HandoverDetect);
5337
5338 /* The MSC chooses to clear the connection now, maybe we got the
5339 * Handover RACH on the new cell but the MS still signaled Handover
5340 * Failure to the old BSS? */
5341
5342 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
5343 var BssmapCause cause := enum2int(cause_val);
5344 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5345
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005346 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005347 f_sleep(1.0);
5348}
5349testcase TC_ho_in_fail_msc_clears_after_ho_detect() runs on test_CT {
5350 var MSC_ConnHdlr vc_conn;
5351 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5352
5353 f_init(1, true);
5354 f_sleep(1.0);
5355
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005356 f_ctrs_bsc_and_bts_init();
5357
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005358 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5359 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005360
5361 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_msc_clears_after_ho_detect), pars);
5362 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005363
5364 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5365 f_ctrs_bsc_and_bts_add(0, "handover:stopped");
5366 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
5367 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:stopped");
5368 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005369 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005370}
5371
5372/* The new BSS's lchan times out before the MSC decides that handover failed. */
5373private function f_tc_ho_in_fail_no_detect(charstring id) runs on MSC_ConnHdlr {
5374 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
5375 f_rslem_register(0, new_chan_nr);
5376 g_chan_nr := new_chan_nr;
5377 f_sleep(1.0);
5378
5379 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
5380 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5381 activate(as_Media());
5382
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005383 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005384 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02005385 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005386
5387 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
5388
5389 var PDU_BSSAP rx_bssap;
5390 var octetstring ho_command_str;
5391
5392 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
5393
5394 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
5395 log("Received L3 Info in HO Request Ack: ", ho_command_str);
5396 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
5397 log("L3 Info in HO Request Ack is ", ho_command);
5398
5399 var GsmArfcn arfcn;
5400 var RslChannelNr actual_new_chan_nr;
5401 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
5402 actual_new_chan_nr, arfcn);
5403
5404 if (actual_new_chan_nr != new_chan_nr) {
5405 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
5406 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
5407 setverdict(fail);
5408 return;
5409 }
5410 log("Handover Command chan_nr is", actual_new_chan_nr);
5411
5412 /* Now the MSC forwards the RR Handover Command to the other BSC, which
5413 * tells the MS to handover to the new lchan. But the MS never shows up
5414 * on the new lchan. */
5415
5416 BSSAP.receive(tr_BSSMAP_HandoverFailure);
5417
5418 /* Did osmo-bsc also send a Clear Request? */
5419 timer T := 0.5;
5420 T.start;
5421 alt {
5422 [] BSSAP.receive(tr_BSSMAP_ClearRequest);
5423 [] T.timeout { }
5424 }
5425
5426 /* MSC plays along with a Clear Command (no matter whether osmo-bsc
5427 * asked for it, this is a Handover Failure after all). */
5428
5429 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
5430 var BssmapCause cause := enum2int(cause_val);
5431 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5432
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005433 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005434 f_sleep(1.0);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005435}
5436testcase TC_ho_in_fail_no_detect() runs on test_CT {
5437 var MSC_ConnHdlr vc_conn;
5438 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5439
5440 f_init(1, true);
5441 f_sleep(1.0);
5442
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005443 f_ctrs_bsc_and_bts_init();
5444
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005445 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5446 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005447
5448 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_no_detect), pars);
5449 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005450
5451 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5452 f_ctrs_bsc_and_bts_add(0, "handover:error");
5453 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
5454 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:error");
5455 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005456 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005457}
5458
5459/* Same as f_tc_ho_in_fail_no_detect, but MSC fails to send a Clear Command */
5460private function f_tc_ho_in_fail_no_detect2(charstring id) runs on MSC_ConnHdlr {
5461 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
5462 f_rslem_register(0, new_chan_nr);
5463 g_chan_nr := new_chan_nr;
5464 f_sleep(1.0);
5465
5466 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
5467 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5468 activate(as_Media());
5469
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005470 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005471 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02005472 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005473
5474 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
5475
5476 var PDU_BSSAP rx_bssap;
5477 var octetstring ho_command_str;
5478
5479 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
5480
5481 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
5482 log("Received L3 Info in HO Request Ack: ", ho_command_str);
5483 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
5484 log("L3 Info in HO Request Ack is ", ho_command);
5485
5486 var GsmArfcn arfcn;
5487 var RslChannelNr actual_new_chan_nr;
5488 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
5489 actual_new_chan_nr, arfcn);
5490
5491 if (actual_new_chan_nr != new_chan_nr) {
5492 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
5493 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
5494 setverdict(fail);
5495 return;
5496 }
5497 log("Handover Command chan_nr is", actual_new_chan_nr);
5498
5499 /* Now the MSC forwards the RR Handover Command to the other BSC, which
5500 * tells the MS to handover to the new lchan. But the MS never shows up
5501 * on the new lchan. */
5502
5503 BSSAP.receive(tr_BSSMAP_HandoverFailure);
5504
5505 /* MSC plays dumb and sends no Clear Command */
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005506 var PDU_BSSAP rx_clear_request;
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02005507
5508 BSSAP.receive(tr_BSSMAP_ClearRequest) -> value rx_clear_request {
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005509 var BssmapCause cause := bit2int(rx_clear_request.pdu.bssmap.clearRequest.cause.causeValue);
5510 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5511 };
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005512 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005513 f_sleep(1.0);
5514}
5515testcase TC_ho_in_fail_no_detect2() runs on test_CT {
5516 var MSC_ConnHdlr vc_conn;
5517 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5518
5519 f_init(1, true);
5520 f_sleep(1.0);
5521
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005522 f_ctrs_bsc_and_bts_init();
5523
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005524 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5525 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005526
5527 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_no_detect2), pars);
5528 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005529
5530 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5531 f_ctrs_bsc_and_bts_add(0, "handover:error");
5532 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
5533 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:error");
5534 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005535 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005536}
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005537
Neels Hofmeyr91401012019-07-11 00:42:35 +02005538type record of charstring Commands;
5539
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005540private function f_bts_0_cfg(TELNETasp_PT pt, Commands cmds := {})
Neels Hofmeyr91401012019-07-11 00:42:35 +02005541{
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005542 f_vty_enter_cfg_bts(pt, 0);
Neels Hofmeyr91401012019-07-11 00:42:35 +02005543 for (var integer i := 0; i < sizeof(cmds); i := i+1) {
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005544 f_vty_transceive(pt, cmds[i]);
Neels Hofmeyr91401012019-07-11 00:42:35 +02005545 }
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005546 f_vty_transceive(pt, "end");
Neels Hofmeyr91401012019-07-11 00:42:35 +02005547}
5548
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01005549private function f_cs7_inst_0_cfg(TELNETasp_PT pt, Commands cmds := {})
5550{
5551 f_vty_enter_cfg_cs7_inst(pt, 0);
5552 for (var integer i := 0; i < sizeof(cmds); i := i+1) {
5553 f_vty_transceive(pt, cmds[i]);
5554 }
5555 f_vty_transceive(pt, "end");
5556}
5557
Neels Hofmeyr91401012019-07-11 00:42:35 +02005558private function f_probe_for_handover(charstring log_label,
5559 charstring log_descr,
5560 charstring handover_vty_cmd,
5561 boolean expect_handover,
5562 boolean is_inter_bsc_handover := false)
5563runs on MSC_ConnHdlr
5564{
Neels Hofmeyrb3fc8982020-05-11 00:16:42 +02005565 /* We're going to thwart any and all handover attempts, just be ready to handle (and ignore) handover target
5566 * lchans to be established on bts 1 or bts 2. */
5567 f_rslem_suspend(RSL1_PROC);
5568 f_rslem_suspend(RSL2_PROC);
5569
Neels Hofmeyr91401012019-07-11 00:42:35 +02005570 var RSL_Message rsl;
5571
5572 var charstring log_msg := " (expecting handover)"
5573 if (not expect_handover) {
5574 log_msg := " (expecting NO handover)";
5575 }
5576 log("f_probe_for_handover starting: " & log_label & ": " & log_descr & log_msg);
5577 f_vty_transceive(BSCVTY, handover_vty_cmd);
5578
Neels Hofmeyr91401012019-07-11 00:42:35 +02005579 timer T := 2.0;
5580 T.start;
5581
5582 alt {
5583 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr)) -> value rsl {
5584 var PDU_ML3_NW_MS l3 := dec_PDU_ML3_NW_MS(rsl.ies[2].body.l3_info.payload);
5585 log("Rx L3 from net: ", l3);
5586 if (ischosen(l3.msgs.rrm.handoverCommand)) {
5587 var RslChannelNr new_chan_nr;
5588 var GsmArfcn arfcn;
5589 f_ChDesc2RslChanNr(l3.msgs.rrm.handoverCommand.channelDescription2,
5590 new_chan_nr, arfcn);
5591 log("Handover to new chan ", new_chan_nr, " on ARFCN ", arfcn);
5592 log(l3.msgs.rrm.handoverCommand);
5593
5594 /* Need to register for new lchan on new BTS -- it's either bts 1 or bts 2. It doesn't really
5595 * matter on which BTS it really is, we're not going to follow through an entire handover
5596 * anyway. */
5597 f_rslem_register(0, new_chan_nr, RSL1_PROC);
5598 f_rslem_resume(RSL1_PROC);
5599 f_rslem_register(0, new_chan_nr, RSL2_PROC);
5600 f_rslem_resume(RSL2_PROC);
5601
5602 if (expect_handover and not is_inter_bsc_handover) {
5603 setverdict(pass);
5604 log("f_probe_for_handover(" & log_label & "): Got RSL Handover Command as expected.");
5605 } else {
5606 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected none, but got RSL Handover Command. "
5607 & log_label & ": " & log_descr);
5608 }
5609
5610 log("f_probe_for_handover(" & log_label & "): Ending the test: Handover Failure stops the procedure.");
5611 /* osmo-bsc has triggered Handover. That's all we need to know for this test, reply with
5612 * Handover Failure. */
5613 f_rsl_send_l3(ts_RRM_HandoverFailure('00'O));
5614
5615 /* target BTS is told to release lchan again; don't care which BTS nor what messages. */
5616 f_sleep(0.5);
5617 RSL1.clear;
5618 RSL2.clear;
5619 log("f_probe_for_handover(" & log_label & "): done (got RSL Handover Command)");
5620 break;
5621 } else {
5622 repeat;
5623 }
5624 }
5625 [] BSSAP.receive(tr_BSSMAP_HandoverRequired) {
5626 if (expect_handover and is_inter_bsc_handover) {
5627 setverdict(pass);
5628 log("f_probe_for_handover(" & log_label & "): Got BSSMAP Handover Required as expected.");
5629 } else {
5630 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected none, but got BSSMAP Handover Required. "
5631 & log_label & ": " & log_descr);
5632 }
5633
5634 log("f_probe_for_handover(" & log_label & "): done (got BSSMAP Handover Required)");
5635
5636 /* Note: f_tc_ho_neighbor_config_start() sets T7, the timeout for BSSMAP Handover Required, to
5637 * 1 second. There is no legal way to quickly abort a handover after a BSSMAP Handover Required,
5638 * setting a short timeout and waiting is the only way. */
5639 log("f_probe_for_handover(" & log_label & "): waiting for inter-BSC HO to time out...");
5640 f_sleep(1.5);
5641 log("f_probe_for_handover(" & log_label & "): ...done");
5642
5643 break;
5644 }
5645 [] T.timeout {
5646 if (expect_handover) {
5647 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected Handover, but got none. "
5648 & log_label & ": " & log_descr);
5649 } else {
5650 setverdict(pass);
5651 log("f_probe_for_handover(" & log_label & "): Got no Handover, as expected.");
5652 }
5653 log("f_probe_for_handover(" & log_label & "): done (got no Handover)");
5654 break;
5655 }
5656 }
5657
5658 f_rslem_resume(RSL1_PROC);
5659 f_rslem_resume(RSL2_PROC);
5660 f_sleep(3.0);
5661 RSL.clear;
5662
5663 log("f_probe_for_handover(" & log_label & "): done clearing");
5664}
5665
5666/* Test the effect of various neighbor configuration scenarios:
5667 *
5668 * To avoid complexity, block off any actual handover operation, and always remain on the lchan at bts 0.
5669 * Reconfigure the neighbors for bts 0, trigger a Handover, and probe whether osmo-bsc does or doesn't start HO.
5670 */
5671private function f_tc_ho_neighbor_config_start() runs on MSC_ConnHdlr {
5672 g_pars := f_gen_test_hdlr_pars();
5673 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
5674 var PDU_BSSAP ass_cmd := f_gen_ass_req();
5675 const OCT8 kc := '0001020304050607'O;
5676
5677 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
5678 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
5679
5680 /* Establish lchan at bts 0 */
5681 f_establish_fully(ass_cmd, exp_compl);
5682
5683 /* Shorten the inter-BSC Handover timeout, to not wait so long for inter-BSC Handovers */
5684 f_vty_enter_cfg_network(BSCVTY);
5685 f_vty_transceive(BSCVTY, "timer T7 1");
5686 f_vty_transceive(BSCVTY, "end");
5687}
5688
5689private function f_tc_ho_neighbor_config_1(charstring id) runs on MSC_ConnHdlr {
5690 f_tc_ho_neighbor_config_start();
5691
5692 /*
5693 * bts 0 ARFCN 871 BSIC 10
5694 * bts 1 ARFCN 871 BSIC 11
5695 * bts 2 ARFCN 871 BSIC 12
5696 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5697 */
5698
5699 log("f_tc_ho_neighbor_config: 1. No 'neighbor' config");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005700 f_bts_0_cfg(BSCVTY, {"no neighbors"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005701 f_probe_for_handover("1.a", "HO to bts 1 works, implicitly listed as neighbor (legacy behavior when none are configured)",
5702 "handover any to arfcn 871 bsic 11",
5703 true);
5704
5705 f_probe_for_handover("1.b", "HO to unknown cell does not start",
5706 "handover any to arfcn 13 bsic 39",
5707 false);
5708
5709 f_probe_for_handover("1.c", "HO to 871-12 is ambiguous = error",
5710 "handover any to arfcn 871 bsic 12",
5711 false);
5712
5713 f_probe_for_handover("1.d", "HO to 871-11 still works (verify that this test properly cleans up)",
5714 "handover any to arfcn 871 bsic 11",
5715 true);
5716}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005717testcase TC_ho_neighbor_config_1() runs on test_CT {
5718 var MSC_ConnHdlr vc_conn;
5719 f_init(3, true, guard_timeout := 60.0);
5720 f_sleep(1.0);
5721 f_ctrs_bsc_and_bts_init();
5722 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_1));
5723 vc_conn.done;
5724
5725 /* f_tc_ho_neighbor_config_start() */
5726 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5727 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5728
5729 /* 1.a */
5730 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
5731 * handover quickly by sending a Handover Failure message. */
5732 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5733 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5734 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5735 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
5736
5737 /* 1.b */
5738 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5739 f_ctrs_bsc_and_bts_add(0, "handover:error");
5740
5741 /* 1.c */
5742 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5743 f_ctrs_bsc_and_bts_add(0, "handover:error");
5744
5745 /* 1.d */
5746 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5747 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5748 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5749 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
5750
5751 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005752 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005753}
5754
Neels Hofmeyr91401012019-07-11 00:42:35 +02005755private function f_tc_ho_neighbor_config_2(charstring id) runs on MSC_ConnHdlr {
5756 f_tc_ho_neighbor_config_start();
5757
5758 /*
5759 * bts 0 ARFCN 871 BSIC 10
5760 * bts 1 ARFCN 871 BSIC 11
5761 * bts 2 ARFCN 871 BSIC 12
5762 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5763 */
5764
5765 log("f_tc_ho_neighbor_config: 2. explicit local neighbor: 'neighbor bts 1'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005766 f_bts_0_cfg(BSCVTY, {"neighbor bts 1"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005767 f_sleep(0.5);
5768
5769 f_probe_for_handover("2.a", "HO to bts 1 works, explicitly listed as neighbor",
5770 "handover any to arfcn 871 bsic 11",
5771 true);
5772
5773 f_probe_for_handover("2.b", "HO to bts 2 doesn't work, not listed as neighbor",
5774 "handover any to arfcn 871 bsic 12",
5775 false);
5776}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005777testcase TC_ho_neighbor_config_2() runs on test_CT {
5778 var MSC_ConnHdlr vc_conn;
5779 f_init(3, true, guard_timeout := 50.0);
5780 f_sleep(1.0);
5781 f_ctrs_bsc_and_bts_init();
5782 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_2));
5783 vc_conn.done;
5784
5785 /* f_tc_ho_neighbor_config_start() */
5786 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5787 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5788
5789 /* 2.a */
5790 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
5791 * handover quickly by sending a Handover Failure message. */
5792 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5793 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5794 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5795 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
5796
5797 /* 2.b */
5798 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5799 f_ctrs_bsc_and_bts_add(0, "handover:error");
5800
5801 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005802 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005803}
5804
Neels Hofmeyr91401012019-07-11 00:42:35 +02005805private function f_tc_ho_neighbor_config_3(charstring id) runs on MSC_ConnHdlr {
5806 f_tc_ho_neighbor_config_start();
5807
5808 /*
5809 * bts 0 ARFCN 871 BSIC 10
5810 * bts 1 ARFCN 871 BSIC 11
5811 * bts 2 ARFCN 871 BSIC 12
5812 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5813 */
5814
5815 log("f_tc_ho_neighbor_config: 3. explicit local neighbor: 'neighbor bts 2'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005816 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor bts 2"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005817 f_sleep(0.5);
5818
5819 f_probe_for_handover("3.a", "HO to bts 1 doesn't work, not listed as neighbor",
5820 "handover any to arfcn 871 bsic 11",
5821 false);
5822 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",
5823 "handover any to arfcn 871 bsic 12",
5824 true);
5825}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005826testcase TC_ho_neighbor_config_3() runs on test_CT {
5827 var MSC_ConnHdlr vc_conn;
5828 f_init(3, true, guard_timeout := 50.0);
5829 f_sleep(1.0);
5830 f_ctrs_bsc_and_bts_init();
5831 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_3));
5832 vc_conn.done;
5833
5834 /* f_tc_ho_neighbor_config_start() */
5835 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5836 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5837
5838 /* 3.a */
5839 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5840 f_ctrs_bsc_and_bts_add(0, "handover:error");
5841
5842 /* 3.b */
5843 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
5844 * handover quickly by sending a Handover Failure message. */
5845 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5846 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5847 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5848 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
5849
5850 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005851 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005852}
5853
Neels Hofmeyr91401012019-07-11 00:42:35 +02005854private function f_tc_ho_neighbor_config_4(charstring id) runs on MSC_ConnHdlr {
5855 f_tc_ho_neighbor_config_start();
5856
5857 /*
5858 * bts 0 ARFCN 871 BSIC 10
5859 * bts 1 ARFCN 871 BSIC 11
5860 * bts 2 ARFCN 871 BSIC 12
5861 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5862 */
5863
5864 log("f_tc_ho_neighbor_config: 4. explicit remote neighbor: 'neighbor lac 99 arfcn 123 bsic 45'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005865 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor lac 99 arfcn 123 bsic 45"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005866 f_sleep(0.5);
5867
5868 f_probe_for_handover("4.a", "HO to bts 1 doesn't work, not listed as neighbor",
5869 "handover any to arfcn 871 bsic 11",
5870 false);
5871 f_probe_for_handover("4.b", "HO to bts 2 doesn't work, not listed as neighbor",
5872 "handover any to arfcn 871 bsic 12",
5873 false);
5874 f_probe_for_handover("4.c", "HO to 123-45 triggers inter-BSC HO",
5875 "handover any to arfcn 123 bsic 45",
5876 true, true);
5877}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005878testcase TC_ho_neighbor_config_4() runs on test_CT {
5879 var MSC_ConnHdlr vc_conn;
5880 f_init(3, true, guard_timeout := 50.0);
5881 f_sleep(1.0);
5882 f_ctrs_bsc_and_bts_init();
5883 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_4));
5884 vc_conn.done;
5885
5886 /* f_tc_ho_neighbor_config_start() */
5887 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5888 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5889
5890 /* 4.a */
5891 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5892 f_ctrs_bsc_and_bts_add(0, "handover:error");
5893
5894 /* 4.b */
5895 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5896 f_ctrs_bsc_and_bts_add(0, "handover:error");
5897
5898 /* 4.c */
5899 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
5900 * handover quickly by timing out after the Handover Required message */
5901 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5902 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
5903 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
5904 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
5905
5906 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005907 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005908}
5909
Neels Hofmeyr91401012019-07-11 00:42:35 +02005910private function f_tc_ho_neighbor_config_5(charstring id) runs on MSC_ConnHdlr {
5911 f_tc_ho_neighbor_config_start();
5912
5913 /*
5914 * bts 0 ARFCN 871 BSIC 10
5915 * bts 1 ARFCN 871 BSIC 11
5916 * bts 2 ARFCN 871 BSIC 12
5917 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5918 */
5919
5920 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 +02005921 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor lac 99 arfcn 871 bsic 12"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005922 f_sleep(0.5);
5923
5924 f_probe_for_handover("5.a", "HO to 871-12 triggers inter-BSC HO (ignoring local cells with same ARFCN+BSIC)",
5925 "handover any to arfcn 871 bsic 12",
5926 true, true);
5927}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005928testcase TC_ho_neighbor_config_5() runs on test_CT {
5929 var MSC_ConnHdlr vc_conn;
5930 f_init(3, true);
5931 f_sleep(1.0);
5932 f_ctrs_bsc_and_bts_init();
5933 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_5));
5934 vc_conn.done;
5935
5936 /* f_tc_ho_neighbor_config_start() */
5937 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5938 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5939
5940 /* 5 */
5941 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
5942 * handover quickly by timing out after the Handover Required message */
5943 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5944 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
5945 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
5946 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
5947
5948 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005949 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005950}
5951
Neels Hofmeyr91401012019-07-11 00:42:35 +02005952private function f_tc_ho_neighbor_config_6(charstring id) runs on MSC_ConnHdlr {
5953 f_tc_ho_neighbor_config_start();
5954
5955 /*
5956 * bts 0 ARFCN 871 BSIC 10
5957 * bts 1 ARFCN 871 BSIC 11
5958 * bts 2 ARFCN 871 BSIC 12
5959 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5960 */
5961
5962 log("f_tc_ho_neighbor_config: 6. config error: explicit local and remote neighbors with ambiguous ARFCN+BSIC:"
5963 & " 'neighbor bts 2; neighbor lac 99 arfcn 871 bsic 12'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005964 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor bts 2", "neighbor lac 99 arfcn 871 bsic 12"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005965 f_sleep(0.5);
5966
5967 f_probe_for_handover("6.a", "HO to 871-12 is ambiguous = error",
5968 "handover any to arfcn 871 bsic 12",
5969 false);
5970}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005971testcase TC_ho_neighbor_config_6() runs on test_CT {
5972 var MSC_ConnHdlr vc_conn;
5973 f_init(3, true);
5974 f_sleep(1.0);
5975 f_ctrs_bsc_and_bts_init();
5976 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_6));
5977 vc_conn.done;
5978
5979 /* f_tc_ho_neighbor_config_start() */
5980 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5981 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5982
5983 /* 6.a */
5984 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
5985 * handover quickly by timing out after the Handover Required message */
5986 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5987 f_ctrs_bsc_and_bts_add(0, "handover:error");
5988
5989 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005990 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005991}
5992
Neels Hofmeyr91401012019-07-11 00:42:35 +02005993private function f_tc_ho_neighbor_config_7(charstring id) runs on MSC_ConnHdlr {
5994 f_tc_ho_neighbor_config_start();
5995
5996 /*
5997 * bts 0 ARFCN 871 BSIC 10
5998 * bts 1 ARFCN 871 BSIC 11
5999 * bts 2 ARFCN 871 BSIC 12
6000 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
6001 */
6002
6003 log("f_tc_ho_neighbor_config: 7. explicit local and remote neighbors:"
6004 & " 'neighbor bts 2; neighbor lac 99 arfcn 123 bsic 45'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02006005 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor bts 2", "neighbor lac 99 arfcn 123 bsic 45"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02006006 f_sleep(0.5);
6007
6008 f_probe_for_handover("7.a", "HO to 871-12 does HO to bts 2",
6009 "handover any to arfcn 871 bsic 12",
6010 true);
6011 f_probe_for_handover("7.b", "HO to 123-45 triggers inter-BSC HO",
6012 "handover any to arfcn 123 bsic 45",
6013 true, true);
6014}
Neels Hofmeyr91401012019-07-11 00:42:35 +02006015testcase TC_ho_neighbor_config_7() runs on test_CT {
6016 var MSC_ConnHdlr vc_conn;
Neels Hofmeyrf2b88032020-06-16 00:35:04 +02006017 f_init(3, true, guard_timeout := 50.0);
Neels Hofmeyr91401012019-07-11 00:42:35 +02006018 f_sleep(1.0);
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006019 f_ctrs_bsc_and_bts_init();
Neels Hofmeyr91401012019-07-11 00:42:35 +02006020 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_7));
6021 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006022
6023 /* f_tc_ho_neighbor_config_start() */
6024 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
6025 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
6026
6027 /* 7.a */
6028 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
6029 * handover quickly by sending a Handover Failure message. */
6030 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6031 f_ctrs_bsc_and_bts_add(0, "handover:failed");
6032 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
6033 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
6034
6035 /* 7.b */
6036 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
6037 * handover quickly by timing out after the Handover Required message */
6038 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6039 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
6040 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
6041 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
6042
6043 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006044 f_shutdown_helper();
Neels Hofmeyr91401012019-07-11 00:42:35 +02006045}
6046
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01006047/* OS#3041: Open and close N connections in a normal fashion, and expect no
6048 * BSSMAP Reset just because of that. */
6049testcase TC_bssap_rlsd_does_not_cause_bssmap_reset() runs on test_CT {
6050 var default d;
6051 var integer i;
6052 var DchanTuple dt;
6053
6054 f_init();
6055
6056 /* Wait for initial BSSMAP Reset to pass */
6057 f_sleep(4.0);
6058
6059 d := activate(no_bssmap_reset());
6060
6061 /* Setup up a number of connections and RLSD them again from the MSC
6062 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
6063 * Let's do it some more times for good measure. */
Harald Weltec3260d92018-06-11 17:48:16 +02006064 for (i := 0; i < 4; i := i+1) {
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01006065 /* Since we're doing a lot of runs, give each one a fresh
6066 * T_guard from the top. */
6067 T_guard.start;
6068
6069 /* Setup a BSSAP connection and clear it right away. This is
6070 * the MSC telling the BSC about a planned release, it's not an
6071 * erratic loss of a connection. */
Harald Weltea1897182018-06-11 13:53:09 +02006072 dt := f_est_dchan(int2oct(i,1), 23+i, '00010203040506'O);
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01006073
6074 /* MSC disconnects (RLSD). */
6075 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
6076 }
6077
6078 /* In the buggy behavior, a timeout of 2 seconds happens between above
6079 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
6080 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
6081 f_sleep(4.0);
6082
6083 deactivate(d);
6084 f_shutdown_helper();
6085}
Harald Welte552620d2017-12-16 23:21:36 +01006086
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01006087/* OS#3041: Open and close N connections in a normal fashion, and expect no
6088 * BSSMAP Reset just because of that. Invoke the release by a BSSMAP Clear from
6089 * the MSC. */
6090testcase TC_bssmap_clear_does_not_cause_bssmap_reset() runs on test_CT {
6091 var default d;
6092 var integer i;
6093 var DchanTuple dt;
6094 var BSSAP_N_DATA_ind rx_di;
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01006095 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_CALL_CONTROL;
6096 var BssmapCause cause := enum2int(cause_val);
6097
6098 f_init();
6099
6100 /* Wait for initial BSSMAP Reset to pass */
6101 f_sleep(4.0);
6102
6103 d := activate(no_bssmap_reset());
6104
6105 /* Setup up a number of connections and RLSD them again from the MSC
6106 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
6107 * Let's do it some more times for good measure. */
6108 for (i := 0; i < 8; i := i+1) {
6109 /* Since we're doing a lot of runs, give each one a fresh
6110 * T_guard from the top. */
6111 T_guard.start;
6112
6113 /* Setup a BSSAP connection and clear it right away. This is
6114 * the MSC telling the BSC about a planned release, it's not an
6115 * erratic loss of a connection. */
Harald Weltea1897182018-06-11 13:53:09 +02006116 dt := f_est_dchan(int2oct(i,1), 23+i, '00010203040506'O);
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01006117
6118 /* Instruct BSC to clear channel */
6119 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
6120
6121 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02006122 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01006123 }
6124
6125 /* In the buggy behavior, a timeout of 2 seconds happens between above
6126 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
6127 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
6128 f_sleep(4.0);
6129
6130 deactivate(d);
6131 f_shutdown_helper();
6132}
6133
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01006134/* OS#3041: Open and close N connections in a normal fashion, and expect no
6135 * BSSMAP Reset just because of that. Close connections from the MS side with a
6136 * Release Ind on RSL. */
6137testcase TC_ms_rel_ind_does_not_cause_bssmap_reset() runs on test_CT {
6138 var default d;
6139 var integer i;
6140 var DchanTuple dt;
6141 var BSSAP_N_DATA_ind rx_di;
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01006142 var integer j;
6143
6144 f_init();
6145
6146 /* Wait for initial BSSMAP Reset to pass */
6147 f_sleep(4.0);
6148
6149 d := activate(no_bssmap_reset());
6150
6151 /* Setup up a number of connections and RLSD them again from the MSC
6152 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
6153 * Let's do it some more times for good measure. */
6154 for (i := 0; i < 8; i := i+1) {
6155 /* Since we're doing a lot of runs, give each one a fresh
6156 * T_guard from the top. */
6157 T_guard.start;
6158
6159 /* Setup a BSSAP connection and clear it right away. This is
6160 * the MSC telling the BSC about a planned release, it's not an
6161 * erratic loss of a connection. */
6162 dt := f_est_dchan('23'O, 23, '00010203040506'O);
6163
6164 /* simulate RLL REL IND */
6165 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0))));
6166
6167 /* expect Clear Request on MSC side */
6168 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
6169
6170 /* Instruct BSC to clear channel */
6171 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
6172 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
6173
6174 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02006175 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01006176 }
6177
6178 /* In the buggy behavior, a timeout of 2 seconds happens between above
6179 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
6180 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
6181 f_sleep(4.0);
6182
6183 deactivate(d);
6184 f_shutdown_helper();
6185}
6186
Harald Welte94e0c342018-04-07 11:33:23 +02006187/***********************************************************************
6188 * IPA style dynamic PDCH
6189 ***********************************************************************/
6190
6191private function f_dyn_ipa_pdch_act(integer bts_nr, integer trx_nr, integer ts_nr,
6192 template (omit) RSL_Cause nack := omit)
6193runs on test_CT {
6194 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(ts_nr));
6195 var RSL_Message rsl_unused;
6196 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
6197 f_vty_ts_action("pdch activate", bts_nr, trx_nr, ts_nr);
6198 /* expect the BSC to issue the related RSL command */
6199 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
6200 if (istemplatekind(nack, "omit")) {
6201 /* respond with a related acknowledgement */
6202 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
6203 } else {
6204 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_NACK(chan_nr, valueof(nack)));
6205 }
6206}
6207
6208private function f_dyn_ipa_pdch_deact(integer bts_nr, integer trx_nr, integer ts_nr,
6209 template (omit) RSL_Cause nack := omit)
6210runs on test_CT {
6211 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(ts_nr));
6212 var RSL_Message rsl_unused;
6213 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
6214 f_vty_ts_action("pdch deactivate", bts_nr, trx_nr, ts_nr);
6215 /* expect the BSC to issue the related RSL command */
6216 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_DEACT(chan_nr));
6217 if (istemplatekind(nack, "omit")) {
6218 /* respond with a related acknowledgement */
6219 f_ipa_tx(0, ts_RSL_IPA_PDCH_DEACT_ACK(chan_nr));
6220 } else {
6221 f_ipa_tx(0, ts_RSL_IPA_PDCH_DEACT_NACK(chan_nr, valueof(nack)));
6222 }
6223}
6224
6225private function f_ts_dyn_mode_get(integer bts_nr, integer trx_nr, integer ts_nr)
6226runs on test_CT return charstring {
6227 var charstring cmd, resp;
6228 cmd := "show timeslot "&int2str(bts_nr)&" "&int2str(trx_nr)&" "&int2str(ts_nr);
Stefan Sperlingcff13562018-11-13 15:24:06 +01006229 return f_vty_transceive_match_regexp_retry(BSCVTY, cmd, "*\((*)\)*", 0, 4, 1.0);
Harald Welte94e0c342018-04-07 11:33:23 +02006230}
6231
6232private function f_ts_dyn_mode_assert(integer bts_nr, integer trx_nr, integer ts_nr,
6233 template charstring exp)
6234runs on test_CT {
6235 var charstring mode := f_ts_dyn_mode_get(bts_nr, trx_nr, ts_nr);
6236 if (not match(mode, exp)) {
6237 setverdict(fail, "Unexpected TS Mode: ", mode);
Daniel Willmannafce8662018-07-06 23:11:32 +02006238 mtc.stop;
Harald Welte94e0c342018-04-07 11:33:23 +02006239 }
6240}
6241
6242private function f_ts_set_chcomb(integer bts_nr, integer trx_nr, integer ts_nr, charstring chcomb)
6243runs on test_CT {
6244 f_vty_enter_cfg_ts(BSCVTY, bts_nr, trx_nr, ts_nr);
6245 f_vty_transceive(BSCVTY, "phys_chan_config " & chcomb);
6246 f_vty_transceive(BSCVTY, "end");
6247}
6248
6249private const charstring TCHF_MODE := "TCH/F mode";
6250private const charstring TCHH_MODE := "TCH/H mode";
6251private const charstring PDCH_MODE := "PDCH mode";
6252private const charstring NONE_MODE := "NONE mode";
6253
6254/* Test IPA PDCH activation / deactivation triggered by VTY */
6255testcase TC_dyn_pdch_ipa_act_deact() runs on test_CT {
6256 var RSL_Message rsl_unused;
6257
6258 /* change Timeslot 6 before f_init() starts RSL */
6259 f_init_vty();
6260 f_ts_set_chcomb(0, 0, 6, "TCH/F_PDCH");
6261 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
6262
6263 f_init(1, false);
6264 f_sleep(1.0);
6265
6266 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
6267
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006268 log("TCH/F_PDCH pchan starts out in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02006269 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6270 /* The BSC will activate the dynamic PDCH by default, so confirm that */
6271 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
6272 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
6273 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006274 log("TCH/F_PDCH pchan, PDCH ACT was ACKed, so now in PDCH mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02006275 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
6276
6277 /* De-activate it via VTY */
6278 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
6279 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006280 log("TCH/F_PDCH pchan, PDCH DEACT via VTY, so now back in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02006281 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6282
6283 /* re-activate it via VTY */
6284 f_dyn_ipa_pdch_act(0, 0, chan_nr.tn);
6285 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006286 log("TCH/F_PDCH pchan, PDCH ACT via VTY, so now in PDCH mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02006287 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
6288
6289 /* and finally de-activate it again */
6290 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
6291 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006292 log("TCH/F_PDCH pchan, PDCH DEACT via VTY, so now back in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02006293 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6294
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02006295 /* clean up config */
6296 f_ts_set_chcomb(0, 0, 6, "PDCH");
6297
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006298 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02006299}
6300
6301/* Test IPA PDCH activation NACK */
6302testcase TC_dyn_pdch_ipa_act_nack() runs on test_CT {
6303 var RSL_Message rsl_unused;
6304
6305 /* change Timeslot 6 before f_init() starts RSL */
6306 f_init_vty();
6307 f_ts_set_chcomb(0, 0, 6, "TCH/F_PDCH");
6308 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
6309
6310 f_init(1, false);
6311 f_sleep(1.0);
6312
6313 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
6314
6315 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6316 /* The BSC will activate the dynamic PDCH by default, so confirm that */
6317 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
6318 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
6319 f_sleep(1.0);
6320 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
6321
6322 /* De-activate it via VTY */
6323 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
6324 f_sleep(1.0);
6325 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6326
6327 /* re-activate it via VTY, but fail that; check BSC still assumes TCH/F mode */
6328 f_dyn_ipa_pdch_act(0, 0, chan_nr.tn, RSL_ERR_EQUIPMENT_FAIL);
6329 f_sleep(1.0);
6330 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6331
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02006332 /* clean up config */
6333 f_ts_set_chcomb(0, 0, 6, "PDCH");
6334
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006335 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02006336}
6337
6338
6339/***********************************************************************
6340 * Osmocom style dynamic PDCH
6341 ***********************************************************************/
6342
6343private function f_dyn_osmo_pdch_act(integer bts_nr, integer trx_nr, integer ts_nr,
6344 template (omit) RSL_Cause nack := omit)
6345runs on test_CT {
6346 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(ts_nr));
6347 var RSL_Message rsl_unused;
6348 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
6349 /* FIXME: no VTY command to activate Osmocom PDCH !! */
6350 /* expect the BSC to issue the related RSL command */
6351 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT(chan_nr, ?));
6352 if (istemplatekind(nack, "omit")) {
6353 /* respond with a related acknowledgement */
6354 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342));
6355 } else {
6356 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, valueof(nack)));
6357 }
6358}
6359
6360private function f_dyn_osmo_pdch_deact(integer bts_nr, integer trx_nr, integer ts_nr,
6361 template (omit) RSL_Cause nack := omit)
6362runs on test_CT {
6363 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(ts_nr));
6364 var RSL_Message rsl_unused;
6365 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
6366 /* FIXME: no VTY command to activate Osmocom PDCH !! */
6367 /* expect the BSC to issue the related RSL command */
6368 rsl_unused := f_exp_ipa_rx(0, tr_RSL_RF_CHAN_REL(chan_nr));
6369 if (istemplatekind(nack, "omit")) {
6370 /* respond with a related acknowledgement */
6371 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(chan_nr));
6372 } else {
6373 //f_ipa_tx(0, ts_RSL_RF_CHAN_REL_NACK(chan_nr, valueof(nack)));
6374 }
6375}
6376
6377/* Test Osmocom dyn PDCH activation / deactivation triggered by VTY */
6378testcase TC_dyn_pdch_osmo_act_deact() runs on test_CT {
6379 var RSL_Message rsl_unused;
6380
6381 /* change Timeslot 6 before f_init() starts RSL */
6382 f_init_vty();
6383 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_PDCH");
6384 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
6385
6386 f_init(1, false);
6387 f_sleep(1.0);
6388
6389 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(6));
6390
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006391 log("TCH/F_TCH/H_PDCH pchan starts out in disabled mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02006392 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
6393 /* The BSC will activate the dynamic PDCH by default, so confirm that */
6394 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
6395
6396 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342));
6397 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006398 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 +02006399 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_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/* Test Osmocom dyn PDCH activation NACK behavior */
6408testcase TC_dyn_pdch_osmo_act_nack() runs on test_CT {
6409 var RSL_Message rsl_unused;
6410
6411 /* change Timeslot 6 before f_init() starts RSL */
6412 f_init_vty();
6413 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_PDCH");
6414 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
6415
6416 f_init(1, false);
6417 f_sleep(1.0);
6418
6419 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(6));
6420
6421 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
6422 /* The BSC will activate the dynamic PDCH by default, so confirm that */
6423 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
6424
6425 /* NACK this activation and expect the "show timeslot" mode still to be NONE */
6426 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, RSL_ERR_EQUIPMENT_FAIL));
6427 f_sleep(1.0);
6428 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
6429
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02006430 /* clean up config */
6431 f_ts_set_chcomb(0, 0, 6, "PDCH");
6432
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006433 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02006434}
6435
Stefan Sperling0796a822018-10-05 13:01:39 +02006436testcase TC_chopped_ipa_ping() runs on test_CT {
Stefan Sperling554123f2018-10-09 14:12:30 +02006437 const Integers bsc_ipa_ports := {mp_bsc_rsl_port, mp_bsc_oml_port, mp_bsc_ctrl_port};
Stefan Sperling0796a822018-10-05 13:01:39 +02006438 for (var integer i := 0; i < lengthof(bsc_ipa_ports); i := i + 1) {
6439 IPA_Testing.f_run_TC_chopped_ipa_ping(mp_bsc_ip, bsc_ipa_ports[i], CONNECT_TO_SERVER);
6440 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006441 f_shutdown_helper();
Stefan Sperling0796a822018-10-05 13:01:39 +02006442}
6443
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02006444testcase TC_chopped_ipa_payload() runs on test_CT {
6445 const Integers bsc_ipa_ports := {mp_bsc_rsl_port, mp_bsc_oml_port
6446 /* TODO: mp_bsc_ctrl_port does not work yet */};
6447 for (var integer i := 0; i < lengthof(bsc_ipa_ports); i := i + 1) {
6448 IPA_Testing.f_run_TC_chopped_ipa_payload(mp_bsc_ip, bsc_ipa_ports[i], CONNECT_TO_SERVER);
6449 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006450 f_shutdown_helper();
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02006451}
6452
Pau Espin Pedrol8f773632019-11-05 11:46:53 +01006453/* Verify the BSC sends the MS Power Parameters IE during CHAN ACT to make sure
6454 the BTS does autonomous MS power control loop */
6455testcase TC_assignment_verify_ms_power_params_ie() runs on test_CT {
6456 var MSC_ConnHdlr vc_conn;
6457 var TestHdlrParams pars := f_gen_test_hdlr_pars();
6458 //pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
6459 pars.exp_ms_power_params := true;
6460
6461 f_init(1, true);
6462 f_sleep(1.0);
6463 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
6464 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006465 f_shutdown_helper();
Pau Espin Pedrol8f773632019-11-05 11:46:53 +01006466}
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02006467
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006468/***********************************************************************
6469 * MSC Pooling
6470 ***********************************************************************/
6471
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006472template MobileIdentityLV ts_MI_TMSI_NRI_LV(integer nri_v, integer nri_bitlen := 10) :=
Harald Weltebf397612021-01-14 20:39:46 +01006473 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 +02006474
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02006475private function f_expect_lchan_rel(RSL_DCHAN_PT rsl) runs on MSC_ConnHdlr {
6476 interleave {
6477 [] rsl.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
6478 f_logp(BSCVTY, "Got RSL RR Release");
6479 }
6480 [] rsl.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
6481 f_logp(BSCVTY, "Got RSL Deact SACCH");
6482 }
6483 [] rsl.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
6484 f_logp(BSCVTY, "Got RSL RF Chan Rel, sending Rel Ack");
6485 rsl.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
6486 break;
6487 }
6488 }
6489}
6490
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006491private function f_perform_clear(RSL_DCHAN_PT rsl) runs on MSC_ConnHdlr {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006492 f_logp(BSCVTY, "MSC instructs BSC to clear channel");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006493 BSSAP.send(ts_BSSMAP_ClearCommand(0));
6494 interleave {
6495 [] rsl.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006496 f_logp(BSCVTY, "Got RSL RR Release");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006497 }
6498 [] rsl.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006499 f_logp(BSCVTY, "Got RSL Deact SACCH");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006500 }
6501 [] BSSAP.receive(tr_BSSMAP_ClearComplete) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006502 f_logp(BSCVTY, "Got BSSMAP Clear Complete");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006503 /* Also drop the SCCP connection */
6504 BSSAP.send(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_REQ);
6505 }
6506 [] rsl.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006507 f_logp(BSCVTY, "Got RSL RF Chan Rel, sending Rel Ack");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006508 rsl.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
6509 }
6510 }
6511}
6512
Neels Hofmeyr66e15092020-10-12 18:44:41 +00006513private 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 +02006514runs on MSC_ConnHdlr {
6515 timer T := 10.0;
6516 var octetstring l3_enc := enc_PDU_ML3_MS_NW(valueof(l3_info));
6517
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006518 f_logp(BSCVTY, "establish channel, send Complete Layer 3 Info");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006519 f_create_bssmap_exp(l3_enc);
6520
6521 /* RSL_Emulation.f_chan_est() on rsl:
6522 * This is basically code dup with s/RSL/rsl from:
6523 * RSL_Emulation.f_chan_est(g_pars.ra, l3_enc, g_pars.link_id, g_pars.fn);
6524 */
6525 var RSL_Message rx_rsl;
6526 var GsmRrMessage rr;
6527
6528 /* request a channel to be established */
6529 rsl.send(ts_RSLDC_ChanRqd(g_pars.ra, g_pars.fn));
6530 /* expect immediate assignment.
6531 * Code dup with s/RSL/rsl from:
6532 * rx_rsl := f_rx_or_fail(tr_RSL_IMM_ASSIGN);
6533 */
6534 timer Tt := 10.0;
6535
6536 /* request a channel to be established */
6537 Tt.start;
6538 alt {
6539 [] rsl.receive(tr_RSL_IMM_ASSIGN) -> value rx_rsl {
6540 Tt.stop;
6541 }
6542 [] rsl.receive {
6543 setverdict(fail, "Unexpected RSL message on DCHAN");
6544 mtc.stop;
6545 }
6546 [] Tt.timeout {
6547 setverdict(fail, "Timeout waiting for RSL on DCHAN");
6548 mtc.stop;
6549 }
6550 }
6551 rr := dec_GsmRrMessage(rx_rsl.ies[1].body.full_imm_ass_info.payload);
6552 g_chan_nr := rr.payload.imm_ass.chan_desc.chan_nr;
6553 rsl.send(ts_RSL_EST_IND(g_chan_nr, valueof(g_pars.link_id), l3_enc));
6554
6555
Neels Hofmeyr66e15092020-10-12 18:44:41 +00006556 if (expect_bssmap_l3) {
6557 f_logp(BSCVTY, "expect BSSAP Complete Layer 3 Info at MSC");
6558 var template PDU_BSSAP exp_l3_compl;
6559 exp_l3_compl := tr_BSSMAP_ComplL3()
6560 if (g_pars.aoip == false) {
6561 exp_l3_compl.pdu.bssmap.completeLayer3Information.codecList := omit;
6562 } else {
6563 exp_l3_compl.pdu.bssmap.completeLayer3Information.codecList := ?;
6564 }
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006565
Neels Hofmeyr66e15092020-10-12 18:44:41 +00006566 var PDU_BSSAP bssap;
6567 T.start;
6568 alt {
6569 [] BSSAP.receive(exp_l3_compl) -> value bssap {
6570 f_logp(BSCVTY, "received expected Complete Layer 3 Info at MSC");
6571 log("rx exp_l3_compl = ", bssap);
6572 }
6573 [] BSSAP.receive(tr_BSSMAP_ComplL3) {
6574 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received non-matching COMPLETE LAYER 3 INFORMATION");
6575 }
6576 [] T.timeout {
6577 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for COMPLETE LAYER 3 INFORMATION");
6578 }
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006579 }
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006580
Neels Hofmeyr66e15092020-10-12 18:44:41 +00006581 /* start ciphering, if requested */
6582 if (ispresent(g_pars.encr)) {
6583 f_logp(BSCVTY, "start ciphering");
6584 f_cipher_mode(g_pars.encr.enc_alg, g_pars.encr.enc_key);
6585 }
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006586 }
6587
6588 if (do_clear) {
6589 f_perform_clear(rsl);
6590 }
6591 setverdict(pass);
6592 f_sleep(1.0);
6593}
6594
6595private function f_tc_mscpool_compl_l3(charstring id) runs on MSC_ConnHdlr {
6596 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
6597 if (g_pars.mscpool.rsl_idx == 0) {
6598 f_perform_compl_l3(RSL, g_pars.mscpool.l3_info);
6599 } else if (g_pars.mscpool.rsl_idx == 1) {
6600 f_perform_compl_l3(RSL1, g_pars.mscpool.l3_info);
6601 } else if (g_pars.mscpool.rsl_idx == 2) {
6602 f_perform_compl_l3(RSL2, g_pars.mscpool.l3_info);
6603 }
6604}
6605
6606/* Various Complete Layer 3 by IMSI all end up with the first MSC, because the other MSCs are not connected. */
6607private function f_tc_mscpool_L3Compl_on_1_msc(charstring id) runs on MSC_ConnHdlr {
6608 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
6609 f_perform_compl_l3(RSL, ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000001'H)), '00F110'O) );
6610 f_perform_compl_l3(RSL, ts_CM_SERV_REQ(CM_TYPE_MO_SMS, valueof(ts_MI_IMSI_LV('001010000000002'H))) );
6611 f_perform_compl_l3(RSL, ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010000000003'H))) );
6612 f_perform_compl_l3(RSL, ts_ML3_MO_MM_IMSI_DET_Ind(valueof(ts_MI_IMSI_LV('001010000000004'H))) );
6613}
6614testcase TC_mscpool_L3Compl_on_1_msc() runs on test_CT {
6615
6616 f_init(1, true);
6617 f_sleep(1.0);
6618 var MSC_ConnHdlr vc_conn;
6619 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006620
6621 f_ctrs_msc_init();
6622
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006623 vc_conn := f_start_handler(refers(f_tc_mscpool_L3Compl_on_1_msc), pars);
6624 vc_conn.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006625
6626 f_ctrs_msc_expect(0, "mscpool:subscr:new", 4);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006627 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006628}
6629
6630/* Three Layer 3 Complete by IMSI are round-robin'ed across two connected MSCs */
6631/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6632 * just as well using only RSL. */
6633testcase TC_mscpool_L3Complete_by_imsi_round_robin() runs on test_CT {
6634
6635 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6636 f_sleep(1.0);
6637
6638 /* Control which MSC gets chosen next by the round-robin, otherwise
6639 * would be randomly affected by which other tests ran before this. */
6640 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6641
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006642 f_ctrs_msc_init();
6643
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006644 var MSC_ConnHdlr vc_conn1;
6645 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6646 pars1.mscpool.rsl_idx := 0;
6647 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000001'H)), '00F110'O));
6648 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6649 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006650 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006651
6652 var MSC_ConnHdlr vc_conn2;
6653 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6654 pars2.mscpool.rsl_idx := 1;
6655 pars2.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000002'H))));
6656 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6657 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006658 f_ctrs_msc_expect(1, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006659
6660 /* Test round-robin wrap to the first MSC */
6661 var MSC_ConnHdlr vc_conn3;
6662 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6663 pars3.mscpool.rsl_idx := 2;
6664 pars3.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010000000003'H))));
6665 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6666 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006667 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006668 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006669}
6670
6671/* Three LU by TMSI are round-robin'ed across two connected MSCs, because they contain the NULL-NRI 0
6672 * (configured in osmo-bsc.cfg). */
6673/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6674 * just as well using only RSL. */
6675testcase TC_mscpool_LU_by_tmsi_null_nri_0_round_robin() runs on test_CT {
6676
6677 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6678 f_sleep(1.0);
6679
6680 /* Control which MSC gets chosen next by the round-robin, otherwise
6681 * would be randomly affected by which other tests ran before this. */
6682 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6683
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006684 f_ctrs_msc_init();
6685
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006686 var MSC_ConnHdlr vc_conn1;
6687 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6688 pars1.mscpool.rsl_idx := 0;
6689 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(0)), '00F110'O));
6690 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6691 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006692 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006693
6694 var MSC_ConnHdlr vc_conn2;
6695 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6696 pars2.mscpool.rsl_idx := 1;
6697 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(0)), '00F110'O));
6698 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6699 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006700 f_ctrs_msc_expect(1, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006701
6702 /* Test round-robin wrap to the first MSC */
6703 var MSC_ConnHdlr vc_conn3;
6704 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6705 pars3.mscpool.rsl_idx := 2;
6706 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(0)), '00F110'O));
6707 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6708 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006709 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006710 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006711}
6712
6713/* Three LU by TMSI are round-robin'ed across two connected MSCs, because they contain the NULL-NRI 1
6714 * (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
6715 * NULL-NRI setting is stronger than that. */
6716/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6717 * just as well using only RSL. */
6718testcase TC_mscpool_LU_by_tmsi_null_nri_1_round_robin() runs on test_CT {
6719
6720 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6721 f_sleep(1.0);
6722
6723 /* Control which MSC gets chosen next by the round-robin, otherwise
6724 * would be randomly affected by which other tests ran before this. */
6725 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6726
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006727 f_ctrs_msc_init();
6728
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006729 var MSC_ConnHdlr vc_conn1;
6730 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6731 pars1.mscpool.rsl_idx := 0;
6732 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(1)), '00F110'O));
6733 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6734 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006735 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006736
6737 var MSC_ConnHdlr vc_conn2;
6738 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6739 pars2.mscpool.rsl_idx := 1;
6740 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(1)), '00F110'O));
6741 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6742 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006743 f_ctrs_msc_expect(1, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006744
6745 /* Test round-robin wrap to the first MSC */
6746 var MSC_ConnHdlr vc_conn3;
6747 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6748 pars3.mscpool.rsl_idx := 2;
6749 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(1)), '00F110'O));
6750 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6751 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006752 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006753 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006754}
6755
6756/* Three Layer 3 Complete by TMSI are round-robin'ed across two connected MSCs, because they contain an NRI not
6757 * assigned to any MSC (configured in osmo-bsc.cfg). */
6758/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6759 * just as well using only RSL. */
6760testcase TC_mscpool_L3Complete_by_tmsi_unassigned_nri_round_robin() runs on test_CT {
6761
6762 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6763 f_sleep(1.0);
6764
6765 /* Control which MSC gets chosen next by the round-robin, otherwise
6766 * would be randomly affected by which other tests ran before this. */
6767 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6768
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006769 f_ctrs_msc_init();
6770
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006771 var MSC_ConnHdlr vc_conn1;
6772 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6773 pars1.mscpool.rsl_idx := 0;
6774 /* An NRI that is not assigned to any MSC */
6775 pars1.mscpool.l3_info := valueof(ts_ML3_MO_MM_IMSI_DET_Ind(valueof(ts_MI_TMSI_NRI_LV(1023))));
6776 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6777 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006778 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006779
6780 var MSC_ConnHdlr vc_conn2;
6781 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6782 pars2.mscpool.rsl_idx := 1;
6783 /* An NRI that is not assigned to any MSC */
6784 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(768)), '00F110'O));
6785 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6786 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006787 f_ctrs_msc_expect(1, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006788
6789 /* Test round-robin wrap to the first MSC */
6790 var MSC_ConnHdlr vc_conn3;
6791 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6792 pars3.mscpool.rsl_idx := 2;
6793 /* An NRI that is not assigned to any MSC */
6794 pars3.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_SS_ACT, valueof(ts_MI_TMSI_NRI_LV(819))));
6795 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6796 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006797 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006798 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006799}
6800
6801/* Three Layer 3 Complete by TMSI are round-robin'ed across two connected MSCs, because they contain an NRI
6802 * assigned to an MSC that is currently not connected (configured in osmo-bsc.cfg). */
6803/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6804 * just as well using only RSL. */
6805testcase TC_mscpool_L3Complete_by_tmsi_valid_nri_msc_not_connected_round_robin() runs on test_CT {
6806
6807 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6808 f_sleep(1.0);
6809
6810 /* Control which MSC gets chosen next by the round-robin, otherwise
6811 * would be randomly affected by which other tests ran before this. */
6812 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6813
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006814 f_ctrs_msc_init();
6815
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006816 var MSC_ConnHdlr vc_conn1;
6817 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6818 pars1.mscpool.rsl_idx := 0;
6819 /* An NRI that is assigned to an unconnected MSC */
6820 pars1.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(512))));
6821 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6822 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006823 f_ctrs_msc_add(2, "mscpool:subscr:attach_lost");
6824 f_ctrs_msc_add(0, "mscpool:subscr:new");
6825 f_ctrs_msc_verify();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006826
6827 var MSC_ConnHdlr vc_conn2;
6828 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6829 pars2.mscpool.rsl_idx := 1;
6830 /* An NRI that is assigned to an unconnected MSC */
6831 pars2.mscpool.l3_info := valueof(ts_ML3_MO_MM_IMSI_DET_Ind(valueof(ts_MI_TMSI_NRI_LV(767))));
6832 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6833 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006834 f_ctrs_msc_add(2, "mscpool:subscr:attach_lost");
6835 f_ctrs_msc_add(1, "mscpool:subscr:new");
6836 f_ctrs_msc_verify();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006837
6838 /* Test round-robin wrap to the first MSC */
6839 var MSC_ConnHdlr vc_conn3;
6840 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6841 pars3.mscpool.rsl_idx := 2;
6842 /* An NRI that is assigned to an unconnected MSC */
6843 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(750)), '00F110'O));
6844 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6845 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006846 f_ctrs_msc_add(2, "mscpool:subscr:attach_lost");
6847 f_ctrs_msc_add(0, "mscpool:subscr:new");
6848 f_ctrs_msc_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006849 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006850}
6851
6852/* Three Layer 3 Complete by TMSI with valid NRI for the second MSC are all directed to the second MSC (configured in
6853 * osmo-bsc.cfg). */
6854/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6855 * just as well using only RSL. */
6856testcase TC_mscpool_L3Complete_by_tmsi_valid_nri_1() runs on test_CT {
6857
6858 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6859 f_sleep(1.0);
6860
6861 /* All TMSIs in this test point at the second MSC, set the round robin to point at the first MSC to make sure
6862 * this is not using round-robin. */
6863 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6864
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006865 f_ctrs_msc_init();
6866
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006867 var MSC_ConnHdlr vc_conn1;
6868 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 1);
6869 pars1.mscpool.rsl_idx := 0;
6870 /* An NRI of the second MSC's range (256-511) */
6871 pars1.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_SMS, valueof(ts_MI_TMSI_NRI_LV(256))));
6872 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6873 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006874 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006875
6876 var MSC_ConnHdlr vc_conn2;
6877 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6878 pars2.mscpool.rsl_idx := 1;
6879 /* An NRI of the second MSC's range (256-511) */
6880 pars2.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(260))));
6881 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6882 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006883 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006884
6885 var MSC_ConnHdlr vc_conn3;
6886 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 1);
6887 pars3.mscpool.rsl_idx := 2;
6888 /* An NRI of the second MSC's range (256-511) */
6889 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(511)), '00F110'O));
6890 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6891 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006892 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006893 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006894}
6895
6896/* Layer 3 Complete by TMSI with valid NRI for the third MSC are directed to the third MSC (configured in osmo-bsc.cfg),
6897 * while a round-robin remains unaffected by that. */
6898/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6899 * just as well using only RSL. */
6900testcase TC_mscpool_L3Complete_by_tmsi_valid_nri_2() runs on test_CT {
6901
6902 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
6903 f_sleep(1.0);
6904
6905 /* All TMSIs in this test point at the third MSC, set the round robin to point at the second MSC to make sure
6906 * this is not using round-robin. */
6907 f_vty_transceive(BSCVTY, "mscpool roundrobin next 1");
6908
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006909 f_ctrs_msc_init();
6910
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006911 var MSC_ConnHdlr vc_conn1;
6912 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 2);
6913 pars1.mscpool.rsl_idx := 0;
6914 /* An NRI of the third MSC's range (512-767) */
6915 pars1.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_SMS, valueof(ts_MI_TMSI_NRI_LV(512))));
6916 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6917 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006918 f_ctrs_msc_expect(2, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006919
6920 var MSC_ConnHdlr vc_conn2;
6921 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 2);
6922 pars2.mscpool.rsl_idx := 1;
6923 /* An NRI of the third MSC's range (512-767) */
6924 pars2.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(678))));
6925 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6926 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006927 f_ctrs_msc_expect(2, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006928
6929 /* The above forwardings to third MSC have not affected the round robin, which still points at the second MSC */
6930 var MSC_ConnHdlr vc_conn3;
6931 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 1);
6932 pars3.mscpool.rsl_idx := 2;
6933 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000013'H)), '00F110'O));
6934 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6935 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006936 f_ctrs_msc_expect(1, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006937 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006938}
6939
6940/* LU with a TMSI but indicating a different PLMN in its previous LAI: ignore the NRI. */
6941/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6942 * just as well using only RSL. */
6943testcase TC_mscpool_LU_by_tmsi_from_other_PLMN() runs on test_CT {
6944
6945 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
6946 f_sleep(1.0);
6947
6948 /* The TMSIs in this test points at the second MSC, but since it is from a different PLMN, round-robin is used
6949 * instead, and hits msc 0. */
6950 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6951
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006952 f_ctrs_msc_init();
6953
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006954 /* An NRI of the second MSC's range (256-511), but a PLMN that doesn't match with osmo-bsc.cfg */
6955 var MSC_ConnHdlr vc_conn1;
6956 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6957 pars1.mscpool.rsl_idx := 0;
6958 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(260)), '99F999'O));
6959 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6960 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006961 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006962
6963 /* An NRI of the third MSC's range (512-767) and a matching PLMN gets directed by NRI. */
6964 var MSC_ConnHdlr vc_conn2;
6965 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 2);
6966 pars2.mscpool.rsl_idx := 1;
6967 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(555)), '00F110'O));
6968 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6969 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006970 f_ctrs_msc_expect(2, "mscpool:subscr:known");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006971 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006972}
6973
6974/* Make sure that whichever MSC paged a subscriber will also get the Paging Response. Page by IMSI, which would be
6975 * round-robined to another MSC, to make sure the Paging->Response relation is stronger than the NRI->MSC mapping. */
6976private function f_tc_mscpool_paging_imsi(charstring id) runs on MSC_ConnHdlr {
6977 var template BSSMAP_FIELD_CellIdentificationList cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(0) } };
6978 //cid_list := { cIl_allInBSS := ''O };
6979 var RSL_ChanNeeded rsl_chneed := RSL_CHANNEED_SDCCH;
6980 var template BSSMAP_IE_ChannelNeeded bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
6981 var BSSAP_N_UNITDATA_req paging;
6982 var hexstring imsi := '001010000000123'H;
6983
6984 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
6985
Neels Hofmeyr90f80962020-06-12 16:16:55 +02006986 paging := valueof(ts_BSSAP_UNITDATA_req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006987 valueof(ts_BSSMAP_Paging(imsi, cid_list, omit, bssmap_chneed))));
6988 BSSAP.send(paging);
6989
6990 /* Register any RSL conn so that the Paging Command gets received here. With the current RSL_Emulation's main()
6991 * handling of '[bts_role] IPA_PT.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD()))' it doesn't matter at all which
6992 * channel number is picked here. */
6993 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(0, RSL_CHAN_NR_INVALID));
6994 f_rslem_register(0, new_chan_nr);
6995 RSL.receive(tr_RSL_PAGING_CMD(tr_MI_IMSI(imsi)));
6996 f_rslem_unregister(0, new_chan_nr);
6997
6998 /* Despite the round robin pointing at the second MSC ('roundrobin next 1'), the earlier Paging for the same IMSI
6999 * causes this Paging Response to go to the first MSC (bssap_idx := 0). */
7000 f_perform_compl_l3(RSL, ts_PAG_RESP(valueof(ts_MI_IMSI_LV(imsi))) );
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007001 f_sleep(1.0);
7002}
7003testcase TC_mscpool_paging_and_response_imsi() runs on test_CT {
7004 f_init(nr_bts := 1, handler_mode := true, nr_msc := 3);
7005 f_sleep(1.0);
7006
7007 /* Testing a Paging on the first MSC to get a Paging Response back to the first MSC. Set round robin to the
7008 * second MSC to make sure we're getting the Paging logic, not a coincidental round robin match. */
7009 f_vty_transceive(BSCVTY, "mscpool roundrobin next 1");
7010
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007011 f_ctrs_msc_init();
7012
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007013 var MSC_ConnHdlr vc_conn1;
7014 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
7015 pars1.mscpool.rsl_idx := 0;
Neels Hofmeyr90f80962020-06-12 16:16:55 +02007016 pars1.sccp_addr_bsc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_peer;
7017 pars1.sccp_addr_msc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_own;
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007018 vc_conn1 := f_start_handler(refers(f_tc_mscpool_paging_imsi), pars1);
7019 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007020 f_ctrs_msc_expect(0, "mscpool:subscr:paged");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007021 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007022}
7023
7024/* Make sure that whichever MSC paged a subscriber will also get the Paging Response. Page by TMSI with an NRI value
7025 * that matches a different MSC, to make sure the Paging->Response relation is stronger than the NRI->MSC mapping. */
7026private function f_tc_mscpool_paging_tmsi(charstring id) runs on MSC_ConnHdlr {
7027 var template BSSMAP_FIELD_CellIdentificationList cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(0) } };
7028 //cid_list := { cIl_allInBSS := ''O };
7029 var RSL_ChanNeeded rsl_chneed := RSL_CHANNEED_SDCCH;
7030 var template BSSMAP_IE_ChannelNeeded bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
7031 var integer nri_v := 300; /* <-- second MSC's NRI */
Harald Weltebf397612021-01-14 20:39:46 +01007032 var octetstring tmsi := f_gen_tmsi(suffix := 0, nri_v := nri_v);
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007033 var BSSAP_N_UNITDATA_req paging;
7034
7035 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
7036
Neels Hofmeyr90f80962020-06-12 16:16:55 +02007037 paging := valueof(ts_BSSAP_UNITDATA_req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007038 valueof(ts_BSSMAP_Paging('001010000000011'H, cid_list, tmsi, bssmap_chneed))));
7039 BSSAP.send(paging);
7040
7041 /* Register any RSL conn so that the Paging Command gets received here. With the current RSL_Emulation's main()
7042 * handling of '[bts_role] IPA_PT.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD()))' it doesn't matter at all which
7043 * channel number is picked here. */
7044 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(0, RSL_CHAN_NR_INVALID));
7045 f_rslem_register(0, new_chan_nr);
7046 RSL.receive(tr_RSL_PAGING_CMD(t_MI_TMSI(tmsi)));
7047 f_rslem_unregister(0, new_chan_nr);
7048
7049 /* Despite the NRI matching the second MSC (NRI from 'msc 1' in osmo-bsc.cfg) and round robin pointing at the
7050 * third MSC ('roundrobin next 2'), the earlier Paging for the same TMSI causes this Paging Response to go to
7051 * the first MSC (bssap_idx := 0). */
7052 f_perform_compl_l3(RSL, ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(nri_v))) );
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007053 f_sleep(1.0);
7054}
7055testcase TC_mscpool_paging_and_response_tmsi() runs on test_CT {
7056 f_init(nr_bts := 1, handler_mode := true, nr_msc := 3);
7057 f_sleep(1.0);
7058
7059 /* Testing a Paging on the first MSC to get a Paging Response back to the first MSC. Set round robin to the
7060 * third MSC to make sure we're getting the Paging logic, not a coincidental round robin match. */
7061 f_vty_transceive(BSCVTY, "mscpool roundrobin next 2");
7062
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007063 f_ctrs_msc_init();
7064
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007065 var MSC_ConnHdlr vc_conn1;
7066 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
7067 pars1.mscpool.rsl_idx := 0;
Neels Hofmeyr90f80962020-06-12 16:16:55 +02007068 pars1.sccp_addr_bsc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_peer;
7069 pars1.sccp_addr_msc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_own;
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007070 vc_conn1 := f_start_handler(refers(f_tc_mscpool_paging_tmsi), pars1);
7071 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007072 f_ctrs_msc_expect(0, "mscpool:subscr:paged");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007073 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007074}
7075
7076/* For round-robin, skip an MSC that has 'no allow-attach' set. */
7077/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
7078 * just as well using only RSL. */
7079testcase TC_mscpool_no_allow_attach_round_robin() runs on test_CT {
7080
7081 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
7082 f_sleep(1.0);
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00007083 /* Mark the second MSC as offloading, round-robin should skip this MSC now. */
7084 f_vty_msc_allow_attach(BSCVTY, {true, false, true});
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007085
7086 /* Control which MSC gets chosen next by the round-robin, otherwise
7087 * would be randomly affected by which other tests ran before this. */
7088 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
7089
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007090 f_ctrs_msc_init();
7091
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007092 var MSC_ConnHdlr vc_conn1;
7093 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
7094 pars1.mscpool.rsl_idx := 0;
7095 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000001'H)), '00F110'O));
7096 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
7097 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007098 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007099
7100 var MSC_ConnHdlr vc_conn2;
7101 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 2);
7102 pars2.mscpool.rsl_idx := 1;
7103 pars2.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000002'H))));
7104 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
7105 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007106 f_ctrs_msc_expect(2, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007107
7108 var MSC_ConnHdlr vc_conn3;
7109 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
7110 pars3.mscpool.rsl_idx := 2;
7111 pars3.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010000000003'H))));
7112 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
7113 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007114 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007115 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007116}
7117
7118/* An MSC that has 'no allow-attach' set should still serve subscribers that are already attached according to their
7119 * TMSI NRI. */
7120testcase TC_mscpool_no_allow_attach_valid_nri() runs on test_CT {
7121
7122 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
7123 f_sleep(1.0);
7124
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00007125 /* Mark the second MSC as offloading, round-robin should skip this MSC now. */
7126 f_vty_msc_allow_attach(BSCVTY, {true, false, true});
7127
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007128 /* Control which MSC gets chosen next by the round-robin, otherwise
7129 * would be randomly affected by which other tests ran before this. */
7130 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
7131
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007132 f_ctrs_msc_init();
7133
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007134 /* Round robin points at msc 0, but the valid NRI directs to msc 1, even though msc 1 has 'no allow-attach'. */
7135 var MSC_ConnHdlr vc_conn1;
7136 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 1);
7137 pars1.mscpool.rsl_idx := 0;
7138 /* An NRI of the second MSC's range (256-511) */
7139 pars1.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_TMSI_NRI_LV(260))));
7140 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
7141 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007142 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007143
7144 var MSC_ConnHdlr vc_conn2;
7145 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 0);
7146 pars2.mscpool.rsl_idx := 1;
7147 pars2.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000002'H))));
7148 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
7149 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007150 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007151
7152 var MSC_ConnHdlr vc_conn3;
7153 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 2);
7154 pars3.mscpool.rsl_idx := 2;
7155 pars3.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000003'H))));
7156 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
7157 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007158 f_ctrs_msc_expect(2, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007159 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007160}
7161
Philipp Maier783681c2020-07-16 16:47:06 +02007162/* Allow/Deny emergency calls globally via VTY */
7163private function f_vty_allow_emerg_msc(boolean allow) runs on test_CT {
7164 f_vty_enter_cfg_msc(BSCVTY, 0);
7165 if (allow) {
7166 f_vty_transceive(BSCVTY, "allow-emergency allow");
7167 } else {
7168 f_vty_transceive(BSCVTY, "allow-emergency deny");
7169 }
7170 f_vty_transceive(BSCVTY, "exit");
7171 f_vty_transceive(BSCVTY, "exit");
7172}
7173
7174/* Allow/Deny emergency calls per BTS via VTY */
7175private function f_vty_allow_emerg_bts(boolean allow, integer bts_nr) runs on test_CT {
7176 f_vty_enter_cfg_bts(BSCVTY, bts_nr);
7177 if (allow) {
7178 f_vty_transceive(BSCVTY, "rach emergency call allowed 1");
7179 } else {
7180 f_vty_transceive(BSCVTY, "rach emergency call allowed 0");
7181 }
7182 f_vty_transceive(BSCVTY, "exit");
7183 f_vty_transceive(BSCVTY, "exit");
Neels Hofmeyrb6ed80c2020-10-12 22:52:39 +00007184 f_vty_transceive(BSCVTY, "exit");
Philipp Maier783681c2020-07-16 16:47:06 +02007185}
7186
7187/* Begin assignmet procedure and send an EMERGENCY SETUP (RR) */
7188private function f_assignment_emerg_setup() runs on MSC_ConnHdlr {
7189 var PDU_ML3_MS_NW emerg_setup;
7190 var octetstring emerg_setup_enc;
7191 var RSL_Message emerg_setup_data_ind;
7192
7193 f_establish_fully(omit, omit);
7194
7195 emerg_setup := valueof(ts_ML3_MO_CC_EMERG_SETUP(1, valueof(ts_Bcap_voice)));
7196 emerg_setup_enc := enc_PDU_ML3_MS_NW(emerg_setup);
7197 emerg_setup_data_ind := valueof(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), emerg_setup_enc));
7198
7199 RSL.send(emerg_setup_data_ind);
7200}
7201
7202/* Test if the EMERGENCY SETUP gets passed on to the MSC via A when EMERGENCY
7203 * CALLS are permitted by the BSC config. */
7204private function f_TC_assignment_emerg_setup_allow(charstring id) runs on MSC_ConnHdlr {
7205 var PDU_BSSAP emerg_setup_data_ind_bssap;
7206 var PDU_ML3_MS_NW emerg_setup;
7207 timer T := 3.0;
7208
7209 f_assignment_emerg_setup()
7210
7211 T.start;
7212 alt {
7213 [] BSSAP.receive(tr_BSSAP_DTAP) -> value emerg_setup_data_ind_bssap {
7214 emerg_setup := dec_PDU_ML3_MS_NW(emerg_setup_data_ind_bssap.pdu.dtap);
7215 if (not isbound(emerg_setup.msgs.cc.emergencySetup)) {
7216 setverdict(fail, "no emergency setup");
7217 }
7218 }
7219 [] BSSAP.receive {
7220 setverdict(fail, "unexpected BSSAP message!");
7221 }
7222 [] T.timeout {
7223 setverdict(fail, "timout waiting for EMERGENCY SETUP!");
7224 }
7225 }
7226
7227 setverdict(pass);
7228}
7229
7230/* Test if the EMERGENCY SETUP gets blocked by the BSC if EMERGENCY CALLS are
7231 * forbidden by the BSC config. */
7232private function f_TC_assignment_emerg_setup_deny(charstring id) runs on MSC_ConnHdlr {
7233 var PDU_BSSAP emerg_setup_data_ind_bssap;
7234 timer T := 3.0;
7235
7236 f_assignment_emerg_setup()
7237
7238 T.start;
7239 alt {
7240 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
7241 setverdict(pass);
7242 }
7243 [] RSL.receive {
7244 setverdict(fail, "unexpected RSL message!");
7245 }
7246 [] T.timeout {
7247 setverdict(fail, "timout waiting for RR CHANNEL RELEASE!");
7248 }
7249 }
7250}
7251
7252/* EMERGENCY CALL situation #1, allowed globally and by BTS */
7253testcase TC_assignment_emerg_setup_allow() runs on test_CT {
7254 var TestHdlrParams pars := f_gen_test_hdlr_pars();
7255 var MSC_ConnHdlr vc_conn;
7256
7257 f_init(1, true);
7258 f_sleep(1.0);
7259
7260 f_vty_allow_emerg_msc(true);
7261 f_vty_allow_emerg_bts(true, 0);
7262 vc_conn := f_start_handler(refers(f_TC_assignment_emerg_setup_allow), pars);
7263 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007264 f_shutdown_helper();
Philipp Maier783681c2020-07-16 16:47:06 +02007265}
7266
7267/* EMERGENCY CALL situation #2, forbidden globally but allowed by BTS */
7268testcase TC_assignment_emerg_setup_deny_msc() runs on test_CT {
7269 var TestHdlrParams pars := f_gen_test_hdlr_pars();
7270 var MSC_ConnHdlr vc_conn;
7271
7272 f_init(1, true);
7273 f_sleep(1.0);
7274
7275 f_vty_allow_emerg_msc(false);
7276 f_vty_allow_emerg_bts(true, 0);
7277 vc_conn := f_start_handler(refers(f_TC_assignment_emerg_setup_deny), pars);
7278 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007279 f_shutdown_helper();
Philipp Maier783681c2020-07-16 16:47:06 +02007280}
7281
7282/* EMERGENCY CALL situation #3, allowed globally but forbidden by BTS */
7283testcase TC_assignment_emerg_setup_deny_bts() runs on test_CT {
7284 var TestHdlrParams pars := f_gen_test_hdlr_pars();
7285 var MSC_ConnHdlr vc_conn;
7286
7287 /* Note: This simulates a spec violation by the MS, correct MS
7288 * implementations would not try to establish an emergency call because
7289 * the system information tells in advance that emergency calls are
7290 * not forbidden */
7291
7292 f_init(1, true);
7293 f_sleep(1.0);
7294
7295 f_vty_allow_emerg_msc(true);
7296 f_vty_allow_emerg_bts(false, 0);
7297 vc_conn := f_start_handler(refers(f_TC_assignment_emerg_setup_deny), pars);
7298 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007299 f_shutdown_helper();
Philipp Maier783681c2020-07-16 16:47:06 +02007300}
7301
Philipp Maier82812002020-08-13 18:48:27 +02007302/* Test what happens when an emergency call arrives while all TCH channels are
7303 * busy, the BSC is expected to terminate one call in favor of the incoming
7304 * emergency call */
7305testcase TC_emerg_premption() runs on test_CT {
7306 var ASP_RSL_Unitdata rsl_ud;
7307 var integer i;
7308 var integer chreq_total, chreq_nochan;
7309 var RSL_Message rx_rsl;
7310 var RslChannelNr chan_nr;
7311
7312 f_init(1);
7313 f_sleep(1.0);
7314
7315 f_vty_allow_emerg_msc(true);
7316 f_vty_allow_emerg_bts(true, 0);
7317
7318 /* Fill up all channels on the BTS */
7319 chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total");
7320 chreq_nochan := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel");
7321 for (i := 0; i < NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS; i := i+1) {
7322 chan_nr := f_chreq_act_ack('33'O, i);
7323 }
7324 IPA_RSL[0].clear;
7325 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total",
7326 chreq_total + NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS);
7327
7328 /* Send Channel request for emegergency call */
7329 f_ipa_tx(0, ts_RSL_CHAN_RQD('A5'O, 23));
7330
7331 /* Expect the BSC to release one (the first) TCH/F on the BTS */
7332 chan_nr := valueof(t_RslChanNr_Bm(1));
7333 f_expect_chan_rel(0, chan_nr, expect_rr_chan_rel := false, expect_rll_rel_req := false);
7334
7335 /* Expect the BSC to send activate/assign the a channel for the emergency call */
7336 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7337 chan_nr := rx_rsl.ies[0].body.chan_nr;
7338 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 33));
7339 rx_rsl := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
Philipp Maier104f4c02020-09-11 18:12:18 +02007340
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007341 f_shutdown_helper();
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007342}
7343
7344/* Hopping parameters per a timeslot */
Vadim Yanitskiybc6654a2020-09-13 01:27:40 +07007345private type record length(0..64) of GsmArfcn ArfcnList;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007346private type record FHParamsTs {
7347 boolean enabled,
7348 uint6_t hsn,
7349 uint6_t maio,
7350 ArfcnList ma
7351};
7352
7353/* Hopping parameters per a transceiver */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007354private type record FHParamsTrx {
7355 GsmArfcn arfcn,
7356 FHParamsTs ts[8]
7357};
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007358
7359/* Randomly generate the hopping parameters for the given timeslot numbers */
7360private function f_TC_fh_params_gen(template integer tr_tn := (1, 3, 5))
7361runs on test_CT return FHParamsTrx {
7362 var FHParamsTrx fhp;
7363
Vadim Yanitskiy3e997362020-09-05 21:08:34 +07007364 /* Generate a random ARFCN, including ARFCN 0 */
7365 fhp.arfcn := f_rnd_int(3);
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007366
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007367 for (var integer tn := 0; tn < 8; tn := tn + 1) {
7368 if (not match(tn, tr_tn)) {
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007369 fhp.ts[tn].enabled := false;
7370 fhp.ts[tn].ma := { };
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007371 continue;
7372 }
7373
7374 /* Random HSN / MAIO values: 0..63 */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007375 fhp.ts[tn].hsn := f_rnd_int(64);
7376 fhp.ts[tn].maio := f_rnd_int(64);
7377 fhp.ts[tn].ma := { };
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007378
7379 /* Random Mobile Allocation (hopping channels) */
7380 var integer ma_len := 2 + f_rnd_int(9); /* 2..10 channels */
7381 var integer step := 3 + f_rnd_int(4); /* 3..6 stepping */
7382 for (var integer i := 1; i <= ma_len; i := i + 1) {
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007383 fhp.ts[tn].ma := fhp.ts[tn].ma & { i * step };
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007384 }
7385
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007386 fhp.ts[tn].enabled := true;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007387 }
7388
7389 log("f_TC_fh_params_gen(): ", fhp);
7390 return fhp;
7391}
7392
7393/* Make sure that the given Channel Description IE matches the hopping configuration */
7394private function f_TC_fh_params_match_chan_desc(in FHParamsTrx fhp, in ChannelDescription cd)
7395{
7396 var template (present) ChannelDescription tr_cd;
7397 var template (present) MaioHsn tr_maio_hsn;
7398 var uint3_t tn := cd.chan_nr.tn;
7399
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007400 if (fhp.ts[tn].enabled) {
7401 tr_maio_hsn := tr_HsnMaio(fhp.ts[tn].hsn, fhp.ts[tn].maio);
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007402 tr_cd := tr_ChanDescH1(cd.chan_nr, tr_maio_hsn);
7403 } else {
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007404 tr_cd := tr_ChanDescH0(cd.chan_nr, fhp.arfcn);
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007405 }
7406
7407 if (not match(cd, tr_cd)) {
7408 setverdict(fail, "Channel Description IE does not match: ",
7409 cd, " vs expected ", tr_cd);
7410 }
7411}
7412
7413/* Make sure that the given Mobile Allocation IE matches the hopping configuration */
7414private function f_TC_fh_params_match_ma(in FHParamsTrx fhp, uint3_t tn,
7415 in MobileAllocationLV ma)
7416{
7417 var template MobileAllocationLV tr_ma := f_TC_fh_params_gen_tr_ma(fhp, tn, ma);
7418
7419 if (not match(ma, tr_ma)) {
7420 setverdict(fail, "Mobile Allocation IE does not match (tn := ",
7421 tn, "): ", ma, " vs expected: ", tr_ma);
7422 } else {
7423 setverdict(pass);
7424 }
7425}
7426
7427private function f_TC_fh_params_gen_tr_ma(in FHParamsTrx fhp, uint3_t tn,
7428 in MobileAllocationLV ma)
7429return template MobileAllocationLV {
7430 /* Mobile Allocation IE is expected to be empty if hopping is not enabled */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007431 if (not fhp.ts[tn].enabled) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007432 return { len := 0, ma := ''B };
7433 }
7434
7435 var bitstring full_mask := f_pad_bit(''B, 1024, '0'B);
7436 var bitstring slot_mask := f_pad_bit(''B, 1024, '0'B);
7437 var bitstring ma_mask := ''B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007438
7439 /* Compose the full bit-mask (all channels, up to 1024 entries) */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007440 for (var integer i := 0; i < lengthof(fhp.ts); i := i + 1) {
7441 for (var integer j := 0; j < lengthof(fhp.ts[i].ma); j := j + 1) {
7442 if (full_mask[fhp.ts[i].ma[j]] == '1'B)
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007443 { continue; }
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007444 full_mask[fhp.ts[i].ma[j]] := '1'B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007445 }
7446 }
7447
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007448 /* Take ARFCN of the TRX itself into account */
7449 full_mask[fhp.arfcn] := '1'B;
7450
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007451 /* Compose a bit-mask for the given timeslot number */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007452 for (var integer i := 0; i < lengthof(fhp.ts[tn].ma); i := i + 1) {
7453 slot_mask[fhp.ts[tn].ma[i]] := '1'B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007454 }
7455
7456 /* Finally, compose the Mobile Allocation bit-mask */
Vadim Yanitskiy3e997362020-09-05 21:08:34 +07007457 for (var integer i := 1; i < lengthof(full_mask); i := i + 1) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007458 if (full_mask[i] != '1'B)
7459 { continue; }
7460
7461 /* FIXME: ma_mask := ma_mask & slot_mask[i]; // triggers a bug in TITAN */
7462 if (slot_mask[i] == '1'B) {
7463 ma_mask := ma_mask & '1'B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007464 } else {
7465 ma_mask := ma_mask & '0'B;
7466 }
7467 }
7468
Vadim Yanitskiy3e997362020-09-05 21:08:34 +07007469 /* ARFCN 0 (if present) goes to the last position of the bit-mask */
7470 if (full_mask[0] == '1'B) {
7471 /* FIXME: ma_mask := ma_mask & slot_mask[0]; // triggers a bug in TITAN */
7472 if (slot_mask[0] == '1'B) {
7473 ma_mask := ma_mask & '1'B;
7474 } else {
7475 ma_mask := ma_mask & '0'B;
7476 }
7477 }
7478
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007479 /* Ensure that ma_mask is octet-aligned */
Vadim Yanitskiy2aa02522020-09-06 14:05:23 +07007480 var integer ma_mask_len := (lengthof(ma_mask) + 8 - 1) / 8;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007481 ma_mask := f_pad_bit(ma_mask, ma_mask_len * 8, '0'B);
7482
7483 return { len := ma_mask_len, ma := ma_mask };
7484}
7485
7486/* Configure the hopping parameters in accordance with the given record */
7487private function f_TC_fh_params_set(in FHParamsTrx fhp,
7488 uint8_t bts_nr := 0,
7489 uint8_t trx_nr := 0)
7490runs on test_CT {
7491 /* Enter the configuration node for the given BTS/TRX numbers */
7492 f_vty_enter_cfg_trx(BSCVTY, bts_nr, trx_nr);
7493
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007494 f_vty_transceive(BSCVTY, "arfcn " & int2str(fhp.arfcn));
7495
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007496 for (var integer tn := 0; tn < lengthof(fhp.ts); tn := tn + 1) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007497 f_vty_transceive(BSCVTY, "timeslot " & int2str(tn));
7498
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007499 if (not fhp.ts[tn].enabled) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007500 f_vty_transceive(BSCVTY, "hopping enabled 0");
7501 f_vty_transceive(BSCVTY, "exit"); /* go back */
7502 continue;
7503 }
7504
7505 /* Configure HSN / MAIO values */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007506 f_vty_transceive(BSCVTY, "hopping sequence-number " & int2str(fhp.ts[tn].hsn));
7507 f_vty_transceive(BSCVTY, "hopping maio " & int2str(fhp.ts[tn].maio));
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007508
7509 /* Configure the Mobile Allocation (hopping channels) */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007510 for (var integer i := 0; i < lengthof(fhp.ts[tn].ma); i := i + 1) {
7511 f_vty_transceive(BSCVTY, "hopping arfcn add " & int2str(fhp.ts[tn].ma[i]));
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007512 }
7513
7514 f_vty_transceive(BSCVTY, "hopping enabled 1");
7515 f_vty_transceive(BSCVTY, "exit"); /* go back */
7516 }
7517
7518 f_vty_transceive(BSCVTY, "end");
7519}
7520
7521/* Disable frequency hopping on all timeslots */
7522private function f_TC_fh_params_unset(in FHParamsTrx fhp,
7523 uint8_t bts_nr := 0,
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007524 uint8_t trx_nr := 0,
7525 GsmArfcn arfcn := 871)
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007526runs on test_CT {
7527 /* Enter the configuration node for the given BTS/TRX numbers */
7528 f_vty_enter_cfg_trx(BSCVTY, bts_nr, trx_nr);
7529
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007530 f_vty_transceive(BSCVTY, "arfcn " & int2str(arfcn));
7531
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007532 for (var integer tn := 0; tn < lengthof(fhp.ts); tn := tn + 1) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007533 f_vty_transceive(BSCVTY, "timeslot " & int2str(tn));
7534
7535 /* Delete all ARFCNs from the Mobile Allocation (if any) */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007536 for (var integer i := 0; i < lengthof(fhp.ts[tn].ma); i := i + 1) {
7537 f_vty_transceive(BSCVTY, "hopping arfcn del " & int2str(fhp.ts[tn].ma[i]));
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007538 }
7539
7540 f_vty_transceive(BSCVTY, "hopping enabled 0");
7541 f_vty_transceive(BSCVTY, "exit"); /* go back */
7542 }
7543
7544 f_vty_transceive(BSCVTY, "end");
7545 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7546}
7547
7548/* Verify presence and correctness of the hopping parameters (HSN, MAIO)
7549 * in the Channel Identification IE of the RSL CHANnel ACTIVation message. */
7550testcase TC_fh_params_chan_activ() runs on test_CT {
7551 var FHParamsTrx fhp := f_TC_fh_params_gen();
7552 var RSL_Message rsl_msg;
7553 var RSL_IE_Body ie;
7554
7555 f_init_vty();
7556
7557 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
7558 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7559
7560 f_init(1);
7561
7562 /* CS domain: 3 (SDCCH/4+CBCH) + 4 (TCH/F) + 2 (TCH/H) channels available */
7563 for (var integer i := 0; i < 9; i := i + 1) {
7564 f_ipa_tx(0, ts_RSL_CHAN_RQD(f_rnd_ra_cs(), 23));
7565 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7566
7567 /* Make sure that Channel Identification IE is present */
7568 if (not f_rsl_find_ie(rsl_msg, RSL_IE_CHAN_IDENT, ie)) {
7569 setverdict(fail, "RSL Channel Identification IE is absent");
7570 continue;
7571 }
7572
7573 /* Make sure that hopping parameters (HSN/MAIO) match */
7574 f_TC_fh_params_match_chan_desc(fhp, ie.chan_ident.ch_desc.v);
7575
7576 /* "Mobile Allocation shall be included but empty" - let's check this */
7577 if (ie.chan_ident.ma.v.len != 0) {
7578 setverdict(fail, "Mobile Allocation IE is not empty: ",
7579 ie.chan_ident.ma, ", despite it shall be");
7580 continue;
7581 }
7582 }
7583
7584 /* Disable frequency hopping */
7585 f_TC_fh_params_unset(fhp);
7586
Vadim Yanitskiy21726312020-09-04 01:45:36 +07007587 f_shutdown_helper();
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007588}
7589
7590/* Verify the hopping parameters (HSN, MAIO, MA) in (RR) Immediate Assignment */
7591testcase TC_fh_params_imm_ass() runs on test_CT {
7592 var FHParamsTrx fhp := f_TC_fh_params_gen();
7593 var RSL_Message rsl_msg;
7594 var RSL_IE_Body ie;
7595
7596 f_init_vty();
7597
7598 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
7599 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7600
7601 f_init(1);
7602
7603 /* CS domain: 3 (SDCCH/4+CBCH) + 4 (TCH/F) + 2 (TCH/H) channels available */
7604 for (var integer i := 0; i < 9; i := i + 1) {
7605 f_ipa_tx(0, ts_RSL_CHAN_RQD(f_rnd_ra_cs(), 23));
7606 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7607
7608 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(rsl_msg.ies[0].body.chan_nr, 33));
7609 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeC(RSL_MT_IMMEDIATE_ASSIGN_CMD));
7610
7611 /* Make sure that Full Immediate Assign Info IE is present */
7612 if (not f_rsl_find_ie(rsl_msg, RSL_IE_FULL_IMM_ASS_INFO, ie)) {
7613 setverdict(fail, "RSL Full Immediate Assign Info IE is absent");
7614 continue;
7615 }
7616
7617 /* Decode the actual Immediate Assignment message */
7618 var GsmRrMessage rr_msg := dec_GsmRrMessage(ie.full_imm_ass_info.payload);
7619 if (not match(rr_msg.header, t_RrHeader(IMMEDIATE_ASSIGNMENT, ?))) {
7620 setverdict(fail, "Failed to match Immediate Assignment: ", rr_msg);
7621 continue;
7622 }
7623
7624 /* Make sure that hopping parameters (HSN/MAIO) match */
7625 f_TC_fh_params_match_chan_desc(fhp, rr_msg.payload.imm_ass.chan_desc);
7626
7627 /* Make sure that the Mobile Allocation IE matches */
7628 f_TC_fh_params_match_ma(fhp, rr_msg.payload.imm_ass.chan_desc.chan_nr.tn,
7629 rr_msg.payload.imm_ass.mobile_allocation);
7630 }
7631
7632 /* Disable frequency hopping */
7633 f_TC_fh_params_unset(fhp);
Philipp Maier82812002020-08-13 18:48:27 +02007634
Vadim Yanitskiy21726312020-09-04 01:45:36 +07007635 f_shutdown_helper();
Philipp Maier82812002020-08-13 18:48:27 +02007636}
7637
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07007638/* Verify the hopping parameters (HSN, MAIO, MA) in (RR) Assignment Command */
7639testcase TC_fh_params_assignment_cmd() runs on test_CT {
7640 var FHParamsTrx fhp := f_TC_fh_params_gen();
7641 var RSL_Message rsl_msg;
7642 var RSL_IE_Body ie;
7643
7644 f_init_vty();
7645
7646 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
7647 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7648
7649 f_init(1);
7650
7651 /* HACK: work around "Couldn't find Expect for CRCX" */
7652 vc_MGCP.stop;
7653
7654 var template PDU_BSSAP ass_cmd := f_gen_ass_req();
7655 ass_cmd.pdu.bssmap.assignmentRequest.codecList := ts_BSSMAP_IE_CodecList({ts_CodecFR});
7656
7657 /* CS domain (TCH): 4 (TCH/F) + 2 (TCH/H) channels available
7658 * NOTE: only 3 SDCCH/4 channels are available on CCCH+SDCCH4+CBCH */
7659 for (var integer i := 0; i < 3; i := i + 1) {
7660 /* Establish a dedicated channel, so we can trigger (late) TCH assignment */
7661 var DchanTuple dt := f_est_dchan(f_rnd_ra_cs(), 23, f_rnd_octstring(16));
7662
7663 /* Send a BSSMAP Assignment Command, expect CHANnel ACTIVation */
7664 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ass_cmd));
7665 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7666
7667 /* ACKnowledge CHANnel ACTIVation, expect RSL DATA REQuest */
7668 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(rsl_msg.ies[0].body.chan_nr, 33));
7669 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeR(RSL_MT_DATA_REQ));
7670
7671 /* Make sure that L3 Information IE is present */
7672 if (not f_rsl_find_ie(rsl_msg, RSL_IE_L3_INFO, ie)) {
7673 setverdict(fail, "RSL L3 Information IE is absent");
7674 continue;
7675 }
7676
7677 /* Decode the L3 message and make sure it is (RR) Assignment Command */
7678 var GsmRrL3Message l3_msg := dec_GsmRrL3Message(ie.l3_info.payload);
7679 if (not match(l3_msg.header, t_RrL3Header(ASSIGNMENT_COMMAND))) {
7680 setverdict(fail, "Failed to match Assignment Command: ", l3_msg);
7681 continue;
7682 }
7683
7684 /* Make sure that hopping parameters (HSN/MAIO) match */
7685 var ChannelDescription chan_desc := l3_msg.payload.ass_cmd.chan_desc;
7686 f_TC_fh_params_match_chan_desc(fhp, chan_desc);
7687
7688 /* Make sure that Cell Channel Description IE is present if FH is enabled */
7689 if (chan_desc.h and not ispresent(l3_msg.payload.ass_cmd.cell_chan_desc)) {
Vadim Yanitskiy38d069d2020-09-02 17:18:57 +07007690 setverdict(fail, "FH enabled, but Cell Channel Description IE is absent");
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07007691 continue;
7692 }
7693
7694 /* Make sure that the Mobile Allocation IE matches (if present) */
7695 var boolean ma_present := ispresent(l3_msg.payload.ass_cmd.mobile_allocation);
7696 if (chan_desc.h and ma_present) {
7697 f_TC_fh_params_match_ma(fhp, chan_desc.chan_nr.tn,
7698 l3_msg.payload.ass_cmd.mobile_allocation.v);
7699 } else if (chan_desc.h and not ma_present) {
7700 setverdict(fail, "FH enabled, but Mobile Allocation IE is absent");
7701 continue;
7702 } else if (not chan_desc.h and ma_present) {
7703 setverdict(fail, "FH disabled, but Mobile Allocation IE is present");
7704 continue;
7705 }
7706 }
7707
7708 /* Give the IUT some time to release all channels */
7709 f_sleep(3.0);
7710
7711 /* Disable frequency hopping */
7712 f_TC_fh_params_unset(fhp);
7713
Vadim Yanitskiy21726312020-09-04 01:45:36 +07007714 f_shutdown_helper();
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07007715}
7716
Vadim Yanitskiy8f5430d2020-09-02 18:51:38 +07007717/* Verify the hopping parameters (HSN, MAIO, MA) in (RR) Handover Command */
7718private function f_TC_fh_params_handover_cmd(in FHParamsTrx fhp)
7719runs on test_CT {
7720 var RSL_Message rsl_msg;
7721 var RSL_IE_Body ie;
7722 var DchanTuple dt;
7723
7724 /* Establish a dedicated channel, so we can trigger handover */
7725 dt := f_est_dchan(f_rnd_ra_cs(), 23, f_rnd_octstring(16));
7726
7727 /* Trigger handover from BTS0 to BTS1 */
7728 f_bts_0_cfg(BSCVTY, { "neighbor bts 1" });
7729 f_vty_handover(BSCVTY, 0, 0, dt.rsl_chan_nr, 1);
7730
7731 /* Expect RSL CHANnel ACTIVation on BTS1/TRX0/TS1 */
7732 rsl_msg := f_exp_ipa_rx(1, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7733
7734 /* ACKnowledge channel activation and expect (RR) Handover Command */
7735 f_ipa_tx(1, ts_RSL_CHAN_ACT_ACK(rsl_msg.ies[0].body.chan_nr, 33));
7736 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeR(RSL_MT_DATA_REQ));
7737
7738 /* Make sure that L3 Information IE is present */
7739 if (not f_rsl_find_ie(rsl_msg, RSL_IE_L3_INFO, ie)) {
7740 setverdict(fail, "RSL L3 Information IE is absent");
7741 return;
7742 }
7743
7744 /* Decode the L3 message and make sure it is (RR) Handover Command */
7745 var GsmRrL3Message l3_msg := dec_GsmRrL3Message(ie.l3_info.payload);
7746 if (not match(l3_msg.header, t_RrL3Header(HANDOVER_COMMAND))) {
7747 setverdict(fail, "Failed to match Handover Command: ", l3_msg);
7748 return;
7749 }
7750
7751 /* Make sure that we've got SDCCH/8 on TS1 (expected to be hopping) */
7752 var ChannelDescription chan_desc := l3_msg.payload.ho_cmd.chan_desc;
7753 if (not match(chan_desc.chan_nr, t_RslChanNr_SDCCH8(1, ?))) {
7754 setverdict(fail, "Unexpected channel number: ", chan_desc.chan_nr);
7755 return;
7756 }
7757
7758 /* Make sure that hopping parameters (HSN/MAIO) match */
7759 f_TC_fh_params_match_chan_desc(fhp, chan_desc);
7760
7761 /* Make sure that Cell Channel Description IE is present */
7762 if (not ispresent(l3_msg.payload.ho_cmd.cell_chan_desc)) {
7763 setverdict(fail, "FH enabled, but Cell Channel Description IE is absent");
7764 return;
7765 }
7766
7767 /* Make sure that the Mobile Allocation (after time) IE is present and matches */
7768 var boolean ma_present := ispresent(l3_msg.payload.ho_cmd.mobile_allocation);
7769 if (ma_present) {
7770 f_TC_fh_params_match_ma(fhp, chan_desc.chan_nr.tn,
7771 l3_msg.payload.ho_cmd.mobile_allocation.v);
7772 } else {
7773 setverdict(fail, "FH enabled, but Mobile Allocation IE is absent");
7774 return;
7775 }
7776}
7777testcase TC_fh_params_handover_cmd() runs on test_CT {
7778 var FHParamsTrx fhp := f_TC_fh_params_gen();
7779
7780 f_init_vty();
7781
7782 /* (Re)configure TS0 as BCCH and TS1 as SDCCH8 on BTS1/TRX0 */
7783 f_vty_enter_cfg_trx(BSCVTY, bts := 1, trx := 0);
7784
7785 f_vty_transceive(BSCVTY, "timeslot 0");
7786 f_vty_transceive(BSCVTY, "phys_chan_config ccch");
7787 f_vty_transceive(BSCVTY, "exit"); /* go back */
7788
7789 f_vty_transceive(BSCVTY, "timeslot 1");
7790 f_vty_transceive(BSCVTY, "phys_chan_config sdcch8");
7791 f_vty_transceive(BSCVTY, "end"); /* we're done */
7792
7793 f_TC_fh_params_set(fhp, 1); /* Enable frequency hopping on BTS1 */
7794 f_vty_transceive(BSCVTY, "drop bts connection 1 oml");
7795
7796 f_init(2);
7797
7798 f_TC_fh_params_handover_cmd(fhp);
7799
7800 /* Disable frequency hopping on BTS1 */
7801 f_TC_fh_params_unset(fhp, 1);
7802
7803 /* (Re)configure TS0 as CCCH+SDCCH4+CBCH and TS1 as TCH/F */
7804 f_vty_enter_cfg_trx(BSCVTY, bts := 1, trx := 0);
7805
7806 f_vty_transceive(BSCVTY, "timeslot 0");
7807 f_vty_transceive(BSCVTY, "phys_chan_config ccch+sdcch4+cbch");
7808 f_vty_transceive(BSCVTY, "exit"); /* go back */
7809
7810 f_vty_transceive(BSCVTY, "timeslot 1");
7811 f_vty_transceive(BSCVTY, "phys_chan_config tch/f");
7812 f_vty_transceive(BSCVTY, "end"); /* we're done */
7813
7814 f_shutdown_helper();
7815}
7816
Vadim Yanitskiyca974032020-09-01 07:20:39 +07007817/* Verify the hopping parameters in System Information Type 4 */
7818testcase TC_fh_params_si4_cbch() runs on test_CT {
7819 var FHParamsTrx fhp := f_TC_fh_params_gen(tr_tn := 1);
7820 var ASP_RSL_Unitdata rx_rsl_ud;
7821 timer T := 5.0;
7822
7823 f_init_vty();
7824
7825 /* (Re)configure TS0 as BCCH and TS1 as SDCCH8+CBCH */
7826 f_vty_enter_cfg_trx(BSCVTY, trx := 0);
7827
7828 f_vty_transceive(BSCVTY, "timeslot 0");
7829 f_vty_transceive(BSCVTY, "phys_chan_config ccch");
7830 f_vty_transceive(BSCVTY, "exit"); /* go back */
7831
7832 f_vty_transceive(BSCVTY, "timeslot 1");
7833 f_vty_transceive(BSCVTY, "phys_chan_config sdcch8+cbch");
7834 f_vty_transceive(BSCVTY, "end"); /* we're done */
7835
7836 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
7837 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7838
7839 f_init(1);
7840
7841 T.start;
7842 alt {
7843 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_BCCH_INFO(RSL_SYSTEM_INFO_4))) -> value rx_rsl_ud {
7844 var RSL_IE_Body ie := rx_rsl_ud.rsl.ies[2].body; /* FULL BCCH Information IE */
7845 var SystemInformation si := dec_SystemInformation(ie.other.payload);
7846
7847 /* Make sure that what we decoded is System Information Type 4 */
7848 if (si.header.message_type != SYSTEM_INFORMATION_TYPE_4) {
7849 setverdict(fail, "RSL FULL BCCH Information IE contains: ", si);
7850 repeat;
7851 }
7852
7853 /* Make sure that CBCH Channel Description IE is present */
7854 if (not ispresent(si.payload.si4.cbch_chan_desc)) {
7855 setverdict(fail, "CBCH Channel Description IE is absent");
7856 break;
7857 }
7858
7859 /* Finally, check the hopping parameters (HSN, MAIO) */
7860 var ChannelDescription chan_desc := si.payload.si4.cbch_chan_desc.v;
7861 f_TC_fh_params_match_chan_desc(fhp, chan_desc);
7862
7863 /* 3GPP TS 44.018, section 9.1.36.2 "CBCH Mobile Allocation":
7864 * The CBCH Mobile Allocation IE *shall* be present if FH is enabled. */
7865 if (chan_desc.h and not ispresent(si.payload.si4.cbch_mobile_alloc)) {
7866 setverdict(fail, "FH enabled, but Mobile Allocation IE is absent");
7867 break;
7868 } else if (chan_desc.h and ispresent(si.payload.si4.cbch_mobile_alloc)) {
7869 f_TC_fh_params_match_ma(fhp, chan_desc.chan_nr.tn,
7870 si.payload.si4.cbch_mobile_alloc.v);
7871 }
7872 }
7873 [] IPA_RSL[0].receive { repeat; }
7874 [] T.timeout {
7875 setverdict(fail, "Timeout waiting for RSL BCCH INFOrmation (SI4)");
7876 }
7877 }
7878
7879 /* Disable frequency hopping */
7880 f_TC_fh_params_unset(fhp);
7881
Vadim Yanitskiy8bc46012020-09-06 12:38:01 +07007882 /* (Re)configure TS0 as CCCH+SDCCH4+CBCH and TS1 as TCH/F */
Vadim Yanitskiyca974032020-09-01 07:20:39 +07007883 f_vty_enter_cfg_trx(BSCVTY, trx := 0);
7884
7885 f_vty_transceive(BSCVTY, "timeslot 0");
Vadim Yanitskiy8bc46012020-09-06 12:38:01 +07007886 f_vty_transceive(BSCVTY, "phys_chan_config ccch+sdcch4+cbch");
Vadim Yanitskiyca974032020-09-01 07:20:39 +07007887 f_vty_transceive(BSCVTY, "exit"); /* go back */
7888
7889 f_vty_transceive(BSCVTY, "timeslot 1");
7890 f_vty_transceive(BSCVTY, "phys_chan_config tch/f");
7891 f_vty_transceive(BSCVTY, "end"); /* we're done */
7892
Vadim Yanitskiy21726312020-09-04 01:45:36 +07007893 f_shutdown_helper();
Vadim Yanitskiyca974032020-09-01 07:20:39 +07007894}
7895
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02007896template (value) PDU_BSSAP_LE ts_BSSMAP_LE_BSSLAP(template (value) BSSLAP_PDU bsslap)
7897 := ts_BSSMAP_LE_ConnInfo(BSSMAP_LE_PROT_BSSLAP, data := enc_BSSLAP_PDU(valueof(bsslap)));
7898
7899private function f_match_bsslap(PDU_BSSAP_LE got_bsslap_msg,
7900 template (present) BSSLAP_PDU expect_bsslap)
7901{
7902 var BSSLAP_PDU bsslap := dec_BSSLAP_PDU(got_bsslap_msg.pdu.bssmap.co_info.bsslap_apdu.data);
7903 if (not match(bsslap, expect_bsslap)) {
7904 log("EXPECTING BSSLAP: ", expect_bsslap);
7905 log("GOT BSSLAP: ", bsslap);
7906 setverdict(fail, "BSSLAP is not as expected");
7907 mtc.stop;
7908 }
7909 setverdict(pass);
7910}
7911
7912/* GAD: this is an Ellipsoid point with uncertainty circle, encoded as in 3GPP TS 23.032 §7.3.2. */
7913const octetstring gad_ell_point_unc_circle := '10b0646d0d5f6627'O;
7914
7915private function f_expect_bsslap(template (present) BSSLAP_PDU expect_rx_bsslap) runs on MSC_ConnHdlr {
7916 var PDU_BSSAP_LE rx_bsslap;
7917 BSSAP_LE.receive(tr_BSSMAP_LE_ConnInfo(BSSMAP_LE_PROT_BSSLAP, ?)) -> value(rx_bsslap);
7918 f_match_bsslap(rx_bsslap, expect_rx_bsslap);
7919}
7920
7921/* With an active lchan, start BSSMAP Perform Location Request on A interface, starting BSSMAP-LE Perform Location
7922 * Request on Lb interface. Either with or without the SMLC doing a BSSLAP TA Request. */
7923private function f_lcs_loc_req_for_active_ms(boolean do_ta_request := false) runs on MSC_ConnHdlr {
7924 f_sleep(1.0);
7925
7926 f_establish_fully(omit, omit);
7927 f_bssap_le_register_imsi(g_pars.imsi, omit);
7928
7929 BSSAP.send(valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
7930 ts_CellId_CGI('262'H, '42'H, 23, 42))));
7931
7932 var PDU_BSSAP_LE plr;
7933 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
7934
7935 if (not do_ta_request) {
7936 /* verify TA Layer 3 in APDU. First the APDU type (BSSLAP), then the BSSLAP data contents. */
7937 var template BSSMAP_LE_IE_APDU expect_apdu := tr_BSSMAP_LE_APDU(BSSMAP_LE_PROT_BSSLAP, ?);
7938 if (not match(plr.pdu.bssmap.perf_loc_req.bsslap_apdu, expect_apdu)) {
7939 log("EXPECTING BSSMAP-LE APDU IE ", expect_apdu);
7940 log("GOT BSSMAP-LE APDU IE ", plr.pdu.bssmap.perf_loc_req.bsslap_apdu);
7941 setverdict(fail, "BSSMAP-LE APDU IE is not as expected");
7942 mtc.stop;
7943 }
7944 var template BSSLAP_PDU expect_ta_layer3 := tr_BSSLAP_TA_Layer3(tr_BSSLAP_IE_TA(0));
7945 var BSSLAP_PDU bsslap := dec_BSSLAP_PDU(plr.pdu.bssmap.perf_loc_req.bsslap_apdu.data);
7946 if (not match(bsslap, expect_ta_layer3)) {
7947 log("EXPECTING BSSLAP TA Layer 3: ", expect_ta_layer3);
7948 log("GOT BSSLAP: ", bsslap);
7949 setverdict(fail, "BSSLAP is not as expected");
7950 mtc.stop;
7951 }
7952 /* OsmoBSC directly sent the TA as BSSLAP APDU in the BSSMAP-LE Perform Location Request to the SMLC. The SMLC
7953 * has no need to request the TA from the BSC and directly responds. */
7954 } else {
7955 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
7956 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
7957 f_expect_bsslap(tr_BSSLAP_TA_Resp(?, ?));
7958 }
7959
7960 /* SMLC got the TA from the BSC, now responds with geo information data. */
7961 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(gad_ell_point_unc_circle, omit));
7962 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
7963 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(tr_BSSMAP_IE_LocationEstimate(gad_ell_point_unc_circle)));
7964
7965 /* The LCS was using an active A-interface conn. It should still remain active after this. */
7966 f_mo_l3_transceive();
7967
7968 f_perform_clear(RSL);
7969
7970 f_sleep(2.0);
7971 setverdict(pass);
7972}
7973
7974/* With an active lchan, start BSSMAP Perform Location Request on A interface, starting BSSMAP-LE Perform Location
7975 * Request on Lb interface. Without the SMLC doing a BSSLAP TA Request. */
7976private function f_tc_lcs_loc_req_for_active_ms(charstring id) runs on MSC_ConnHdlr {
7977 f_lcs_loc_req_for_active_ms(false);
7978}
7979testcase TC_lcs_loc_req_for_active_ms() runs on test_CT {
7980 var MSC_ConnHdlr vc_conn;
7981 var TestHdlrParams pars := f_gen_test_hdlr_pars();
7982
7983 f_init(1, true);
7984 f_sleep(1.0);
7985 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_active_ms), pars);
7986 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01007987 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02007988}
7989
7990/* With an active lchan, start BSSMAP Perform Location Request on A interface, starting BSSMAP-LE Perform Location
7991 * Request on Lb interface. With the SMLC doing a BSSLAP TA Request. */
7992private function f_tc_lcs_loc_req_for_active_ms_ta_req(charstring id) runs on MSC_ConnHdlr {
7993 f_lcs_loc_req_for_active_ms(true);
7994}
7995testcase TC_lcs_loc_req_for_active_ms_ta_req() runs on test_CT {
7996 var MSC_ConnHdlr vc_conn;
7997 var TestHdlrParams pars := f_gen_test_hdlr_pars();
7998
7999 f_init(1, true);
8000 f_sleep(1.0);
8001 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_active_ms_ta_req), pars);
8002 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008003 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008004}
8005
8006/* Clear the A-interface conn only, without doing anything on Abis. Useful for LCS, for cases where there is only an A
8007 * conn without an active lchan. */
8008private function f_clear_A_conn() runs on MSC_ConnHdlr
8009{
8010 var BssmapCause cause := 0;
8011 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
8012 BSSAP.receive(tr_BSSMAP_ClearComplete);
8013 BSSAP.send(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_REQ);
8014
8015 timer no_more_bssap := 5.0;
8016 no_more_bssap.start;
8017 alt {
8018 [] no_more_bssap.timeout { break; }
8019 [] BSSAP.receive(tr_BSSAP_BSSMAP) {
8020 setverdict(fail, "Expected no more BSSAP after Clear Complete");
8021 mtc.stop;
8022 }
8023 }
8024 setverdict(pass);
8025}
8026
8027/* Verify that the A-interface connection is still working, and then clear it, without doing anything on Abis. Useful
8028 * for LCS, for cases where there is only an A conn without an active lchan. */
8029private function f_verify_active_A_conn_and_clear() runs on MSC_ConnHdlr
8030{
8031 f_logp(BSCVTY, "f_verify_active_A_conn_and_clear: test A link, then clear");
8032
8033 /* When an lchan is active, we can send some L3 data from the BTS side and verify that it shows up on the other
8034 * side towards the MSC. When there is no lchan, this is not possible. To probe whether the A-interface
8035 * connection is still up, we need something that echos back on the A-interface. Another LCS request! */
8036 BSSAP.send(valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
8037 ts_CellId_CGI('262'H, '42'H, 23, 42))));
8038 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?));
8039
8040 /* Right, the Perform Location Request showed up on Lb, now we can clear the A conn. */
8041 f_clear_A_conn();
8042 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocAbort(BSSMAP_LE_LCS_CAUSE_REQUEST_ABORTED));
8043 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
8044}
8045
8046/* With *no* active lchan, start BSSMAP Perform Location Request on A interface, starting BSSMAP-LE Perform Location
8047 * Request on Lb interface. BSC will Page for the subscriber as soon as we (virtual SMLC) request the TA via BSSLAP.
8048 */
8049private function f_tc_lcs_loc_req_for_idle_ms(charstring id) runs on MSC_ConnHdlr {
8050 f_sleep(1.0);
8051
8052 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
8053 f_bssap_le_register_imsi(g_pars.imsi, omit);
8054
8055 /* Register to receive the Paging Command */
8056 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
8057 g_chan_nr := new_chan_nr;
8058 f_rslem_register(0, g_chan_nr);
8059
8060 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
8061 valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
8062 ts_CellId_CGI('001'H, '01'H, 1, 0)))));
8063 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
8064
8065 var PDU_BSSAP_LE plr;
8066 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
8067
8068 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
8069 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
8070
8071 /* OsmoBSC needs to Page */
8072 RSL.receive(tr_RSL_PAGING_CMD(tr_MI_IMSI(g_pars.imsi)));
8073 f_logp(BSCVTY, "got Paging Command");
8074
8075 /* MS requests channel. Since the Paging was for LCS, the Paging Response does not trigger a Complete Layer 3 to
8076 * the MSC, and releases the lchan directly. */
8077 f_perform_compl_l3(RSL, ts_PAG_RESP(valueof(ts_MI_IMSI_LV(g_pars.imsi))), do_clear := false, expect_bssmap_l3 := false);
8078 f_expect_lchan_rel(RSL);
8079
8080 /* From the Paging Response, the TA is now known to the BSC, and it responds to the SMLC. */
8081
8082 f_expect_bsslap(tr_BSSLAP_TA_Resp(?, ?));
8083
8084 /* SMLC got the TA from the BSC, now responds with geo information data. */
8085 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(gad_ell_point_unc_circle, omit));
8086 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
8087
8088 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(tr_BSSMAP_IE_LocationEstimate(gad_ell_point_unc_circle)));
8089
8090 /* The lchan is gone, the A-interface conn was created for the LCS only.
8091 * Still it is clearly the MSC's job to decide whether to tear down the conn or not. */
8092 f_verify_active_A_conn_and_clear();
8093
8094 f_sleep(2.0);
8095 setverdict(pass);
8096}
8097testcase TC_lcs_loc_req_for_idle_ms() runs on test_CT {
8098 var MSC_ConnHdlr vc_conn;
8099 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8100
8101 f_init(1, true);
8102 f_sleep(1.0);
8103
8104 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
8105 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
8106
8107 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_idle_ms), pars);
8108 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008109 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008110}
8111
8112/* With no active lchan, start BSSMAP Perform Location Request on A interface, but omit IMSI; expect failure response.
8113 */
8114private function f_tc_lcs_loc_req_no_subscriber(charstring id) runs on MSC_ConnHdlr {
8115 f_sleep(1.0);
8116
8117 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
8118 f_bssap_le_register_imsi(g_pars.imsi, omit);
8119
8120 /* provoke an abort by omitting both IMSI and IMEI */
8121 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
8122 valueof(ts_BSSMAP_Perform_Location_Request(omit,
8123 ts_CellId_CGI('262'H, '42'H, 23, 42)))));
8124 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
8125
8126 /* BSC tells MSC about failure */
8127 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(
8128 locationEstimate := omit, positioningData := omit,
8129 lCS_Cause := tr_BSSMAP_LcsCause(BSSMAP_LCS_CAUSE_DATA_MISSING_IN_REQ)));
8130
8131 /* There is no lchan. Still the MSC's job to decide whether to tear down the conn or not. */
8132 f_verify_active_A_conn_and_clear();
8133
8134 f_sleep(2.0);
8135 setverdict(pass);
8136}
8137testcase TC_lcs_loc_req_no_subscriber() runs on test_CT {
8138 var MSC_ConnHdlr vc_conn;
8139 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8140
8141 f_init(1, true);
8142 f_sleep(1.0);
8143
8144 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
8145 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
8146
8147 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_no_subscriber), pars);
8148 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008149 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008150}
8151
8152/* With an active lchan, start a Perform Location Request on the A-interface, but virtual SMLC does not answer with
8153 * BSSMAP-LE Perform Location Response (before or after sending a BSSLAP TA Request) */
8154private function f_lcs_loc_req_for_active_ms_le_timeout(boolean do_ta) runs on MSC_ConnHdlr {
8155 f_sleep(1.0);
8156
8157 f_establish_fully(omit, omit);
8158 f_bssap_le_register_imsi(g_pars.imsi, omit);
8159
8160 BSSAP.send(valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
8161 ts_CellId_CGI('262'H, '42'H, 23, 42))));
8162
8163 var PDU_BSSAP_LE plr;
8164 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
8165
8166 if (do_ta) {
8167 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
8168 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
8169 f_expect_bsslap(tr_BSSLAP_TA_Resp(?, ?));
8170 }
8171
8172 /* SMLC fails to respond, BSC runs into timeout */
8173 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocAbort(BSSMAP_LE_LCS_CAUSE_SYSTEM_FAILURE));
8174 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
8175
8176 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(
8177 locationEstimate := omit, positioningData := omit,
8178 lCS_Cause := tr_BSSMAP_LcsCause(BSSMAP_LCS_CAUSE_SYSTEM_FAILURE)));
8179
8180 /* There is no lchan. Still the MSC's job to decide whether to tear down the conn or not. */
8181 f_verify_active_A_conn_and_clear();
8182
8183 f_sleep(2.0);
8184 setverdict(pass);
8185}
8186
8187/* With an active lchan, start a Perform Location Request on the A-interface, but virtual SMLC does not answer with
8188 * BSSMAP-LE Perform Location Response, without sending a BSSLAP TA Request. */
8189private function f_tc_lcs_loc_req_for_active_ms_le_timeout(charstring id) runs on MSC_ConnHdlr {
8190 f_lcs_loc_req_for_active_ms_le_timeout(false);
8191}
8192
8193testcase TC_lcs_loc_req_for_active_ms_le_timeout() runs on test_CT {
8194 var MSC_ConnHdlr vc_conn;
8195 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8196
8197 f_init(1, true);
8198 f_sleep(1.0);
8199 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_active_ms_le_timeout), pars);
8200 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008201 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008202}
8203
8204/* With an active lchan, start a Perform Location Request on the A-interface, but virtual SMLC does not answer with
8205 * BSSMAP-LE Perform Location Response, after sending a BSSLAP TA Request. */
8206private function f_tc_lcs_loc_req_for_active_ms_le_timeout2(charstring id) runs on MSC_ConnHdlr {
8207 f_lcs_loc_req_for_active_ms_le_timeout(true);
8208}
8209
8210testcase TC_lcs_loc_req_for_active_ms_le_timeout2() runs on test_CT {
8211 var MSC_ConnHdlr vc_conn;
8212 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8213
8214 f_init(1, true);
8215 f_sleep(1.0);
8216 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_active_ms_le_timeout2), pars);
8217 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008218 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008219}
8220
8221/* With *no* active lchan, start a Perform Location Request, expecting that the MS will be Paged. */
8222private function f_tc_lcs_loc_req_for_idle_ms_no_pag_resp(charstring id) runs on MSC_ConnHdlr {
8223 f_sleep(1.0);
8224
8225 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
8226 f_bssap_le_register_imsi(g_pars.imsi, omit);
8227
8228 /* Register to receive the Paging Command */
8229 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
8230 g_chan_nr := new_chan_nr;
8231 f_rslem_register(0, g_chan_nr);
8232
8233 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
8234 valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
8235 ts_CellId_CGI('001'H, '01'H, 1, 0)))));
8236 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
8237
8238 var PDU_BSSAP_LE plr;
8239 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
8240
8241 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
8242 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
8243
8244 /* OsmoBSC needs to Page */
8245 var PDU_BSSAP_LE rx_bsslap;
8246 alt {
8247 [] RSL.receive(tr_RSL_PAGING_CMD(tr_MI_IMSI(g_pars.imsi))) {
8248 f_logp(BSCVTY, "got Paging Command");
8249 repeat;
8250 }
8251 [] BSSAP_LE.receive(tr_BSSMAP_LE_ConnInfo(BSSMAP_LE_PROT_BSSLAP, ?)) -> value(rx_bsslap) {
8252 /* MS does not respond to Paging, TA Req runs into timeout. */
8253 f_match_bsslap(rx_bsslap, tr_BSSLAP_Abort(?));
8254 }
8255 }
8256
8257 /* SMLC responds with failure */
8258 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(omit, BSSMAP_LE_LCS_CAUSE_REQUEST_ABORTED));
8259 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
8260
8261 /* BSC tells MSC about failure */
8262 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(
8263 locationEstimate := omit, positioningData := omit,
8264 lCS_Cause := tr_BSSMAP_LcsCause(BSSMAP_LCS_CAUSE_REQUEST_ABORTED)));
8265
8266 /* There is no lchan. Still the MSC's job to decide whether to tear down the conn or not. */
8267 f_verify_active_A_conn_and_clear();
8268
8269 f_sleep(2.0);
8270 setverdict(pass);
8271}
8272testcase TC_lcs_loc_req_for_idle_ms_no_pag_resp() runs on test_CT {
8273 var MSC_ConnHdlr vc_conn;
8274 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8275
8276 f_init(1, true);
8277 f_sleep(1.0);
8278
8279 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
8280 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
8281
8282 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_idle_ms_no_pag_resp), pars);
8283 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008284 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008285}
8286
8287/* During an ongoing Location Request, the MS sends a CM Service Request. Expect the same A-conn to be re-used / taken
8288 * over. */
8289private function f_tc_cm_service_during_lcs_loc_req(charstring id) runs on MSC_ConnHdlr {
8290 f_sleep(1.0);
8291
8292 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
8293 f_bssap_le_register_imsi(g_pars.imsi, omit);
8294
8295 /* Register to receive the Paging Command */
8296 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
8297 g_chan_nr := new_chan_nr;
8298 f_rslem_register(0, g_chan_nr);
8299
8300 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
8301 valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
8302 ts_CellId_CGI('001'H, '01'H, 1, 0)))));
8303 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
8304
8305 var PDU_BSSAP_LE plr;
8306 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
8307
8308 /* As the A-interface conn was established for LCS, the MS coincidentally decides to issue a CM Service Request
8309 * and establish Layer 3. It should use the existing A-interface conn. */
8310 f_perform_compl_l3(RSL, valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV(g_pars.imsi)))),
8311 do_clear := false, expect_bssmap_l3 := true);
8312
8313 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
8314 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
8315
8316 /* OsmoBSC already has an lchan, no need to Page, just returns the TA */
8317 f_expect_bsslap(tr_BSSLAP_TA_Resp(?, ?));
8318
8319 /* SMLC got the TA from the BSC, now responds with geo information data. */
8320 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(gad_ell_point_unc_circle, omit));
8321 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
8322 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(tr_BSSMAP_IE_LocationEstimate(gad_ell_point_unc_circle)));
8323
8324 /* The lchan should still exist, it was from a CM Service Request. */
8325 f_mo_l3_transceive();
8326
8327 f_perform_clear(RSL);
8328
8329 f_sleep(2.0);
8330 setverdict(pass);
8331}
8332testcase TC_cm_service_during_lcs_loc_req() runs on test_CT {
8333 var MSC_ConnHdlr vc_conn;
8334 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8335
8336 f_init(1, true);
8337 f_sleep(1.0);
8338
8339 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
8340 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
8341
8342 vc_conn := f_start_handler(refers(f_tc_cm_service_during_lcs_loc_req), pars);
8343 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008344 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008345}
8346
8347/* During an ongoing Perform Location Request, do a Handover, an expect a BSSLAP Reset message from the BSC to indicate
8348 * the new lchan after handover. */
8349private function f_tc_ho_during_lcs_loc_req(charstring id) runs on MSC_ConnHdlr {
8350 f_sleep(1.0);
8351
8352 f_establish_fully(omit, omit);
8353 f_bssap_le_register_imsi(g_pars.imsi, omit);
8354
8355 BSSAP.send(valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
8356 ts_CellId_CGI('262'H, '42'H, 23, 42))));
8357
8358 var PDU_BSSAP_LE plr;
8359 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
8360
8361 /* SMLC ponders the Location Request, in the meantime the BSC decides to handover */
8362 f_bts_0_cfg(BSCVTY, {"neighbor bts 1"});
8363
8364 var HandoverState hs := {
8365 rr_ho_cmpl_seen := false,
8366 handover_done := false,
8367 old_chan_nr := -
8368 };
8369 /* issue hand-over command on VTY */
8370 f_vty_handover(BSCVTY, 0, 0, g_chan_nr, 1);
8371 /* temporarily suspend DChan processing on BTS1 to avoid race with RSLEM_register */
8372 f_rslem_suspend(RSL1_PROC);
8373
8374 /* From the MGW perspective, a handover is is characterized by
8375 * performing one MDCX operation with the MGW. So we expect to see
8376 * one more MDCX during handover. */
8377 g_media.mgcp_conn[0].mdcx_seen_exp := g_media.mgcp_conn[0].crcx_seen_exp + 1;
8378
8379 alt {
8380 [] as_handover(hs);
8381 }
8382
8383 var PDU_BSSAP_LE rx_bsslap;
8384
8385 interleave {
8386 /* Expect the BSC to inform the MSC about the handover */
8387 [] BSSAP.receive(tr_BSSMAP_HandoverPerformed);
8388
8389 /* Expect the BSC to inform the SMLC about the handover */
8390 [] BSSAP_LE.receive(tr_BSSMAP_LE_ConnInfo(BSSMAP_LE_PROT_BSSLAP, ?)) -> value(rx_bsslap) {
8391 f_match_bsslap(rx_bsslap, tr_BSSLAP_Reset(BSSLAP_CAUSE_INTRA_BSS_HO));
8392 }
8393 }
8394
8395 /* SMLC now responds with geo information data. */
8396 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(gad_ell_point_unc_circle, omit));
8397 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
8398 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(tr_BSSMAP_IE_LocationEstimate(gad_ell_point_unc_circle)));
8399
8400 /* lchan still active */
8401 f_mo_l3_transceive(RSL1);
8402
8403 /* MSC decides it is done now. */
8404 f_perform_clear(RSL1);
8405
8406 f_sleep(2.0);
8407 setverdict(pass);
8408}
8409testcase TC_ho_during_lcs_loc_req() runs on test_CT {
8410 var MSC_ConnHdlr vc_conn;
8411 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8412
8413 f_init(2, true);
8414 f_sleep(1.0);
8415 vc_conn := f_start_handler(refers(f_tc_ho_during_lcs_loc_req), pars);
8416 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008417 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008418}
8419
Neels Hofmeyrbf037052020-10-28 22:52:02 +00008420/* Attempt Complete Layer 3 without any MSC available (OS#4832) */
8421private function f_tc_no_msc(charstring id) runs on MSC_ConnHdlr {
8422 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
8423
8424 /* Also disable attach for the single connected MSC */
8425 f_vty_msc_allow_attach(BSCVTY, { false });
8426
8427 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) ));
8428 f_chan_est(g_pars.ra, l3_enc, g_pars.link_id, g_pars.fn);
8429
8430 /* No MSC is found, expecting a proper release on RSL */
8431 interleave {
8432 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
8433 f_logp(BSCVTY, "Got RSL RR Release");
8434 }
8435 [] RSL.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
8436 f_logp(BSCVTY, "Got RSL Deact SACCH");
8437 }
8438 [] RSL.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
8439 f_logp(BSCVTY, "Got RSL RF Chan Rel, sending Rel Ack");
8440 RSL.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
8441 }
8442 }
8443 setverdict(pass);
8444}
8445testcase TC_no_msc() runs on test_CT {
8446
8447 f_init(1, true);
8448 f_sleep(1.0);
8449 var MSC_ConnHdlr vc_conn;
8450 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8451
8452 f_ctrs_bsc_init(counternames_bsc_mscpool);
8453
8454 vc_conn := f_start_handler(refers(f_tc_no_msc), pars);
8455 vc_conn.done;
8456
8457 f_ctrs_bsc_add("mscpool:subscr:no_msc");
8458 f_ctrs_bsc_verify();
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008459 f_shutdown_helper();
Neels Hofmeyrbf037052020-10-28 22:52:02 +00008460}
8461
Harald Welte0ea2d5e2018-04-07 21:40:29 +02008462/* Dyn PDCH todo:
8463 * activate OSMO as TCH/F
8464 * activate OSMO as TCH/H
8465 * does the BSC-located PCU socket get the updated INFO?
8466 * what if no PCU is connected at the time?
8467 * is the info correct on delayed PCU (re)connect?
8468 */
Harald Welte94e0c342018-04-07 11:33:23 +02008469
Harald Welte28d943e2017-11-25 15:00:50 +01008470control {
Harald Welte898113b2018-01-31 18:32:21 +01008471 /* CTRL interface testing */
Harald Welte4003d112017-12-09 22:35:39 +01008472 execute( TC_ctrl_msc_connection_status() );
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01008473 execute( TC_ctrl_msc0_connection_status() );
Harald Welte96c94412017-12-09 03:12:45 +01008474 execute( TC_ctrl() );
Neels Hofmeyrf246a922020-05-13 02:27:10 +02008475 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_SCCPlite_SERVER) {
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +02008476 execute( TC_ctrl_location() );
8477 }
Harald Welte898113b2018-01-31 18:32:21 +01008478
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02008479 execute( TC_si_default() );
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02008480 execute( TC_si2quater_2_earfcns() );
8481 execute( TC_si2quater_3_earfcns() );
8482 execute( TC_si2quater_4_earfcns() );
8483 execute( TC_si2quater_5_earfcns() );
8484 execute( TC_si2quater_6_earfcns() );
Neels Hofmeyrad132f22020-07-08 02:20:16 +02008485 execute( TC_si2quater_12_earfcns() );
8486 execute( TC_si2quater_23_earfcns() );
8487 execute( TC_si2quater_32_earfcns() );
8488 execute( TC_si2quater_33_earfcns() );
8489 execute( TC_si2quater_42_earfcns() );
8490 execute( TC_si2quater_48_earfcns() );
8491 execute( TC_si2quater_49_earfcns() );
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02008492 execute( TC_si_acc_rotate() );
Alexander Couzens4ad3a352020-09-10 22:29:12 +02008493 execute( TC_si_acc_ramp_rotate() );
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02008494
Harald Welte898113b2018-01-31 18:32:21 +01008495 /* RSL DCHAN Channel ACtivation / Deactivation */
Harald Welteae026692017-12-09 01:03:01 +01008496 execute( TC_chan_act_noreply() );
Harald Welte4003d112017-12-09 22:35:39 +01008497 execute( TC_chan_act_counter() );
Harald Welteae026692017-12-09 01:03:01 +01008498 execute( TC_chan_act_ack_noest() );
Philipp Maier9c60a622020-07-09 15:08:46 +02008499 execute( TC_chan_act_ack_noest_emerg() );
Philipp Maier606f07d2020-08-12 17:21:58 +02008500 execute( TC_chan_rqd_emerg_deny() );
Harald Welteae026692017-12-09 01:03:01 +01008501 execute( TC_chan_act_ack_est_ind_noreply() );
8502 execute( TC_chan_act_ack_est_ind_refused() );
Harald Welte618ef642017-12-14 14:58:20 +01008503 execute( TC_chan_act_nack() );
Harald Welte799c97b2017-12-14 17:50:30 +01008504 execute( TC_chan_exhaustion() );
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07008505 execute( TC_chan_deact_silence() );
Harald Welte4003d112017-12-09 22:35:39 +01008506 execute( TC_chan_rel_rll_rel_ind() );
8507 execute( TC_chan_rel_conn_fail() );
8508 execute( TC_chan_rel_hard_clear() );
Pau Espin Pedrol841b90d2021-04-15 16:42:52 +02008509 execute( TC_chan_rel_last_eutran_plmn_hard_clear_no_csfb() );
8510 execute( TC_chan_rel_last_eutran_plmn_hard_clear_csfb() );
Harald Welte99787102019-02-04 10:41:36 +01008511 execute( TC_chan_rel_hard_clear_csfb() );
Harald Welted8c36cd2017-12-09 23:05:31 +01008512 execute( TC_chan_rel_hard_rlsd() );
Harald Welte550daf92018-06-11 19:22:13 +02008513 execute( TC_chan_rel_hard_rlsd_ms_dead() );
Harald Welte85804d42017-12-10 14:11:58 +01008514 execute( TC_chan_rel_a_reset() );
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01008515 execute( TC_chan_rel_sccp_tiar_timeout() );
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02008516 execute( TC_chan_rel_rr_cause() );
Harald Welte6f521d82017-12-11 19:52:02 +01008517
Harald Weltecfe2c962017-12-15 12:09:32 +01008518 execute( TC_outbound_connect() );
Harald Welte898113b2018-01-31 18:32:21 +01008519
8520 /* Assignment related */
Harald Welte16a4adf2017-12-14 18:54:01 +01008521 execute( TC_assignment_cic_only() );
Harald Welte235ebf12017-12-15 14:18:16 +01008522 execute( TC_assignment_csd() );
8523 execute( TC_assignment_ctm() );
8524 execute( TC_assignment_sign() );
Pau Espin Pedrol07866632020-09-03 19:10:55 +02008525 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
8526 execute( TC_assignment_aoip_tla_v6() );
8527 }
Harald Welte235ebf12017-12-15 14:18:16 +01008528 execute( TC_assignment_fr_a5_0() );
8529 execute( TC_assignment_fr_a5_1() );
Neels Hofmeyrf246a922020-05-13 02:27:10 +02008530 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welte8f67d1d2018-05-25 20:38:42 +02008531 execute( TC_assignment_fr_a5_1_codec_missing() );
8532 }
Harald Welte235ebf12017-12-15 14:18:16 +01008533 execute( TC_assignment_fr_a5_3() );
8534 execute( TC_assignment_fr_a5_4() );
Harald Welte3c86ea02018-05-10 22:28:05 +02008535 execute( TC_ciph_mode_a5_0() );
8536 execute( TC_ciph_mode_a5_1() );
8537 execute( TC_ciph_mode_a5_3() );
Harald Welte16a4adf2017-12-14 18:54:01 +01008538
Harald Welte60aa5762018-03-21 19:33:13 +01008539 execute( TC_assignment_codec_fr() );
8540 execute( TC_assignment_codec_hr() );
8541 execute( TC_assignment_codec_efr() );
8542 execute( TC_assignment_codec_amr_f() );
8543 execute( TC_assignment_codec_amr_h() );
Philipp Maier8a581d22019-03-26 18:32:48 +01008544
Neels Hofmeyrf246a922020-05-13 02:27:10 +02008545 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Philipp Maier8a581d22019-03-26 18:32:48 +01008546 execute( TC_assignment_codec_amr_f_S1() );
8547 execute( TC_assignment_codec_amr_h_S1() );
8548 execute( TC_assignment_codec_amr_f_S124() );
8549 execute( TC_assignment_codec_amr_h_S124() );
8550 execute( TC_assignment_codec_amr_f_S0() );
8551 execute( TC_assignment_codec_amr_f_S02() );
8552 execute( TC_assignment_codec_amr_f_S024() );
8553 execute( TC_assignment_codec_amr_f_S0247() );
8554 execute( TC_assignment_codec_amr_h_S0() );
8555 execute( TC_assignment_codec_amr_h_S02() );
8556 execute( TC_assignment_codec_amr_h_S024() );
8557 execute( TC_assignment_codec_amr_h_S0247() );
8558 execute( TC_assignment_codec_amr_f_S01234567() );
8559 execute( TC_assignment_codec_amr_f_S0234567() );
8560 execute( TC_assignment_codec_amr_f_zero() );
8561 execute( TC_assignment_codec_amr_f_unsupp() );
8562 execute( TC_assignment_codec_amr_h_S7() );
Neels Hofmeyr21863562020-11-26 00:34:33 +00008563 execute( TC_assignment_codec_amr_f_start_mode_auto() );
8564 execute( TC_assignment_codec_amr_h_start_mode_auto() );
Neels Hofmeyr3eb94562020-11-26 02:40:26 +00008565 execute( TC_assignment_codec_amr_f_start_mode_4() );
8566 execute( TC_assignment_codec_amr_h_start_mode_4() );
Neels Hofmeyr454d7922020-11-26 02:24:57 +00008567 execute( TC_assignment_codec_amr_startmode_cruft() );
Philipp Maier8a581d22019-03-26 18:32:48 +01008568 }
Harald Welte60aa5762018-03-21 19:33:13 +01008569
Philipp Maierac09bfc2019-01-08 13:41:39 +01008570 execute( TC_assignment_codec_fr_exhausted_req_hr() );
8571 execute( TC_assignment_codec_fr_exhausted_req_fr() );
8572 execute( TC_assignment_codec_fr_exhausted_req_fr_hr() );
8573 execute( TC_assignment_codec_fr_exhausted_req_hr_fr() );
8574 execute( TC_assignment_codec_hr_exhausted_req_fr() );
8575 execute( TC_assignment_codec_hr_exhausted_req_hr() );
8576 execute( TC_assignment_codec_hr_exhausted_req_hr_fr() );
8577 execute( TC_assignment_codec_hr_exhausted_req_fr_hr() );
8578 execute( TC_assignment_codec_req_hr_fr() );
8579 execute( TC_assignment_codec_req_fr_hr() );
8580
Pau Espin Pedrol58cf6822019-05-28 18:11:33 +02008581 if (mp_enable_osmux_test) {
8582 execute( TC_assignment_osmux() );
8583 }
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02008584
Harald Welte898113b2018-01-31 18:32:21 +01008585 /* RLL Establish Indication on inactive DCHAN / SAPI */
Harald Welte5cd20ed2017-12-13 21:03:20 +01008586 execute( TC_rll_est_ind_inact_lchan() );
8587 execute( TC_rll_est_ind_inval_sapi1() );
8588 execute( TC_rll_est_ind_inval_sapi3() );
8589 execute( TC_rll_est_ind_inval_sacch() );
8590
Vadim Yanitskiy61f784a2020-10-01 21:12:19 +07008591 /* DLCI / RSL Link ID conversion for MO/MT messages on SAPI0/SAPI3 */
8592 execute( TC_tch_dlci_link_id_sapi() );
8593
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07008594 /* SAPI N Reject triggered by RLL establishment failures */
8595 execute( TC_rll_rel_ind_sapi_n_reject() );
8596 execute( TC_rll_err_ind_sapi_n_reject() );
8597 execute( TC_rll_timeout_sapi_n_reject() );
8598
Harald Welte898113b2018-01-31 18:32:21 +01008599 /* Paging related tests */
Harald Welte6f521d82017-12-11 19:52:02 +01008600 execute( TC_paging_imsi_nochan() );
8601 execute( TC_paging_tmsi_nochan() );
8602 execute( TC_paging_tmsi_any() );
8603 execute( TC_paging_tmsi_sdcch() );
8604 execute( TC_paging_tmsi_tch_f() );
8605 execute( TC_paging_tmsi_tch_hf() );
8606 execute( TC_paging_imsi_nochan_cgi() );
8607 execute( TC_paging_imsi_nochan_lac_ci() );
8608 execute( TC_paging_imsi_nochan_ci() );
8609 execute( TC_paging_imsi_nochan_lai() );
8610 execute( TC_paging_imsi_nochan_lac() );
8611 execute( TC_paging_imsi_nochan_all() );
Harald Welte751d3eb2018-01-31 15:51:06 +01008612 execute( TC_paging_imsi_nochan_plmn_lac_rnc() );
8613 execute( TC_paging_imsi_nochan_rnc() );
8614 execute( TC_paging_imsi_nochan_lac_rnc() );
8615 execute( TC_paging_imsi_nochan_lacs() );
8616 execute( TC_paging_imsi_nochan_lacs_empty() );
Stefan Sperling049a86e2018-03-20 15:51:00 +01008617 execute( TC_paging_imsi_nochan_cgi_unknown_cid() );
Harald Welte10985002017-12-12 09:29:15 +01008618 execute( TC_paging_imsi_a_reset() );
Harald Weltee65d40e2017-12-13 00:09:06 +01008619 execute( TC_paging_imsi_load() );
Philipp Maier779a7922018-02-16 11:00:37 +01008620 execute( TC_paging_counter() );
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01008621 execute( TC_paging_resp_unsol() );
Harald Welte4e9b9cc2017-12-14 18:31:02 +01008622
8623 execute( TC_rsl_drop_counter() );
Stefan Sperling830dc9d2018-02-12 21:08:28 +01008624 execute( TC_rsl_unknown_unit_id() );
8625
8626 execute( TC_oml_unknown_unit_id() );
Harald Welte898113b2018-01-31 18:32:21 +01008627
8628 execute( TC_classmark() );
Harald Welteeddf0e92020-06-21 19:42:15 +02008629 execute( TC_common_id() );
Harald Welte898113b2018-01-31 18:32:21 +01008630 execute( TC_unsol_ass_fail() );
Harald Welteea99a002018-01-31 20:46:43 +01008631 execute( TC_unsol_ass_compl() );
Harald Weltefbf9b5e2018-01-31 20:41:23 +01008632 execute( TC_unsol_ho_fail() );
Harald Weltee3bd6582018-01-31 22:51:25 +01008633 execute( TC_err_82_short_msg() );
Harald Weltee9e02e42018-01-31 23:36:25 +01008634 execute( TC_err_84_unknown_msg() );
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01008635
Harald Welte261af4b2018-02-12 21:20:39 +01008636 execute( TC_ho_int() );
Neels Hofmeyr5f144212020-11-03 15:41:58 +00008637 execute( TC_ho_int_radio_link_failure() );
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01008638
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01008639 execute( TC_ho_out_of_this_bsc() );
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02008640 execute( TC_ho_out_fail_no_msc_response() );
8641 execute( TC_ho_out_fail_rr_ho_failure() );
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02008642 execute( TC_ho_out_fail_no_result_after_ho_cmd() );
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01008643
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01008644 execute( TC_ho_into_this_bsc() );
Pau Espin Pedrol07866632020-09-03 19:10:55 +02008645 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
8646 execute( TC_ho_into_this_bsc_tla_v6() );
8647 }
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01008648 execute( TC_ho_in_fail_msc_clears() );
8649 execute( TC_ho_in_fail_msc_clears_after_ho_detect() );
8650 execute( TC_ho_in_fail_no_detect() );
8651 execute( TC_ho_in_fail_no_detect2() );
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01008652
Neels Hofmeyr91401012019-07-11 00:42:35 +02008653 execute( TC_ho_neighbor_config_1() );
8654 execute( TC_ho_neighbor_config_2() );
8655 execute( TC_ho_neighbor_config_3() );
8656 execute( TC_ho_neighbor_config_4() );
8657 execute( TC_ho_neighbor_config_5() );
8658 execute( TC_ho_neighbor_config_6() );
8659 execute( TC_ho_neighbor_config_7() );
8660
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01008661 execute( TC_bssap_rlsd_does_not_cause_bssmap_reset() );
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01008662 execute( TC_bssmap_clear_does_not_cause_bssmap_reset() );
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01008663 execute( TC_ms_rel_ind_does_not_cause_bssmap_reset() );
Harald Welte94e0c342018-04-07 11:33:23 +02008664
8665 execute( TC_dyn_pdch_ipa_act_deact() );
8666 execute( TC_dyn_pdch_ipa_act_nack() );
8667 execute( TC_dyn_pdch_osmo_act_deact() );
8668 execute( TC_dyn_pdch_osmo_act_nack() );
Harald Welte99f3ca02018-06-14 13:40:29 +02008669
Stefan Sperling0796a822018-10-05 13:01:39 +02008670 execute( TC_chopped_ipa_ping() );
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02008671 execute( TC_chopped_ipa_payload() );
Stefan Sperling0796a822018-10-05 13:01:39 +02008672
Pau Espin Pedrol8f773632019-11-05 11:46:53 +01008673 /* Power control related */
8674 execute( TC_assignment_verify_ms_power_params_ie() );
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008675
8676 /* MSC pooling */
8677 /* FIXME: in SCCPlite, indicating how many MSCs should be connected does currently not work. Since
8678 * RESET->RESET-ACK is unconditionally negotiated for all configured MSCs, they always all appear as connected
8679 * to osmo-bsc. The MSC pooling tests however require disconnecting selected MSCs, and hence don't work out as
8680 * intended on SCCPlite. So for now, run these only for SCCP/M3UA. */
8681 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
8682 execute( TC_mscpool_L3Compl_on_1_msc() );
8683 execute( TC_mscpool_L3Complete_by_imsi_round_robin() );
8684 execute( TC_mscpool_LU_by_tmsi_null_nri_0_round_robin() );
8685 execute( TC_mscpool_LU_by_tmsi_null_nri_1_round_robin() );
8686 execute( TC_mscpool_L3Complete_by_tmsi_unassigned_nri_round_robin() );
8687 execute( TC_mscpool_L3Complete_by_tmsi_valid_nri_msc_not_connected_round_robin() );
8688 execute( TC_mscpool_L3Complete_by_tmsi_valid_nri_1() );
8689 execute( TC_mscpool_L3Complete_by_tmsi_valid_nri_2() );
8690 execute( TC_mscpool_LU_by_tmsi_from_other_PLMN() );
8691 execute( TC_mscpool_paging_and_response_imsi() );
8692 execute( TC_mscpool_paging_and_response_tmsi() );
8693 execute( TC_mscpool_no_allow_attach_round_robin() );
8694 execute( TC_mscpool_no_allow_attach_valid_nri() );
8695 }
8696
Harald Welte99f3ca02018-06-14 13:40:29 +02008697 /* at bottom as they might crash OsmoBSC before OS#3182 is fixed */
8698 execute( TC_early_conn_fail() );
8699 execute( TC_late_conn_fail() );
8700
Philipp Maier783681c2020-07-16 16:47:06 +02008701 /* Emergency call handling (deny / allow) */
8702 execute( TC_assignment_emerg_setup_allow() );
8703 execute( TC_assignment_emerg_setup_deny_msc() );
8704 execute( TC_assignment_emerg_setup_deny_bts() );
Philipp Maier82812002020-08-13 18:48:27 +02008705 execute( TC_emerg_premption() );
8706
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008707 /* Frequency hopping parameters handling */
8708 execute( TC_fh_params_chan_activ() );
8709 execute( TC_fh_params_imm_ass() );
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07008710 execute( TC_fh_params_assignment_cmd() );
Vadim Yanitskiy8f5430d2020-09-02 18:51:38 +07008711 execute( TC_fh_params_handover_cmd() );
Vadim Yanitskiyca974032020-09-01 07:20:39 +07008712 execute( TC_fh_params_si4_cbch() );
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008713
8714 if (mp_enable_lcs_tests) {
8715 execute( TC_lcs_loc_req_for_active_ms() );
8716 execute( TC_lcs_loc_req_for_active_ms_ta_req() );
8717 execute( TC_lcs_loc_req_for_idle_ms() );
8718 execute( TC_lcs_loc_req_no_subscriber() );
8719 execute( TC_lcs_loc_req_for_active_ms_le_timeout() );
8720 execute( TC_lcs_loc_req_for_active_ms_le_timeout2() );
8721 execute( TC_lcs_loc_req_for_idle_ms_no_pag_resp() );
8722 execute( TC_cm_service_during_lcs_loc_req() );
8723 execute( TC_ho_during_lcs_loc_req() );
8724 }
Neels Hofmeyrbf037052020-10-28 22:52:02 +00008725
8726 execute( TC_no_msc() );
Harald Welte28d943e2017-11-25 15:00:50 +01008727}
8728
8729}