blob: 889a64d5f797b6739755d956ddbe492077a6c894 [file] [log] [blame]
Harald Welte28d943e2017-11-25 15:00:50 +01001module BSC_Tests {
2
Harald Welte21b46bd2017-12-17 19:46:32 +01003/* Integration Tests for OsmoBSC
Harald Weltea0630032018-03-20 21:09:55 +01004 * (C) 2017-2018 by Harald Welte <laforge@gnumonks.org>
Harald Welte21b46bd2017-12-17 19:46:32 +01005 * All rights reserved.
6 *
7 * Released under the terms of GNU General Public License, Version 2 or
8 * (at your option) any later version.
9 *
Harald Welte34b5a952019-05-27 11:54:11 +020010 * SPDX-License-Identifier: GPL-2.0-or-later
11 *
Harald Welte21b46bd2017-12-17 19:46:32 +010012 * This test suite tests OsmoBSC while emulating both multiple BTS + MS as
13 * well as the MSC. See README for more details.
14 *
15 * There are test cases that run in so-called 'handler mode' and test cases
16 * that run directly on top of the BSSAP and RSL CodecPorts. The "handler mode"
17 * tests abstract the multiplexing/demultiplexing of multiple SCCP connections
18 * and/or RSL channels and are hence suitable for higher-level test cases, while
19 * the "raw" tests directly on top of the CodecPorts are more suitable for lower-
20 * level testing.
21 */
22
Neels Hofmeyr4f118412020-06-04 15:25:10 +020023import from Misc_Helpers all;
Harald Welte4003d112017-12-09 22:35:39 +010024import from General_Types all;
Harald Welte28d943e2017-11-25 15:00:50 +010025import from Osmocom_Types all;
Harald Welteae026692017-12-09 01:03:01 +010026import from GSM_Types all;
Harald Welte28d943e2017-11-25 15:00:50 +010027import from IPL4asp_Types all;
28
Harald Welte6f521d82017-12-11 19:52:02 +010029import from BSSAP_Types all;
Harald Welte6811d102019-04-14 22:23:14 +020030import from RAN_Adapter all;
Harald Welte47cd0e32020-08-21 12:39:11 +020031import from BSSAP_LE_Adapter all;
32import from BSSAP_LE_CodecPort all;
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +020033import from BSSAP_LE_Types all;
34import from BSSLAP_Types all;
Harald Welteae026692017-12-09 01:03:01 +010035import from BSSAP_CodecPort all;
36import from BSSMAP_Templates all;
Harald Welte28d943e2017-11-25 15:00:50 +010037import from IPA_Emulation all;
Stefan Sperling830dc9d2018-02-12 21:08:28 +010038import from IPA_CodecPort all;
Harald Welteae026692017-12-09 01:03:01 +010039import from IPA_Types all;
Stefan Sperling0796a822018-10-05 13:01:39 +020040import from IPA_Testing all;
Harald Welteae026692017-12-09 01:03:01 +010041import from RSL_Types all;
Harald Welte624f9632017-12-16 19:26:04 +010042import from RSL_Emulation all;
Daniel Willmann191e0d92018-01-17 12:44:35 +010043import from MGCP_Emulation all;
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +010044import from MGCP_Templates all;
45import from MGCP_Types all;
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +020046import from MGCP_CodecPort all;
Harald Welte28d943e2017-11-25 15:00:50 +010047
Harald Welte96c94412017-12-09 03:12:45 +010048import from Osmocom_CTRL_Functions all;
Harald Weltea5d2ab22017-12-09 14:21:42 +010049import from Osmocom_CTRL_Types all;
Harald Welteffe55fc2018-01-17 22:39:54 +010050import from Osmocom_CTRL_Adapter all;
Harald Welte96c94412017-12-09 03:12:45 +010051
Daniel Willmannebdecc02020-08-12 15:30:17 +020052import from StatsD_Types all;
53import from StatsD_CodecPort all;
54import from StatsD_CodecPort_CtrlFunct all;
55import from StatsD_Checker all;
56
Harald Weltebc03c762018-02-12 18:09:38 +010057import from Osmocom_VTY_Functions all;
58import from TELNETasp_PortType all;
59
Harald Welte6f521d82017-12-11 19:52:02 +010060import from MobileL3_CommonIE_Types all;
Harald Weltee3bd6582018-01-31 22:51:25 +010061import from MobileL3_Types all;
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +010062import from MobileL3_RRM_Types all;
Harald Welte6f521d82017-12-11 19:52:02 +010063import from L3_Templates all;
64import from GSM_RR_Types all;
65
Stefan Sperlingc307e682018-06-14 15:15:46 +020066import from SCCP_Templates all;
Neels Hofmeyr4ff93282018-03-12 04:25:35 +010067import from BSSMAP_Templates all;
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +020068import from BSSMAP_LE_Templates all;
Neels Hofmeyr4ff93282018-03-12 04:25:35 +010069
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +010070import from SCCPasp_Types all;
71
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +020072import from GSM_SystemInformation all;
73import from GSM_RestOctets all;
Neels Hofmeyrad132f22020-07-08 02:20:16 +020074import from TCCConversion_Functions all;
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +020075
Harald Welte5d1a2202017-12-13 19:51:29 +010076const integer NUM_BTS := 3;
Neels Hofmeyrf246a922020-05-13 02:27:10 +020077const integer NUM_MSC := 3;
Harald Welteae026692017-12-09 01:03:01 +010078const float T3101_MAX := 12.0;
Harald Welte28d943e2017-11-25 15:00:50 +010079
Harald Welte799c97b2017-12-14 17:50:30 +010080/* make sure to sync this with the osmo-bts.cfg you're using */
Philipp Maiercb6cc482018-03-26 13:08:00 +020081const integer NUM_TCHH_PER_BTS := 2;
82const integer NUM_TCHF_PER_BTS := 4;
Neels Hofmeyr74083c22020-07-29 00:43:01 +020083const integer NUM_SDCCH_PER_BTS := 3;
Harald Welte799c97b2017-12-14 17:50:30 +010084
Harald Welte4003d112017-12-09 22:35:39 +010085
Harald Welte21b46bd2017-12-17 19:46:32 +010086/* per-BTS state which we keep */
Harald Welte96c94412017-12-09 03:12:45 +010087type record BTS_State {
Harald Welte21b46bd2017-12-17 19:46:32 +010088 /* component reference to the IPA_Client component used for RSL */
Harald Weltea5d2ab22017-12-09 14:21:42 +010089 IPA_Client rsl
Harald Welte96c94412017-12-09 03:12:45 +010090}
91
Neels Hofmeyr22c3f792020-06-17 02:49:28 +020092/* Default list of counters for an 'msc' entity. */
93const CounterNameVals counternames_msc_mscpool := {
94 { "mscpool:subscr:new", 0 },
95 { "mscpool:subscr:known", 0 },
96 { "mscpool:subscr:reattach", 0 },
97 { "mscpool:subscr:attach_lost", 0 },
98 { "mscpool:subscr:paged", 0 }
99};
100
Neels Hofmeyrbf037052020-10-28 22:52:02 +0000101/* List of global mscpool counters, not related to a specific 'msc' entity. */
102const CounterNameVals counternames_bsc_mscpool := {
103 { "mscpool:subscr:no_msc", 0 }
104};
105
Neels Hofmeyr12941bd2020-08-29 03:21:26 +0000106/* Default list of counters for 'bsc' and 'bts' entities. */
107const CounterNameVals counternames_bsc_bts_handover := {
108 { "assignment:attempted", 0 },
109 { "assignment:completed", 0 },
110 { "assignment:stopped", 0 },
111 { "assignment:no_channel", 0 },
112 { "assignment:timeout", 0 },
113 { "assignment:failed", 0 },
114 { "assignment:error", 0 },
115
116 { "handover:attempted", 0 },
117 { "handover:completed", 0 },
118 { "handover:stopped", 0 },
119 { "handover:no_channel", 0 },
120 { "handover:timeout", 0 },
121 { "handover:failed", 0 },
122 { "handover:error", 0 },
123
124 { "intra_cell_ho:attempted", 0 },
125 { "intra_cell_ho:completed", 0 },
126 { "intra_cell_ho:stopped", 0 },
127 { "intra_cell_ho:no_channel", 0 },
128 { "intra_cell_ho:timeout", 0 },
129 { "intra_cell_ho:failed", 0 },
130 { "intra_cell_ho:error", 0 },
131
132 { "intra_bsc_ho:attempted", 0 },
133 { "intra_bsc_ho:completed", 0 },
134 { "intra_bsc_ho:stopped", 0 },
135 { "intra_bsc_ho:no_channel", 0 },
136 { "intra_bsc_ho:timeout", 0 },
137 { "intra_bsc_ho:failed", 0 },
138 { "intra_bsc_ho:error", 0 },
139
140 { "interbsc_ho_out:attempted", 0 },
141 { "interbsc_ho_out:completed", 0 },
142 { "interbsc_ho_out:stopped", 0 },
143 { "interbsc_ho_out:timeout", 0 },
144 { "interbsc_ho_out:failed", 0 },
145 { "interbsc_ho_out:error", 0 },
146
147 { "interbsc_ho_in:attempted", 0 },
148 { "interbsc_ho_in:completed", 0 },
149 { "interbsc_ho_in:stopped", 0 },
150 { "interbsc_ho_in:no_channel", 0 },
151 { "interbsc_ho_in:timeout", 0 },
152 { "interbsc_ho_in:failed", 0 },
153 { "interbsc_ho_in:error", 0 }
154};
155
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200156/* Set of all System Information received during one RSL port's startup.
157 * Note that some System Information may be sent on RSL, but lacking actual SI data, to indicate that the BTS should not
158 * broadcast that SI type. That will be reflected as 'omit' here.
159 */
160type record SystemInformationConfig {
161 SystemInformationType1 si1 optional,
162 SystemInformationType2 si2 optional,
163 SystemInformationType2bis si2bis optional,
164 SystemInformationType2ter si2ter optional,
Neels Hofmeyrad132f22020-07-08 02:20:16 +0200165 SI2quaterRestOctetsList si2quater optional,
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200166 SystemInformationType3 si3 optional,
167 SystemInformationType4 si4 optional,
Pau Espin Pedrol28652d82021-02-09 20:20:17 +0100168 SystemInformationType13 si13 optional,
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200169 SystemInformationType5 si5 optional,
170 SystemInformationType5bis si5bis optional,
171 SystemInformationType5ter si5ter optional,
172 SystemInformationType6 si6 optional
173};
174
175const SystemInformationConfig SystemInformationConfig_omit := {
176 si1 := omit,
177 si2 := omit,
178 si2bis := omit,
179 si2ter := omit,
180 si2quater := omit,
181 si3 := omit,
182 si4 := omit,
183 si13 := omit,
184 si5 := omit,
185 si5bis := omit,
186 si5ter := omit,
187 si6 := omit
188};
189
190/* tr_EUTRAN_CellDesc with defaults used in BSC_Tests.ttcn */
191template EUTRAN_CellDesc tr_EUTRAN_CellDesc_default(template (present) uint16_t e_arfcn := ?,
192 template uint3_t meas_bw := 3)
193:= tr_EUTRAN_CellDesc(e_arfcn := e_arfcn,
194 meas_bw_presence := '1'B,
195 meas_bw := meas_bw);
196
197/* tr_EUTRAN_NeighbourCells with defaults used in BSC_Tests.ttcn */
Harald Welte65e419a2020-08-21 12:38:33 +0200198template EUTRAN_NeighbourCells tr_EUTRAN_NeighbourCells_default(template (present) EUTRAN_CellDescs cell_desc_list := { tr_EUTRAN_CellDesc_default },
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200199 template uint3_t prio := 3,
200 template (present) uint5_t thresh_high := 20,
201 template uint5_t thresh_low := 10,
202 template uint5_t qrxlevmin := 22)
203:= tr_EUTRAN_NeighbourCells(
204 cell_desc_list := cell_desc_list,
205 prio_presence := '1'B,
206 prio := prio,
207 thresh_high := thresh_high,
208 thresh_low_presence := '1'B,
209 thresh_low := thresh_low,
210 qrxlevmin_presence := '1'B,
211 qrxlevmin := qrxlevmin);
212
213template SystemInformationConfig SystemInformationConfig_default := {
214 si1 := {
215 cell_chan_desc := '8FB38000000000000000000000000000'O,
216 rach_control := {
217 max_retrans := RACH_MAX_RETRANS_7,
218 tx_integer := '1001'B,
219 cell_barr_access := false,
220 re_not_allowed := true,
221 acc := '0000010000000000'B
222 },
223 rest_octets := ?
224 },
225 si2 := {
226 bcch_freq_list := '00000000000000000000000000000000'O,
227 ncc_permitted := '11111111'B,
228 rach_control := {
229 max_retrans := RACH_MAX_RETRANS_7,
230 tx_integer := '1001'B,
231 cell_barr_access := false,
232 re_not_allowed := true,
233 acc := '0000010000000000'B
234 }
235 },
236 si2bis := omit,
237 si2ter := {
238 extd_bcch_freq_list := '8E320000000000000000000000000800'O,
239 rest_octets := ?
240 },
241 si2quater := {
242 tr_SI2quaterRestOctets_EUTRAN( repeated_neigh_cells := { tr_EUTRAN_NeighbourCells_default } )
243 },
244 si3 := {
245 cell_id := 0,
246 lai := {
247 mcc_mnc := '001F01'H,
248 lac := 1
249 },
250 ctrl_chan_desc := {
251 msc_r99 := true,
252 att := true,
253 bs_ag_blks_res := 1,
254 ccch_conf := CCHAN_DESC_1CCCH_COMBINED,
255 si22ind := false,
256 cbq3 := CBQ3_IU_MODE_NOT_SUPPORTED,
257 spare := '00'B,
258 bs_pa_mfrms := 3,
259 t3212 := 30
260 },
261 cell_options := {
262 dn_ind := false,
263 pwrc := false,
264 dtx := MS_SHALL_USE_UL_DTX,
265 radio_link_tout_div4 := 7
266 },
267 cell_sel_par := {
268 cell_resel_hyst_2dB := 2,
269 ms_txpwr_max_cch := 7,
270 acs := '0'B,
271 neci := true,
272 rxlev_access_min := 0
273 },
274 rach_control := {
275 max_retrans := RACH_MAX_RETRANS_7,
276 tx_integer := '1001'B,
277 cell_barr_access := false,
278 re_not_allowed := true,
279 acc := '0000010000000000'B
280 },
281 rest_octets := {
282 sel_params := {
283 presence := '0'B,
284 params := omit
285 },
286 pwr_offset := {
287 presence := '0'B,
288 offset := omit
289 },
290 si_2ter_ind := '1'B,
291 early_cm_ind := '0'B,
292 sched_where := {
293 presence := '0'B,
294 where := omit
295 },
296 gprs_ind := {
297 presence := '1'B,
298 ind := {
299 ra_colour := 0,
300 si13_pos := '0'B
301 }
302 },
303 umts_early_cm_ind := '1'B,
304 si2_quater_ind := {
305 presence := '1'B,
306 ind := '0'B
307 },
308 iu_mode_ind := omit,
309 si21_ind := {
310 presence := '0'B,
311 pos := omit
312 }
313 }
314 },
315 si4 := {
316 lai := {
317 mcc_mnc := '001F01'H,
318 lac := 1
319 },
320 cell_sel_par := {
321 cell_resel_hyst_2dB := 2,
322 ms_txpwr_max_cch := 7,
323 acs := '0'B,
324 neci := true,
325 rxlev_access_min := 0
326 },
327 rach_control := {
328 max_retrans := RACH_MAX_RETRANS_7,
329 tx_integer := '1001'B,
330 cell_barr_access := false,
331 re_not_allowed := true,
332 acc := '0000010000000000'B
333 },
Neels Hofmeyr74083c22020-07-29 00:43:01 +0200334 cbch_chan_desc := {
335 iei := '64'O,
336 v := {
337 chan_nr := {
338 u := {
339 sdcch4 := {
340 tag := '001'B,
341 sub_chan := 2
342 }
343 },
344 tn := 0
345 },
346 tsc := 2,
347 h := false,
348 arfcn := 871,
349 maio_hsn := omit
350 }
351 },
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200352 cbch_mobile_alloc := omit,
353 rest_octets := {
354 sel_params := {
355 presence := '0'B,
356 params := omit
357 },
358 pwr_offset := {
359 presence := '0'B,
360 offset := omit
361 },
362 gprs_ind := {
363 presence := '1'B,
364 ind := {
365 ra_colour := 0,
366 si13_pos := '0'B
367 }
368 },
369 s_presence := '0'B,
370 s := omit
371 }
372 },
Pau Espin Pedrol28652d82021-02-09 20:20:17 +0100373 si13 := {
374 rest_octets := {
375 presence := '1'B,
376 bcch_change_mark := ?,
377 si_change_field := '0000'B,
378 presence2 := '0'B,
379 si13_change_mark := omit,
380 gprs_ma := omit,
381 zero := '0'B, /* PBCCH not present in cell */
382 rac := 0,
383 spgc_ccch_sup := '0'B,
384 priority_access_thr := '110'B,
385 network_control_order := '00'B,
386 gprs_cell_opts := {
387 nmo := '01'B,
388 t3168 := '011'B,
389 t3192 := '010'B,
390 drx_timer_max := '011'B,
391 access_burst_type := '0'B,
392 control_ack_type := '1'B,
393 bs_cv_max := 15,
394 pan_presence := '1'B,
395 pan_dec := 1,
396 pan_inc := 1,
397 pan_max := '111'B,
398 ext_info_presence := ?,
399 ext_info_length := *,
400 ext_info := *
401 },
402 gprs_pwr_ctrl_params := {
403 alpha := 0,
404 t_avg_w := '10000'B,
405 t_avg_t := '10000'B,
406 pc_meas_chan := '0'B,
407 n_avg_i := '1000'B
408 }
409 }
410 },
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200411 si5 := {
412 bcch_freq_list := '10000000000000000000000000000000'O
413 },
414 si5bis := omit,
415 si5ter := {
416 extd_bcch_freq_list := '9E050020000000000000000000000000'O
417 },
418 si6 := {
419 cell_id := 0,
420 lai := {
421 mcc_mnc := '001F01'H,
422 lac := 1
423 },
424 cell_options := {
425 dtx_ext := '1'B,
426 pwrc := false,
427 dtx := '01'B,
428 radio_link_timeout := '0111'B
429 },
430 ncc_permitted := '11111111'B,
431 rest_octets := ?
432 }
433 };
434
435
436/* List of all the System Information received on all RSL ports */
437type record of SystemInformationConfig SystemInformationConfig_list;
438
439function f_sysinfo_dec_raw(inout SystemInformationConfig si, RSL_Message rsl)
440{
441 var RSL_IE_Body sysinfo_type_ie;
442 var RSL_IE_SysinfoType si_type;
443 var octetstring data;
444
445 if (f_rsl_find_ie(rsl, RSL_IE_SYSINFO_TYPE, sysinfo_type_ie) == false) {
446 setverdict(fail, "Cannot find RSL_IE_SYSINFO_TYPE");
447 mtc.stop;
448 }
449 si_type := sysinfo_type_ie.sysinfo_type;
450
451 if (rsl.msg_type == RSL_MT_BCCH_INFO) {
452 var RSL_IE_Body bcch_ie;
453 if (f_rsl_find_ie(rsl, RSL_IE_FULL_BCCH_INFO, bcch_ie)) {
454 data := bcch_ie.other.payload;
455 }
456 } else if (rsl.msg_type == RSL_MT_SACCH_FILL) {
457 var RSL_IE_Body l3_ie;
458 if (f_rsl_find_ie(rsl, RSL_IE_L3_INFO, l3_ie)) {
459 data := l3_ie.l3_info.payload;
460 }
461 } else {
462 setverdict(fail, "Don't understand this System Information message");
463 mtc.stop;
464 }
465
466 var boolean handled := false;
467
468 if (rsl.msg_type == RSL_MT_BCCH_INFO) {
469 handled := true;
470
471 if (si_type == RSL_SYSTEM_INFO_1) {
472 if (not isbound(data)) {
473 si.si1 := omit;
474 } else {
475 si.si1 := dec_SystemInformation(data).payload.si1;
476 }
477 } else if (si_type == RSL_SYSTEM_INFO_2) {
478 if (not isbound(data)) {
479 si.si2 := omit;
480 } else {
481 si.si2 := dec_SystemInformation(data).payload.si2;
482 }
483 } else if (si_type == RSL_SYSTEM_INFO_2bis) {
484 if (not isbound(data)) {
485 si.si2bis := omit;
486 } else {
487 si.si2bis := dec_SystemInformation(data).payload.si2bis;
488 }
489 } else if (si_type == RSL_SYSTEM_INFO_2ter) {
490 if (not isbound(data)) {
491 si.si2ter := omit;
492 } else {
493 si.si2ter := dec_SystemInformation(data).payload.si2ter;
494 }
495 } else if (si_type == RSL_SYSTEM_INFO_2quater) {
496 if (not isbound(data)) {
497 si.si2quater := {};
498 } else {
499 var SystemInformationType2quater decoded := dec_SystemInformation(data).payload.si2quater;
500 /* this is a *record* of SI2quaterRestOctets! (multiplexed) */
501 si.si2quater[decoded.rest_octets.si2quater_index] := decoded.rest_octets;
502 }
503 } else if (si_type == RSL_SYSTEM_INFO_3) {
504 if (not isbound(data)) {
505 si.si3 := omit;
506 } else {
507 si.si3 := dec_SystemInformation(data).payload.si3;
508 }
509 } else if (si_type == RSL_SYSTEM_INFO_4) {
510 if (not isbound(data)) {
511 si.si4 := omit;
512 } else {
513 si.si4 := dec_SystemInformation(data).payload.si4;
514 }
515 } else if (si_type == RSL_SYSTEM_INFO_13) {
516 if (not isbound(data)) {
517 si.si13 := omit;
518 } else {
Pau Espin Pedrol28652d82021-02-09 20:20:17 +0100519 si.si13 := dec_SystemInformation(data).payload.si13;
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200520 }
521 } else {
522 handled := false;
523 }
524 } else if (rsl.msg_type == RSL_MT_SACCH_FILL) {
525 handled := true;
526
527 if (si_type == RSL_SYSTEM_INFO_5) {
528 if (not isbound(data)) {
529 si.si5 := omit;
530 } else {
531 si.si5 := dec_SystemInformation(data).payload.si5;
532 }
533 } else if (si_type == RSL_SYSTEM_INFO_5bis) {
534 if (not isbound(data)) {
535 si.si5bis := omit;
536 } else {
537 si.si5bis := dec_SystemInformation(data).payload.si5bis;
538 }
539 } else if (si_type == RSL_SYSTEM_INFO_5ter) {
540 if (not isbound(data)) {
541 si.si5ter := omit;
542 } else {
543 si.si5ter := dec_SystemInformation(data).payload.si5ter;
544 }
545 } else if (si_type == RSL_SYSTEM_INFO_6) {
546 if (not isbound(data)) {
547 si.si6 := omit;
548 } else {
549 si.si6 := dec_SystemInformation(data).payload.si6;
550 }
551 } else {
552 handled := false;
553 }
554 }
555
556 if (not handled) {
557 setverdict(fail, "Unexpected SI type in ", rsl.msg_type, " message: ", si_type);
558 }
559}
560
Harald Weltea4ca4462018-02-09 00:17:14 +0100561type component test_CT extends CTRL_Adapter_CT {
Harald Welte21b46bd2017-12-17 19:46:32 +0100562 /* Array of per-BTS state */
Harald Welte96c94412017-12-09 03:12:45 +0100563 var BTS_State bts[NUM_BTS];
Harald Welte89ab1912018-02-23 18:56:29 +0100564 /* RSL common Channel Port (for RSL_Emulation) */
565 port RSL_CCHAN_PT RSL_CCHAN[NUM_BTS];
Harald Welte21b46bd2017-12-17 19:46:32 +0100566 /* array of per-BTS RSL test ports */
Harald Welteae026692017-12-09 01:03:01 +0100567 port IPA_RSL_PT IPA_RSL[NUM_BTS];
Stefan Sperling830dc9d2018-02-12 21:08:28 +0100568 port IPA_CODEC_PT IPA; /* Required for compilation of TC_rsl_unknown_unit_id() */
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +0200569 /* CTRL muxed over IPA in SCCPlite conn BSC<->MSC (or BSC-NAT) */
570 port IPA_CTRL_PT SCCPLITE_IPA_CTRL;
Harald Weltea5d2ab22017-12-09 14:21:42 +0100571
Daniel Willmann191e0d92018-01-17 12:44:35 +0100572 var MGCP_Emulation_CT vc_MGCP;
Harald Weltebc03c762018-02-12 18:09:38 +0100573 port TELNETasp_PT BSCVTY;
Daniel Willmann191e0d92018-01-17 12:44:35 +0100574
Daniel Willmannebdecc02020-08-12 15:30:17 +0200575 /* StatsD */
576 var StatsD_Checker_CT vc_STATSD;
577
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200578 var RAN_Adapter g_bssap[NUM_MSC];
Harald Welte47cd0e32020-08-21 12:39:11 +0200579 var BSSAP_LE_Adapter g_bssap_le;
Harald Weltea4ca4462018-02-09 00:17:14 +0100580 /* for old legacy-tests only */
581 port BSSAP_CODEC_PT BSSAP;
Harald Welte47cd0e32020-08-21 12:39:11 +0200582 port BSSAP_LE_CODEC_PT BSSAP_LE;
Harald Weltea4ca4462018-02-09 00:17:14 +0100583
Harald Welte21b46bd2017-12-17 19:46:32 +0100584 /* are we initialized yet */
Harald Welte28d943e2017-11-25 15:00:50 +0100585 var boolean g_initialized := false;
Harald Welte21b46bd2017-12-17 19:46:32 +0100586
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200587 /* Osmux is enabled through VTY */
588 var boolean g_osmux_enabled := false;
589
Pau Espin Pedrolc675b612020-01-09 19:55:40 +0100590 /*Configure T(tias) over VTY, seconds */
591 var integer g_bsc_sccp_timer_ias := 7 * 60;
592 /*Configure T(tiar) over VTY, seconds */
593 var integer g_bsc_sccp_timer_iar := 15 * 60;
594
Neels Hofmeyr4fbad7f2020-06-16 00:30:47 +0200595 /* global test case guard timer (actual timeout value is set in f_init()) */
Harald Welteae026692017-12-09 01:03:01 +0100596 timer T_guard := 30.0;
597
Neels Hofmeyr22c3f792020-06-17 02:49:28 +0200598 var CounterNameValsList g_ctr_msc;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +0000599 var CounterNameValsList g_ctr_bsc;
600 var CounterNameValsList g_ctr_bts;
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200601
602 /* System Information bytes as received during RSL startup, for each RSL[idx]. */
603 var SystemInformationConfig_list g_system_information := {};
Harald Welte28d943e2017-11-25 15:00:50 +0100604}
605
606modulepar {
Harald Welte21b46bd2017-12-17 19:46:32 +0100607 /* IP address at which the BSC can be reached */
Harald Welte696ddb62017-12-08 14:01:43 +0100608 charstring mp_bsc_ip := "127.0.0.1";
Stefan Sperling830dc9d2018-02-12 21:08:28 +0100609 /* port number to which to establish the IPA OML connections */
610 integer mp_bsc_oml_port := 3002;
Harald Welte21b46bd2017-12-17 19:46:32 +0100611 /* port number to which to establish the IPA RSL connections */
Harald Welte696ddb62017-12-08 14:01:43 +0100612 integer mp_bsc_rsl_port := 3003;
Harald Welte21b46bd2017-12-17 19:46:32 +0100613 /* port number to which to establish the IPA CTRL connection */
Harald Welte96c94412017-12-09 03:12:45 +0100614 integer mp_bsc_ctrl_port := 4249;
Daniel Willmannebdecc02020-08-12 15:30:17 +0200615 /* port number to which to listen for STATSD metrics */
616 integer mp_bsc_statsd_port := 8125;
Daniel Willmann191e0d92018-01-17 12:44:35 +0100617 /* IP address at which the test binds */
618 charstring mp_test_ip := "127.0.0.1";
Harald Weltea4ca4462018-02-09 00:17:14 +0100619
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200620 RAN_Configurations mp_bssap_cfg := {
621 {
622 transport := BSSAP_TRANSPORT_AoIP,
623 sccp_service_type := "mtp3_itu",
624 sctp_addr := { 23905, "127.0.0.1", 2905, "127.0.0.1" },
625 own_pc := 185, /* 0.23.1 first MSC emulation */
626 own_ssn := 254,
627 peer_pc := 187, /* 0.23.3 osmo-bsc */
628 peer_ssn := 254,
629 sio := '83'O,
Harald Weltecb0cc432020-06-21 19:42:31 +0200630 rctx := 1
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200631 },
632 {
633 transport := BSSAP_TRANSPORT_AoIP,
634 sccp_service_type := "mtp3_itu",
635 sctp_addr := { 23906, "127.0.0.1", 2905, "127.0.0.1" },
636 own_pc := 2, /* 0.0.2 second MSC emulation */
637 own_ssn := 254,
638 peer_pc := 187, /* 0.23.3 osmo-bsc */
639 peer_ssn := 254,
640 sio := '83'O,
641 rctx := 2
642 },
643 {
644 transport := BSSAP_TRANSPORT_AoIP,
645 sccp_service_type := "mtp3_itu",
646 sctp_addr := { 23907, "127.0.0.1", 2905, "127.0.0.1" },
647 own_pc := 3, /* 0.0.3 third MSC emulation */
648 own_ssn := 254,
649 peer_pc := 187, /* 0.23.3 osmo-bsc */
650 peer_ssn := 254,
651 sio := '83'O,
652 rctx := 3
653 }
Harald Weltea4ca4462018-02-09 00:17:14 +0100654 };
Pau Espin Pedrol58cf6822019-05-28 18:11:33 +0200655
Harald Welte47cd0e32020-08-21 12:39:11 +0200656 BSSAP_LE_Configuration mp_bssap_le_cfg := {
657 sccp_service_type := "mtp3_itu",
658 sctp_addr := { 23908, "127.0.0.1", 2905, "127.0.0.1" },
Neels Hofmeyrac086c12020-09-18 23:46:42 +0200659 own_pc := 190, /* 0.23.6 SMLC emulation */
Harald Welte47cd0e32020-08-21 12:39:11 +0200660 own_ssn := 252, /* SMLC side SSN */
661 peer_pc := 187, /* 0.23.3 osmo-bsc */
662 peer_ssn := 250, /* BSC side SSN */
663 sio := '83'O,
664 rctx := 6
665 };
Neels Hofmeyrcfe44062020-10-15 02:28:08 +0200666 boolean mp_enable_lcs_tests := true;
Harald Welte47cd0e32020-08-21 12:39:11 +0200667
Pau Espin Pedrol58cf6822019-05-28 18:11:33 +0200668 /* Whether to enable osmux tests. Can be dropped completely and enable
669 unconditionally once new version of osmo-bsc is released (current
670 version: 1.4.1) */
671 boolean mp_enable_osmux_test := true;
Pau Espin Pedrol8f30ccd2019-11-01 17:30:57 +0100672 /* Value set in osmo-bsc.cfg "ms max power" */
673 uint8_t mp_exp_ms_power_level := 7;
Harald Weltea4ca4462018-02-09 00:17:14 +0100674}
675
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200676private function f_gen_test_hdlr_pars(integer bssap_idx := 0) return TestHdlrParams {
Philipp Maier48604732018-10-09 15:00:37 +0200677
678 var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200679 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Philipp Maier48604732018-10-09 15:00:37 +0200680 pars.aoip := true;
681 } else {
682 pars.aoip := false;
683 }
Pau Espin Pedrol8f30ccd2019-11-01 17:30:57 +0100684 pars.exp_ms_power_level := mp_exp_ms_power_level;
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200685 pars.mscpool.bssap_idx := bssap_idx;
Philipp Maier48604732018-10-09 15:00:37 +0200686
687 return pars;
688}
689
Neels Hofmeyr22c3f792020-06-17 02:49:28 +0200690/* Convenience functions for rate counters using g_ctr_msc. */
691
692private function f_ctrs_msc_init(integer mscs_count := NUM_MSC, CounterNameVals counternames := counternames_msc_mscpool) runs on test_CT {
693 g_ctr_msc := f_counter_name_vals_get_n(IPA_CTRL, "msc", mscs_count, counternames);
694 log("initial msc rate counters: ", g_ctr_msc);
695}
696
697private function f_ctrs_msc_add(integer msc_nr, charstring countername, integer val := 1) runs on test_CT {
Neels Hofmeyr9656e922020-06-30 01:27:01 +0200698 f_counter_name_vals_list_add(g_ctr_msc, msc_nr, countername, val);
Neels Hofmeyr22c3f792020-06-17 02:49:28 +0200699}
700
701/* f_ctrs_msc_init();
702 * f_do_thing(on_msc := 0);
703 * f_do_thing(on_msc := 0);
704 * f_do_other(on_msc := 1);
705 * f_ctrs_msc_add(0, "thing", 2);
706 * f_ctrs_msc_add(1, "other");
707 * f_ctrs_msc_verify();
708 */
709private function f_ctrs_msc_verify() runs on test_CT {
710 log("verifying msc rate counters: ", g_ctr_msc);
711 f_counter_name_vals_expect_n(IPA_CTRL, "msc", g_ctr_msc);
712}
713
714/* convenience: f_ctrs_msc_add() and f_ctrs_msc_verify() in one call.
715 * f_ctrs_msc_init();
716 * f_do_thing(on_msc := 0);
717 * f_do_thing(on_msc := 0);
718 * f_do_thing(on_msc := 0);
719 * f_ctrs_msc_expect(0, "thing", 3);
720 */
721private function f_ctrs_msc_expect(integer msc_nr, charstring countername, integer val := 1) runs on test_CT {
722 f_ctrs_msc_add(msc_nr, countername, val);
723 f_ctrs_msc_verify();
724}
725
Neels Hofmeyr12941bd2020-08-29 03:21:26 +0000726/* Convenience functions for rate counters using g_ctr_bts, always also including g_ctr_bsc. */
727
728private function f_ctrs_bsc_and_bts_init(integer bts_count := NUM_BTS, CounterNameVals counternames := counternames_bsc_bts_handover) runs on test_CT {
729 g_ctr_bts := f_counter_name_vals_get_n(IPA_CTRL, "bts", bts_count, counternames);
730 log("initial bts rate counters: ", g_ctr_bts);
731 f_ctrs_bsc_init(counternames);
732}
733
734private function f_ctrs_bsc_and_bts_add(integer bts_nr, charstring countername, integer val := 1) runs on test_CT {
735 f_counter_name_vals_list_add(g_ctr_bts, bts_nr, countername, val);
736 f_ctrs_bsc_add(countername, val);
737}
738
739/* f_ctrs_bsc_and_bts_init();
740 * f_do_thing(on_bts := 0);
741 * f_do_thing(on_bts := 0);
742 * f_do_other(on_bts := 1);
743 * f_ctrs_bsc_and_bts_add(0, "thing", 2);
744 * f_ctrs_bsc_and_bts_add(1, "other");
745 * f_ctrs_bsc_and_bts_verify();
746 */
747private function f_ctrs_bsc_and_bts_verify() runs on test_CT {
748 f_counter_name_vals_expect_n(IPA_CTRL, "bts", g_ctr_bts);
749 f_ctrs_bsc_verify();
750}
751
752/* convenience: f_ctrs_bsc_and_bts_add() and f_ctrs_bsc_and_bts_verify() in one call.
753 * f_ctrs_bsc_and_bts_init();
754 * f_do_thing(on_bts := 0);
755 * f_do_thing(on_bts := 0);
756 * f_do_thing(on_bts := 0);
757 * f_ctrs_bsc_and_bts_expect(0, "thing", 3);
758 */
759private function f_ctrs_bsc_and_bts_expect(integer bts_nr, charstring countername, integer val := 1) runs on test_CT {
760 f_ctrs_bsc_and_bts_add(bts_nr, countername, val);
761 f_ctrs_bsc_and_bts_verify();
762}
763
764
765/* Convenience functions for rate counters using g_ctr_bsc. */
766
767private function f_ctrs_bsc_init(CounterNameVals counternames := counternames_bsc_bts_handover) runs on test_CT {
768 g_ctr_bsc := f_counter_name_vals_get_n(IPA_CTRL, "bsc", 1, counternames);
769 log("initial bsc rate counters: ", g_ctr_bsc);
770}
771
772private function f_ctrs_bsc_add(charstring countername, integer val := 1) runs on test_CT {
773 f_counter_name_vals_list_add(g_ctr_bsc, 0, countername, val);
774}
775
776/* f_ctrs_bsc_init();
777 * f_do_thing();
778 * f_do_thing();
779 * f_do_other();
780 * f_ctrs_bsc_add("thing", 2);
781 * f_ctrs_bsc_add("other");
782 * f_ctrs_bsc_verify();
783 */
784private function f_ctrs_bsc_verify() runs on test_CT {
785 f_counter_name_vals_expect_n(IPA_CTRL, "bsc", g_ctr_bsc);
786}
787
788/* convenience: f_ctrs_bsc_add() and f_ctrs_bsc_verify() in one call.
789 * f_ctrs_bsc_init();
790 * f_do_thing();
791 * f_ctrs_bsc_expect("thing", 1);
792 */
793private function f_ctrs_bsc_expect(charstring countername, integer val := 1) runs on test_CT {
794 f_ctrs_bsc_add(countername, val);
795 f_ctrs_bsc_verify();
796}
797
Neels Hofmeyr22c3f792020-06-17 02:49:28 +0200798
Philipp Maier282ca4b2018-02-27 17:17:00 +0100799private function f_shutdown_helper() runs on test_CT {
Daniel Willmann637ef6c2018-07-25 10:49:09 +0200800 all component.stop;
Philipp Maier282ca4b2018-02-27 17:17:00 +0100801 setverdict(pass);
Daniel Willmannafce8662018-07-06 23:11:32 +0200802 mtc.stop;
Philipp Maier282ca4b2018-02-27 17:17:00 +0100803}
804
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200805private function f_legacy_bssap_reset(integer bssap_idx := 0) runs on test_CT {
Harald Weltea4ca4462018-02-09 00:17:14 +0100806 var BSSAP_N_UNITDATA_ind ud_ind;
Pau Espin Pedrol24c05992020-09-01 12:54:12 +0200807 var boolean reset_received := false;
Harald Weltea4ca4462018-02-09 00:17:14 +0100808 timer T := 5.0;
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200809 BSSAP.send(ts_BSSAP_UNITDATA_req(g_bssap[bssap_idx].sccp_addr_peer, g_bssap[bssap_idx].sccp_addr_own,
810 ts_BSSMAP_Reset(0, g_osmux_enabled)));
Harald Weltea4ca4462018-02-09 00:17:14 +0100811 T.start;
812 alt {
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200813 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(g_bssap[bssap_idx].sccp_addr_own, g_bssap[bssap_idx].sccp_addr_peer,
814 tr_BSSMAP_ResetAck(g_osmux_enabled))) {
Neels Hofmeyr4f5d7be2020-10-16 16:28:16 +0200815 log("BSSMAP: Received RESET-ACK in response to RESET, we're ready to go!");
Harald Weltea4ca4462018-02-09 00:17:14 +0100816 }
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200817 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset(g_osmux_enabled))) -> value ud_ind {
Neels Hofmeyr4f5d7be2020-10-16 16:28:16 +0200818 log("BSSMAP: Respoding to inbound RESET with RESET-ACK");
Harald Weltea4ca4462018-02-09 00:17:14 +0100819 BSSAP.send(ts_BSSAP_UNITDATA_req(ud_ind.callingAddress, ud_ind.calledAddress,
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200820 ts_BSSMAP_ResetAck(g_osmux_enabled)));
Pau Espin Pedrol24c05992020-09-01 12:54:12 +0200821 reset_received := true;
Harald Weltea4ca4462018-02-09 00:17:14 +0100822 repeat;
823 }
824 [] BSSAP.receive { repeat; }
Pau Espin Pedrol24c05992020-09-01 12:54:12 +0200825 [] T.timeout {
Neels Hofmeyr4f5d7be2020-10-16 16:28:16 +0200826 log("BSSMAP: Timeout waiting for RESET-ACK after sending RESET");
Pau Espin Pedrol24c05992020-09-01 12:54:12 +0200827 /* If we received a RESET after ours was sent, it
828 may be a race condition where the other peer beacame
829 available after we sent it, but we are in a desired
830 state anyway, so go forward. */
831 if (not reset_received) {
832 setverdict(fail);
833 }
834 }
Harald Weltea4ca4462018-02-09 00:17:14 +0100835 }
Harald Welte28d943e2017-11-25 15:00:50 +0100836}
837
Harald Welteae026692017-12-09 01:03:01 +0100838type record IPA_Client {
Harald Welte21b46bd2017-12-17 19:46:32 +0100839 /* IPA Emulation component reference */
Harald Welteae026692017-12-09 01:03:01 +0100840 IPA_Emulation_CT vc_IPA,
Harald Welte21b46bd2017-12-17 19:46:32 +0100841 /* Unit-ID and other CCM parameters to use for IPA client emulation */
Harald Welteae026692017-12-09 01:03:01 +0100842 IPA_CCM_Parameters ccm_pars,
Harald Welte21b46bd2017-12-17 19:46:32 +0100843 /* String identifier for this IPA Client */
Harald Welte624f9632017-12-16 19:26:04 +0100844 charstring id,
Harald Welte21b46bd2017-12-17 19:46:32 +0100845 /* Associated RSL Emulation Component (if any). Only used in "Handler mode" */
Harald Welte624f9632017-12-16 19:26:04 +0100846 RSL_Emulation_CT vc_RSL optional
Harald Welte28d943e2017-11-25 15:00:50 +0100847}
848
Harald Welte21b46bd2017-12-17 19:46:32 +0100849/*! Start the IPA/RSL related bits for one IPA_Client.
850 * \param clnt IPA_Client for which to establish
851 * \param bsc_host IP address / hostname of the BSC
852 * \param bsc_port TCP port number of the BSC
853 * \param i number identifying this BTS
854 * \param handler_mode Start an RSL_Emulation_CT component (true) or not (false) */
Harald Welte624f9632017-12-16 19:26:04 +0100855function f_ipa_rsl_start(inout IPA_Client clnt, charstring bsc_host, PortNumber bsc_port, integer i,
856 boolean handler_mode := false)
Harald Welte28d943e2017-11-25 15:00:50 +0100857runs on test_CT {
Harald Welteae026692017-12-09 01:03:01 +0100858 timer T := 10.0;
859
Harald Welte96c94412017-12-09 03:12:45 +0100860 clnt.id := "IPA" & int2str(i) & "-RSL";
Harald Welteae026692017-12-09 01:03:01 +0100861 clnt.vc_IPA := IPA_Emulation_CT.create(clnt.id & "-IPA");
862 clnt.ccm_pars := c_IPA_default_ccm_pars;
863 clnt.ccm_pars.name := "Osmocom TTCN-3 BTS Simulator";
864 clnt.ccm_pars.unit_id := int2str(1234+i) & "/0/0";
Harald Welte624f9632017-12-16 19:26:04 +0100865 if (handler_mode) {
866 clnt.vc_RSL := RSL_Emulation_CT.create(clnt.id & "-RSL");
Harald Welte89ab1912018-02-23 18:56:29 +0100867 connect(clnt.vc_RSL:CCHAN_PT, self:RSL_CCHAN[i]);
Harald Welte624f9632017-12-16 19:26:04 +0100868 }
Harald Welteae026692017-12-09 01:03:01 +0100869
870 map(clnt.vc_IPA:IPA_PORT, system:IPA_CODEC_PT);
Harald Welte624f9632017-12-16 19:26:04 +0100871 if (handler_mode) {
872 connect(clnt.vc_IPA:IPA_RSL_PORT, clnt.vc_RSL:IPA_PT);
873 } else {
874 connect(clnt.vc_IPA:IPA_RSL_PORT, self:IPA_RSL[i]);
875 }
Harald Welteae026692017-12-09 01:03:01 +0100876
Harald Welte5d1a2202017-12-13 19:51:29 +0100877 clnt.vc_IPA.start(IPA_Emulation.main_client(bsc_host, bsc_port, "", 10000+i, clnt.ccm_pars));
Harald Welte624f9632017-12-16 19:26:04 +0100878 if (handler_mode) {
879 clnt.vc_RSL.start(RSL_Emulation.main());
880 return;
881 }
Harald Welteae026692017-12-09 01:03:01 +0100882
883 /* wait for IPA RSL link to connect and send ID ACK */
884 T.start;
885 alt {
Vadim Yanitskiya2afacc2020-05-18 21:16:19 +0700886 [] IPA_RSL[i].receive(tr_ASP_IPA_EV(ASP_IPA_EVENT_ID_ACK)) {
Harald Welteae026692017-12-09 01:03:01 +0100887 T.stop;
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +0700888 IPA_RSL[i].send(ts_ASP_RSL_UD(ts_RSL_PAGING_LOAD_IND(23)));
Harald Welteae026692017-12-09 01:03:01 +0100889 }
Harald Welte60e823a2017-12-10 14:10:59 +0100890 [] IPA_RSL[i].receive(ASP_IPA_Event:?) { repeat }
Harald Welteae026692017-12-09 01:03:01 +0100891 [] IPA_RSL[i].receive { repeat }
892 [] T.timeout {
Harald Welte96c94412017-12-09 03:12:45 +0100893 setverdict(fail, "Timeout RSL waiting for ASP_IPA_EVENT_ID_ACK");
Daniel Willmannafce8662018-07-06 23:11:32 +0200894 mtc.stop;
Harald Welteae026692017-12-09 01:03:01 +0100895 }
896 }
897}
898
Harald Welte12055472018-03-17 20:10:08 +0100899function f_ipa_rsl_stop(inout IPA_Client clnt) runs on test_CT {
900 if (not isbound(clnt) or not isbound(clnt.vc_IPA)) {
901 return;
902 }
903 clnt.vc_IPA.stop;
904 if (isbound(clnt.vc_RSL)) {
905 clnt.vc_RSL.stop;
906 }
907}
908
Harald Welte21b46bd2017-12-17 19:46:32 +0100909/* Wait for the OML connection to be brought up by the external osmo-bts-omldummy */
Harald Weltea5d2ab22017-12-09 14:21:42 +0100910function f_wait_oml(integer bts_nr, charstring status, float secs_max) runs on test_CT {
911 timer T := secs_max;
912 T.start;
913 while (true) {
914 if (f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-connection-state") == status) {
915 T.stop;
Harald Weltebd868bd2017-12-10 18:28:40 +0100916 /* the 'degraded' state exists from OML connection time, and we have to wait
917 * until all MO's are initialized */
918 T.start(1.0);
919 T.timeout;
Harald Weltea5d2ab22017-12-09 14:21:42 +0100920 return;
921 }
Harald Weltef0d6ac62017-12-17 17:02:21 +0100922 f_sleep(0.1);
Harald Weltea5d2ab22017-12-09 14:21:42 +0100923 if (not T.running) {
Max99253902018-11-16 17:57:39 +0100924 setverdict(fail, "Timeout waiting for BTS" & int2str(bts_nr) & " oml-connection-state ", status);
Daniel Willmannafce8662018-07-06 23:11:32 +0200925 mtc.stop;
Harald Weltea5d2ab22017-12-09 14:21:42 +0100926 }
927 }
928}
929
Harald Welte21b46bd2017-12-17 19:46:32 +0100930/* global altstep for global guard timer; also takes care of responding RESET witH RESET-ACK */
Harald Welteae026692017-12-09 01:03:01 +0100931altstep as_Tguard() runs on test_CT {
Harald Welte60e823a2017-12-10 14:10:59 +0100932 var BSSAP_N_UNITDATA_ind ud_ind;
Neels Hofmeyrcc3f76a2018-03-12 01:43:25 +0100933 [] T_guard.timeout {
934 setverdict(fail, "Timeout of T_guard");
Daniel Willmannafce8662018-07-06 23:11:32 +0200935 mtc.stop;
Neels Hofmeyrcc3f76a2018-03-12 01:43:25 +0100936 }
Harald Welte60e823a2017-12-10 14:10:59 +0100937 /* always respond with RESET ACK to RESET */
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200938 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset(g_osmux_enabled))) -> value ud_ind {
Harald Welte60e823a2017-12-10 14:10:59 +0100939 BSSAP.send(ts_BSSAP_UNITDATA_req(ud_ind.callingAddress, ud_ind.calledAddress,
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200940 ts_BSSMAP_ResetAck(g_osmux_enabled)));
Harald Welte69c1c262017-12-13 21:02:08 +0100941 repeat;
Harald Welte60e823a2017-12-10 14:10:59 +0100942 }
Harald Welte28d943e2017-11-25 15:00:50 +0100943}
944
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +0100945altstep no_bssmap_reset() runs on test_CT {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200946 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset(g_osmux_enabled))) {
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +0100947 setverdict(fail, "unexpected BSSMAP Reset");
Daniel Willmannafce8662018-07-06 23:11:32 +0200948 mtc.stop;
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +0100949 }
950}
951
Daniel Willmann191e0d92018-01-17 12:44:35 +0100952function f_init_mgcp(charstring id) runs on test_CT {
953 id := id & "-MGCP";
954
955 var MGCPOps ops := {
956 create_cb := refers(MGCP_Emulation.ExpectedCreateCallback),
957 unitdata_cb := refers(MGCP_Emulation.DummyUnitdataCallback)
958 };
959 var MGCP_conn_parameters mgcp_pars := {
960 callagent_ip := mp_bsc_ip,
Harald Welte9e4273e2018-01-29 22:01:22 +0100961 callagent_udp_port := -1,
Daniel Willmann191e0d92018-01-17 12:44:35 +0100962 mgw_ip := mp_test_ip,
Pau Espin Pedrol1a026a52019-06-18 17:21:52 +0200963 mgw_udp_port := 2427,
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +0200964 /* Enable it for SCCPlite, since we have 2 MGCP sockets towards MGW (UDP one +
965 the on with MGCP over IPA forwarded from MSC one) */
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200966 multi_conn_mode := (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_SCCPlite_SERVER)
Daniel Willmann191e0d92018-01-17 12:44:35 +0100967 };
968
969 vc_MGCP := MGCP_Emulation_CT.create(id);
970 vc_MGCP.start(MGCP_Emulation.main(ops, mgcp_pars, id));
971}
972
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200973/* Enable or disable (current default) Osmux. When enabling, BSSMAP Reset
974 * contains extra IE (OsmuxSupport) and osmo-bsc will handle AssignReq with
975 * OsmuxCID IE.
976 */
977private function f_vty_allow_osmux(boolean allow) runs on test_CT {
978 f_vty_enter_cfg_msc(BSCVTY, 0);
979 if (allow) {
980 f_vty_transceive(BSCVTY, "osmux on");
981 } else {
982 f_vty_transceive(BSCVTY, "osmux off");
983 }
984 f_vty_transceive(BSCVTY, "exit");
985 f_vty_transceive(BSCVTY, "exit");
986 g_osmux_enabled := allow;
987}
988
Max2253c0b2018-11-06 19:28:05 +0100989function f_init_vty(charstring id := "foo") runs on test_CT {
Harald Welte94e0c342018-04-07 11:33:23 +0200990 if (BSCVTY.checkstate("Mapped")) {
991 /* skip initialization if already executed once */
992 return;
993 }
Harald Weltebc03c762018-02-12 18:09:38 +0100994 map(self:BSCVTY, system:BSCVTY);
995 f_vty_set_prompts(BSCVTY);
996 f_vty_transceive(BSCVTY, "enable");
Pau Espin Pedrolc675b612020-01-09 19:55:40 +0100997 f_cs7_inst_0_cfg(BSCVTY, {"sccp-timer ias " & int2str(g_bsc_sccp_timer_ias),
998 "sccp-timer iar " & int2str(g_bsc_sccp_timer_iar)});
Harald Weltebc03c762018-02-12 18:09:38 +0100999}
1000
Neels Hofmeyr767548a2020-08-09 20:26:07 +00001001private function f_logp(TELNETasp_PT pt, charstring log_msg)
Neels Hofmeyr4f118412020-06-04 15:25:10 +02001002{
1003 // log on TTCN3 log output
1004 log(log_msg);
1005 // log in stderr log
Neels Hofmeyr767548a2020-08-09 20:26:07 +00001006 f_vty_transceive(pt, "logp lglobal notice TTCN3 f_logp(): " & log_msg);
Neels Hofmeyr4f118412020-06-04 15:25:10 +02001007}
1008
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02001009private function f_sysinfo_seen(integer rsl_idx, RSL_Message rsl) runs on test_CT
1010{
1011 if (rsl_idx >= lengthof(g_system_information)) {
1012 g_system_information[rsl_idx] := SystemInformationConfig_omit
1013 }
1014 f_sysinfo_dec_raw(g_system_information[rsl_idx], rsl);
1015}
1016
1017altstep as_catch_RSL_sysinfo(integer rsl_idx) runs on test_CT {
1018 var ASP_RSL_Unitdata rx_rsl_ud;
1019
1020 /* For handler_mode := false, receiving the RSL bootstrap messages directly on IPA_RSL */
1021 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_NO_BCCH_INFO)) -> value rx_rsl_ud {
1022 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1023 repeat;
1024 }
1025 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_BCCH_INFO)) -> value rx_rsl_ud {
1026 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1027 repeat;
1028 }
1029 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_NO_SACCH_FILL)) -> value rx_rsl_ud {
1030 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1031 repeat;
1032 }
1033 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_SACCH_FILL)) -> value rx_rsl_ud {
1034 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1035 repeat;
1036 }
1037
1038 /* For handler_mode := true, receiving the RSL bootstrap messages via RSL_Emulation */
1039 [] RSL_CCHAN[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_NO_BCCH_INFO)) -> value rx_rsl_ud {
1040 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1041 repeat;
1042 }
1043 [] RSL_CCHAN[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_BCCH_INFO)) -> value rx_rsl_ud {
1044 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1045 repeat;
1046 }
1047 [] RSL_CCHAN[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_NO_SACCH_FILL)) -> value rx_rsl_ud {
1048 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1049 repeat;
1050 }
1051 [] RSL_CCHAN[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_SACCH_FILL)) -> value rx_rsl_ud {
1052 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1053 repeat;
1054 }
1055}
1056
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001057/* TODO: use BooleanList from COMMON/src/General_Types.ttcn */
1058private type record of boolean my_BooleanList;
1059
1060private function f_vty_msc_allow_attach(TELNETasp_PT pt, my_BooleanList allow_attach_list)
1061{
Neels Hofmeyr8f576712020-08-12 22:49:53 +00001062 var charstring config := f_vty_transceive_ret(pt, "show running-config");
1063
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001064 for (var integer msc_nr := 0; msc_nr < sizeof(allow_attach_list); msc_nr := msc_nr+1) {
Neels Hofmeyr8f576712020-08-12 22:49:53 +00001065 if (f_strstr(config, "\nmsc " & int2str(msc_nr) & "\n") < 0) {
1066 /* There is no 'msc N' for this msc_nr in the running config, so don't create an empty msc by
1067 * stepping into that config node. */
1068 log("msc ", msc_nr, " is not configured, skipping");
1069 continue;
1070 }
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001071 f_vty_enter_cfg_msc(pt, msc_nr);
1072 if (allow_attach_list[msc_nr]) {
1073 /* strict := false: ignore if osmo-bsc does not support this config option (latest build) */
1074 f_vty_transceive(pt, "allow-attach", strict := false);
1075 } else {
1076 f_vty_transceive(pt, "no allow-attach", strict := false);
1077 }
1078 f_vty_transceive(pt, "exit");
1079 f_vty_transceive(pt, "exit");
1080 }
1081}
1082
Harald Welte21b46bd2017-12-17 19:46:32 +01001083/* global initialization function
1084 * \param nr_bts Number of BTSs we should start/bring up
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001085 * \param handler_mode Start an RSL_Emulation_CT component (true) or not (false).
1086 * \param nr_msc Number of virtual MSCs to bring up to connect to osmo-bsc.
1087 */
1088function f_init(integer nr_bts := NUM_BTS, boolean handler_mode := false, boolean allow_osmux := false,
Neels Hofmeyr4fbad7f2020-06-16 00:30:47 +02001089 integer nr_msc := 1, float guard_timeout := 30.0) runs on test_CT {
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001090 var integer bssap_idx;
Harald Welte28d943e2017-11-25 15:00:50 +01001091
Harald Welteae026692017-12-09 01:03:01 +01001092 if (g_initialized) {
1093 return;
Harald Welte28d943e2017-11-25 15:00:50 +01001094 }
Harald Welteae026692017-12-09 01:03:01 +01001095 g_initialized := true;
1096
Neels Hofmeyr4fbad7f2020-06-16 00:30:47 +02001097 T_guard.start(guard_timeout);
Daniel Willmanne68f9272018-11-27 15:15:28 +01001098 activate(as_Tguard());
1099
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001100 f_init_vty("VirtMSC");
Pau Espin Pedrol58cf6822019-05-28 18:11:33 +02001101 if (mp_enable_osmux_test) {
1102 f_vty_allow_osmux(allow_osmux);
1103 }
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001104
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001105 var my_BooleanList allow_attach := { false, false, false };
Daniel Willmannebdecc02020-08-12 15:30:17 +02001106 f_init_statsd("VirtMSC", vc_STATSD, mp_test_ip, mp_bsc_statsd_port);
1107
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001108 for (bssap_idx := 0; bssap_idx < nr_msc; bssap_idx := bssap_idx+1) {
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001109 allow_attach[bssap_idx] := true;
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001110 /* Call a function of our 'parent component' RAN_Adapter_CT to start the
1111 * MSC-side BSSAP emulation */
1112 if (handler_mode) {
1113 var RanOps ranops := MSC_RanOps;
1114 ranops.use_osmux := g_osmux_enabled;
1115 f_ran_adapter_init(g_bssap[bssap_idx], mp_bssap_cfg[bssap_idx], "VirtMSC", ranops);
1116 connect(self:SCCPLITE_IPA_CTRL, g_bssap[bssap_idx].vc_RAN:CTRL_CLIENT);
1117 f_ran_adapter_start(g_bssap[bssap_idx]);
1118 } else {
1119 f_ran_adapter_init(g_bssap[bssap_idx], mp_bssap_cfg[bssap_idx], "VirtMSC", omit);
1120 connect(self:BSSAP, g_bssap[bssap_idx].vc_SCCP:SCCP_SP_PORT);
1121 f_ran_adapter_start(g_bssap[bssap_idx]);
1122 f_legacy_bssap_reset();
1123 }
Harald Welte67089ee2018-01-17 22:19:03 +01001124 }
Harald Welted5833a82018-05-27 16:52:56 +02001125
Neels Hofmeyrcfe44062020-10-15 02:28:08 +02001126 if (mp_enable_lcs_tests) {
1127 if (handler_mode) {
1128 f_bssap_le_adapter_init(g_bssap_le, mp_bssap_le_cfg, "VirtSMLC", SMLC_BssapLeOps);
1129 } else {
1130 f_bssap_le_adapter_init(g_bssap_le, mp_bssap_le_cfg, "VirtSMLC", omit);
1131 connect(self:BSSAP_LE, g_bssap_le.vc_SCCP:SCCP_SP_PORT);
1132 }
1133 f_bssap_le_adapter_start(g_bssap_le);
Harald Welte47cd0e32020-08-21 12:39:11 +02001134 }
Harald Welte47cd0e32020-08-21 12:39:11 +02001135
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001136 /* start the test with exactly all enabled MSCs allowed to attach */
1137 f_vty_msc_allow_attach(BSCVTY, allow_attach);
1138
Pau Espin Pedrol9a5b8ff2021-01-04 19:01:31 +01001139 f_ipa_ctrl_start_client(mp_bsc_ip, mp_bsc_ctrl_port);
Harald Welte28d943e2017-11-25 15:00:50 +01001140
Daniel Willmann191e0d92018-01-17 12:44:35 +01001141 f_init_mgcp("VirtMSC");
1142
Neels Hofmeyr0b7365b2020-07-04 00:52:34 +02001143 for (var integer i := 0; i < nr_bts; i := i+1) {
1144 f_init_bts(i, handler_mode);
Harald Welte696ddb62017-12-08 14:01:43 +01001145 }
Neels Hofmeyr0b7365b2020-07-04 00:52:34 +02001146}
Harald Welte696ddb62017-12-08 14:01:43 +01001147
Neels Hofmeyr0b7365b2020-07-04 00:52:34 +02001148function f_init_bts(integer bts_idx := 0, boolean handler_mode := false)
1149runs on test_CT {
1150 /* wait until osmo-bts-omldummy has respawned */
1151 f_wait_oml(bts_idx, "degraded", 5.0);
1152
1153 /* start RSL connection */
1154 f_ipa_rsl_start(bts[bts_idx].rsl, mp_bsc_ip, mp_bsc_rsl_port, bts_idx, handler_mode);
1155 /* wait until BSC tells us "connected" */
1156 f_wait_oml(bts_idx, "connected", 5.0);
Harald Welte28d943e2017-11-25 15:00:50 +01001157}
1158
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02001159function f_init_bts_and_check_sysinfo(integer bts_idx := 0, boolean handler_mode := false,
1160 template SystemInformationConfig expect_si)
1161runs on test_CT {
1162 var default sysinfo := activate(as_catch_RSL_sysinfo(bts_idx));
1163
1164 f_init_bts(bts_idx, handler_mode);
1165
1166 /* Give some time to (hopefully/most likely) collect all system informations from RSL startup.
1167 * We could stop as soon as all expected SI are received, but then we might miss SI that we don't expect and
1168 * that might be sent afterwards. So rather give a generous timeout and be quite sure to catch all SI.
1169 */
1170 f_sleep(5.0);
1171 log("RSL ", bts_idx, " SYSTEM INFORMATION: ", g_system_information[bts_idx]);
1172
1173 deactivate(sysinfo);
1174
1175 if (match(g_system_information[bts_idx], expect_si)) {
1176 setverdict(pass);
1177 } else {
1178 log("RSL ", bts_idx, ": EXPECTED SI: ", expect_si);
1179 log("RSL ", bts_idx, ": GOT SI: ", g_system_information[bts_idx]);
1180 setverdict(fail, "received SI does not match expectations");
1181 return;
1182 }
1183}
1184
Maxd4e56962018-10-31 19:08:25 +01001185/* expect to receive a RSL message matching a specified template on a given BTS / stream */
Harald Welte65e419a2020-08-21 12:38:33 +02001186function f_exp_ipa_rx(integer bts_nr, template (present) RSL_Message t_rx, float t_secs := 2.0, IpaStreamId sid := IPAC_PROTO_RSL_TRX0)
Harald Welteae026692017-12-09 01:03:01 +01001187runs on test_CT return RSL_Message {
1188 var ASP_RSL_Unitdata rx_rsl_ud;
1189 timer T := t_secs;
1190
1191 T.start;
1192 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001193 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(t_rx, sid)) -> value rx_rsl_ud {
Harald Welteae026692017-12-09 01:03:01 +01001194 T.stop;
1195 }
1196 [] IPA_RSL[bts_nr].receive { repeat; }
Harald Welteb2917702017-12-10 15:48:52 +01001197 [] T.timeout {
1198 setverdict(fail, "Timeout expecting ", t_rx);
Daniel Willmannafce8662018-07-06 23:11:32 +02001199 mtc.stop;
Harald Welteb2917702017-12-10 15:48:52 +01001200 }
Harald Welteae026692017-12-09 01:03:01 +01001201 }
1202 return rx_rsl_ud.rsl;
1203}
1204
Harald Welte21b46bd2017-12-17 19:46:32 +01001205/* helper function to transmit RSL on a given BTS/stream */
Harald Welte65e419a2020-08-21 12:38:33 +02001206function f_ipa_tx(integer bts_nr, template (value) RSL_Message t_tx, IpaStreamId sid := IPAC_PROTO_RSL_TRX0)
Harald Welteae026692017-12-09 01:03:01 +01001207runs on test_CT {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001208 IPA_RSL[bts_nr].send(ts_ASP_RSL_UD(t_tx, sid));
Harald Welteae026692017-12-09 01:03:01 +01001209}
1210
1211
Harald Welte4003d112017-12-09 22:35:39 +01001212/* verify we get a CHAN_ACT after CHAN RQD */
Harald Welteae026692017-12-09 01:03:01 +01001213testcase TC_chan_act_noreply() runs on test_CT {
1214 var BSSAP_N_UNITDATA_ind ud_ind;
Harald Welte930d0a72018-03-22 22:08:40 +01001215 var RSL_Message rsl_unused;
Harald Welte28d943e2017-11-25 15:00:50 +01001216
Harald Welte89d42e82017-12-17 16:42:41 +01001217 f_init(1);
Harald Welte28d943e2017-11-25 15:00:50 +01001218
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001219 IPA_RSL[0].send(ts_ASP_RSL_UD(ts_RSL_CHAN_RQD('23'O, 23)));
Harald Welte930d0a72018-03-22 22:08:40 +01001220 rsl_unused := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001221 f_shutdown_helper();
Harald Welte28d943e2017-11-25 15:00:50 +01001222}
1223
Harald Welte4003d112017-12-09 22:35:39 +01001224/* verify if the "chreq:total" counter increments as expected */
1225testcase TC_chan_act_counter() runs on test_CT {
1226 var BSSAP_N_UNITDATA_ind ud_ind;
1227 var integer chreq_total;
Harald Welte930d0a72018-03-22 22:08:40 +01001228 var RSL_Message rsl_unused;
Harald Welte4003d112017-12-09 22:35:39 +01001229
Harald Welte89d42e82017-12-17 16:42:41 +01001230 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01001231
1232 chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total");
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001233 IPA_RSL[0].send(ts_ASP_RSL_UD(ts_RSL_CHAN_RQD('23'O, 23)));
Harald Welte930d0a72018-03-22 22:08:40 +01001234 rsl_unused := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
Harald Welte4003d112017-12-09 22:35:39 +01001235 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total", chreq_total+1);
1236
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001237 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01001238}
1239
Harald Welteae026692017-12-09 01:03:01 +01001240/* CHAN RQD -> CHAN ACT -> CHAN ACT ACK -> RF CHAN REL */
Philipp Maier9c60a622020-07-09 15:08:46 +02001241private function f_TC_chan_act_ack_noest(OCT1 ra := '23'O) runs on test_CT {
Harald Welteae026692017-12-09 01:03:01 +01001242 var RSL_Message rx_rsl;
1243
Harald Welteae026692017-12-09 01:03:01 +01001244 /* Send CHAN RQD and wait for allocation; acknowledge it */
Philipp Maier9c60a622020-07-09 15:08:46 +02001245 var RslChannelNr chan_nr := f_chreq_act_ack(ra);
Harald Welteae026692017-12-09 01:03:01 +01001246
1247 /* expect BSC to disable the channel again if there's no RLL EST IND */
1248 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX);
1249
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001250 f_shutdown_helper();
Harald Welteae026692017-12-09 01:03:01 +01001251}
1252
Philipp Maier9c60a622020-07-09 15:08:46 +02001253/* Normal variant */
1254testcase TC_chan_act_ack_noest() runs on test_CT {
Philipp Maieraf58db22020-08-12 17:24:40 +02001255 f_init(1);
Philipp Maier9c60a622020-07-09 15:08:46 +02001256 f_TC_chan_act_ack_noest();
1257}
1258
1259/* Emergency call variant */
1260testcase TC_chan_act_ack_noest_emerg() runs on test_CT {
1261 /* See also: 3GPP TS 04.08, Table 9.9, ra=101xxxxx */
Philipp Maieraf58db22020-08-12 17:24:40 +02001262 f_init(1);
1263 f_vty_allow_emerg_bts(true, 0);
Philipp Maier9c60a622020-07-09 15:08:46 +02001264 f_TC_chan_act_ack_noest(ra := 'A5'O);
1265}
1266
Philipp Maier606f07d2020-08-12 17:21:58 +02001267/* Emergency call variant, but emergency calls are not allowed */
1268testcase TC_chan_rqd_emerg_deny() runs on test_CT {
1269 /* See also: 3GPP TS 04.08, Table 9.9, ra=101xxxxx */
1270
1271 var RSL_Message rx_rsl;
1272 var GsmRrMessage rr;
1273
1274 f_init(1);
1275 f_vty_allow_emerg_bts(false, 0);
1276
1277 IPA_RSL[0].clear;
1278 f_ipa_tx(0, ts_RSL_CHAN_RQD('A5'O, 23));
1279
1280 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeC(RSL_MT_IMMEDIATE_ASSIGN_CMD));
1281 rr := dec_GsmRrMessage(rx_rsl.ies[1].body.full_imm_ass_info.payload);
1282 if (rr.header.message_type == IMMEDIATE_ASSIGNMENT_REJECT) {
1283 setverdict(pass);
1284 } else {
1285 setverdict(fail, "immediate assignment not rejected");
1286 }
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01001287
1288 f_shutdown_helper();
Philipp Maier606f07d2020-08-12 17:21:58 +02001289}
1290
Harald Welteae026692017-12-09 01:03:01 +01001291/* Test behavior if MSC never answers to CR */
1292testcase TC_chan_act_ack_est_ind_noreply() runs on test_CT {
Harald Weltef77aef62018-01-28 15:35:42 +01001293 var RslLinkId main_dcch := valueof(ts_RslLinkID_DCCH(0));
1294 var IpaStreamId sid := IPAC_PROTO_RSL_TRX0;
Harald Welteae026692017-12-09 01:03:01 +01001295 var RSL_Message rx_rsl;
Harald Weltef77aef62018-01-28 15:35:42 +01001296 var ASP_RSL_Unitdata rx_rsl_ud;
Harald Welteae026692017-12-09 01:03:01 +01001297
Harald Welte89d42e82017-12-17 16:42:41 +01001298 f_init(1);
Harald Welteae026692017-12-09 01:03:01 +01001299
1300 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +01001301 var RslChannelNr chan_nr := f_chreq_act_ack();
Harald Welteae026692017-12-09 01:03:01 +01001302
1303 var octetstring l3 := '00010203040506'O
1304 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
1305
1306 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3)));
1307
1308 /* expect BSC to disable the channel again if there's no response from MSC */
Harald Weltef77aef62018-01-28 15:35:42 +01001309 /* MS waits 20s (T3210) at LU; 10s (T3230) at CM SERV REQ and 5s (T3220) AT detach */
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001310 f_expect_chan_rel(0, chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001311 f_shutdown_helper();
Harald Welteae026692017-12-09 01:03:01 +01001312}
1313
1314/* Test behavior if MSC answers with CREF to CR */
1315testcase TC_chan_act_ack_est_ind_refused() runs on test_CT {
1316 var BSSAP_N_CONNECT_ind rx_c_ind;
1317 var RSL_Message rx_rsl;
1318
Harald Welte89d42e82017-12-17 16:42:41 +01001319 f_init(1);
Harald Welteae026692017-12-09 01:03:01 +01001320
1321 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +01001322 var RslChannelNr chan_nr := f_chreq_act_ack();
Harald Welteae026692017-12-09 01:03:01 +01001323
1324 var octetstring l3 := '00010203040506'O
1325 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
1326
1327 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
1328 BSSAP.send(ts_BSSAP_DISC_req(rx_c_ind.connectionId, 0));
1329
1330 /* expect BSC to disable the channel */
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001331 f_expect_chan_rel(0, chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001332 f_shutdown_helper();
Harald Welteae026692017-12-09 01:03:01 +01001333}
1334
Harald Welte618ef642017-12-14 14:58:20 +01001335/* CHAN RQD -> CHAN ACT -> CHAN ACT NACK -> RF CHAN REL */
1336testcase TC_chan_act_nack() runs on test_CT {
1337 var RSL_Message rx_rsl;
1338 var integer chact_nack;
1339
Harald Welte89d42e82017-12-17 16:42:41 +01001340 f_init(1);
Harald Welte618ef642017-12-14 14:58:20 +01001341
1342 chact_nack := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chan_act:nack");
1343
1344 f_ipa_tx(0, ts_RSL_CHAN_RQD('33'O, 33));
1345 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
1346 var RslChannelNr chan_nr := rx_rsl.ies[0].body.chan_nr;
1347
1348 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, RSL_ERR_EQUIPMENT_FAIL));
1349
1350 /* wait for some time to hope the NACK arrives before the CTRL GET below */
1351 f_sleep(0.5);
1352
1353 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chan_act:nack", chact_nack+1);
1354
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001355 f_shutdown_helper();
Harald Welte618ef642017-12-14 14:58:20 +01001356}
1357
Harald Welte799c97b2017-12-14 17:50:30 +01001358/* Test for channel exhaustion due to RACH overload */
1359testcase TC_chan_exhaustion() runs on test_CT {
1360 var ASP_RSL_Unitdata rsl_ud;
1361 var integer i;
1362 var integer chreq_total, chreq_nochan;
1363
Harald Welte89d42e82017-12-17 16:42:41 +01001364 f_init(1);
Harald Welte799c97b2017-12-14 17:50:30 +01001365
1366 chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total");
1367 chreq_nochan := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel");
1368
Pau Espin Pedrolfe200d72018-12-10 12:41:04 +01001369 /* GSM 04.08 Table 9.9a:
1370 * RA = '33'O -> Establishment cause = 0011xxxx (MS dual rate capable and asks for "TCH/H or TCH/F").
1371 * With current setup, expect 4xSDCCH + 4xTCH/F + 1xTCH/H to succeed */
Philipp Maiercb6cc482018-03-26 13:08:00 +02001372 for (i := 0; i < NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS; i := i+1) {
Pau Espin Pedrolfe200d72018-12-10 12:41:04 +01001373 var RslChannelNr chan_nr := f_chreq_act_ack('33'O, i);
Harald Welte799c97b2017-12-14 17:50:30 +01001374 }
1375
1376 IPA_RSL[0].clear;
1377
Harald Weltedd8cbf32018-01-28 12:07:52 +01001378 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total",
Philipp Maiercb6cc482018-03-26 13:08:00 +02001379 chreq_total + NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS);
Harald Welte799c97b2017-12-14 17:50:30 +01001380
1381 /* now expect additional channel activations to fail */
1382 f_ipa_tx(0, ts_RSL_CHAN_RQD('42'O, 42));
1383
1384 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001385 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV))) {
Harald Welte799c97b2017-12-14 17:50:30 +01001386 setverdict(fail, "Received CHAN ACT ACK without resources?!?");
1387 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001388 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_IMM_ASSIGN(?))) -> value rsl_ud {
Harald Welte799c97b2017-12-14 17:50:30 +01001389 var GsmRrMessage rr;
1390 /* match on IMM ASS REJ */
1391 rr := dec_GsmRrMessage(rsl_ud.rsl.ies[1].body.full_imm_ass_info.payload);
1392 if (rr.header.message_type == IMMEDIATE_ASSIGNMENT_REJECT) {
1393 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total",
Philipp Maiercb6cc482018-03-26 13:08:00 +02001394 chreq_total + NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS+1);
Harald Welte799c97b2017-12-14 17:50:30 +01001395 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel",
1396 chreq_nochan+1);
1397 setverdict(pass);
1398 } else {
1399 repeat;
1400 }
1401 }
1402 [] IPA_RSL[0].receive { repeat; }
1403 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001404 f_shutdown_helper();
Harald Welte799c97b2017-12-14 17:50:30 +01001405}
1406
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07001407/* Test channel deactivation due to silence from MS */
1408testcase TC_chan_deact_silence() runs on test_CT {
1409 var RslChannelNr chan_nr;
1410
1411 f_init(1);
1412
1413 /* Request for a dedicated channel */
1414 chan_nr := f_chreq_act_ack('23'O);
1415
1416 /* Wait some time until the channel is released */
1417 f_sleep(2.0);
1418
1419 /* Expect CHANnel RELease */
1420 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001421 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL))) {
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07001422 log("Received CHANnel RELease");
1423 setverdict(pass);
1424 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001425 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_IMM_ASSIGN(?))) {
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07001426 /* See OS#3709, OsmoBSC should not send Immediate
1427 * Assignment Reject since a dedicated channel was
1428 * already allocated, and Immediate Assignment was
1429 * already sent. */
1430 setverdict(fail, "Unexpected Immediate Assignment!");
1431 }
1432 [] IPA_RSL[0].receive {
1433 setverdict(fail, "Unexpected RSL message!");
1434 }
1435 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001436 f_shutdown_helper();
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07001437}
1438
Harald Weltecfe2c962017-12-15 12:09:32 +01001439/***********************************************************************
1440 * Assignment Testing
1441 ***********************************************************************/
1442
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02001443/* Verify that the BSC refuses any BSSAP connection from the MSC (They are all BSC->MSC direction,
1444 * except for the inter-BSC handover, MT side) */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001445testcase TC_outbound_connect(integer bssap_idx := 0) runs on test_CT {
Harald Welte89d42e82017-12-17 16:42:41 +01001446 f_init(1);
Harald Weltecfe2c962017-12-15 12:09:32 +01001447
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001448 BSSAP.send(ts_BSSAP_CONNECT_req(g_bssap[bssap_idx].sccp_addr_peer, g_bssap[bssap_idx].sccp_addr_own,
1449 2342, ts_BSSMAP_AssignmentReq));
Harald Weltecfe2c962017-12-15 12:09:32 +01001450 BSSAP.receive(tr_BSSAP_DISC_ind(2342, ?, ?));
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001451 f_shutdown_helper();
Harald Weltecfe2c962017-12-15 12:09:32 +01001452}
1453
Harald Welte16a4adf2017-12-14 18:54:01 +01001454/* Test behavior if MSC answers with CREF to CR */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001455testcase TC_assignment_cic_only(integer bssap_idx := 0) runs on test_CT {
Harald Welte16a4adf2017-12-14 18:54:01 +01001456 var BSSAP_N_CONNECT_ind rx_c_ind;
1457 var RSL_Message rx_rsl;
1458 var DchanTuple dt;
1459
Harald Welte89d42e82017-12-17 16:42:41 +01001460 f_init(1);
Harald Welte16a4adf2017-12-14 18:54:01 +01001461
1462 dt := f_est_dchan('23'O, 23, '00000000'O);
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001463 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welte17b27da2018-05-25 20:33:53 +02001464 /* send assignment without AoIP IEs */
1465 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_AssignmentReq(ts_BSSMAP_IE_CIC(0, 1))));
1466 } else {
1467 /* Send assignmetn without CIC in IPA case */
1468 var BSSMAP_IE_AoIP_TransportLayerAddress tla :=
1469 valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342));
1470 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_AssignmentReq(omit, tla)));
1471 }
Harald Welte16a4adf2017-12-14 18:54:01 +01001472 alt {
1473 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentComplete)) {
1474 setverdict(fail, "AoIP BSC cannot accept ASSIGNMENT without AoIP Transport IE");
1475 }
Harald Welte235ebf12017-12-15 14:18:16 +01001476 /* TODO: Actually expect GSM0808_CAUSE_REQ_A_IF_TYPE_NOT_SUPP */
Harald Welte16a4adf2017-12-14 18:54:01 +01001477 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentFail)) {
1478 setverdict(pass);
1479 }
1480 [] BSSAP.receive { repeat; }
1481 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001482 f_shutdown_helper();
Harald Welte16a4adf2017-12-14 18:54:01 +01001483}
1484
Harald Welteed848512018-05-24 22:27:58 +02001485/* generate an assignment request for either AoIP or SCCPlite */
Pau Espin Pedrol07866632020-09-03 19:10:55 +02001486function f_gen_ass_req(boolean osmux_enabled := false, integer bssap_idx := 0, charstring aoip_tla := "1.2.3.4") return PDU_BSSAP {
Harald Welteed848512018-05-24 22:27:58 +02001487 var PDU_BSSAP ass_cmd;
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001488 var BSSMAP_IE_Osmo_OsmuxCID osmux_cid := valueof(ts_OsmuxCID(0));
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001489 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welteed848512018-05-24 22:27:58 +02001490 var BSSMAP_IE_AoIP_TransportLayerAddress tla :=
Pau Espin Pedrol07866632020-09-03 19:10:55 +02001491 valueof(f_ts_BSSMAP_IE_AoIP_TLA(aoip_tla, 2342));
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001492 if (osmux_enabled) {
1493 ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla, osmux_cid));
1494 } else {
1495 ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla));
1496 }
Harald Welteed848512018-05-24 22:27:58 +02001497 } else {
1498 var BSSMAP_IE_CircuitIdentityCode cic := valueof(ts_BSSMAP_IE_CIC(0,1));
Pau Espin Pedrol096d73d2019-06-06 12:49:17 +02001499 ass_cmd := valueof(ts_BSSMAP_AssignmentReq(cic, omit));
Harald Welteed848512018-05-24 22:27:58 +02001500 }
1501 return ass_cmd;
1502}
1503
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02001504function f_gen_handover_req(integer bssap_idx := 0, charstring aoip_tla := "1.2.3.4",
1505 template (omit) BSSMAP_oldToNewBSSIEs oldToNewBSSIEs := omit) return PDU_BSSAP {
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01001506 var PDU_BSSAP ho_req;
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001507 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01001508 var BSSMAP_IE_AoIP_TransportLayerAddress tla :=
Pau Espin Pedrol07866632020-09-03 19:10:55 +02001509 valueof(f_ts_BSSMAP_IE_AoIP_TLA(aoip_tla, 2342));
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02001510 ho_req := valueof(ts_BSSMAP_HandoverRequest(omit, tla, oldToNewBSSIEs := oldToNewBSSIEs));
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01001511 } else {
1512 var BSSMAP_IE_CircuitIdentityCode cic := valueof(ts_BSSMAP_IE_CIC(0,1));
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02001513 ho_req := valueof(ts_BSSMAP_HandoverRequest(cic, omit, oldToNewBSSIEs := oldToNewBSSIEs));
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01001514 }
1515 return ho_req;
1516}
1517
Harald Welteed848512018-05-24 22:27:58 +02001518/* generate an assignment complete template for either AoIP or SCCPlite */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001519function f_gen_exp_compl(boolean expect_osmux := false, integer bssap_idx := 0) return template PDU_BSSAP {
Harald Welteed848512018-05-24 22:27:58 +02001520 var template PDU_BSSAP exp_compl;
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001521 var BSSMAP_IE_Osmo_OsmuxCID osmux_cid := valueof(ts_OsmuxCID(0));
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001522 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001523 if (expect_osmux) {
1524 exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?, osmux_cid);
1525 } else {
1526 exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?, omit);
1527 }
Harald Welteed848512018-05-24 22:27:58 +02001528 } else {
1529 /* CIC is optional "*" as the MSC allocated it */
Pau Espin Pedrol096d73d2019-06-06 12:49:17 +02001530 exp_compl := tr_BSSMAP_AssignmentComplete(*, omit);
Harald Welteed848512018-05-24 22:27:58 +02001531 }
1532 return exp_compl;
1533}
1534
Harald Welte235ebf12017-12-15 14:18:16 +01001535/* Run everything required up to sending a caller-specified assignment command and expect response */
1536function f_assignment_exp(PDU_BSSAP ass_cmd, template PDU_BSSAP exp, charstring fail_text)
1537runs on test_CT {
1538 var BSSAP_N_CONNECT_ind rx_c_ind;
1539 var RSL_Message rx_rsl;
1540 var DchanTuple dt;
1541
Harald Welte89d42e82017-12-17 16:42:41 +01001542 f_init(1);
Harald Welte235ebf12017-12-15 14:18:16 +01001543
1544 dt := f_est_dchan('23'O, 23, '00000000'O);
1545 /* send assignment without AoIP IEs */
1546 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ass_cmd));
1547 alt {
1548 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentComplete)) {
1549 if (ischosen(exp.pdu.bssmap.assignmentComplete)) {
1550 setverdict(pass);
1551 } else {
1552 setverdict(fail, fail_text);
1553 }
1554 }
1555 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentFail)) {
1556 if (ischosen(exp.pdu.bssmap.assignmentFailure)) {
1557 setverdict(pass);
1558 } else {
1559 setverdict(fail, fail_text);
1560 }
1561 }
1562 [] BSSAP.receive { repeat; }
1563 }
1564}
1565testcase TC_assignment_csd() runs on test_CT {
1566 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +02001567 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte235ebf12017-12-15 14:18:16 +01001568 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeCSD);
1569 //exp_fail.pdu.bssmap.assignmentFailure.cause.causeValue := int2bit(enum2int(GSM0808_CAUSE_REQ_CODEC_TYPE_OR_CONFIG_UNAVAIL), 7);
1570 f_assignment_exp(ass_cmd, exp_fail, "BSC accepted Assignment for CSD");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001571 f_shutdown_helper();
Harald Welte235ebf12017-12-15 14:18:16 +01001572}
1573
1574testcase TC_assignment_ctm() runs on test_CT {
1575 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +02001576 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte235ebf12017-12-15 14:18:16 +01001577 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeCTM);
1578 //exp_fail.pdu.bssmap.assignmentFailure.cause.causeValue := int2bit(enum2int(GSM0808_CAUSE_REQ_CODEC_TYPE_OR_CONFIG_UNAVAIL), 7);
1579 f_assignment_exp(ass_cmd, exp_fail, "BSC accepted Assignment for Speech+CTM");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001580 f_shutdown_helper();
Harald Welte235ebf12017-12-15 14:18:16 +01001581}
1582
Harald Welte4003d112017-12-09 22:35:39 +01001583type record DchanTuple {
1584 integer sccp_conn_id,
1585 RslChannelNr rsl_chan_nr
Harald Weltea5d2ab22017-12-09 14:21:42 +01001586}
1587
Harald Welted6939652017-12-13 21:02:46 +01001588/* Send CHAN RQD and wait for allocation; acknowledge it */
1589private function f_chreq_act_ack(OCT1 ra := '23'O, GsmFrameNumber fn := 23)
1590runs on test_CT return RslChannelNr {
1591 var RSL_Message rx_rsl;
1592 f_ipa_tx(0, ts_RSL_CHAN_RQD(ra, fn));
1593 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
1594 var RslChannelNr chan_nr := rx_rsl.ies[0].body.chan_nr;
1595 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, fn+10));
Daniel Willmannf4ac4ce2018-08-02 14:06:30 +02001596 rx_rsl := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
Harald Welted6939652017-12-13 21:02:46 +01001597 return chan_nr;
1598}
1599
Harald Welte4003d112017-12-09 22:35:39 +01001600/* helper function to establish a dedicated channel via BTS and MSC */
1601function f_est_dchan(OCT1 ra, GsmFrameNumber fn, octetstring l3)
1602runs on test_CT return DchanTuple {
1603 var BSSAP_N_CONNECT_ind rx_c_ind;
Harald Welte4003d112017-12-09 22:35:39 +01001604 var DchanTuple dt;
Harald Weltea5d2ab22017-12-09 14:21:42 +01001605
Harald Welte4003d112017-12-09 22:35:39 +01001606 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +01001607 dt.rsl_chan_nr := f_chreq_act_ack(ra, fn);
Harald Welte4003d112017-12-09 22:35:39 +01001608
1609 f_ipa_tx(0, ts_RSL_EST_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
1610
1611 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
1612 dt.sccp_conn_id := rx_c_ind.connectionId;
1613 BSSAP.send(ts_BSSAP_CONNECT_res(dt.sccp_conn_id));
1614
1615 return dt;
Harald Weltea5d2ab22017-12-09 14:21:42 +01001616}
1617
Harald Welte641fcbe2018-06-14 10:58:35 +02001618/* expect RF CAN REL from BTS, acknowledge it and clear the MSC side */
1619private function f_exp_chan_rel_and_clear(DchanTuple dt, integer bts_nr := 0) runs on test_CT {
1620 var RSL_Message rx_rsl;
1621 /* expect BSC to disable the channel */
1622 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX);
1623 /* respond with CHAN REL ACK */
1624 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
1625
1626 /* expect Clear Complete from BSC */
1627 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete));
1628
1629 /* MSC disconnects as instructed. */
1630 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1631}
1632
Harald Welte4003d112017-12-09 22:35:39 +01001633/* Test behavior of channel release after unilateral RLL REL IND (DISC from MS) */
1634testcase TC_chan_rel_rll_rel_ind() runs on test_CT {
Neels Hofmeyr27f64362018-03-12 01:44:00 +01001635 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +01001636 var DchanTuple dt;
Harald Welte96c94412017-12-09 03:12:45 +01001637
Harald Welte89d42e82017-12-17 16:42:41 +01001638 f_init(1);
Harald Welte96c94412017-12-09 03:12:45 +01001639
Harald Welte4003d112017-12-09 22:35:39 +01001640 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1641
1642 /* simulate RLL REL IND */
1643 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0))));
1644
Neels Hofmeyr27f64362018-03-12 01:44:00 +01001645 /* expect Clear Request on MSC side */
1646 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
1647
1648 /* Instruct BSC to clear channel */
1649 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
1650 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
1651
Harald Welte4003d112017-12-09 22:35:39 +01001652 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02001653 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyr27f64362018-03-12 01:44:00 +01001654
1655 /* wait for SCCP emulation to do its job */
1656 f_sleep(1.0);
Harald Welte4003d112017-12-09 22:35:39 +01001657
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001658 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01001659}
1660
1661/* Test behavior of channel release after CONN FAIL IND from BTS */
1662testcase TC_chan_rel_conn_fail() runs on test_CT {
1663 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +01001664 var DchanTuple dt;
1665
Harald Welte89d42e82017-12-17 16:42:41 +01001666 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01001667
1668 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1669
1670 /* simulate CONN FAIL IND */
Harald Weltea8ed9062017-12-14 09:46:01 +01001671 f_ipa_tx(0, ts_RSL_CONN_FAIL_IND(dt.rsl_chan_nr, RSL_ERR_RADIO_LINK_FAIL));
Harald Welte4003d112017-12-09 22:35:39 +01001672 /* TODO: different cause values? */
1673
Harald Welte4003d112017-12-09 22:35:39 +01001674 /* expect Clear Request from BSC */
1675 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
1676
1677 /* Instruct BSC to clear channel */
1678 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
1679 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
1680
Harald Welte6ff76ea2018-01-28 13:08:01 +01001681 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02001682 f_exp_chan_rel_and_clear(dt, 0);
Harald Welte4003d112017-12-09 22:35:39 +01001683
1684 /* wait for SCCP emulation to do its job */
1685 f_sleep(1.0);
1686
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001687 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01001688}
1689
Harald Welte99f3ca02018-06-14 13:40:29 +02001690/* Test behavior of early CONN FAIL IND from BTS (before EST IND!) */
1691/* See also https://www.osmocom.org/issues/3182 */
1692testcase TC_early_conn_fail() runs on test_CT {
1693 var RSL_Message rx_rsl;
1694 var DchanTuple dt;
1695
1696 f_init(1);
1697
1698 /* BTS->BSC: Send CHAN RQD and wait for allocation; acknowledge it */
Harald Weltec46ea3c2020-10-10 18:46:12 +02001699 dt.rsl_chan_nr := f_chreq_act_ack(f_rnd_ra_cs(), 23);
Harald Welte99f3ca02018-06-14 13:40:29 +02001700
1701 /* BTS->BSC: simulate CONN FAIL IND */
1702 f_ipa_tx(0, ts_RSL_CONN_FAIL_IND(dt.rsl_chan_nr, RSL_ERR_RADIO_LINK_FAIL));
1703
1704 /* BTS->BSC: Expect RF channel release from BSC on Abis */
1705 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), 10.0);
1706
1707 /* BTS<-BSC: respond with CHAN REL ACK */
1708 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
1709
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001710 f_shutdown_helper();
Harald Welte99f3ca02018-06-14 13:40:29 +02001711}
1712
1713/* Test behavior of late CONN FAIL IND from BTS (ater REL IND!) */
1714/* See also https://www.osmocom.org/issues/3182 */
1715testcase TC_late_conn_fail() runs on test_CT {
1716 var RSL_Message rx_rsl;
1717 var DchanTuple dt;
1718
1719 f_init(1);
1720
1721 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1722
1723 /* BSC<-MSC: Instruct BSC to clear connection */
1724 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(0)));
1725
1726 /* BTS->BSC: expect BSC to deactivate SACCH */
1727 rx_rsl := f_exp_ipa_rx(0, tr_RSL_DEACT_SACCH(dt.rsl_chan_nr));
1728
1729 /* BTS->BSC: simulate a late CONN FAIL IND from BTS */
1730 f_ipa_tx(0, ts_RSL_CONN_FAIL_IND(dt.rsl_chan_nr, RSL_ERR_RADIO_LINK_FAIL));
1731
1732 /* BTS<-BSC: Expect RF channel release from BSC on Abis */
1733 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), 10.0);
1734 /* BTS->BSC: respond with CHAN REL ACK */
1735 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
1736
1737 /* BSC->MSC: expect Clear Complete from BSC */
1738 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete));
1739
1740 /* BSC<-MSC: MSC disconnects as requested. */
1741 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1742
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001743 f_shutdown_helper();
Harald Welte99f3ca02018-06-14 13:40:29 +02001744}
1745
Neels Hofmeyrf44ccd12018-11-05 19:15:23 +01001746function f_expect_chan_rel(integer bts_nr, RslChannelNr rsl_chan_nr,
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001747 boolean expect_deact_sacch := true,
1748 boolean expect_rr_chan_rel := true,
1749 boolean expect_rll_rel_req := true,
Harald Welte99787102019-02-04 10:41:36 +01001750 boolean handle_rll_rel := true,
Pau Espin Pedrol36bd4fa2021-04-15 13:00:24 +02001751 template CellSelIndValue expect_cells := omit,
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001752 template RR_Cause expect_rr_cause := ?
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001753 ) runs on test_CT {
Harald Welte91d54a52018-01-28 15:35:07 +01001754
1755 var RslLinkId main_dcch := valueof(ts_RslLinkID_DCCH(0));
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001756 var boolean got_deact_sacch := false;
1757 var boolean got_rr_chan_rel := false;
1758 var boolean got_rll_rel_req := false;
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001759 var ASP_RSL_Unitdata ud;
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001760 var RSL_IE_Body l3_ie;
1761 var PDU_ML3_NW_MS l3;
1762 var RR_Cause got_cause;
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001763 log("f_expect_chan_rel() expecting: expect_deact_sacch=", expect_deact_sacch, " expect_rr_chan_rel=", expect_rr_chan_rel,
1764 " expect_rll_rel_req=", expect_rll_rel_req);
Harald Welte91d54a52018-01-28 15:35:07 +01001765 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001766 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_DEACT_SACCH(rsl_chan_nr))) {
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001767 got_deact_sacch := true;
Harald Welte91d54a52018-01-28 15:35:07 +01001768 repeat;
1769 }
Pau Espin Pedrol841b90d2021-04-15 16:42:52 +02001770 [not istemplatekind(expect_cells, "omit")] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_DATA_REQ(rsl_chan_nr, ?, decmatch tr_RRM_RR_RELEASE_CellSelectInd))) -> value ud {
Harald Welte99787102019-02-04 10:41:36 +01001771 got_rr_chan_rel := true;
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001772
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001773 if (f_rsl_find_ie(ud.rsl, RSL_IE_L3_INFO, l3_ie) == false) {
1774 setverdict(fail, "cannot find L3");
1775 mtc.stop;
1776 }
1777 l3 := dec_PDU_ML3_NW_MS(l3_ie.l3_info.payload);
1778
Pau Espin Pedrol36bd4fa2021-04-15 13:00:24 +02001779 if (not istemplatekind(expect_cells, "omit")) {
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001780 var CellSelIndValue cells := dec_CellSelIndValue(
1781 l3.msgs.rrm.channelRelease.cellSelectionIndicator.cellSelectionIndicatorValue);
1782
Pau Espin Pedrol36bd4fa2021-04-15 13:00:24 +02001783 log("GOT RR CHANNEL RELEASE WITH CELLS: ", cells);
1784 if (match(cells, expect_cells)) {
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001785 setverdict(pass);
1786 } else {
Pau Espin Pedrol36bd4fa2021-04-15 13:00:24 +02001787 log("EXPECTED CELLS: ", expect_cells);
1788 setverdict(fail, "Received cells list on RR Channel Release does not match expectations");
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001789 }
1790 }
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001791
1792 if (not istemplatekind(expect_rr_cause, "omit")) {
1793 int2enum(oct2int(l3.msgs.rrm.channelRelease.rRCause.valuePart), got_cause);
1794 log("GOT CAUSE CODE: ", l3.msgs.rrm.channelRelease.rRCause.valuePart, " = ", got_cause);
1795 if (match(got_cause, expect_rr_cause)) {
1796 setverdict(pass);
1797 } else {
1798 log("EXPECTED CAUSE CODE: ", expect_rr_cause);
1799 setverdict(fail, "Received RR Channel Release Cause code does not match expectations");
1800 }
1801 }
Harald Welte99787102019-02-04 10:41:36 +01001802 repeat;
1803 }
Pau Espin Pedrol841b90d2021-04-15 16:42:52 +02001804 [istemplatekind(expect_cells, "omit")] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_DATA_REQ(rsl_chan_nr, ?, decmatch tr_RRM_RR_RELEASE))) -> value ud {
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001805 got_rr_chan_rel := true;
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001806
1807 if (not istemplatekind(expect_rr_cause, "omit")) {
1808 if (f_rsl_find_ie(ud.rsl, RSL_IE_L3_INFO, l3_ie) == false) {
1809 setverdict(fail, "cannot find L3");
1810 mtc.stop;
1811 }
1812 l3 := dec_PDU_ML3_NW_MS(l3_ie.l3_info.payload);
1813
1814 int2enum(oct2int(l3.msgs.rrm.channelRelease.rRCause.valuePart), got_cause);
1815 log("GOT CAUSE CODE: ", l3.msgs.rrm.channelRelease.rRCause.valuePart, " = ", got_cause);
1816 if (match(got_cause, expect_rr_cause)) {
1817 setverdict(pass);
1818 } else {
1819 log("EXPECTED CAUSE CODE: ", expect_rr_cause);
1820 setverdict(fail, "Received RR Channel Release Cause code does not match expectations");
1821 }
1822 }
Neels Hofmeyr211169d2018-11-07 00:37:29 +01001823 repeat;
1824 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001825 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_REL_REQ(rsl_chan_nr, ?))) {
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001826 got_rll_rel_req := true;
Harald Welte91d54a52018-01-28 15:35:07 +01001827 /* FIXME: Why are we getting this for LinkID SACCH? */
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001828 if (handle_rll_rel) {
1829 f_ipa_tx(0, ts_RSL_REL_CONF(rsl_chan_nr, main_dcch));
1830 }
Harald Welte91d54a52018-01-28 15:35:07 +01001831 repeat;
1832 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001833 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL))) {
Harald Welte91d54a52018-01-28 15:35:07 +01001834 /* respond with CHAN REL ACK */
1835 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(rsl_chan_nr));
1836 }
1837 /* ignore any user data */
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001838 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeR(?))) {
Harald Welte91d54a52018-01-28 15:35:07 +01001839 repeat;
1840 }
1841 }
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001842
1843 log("f_expect_chan_rel() summary: got_deact_sacch=", got_deact_sacch, " got_rr_chan_rel=", got_rr_chan_rel,
1844 " got_rll_rel_req=", got_rll_rel_req);
1845
1846 if (expect_deact_sacch != got_deact_sacch) {
1847 setverdict(fail, "f_expect_chan_rel(): expect_deact_sacch=", expect_deact_sacch, " got_deact_sacch=", got_deact_sacch);
1848 }
1849 if (expect_rr_chan_rel != got_rr_chan_rel) {
1850 setverdict(fail, "f_expect_chan_rel(): expect_rr_chan_rel=", expect_rr_chan_rel, " got_rr_chan_rel=", got_rr_chan_rel);
1851 }
1852 if (expect_rll_rel_req != got_rll_rel_req) {
1853 setverdict(fail, "f_expect_chan_rel(): expect_rll_rel_req=", expect_rll_rel_req, " got_rll_rel_req=", got_rll_rel_req);
1854 }
Harald Welte91d54a52018-01-28 15:35:07 +01001855}
1856
Harald Welte4003d112017-12-09 22:35:39 +01001857/* Test behavior of channel release after hard Clear Command from MSC */
1858testcase TC_chan_rel_hard_clear() runs on test_CT {
1859 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +01001860 var DchanTuple dt;
Harald Welte4003d112017-12-09 22:35:39 +01001861
Harald Welte89d42e82017-12-17 16:42:41 +01001862 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01001863
1864 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1865
1866 /* Instruct BSC to clear channel */
1867 var BssmapCause cause := 0;
1868 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
1869
1870 /* expect Clear Complete from BSC on A */
1871 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
1872 /* release the SCCP connection */
1873 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1874 }
1875
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001876 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001877 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01001878}
1879
Pau Espin Pedrol841b90d2021-04-15 16:42:52 +02001880function f_TC_chan_rel_last_eutran_plmn_hard_clear(boolean tx_csfb_ind) runs on test_CT {
1881 var BSSAP_N_DATA_ind rx_di;
1882 var DchanTuple dt;
1883
1884 f_init(1);
1885
1886 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1887 /* Send CommonID with some random PLMN (BSC doesn't take it into account
1888 /* yet when generating the EUTRAN neigh list in RR CHannel Release) */
1889 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_CommonId('001019876543210'H, '323454'O)));
1890
1891 /* Instruct BSC to clear channel */
1892 var BssmapCause cause := 0;
1893 if (tx_csfb_ind) {
1894 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommandCSFB(cause)));
1895 } else {
1896 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
1897 }
1898
1899 /* expect Clear Complete from BSC on A */
1900 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
1901 /* release the SCCP connection */
1902 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1903 }
1904
1905 /* 1 neighbor is added by default in osmo-bts.cfg and
1906 SystemInformationConfig_default, use that: */
1907 var template CellSelIndValue exp_cells := f_tr_rr_chan_rel_earfcns(1);
1908
1909 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false, expect_cells := exp_cells);
1910 f_shutdown_helper();
1911}
1912
1913/* Test behavior of RR Channel rRelease after Clear Command without CSFB indicator
1914 from MSC, previously receiving any CommonID containing the "Last Used E-UTRAN
1915 PLMN Id". According to spec (3GPP TS 48.008 sec 3.1.30) that's the bit requesting
1916 EUTRAN neighbor list sent later on by BSC in RR Channel, so receiving CSFB
1917 Indicator or not shouldn't matter at all. */
1918testcase TC_chan_rel_last_eutran_plmn_hard_clear_no_csfb() runs on test_CT {
1919 f_TC_chan_rel_last_eutran_plmn_hard_clear(false);
1920}
1921
1922/* Test behavior of RR Channel rRelease after Clear Command with CSFB indicator from
1923 MSC, previously receiving any CommonID containing the "Last Used E-UTRAN PLMN
1924 Id". According to spec (3GPP TS 48.008 sec 3.1.30) that's the bit requesting
1925 EUTRAN neighbor list sent later on by BSC in RR Channel. */
1926testcase TC_chan_rel_last_eutran_plmn_hard_clear_csfb() runs on test_CT {
1927 f_TC_chan_rel_last_eutran_plmn_hard_clear(true);
1928}
1929
1930/* Test behavior of RR Channel Release after Clear Command with CSFB indicator from
1931 MSC, without receiving any CommonID containing the "Last Used E-UTRAN PLMN
1932 Id". According to spec (TS 48.008 version 16.0.0 Release 16 "3.2.1.21") the
1933 CSFB Indicator should not be used anymore, and hence, there should be no
1934 EUTRAN neighbor list sent by BSC in RR Channel release since no CommonId with
1935 Last Used E-UTRAN PLMN Id" IE was sent for this conn. */
Harald Welte99787102019-02-04 10:41:36 +01001936testcase TC_chan_rel_hard_clear_csfb() runs on test_CT {
1937 var BSSAP_N_DATA_ind rx_di;
1938 var DchanTuple dt;
1939
1940 f_init(1);
1941
1942 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1943
1944 /* Instruct BSC to clear channel */
1945 var BssmapCause cause := 0;
1946 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommandCSFB(cause)));
1947
1948 /* expect Clear Complete from BSC on A */
1949 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
1950 /* release the SCCP connection */
1951 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1952 }
1953
Pau Espin Pedrol841b90d2021-04-15 16:42:52 +02001954 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001955 f_shutdown_helper();
Harald Welte99787102019-02-04 10:41:36 +01001956}
1957
Harald Welted8c36cd2017-12-09 23:05:31 +01001958/* Test behavior of channel release after hard RLSD from MSC */
1959testcase TC_chan_rel_hard_rlsd() runs on test_CT {
Harald Welted8c36cd2017-12-09 23:05:31 +01001960 var DchanTuple dt;
Harald Welted8c36cd2017-12-09 23:05:31 +01001961
Harald Welte89d42e82017-12-17 16:42:41 +01001962 f_init(1);
Harald Welted8c36cd2017-12-09 23:05:31 +01001963
1964 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1965
1966 /* release the SCCP connection */
1967 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1968
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001969 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001970 f_shutdown_helper();
Harald Welted8c36cd2017-12-09 23:05:31 +01001971}
1972
Harald Welte550daf92018-06-11 19:22:13 +02001973/* Test behavior of channel release after hard RLSD from MSC and MS is not responding to RLL REL REQ */
1974testcase TC_chan_rel_hard_rlsd_ms_dead() runs on test_CT {
1975 var DchanTuple dt;
1976
1977 f_init(1);
1978
1979 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1980
1981 /* release the SCCP connection */
1982 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1983
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001984 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001985 f_shutdown_helper();
Harald Welte550daf92018-06-11 19:22:13 +02001986}
1987
Harald Welte85804d42017-12-10 14:11:58 +01001988/* Test behavior of channel release after BSSMAP RESET from MSC */
1989testcase TC_chan_rel_a_reset() runs on test_CT {
Harald Welte85804d42017-12-10 14:11:58 +01001990 var DchanTuple dt;
Harald Welte85804d42017-12-10 14:11:58 +01001991
Harald Welte89d42e82017-12-17 16:42:41 +01001992 f_init(1);
Harald Welte85804d42017-12-10 14:11:58 +01001993
1994 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1995
1996 /* Clear the queue, it might still contain stuff like IMMEDIATE ASSIGN */
1997 IPA_RSL[0].clear;
1998
1999 /* perform BSSAP RESET, expect RESET ACK and DISC.ind on connection */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02002000 BSSAP.send(ts_BSSAP_UNITDATA_req(g_bssap[0].sccp_addr_peer, g_bssap[0].sccp_addr_own, ts_BSSMAP_Reset(0, g_osmux_enabled)));
Harald Welte85804d42017-12-10 14:11:58 +01002001 interleave {
Neels Hofmeyrf246a922020-05-13 02:27:10 +02002002 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(g_bssap[0].sccp_addr_own, g_bssap[0].sccp_addr_peer, tr_BSSMAP_ResetAck(g_osmux_enabled))) { }
Harald Welte85804d42017-12-10 14:11:58 +01002003 [] BSSAP.receive(tr_BSSAP_DISC_ind(dt.sccp_conn_id, ?, ?)) { }
2004 }
2005
Neels Hofmeyra5302c82018-11-04 23:09:58 +01002006 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002007 f_shutdown_helper();
Harald Welte85804d42017-12-10 14:11:58 +01002008}
2009
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01002010/* Verify T(iar) triggers and releases the channel */
2011testcase TC_chan_rel_sccp_tiar_timeout() runs on test_CT {
2012 var DchanTuple dt;
2013
2014 /* Set T(iar) in BSC low enough that it will trigger before other side
2015 has time to keep alive with a T(ias). Keep recommended ratio of
2016 T(iar) >= T(ias)*2 */
2017 g_bsc_sccp_timer_ias := 2;
2018 g_bsc_sccp_timer_iar := 5;
2019
2020 f_init(1);
2021
2022 dt := f_est_dchan('23'O, 23, '00010203040506'O);
2023 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002024 f_shutdown_helper();
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01002025}
2026
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02002027private function f_tc_chan_rel_rr_cause(myBSSMAP_Cause clear_cmd_cause, template RR_Cause expect_rr_cause)
2028runs on test_CT
2029{
2030 var DchanTuple dt;
2031
2032 dt := f_est_dchan('23'O, 23, '00010203040506'O);
2033 var BssmapCause cause := 0;
2034 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(enum2int(clear_cmd_cause))));
2035 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
2036 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2037 }
2038
2039 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false, expect_rr_cause := expect_rr_cause);
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02002040}
2041
2042/* Test that Clear Command cause codes affect the RR Channel Release cause code */
2043testcase TC_chan_rel_rr_cause() runs on test_CT {
2044 f_init(1);
2045
2046 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_CALL_CONTROL, GSM48_RR_CAUSE_NORMAL);
2047 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_HANDOVER_SUCCESSFUL, GSM48_RR_CAUSE_NORMAL);
2048 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_PREEMPTION, GSM48_RR_CAUSE_PREMPTIVE_REL);
2049 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_RADIO_INTERFACE_MESSAGE_FAILURE, GSM48_RR_CAUSE_PROT_ERROR_UNSPC);
2050 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_RADIO_INTERFACE_FAILURE, GSM48_RR_CAUSE_ABNORMAL_UNSPEC);
2051 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_EQUIPMENT_FAILURE, GSM48_RR_CAUSE_ABNORMAL_UNSPEC);
Vadim Yanitskiye18aebb2021-01-03 13:10:43 +01002052
2053 f_shutdown_helper();
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02002054}
2055
Harald Welte5cd20ed2017-12-13 21:03:20 +01002056/* Test behavior if RSL EST IND for non-active channel */
2057testcase TC_rll_est_ind_inact_lchan() runs on test_CT {
2058 timer T := 2.0;
2059
Harald Welte89d42e82017-12-17 16:42:41 +01002060 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01002061
2062 var octetstring l3 := '00010203040506'O;
2063 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
2064 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
2065
2066 T.start;
2067 alt {
2068 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
2069 setverdict(fail, "MSC received COMPL L3 for non-active lchan");
2070 }
2071 [] BSSAP.receive {}
2072 [] IPA_RSL[0].receive {}
2073 [] T.timeout {}
2074 }
2075
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002076 f_shutdown_helper();
Harald Welte5cd20ed2017-12-13 21:03:20 +01002077}
2078
2079/* Test behavior if RSL EST IND for invalid SAPI */
2080testcase TC_rll_est_ind_inval_sapi1() runs on test_CT {
2081 var RslChannelNr chan_nr;
2082
Harald Welte89d42e82017-12-17 16:42:41 +01002083 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01002084
2085 chan_nr := f_chreq_act_ack()
2086
2087 var octetstring l3 := '00010203040506'O;
2088 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(1)), l3));
2089
2090 timer T := 2.0;
2091 T.start;
2092 alt {
2093 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
2094 setverdict(fail, "MSC received COMPL L3 for invalid SAPI 1");
2095 }
2096 [] BSSAP.receive { repeat; }
2097 [] IPA_RSL[0].receive { repeat; }
2098 [] T.timeout {}
2099 }
2100
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002101 f_shutdown_helper();
Harald Welte5cd20ed2017-12-13 21:03:20 +01002102}
2103
2104/* Test behavior if RSL EST IND for invalid SAPI */
2105testcase TC_rll_est_ind_inval_sapi3() runs on test_CT {
2106 timer T := 2.0;
2107
Harald Welte89d42e82017-12-17 16:42:41 +01002108 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01002109
2110 var RslChannelNr chan_nr := f_chreq_act_ack();
2111
2112 var octetstring l3 := '00010203040506'O;
2113 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(3)), l3));
2114
2115 T.start;
2116 alt {
2117 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
2118 setverdict(fail, "MSC received COMPL L3 for invalid SAPI 3");
2119 }
2120 [] BSSAP.receive { repeat; }
2121 [] IPA_RSL[0].receive { repeat; }
2122 [] T.timeout {}
2123 }
2124
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002125 f_shutdown_helper();
Harald Welte5cd20ed2017-12-13 21:03:20 +01002126}
2127
2128/* Test behavior if RSL EST IND for invalid SACCH */
2129testcase TC_rll_est_ind_inval_sacch() runs on test_CT {
2130 timer T := 2.0;
2131
Harald Welte89d42e82017-12-17 16:42:41 +01002132 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01002133
2134 var RslChannelNr chan_nr := f_chreq_act_ack();
2135
2136 var octetstring l3 := '00010203040506'O;
2137 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_SACCH(0)), l3));
2138
2139 T.start;
2140 alt {
2141 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
2142 setverdict(fail, "MSC received COMPL L3 for invalid Link SACCH");
2143 }
2144 [] BSSAP.receive { repeat; }
2145 [] IPA_RSL[0].receive { repeat; }
2146 [] T.timeout {}
2147 }
2148
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002149 f_shutdown_helper();
Harald Welte5cd20ed2017-12-13 21:03:20 +01002150}
2151
Vadim Yanitskiy61f784a2020-10-01 21:12:19 +07002152/* Verify DLCI / RSL Link ID conversion for MO/MT messages on SAPI0/SAPI3 */
2153private function f_TC_tch_dlci_link_id_sapi(charstring id) runs on MSC_ConnHdlr {
2154 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2155 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2156
2157 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2158 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
2159
2160 f_establish_fully(ass_cmd, exp_compl);
2161
2162 /* SAPI0 has already been established by f_establish_fully(), establish SAPI3 */
2163 RSL.send(ts_RSL_EST_IND(g_chan_nr, ts_RslLinkID_SACCH(3), '0904'O));
2164 /* Expect BSSAP/DTAP on SAPI3 (DLCI IE) */
2165 BSSAP.receive(PDU_BSSAP:{
2166 discriminator := '1'B,
2167 spare := '0000000'B,
2168 dlci := 'C3'O,
2169 lengthIndicator := ?,
2170 pdu := { dtap := '0904'O }
2171 });
2172
2173 /* Send messages on DCCH/SAPI0 and ACCH/SAPI3 */
2174 for (var integer i := 0; i < 32; i := i + 1) {
2175 var octetstring l3 := '09'O & f_rnd_octstring(14);
2176 var template (value) RslLinkId link_id;
2177 var template (value) OCT1 dlci;
2178
2179 if (i mod 2 == 0) {
2180 /* SAPI0 on FACCH or SDCCH */
2181 link_id := ts_RslLinkID_DCCH(0);
2182 dlci := '80'O;
2183 } else {
2184 /* SAPI3 on SACCH */
2185 link_id := ts_RslLinkID_SACCH(3);
2186 dlci := 'C3'O;
2187 }
2188
2189 /* Send MO message: RSL -> BSSAP */
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00002190 f_mo_l3_transceive(RSL, link_id, dlci, l3);
Vadim Yanitskiy61f784a2020-10-01 21:12:19 +07002191 /* Send MT message: BSSAP -> RSL */
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00002192 f_mt_l3_transceive(RSL, link_id, dlci, l3);
Vadim Yanitskiy61f784a2020-10-01 21:12:19 +07002193 }
2194}
2195testcase TC_tch_dlci_link_id_sapi() runs on test_CT {
2196 var TestHdlrParams pars := f_gen_test_hdlr_pars();
2197 var MSC_ConnHdlr vc_conn;
2198
2199 f_init(1, true);
2200 f_sleep(1.0);
2201
2202 vc_conn := f_start_handler(refers(f_TC_tch_dlci_link_id_sapi), pars);
2203 vc_conn.done;
2204
2205 f_shutdown_helper();
2206}
2207
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07002208private function f_exp_sapi_n_reject(template (present) GsmSapi sapi := ?,
2209 template myBSSMAP_Cause cause := ?,
2210 float T_val := 2.0)
2211runs on test_CT {
2212 var BSSAP_N_DATA_ind rx_di;
2213 timer T;
2214
2215 var template BSSMAP_IE_Cause tr_cause := tr_BSSMAP_IE_Cause(cause);
2216 var template PDU_BSSAP tr_pdu := tr_BSSMAP_SAPInReject(sapi);
2217
2218 T.start(T_val);
2219 alt {
2220 [] BSSAP.receive(tr_BSSAP_DATA_ind(?, tr_pdu)) -> value rx_di {
2221 var BSSMAP_IE_Cause rx_cause := rx_di.userData.pdu.bssmap.sAPInReject.cause;
2222 if (not match(rx_cause, tr_cause)) {
2223 setverdict(fail, "Rx unexpected Cause IE: ",
2224 rx_cause, " vs expected ", tr_cause);
2225 }
2226 setverdict(pass);
2227 }
2228 [] BSSAP.receive(BSSAP_N_DATA_ind:?) -> value rx_di {
2229 setverdict(fail, "Rx unexpected BSSAP PDU: ", rx_di);
2230 }
2231 [] T.timeout {
2232 setverdict(fail, "Timeout waiting for BSSMAP SAPI N Reject");
2233 }
2234 }
2235}
2236
2237/* Check if we get SAPI N Reject on receipt of unexpected RLL RELease INDication */
2238testcase TC_rll_rel_ind_sapi_n_reject() runs on test_CT {
2239 var octetstring rnd_data := f_rnd_octstring(16);
2240 var RSL_Message rx_rsl;
2241 var DchanTuple dt;
2242
2243 f_init(1);
2244
2245 /* MS establishes a SAPI=0 link on DCCH */
2246 dt := f_est_dchan(f_rnd_ra_cs(), 23, rnd_data);
2247
2248 /* MSC sends some data on (not yet established) SAPI=3 link */
2249 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSAP_DTAP(rnd_data, '03'O)));
2250 /* BSC attempts to establish a SAPI=3 link on DCCH */
2251 rx_rsl := f_exp_ipa_rx(0, tr_RSL_EST_REQ(dt.rsl_chan_nr, tr_RslLinkID_DCCH(3)));
2252
2253 /* MS sends unexpected RELease INDication on SAPI=3 */
2254 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, ts_RslLinkID_DCCH(3)));
2255 /* We expect to receive BSSMAP SAPI N Reject message from the BSC */
2256 f_exp_sapi_n_reject(3, GSM0808_CAUSE_MS_NOT_EQUIPPED);
2257
2258 /* Clean up the connection */
2259 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2260 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
2261
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002262 f_shutdown_helper();
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07002263}
2264
2265/* Check if we get SAPI N Reject on receipt of unexpected RLL ERROR INDication */
2266testcase TC_rll_err_ind_sapi_n_reject() runs on test_CT {
2267 var octetstring rnd_data := f_rnd_octstring(16);
2268 var RSL_Message rx_rsl;
2269 var DchanTuple dt;
2270
2271 f_init(1);
2272
2273 /* MS establishes a SAPI=0 link on DCCH */
2274 dt := f_est_dchan(f_rnd_ra_cs(), 23, rnd_data);
2275
2276 /* MSC sends some data on (not yet established) SAPI=3 link */
2277 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSAP_DTAP(rnd_data, '03'O)));
2278 /* BSC attempts to establish a SAPI=3 link on DCCH */
2279 rx_rsl := f_exp_ipa_rx(0, tr_RSL_EST_REQ(dt.rsl_chan_nr, tr_RslLinkID_DCCH(3)));
2280
2281 /* BTS sends unexpected ERROR INDication on SAPI=3 */
2282 f_ipa_tx(0, ts_RSL_ERROR_IND(dt.rsl_chan_nr, ts_RslLinkID_DCCH(3), ''O));
2283 /* We expect to receive BSSMAP SAPI N Reject message from the BSC */
2284 f_exp_sapi_n_reject(3, GSM0808_CAUSE_BSS_NOT_EQUIPPED);
2285
2286 /* Clean up the connection */
2287 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2288 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
2289
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002290 f_shutdown_helper();
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07002291}
2292
2293/* Check if we get SAPI N Reject due to a SAPI=3 link establishment timeout */
2294testcase TC_rll_timeout_sapi_n_reject() runs on test_CT {
2295 var octetstring rnd_data := f_rnd_octstring(16);
2296 var RSL_Message rx_rsl;
2297 var DchanTuple dt;
2298
2299 f_init(1);
2300
2301 /* MS establishes a SAPI=0 link on DCCH */
2302 dt := f_est_dchan(f_rnd_ra_cs(), 23, rnd_data);
2303
2304 /* MSC sends some data on (not yet established) SAPI=3 link */
2305 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSAP_DTAP(rnd_data, '03'O)));
2306 /* BSC attempts to establish a SAPI=3 link on DCCH */
2307 rx_rsl := f_exp_ipa_rx(0, tr_RSL_EST_REQ(dt.rsl_chan_nr, tr_RslLinkID_DCCH(3)));
2308
2309 /* MS does not respond, so the link establishment timeout triggers SAPI N Reject */
2310 f_exp_sapi_n_reject(3, GSM0808_CAUSE_BSS_NOT_EQUIPPED, T_val := 8.0);
2311
2312 /* Clean up the connection */
2313 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2314 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
2315
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002316 f_shutdown_helper();
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07002317}
2318
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02002319testcase TC_si_default() runs on test_CT {
2320 f_init(0);
2321 f_init_bts_and_check_sysinfo(0, expect_si := SystemInformationConfig_default);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002322 f_shutdown_helper();
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02002323}
Harald Welte4003d112017-12-09 22:35:39 +01002324
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002325/* We're testing SI2quater with lists of EARFCNs. Instead of just incrementing EARFCNs, also pick some from the edges of
2326 * the entire value range. This function provides the same EARFCN numbers for the same earfcn_index */
2327private function f_test_si2quater_earfcn_by_idx(integer earfcn_index) return uint16_t
2328{
2329 select (earfcn_index) {
2330 case (0) {
2331 /* E-ARFCN 111 is already added in the osmo-bsc.cfg */
2332 return 111;
2333 }
2334 case (1) {
2335 return 1;
2336 }
2337 case (2) {
2338 return 0;
2339 }
2340 case (3) {
2341 return 65535;
2342 }
2343 case else {
2344 return 23 * (earfcn_index - 3);
2345 }
2346 }
2347}
2348
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002349function f_test_si2quater(integer total_earfcns, template SystemInformationConfig expect_si,
2350 template CellSelIndValue expect_cells := omit) runs on test_CT {
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002351
2352 f_init(0);
2353
2354 /* E-ARFCN 111 is already added in the osmo-bsc.cfg, so only add more arfcns if total_earfcns > 1 */
2355 for (var integer i := 1; i < total_earfcns; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002356 f_bts_0_cfg(BSCVTY, {"si2quater neighbor-list add earfcn " & int2str(f_test_si2quater_earfcn_by_idx(i))
2357 & " thresh-hi 20 thresh-lo 10 prio 3 qrxlv 22 meas 3"});
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002358 }
2359
2360 f_init_bts_and_check_sysinfo(0, expect_si := expect_si);
2361
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002362 if (not istemplatekind(expect_cells, "omit")) {
2363 /* Also check that RR Channel Release contains these EARFCNs.
2364 * (copied code from TC_chan_rel_hard_clear_csfb) */
2365 var BSSAP_N_DATA_ind rx_di;
2366 var DchanTuple dt;
2367
2368 dt := f_est_dchan('23'O, 23, '00010203040506'O);
Pau Espin Pedrold0046312021-04-19 16:35:58 +02002369 /* Send CommonID with some random PLMN (BSC doesn't take it into account
2370 * yet when generating the EUTRAN neigh list in RR CHannel Release) */
2371 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_CommonId('001019876543210'H, '323454'O)));
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002372
2373 /* Instruct BSC to clear channel */
2374 var BssmapCause cause := 0;
2375 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommandCSFB(cause)));
2376
2377 /* expect Clear Complete from BSC on A */
2378 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
2379 /* release the SCCP connection */
2380 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2381 }
2382
Pau Espin Pedrol841b90d2021-04-15 16:42:52 +02002383 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false, expect_cells := expect_cells);
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002384 }
2385
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002386 for (var integer i := 1; i < total_earfcns; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002387 f_bts_0_cfg(BSCVTY, {"si2quater neighbor-list del earfcn " & int2str(f_test_si2quater_earfcn_by_idx(i))});
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002388 }
2389}
2390
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002391private function f_tr_si2quater_earfcns(integer count) return template SI2quaterRestOctetsList
2392{
2393 var template SI2quaterRestOctetsList si2quater := {};
2394 var integer si2quater_count := (count + 2) / 3;
2395
2396 for (var integer i := 0; i < count; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002397 var integer earfcn := f_test_si2quater_earfcn_by_idx(i);
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002398 var integer index := i / 3;
2399 var integer earfcn_index := i mod 3;
2400 if (index >= lengthof(si2quater)) {
2401 si2quater[index] := tr_SI2quaterRestOctets_EUTRAN(index := index, count := si2quater_count - 1);
2402 }
2403 si2quater[index].rel_additions.rel5.rel6.rel7.rel8.prio_eutran_params_desc.desc.eutran_params_desc.desc.repeated_neigh_cells[0].cell_desc_list[earfcn_index] := tr_EUTRAN_CellDesc_default(e_arfcn := earfcn);
2404 }
2405
2406 return si2quater;
2407}
2408
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002409private function f_tr_rr_chan_rel_earfcns(integer count) return template CellSelIndValue
2410{
2411 var template CellSelIndValue_EUTRAN_Descrs cells := {};
2412
Alexander Couzensf74b5cb2020-09-10 22:28:40 +02002413 /* the lte neighbors must match the config & vty to pass this test */
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002414 for (var integer i := 0; i < count; i := i + 1) {
2415 var integer earfcn := f_test_si2quater_earfcn_by_idx(i);
Alexander Couzensf74b5cb2020-09-10 22:28:40 +02002416 cells[i] := tr_CellSelIndValue_EUTRAN_Descr(earfcn, '1'B, 3);
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002417 }
2418
2419 return tr_CellSelIndValue_EUTRAN(cells);
2420}
2421
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002422private function f_tc_si2quater_n_earfcns(integer n) runs on test_CT
2423{
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002424 var template SystemInformationConfig sic := SystemInformationConfig_default;
Pau Espin Pedrol8ab62e42020-12-18 16:19:11 +01002425 sic.si2quater := f_tr_si2quater_earfcns(n);
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002426 var template CellSelIndValue cells := f_tr_rr_chan_rel_earfcns(n);
2427 f_test_si2quater(n, sic, cells);
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002428}
2429
2430testcase TC_si2quater_2_earfcns() runs on test_CT {
2431 f_tc_si2quater_n_earfcns(2);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002432 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002433}
2434
2435testcase TC_si2quater_3_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002436 f_tc_si2quater_n_earfcns(3);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002437 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002438}
2439
2440testcase TC_si2quater_4_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002441 f_tc_si2quater_n_earfcns(4);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002442 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002443}
2444
2445testcase TC_si2quater_5_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002446 f_tc_si2quater_n_earfcns(5);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002447 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002448}
2449
2450testcase TC_si2quater_6_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002451 f_tc_si2quater_n_earfcns(6);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002452 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002453}
2454
2455testcase TC_si2quater_12_earfcns() runs on test_CT {
2456 f_tc_si2quater_n_earfcns(12);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002457 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002458}
2459
2460testcase TC_si2quater_23_earfcns() runs on test_CT {
2461 f_tc_si2quater_n_earfcns(23);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002462 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002463}
2464
2465testcase TC_si2quater_32_earfcns() runs on test_CT {
2466 f_tc_si2quater_n_earfcns(32);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002467 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002468}
2469
2470testcase TC_si2quater_33_earfcns() runs on test_CT {
2471 f_tc_si2quater_n_earfcns(33);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002472 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002473}
2474
2475testcase TC_si2quater_42_earfcns() runs on test_CT {
2476 f_tc_si2quater_n_earfcns(42);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002477 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002478}
2479
2480testcase TC_si2quater_48_earfcns() runs on test_CT {
2481 f_tc_si2quater_n_earfcns(48);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002482 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002483}
2484
2485/* verify the VTY error response when adding too many EARFCNs, and showing that osmo-bsc still sends 16 SI2quater with
2486 * 48 EARFCNs. */
2487testcase TC_si2quater_49_earfcns() runs on test_CT {
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002488 var template SystemInformationConfig sic := SystemInformationConfig_default;
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002489 sic.si2quater := f_tr_si2quater_earfcns(48); /* 48, not 49! */
2490 f_init(0);
2491
2492 for (var integer i := 1; i < 48; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002493 f_bts_0_cfg(BSCVTY, {"si2quater neighbor-list add earfcn " & int2str(f_test_si2quater_earfcn_by_idx(i))
2494 & " thresh-hi 20 thresh-lo 10 prio 3 qrxlv 22 meas 3"});
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002495 }
2496
2497 /* The 49th EARFCN no longer fits, expect VTY error */
2498 f_vty_enter_cfg_bts(BSCVTY, 0);
2499 var charstring vty_error;
2500 vty_error := f_vty_transceive_ret(BSCVTY,
2501 "si2quater neighbor-list add earfcn 70 thresh-hi 20 thresh-lo 10 prio 3 qrxlv 22 meas 3")
2502 f_vty_transceive(BSCVTY, "end");
2503
2504 if (f_strstr(vty_error, "Unable to add ARFCN 70") >= 0) {
2505 log("Got expected VTY error: ", vty_error);
2506 setverdict(pass);
2507 } else {
2508 setverdict(fail, "Expected the 49th EUTRAN ARFCN to be rejected by vty config, got: ", vty_error);
2509 }
2510
2511 f_init_bts_and_check_sysinfo(0, expect_si := sic);
2512
2513 for (var integer i := 1; i < 48; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002514 f_bts_0_cfg(BSCVTY, {"si2quater neighbor-list del earfcn " & int2str(f_test_si2quater_earfcn_by_idx(i))});
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002515 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002516 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002517}
2518
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002519private function f_acc09_count_allowed(AccessControlClass acc) return uint8_t
2520{
2521 var uint8_t count := 0;
2522 for (var integer i := 5; i < 16; i := i + 1) {
2523 if (acc[i] == '0'B) { /* the list marks barred, we count allowed */
2524 count := count + 1;
2525 }
2526 }
2527 return count;
2528}
2529
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002530private function f_recv_next_si1(integer rsl_idx := 0) runs on test_CT return SystemInformationType1
2531{
2532 var ASP_RSL_Unitdata rx_rsl_ud;
2533 var SystemInformationType1 last_si1;
2534
2535 timer T := 30.0;
2536 T.start;
2537 alt {
2538 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD((tr_RSL_NO_BCCH_INFO,
2539 tr_RSL_BCCH_INFO,
2540 tr_RSL_NO_SACCH_FILL,
2541 tr_RSL_SACCH_FILL))
2542 ) -> value rx_rsl_ud {
2543 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
2544 if (g_system_information[rsl_idx].si1 == omit) {
2545 repeat;
2546 }
2547 last_si1 := g_system_information[rsl_idx].si1;
2548 g_system_information[rsl_idx].si1 := omit;
2549 T.stop;
2550 }
Vadim Yanitskiy79ebd5e2021-01-04 00:12:55 +01002551 [] IPA_RSL[rsl_idx].receive { repeat; }
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002552 [] T.timeout { setverdict(fail, "Timeout receiving next SI1"); }
2553 }
2554 return last_si1;
2555}
2556
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002557/* verify ACC rotate feature */
2558testcase TC_si_acc_rotate() runs on test_CT {
2559 var template SystemInformationConfig sic := SystemInformationConfig_default;
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002560 var SystemInformationType1 last_si1;
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002561 var AccessControlClass acc;
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002562 var uint8_t count;
2563 var integer times_allowed[10] := { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
2564
2565 f_init(0, guard_timeout := 60.0);
2566
2567 f_bts_0_cfg(BSCVTY, {"rach access-control-class 5 barred",
2568 "access-control-class-rotate 3",
2569 "access-control-class-rotate-quantum 1"});
2570
2571 /* Init and get first sysinfo */
2572 f_init_bts_and_check_sysinfo(0, expect_si := ?);
2573
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002574 for (var integer i:= 0; i < 20; i := i + 1) {
2575 last_si1 := f_recv_next_si1(0);
2576 acc := last_si1.rach_control.acc;
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002577 count := f_acc09_count_allowed(acc);
2578 log("RSL: GOT SI1 ACC len=", count, ": ", acc);
2579
2580 if (count != 3) {
2581 log("RSL: EXPECTED SI ACC len=3");
2582 setverdict(fail, "received SI does not match expectations");
2583 break;
2584 }
2585
2586 for (var integer j := 0; j < 10; j := j + 1) {
2587 if (acc[16 - 1 - j] == '0'B) { /* the list marks barred, we count allowed */
2588 times_allowed[j] := times_allowed[j] + 1;
2589 }
2590 }
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002591 }
2592
2593 for (var integer j := 0; j < 10; j := j + 1) {
2594 log("ACC", j, " allowed ", times_allowed[j], " times" );
2595 if (j != 5 and times_allowed[j] < 3) {
2596 setverdict(fail, "ACC", j, " ERROR: allowed ", times_allowed[j], " < 1 times");
2597 } else if (j == 5 and times_allowed[j] > 0) {
2598 setverdict(fail, "ACC", j, " ERROR: allowed ", times_allowed[j], " > 0 times");
2599 }
2600 }
2601
2602 f_bts_0_cfg(BSCVTY, {"access-control-class-rotate 10",
2603 "rach access-control-class 5 allowed"});
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002604 f_shutdown_helper();
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002605}
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002606
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002607/* verify ACC startup ramp+rotate feature */
2608testcase TC_si_acc_ramp_rotate() runs on test_CT {
2609 var template SystemInformationConfig sic := SystemInformationConfig_default;
2610 var SystemInformationType1 last_si1;
2611 var AccessControlClass acc;
2612 var ASP_RSL_Unitdata rx_rsl_ud;
2613 var uint8_t count;
2614 var uint8_t prev_count;
2615 var integer times_allowed[10] := { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
2616
2617 f_init(0, guard_timeout := 80.0);
2618
2619 f_bts_0_cfg(BSCVTY, {"rach access-control-class 4 barred",
2620 "access-control-class-rotate 0",
2621 "access-control-class-rotate-quantum 1",
2622 "access-control-class-ramping",
2623 "access-control-class-ramping-step-interval 5",
2624 "access-control-class-ramping-step-size 5"});
2625
2626 /* Init and get first sysinfo */
2627 f_init_bts_and_check_sysinfo(0, expect_si := ?);
2628 last_si1 := g_system_information[0].si1;
2629 acc := last_si1.rach_control.acc;
2630 count := f_acc09_count_allowed(acc);
2631 /* Adm subset size was set to 0 above, so wait until all ACC are barred */
2632 while (count > 0) {
2633 last_si1 := f_recv_next_si1(0);
2634 acc := last_si1.rach_control.acc;
2635 count := f_acc09_count_allowed(acc);
2636 log("RSL: wait len()=0: GOT SI1 ACC len=", count, ": ", acc);
2637 }
2638
2639 /* Increase adm subset size, we should see ramping start up */
2640 f_bts_0_cfg(BSCVTY, {"access-control-class-rotate 10"});
2641 prev_count := 0;
2642 while (true) {
2643 last_si1 := f_recv_next_si1(0);
2644 acc := last_si1.rach_control.acc;
2645 count := f_acc09_count_allowed(acc);
2646 log("RSL: GOT SI1 ACC len=", count, ": ", acc);
2647
2648 if (prev_count > count) {
2649 setverdict(fail, "ACC allowed count dropped while expecting grow: ", prev_count, " -> ", count);
2650 break;
2651 }
2652
2653 if (count == 9) {
2654 break; /* Maximum reached (10 - 1 perm barred), done here */
2655 }
2656
2657 prev_count := count;
2658 }
2659
2660 setverdict(pass);
2661
2662 f_bts_0_cfg(BSCVTY, {"access-control-class-rotate 10",
2663 "rach access-control-class 4 allowed",
2664 "no access-control-class-ramping"});
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002665 f_shutdown_helper();
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002666}
2667
Harald Welte4003d112017-12-09 22:35:39 +01002668testcase TC_ctrl_msc_connection_status() runs on test_CT {
2669 var charstring ctrl_resp;
2670
Harald Welte89d42e82017-12-17 16:42:41 +01002671 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01002672
2673 /* See https://osmocom.org/issues/2729 */
2674 f_ctrl_get_exp(IPA_CTRL, "msc_connection_status", "connected");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002675 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01002676}
2677
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01002678testcase TC_ctrl_msc0_connection_status() runs on test_CT {
2679 var charstring ctrl_resp;
2680
2681 f_init(1);
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01002682
2683 f_ctrl_get_exp(IPA_CTRL, "msc.0.connection_status", "connected");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002684 f_shutdown_helper();
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01002685}
2686
Harald Welte4003d112017-12-09 22:35:39 +01002687testcase TC_ctrl() runs on test_CT {
2688 var charstring ctrl_resp;
2689
Harald Welte89d42e82017-12-17 16:42:41 +01002690 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01002691
2692 /* all below values must match the osmo-bsc.cfg config file used */
2693
Harald Welte6a129692018-03-17 17:30:14 +01002694 f_ctrl_get_exp(IPA_CTRL, "mcc", "001");
2695 f_ctrl_get_exp(IPA_CTRL, "mnc", "01");
Oliver Smith75aa0202019-08-19 14:17:50 +02002696 f_ctrl_get_exp(IPA_CTRL, "number-of-bts", "4");
Harald Welte4003d112017-12-09 22:35:39 +01002697
2698 var integer bts_nr := 0;
2699 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "location-area-code", "1");
2700 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "cell-identity", "0");
2701 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "oml-connection-state", "connected");
2702 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "gprs-mode", "gprs");
2703 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "rf_state", "operational,unlocked,on");
2704 f_ctrl_get_exp_trx(IPA_CTRL, bts_nr, 0, "arfcn", "871");
2705 f_ctrl_get_exp_trx(IPA_CTRL, bts_nr, 0, "max-power-reduction", "20");
2706
2707 var integer uptime := str2int(f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-uptime"));
2708 f_sleep(2.0);
2709 if (str2int(f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-uptime")) < uptime+1) {
2710 setverdict(fail, "oml-uptime not incrementing as expected");
2711 }
2712 /* TODO: Disconnect RSL, imply that OML is disconnected and check for uptime zero? */
2713
2714 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted", 0);
2715
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002716 f_shutdown_helper();
Harald Welte96c94412017-12-09 03:12:45 +01002717}
2718
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +02002719/* Verify that Upon receival of SET "location", BSC forwards a TRAP
2720 "location-state" over the SCCPlite IPA conn */
2721testcase TC_ctrl_location() runs on test_CT {
2722 var MSC_ConnHdlr vc_conn;
2723 var integer bts_nr := 0;
2724
2725 f_init(1, true);
2726 f_sleep(1.0);
2727
2728 f_ctrl_set_bts(IPA_CTRL, bts_nr, "location", "1234567,fix3d,0.340000,0.560000,0.780000");
2729 f_ctrl_exp_trap(SCCPLITE_IPA_CTRL, "bts." & int2str(bts_nr) & ".location-state",
2730 "1234567,fix3d,0.340000,0.560000,0.780000,operational,unlocked,on,001,01");
2731
2732 f_ctrl_set(SCCPLITE_IPA_CTRL, "rf_locked", "1");
2733 f_sleep(2.0);
2734
2735 f_ctrl_set_bts(IPA_CTRL, bts_nr, "location", "1234888,fix3d,0.350000,0.570000,0.790000");
2736 f_ctrl_exp_trap(SCCPLITE_IPA_CTRL, "bts." & int2str(bts_nr) & ".location-state",
2737 "1234888,fix3d,0.350000,0.570000,0.790000,operational,locked,off,001,01");
2738
2739 /* should match the one from config */
2740 f_ctrl_set(SCCPLITE_IPA_CTRL, "rf_locked", "0");
2741
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002742 f_shutdown_helper();
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +02002743}
2744
Harald Welte6f521d82017-12-11 19:52:02 +01002745
2746/***********************************************************************
2747 * Paging Testing
2748 ***********************************************************************/
2749
2750type record Cell_Identity {
2751 GsmMcc mcc,
2752 GsmMnc mnc,
2753 GsmLac lac,
2754 GsmCellId ci
2755};
Harald Welte24135bd2018-03-17 19:27:53 +01002756private const Cell_Identity cid := { '001'H, '01'H, 1, 0 };
Stefan Sperling049a86e2018-03-20 15:51:00 +01002757private const Cell_Identity unknown_cid := { '678'H, 'f90'H, 1, 0 };
Harald Welte6f521d82017-12-11 19:52:02 +01002758
Harald Welte5d1a2202017-12-13 19:51:29 +01002759type set of integer BtsIdList;
2760
2761private function f_bts_in_list(integer bts_id, BtsIdList bts_ids) return boolean {
2762 for (var integer j := 0; j < sizeof(bts_ids); j := j + 1) {
2763 if (bts_id == bts_ids[j]) {
2764 return true;
2765 }
2766 }
2767 return false;
2768}
Harald Welte6f521d82017-12-11 19:52:02 +01002769
2770/* core paging test helper function; used by most paging test cases */
2771private function f_pageing_helper(hexstring imsi,
2772 template BSSMAP_FIELD_CellIdentificationList cid_list,
Harald Welte5d1a2202017-12-13 19:51:29 +01002773 BtsIdList bts_ids := { 0 },
Harald Welte6f521d82017-12-11 19:52:02 +01002774 template RSL_ChanNeeded rsl_chneed := omit,
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002775 template (omit) OCT4 tmsi := omit) runs on test_CT
Harald Welte6f521d82017-12-11 19:52:02 +01002776{
2777 var template BSSMAP_IE_ChannelNeeded bssmap_chneed;
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002778 var template MobileIdentityV mi;
Harald Welte6f521d82017-12-11 19:52:02 +01002779 var RSL_Message rx_rsl;
2780 var integer paging_group := hex2int(imsi[lengthof(imsi)-1]);
Harald Welte5d1a2202017-12-13 19:51:29 +01002781 var integer i;
Harald Welte6f521d82017-12-11 19:52:02 +01002782
2783 f_init();
Harald Welte6f521d82017-12-11 19:52:02 +01002784
2785 /* Clear the queue, it might still contain stuff like BCCH FILLING */
Harald Weltec3068592018-03-17 19:55:31 +01002786 for (i := 0; i < NUM_BTS; i := i + 1) {
2787 IPA_RSL[i].clear;
Harald Welte5d1a2202017-12-13 19:51:29 +01002788 }
Harald Welte6f521d82017-12-11 19:52:02 +01002789
2790 if (isvalue(rsl_chneed)) {
2791 /* The values of 08.08 3.2.2.36 and 08.58 9.3.40 are luckily identical */
2792 bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
2793 } else {
2794 bssmap_chneed := omit;
2795 }
2796
Neels Hofmeyrf246a922020-05-13 02:27:10 +02002797 BSSAP.send(ts_BSSAP_UNITDATA_req(g_bssap[0].sccp_addr_peer, g_bssap[0].sccp_addr_own,
2798 ts_BSSMAP_Paging(imsi, cid_list, tmsi, bssmap_chneed)));
Harald Welte6f521d82017-12-11 19:52:02 +01002799
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002800 if (not istemplatekind(tmsi, "omit")) {
2801 mi := t_MI_TMSI(tmsi);
Harald Welte6f521d82017-12-11 19:52:02 +01002802 } else {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002803 mi := tr_MI_IMSI(imsi);
Harald Welte6f521d82017-12-11 19:52:02 +01002804 }
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002805
Harald Welte5d1a2202017-12-13 19:51:29 +01002806 for (i := 0; i < sizeof(bts_ids); i := i + 1) {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002807 rx_rsl := f_exp_ipa_rx(bts_ids[i], tr_RSL_PAGING_CMD(mi));
Harald Welte5d1a2202017-12-13 19:51:29 +01002808 /* check channel type, paging group */
2809 if (rx_rsl.ies[1].body.paging_group != paging_group) {
2810 setverdict(fail, "Paging for wrong paging group");
2811 }
2812 if (ispresent(rsl_chneed) and
2813 rx_rsl.ies[3].body.chan_needed.chan_needed != valueof(rsl_chneed)) {
2814 setverdict(fail, "RSL Channel Needed != BSSMAP Channel Needed");
2815 }
Harald Welte6f521d82017-12-11 19:52:02 +01002816 }
Harald Welte2fccd982018-01-31 15:48:19 +01002817 f_sleep(2.0);
Harald Welte5d1a2202017-12-13 19:51:29 +01002818 /* do a quick check on all not-included BTSs if they received paging */
2819 for (i := 0; i < NUM_BTS; i := i + 1) {
2820 timer T := 0.1;
2821 if (f_bts_in_list(i, bts_ids)) {
2822 continue;
2823 }
2824 T.start;
2825 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07002826 [] IPA_RSL[i].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(mi))) {
Harald Welte5d1a2202017-12-13 19:51:29 +01002827 setverdict(fail, "Paging on BTS ", i, " which is not part of ", bts_ids);
2828 }
2829 [] IPA_RSL[i].receive { repeat; }
2830 [] T.timeout { }
2831 }
Harald Welte6f521d82017-12-11 19:52:02 +01002832 }
2833
2834 setverdict(pass);
2835}
2836
Harald Welte5d1a2202017-12-13 19:51:29 +01002837const BtsIdList c_BtsId_all := { 0, 1, 2 };
Harald Welte751d3eb2018-01-31 15:51:06 +01002838const BtsIdList c_BtsId_none := { };
Harald Welte5d1a2202017-12-13 19:51:29 +01002839const BtsIdList c_BtsId_LAC1 := { 0, 1 };
2840const BtsIdList c_BtsId_LAC2 := { 2 };
2841
Harald Welte6f521d82017-12-11 19:52:02 +01002842/* PAGING by IMSI + TMSI */
2843testcase TC_paging_imsi_nochan() runs on test_CT {
2844 var BSSMAP_FIELD_CellIdentificationList cid_list;
2845 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Philipp Maier8c04b0a2018-02-23 13:48:48 +01002846 f_pageing_helper('001010100000001'H, cid_list, c_BtsId_all, omit, omit);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002847 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002848}
2849
2850/* PAGING by IMSI + TMSI */
2851testcase TC_paging_tmsi_nochan() runs on test_CT {
2852 var BSSMAP_FIELD_CellIdentificationList cid_list;
2853 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002854 f_pageing_helper('001010100000001'H, cid_list, c_BtsId_all, omit, 'A1B2C301'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002855 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002856}
2857
2858/* Paging with different "channel needed' values */
2859testcase TC_paging_tmsi_any() runs on test_CT {
2860 var BSSMAP_FIELD_CellIdentificationList cid_list;
2861 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002862 f_pageing_helper('001010100000002'H, cid_list, c_BtsId_all, RSL_CHANNEED_ANY, 'A1B2C302'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002863 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002864}
2865testcase TC_paging_tmsi_sdcch() runs on test_CT {
2866 var BSSMAP_FIELD_CellIdentificationList cid_list;
2867 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002868 f_pageing_helper('001010100000003'H, cid_list, c_BtsId_all, RSL_CHANNEED_SDCCH, 'A1B2C303'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002869 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002870}
2871testcase TC_paging_tmsi_tch_f() runs on test_CT {
2872 var BSSMAP_FIELD_CellIdentificationList cid_list;
2873 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002874 f_pageing_helper('001010000000004'H, cid_list, c_BtsId_all, RSL_CHANNEED_TCH_F, 'A1B2C304'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002875 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002876}
2877testcase TC_paging_tmsi_tch_hf() runs on test_CT {
2878 var BSSMAP_FIELD_CellIdentificationList cid_list;
2879 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002880 f_pageing_helper('001010000000005'H, cid_list, c_BtsId_all, RSL_CHANNEED_TCH_ForH, 'A1B2C305'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002881 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002882}
2883
2884/* Paging by CGI */
2885testcase TC_paging_imsi_nochan_cgi() runs on test_CT {
2886 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2887 cid_list := { cIl_CGI := { ts_BSSMAP_CI_CGI(cid.mcc, cid.mnc, cid.lac, cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002888 f_pageing_helper('001010000000006'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01002889 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002890}
2891
2892/* Paging by LAC+CI */
2893testcase TC_paging_imsi_nochan_lac_ci() runs on test_CT {
2894 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2895 cid_list := { cIl_LAC_CI := { ts_BSSMAP_CI_LAC_CI(cid.lac, cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002896 f_pageing_helper('001010000000007'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01002897 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002898}
2899
2900/* Paging by CI */
2901testcase TC_paging_imsi_nochan_ci() runs on test_CT {
2902 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2903 cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002904 f_pageing_helper('001010000000008'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01002905 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002906}
2907
2908/* Paging by LAI */
2909testcase TC_paging_imsi_nochan_lai() runs on test_CT {
2910 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2911 cid_list := { cIl_LAI := { ts_BSSMAP_CI_LAI(cid.mcc, cid.mnc, cid.lac) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002912 f_pageing_helper('001010000000009'H, cid_list, c_BtsId_LAC1);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002913 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002914}
2915
2916/* Paging by LAC */
2917testcase TC_paging_imsi_nochan_lac() runs on test_CT {
2918 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2919 cid_list := { cIl_LAC := { ts_BSSMAP_CI_LAC(cid.lac) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002920 f_pageing_helper('001010000000010'H, cid_list, c_BtsId_LAC1);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002921 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002922}
2923
2924/* Paging by "all in BSS" */
2925testcase TC_paging_imsi_nochan_all() runs on test_CT {
2926 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2927 cid_list := { cIl_allInBSS := ''O };
Harald Welte5d1a2202017-12-13 19:51:29 +01002928 f_pageing_helper('001010000000011'H, cid_list, c_BtsId_all);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002929 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002930}
2931
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002932/* Paging by PLMN+LAC+RNC; We do not implement this; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01002933testcase TC_paging_imsi_nochan_plmn_lac_rnc() runs on test_CT {
2934 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2935 cid_list := { cIl_PLMN_LAC_RNC := { ts_BSSMAP_CI_PLMN_LAC_RNC(cid.mcc, cid.mnc, cid.lac, 12) } };
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002936 f_pageing_helper('001010000000012'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002937 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002938}
Harald Welte6f521d82017-12-11 19:52:02 +01002939
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002940/* Paging by RNC; We do not implement this; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01002941testcase TC_paging_imsi_nochan_rnc() runs on test_CT {
2942 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2943 cid_list := { cIl_RNC := { int2oct(13, 2) } };
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002944 f_pageing_helper('001010000000013'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002945 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002946}
2947
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002948/* Paging by LAC+RNC; We do not implement; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01002949testcase TC_paging_imsi_nochan_lac_rnc() runs on test_CT {
2950 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2951 cid_list := { cIl_LAC_RNC := { ts_BSSMAP_CI_LAC_RNC(cid.lac, 14) } };
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002952 f_pageing_helper('001010000000014'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002953 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002954}
2955
Harald Welte6f521d82017-12-11 19:52:02 +01002956/* Paging on multiple cells (multiple entries in list): Verify all of them page */
Harald Welte751d3eb2018-01-31 15:51:06 +01002957testcase TC_paging_imsi_nochan_lacs() runs on test_CT {
2958 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2959 cid_list := { cIl_LAC := { ts_BSSMAP_CI_LAC(1), ts_BSSMAP_CI_LAC(2) } };
2960 f_pageing_helper('001010000000015'H, cid_list, c_BtsId_all);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002961 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002962}
2963
2964/* Paging on empty list: Verify none of them page */
2965testcase TC_paging_imsi_nochan_lacs_empty() runs on test_CT {
2966 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2967 cid_list := { cIl_LAC := { } };
2968 f_pageing_helper('001010000000016'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002969 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002970}
2971
Stefan Sperling049a86e2018-03-20 15:51:00 +01002972/* Paging by CGI with unknown MCC/MNC: Verify nothing is paged. */
2973testcase TC_paging_imsi_nochan_cgi_unknown_cid() runs on test_CT {
2974 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2975 cid_list := { cIl_CGI := { ts_BSSMAP_CI_CGI(unknown_cid.mcc, unknown_cid.mnc, unknown_cid.lac, unknown_cid.ci) } };
2976 f_pageing_helper('001010000000006'H, cid_list, c_BtsId_none);
2977 f_shutdown_helper();
2978}
2979
Harald Welte6f521d82017-12-11 19:52:02 +01002980/* Verify paging retransmission interval + count */
2981/* Verify paging stops after channel establishment */
Harald Welte6f521d82017-12-11 19:52:02 +01002982/* Test behavior under paging overload */
Harald Welteae026692017-12-09 01:03:01 +01002983
Harald Weltee65d40e2017-12-13 00:09:06 +01002984/* Verify PCH load */
2985testcase TC_paging_imsi_load() runs on test_CT {
2986 var BSSMAP_FIELD_CellIdentificationList cid_list;
2987 timer T := 4.0;
Harald Welte2caa1062018-03-17 18:19:05 +01002988 timer T_retrans := 1.0;
Harald Weltee65d40e2017-12-13 00:09:06 +01002989 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002990 f_pageing_helper('001010123456789'H, cid_list, c_BtsId_all);
Harald Weltee65d40e2017-12-13 00:09:06 +01002991
2992 /* tell BSC there is no paging space anymore */
2993 f_ipa_tx(0, ts_RSL_PAGING_LOAD_IND(0));
Harald Welte3b57ab52018-03-17 18:01:10 +01002994 f_sleep(0.2);
2995 IPA_RSL[0].clear;
Harald Weltee65d40e2017-12-13 00:09:06 +01002996
2997 /* Wait for 4 seconds if any more PAGING CMD are received on RSL. Normally,
2998 * there would be 8 retransmissions during 4 seconds */
2999 T.start;
Harald Welte2caa1062018-03-17 18:19:05 +01003000 T_retrans.start;
Harald Weltee65d40e2017-12-13 00:09:06 +01003001 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07003002 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Weltee65d40e2017-12-13 00:09:06 +01003003 setverdict(fail, "Received PAGING after LOAD_IND(0)");
Daniel Willmannafce8662018-07-06 23:11:32 +02003004 mtc.stop;
Harald Weltee65d40e2017-12-13 00:09:06 +01003005 }
Harald Welte2caa1062018-03-17 18:19:05 +01003006 [] T_retrans.timeout {
3007 /* re-trnsmit the zero-space LOAD IND to avoid BSC 'auto credit' */
3008 f_ipa_tx(0, ts_RSL_PAGING_LOAD_IND(0));
3009 T_retrans.start;
3010 repeat;
3011 }
Harald Weltee65d40e2017-12-13 00:09:06 +01003012 [] T.timeout {
3013 setverdict(pass);
3014 }
3015 }
Philipp Maier282ca4b2018-02-27 17:17:00 +01003016
3017 f_shutdown_helper();
Harald Weltee65d40e2017-12-13 00:09:06 +01003018}
3019
Harald Welte235ebf12017-12-15 14:18:16 +01003020/* Verify Paging Counter */
Harald Welte1ff69992017-12-14 12:31:17 +01003021testcase TC_paging_counter() runs on test_CT {
3022 var BSSMAP_FIELD_CellIdentificationList cid_list;
3023 timer T := 4.0;
3024 var integer i;
3025 var integer paging_attempted_bsc;
3026 var integer paging_attempted_bts[NUM_BTS];
3027 var integer paging_expired_bts[NUM_BTS];
3028 cid_list := valueof(ts_BSSMAP_CIL_noCell);
3029
3030 f_init();
3031
3032 /* read counters before paging */
3033 paging_attempted_bsc := f_ctrl_get_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted");
3034 for (i := 0; i < NUM_BTS; i := i+1) {
3035 paging_attempted_bts[i] := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", i, "paging:attempted");
3036 paging_expired_bts[i] := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", i, "paging:expired");
3037 }
3038
3039 f_pageing_helper('001230000000001'H, cid_list, c_BtsId_all);
3040
3041 /* expect the attempted pages on BSC and each BTSs to have incremented by one */
3042 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted", paging_attempted_bsc+1);
3043 for (i := 0; i < NUM_BTS; i := i+1) {
3044 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", i, "paging:attempted",
3045 paging_attempted_bts[i]+1);
3046 }
3047
3048 /* assume that 12s later the paging on all BTSs have expired and hence incremented by 1 */
3049 f_sleep(12.0);
3050 for (i := 0; i < NUM_BTS; i := i+1) {
3051 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", i, "paging:expired",
3052 paging_expired_bts[i]+1);
3053 }
Harald Welte1ff69992017-12-14 12:31:17 +01003054
Philipp Maier282ca4b2018-02-27 17:17:00 +01003055 f_shutdown_helper();
Harald Welte1ff69992017-12-14 12:31:17 +01003056}
3057
3058
Harald Welte10985002017-12-12 09:29:15 +01003059/* Verify paging stops after A-RESET */
3060testcase TC_paging_imsi_a_reset() runs on test_CT {
3061 var BSSMAP_FIELD_CellIdentificationList cid_list;
3062 timer T := 3.0;
3063 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01003064 f_pageing_helper('001010123456789'H, cid_list, c_BtsId_all);
Harald Welte10985002017-12-12 09:29:15 +01003065
3066 /* Perform a BSSMAP Reset and wait for ACK */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003067 BSSAP.send(ts_BSSAP_UNITDATA_req(g_bssap[0].sccp_addr_peer, g_bssap[0].sccp_addr_own, ts_BSSMAP_Reset(0, g_osmux_enabled)));
Harald Welte10985002017-12-12 09:29:15 +01003068 alt {
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003069 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(g_bssap[0].sccp_addr_own, g_bssap[0].sccp_addr_peer, tr_BSSMAP_ResetAck(g_osmux_enabled))) { }
Harald Welte10985002017-12-12 09:29:15 +01003070 [] BSSAP.receive { repeat; }
3071 }
3072
Daniel Willmanncbef3982018-07-30 09:22:40 +02003073 /* Wait to avoid a possible race condition if a paging message is
3074 * received right before the reset ACK. */
3075 f_sleep(0.2);
3076
Harald Welte10985002017-12-12 09:29:15 +01003077 /* Clear the queue, it might still contain stuff like BCCH FILLING */
Philipp Maier1e6b4422018-02-23 14:02:13 +01003078 for (var integer i := 0; i < sizeof(IPA_RSL); i := i+1) {
3079 IPA_RSL[i].clear;
3080 }
Harald Welte10985002017-12-12 09:29:15 +01003081
3082 /* Wait for 3 seconds if any more PAGING CMD are received on RSL */
3083 T.start;
3084 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07003085 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Welte10985002017-12-12 09:29:15 +01003086 setverdict(fail, "Received PAGING after A-RESET");
Daniel Willmannafce8662018-07-06 23:11:32 +02003087 mtc.stop;
Harald Welte10985002017-12-12 09:29:15 +01003088 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07003089 [] IPA_RSL[1].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Welte5d1a2202017-12-13 19:51:29 +01003090 setverdict(fail, "Received PAGING after A-RESET");
Daniel Willmannafce8662018-07-06 23:11:32 +02003091 mtc.stop;
Harald Welte5d1a2202017-12-13 19:51:29 +01003092 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07003093 [] IPA_RSL[2].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Welte5d1a2202017-12-13 19:51:29 +01003094 setverdict(fail, "Received PAGING after A-RESET");
Daniel Willmannafce8662018-07-06 23:11:32 +02003095 mtc.stop;
Harald Welte5d1a2202017-12-13 19:51:29 +01003096 }
Harald Welte10985002017-12-12 09:29:15 +01003097 [] T.timeout {
3098 setverdict(pass);
3099 }
3100 }
Philipp Maier282ca4b2018-02-27 17:17:00 +01003101
3102 f_shutdown_helper();
Harald Welte10985002017-12-12 09:29:15 +01003103}
Harald Welteae026692017-12-09 01:03:01 +01003104
Philipp Maierf45824a2019-08-14 14:44:10 +02003105/* Verify how we handle unsolicited Paging Response. In case of an unsolicit
3106 * paging response we can not know which MSC is in charge, so we will blindly
3107 * pick the first configured MSC. This behavior is required in order to make
3108 * MT-CSFB calls working because in those cases the BSC can not know that the
3109 * MSC has already paged the subscriver via SGs. So any MT-CSFB call will look
3110 * like an unsolicited Paging Response to the MSC.
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003111 */
3112testcase TC_paging_resp_unsol() runs on test_CT {
3113
3114 f_init(1);
Philipp Maierf45824a2019-08-14 14:44:10 +02003115 timer T := 5.0;
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003116
3117 var BSSAP_N_CONNECT_ind rx_c_ind;
3118 var DchanTuple dt;
3119 var PDU_ML3_MS_NW l3 := valueof(ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010008880018'H))));
Philipp Maierf45824a2019-08-14 14:44:10 +02003120 var octetstring rr_pag_resp := enc_PDU_ML3_MS_NW(l3);
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003121
3122 /* Send CHAN RQD and wait for allocation; acknowledge it */
3123 dt.rsl_chan_nr := f_chreq_act_ack();
3124
3125 /* Send unsolicited Paging response (no matching Paging CMD stored in BSC) */
3126 f_ipa_tx(0, ts_RSL_EST_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)), enc_PDU_ML3_MS_NW(l3)));
3127
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003128
Philipp Maierf45824a2019-08-14 14:44:10 +02003129 /* Expevct a CR with a matching Paging response on the A-Interface */
3130 T.start;
3131 alt {
3132 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(rr_pag_resp))) {
3133 setverdict(pass);
3134 }
3135 [] BSSAP.receive {
3136 setverdict(fail, "Received unexpected message on A-Interface!");
3137 }
3138 [] T.timeout {
3139 setverdict(fail, "Received nothing on A-Interface!");
3140 }
3141 }
3142
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003143 f_shutdown_helper();
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003144}
3145
Harald Welte4e9b9cc2017-12-14 18:31:02 +01003146/* Test RSL link drop causes counter increment */
3147testcase TC_rsl_drop_counter() runs on test_CT {
3148 var integer rsl_fail;
3149
Harald Welte89d42e82017-12-17 16:42:41 +01003150 f_init(1);
Harald Welte4e9b9cc2017-12-14 18:31:02 +01003151
3152 rsl_fail := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "rsl_fail");
3153
3154 bts[0].rsl.vc_IPA.stop;
3155
3156 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "rsl_fail", rsl_fail+1);
3157
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003158 f_shutdown_helper();
Harald Welte4e9b9cc2017-12-14 18:31:02 +01003159}
3160
3161/* TODO: Test OML link drop causes counter increment */
3162
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003163/* The body of TC_rsl_unknown_unit_id() and TC_oml_unknown_unit_id() tests. */
3164function f_ipa_unknown_unit_id(integer mp_bsc_ipa_port) runs on test_CT return boolean {
3165 timer T := 10.0;
3166
3167 bts[0].rsl.id := "IPA-0-RSL";
3168 bts[0].rsl.vc_IPA := IPA_Emulation_CT.create(bts[0].rsl.id & "-IPA");
3169 bts[0].rsl.ccm_pars := c_IPA_default_ccm_pars;
3170 bts[0].rsl.ccm_pars.name := "Osmocom TTCN-3 BTS Simulator";
Oliver Smith92c2bdb2019-08-20 15:11:24 +02003171 bts[0].rsl.ccm_pars.unit_id := "99/0/0"; /* value which is unknown at BTS */
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003172
Pau Espin Pedrol9a5b8ff2021-01-04 19:01:31 +01003173 f_ipa_ctrl_start_client(mp_bsc_ip, mp_bsc_ctrl_port);
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003174
3175 f_init_mgcp("VirtMSC");
3176
3177 /* start RSL/OML connection (XXX re-uses RSL port/protocol definitions for OML) */
3178 map(bts[0].rsl.vc_IPA:IPA_PORT, system:IPA);
3179 connect(bts[0].rsl.vc_IPA:IPA_RSL_PORT, self:IPA_RSL[0]);
3180 bts[0].rsl.vc_IPA.start(IPA_Emulation.main_client(mp_bsc_ip, mp_bsc_ipa_port, "", 10000, bts[0].rsl.ccm_pars));
3181
3182 /* wait for IPA OML link to connect and then disconnect */
3183 T.start;
3184 alt {
Vadim Yanitskiya2afacc2020-05-18 21:16:19 +07003185 [] IPA_RSL[0].receive(tr_ASP_IPA_EV(ASP_IPA_EVENT_DOWN)) {
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003186 T.stop;
3187 return true;
3188 }
3189 [] IPA_RSL[0].receive { repeat }
3190 [] T.timeout {
Daniel Willmannafce8662018-07-06 23:11:32 +02003191 return false;
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003192 }
3193 }
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003194 return false;
3195}
3196
3197/* BSC should close an RSL connection from a BTS with unknown unit ID (OS#2714). */
3198testcase TC_rsl_unknown_unit_id() runs on test_CT {
3199 if (f_ipa_unknown_unit_id(mp_bsc_rsl_port)) {
3200 setverdict(pass);
3201 } else {
3202 setverdict(fail, "Timeout RSL waiting for connection to close");
3203 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003204 f_shutdown_helper();
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003205}
3206
3207
3208/* BSC should close an RSL connection from a BTS with unknown unit ID (OS#2714). */
3209testcase TC_oml_unknown_unit_id() runs on test_CT {
3210 if (f_ipa_unknown_unit_id(mp_bsc_oml_port)) {
3211 setverdict(pass);
3212 } else {
3213 setverdict(fail, "Timeout OML waiting for connection to close");
3214 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003215 f_shutdown_helper();
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003216}
3217
3218
Harald Weltec1a2fff2017-12-17 11:06:19 +01003219/***********************************************************************
Harald Welte6811d102019-04-14 22:23:14 +02003220 * "New world" test cases using RSL_Emulation + RAN_Emulation
Harald Weltec1a2fff2017-12-17 11:06:19 +01003221 ***********************************************************************/
3222
Harald Welte6811d102019-04-14 22:23:14 +02003223import from RAN_Emulation all;
Harald Welte47cd0e32020-08-21 12:39:11 +02003224import from BSSAP_LE_Emulation all;
Harald Weltec1a2fff2017-12-17 11:06:19 +01003225import from RSL_Emulation all;
3226import from MSC_ConnectionHandler all;
3227
3228type function void_fn(charstring id) runs on MSC_ConnHdlr;
3229
Harald Welte336820c2018-05-31 20:34:52 +02003230/* helper function to create and connect a MSC_ConnHdlr component */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003231private function f_connect_handler(inout MSC_ConnHdlr vc_conn, integer bssap_idx := 0) runs on test_CT {
3232 connect(vc_conn:RAN, g_bssap[bssap_idx].vc_RAN:PROC);
Daniel Willmann191e0d92018-01-17 12:44:35 +01003233 connect(vc_conn:MGCP_PROC, vc_MGCP:MGCP_PROC);
Harald Weltec1a2fff2017-12-17 11:06:19 +01003234 connect(vc_conn:RSL, bts[0].rsl.vc_RSL:CLIENT_PT);
Harald Weltef70df652018-01-29 22:00:23 +01003235 connect(vc_conn:RSL_PROC, bts[0].rsl.vc_RSL:RSL_PROC);
Philipp Maier88f4ae82018-03-01 14:00:58 +01003236 if (isvalue(bts[1])) {
Philipp Maier956a92f2018-02-16 10:58:07 +01003237 connect(vc_conn:RSL1, bts[1].rsl.vc_RSL:CLIENT_PT);
3238 connect(vc_conn:RSL1_PROC, bts[1].rsl.vc_RSL:RSL_PROC);
3239 }
Neels Hofmeyr91401012019-07-11 00:42:35 +02003240 if (isvalue(bts[2])) {
3241 connect(vc_conn:RSL2, bts[2].rsl.vc_RSL:CLIENT_PT);
3242 connect(vc_conn:RSL2_PROC, bts[2].rsl.vc_RSL:RSL_PROC);
3243 }
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003244 connect(vc_conn:BSSAP, g_bssap[bssap_idx].vc_RAN:CLIENT);
Neels Hofmeyrcfe44062020-10-15 02:28:08 +02003245 if (mp_enable_lcs_tests) {
3246 connect(vc_conn:BSSAP_LE, g_bssap_le.vc_BSSAP_LE:CLIENT);
3247 connect(vc_conn:BSSAP_LE_PROC, g_bssap_le.vc_BSSAP_LE:PROC);
3248 }
Daniel Willmann191e0d92018-01-17 12:44:35 +01003249 connect(vc_conn:MGCP, vc_MGCP:MGCP_CLIENT);
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02003250 connect(vc_conn:MGCP_MULTI, vc_MGCP:MGCP_CLIENT_MULTI);
Daniel Willmannebdecc02020-08-12 15:30:17 +02003251 connect(vc_conn:STATSD_PROC, vc_STATSD:STATSD_PROC);
Harald Welte336820c2018-05-31 20:34:52 +02003252}
3253
3254function f_start_handler(void_fn fn, template (omit) TestHdlrParams pars := omit)
3255runs on test_CT return MSC_ConnHdlr {
3256 var charstring id := testcasename();
3257 var MSC_ConnHdlr vc_conn;
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003258 var integer bssap_idx := 0;
3259 if (isvalue(pars)) {
3260 bssap_idx := valueof(pars).mscpool.bssap_idx;
3261 }
Harald Welte336820c2018-05-31 20:34:52 +02003262 vc_conn := MSC_ConnHdlr.create(id);
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003263 f_connect_handler(vc_conn, bssap_idx);
Neels Hofmeyr1708d1b2020-10-10 16:56:48 +02003264 /* Emit a marker to appear in the SUT's own logging output */
3265 f_logp(BSCVTY, testcasename() & "() start");
Harald Weltea0630032018-03-20 21:09:55 +01003266 vc_conn.start(f_handler_init(fn, id, pars));
Harald Weltec1a2fff2017-12-17 11:06:19 +01003267 return vc_conn;
3268}
3269
Harald Weltea0630032018-03-20 21:09:55 +01003270/* first function inside ConnHdlr component; sets g_pars + starts function */
3271private function f_handler_init(void_fn fn, charstring id, template (omit) TestHdlrParams pars := omit)
3272runs on MSC_ConnHdlr {
3273 if (isvalue(pars)) {
3274 g_pars := valueof(pars);
3275 }
3276 fn.apply(id);
3277}
3278
Harald Welte3c86ea02018-05-10 22:28:05 +02003279/* Establish signalling channel (non-assignment case) followed by cipher mode */
3280private function f_tc_ciph_mode_a5(charstring id) runs on MSC_ConnHdlr {
Harald Welteed848512018-05-24 22:27:58 +02003281 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3282 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte3c86ea02018-05-10 22:28:05 +02003283 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeSIGNAL);
Philipp Maier23000732018-05-18 11:25:37 +02003284 ass_cmd.pdu.bssmap.assignmentRequest.circuitIdentityCode := omit;
3285 ass_cmd.pdu.bssmap.assignmentRequest.aoIPTransportLayer := omit;
3286 exp_compl.pdu.bssmap.assignmentComplete.circuitIdentityCode := omit;
3287 exp_compl.pdu.bssmap.assignmentComplete.aoIPTransportLayer := omit;
Harald Welte3c86ea02018-05-10 22:28:05 +02003288
Philipp Maier23000732018-05-18 11:25:37 +02003289 f_establish_fully(ass_cmd, exp_compl);
Harald Welte3c86ea02018-05-10 22:28:05 +02003290}
3291testcase TC_ciph_mode_a5_0() runs on test_CT {
3292 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003293 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02003294 pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
3295
3296 f_init(1, true);
3297 f_sleep(1.0);
3298 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
3299 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003300 f_shutdown_helper();
Harald Welte3c86ea02018-05-10 22:28:05 +02003301}
3302testcase TC_ciph_mode_a5_1() runs on test_CT {
3303 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003304 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02003305 pars.encr := valueof(t_EncrParams('02'O, f_rnd_octstring(8)));
3306
3307 f_init(1, true);
3308 f_sleep(1.0);
3309 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
3310 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003311 f_shutdown_helper();
Harald Welte3c86ea02018-05-10 22:28:05 +02003312}
3313testcase TC_ciph_mode_a5_3() runs on test_CT {
3314 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003315 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02003316 pars.encr := valueof(t_EncrParams('08'O, f_rnd_octstring(8)));
3317
3318 f_init(1, true);
3319 f_sleep(1.0);
3320 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
3321 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003322 f_shutdown_helper();
Harald Welte3c86ea02018-05-10 22:28:05 +02003323}
3324
Pau Espin Pedrol07866632020-09-03 19:10:55 +02003325/* establish initial channel, enable ciphering followed by assignment to ciphered channel */
3326private function f_tc_assignment_aoip_tla_v6(charstring id) runs on MSC_ConnHdlr {
3327 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3328 var PDU_BSSAP ass_cmd := f_gen_ass_req(aoip_tla := "::3");
3329 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3330 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
3331
3332 f_establish_fully(ass_cmd, exp_compl);
3333}
3334testcase TC_assignment_aoip_tla_v6() runs on test_CT {
3335 var MSC_ConnHdlr vc_conn;
3336 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3337
3338 f_init(1, true);
3339 f_sleep(1.0);
3340 vc_conn := f_start_handler(refers(f_tc_assignment_aoip_tla_v6), pars);
3341 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003342 f_shutdown_helper();
Pau Espin Pedrol07866632020-09-03 19:10:55 +02003343}
3344
Harald Welte3c86ea02018-05-10 22:28:05 +02003345
3346/* establish initial channel, enable ciphering followed by assignment to ciphered channel */
Harald Welte651fcdc2018-05-10 20:23:16 +02003347private function f_tc_assignment_fr_a5(charstring id) runs on MSC_ConnHdlr {
Harald Welteed848512018-05-24 22:27:58 +02003348 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3349 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Weltec1a2fff2017-12-17 11:06:19 +01003350
Harald Welte552620d2017-12-16 23:21:36 +01003351 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3352 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Welte73cd2712017-12-17 00:44:52 +01003353
Harald Weltea0630032018-03-20 21:09:55 +01003354 f_establish_fully(ass_cmd, exp_compl);
Harald Welte552620d2017-12-16 23:21:36 +01003355}
Harald Welte552620d2017-12-16 23:21:36 +01003356testcase TC_assignment_fr_a5_0() runs on test_CT {
3357 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003358 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02003359 pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
Harald Welte552620d2017-12-16 23:21:36 +01003360
Harald Welte89d42e82017-12-17 16:42:41 +01003361 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01003362 f_sleep(1.0);
Harald Welte651fcdc2018-05-10 20:23:16 +02003363 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
Harald Welte552620d2017-12-16 23:21:36 +01003364 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003365 f_shutdown_helper();
Harald Welte552620d2017-12-16 23:21:36 +01003366}
Harald Welte552620d2017-12-16 23:21:36 +01003367testcase TC_assignment_fr_a5_1() runs on test_CT {
Harald Weltec1a2fff2017-12-17 11:06:19 +01003368 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003369 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02003370 pars.encr := valueof(t_EncrParams('02'O, f_rnd_octstring(8)));
Harald Weltec1a2fff2017-12-17 11:06:19 +01003371
Harald Welte89d42e82017-12-17 16:42:41 +01003372 f_init(1, true);
Harald Weltec1a2fff2017-12-17 11:06:19 +01003373 f_sleep(1.0);
Harald Welte651fcdc2018-05-10 20:23:16 +02003374 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
3375 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003376 f_shutdown_helper();
Harald Welte651fcdc2018-05-10 20:23:16 +02003377}
3378testcase TC_assignment_fr_a5_3() runs on test_CT {
3379 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003380 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02003381 pars.encr := valueof(t_EncrParams('08'O, f_rnd_octstring(8)));
Harald Weltec1a2fff2017-12-17 11:06:19 +01003382
Harald Welte651fcdc2018-05-10 20:23:16 +02003383 f_init(1, true);
3384 f_sleep(1.0);
3385 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
Harald Weltec1a2fff2017-12-17 11:06:19 +01003386 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003387 f_shutdown_helper();
Harald Weltec1a2fff2017-12-17 11:06:19 +01003388}
3389
Harald Welte552620d2017-12-16 23:21:36 +01003390/* Expect ASSIGNMENT FAIL if mandatory IE is missing */
3391private function f_tc_assignment_fr_a5_1_codec_missing(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02003392 g_pars := f_gen_test_hdlr_pars();
Harald Welte552620d2017-12-16 23:21:36 +01003393 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +02003394 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte552620d2017-12-16 23:21:36 +01003395 const OCT8 kc := '0001020304050607'O;
3396
3397 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02003398 /* Omit: ass_cmd.pdu.bssmap.assignmentRequest.codecList */
3399
Harald Weltea0630032018-03-20 21:09:55 +01003400 f_establish_fully(ass_cmd, exp_fail);
Harald Welte552620d2017-12-16 23:21:36 +01003401}
Harald Welte552620d2017-12-16 23:21:36 +01003402testcase TC_assignment_fr_a5_1_codec_missing() runs on test_CT {
3403 var MSC_ConnHdlr vc_conn;
3404
Harald Welte89d42e82017-12-17 16:42:41 +01003405 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01003406 f_sleep(1.0);
3407
Harald Welte8863fa12018-05-10 20:15:27 +02003408 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5_1_codec_missing));
Harald Welte552620d2017-12-16 23:21:36 +01003409 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003410 f_shutdown_helper();
Harald Welte552620d2017-12-16 23:21:36 +01003411}
3412
Harald Welte552620d2017-12-16 23:21:36 +01003413private function f_tc_assignment_fr_a5_4(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02003414 g_pars := f_gen_test_hdlr_pars();
Harald Welteed848512018-05-24 22:27:58 +02003415 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3416 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte552620d2017-12-16 23:21:36 +01003417 const OCT8 kc := '0001020304050607'O;
3418 const OCT16 kc128 := kc & kc;
3419
3420 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3421 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Weltea0630032018-03-20 21:09:55 +01003422 f_establish_fully(ass_cmd, exp_compl);
Harald Welte38b2a102017-12-23 02:42:58 +01003423 f_cipher_mode('10'O, kc, kc128, true);
Harald Welte552620d2017-12-16 23:21:36 +01003424 /* TODO: expect GSM0808_CAUSE_CIPHERING_ALGORITHM_NOT_SUPPORTED cause value */
Harald Welte552620d2017-12-16 23:21:36 +01003425}
Harald Welte552620d2017-12-16 23:21:36 +01003426testcase TC_assignment_fr_a5_4() runs on test_CT {
3427 var MSC_ConnHdlr vc_conn;
3428
Harald Welte89d42e82017-12-17 16:42:41 +01003429 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01003430 f_sleep(1.0);
3431
Harald Welte8863fa12018-05-10 20:15:27 +02003432 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5_4));
Harald Welte552620d2017-12-16 23:21:36 +01003433 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003434 f_shutdown_helper();
Harald Welte552620d2017-12-16 23:21:36 +01003435}
3436
3437
Harald Welte4532e0a2017-12-23 02:05:44 +01003438private function f_tc_assignment_sign(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02003439 g_pars := f_gen_test_hdlr_pars();
Harald Welte4532e0a2017-12-23 02:05:44 +01003440 var template PDU_BSSAP exp_compl := tr_BSSMAP_AssignmentComplete(omit, omit);
Philipp Maier48604732018-10-09 15:00:37 +02003441 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte4532e0a2017-12-23 02:05:44 +01003442 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeSIGNAL);
Daniel Willmannebdecc02020-08-12 15:30:17 +02003443
3444 f_statsd_reset();
Harald Weltea0630032018-03-20 21:09:55 +01003445 f_establish_fully(ass_cmd, exp_compl);
Daniel Willmannebdecc02020-08-12 15:30:17 +02003446
3447 var StatsDExpects expect := {
Daniel Willmannc5398f72020-09-21 10:41:35 +02003448 { name := "TTCN3.bts.0.chreq.total", mtype := "c", min := 1, max := 1},
3449 { name := "TTCN3.bts.0.chreq.successful", mtype := "c", min := 1, max := 1},
Daniel Willmannebdecc02020-08-12 15:30:17 +02003450 { name := "TTCN3.bsc.0.assignment.attempted", mtype := "c", min := 1, max := 1},
3451 { name := "TTCN3.bsc.0.assignment.completed", mtype := "c", min := 1, max := 1}
3452 };
3453 f_statsd_expect(expect);
Harald Welte4532e0a2017-12-23 02:05:44 +01003454}
3455
3456testcase TC_assignment_sign() runs on test_CT {
3457 var MSC_ConnHdlr vc_conn;
3458
3459 f_init(1, true);
3460 f_sleep(1.0);
3461
Harald Welte8863fa12018-05-10 20:15:27 +02003462 vc_conn := f_start_handler(refers(f_tc_assignment_sign));
Harald Welte4532e0a2017-12-23 02:05:44 +01003463 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003464 f_shutdown_helper();
Harald Welte4532e0a2017-12-23 02:05:44 +01003465}
3466
Harald Welte60aa5762018-03-21 19:33:13 +01003467/***********************************************************************
3468 * Codec (list) testing
3469 ***********************************************************************/
3470
3471/* check if the given rsl_mode is compatible with the a_elem */
3472private function f_match_codec(BSSMAP_FIELD_CodecElement a_elem, RSL_IE_ChannelMode rsl_mode)
3473return boolean {
3474 select (a_elem.codecType) {
3475 case (GSM_FR) {
3476 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM1))) {
3477 return true;
3478 }
3479 }
3480 case (GSM_HR) {
3481 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1))) {
3482 return true;
3483 }
3484 }
3485 case (GSM_EFR) {
3486 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM2))) {
3487 return true;
3488 }
3489 }
3490 case (FR_AMR) {
3491 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM3))) {
3492 return true;
3493 }
3494 }
3495 case (HR_AMR) {
3496 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM3))) {
3497 return true;
3498 }
3499 }
3500 case else { }
3501 }
3502 return false;
3503}
3504
3505/* check if the given rsl_mode is compatible with the a_list */
3506private function f_match_codecs(BSSMAP_IE_SpeechCodecList a_list, RSL_IE_ChannelMode rsl_mode)
3507return boolean {
3508 for (var integer i := 0; i < sizeof(a_list); i := i+1) {
3509 if (f_match_codec(a_list.codecElements[i], rsl_mode)) {
3510 return true;
3511 }
3512 }
3513 return false;
3514}
3515
3516/* determine BSSMAP_IE_ChannelType from *first* element of BSSMAP_FIELD_CodecElement */
Philipp Maier61f6b572018-07-06 14:03:38 +02003517function f_BSSMAP_chtype_from_codec(BSSMAP_FIELD_CodecElement a_elem)
Harald Welte60aa5762018-03-21 19:33:13 +01003518return BSSMAP_IE_ChannelType {
3519 /* FIXME: actually look at all elements of BSSMAP_IE_SpeechCodecList */
3520 var BSSMAP_IE_ChannelType ret := valueof(ts_BSSMAP_IE_ChannelType);
3521 select (a_elem.codecType) {
3522 case (GSM_FR) {
3523 ret.channelRateAndType := ChRate_TCHF;
3524 ret.speechId_DataIndicator := Spdi_TCHF_FR;
3525 }
3526 case (GSM_HR) {
3527 ret.channelRateAndType := ChRate_TCHH;
3528 ret.speechId_DataIndicator := Spdi_TCHH_HR;
3529 }
3530 case (GSM_EFR) {
3531 ret.channelRateAndType := ChRate_TCHF;
3532 ret.speechId_DataIndicator := Spdi_TCHF_EFR;
3533 }
3534 case (FR_AMR) {
3535 ret.channelRateAndType := ChRate_TCHF;
3536 ret.speechId_DataIndicator := Spdi_TCHF_AMR;
3537 }
3538 case (HR_AMR) {
3539 ret.channelRateAndType := ChRate_TCHH;
3540 ret.speechId_DataIndicator := Spdi_TCHH_AMR;
3541 }
3542 case else {
3543 setverdict(fail, "Unsupported codec ", a_elem);
Daniel Willmannafce8662018-07-06 23:11:32 +02003544 mtc.stop;
Harald Welte60aa5762018-03-21 19:33:13 +01003545 }
3546 }
3547 return ret;
3548}
3549
Harald Weltea63b9102018-03-22 20:36:16 +01003550private function f_rsl_chmod_tmpl_from_codec(BSSMAP_FIELD_CodecElement a_elem)
3551return template RSL_IE_Body {
3552 var template RSL_IE_Body mode_ie := {
3553 chan_mode := {
3554 len := ?,
3555 reserved := ?,
3556 dtx_d := ?,
3557 dtx_u := ?,
3558 spd_ind := RSL_SPDI_SPEECH,
3559 ch_rate_type := -,
3560 coding_alg_rate := -
3561 }
3562 }
3563
3564 select (a_elem.codecType) {
3565 case (GSM_FR) {
3566 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
3567 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM1;
3568 }
3569 case (GSM_HR) {
3570 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_H;
3571 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM1;
3572 }
3573 case (GSM_EFR) {
3574 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
3575 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM2;
3576 }
3577 case (FR_AMR) {
3578 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
3579 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM3;
3580 }
3581 case (HR_AMR) {
3582 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_H;
3583 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM3;
3584 }
3585 }
3586 return mode_ie;
3587}
3588
Harald Welte60aa5762018-03-21 19:33:13 +01003589type record CodecListTest {
3590 BSSMAP_IE_SpeechCodecList codec_list,
3591 charstring id
3592}
3593type record of CodecListTest CodecListTests
3594
3595private function f_TC_assignment_codec(charstring id) runs on MSC_ConnHdlr {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02003596 var PDU_BSSAP ass_cmd := f_gen_ass_req(g_pars.use_osmux);
3597 var template PDU_BSSAP exp_compl := f_gen_exp_compl(g_pars.use_osmux);
Harald Welte60aa5762018-03-21 19:33:13 +01003598
3599 /* puzzle together the ASSIGNMENT REQ for given codec[s] */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003600 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welte79f3f542018-05-25 20:02:37 +02003601 ass_cmd.pdu.bssmap.assignmentRequest.codecList := g_pars.ass_codec_list;
3602 exp_compl.pdu.bssmap.assignmentComplete.speechCodec.codecElements[0] :=
3603 g_pars.ass_codec_list.codecElements[0];
Philipp Maierd0e64b02019-03-13 14:15:23 +01003604 if (isvalue(g_pars.expect_mr_s0_s7)) {
3605 exp_compl.pdu.bssmap.assignmentComplete.speechCodec.codecElements[0].s0_7 :=
3606 g_pars.expect_mr_s0_s7;
3607 }
Harald Welte79f3f542018-05-25 20:02:37 +02003608 }
Harald Welte60aa5762018-03-21 19:33:13 +01003609 ass_cmd.pdu.bssmap.assignmentRequest.channelType :=
3610 f_BSSMAP_chtype_from_codec(g_pars.ass_codec_list.codecElements[0]);
Harald Welte60aa5762018-03-21 19:33:13 +01003611 log("expecting ASS COMPL like this: ", exp_compl);
3612
3613 f_establish_fully(ass_cmd, exp_compl);
Harald Weltea63b9102018-03-22 20:36:16 +01003614
Neels Hofmeyr559d5d02021-04-16 16:50:49 +02003615 if (not g_pars.expect_channel_mode_modify) {
3616 /* Verify that the RSL-side activation actually matches our expectations */
3617 var RSL_Message rsl := f_rslem_get_last_act(RSL_PROC, 0, g_chan_nr);
Harald Weltea63b9102018-03-22 20:36:16 +01003618
Neels Hofmeyr559d5d02021-04-16 16:50:49 +02003619 var RSL_IE_Body mode_ie;
3620 if (f_rsl_find_ie(rsl, RSL_IE_CHAN_MODE, mode_ie) == false) {
3621 setverdict(fail, "Couldn't find CHAN_MODE IE");
Daniel Willmannafce8662018-07-06 23:11:32 +02003622 mtc.stop;
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003623 }
Neels Hofmeyr559d5d02021-04-16 16:50:49 +02003624 var template RSL_IE_Body t_mode_ie := f_rsl_chmod_tmpl_from_codec(g_pars.ass_codec_list.codecElements[0]);
3625 if (not match(mode_ie, t_mode_ie)) {
3626 log("mode_ie ", mode_ie, " != t_mode_ie ", t_mode_ie);
3627 setverdict(fail, "RSL Channel Mode IE doesn't match expectation");
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003628 }
Neels Hofmeyr559d5d02021-04-16 16:50:49 +02003629
3630 var RSL_IE_Body mr_conf;
3631 if (g_pars.expect_mr_conf_ie != omit) {
3632 if (f_rsl_find_ie(rsl, RSL_IE_MR_CONFIG, mr_conf) == false) {
3633 setverdict(fail, "Missing MR CONFIG IE in RSL Chan Activ");
3634 mtc.stop;
3635 }
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003636 log("found RSL MR CONFIG IE: ", mr_conf);
Neels Hofmeyr559d5d02021-04-16 16:50:49 +02003637
3638 if (not match(mr_conf, g_pars.expect_mr_conf_ie)) {
3639 setverdict(fail, "RSL MR CONFIG IE does not match expectation. Expected: ",
3640 g_pars.expect_mr_conf_ie);
3641 }
3642 } else {
3643 if (f_rsl_find_ie(rsl, RSL_IE_MR_CONFIG, mr_conf) == true) {
3644 log("found RSL MR CONFIG IE: ", mr_conf);
3645 setverdict(fail, "Found MR CONFIG IE in RSL Chan Activ, expecting omit");
3646 mtc.stop;
3647 }
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003648 }
3649 }
Harald Welte60aa5762018-03-21 19:33:13 +01003650}
3651
Philipp Maierd0e64b02019-03-13 14:15:23 +01003652private function f_TC_assignment_codec_fail(charstring id) runs on MSC_ConnHdlr {
3653
3654 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3655 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
3656
3657 /* puzzle together the ASSIGNMENT REQ for given codec[s] */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003658 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Philipp Maierd0e64b02019-03-13 14:15:23 +01003659 ass_cmd.pdu.bssmap.assignmentRequest.codecList := g_pars.ass_codec_list;
3660 }
3661 ass_cmd.pdu.bssmap.assignmentRequest.channelType :=
3662 f_BSSMAP_chtype_from_codec(g_pars.ass_codec_list.codecElements[0]);
3663 log("expecting ASS FAIL like this: ", exp_fail);
3664
3665 f_establish_fully(ass_cmd, exp_fail);
3666}
3667
Harald Welte60aa5762018-03-21 19:33:13 +01003668testcase TC_assignment_codec_fr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003669 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003670 var MSC_ConnHdlr vc_conn;
3671
3672 f_init(1, true);
3673 f_sleep(1.0);
3674
3675 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Welte8863fa12018-05-10 20:15:27 +02003676 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003677 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003678 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01003679}
3680
3681testcase TC_assignment_codec_hr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003682 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003683 var MSC_ConnHdlr vc_conn;
3684
3685 f_init(1, true);
3686 f_sleep(1.0);
3687
3688 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
Harald Welte8863fa12018-05-10 20:15:27 +02003689 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003690 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003691 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01003692}
3693
3694testcase TC_assignment_codec_efr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003695 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003696 var MSC_ConnHdlr vc_conn;
3697
3698 f_init(1, true);
3699 f_sleep(1.0);
3700
3701 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecEFR}));
Harald Welte8863fa12018-05-10 20:15:27 +02003702 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003703 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003704 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01003705}
3706
Philipp Maierd0e64b02019-03-13 14:15:23 +01003707/* Allow 5,90k only (current default config) */
3708private function f_allow_amr_rate_5_90k() runs on test_CT {
Neels Hofmeyr2a5670b2020-11-25 23:39:57 +00003709 f_vty_cfg_msc(BSCVTY, 0, {
3710 "amr-config 12_2k forbidden",
3711 "amr-config 10_2k forbidden",
3712 "amr-config 7_95k forbidden",
3713 "amr-config 7_40k forbidden",
3714 "amr-config 6_70k forbidden",
3715 "amr-config 5_90k allowed",
3716 "amr-config 5_15k forbidden",
3717 "amr-config 4_75k forbidden"
3718 });
Philipp Maierd0e64b02019-03-13 14:15:23 +01003719}
3720
3721/* Allow 4,75k, 5,90k, 4,70k and 12,2k, which are the most common rates
3722 * ("Config-NB-Code = 1") */
3723private function f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k() runs on test_CT {
Neels Hofmeyr2a5670b2020-11-25 23:39:57 +00003724 f_vty_cfg_msc(BSCVTY, 0, {
3725 "amr-config 12_2k allowed",
3726 "amr-config 10_2k forbidden",
3727 "amr-config 7_95k forbidden",
3728 "amr-config 7_40k allowed",
3729 "amr-config 6_70k forbidden",
3730 "amr-config 5_90k allowed",
3731 "amr-config 5_15k forbidden",
3732 "amr-config 4_75k allowed"
3733 });
Philipp Maierd0e64b02019-03-13 14:15:23 +01003734}
3735
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003736private function f_vty_amr_start_mode_set(boolean fr, charstring startmode) runs on test_CT {
3737 var charstring tch;
3738 if (fr) {
3739 tch := "tch-f";
3740 } else {
3741 tch := "tch-h";
3742 }
3743 f_vty_cfg_bts(BSCVTY, 0, { "amr " & tch & " start-mode " & startmode });
3744}
3745
3746/* Set the AMR start-mode for this TCH back to the default configuration. */
3747private function f_vty_amr_start_mode_restore(boolean fr) runs on test_CT {
3748 f_vty_amr_start_mode_set(fr, "auto");
3749}
3750
Harald Welte60aa5762018-03-21 19:33:13 +01003751testcase TC_assignment_codec_amr_f() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003752 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003753 var MSC_ConnHdlr vc_conn;
Philipp Maier7695a0d2018-09-27 17:52:14 +02003754
3755 /* Note: This setups the codec configuration. The parameter payload in
3756 * mr_conf must be consistant with the parameter codecElements in pars
3757 * and also must match the amr-config in osmo-bsc.cfg! */
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003758 var RSL_IE_Body mr_conf := {
3759 other := {
3760 len := 2,
3761 payload := '2804'O
3762 }
3763 };
Harald Welte60aa5762018-03-21 19:33:13 +01003764
Philipp Maier7695a0d2018-09-27 17:52:14 +02003765 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
Philipp Maier806f8f12019-03-12 12:13:41 +01003766 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
Philipp Maier7695a0d2018-09-27 17:52:14 +02003767 pars.ass_codec_list.codecElements[0].s8_15 := '01010111'B;
3768 pars.expect_mr_conf_ie := mr_conf;
3769
Harald Welte60aa5762018-03-21 19:33:13 +01003770 f_init(1, true);
3771 f_sleep(1.0);
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003772 f_vty_amr_start_mode_set(true, "1");
Harald Welte60aa5762018-03-21 19:33:13 +01003773
Harald Welte8863fa12018-05-10 20:15:27 +02003774 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003775 vc_conn.done;
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003776
3777 f_vty_amr_start_mode_restore(true);
Vadim Yanitskiy292e5962021-01-03 14:18:47 +01003778 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01003779}
3780
3781testcase TC_assignment_codec_amr_h() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003782 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003783 var MSC_ConnHdlr vc_conn;
Philipp Maier7695a0d2018-09-27 17:52:14 +02003784
3785 /* See note above */
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003786 var RSL_IE_Body mr_conf := {
3787 other := {
3788 len := 2,
3789 payload := '2804'O
3790 }
3791 };
Harald Welte60aa5762018-03-21 19:33:13 +01003792
Philipp Maier7695a0d2018-09-27 17:52:14 +02003793 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
Philipp Maier806f8f12019-03-12 12:13:41 +01003794 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
Philipp Maier7695a0d2018-09-27 17:52:14 +02003795 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
3796 pars.expect_mr_conf_ie := mr_conf;
3797
Harald Welte60aa5762018-03-21 19:33:13 +01003798 f_init(1, true);
3799 f_sleep(1.0);
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003800 f_vty_amr_start_mode_set(false, "1");
Harald Welte60aa5762018-03-21 19:33:13 +01003801
Harald Welte8863fa12018-05-10 20:15:27 +02003802 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003803 vc_conn.done;
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003804
3805 f_vty_amr_start_mode_restore(false);
Vadim Yanitskiy292e5962021-01-03 14:18:47 +01003806 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01003807}
3808
Neels Hofmeyr559d5d02021-04-16 16:50:49 +02003809/* Establish signalling on a TCH/F lchan, and then switch to speech mode without a new Assignment. */
3810testcase TC_assignment_codec_fr_by_mode_modify() runs on test_CT {
3811 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3812 var MSC_ConnHdlr vc_conn;
3813
3814 f_init(1, true);
3815 f_sleep(1.0);
3816
3817 /* By disabling all SDCCH, the MS should be given a TCH/F for signalling. Then activating an FR codec should
3818 * merely do a Channel Mode Modify, and not assign to a new lchan. f_establish_fully() already accounts for
3819 * expecting a Channel Mode Modify if the channel type is compatible. */
3820 f_disable_all_sdcch();
3821 f_disable_all_tch_h();
3822
3823 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
3824 pars.expect_channel_mode_modify := true;
3825 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
3826 vc_conn.done;
3827
3828 f_enable_all_sdcch();
3829 f_enable_all_tch();
3830 f_shutdown_helper();
3831}
3832
Neels Hofmeyr454d7922020-11-26 02:24:57 +00003833/* 'amr start-mode auto' should not keep the (unused) 'smod' bits from previous configuration */
3834testcase TC_assignment_codec_amr_startmode_cruft() runs on test_CT {
3835 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3836 var MSC_ConnHdlr vc_conn;
3837
3838 var RSL_IE_Body mr_conf := {
3839 other := {
3840 len := 2,
3841 payload := '2004'O /* <- expect ICMI=0, smod=00 */
3842 }
3843 };
3844
3845 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
3846 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
3847 pars.ass_codec_list.codecElements[0].s8_15 := '01010111'B;
3848 pars.expect_mr_conf_ie := mr_conf;
3849
3850 f_init(1, true);
3851 f_sleep(1.0);
3852
3853 /* First set nonzero start mode bits */
3854 f_vty_amr_start_mode_set(true, "4");
3855 /* Now set to auto, and expect the startmode bits to be zero in the message, i.e. ensure that osmo-bsc does not
3856 * let the startmode bits stick around and has deterministic MultiRate config for 'start-mode auto'; that is
3857 * ensured by above '2004'O, where 'x0xx'O indicates ICMI = 0, spare = 0, smod = 00. */
3858 f_vty_amr_start_mode_set(true, "auto");
3859
3860 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
3861 vc_conn.done;
Neels Hofmeyr454d7922020-11-26 02:24:57 +00003862
3863 /* Clear the startmode bits to not affect subsequent tests, in case the bits should indeed stick around. */
3864 f_vty_amr_start_mode_set(true, "1");
3865 f_vty_amr_start_mode_restore(true);
Vadim Yanitskiy292e5962021-01-03 14:18:47 +01003866 f_shutdown_helper();
Neels Hofmeyr454d7922020-11-26 02:24:57 +00003867}
3868
Neels Hofmeyr21863562020-11-26 00:34:33 +00003869function f_TC_assignment_codec_amr(boolean fr, octetstring mrconf, bitstring s8_s0, bitstring exp_s8_s0,
3870 charstring start_mode := "1")
Philipp Maierd0e64b02019-03-13 14:15:23 +01003871runs on test_CT {
3872
3873 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3874 var MSC_ConnHdlr vc_conn;
3875
3876 /* See note above */
3877 var RSL_IE_Body mr_conf := {
3878 other := {
3879 len := lengthof(mrconf),
3880 payload := mrconf
3881 }
3882 };
3883
3884 if (fr) {
3885 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
3886 } else {
3887 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
3888 }
3889 pars.ass_codec_list.codecElements[0].s0_7 := s8_s0;
3890 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
3891 pars.expect_mr_conf_ie := mr_conf;
3892 pars.expect_mr_s0_s7 := exp_s8_s0;
3893
3894 f_init(1, true);
3895 f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k();
Neels Hofmeyr21863562020-11-26 00:34:33 +00003896 f_vty_amr_start_mode_set(fr, start_mode);
Philipp Maierd0e64b02019-03-13 14:15:23 +01003897 f_sleep(1.0);
3898
3899 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
3900 vc_conn.done;
3901 f_allow_amr_rate_5_90k();
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003902 f_vty_amr_start_mode_restore(fr);
Philipp Maierd0e64b02019-03-13 14:15:23 +01003903}
3904
3905function f_TC_assignment_codec_amr_fail(boolean fr, bitstring s8_s0)
3906runs on test_CT {
3907
3908 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3909 var MSC_ConnHdlr vc_conn;
3910
3911 if (fr) {
3912 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
3913 } else {
3914 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
3915 }
3916 pars.ass_codec_list.codecElements[0].s0_7 := s8_s0;
3917 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
3918
3919 f_init(1, true);
3920 f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k();
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003921 f_vty_amr_start_mode_set(fr, "1");
Philipp Maierd0e64b02019-03-13 14:15:23 +01003922 f_sleep(1.0);
3923
3924 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fail), pars);
3925 vc_conn.done;
3926 f_allow_amr_rate_5_90k();
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003927 f_vty_amr_start_mode_restore(fr);
Philipp Maierd0e64b02019-03-13 14:15:23 +01003928}
3929
3930
3931/* Set S1, we expect an AMR multirate configuration IE with all four rates
3932 * set. */
3933testcase TC_assignment_codec_amr_f_S1() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003934 f_TC_assignment_codec_amr(true, '289520882208'O, '00000010'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003935 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003936}
3937
3938/* Set S1, we expect an AMR multirate configuration IE with the lower three
3939 * rates set. */
3940testcase TC_assignment_codec_amr_h_S1() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003941 f_TC_assignment_codec_amr(false, '2815208820'O, '00000010'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003942 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003943}
3944
3945/* Set S1 and two other rates, we expect an AMR MULTIRATE CONFIGURATION IE with
3946 * all four rates (and only S1 set in the ASSIGNMENT COMPLETE) */
3947testcase TC_assignment_codec_amr_f_S124() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003948 f_TC_assignment_codec_amr(true, '289520882208'O, '00010110'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003949 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003950}
3951
3952/* Set S1 and two other rates, we expect an AMR MULTIRATE CONFIGURATION IE with
3953 * all four rates (and only S1 set in the ASSIGNMENT COMPLETE) */
3954testcase TC_assignment_codec_amr_h_S124() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003955 f_TC_assignment_codec_amr(false, '2815208820'O, '00010110'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003956 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003957}
3958
3959/* The following block of tests selects more and more rates until all four
3960 * possible rates are in the active set (full rate) */
3961testcase TC_assignment_codec_amr_f_S0() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003962 f_TC_assignment_codec_amr(true, '2801'O, '00000001'B, '00000001'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003963 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003964}
3965
3966testcase TC_assignment_codec_amr_f_S02() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003967 f_TC_assignment_codec_amr(true, '28052080'O, '00000101'B, '00000101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003968 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003969}
3970
3971testcase TC_assignment_codec_amr_f_S024() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003972 f_TC_assignment_codec_amr(true, '2815208820'O, '00010101'B, '00010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003973 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003974}
3975
3976testcase TC_assignment_codec_amr_f_S0247() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003977 f_TC_assignment_codec_amr(true, '289520882208'O, '10010101'B, '10010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003978 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003979}
3980
3981/* The following block of tests selects more and more rates until all three
3982 * possible rates are in the active set (half rate) */
3983testcase TC_assignment_codec_amr_h_S0() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003984 f_TC_assignment_codec_amr(false, '2801'O, '00000001'B, '00000001'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_h_S02() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003989 f_TC_assignment_codec_amr(false, '28052080'O, '00000101'B, '00000101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003990 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003991}
3992
3993testcase TC_assignment_codec_amr_h_S024() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003994 f_TC_assignment_codec_amr(false, '2815208820'O, '00010101'B, '00010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003995 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003996}
3997
3998/* The following block tests what happens when the MSC does offer rate
3999 * configurations that are not supported by the BSC. Normally such situations
4000 * should not happen because the MSC gets informed by the BSC in advance via
4001 * the L3 COMPLETE message which rates are applicable. The MSC should not try
4002 * to offer rates that are not applicable anyway. */
4003
4004testcase TC_assignment_codec_amr_h_S0247() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004005 /* Try to include 12,2k in into the active set even though the channel
4006 * is half rate only. The BSC is expected to remove the 12,0k */
4007 f_TC_assignment_codec_amr(false, '2815208820'O, '10010101'B, '00010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004008 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004009}
4010
4011testcase TC_assignment_codec_amr_f_S01234567() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004012 /* See what happens when all rates are selected at once. Since then
4013 * Also S1 is selected, this setting will be prefered and we should
4014 * get 12.2k, 7,40k, 5,90k, and 4,75k in the active set. */
4015 f_TC_assignment_codec_amr(true, '289520882208'O, '11111111'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004016 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004017}
4018
4019testcase TC_assignment_codec_amr_f_S0234567() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004020 /* Same as above, but with S1 missing, the MSC is then expected to
4021 * select the currently supported rates, which are also 12.2k, 7,40k,
4022 * 5,90k, and 4,75k, into the active set. */
4023 f_TC_assignment_codec_amr(true, '289520882208'O, '11111101'B, '10010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004024 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004025}
4026
4027testcase TC_assignment_codec_amr_f_zero() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004028 /* Try to select no rates at all */
4029 f_TC_assignment_codec_amr_fail(true, '00000000'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004030 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004031}
4032
4033testcase TC_assignment_codec_amr_f_unsupp() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004034 /* Try to select only unsupported rates */
4035 f_TC_assignment_codec_amr_fail(true, '01101000'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004036 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004037}
4038
4039testcase TC_assignment_codec_amr_h_S7() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004040 /* Try to select 12,2k for half rate */
4041 f_TC_assignment_codec_amr_fail(false, '10000000'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004042 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004043}
4044
Neels Hofmeyr21863562020-11-26 00:34:33 +00004045testcase TC_assignment_codec_amr_f_start_mode_auto() runs on test_CT {
4046 f_TC_assignment_codec_amr(true, '209520882208'O, '11111111'B, '00000010'B,
4047 start_mode := "auto");
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01004048 f_shutdown_helper();
Neels Hofmeyr21863562020-11-26 00:34:33 +00004049}
4050
4051testcase TC_assignment_codec_amr_h_start_mode_auto() runs on test_CT {
4052 f_TC_assignment_codec_amr(false, '2015208820'O, '10010101'B, '00010101'B,
4053 start_mode := "auto");
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01004054 f_shutdown_helper();
Neels Hofmeyr21863562020-11-26 00:34:33 +00004055}
4056
Neels Hofmeyr3eb94562020-11-26 02:40:26 +00004057testcase TC_assignment_codec_amr_f_start_mode_4() runs on test_CT {
Vadim Yanitskiy7815f482021-01-03 17:07:37 +01004058 /* "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 +00004059 f_TC_assignment_codec_amr(true, '2b9520882208'O, '11111111'B, '00000010'B,
4060 start_mode := "4");
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01004061 f_shutdown_helper();
Neels Hofmeyr3eb94562020-11-26 02:40:26 +00004062}
4063
4064testcase TC_assignment_codec_amr_h_start_mode_4() runs on test_CT {
Vadim Yanitskiy7815f482021-01-03 17:07:37 +01004065 /* "amr tch-h modes 0 2 4" => total 3 modes and start mode 4 => '10'B on the wire */
4066 f_TC_assignment_codec_amr(false, '2a15208820'O, '10010101'B, '00010101'B,
Neels Hofmeyr3eb94562020-11-26 02:40:26 +00004067 start_mode := "4");
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01004068 f_shutdown_helper();
Neels Hofmeyr3eb94562020-11-26 02:40:26 +00004069}
4070
Philipp Maierac09bfc2019-01-08 13:41:39 +01004071private function f_disable_all_tch_f() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01004072 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 1 sub-slot 0 borken");
4073 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 2 sub-slot 0 borken");
4074 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 3 sub-slot 0 borken");
4075 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 4 sub-slot 0 borken");
Philipp Maierac09bfc2019-01-08 13:41:39 +01004076}
4077
4078private function f_disable_all_tch_h() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01004079 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 0 borken");
4080 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 1 borken");
Philipp Maierac09bfc2019-01-08 13:41:39 +01004081}
4082
4083private function f_enable_all_tch() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01004084 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 1 sub-slot 0 unused");
4085 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 2 sub-slot 0 unused");
4086 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 3 sub-slot 0 unused");
4087 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 4 sub-slot 0 unused");
4088 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 0 unused");
4089 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 1 unused");
Philipp Maierac09bfc2019-01-08 13:41:39 +01004090}
4091
Neels Hofmeyr559d5d02021-04-16 16:50:49 +02004092private function f_disable_all_sdcch() runs on test_CT {
4093 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 0 sub-slot 0 borken");
4094 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 0 sub-slot 1 borken");
4095 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 0 sub-slot 2 borken");
4096 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 0 sub-slot 3 borken");
4097}
4098
4099private function f_enable_all_sdcch() runs on test_CT {
4100 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 0 sub-slot 0 unused");
4101 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 0 sub-slot 1 unused");
4102 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 0 sub-slot 2 unused");
4103 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 0 sub-slot 3 unused");
4104}
4105
Philipp Maierac09bfc2019-01-08 13:41:39 +01004106/* Allow HR only */
4107private function f_TC_assignment_codec_xr_exhausted_req_hr(charstring id) runs on MSC_ConnHdlr {
4108 g_pars := f_gen_test_hdlr_pars();
4109 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4110 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4111 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4112 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '09'O;
4113 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '05'O;
4114 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
4115 f_establish_fully(ass_cmd, exp_compl);
4116}
4117
4118/* Allow FR only */
4119private function f_TC_assignment_codec_xr_exhausted_req_fr(charstring id) runs on MSC_ConnHdlr {
4120 g_pars := f_gen_test_hdlr_pars();
4121 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4122 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4123 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4124 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '08'O;
4125 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '01'O;
4126 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4127 f_establish_fully(ass_cmd, exp_compl);
4128}
4129
4130/* Allow HR only (expect assignment failure) */
4131private function f_TC_assignment_codec_xr_exhausted_req_hr_fail(charstring id) runs on MSC_ConnHdlr {
4132 g_pars := f_gen_test_hdlr_pars();
4133 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4134 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
4135 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4136 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '09'O;
4137 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '05'O;
4138 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
4139 f_establish_fully(ass_cmd, exp_fail);
4140}
4141
4142/* Allow FR only (expect assignment failure) */
4143private function f_TC_assignment_codec_xr_exhausted_req_fr_fail(charstring id) runs on MSC_ConnHdlr {
4144 g_pars := f_gen_test_hdlr_pars();
4145 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4146 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
4147 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4148 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '08'O;
4149 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '01'O;
4150 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4151 f_establish_fully(ass_cmd, exp_fail);
4152}
4153
4154/* Allow FR and HR, but prefer FR */
4155private function f_TC_assignment_codec_fr_exhausted_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
4156 g_pars := f_gen_test_hdlr_pars();
4157 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4158 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4159 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4160 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
4161 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
4162 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
4163 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
4164 f_establish_fully(ass_cmd, exp_compl);
4165}
4166
4167/* Allow FR and HR, but prefer HR */
4168private function f_TC_assignment_codec_fr_exhausted_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
4169 g_pars := f_gen_test_hdlr_pars();
4170 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4171 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4172 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4173 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
4174 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
4175 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
4176 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
4177 f_establish_fully(ass_cmd, exp_compl);
4178}
4179
4180/* Allow FR and HR, but prefer FR */
4181private function f_TC_assignment_codec_hr_exhausted_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
4182 g_pars := f_gen_test_hdlr_pars();
4183 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4184 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4185 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4186 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
4187 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
4188 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
4189 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
4190 f_establish_fully(ass_cmd, exp_compl);
4191}
4192
4193/* Allow FR and HR, but prefer HR */
4194private function f_TC_assignment_codec_hr_exhausted_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
4195 g_pars := f_gen_test_hdlr_pars();
4196 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4197 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4198 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4199 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
4200 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
4201 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
4202 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
4203 f_establish_fully(ass_cmd, exp_compl);
4204}
4205
4206/* Request a HR channel while all FR channels are exhausted, this is expected
4207 * to work without conflicts */
4208testcase TC_assignment_codec_fr_exhausted_req_hr() runs on test_CT {
4209 var MSC_ConnHdlr vc_conn;
4210 f_init(1, true);
4211 f_sleep(1.0);
4212 f_enable_all_tch();
4213 f_disable_all_tch_f();
4214 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_hr));
4215 vc_conn.done;
4216 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004217 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004218}
4219
4220/* Request a FR channel while all FR channels are exhausted, this is expected
4221 * to fail. */
4222testcase TC_assignment_codec_fr_exhausted_req_fr() runs on test_CT {
4223 var MSC_ConnHdlr vc_conn;
4224 f_init(1, true);
4225 f_sleep(1.0);
4226 f_enable_all_tch();
4227 f_disable_all_tch_f();
4228 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_fr_fail));
4229 vc_conn.done;
4230 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004231 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004232}
4233
4234/* Request a FR (prefered) or alternatively a HR channel while all FR channels
4235 * are exhausted, this is expected to be resolved by selecting a HR channel. */
4236testcase TC_assignment_codec_fr_exhausted_req_fr_hr() runs on test_CT {
4237 var MSC_ConnHdlr vc_conn;
4238 f_init(1, true);
4239 f_sleep(1.0);
4240 f_enable_all_tch();
4241 f_disable_all_tch_f();
4242 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fr_exhausted_req_fr_hr));
4243 vc_conn.done;
4244 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004245 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004246}
4247
4248/* Request a HR (prefered) or alternatively a FR channel while all FR channels
4249 * are exhausted, this is expected to work without conflicts. */
4250testcase TC_assignment_codec_fr_exhausted_req_hr_fr() runs on test_CT {
4251 var MSC_ConnHdlr vc_conn;
4252 f_init(1, true);
4253 f_sleep(1.0);
4254 f_enable_all_tch();
4255 f_disable_all_tch_f();
4256 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fr_exhausted_req_hr_fr));
4257 vc_conn.done;
4258 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004259 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004260}
4261
4262/* Request a FR channel while all HR channels are exhausted, this is expected
4263 * to work without conflicts */
4264testcase TC_assignment_codec_hr_exhausted_req_fr() runs on test_CT {
4265 var MSC_ConnHdlr vc_conn;
4266 f_init(1, true);
4267 f_sleep(1.0);
4268 f_enable_all_tch();
4269 f_disable_all_tch_h();
4270 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_fr));
4271 vc_conn.done;
4272 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004273 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004274}
4275
4276/* Request a HR channel while all HR channels are exhausted, this is expected
4277 * to fail. */
4278testcase TC_assignment_codec_hr_exhausted_req_hr() runs on test_CT {
4279 var MSC_ConnHdlr vc_conn;
4280 f_init(1, true);
4281 f_sleep(1.0);
4282 f_enable_all_tch();
4283 f_disable_all_tch_h();
4284 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_hr_fail));
4285 vc_conn.done;
4286 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004287 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004288}
4289
4290/* Request a HR (prefered) or alternatively a FR channel while all HR channels
4291 * are exhausted, this is expected to be resolved by selecting a FR channel. */
4292testcase TC_assignment_codec_hr_exhausted_req_hr_fr() runs on test_CT {
4293 var MSC_ConnHdlr vc_conn;
4294 f_init(1, true);
4295 f_sleep(1.0);
4296 f_enable_all_tch();
4297 f_disable_all_tch_h();
4298 vc_conn := f_start_handler(refers(f_TC_assignment_codec_hr_exhausted_req_hr_fr));
4299 vc_conn.done;
4300 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004301 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004302}
4303
4304/* Request a FR (prefered) or alternatively a HR channel while all HR channels
4305 * are exhausted, this is expected to work without conflicts. */
4306testcase TC_assignment_codec_hr_exhausted_req_fr_hr() runs on test_CT {
4307 var MSC_ConnHdlr vc_conn;
4308 f_init(1, true);
4309 f_sleep(1.0);
4310 f_enable_all_tch();
4311 f_disable_all_tch_h();
4312 vc_conn := f_start_handler(refers(f_TC_assignment_codec_hr_exhausted_req_fr_hr));
4313 vc_conn.done;
4314 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004315 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004316}
4317
4318/* Allow FR and HR, but prefer HR */
4319private function f_TC_assignment_codec_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
4320 g_pars := f_gen_test_hdlr_pars();
4321 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4322 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4323 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4324 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
4325 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
4326 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
4327 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
4328 f_establish_fully(ass_cmd, exp_compl);
4329}
4330
4331/* Allow FR and HR, but prefer FR */
4332private function f_TC_assignment_codec_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
4333 g_pars := f_gen_test_hdlr_pars();
4334 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4335 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4336 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4337 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
4338 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
4339 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
4340 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
4341 f_establish_fully(ass_cmd, exp_compl);
4342}
4343
4344/* Request a HR (prefered) or alternatively a FR channel, it is expected that
4345 * HR, which is the prefered type, is selected. */
4346testcase TC_assignment_codec_req_hr_fr() runs on test_CT {
4347 var MSC_ConnHdlr vc_conn;
4348 f_init(1, true);
4349 f_sleep(1.0);
4350 f_enable_all_tch();
4351 vc_conn := f_start_handler(refers(f_TC_assignment_codec_req_hr_fr));
4352 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004353 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004354}
4355
4356/* Request a FR (prefered) or alternatively a HR channel, it is expected that
4357 * FR, which is the prefered type, is selected. */
4358testcase TC_assignment_codec_req_fr_hr() runs on test_CT {
4359 var MSC_ConnHdlr vc_conn;
4360 f_init(1, true);
4361 f_sleep(1.0);
4362 f_enable_all_tch();
4363 vc_conn := f_start_handler(refers(f_TC_assignment_codec_req_fr_hr));
4364 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004365 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004366}
4367
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02004368testcase TC_assignment_osmux() runs on test_CT {
4369 var TestHdlrParams pars := f_gen_test_hdlr_pars();
4370 var MSC_ConnHdlr vc_conn;
4371
4372 /* See note above */
4373 var RSL_IE_Body mr_conf := {
4374 other := {
4375 len := 2,
4376 payload := '2804'O
4377 }
4378 };
4379
4380 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
4381 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
4382 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
4383 pars.expect_mr_conf_ie := mr_conf;
4384 pars.use_osmux := true;
4385
4386 f_init(1, true, true);
4387 f_sleep(1.0);
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00004388 f_vty_amr_start_mode_set(false, "1");
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02004389
4390 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
4391 vc_conn.done;
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00004392
4393 f_vty_amr_start_mode_restore(false);
Vadim Yanitskiy292e5962021-01-03 14:18:47 +01004394 f_shutdown_helper();
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02004395}
4396
Neels Hofmeyr92b12b72018-09-18 14:30:23 +02004397/* test the procedure of the MSC requesting a Classmark Update:
4398 * a) BSSMAP Classmark Request should result in RR CLASSMARK ENQUIRY,
4399 * b) L3 RR CLASSMARK CHANGE should result in BSSMAP CLASSMARK UPDATE */
Harald Welte898113b2018-01-31 18:32:21 +01004400private function f_tc_classmark(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004401 g_pars := f_gen_test_hdlr_pars();
4402
Harald Weltea0630032018-03-20 21:09:55 +01004403 f_create_chan_and_exp();
Harald Welte898113b2018-01-31 18:32:21 +01004404 /* we should now have a COMPL_L3 at the MSC */
4405 BSSAP.receive(tr_BSSMAP_ComplL3);
4406
Neels Hofmeyr92b12b72018-09-18 14:30:23 +02004407 BSSAP.send(ts_BSSMAP_ClassmarkRequest);
4408 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_CM_ENQUIRY));
4409
Harald Welte898113b2018-01-31 18:32:21 +01004410 f_rsl_send_l3(ts_RRM_CM_CHG(valueof(ts_CM2)));
4411 BSSAP.receive(tr_BSSMAP_ClassmarkUpd(?, omit));
4412 setverdict(pass);
4413}
4414testcase TC_classmark() runs on test_CT {
4415 var MSC_ConnHdlr vc_conn;
4416 f_init(1, true);
4417 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004418 vc_conn := f_start_handler(refers(f_tc_classmark));
Harald Welte898113b2018-01-31 18:32:21 +01004419 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004420 f_shutdown_helper();
Harald Welte898113b2018-01-31 18:32:21 +01004421}
4422
Harald Welteeddf0e92020-06-21 19:42:15 +02004423/* Send a CommonID from the simulated MSC and verify that the information is used to
4424 * fill BSC-internal data structures (specifically, bsc_subscr associated with subscr_conn) */
4425private function f_tc_common_id(charstring id) runs on MSC_ConnHdlr {
4426 g_pars := f_gen_test_hdlr_pars();
4427 f_MscConnHdlr_init_vty();
4428
4429 f_create_chan_and_exp();
4430 /* we should now have a COMPL_L3 at the MSC */
4431 BSSAP.receive(tr_BSSMAP_ComplL3);
4432
4433 /* Send CommonID */
4434 BSSAP.send(ts_BSSMAP_CommonId(g_pars.imsi));
4435
4436 /* Use VTY to verify that the IMSI of the subscr_conn is set */
4437 var charstring regex := "*(IMSI: " & hex2str(g_pars.imsi) & ")*";
4438 f_vty_transceive_match_regexp_retry(BSCVTY, "show conns", regex, 0, 4, 1.0);
4439
4440 setverdict(pass);
4441}
4442testcase TC_common_id() runs on test_CT {
4443 var MSC_ConnHdlr vc_conn;
4444 f_init(1, true);
4445 f_sleep(1.0);
4446 vc_conn := f_start_handler(refers(f_tc_common_id));
4447 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004448 f_shutdown_helper();
Harald Welteeddf0e92020-06-21 19:42:15 +02004449}
4450
Harald Weltee3bd6582018-01-31 22:51:25 +01004451private function f_est_single_l3(template PDU_ML3_MS_NW l3) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004452 g_pars := f_gen_test_hdlr_pars();
Harald Weltea0630032018-03-20 21:09:55 +01004453 f_create_chan_and_exp();
Harald Welte898113b2018-01-31 18:32:21 +01004454 /* we should now have a COMPL_L3 at the MSC */
4455 BSSAP.receive(tr_BSSMAP_ComplL3);
4456
Harald Weltee3bd6582018-01-31 22:51:25 +01004457 /* send the single message we want to send */
4458 f_rsl_send_l3(l3);
4459}
4460
4461private function f_bssap_expect_nothing(float sec := 5.00) runs on MSC_ConnHdlr {
4462 timer T := sec;
4463 var PDU_BSSAP bssap;
Harald Welte898113b2018-01-31 18:32:21 +01004464 T.start;
4465 alt {
Harald Weltee3bd6582018-01-31 22:51:25 +01004466 [] BSSAP.receive(PDU_BSSAP:?) -> value bssap {
4467 setverdict(fail, "Unexpected BSSMAP ", bssap);
Daniel Willmannafce8662018-07-06 23:11:32 +02004468 mtc.stop;
Harald Welte898113b2018-01-31 18:32:21 +01004469 }
4470 [] T.timeout {
4471 setverdict(pass);
4472 }
4473 }
4474}
4475
Harald Weltee3bd6582018-01-31 22:51:25 +01004476/* unsolicited ASSIGNMENT FAIL (without ASSIGN) from MS shouldn't bring BSC down */
4477private function f_tc_unsol_ass_fail(charstring id) runs on MSC_ConnHdlr {
4478 f_est_single_l3(ts_RRM_AssignmentFailure('00'O));
4479 f_bssap_expect_nothing();
4480}
Harald Welte898113b2018-01-31 18:32:21 +01004481testcase TC_unsol_ass_fail() runs on test_CT {
4482 var MSC_ConnHdlr vc_conn;
4483 f_init(1, true);
4484 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004485 vc_conn := f_start_handler(refers(f_tc_unsol_ass_fail));
Harald Welte898113b2018-01-31 18:32:21 +01004486 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004487 f_shutdown_helper();
Harald Welte898113b2018-01-31 18:32:21 +01004488}
Harald Welte552620d2017-12-16 23:21:36 +01004489
Harald Welteea99a002018-01-31 20:46:43 +01004490
4491/* unsolicited ASSIGNMENT COMPLETE (without ASSIGN) from MS shouldn't bring BSC down */
4492private function f_tc_unsol_ass_compl(charstring id) runs on MSC_ConnHdlr {
Harald Weltee3bd6582018-01-31 22:51:25 +01004493 f_est_single_l3(ts_RRM_AssignmentComplete('00'O));
4494 f_bssap_expect_nothing();
Harald Welteea99a002018-01-31 20:46:43 +01004495}
4496testcase TC_unsol_ass_compl() runs on test_CT {
4497 var MSC_ConnHdlr vc_conn;
4498 f_init(1, true);
4499 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004500 vc_conn := f_start_handler(refers(f_tc_unsol_ass_compl));
Harald Welteea99a002018-01-31 20:46:43 +01004501 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004502 f_shutdown_helper();
Harald Welteea99a002018-01-31 20:46:43 +01004503}
4504
4505
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004506/* unsolicited HANDOVER FAIL (without ASSIGN) from MS shouldn't bring BSC down */
4507private function f_tc_unsol_ho_fail(charstring id) runs on MSC_ConnHdlr {
Harald Weltee3bd6582018-01-31 22:51:25 +01004508 f_est_single_l3(ts_RRM_HandoverFailure('00'O));
4509 f_bssap_expect_nothing();
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004510}
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004511testcase TC_unsol_ho_fail() runs on test_CT {
4512 var MSC_ConnHdlr vc_conn;
4513 f_init(1, true);
4514 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004515 vc_conn := f_start_handler(refers(f_tc_unsol_ho_fail));
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004516 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004517 f_shutdown_helper();
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004518}
4519
4520
Harald Weltee3bd6582018-01-31 22:51:25 +01004521/* short message from MS should be ignored */
4522private function f_tc_err_82_short_msg(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004523 g_pars := f_gen_test_hdlr_pars();
Harald Weltea0630032018-03-20 21:09:55 +01004524 f_create_chan_and_exp();
Harald Weltee3bd6582018-01-31 22:51:25 +01004525 /* we should now have a COMPL_L3 at the MSC */
4526 BSSAP.receive(tr_BSSMAP_ComplL3);
4527
4528 /* send short message */
4529 RSL.send(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), ''O));
4530 f_bssap_expect_nothing();
4531}
4532testcase TC_err_82_short_msg() runs on test_CT {
4533 var MSC_ConnHdlr vc_conn;
4534 f_init(1, true);
4535 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004536 vc_conn := f_start_handler(refers(f_tc_err_82_short_msg));
Harald Weltee3bd6582018-01-31 22:51:25 +01004537 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004538 f_shutdown_helper();
Harald Weltee3bd6582018-01-31 22:51:25 +01004539}
4540
4541
Harald Weltee9e02e42018-01-31 23:36:25 +01004542/* 24.008 8.4 Unknown message must trigger RR STATUS */
4543private function f_tc_err_84_unknown_msg(charstring id) runs on MSC_ConnHdlr {
4544 f_est_single_l3(ts_RRM_UL_REL('00'O));
4545 timer T := 3.0
4546 alt {
4547 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_STATUS)) {
4548 setverdict(pass);
4549 }
4550 [] BSSAP.receive { setverdict(fail, "unexpected BSSAP"); }
Harald Welte458fd372018-03-21 11:26:23 +01004551 [] T.timeout { setverdict(fail, "Timeout waiting for RR STATUS"); }
Harald Weltee9e02e42018-01-31 23:36:25 +01004552 }
4553}
4554testcase TC_err_84_unknown_msg() runs on test_CT {
4555 var MSC_ConnHdlr vc_conn;
4556 f_init(1, true);
4557 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004558 vc_conn := f_start_handler(refers(f_tc_err_84_unknown_msg));
Harald Weltee9e02e42018-01-31 23:36:25 +01004559 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004560 f_shutdown_helper();
Harald Weltee9e02e42018-01-31 23:36:25 +01004561}
4562
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004563/***********************************************************************
4564 * Handover
4565 ***********************************************************************/
4566
Harald Welte94e0c342018-04-07 11:33:23 +02004567/* execute a "bts <0-255> trx <0-255> timeslot <0-7> " command on given Dchan */
4568private function f_vty_ts_action(charstring suffix, integer bts_nr, integer trx_nr, integer ts_nr)
4569runs on test_CT {
4570 var charstring cmd := "bts "&int2str(bts_nr)&" trx "&int2str(trx_nr)&
4571 " timeslot "&int2str(ts_nr)&" ";
4572 f_vty_transceive(BSCVTY, cmd & suffix);
4573}
4574
Harald Welte261af4b2018-02-12 21:20:39 +01004575/* 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 +07004576private function f_vty_ss_action(TELNETasp_PT pt, charstring suffix,
4577 uint8_t bts_nr, uint8_t trx_nr,
4578 in RslChannelNr chan_nr)
4579{
Harald Welte261af4b2018-02-12 21:20:39 +01004580 /* FIXME: resolve those from component-global state */
4581 var integer ts_nr := chan_nr.tn;
4582 var integer ss_nr;
4583 if (ischosen(chan_nr.u.ch0)) {
4584 ss_nr := 0;
4585 } else if (ischosen(chan_nr.u.lm)) {
4586 ss_nr := chan_nr.u.lm.sub_chan;
4587 } else if (ischosen(chan_nr.u.sdcch4)) {
4588 ss_nr := chan_nr.u.sdcch4.sub_chan;
4589 } else if (ischosen(chan_nr.u.sdcch8)) {
4590 ss_nr := chan_nr.u.sdcch8.sub_chan;
4591 } else {
4592 setverdict(fail, "Invalid ChanNr ", chan_nr);
Daniel Willmannafce8662018-07-06 23:11:32 +02004593 mtc.stop;
Harald Welte261af4b2018-02-12 21:20:39 +01004594 }
4595
4596 var charstring cmd := "bts "&int2str(bts_nr)&" trx "&int2str(trx_nr)&
4597 " timeslot "&int2str(ts_nr)&" sub-slot "&int2str(ss_nr)&" ";
Vadim Yanitskiy00070722020-09-02 17:27:57 +07004598 f_vty_transceive(pt, cmd & suffix);
Harald Welte261af4b2018-02-12 21:20:39 +01004599}
4600
Neels Hofmeyr91401012019-07-11 00:42:35 +02004601/* Even though the VTY command to trigger handover takes a new BTS number as argument, behind the scenes osmo-bsc always
4602 * translates that to a target ARFCN+BSIC first. See bsc_vty.c trigger_ho_or_as(), which puts the selected BTS' neighbor
4603 * ident key (ARFCN + BSIC) in the struct passed on to handover_request(). handover_start() then resolves that to a
4604 * viable actual neighbor cell. So from the internal osmo-bsc perspective, we always request handover to an ARFCN + BSIC
4605 * pair, not really to a specific BTS number. */
Vadim Yanitskiy00070722020-09-02 17:27:57 +07004606private function f_vty_handover(TELNETasp_PT pt, uint8_t bts_nr, uint8_t trx_nr,
4607 in RslChannelNr chan_nr, uint8_t new_bts_nr)
4608{
4609 f_vty_ss_action(pt, "handover " & int2str(new_bts_nr), bts_nr, trx_nr, chan_nr);
Harald Welte261af4b2018-02-12 21:20:39 +01004610}
4611
4612/* intra-BSC hand-over between BTS0 and BTS1 */
4613private function f_tc_ho_int(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004614 g_pars := f_gen_test_hdlr_pars();
Harald Welteed848512018-05-24 22:27:58 +02004615 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4616 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte261af4b2018-02-12 21:20:39 +01004617 const OCT8 kc := '0001020304050607'O;
4618
4619 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4620 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4621
Harald Weltea0630032018-03-20 21:09:55 +01004622 f_establish_fully(ass_cmd, exp_compl);
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004623 f_bts_0_cfg(BSCVTY, {"neighbor bts 1"});
Harald Welte261af4b2018-02-12 21:20:39 +01004624
4625 var HandoverState hs := {
4626 rr_ho_cmpl_seen := false,
4627 handover_done := false,
4628 old_chan_nr := -
4629 };
4630 /* issue hand-over command on VTY */
Vadim Yanitskiy00070722020-09-02 17:27:57 +07004631 f_vty_handover(BSCVTY, 0, 0, g_chan_nr, 1);
Harald Welte261af4b2018-02-12 21:20:39 +01004632 /* temporarily suspend DChan processing on BTS1 to avoid race with RSLEM_register */
4633 f_rslem_suspend(RSL1_PROC);
Philipp Maier3e2af5d2018-07-11 17:01:05 +02004634
4635 /* From the MGW perspective, a handover is is characterized by
4636 * performing one MDCX operation with the MGW. So we expect to see
4637 * one more MDCX during handover. */
4638 g_media.mgcp_conn[0].mdcx_seen_exp := g_media.mgcp_conn[0].crcx_seen_exp + 1;
4639
Harald Welte261af4b2018-02-12 21:20:39 +01004640 alt {
4641 [] as_handover(hs);
Harald Welte261af4b2018-02-12 21:20:39 +01004642 }
Philipp Maier3e2af5d2018-07-11 17:01:05 +02004643
Philipp Maier4dae0652018-11-12 12:03:26 +01004644 /* Since this is an internal handover we expect the BSC to inform the
4645 * MSC about the event */
4646 BSSAP.receive(tr_BSSMAP_HandoverPerformed);
4647
Philipp Maier3e2af5d2018-07-11 17:01:05 +02004648 /* Check the amount of MGCP transactions is still consistant with the
4649 * test expectation */
4650 f_check_mgcp_expectations()
Neels Hofmeyr861a4c12018-11-07 01:23:17 +01004651 f_sleep(0.5);
Harald Welte261af4b2018-02-12 21:20:39 +01004652}
4653
4654testcase TC_ho_int() runs on test_CT {
4655 var MSC_ConnHdlr vc_conn;
4656 f_init(2, true);
4657 f_sleep(1.0);
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004658
4659 f_ctrs_bsc_and_bts_init();
4660
Harald Welte8863fa12018-05-10 20:15:27 +02004661 vc_conn := f_start_handler(refers(f_tc_ho_int));
Harald Welte261af4b2018-02-12 21:20:39 +01004662 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004663
4664 /* from f_establish_fully() */
4665 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4666 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4667 /* from handover */
4668 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4669 f_ctrs_bsc_and_bts_add(0, "handover:completed");
4670 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
4671 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:completed");
4672 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004673 f_shutdown_helper();
Harald Welte261af4b2018-02-12 21:20:39 +01004674}
Harald Weltee9e02e42018-01-31 23:36:25 +01004675
Neels Hofmeyr5f144212020-11-03 15:41:58 +00004676/* intra-BSC hand-over with CONNection FAILure and cause Radio Link Failure: check RR release cause */
4677private function f_tc_ho_int_radio_link_failure(charstring id) runs on MSC_ConnHdlr {
4678 g_pars := f_gen_test_hdlr_pars();
4679 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4680 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4681 const OCT8 kc := '0001020304050607'O;
4682
4683 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4684 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4685
4686 f_establish_fully(ass_cmd, exp_compl);
4687 f_bts_0_cfg(BSCVTY, {"neighbor bts 1"});
4688
4689 var HandoverState hs := {
4690 rr_ho_cmpl_seen := false,
4691 handover_done := false,
4692 old_chan_nr := -
4693 };
4694 /* issue hand-over command on VTY */
4695 f_vty_handover(BSCVTY, 0, 0, g_chan_nr, 1);
4696 /* temporarily suspend DChan processing on BTS1 to avoid race with RSLEM_register */
4697 f_rslem_suspend(RSL1_PROC);
4698
4699 /* From the MGW perspective, a handover is is characterized by
4700 * performing one MDCX operation with the MGW. So we expect to see
4701 * one more MDCX during handover. */
4702 g_media.mgcp_conn[0].mdcx_seen_exp := g_media.mgcp_conn[0].crcx_seen_exp + 1;
4703
4704 var RSL_Message rsl;
4705 var PDU_ML3_NW_MS l3;
4706 var RslChannelNr new_chan_nr;
4707 var GsmArfcn arfcn;
4708 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr)) -> value rsl {
4709 l3 := dec_PDU_ML3_NW_MS(rsl.ies[2].body.l3_info.payload);
4710 if (not ischosen(l3.msgs.rrm.handoverCommand)) {
4711 setverdict(fail, "Expected handoverCommand");
4712 mtc.stop;
4713 }
4714 }
4715 f_ChDesc2RslChanNr(l3.msgs.rrm.handoverCommand.channelDescription2,
4716 new_chan_nr, arfcn);
4717
4718 f_rslem_register(0, new_chan_nr, RSL1_PROC);
4719
4720 /* resume processing of RSL DChan messages, which was temporarily suspended
4721 * before performing a hand-over */
4722 f_rslem_resume(RSL1_PROC);
4723 RSL1.receive(tr_RSL_IPA_CRCX(new_chan_nr));
4724
4725 f_sleep(1.0);
4726
4727 /* Handover fails because no HANDO DET appears on the new lchan,
4728 * and the old lchan reports a Radio Link Failure. */
4729 RSL.send(ts_RSL_CONN_FAIL_IND(g_chan_nr, RSL_ERR_RADIO_LINK_FAIL));
4730
4731 var PDU_BSSAP rx_clear_request;
4732 BSSAP.receive(tr_BSSMAP_ClearRequest) -> value rx_clear_request;
4733 var BssmapCause cause := bit2int(rx_clear_request.pdu.bssmap.clearRequest.cause.causeValue);
4734 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
4735
4736 var RR_Cause rr_cause := GSM48_RR_CAUSE_ABNORMAL_UNSPEC;
4737
4738 var MgcpCommand mgcp;
4739 interleave {
4740 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE(int2oct(enum2int(rr_cause), 1)))) {}
4741 [] RSL.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {}
4742 [] RSL.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
4743 RSL.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
4744 }
4745 [] RSL1.receive(tr_RSL_DEACT_SACCH(new_chan_nr)) {}
4746 [] RSL1.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
4747 RSL1.send(ts_RSL_RF_CHAN_REL_ACK(new_chan_nr));
4748 }
4749 [] BSSAP.receive(tr_BSSMAP_ClearComplete) {}
4750 }
4751
4752 f_sleep(0.5);
4753 setverdict(pass);
4754}
4755testcase TC_ho_int_radio_link_failure() runs on test_CT {
4756 var MSC_ConnHdlr vc_conn;
4757 f_init(2, true);
4758 f_sleep(1.0);
4759
4760 f_ctrs_bsc_and_bts_init();
4761
4762 vc_conn := f_start_handler(refers(f_tc_ho_int_radio_link_failure));
4763 vc_conn.done;
4764
4765 /* from f_establish_fully() */
4766 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4767 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4768 /* from handover */
4769 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4770 f_ctrs_bsc_and_bts_add(0, "handover:stopped");
4771 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
4772 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:stopped");
4773 f_ctrs_bsc_and_bts_verify();
4774 f_shutdown_helper();
4775}
4776
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004777/* Expecting MGCP to DLCX the endpoint's two connections: towards BTS and towards MSC */
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004778private function f_expect_dlcx_conns() runs on MSC_ConnHdlr {
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004779 var MgcpCommand mgcp;
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02004780 var template MgcpResponse mgcp_resp;
4781 var MGCP_RecvFrom mrf;
4782 var template MgcpMessage msg_resp;
4783 var template MgcpMessage msg_dlcx := {
4784 command := tr_DLCX()
4785 }
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004786
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02004787 if (g_pars.aoip) {
4788 MGCP.receive(tr_DLCX()) -> value mgcp {
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004789 log("Got first DLCX: ", mgcp);
4790 MGCP.send(ts_DLCX_ACK2(mgcp.line.trans_id));
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02004791 };
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004792
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004793 MGCP.receive(tr_DLCX()) -> value mgcp {
4794 log("Got second DLCX: ", mgcp);
4795 MGCP.send(ts_DLCX_ACK2(mgcp.line.trans_id));
4796 };
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02004797 } else {
4798 /* For SCCPLite, BSC doesn't handle the MSC-side */
4799 MGCP_MULTI.receive(tr_MGCP_RecvFrom_any(msg_dlcx)) -> value mrf {
4800 log("Got first DLCX: ", mrf.msg.command);
4801 msg_resp := {
4802 response := ts_DLCX_ACK2(mrf.msg.command.line.trans_id)
4803 }
4804 MGCP_MULTI.send(t_MGCP_SendToMrf(mrf, msg_resp));
4805 };
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004806 }
4807
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004808 BSSAP.receive(tr_BSSMAP_ClearComplete);
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004809}
4810
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02004811private function f_ho_out_of_this_bsc(template (omit) BSSMAP_oldToNewBSSIEs exp_oldToNewBSSIEs := omit) runs on MSC_ConnHdlr {
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004812
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004813 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004814 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
4815
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02004816 BSSAP.receive(tr_BSSMAP_HandoverRequired(exp_oldToNewBSSIEs));
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004817
4818 f_sleep(0.5);
4819 /* The MSC negotiates Handover Request and Handover Request Ack with
4820 * the other BSS and comes back with a BSSMAP Handover Command
4821 * containing an RR Handover Command coming from the target BSS... */
4822
4823 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
4824 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
4825 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
4826 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
4827 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
4828
4829 /* expect the Handover Command to go out on RR */
4830 var RSL_Message rsl_ho_cmd
4831 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
4832 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
4833 var RSL_IE_Body rsl_ho_cmd_l3;
4834 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
4835 log("RSL message contains no L3 Info IE, expected RR Handover Command");
4836 setverdict(fail);
4837 } else {
4838 log("Found L3 Info: ", rsl_ho_cmd_l3);
4839 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
4840 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
4841 setverdict(fail);
4842 } else {
4843 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
4844 setverdict(pass);
4845 }
4846 }
4847
4848 /* When the other BSS has reported a completed handover, this side is
4849 * torn down. */
4850
4851 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_HANDOVER_SUCCESSFUL;
4852 var BssmapCause cause := enum2int(cause_val);
4853 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
4854
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004855 f_expect_dlcx_conns();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004856 setverdict(pass);
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02004857}
4858
4859private function f_tc_ho_out_of_this_bsc(charstring id) runs on MSC_ConnHdlr {
4860 g_pars := f_gen_test_hdlr_pars();
4861 var PDU_BSSAP ass_req := f_gen_ass_req();
4862 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4863 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4864 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4865 f_establish_fully(ass_req, exp_compl);
4866
4867 f_ho_out_of_this_bsc();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004868 f_sleep(1.0);
4869}
4870testcase TC_ho_out_of_this_bsc() runs on test_CT {
4871 var MSC_ConnHdlr vc_conn;
4872
4873 f_init(1, true);
4874 f_sleep(1.0);
4875
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004876 f_ctrs_bsc_and_bts_init();
4877
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004878 vc_conn := f_start_handler(refers(f_tc_ho_out_of_this_bsc));
4879 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004880
4881 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4882 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4883 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4884 f_ctrs_bsc_and_bts_add(0, "handover:completed");
4885 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
4886 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:completed");
4887 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004888 f_shutdown_helper();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004889}
4890
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00004891private function f_mo_l3_transceive(RSL_DCHAN_PT rsl := RSL,
4892 template (value) RslLinkId link_id := ts_RslLinkID_DCCH(0),
Vadim Yanitskiy2ef6a2f2020-10-08 23:17:32 +07004893 template (present) OCT1 dlci := ?,
Vadim Yanitskiyb93aa432020-10-01 14:23:11 +07004894 octetstring l3 := '0123456789'O)
4895runs on MSC_ConnHdlr {
Neels Hofmeyr43654812020-09-25 01:35:35 +02004896 /* The old lchan and conn should still be active. See that arbitrary L3
4897 * is still going through. */
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00004898 rsl.send(ts_RSL_DATA_IND(g_chan_nr, link_id, l3));
Neels Hofmeyr43654812020-09-25 01:35:35 +02004899 var template PDU_BSSAP exp_data := {
4900 discriminator := '1'B,
4901 spare := '0000000'B,
Vadim Yanitskiyb93aa432020-10-01 14:23:11 +07004902 dlci := dlci,
4903 lengthIndicator := lengthof(l3),
Neels Hofmeyr43654812020-09-25 01:35:35 +02004904 pdu := {
4905 dtap := l3
4906 }
4907 };
4908 BSSAP.receive(exp_data);
4909 setverdict(pass);
4910}
4911
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00004912private function f_mt_l3_transceive(RSL_DCHAN_PT rsl := RSL,
4913 template (present) RslLinkId link_id := tr_RslLinkID_DCCH(0),
Vadim Yanitskiy0033a3b2020-10-01 22:21:16 +07004914 template (value) OCT1 dlci := '00'O,
4915 octetstring l3 := '0123456789'O)
4916runs on MSC_ConnHdlr {
4917 BSSAP.send(PDU_BSSAP:{
4918 discriminator := '1'B,
4919 spare := '0000000'B,
4920 dlci := dlci,
4921 lengthIndicator := lengthof(l3),
4922 pdu := {
4923 dtap := l3
4924 }
4925 });
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00004926 rsl.receive(tr_RSL_DATA_REQ(g_chan_nr, link_id, l3));
Vadim Yanitskiy0033a3b2020-10-01 22:21:16 +07004927 setverdict(pass);
4928}
4929
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004930/* BSC asks for inter-BSC HO, but the MSC decides that it won't happen and
4931 * simply never sends a BSSMAP Handover Command. */
4932private function f_tc_ho_out_fail_no_msc_response(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01004933 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004934
4935 var PDU_BSSAP ass_req := f_gen_ass_req();
4936 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4937 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4938 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4939 f_establish_fully(ass_req, exp_compl);
4940
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004941 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004942 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
4943
4944 BSSAP.receive(tr_BSSMAP_HandoverRequired);
4945
4946 /* osmo-bsc should time out 10 seconds after the handover started.
4947 * Let's give it a bit extra. */
4948 f_sleep(15.0);
4949
Vadim Yanitskiy74ae5eb2020-10-01 22:13:29 +07004950 f_mo_l3_transceive();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004951 f_sleep(1.0);
4952}
4953testcase TC_ho_out_fail_no_msc_response() runs on test_CT {
4954 var MSC_ConnHdlr vc_conn;
4955
4956 f_init(1, true);
4957 f_sleep(1.0);
4958
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004959 f_ctrs_bsc_and_bts_init();
4960
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004961 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_no_msc_response));
4962 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004963
4964 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4965 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4966 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4967 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
4968 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
4969 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
4970 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004971 f_shutdown_helper();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004972}
4973
4974/* BSC asks for inter-BSC HO, receives BSSMAP Handover Command, but MS reports
4975 * RR Handover Failure. */
4976private function f_tc_ho_out_fail_rr_ho_failure(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01004977 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004978
4979 var PDU_BSSAP ass_req := f_gen_ass_req();
4980 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4981 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4982 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4983 f_establish_fully(ass_req, exp_compl);
4984
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004985 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004986 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
4987
4988 BSSAP.receive(tr_BSSMAP_HandoverRequired);
4989
4990 f_sleep(0.5);
4991 /* The MSC negotiates Handover Request and Handover Request Ack with
4992 * the other BSS and comes back with a BSSMAP Handover Command
4993 * containing an RR Handover Command coming from the target BSS... */
4994
4995 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
4996 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
4997 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
4998 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
4999 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
5000
5001 /* expect the Handover Command to go out on RR */
5002 var RSL_Message rsl_ho_cmd
5003 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
5004 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
5005 var RSL_IE_Body rsl_ho_cmd_l3;
5006 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
5007 log("RSL message contains no L3 Info IE, expected RR Handover Command");
5008 setverdict(fail);
5009 } else {
5010 log("Found L3 Info: ", rsl_ho_cmd_l3);
5011 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
5012 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
5013 setverdict(fail);
5014 } else {
5015 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
5016 setverdict(pass);
5017 }
5018 }
5019
5020 f_sleep(0.2);
5021 f_rsl_send_l3(ts_RRM_HandoverFailure('00'O));
5022
5023 /* Should tell the MSC about the failure */
5024 BSSAP.receive(tr_BSSMAP_HandoverFailure);
5025
5026 f_sleep(1.0);
5027
Vadim Yanitskiy74ae5eb2020-10-01 22:13:29 +07005028 f_mo_l3_transceive();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005029 f_sleep(1.0);
5030
5031 setverdict(pass);
5032 f_sleep(1.0);
5033}
5034testcase TC_ho_out_fail_rr_ho_failure() runs on test_CT {
5035 var MSC_ConnHdlr vc_conn;
5036
5037 f_init(1, true);
5038 f_sleep(1.0);
5039
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005040 f_ctrs_bsc_and_bts_init();
5041
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005042 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_rr_ho_failure));
5043 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005044
5045 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5046 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5047 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5048 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5049 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
5050 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:failed");
5051 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005052 f_shutdown_helper();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005053}
5054
Neels Hofmeyr10f2bfa2019-07-09 19:33:29 +02005055/* BSC asks for inter-BSC-out HO, receives BSSMAP Handover Command, but then no reply is received about HO outcome
5056 * (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 +02005057 * and the lchan is released. */
5058private function f_tc_ho_out_fail_no_result_after_ho_cmd(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01005059 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005060
5061 var PDU_BSSAP ass_req := f_gen_ass_req();
5062 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
5063 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
5064 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
5065 f_establish_fully(ass_req, exp_compl);
5066
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005067 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005068 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
5069
5070 BSSAP.receive(tr_BSSMAP_HandoverRequired);
5071
5072 f_sleep(0.5);
5073 /* The MSC negotiates Handover Request and Handover Request Ack with
5074 * the other BSS and comes back with a BSSMAP Handover Command
5075 * containing an RR Handover Command coming from the target BSS... */
5076
5077 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
5078 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
5079 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
5080 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
5081 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
5082
5083 /* expect the Handover Command to go out on RR */
5084 var RSL_Message rsl_ho_cmd
5085 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
5086 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
5087 var RSL_IE_Body rsl_ho_cmd_l3;
5088 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
5089 log("RSL message contains no L3 Info IE, expected RR Handover Command");
5090 setverdict(fail);
5091 } else {
5092 log("Found L3 Info: ", rsl_ho_cmd_l3);
5093 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
5094 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
5095 setverdict(fail);
5096 } else {
5097 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
5098 setverdict(pass);
5099 }
5100 }
5101
Neels Hofmeyr10f2bfa2019-07-09 19:33:29 +02005102 /* We get neither success nor failure report from the remote BSS. Eventually T8 times out and we run into 3GPP
5103 * TS 48.008 3.1.5.3.3 "Abnormal Conditions": Clear Request should go to the MSC, and RR should be released
5104 * after Clear Command */
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005105
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005106 var PDU_BSSAP rx_clear_request;
Neels Hofmeyre1797aa2019-07-09 19:34:04 +02005107 BSSAP.receive(tr_BSSMAP_ClearRequest) -> value rx_clear_request;
5108 log("Got BSSMAP Clear Request");
5109 /* Instruct BSC to clear channel */
5110 var BssmapCause cause := bit2int(rx_clear_request.pdu.bssmap.clearRequest.cause.causeValue);
5111 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5112
5113 var MgcpCommand mgcp;
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005114 interleave {
Neels Hofmeyr861a4c12018-11-07 01:23:17 +01005115 [] RSL.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
5116 log("Got Deact SACCH");
5117 }
Harald Welte924b6ea2019-02-04 01:05:34 +01005118 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
Neels Hofmeyr211169d2018-11-07 00:37:29 +01005119 log("Got RR Release");
5120 }
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005121 [] RSL.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
5122 log("Got RF Chan Rel");
5123 RSL.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
5124 }
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005125 }
5126
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005127 f_expect_dlcx_conns();
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02005128
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005129 setverdict(pass);
5130 f_sleep(1.0);
5131}
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02005132testcase TC_ho_out_fail_no_result_after_ho_cmd() runs on test_CT {
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005133 var MSC_ConnHdlr vc_conn;
5134
5135 f_init(1, true);
5136 f_sleep(1.0);
5137
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005138 f_ctrs_bsc_and_bts_init();
5139
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02005140 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_no_result_after_ho_cmd));
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005141 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005142
5143 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5144 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5145 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5146 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
5147 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
5148 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
5149 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005150 f_shutdown_helper();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005151}
5152
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005153private function f_ho_into_this_bsc(charstring id, template (omit) BSSMAP_oldToNewBSSIEs oldToNewBSSIEs := omit) runs on MSC_ConnHdlr {
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005154 /* Hack: the proper way would be to wait for the BSSMAP Handover Request ACK and extract the
5155 * actual assigned chan_nr from its L3 (RR Handover Command) message. But osmo-bsc starts acting
5156 * on the lchan even before we get a chance to evaluate the BSSMAP Handover Request ACK. So we
5157 * need to assume that osmo-bsc will activate TS 1 and already set up this lchan's RSL emulation
5158 * before we get started. */
5159 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
5160 f_rslem_register(0, new_chan_nr);
5161 g_chan_nr := new_chan_nr;
5162 f_sleep(1.0);
5163
5164 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
5165 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5166 activate(as_Media());
5167
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005168 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02005169 f_gen_handover_req(aoip_tla := g_pars.host_aoip_tla,
5170 oldToNewBSSIEs := oldToNewBSSIEs)));
Harald Welte6811d102019-04-14 22:23:14 +02005171 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005172
5173 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
5174
5175 var PDU_BSSAP rx_bssap;
5176 var octetstring ho_command_str;
5177
5178 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
Pau Espin Pedrol76ba5412019-06-10 11:00:33 +02005179
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005180 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
5181 log("Received L3 Info in HO Request Ack: ", ho_command_str);
5182 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
5183 log("L3 Info in HO Request Ack is ", ho_command);
5184
5185 var GsmArfcn arfcn;
5186 var RslChannelNr actual_new_chan_nr;
5187 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
5188 actual_new_chan_nr, arfcn);
5189
5190 if (actual_new_chan_nr != new_chan_nr) {
5191 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
5192 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
5193 setverdict(fail);
5194 return;
5195 }
5196 log("Handover Command chan_nr is", actual_new_chan_nr);
5197
5198 /* Now the MSC forwards the RR Handover Command to the other BSC, which
5199 * tells the MS to handover to the new lchan. Here comes the new MS on
5200 * the new lchan with a Handover RACH: */
5201
5202 /* send handover detect */
5203
5204 RSL.send(ts_RSL_HANDO_DET(new_chan_nr));
5205
5206 BSSAP.receive(tr_BSSMAP_HandoverDetect);
5207
5208 /* send handover complete over the new channel */
5209
5210 var PDU_ML3_MS_NW l3_tx := valueof(ts_RRM_HandoverComplete('00'O));
5211 RSL.send(ts_RSL_EST_IND(new_chan_nr, valueof(ts_RslLinkID_DCCH(0)),
5212 enc_PDU_ML3_MS_NW(l3_tx)));
5213
5214 BSSAP.receive(tr_BSSMAP_HandoverComplete);
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005215 setverdict(pass);
5216}
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02005217
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005218private function f_tc_ho_into_this_bsc(charstring id) runs on MSC_ConnHdlr {
5219 var template PDU_ML3_NW_MS exp_rr_rel_tmpl := tr_RRM_RR_RELEASE;
5220 var template (omit) BSSMAP_oldToNewBSSIEs oldToNewBSSIEs := omit;
5221 if (not istemplatekind(g_pars.last_used_eutran_plmn, "omit")) {
5222 oldToNewBSSIEs := f_ts_BSSMAP_oldToNewBSSIEs(ts_BSSMAP_LastUsedEUTRANPLMNId(g_pars.last_used_eutran_plmn));
5223 exp_rr_rel_tmpl := tr_RRM_RR_RELEASE_CellSelectInd;
5224 }
5225 f_ho_into_this_bsc(id, oldToNewBSSIEs);
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02005226 f_perform_clear(RSL, exp_rr_rel_tmpl);
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005227 setverdict(pass);
5228}
Pau Espin Pedrol07866632020-09-03 19:10:55 +02005229function f_tc_ho_into_this_bsc_main(TestHdlrParams pars) runs on test_CT {
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005230 var MSC_ConnHdlr vc_conn;
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005231
5232 f_init(1, true);
5233 f_sleep(1.0);
5234
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005235 f_ctrs_bsc_and_bts_init();
5236
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005237 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5238 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005239
5240 vc_conn := f_start_handler(refers(f_tc_ho_into_this_bsc), pars);
5241 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005242
5243 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5244 f_ctrs_bsc_and_bts_add(0, "handover:completed");
5245 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
5246 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:completed");
5247 f_ctrs_bsc_and_bts_verify();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005248}
5249
Pau Espin Pedrol07866632020-09-03 19:10:55 +02005250testcase TC_ho_into_this_bsc() runs on test_CT {
5251 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5252 f_tc_ho_into_this_bsc_main(pars);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005253 f_shutdown_helper();
Pau Espin Pedrol07866632020-09-03 19:10:55 +02005254}
5255
5256testcase TC_ho_into_this_bsc_tla_v6() runs on test_CT {
5257 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5258 pars.host_aoip_tla := "::6";
5259 f_tc_ho_into_this_bsc_main(pars);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005260 f_shutdown_helper();
Pau Espin Pedrol07866632020-09-03 19:10:55 +02005261}
5262
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02005263/* Similar to TC_ho_into_this_bsc, but when in SRVCC, HO Req contains "Old BSS
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005264 to New BSS Information" IE with "Last Used E-UTRAN PLMN Id", which, when the
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02005265 channel is later released (RR CHannel Release), should trigger inclusion of
5266 IE "Cell Selection Indicator after Release of all TCH and SDCCH" with E-UTRAN
5267 neighbors. */
5268testcase TC_srvcc_eutran_to_geran() runs on test_CT {
5269 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5270 pars.last_used_eutran_plmn := '323454'O;
5271 f_tc_ho_into_this_bsc_main(pars);
5272 f_shutdown_helper();
5273}
5274
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005275private function f_tc_srvcc_eutran_to_geran_ho_out(charstring id) runs on MSC_ConnHdlr {
5276 var template (omit) BSSMAP_oldToNewBSSIEs oldToNewBSSIEs;
5277 oldToNewBSSIEs := f_ts_BSSMAP_oldToNewBSSIEs(ts_BSSMAP_LastUsedEUTRANPLMNId(g_pars.last_used_eutran_plmn));
5278 f_ho_into_this_bsc(id, oldToNewBSSIEs);
5279 f_ho_out_of_this_bsc(oldToNewBSSIEs);
5280 setverdict(pass);
5281}
5282/* First, HO into BSC from EUTRAN (SRVCC): HO Request contains "Old BSS to New
5283 BSS Information" IE with "Last Used E-UTRAN PLMN Id".
5284 Second, HO to another BSC: HO Required contains "Old BSS to New BSS Information"
5285 IE with "Last Used E-UTRAN PLMN Id" from first step. */
5286testcase TC_srvcc_eutran_to_geran_ho_out() runs on test_CT {
5287 var MSC_ConnHdlr vc_conn;
5288 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5289
5290 f_init(1, true);
5291 f_sleep(1.0);
5292
5293 f_ctrs_bsc_and_bts_init();
5294
5295 pars.last_used_eutran_plmn := '323454'O;
5296 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5297 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
5298
5299 vc_conn := f_start_handler(refers(f_tc_srvcc_eutran_to_geran_ho_out), pars);
5300 vc_conn.done;
5301
5302 f_ctrs_bsc_and_bts_add(0, "handover:attempted", 2);
5303 f_ctrs_bsc_and_bts_add(0, "handover:completed", 2);
5304 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted", 1);
5305 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:completed", 1);
5306 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted", 1);
5307 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:completed", 1);
5308 f_ctrs_bsc_and_bts_verify();
5309 f_shutdown_helper();
5310}
5311
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005312private function f_tc_ho_in_fail_msc_clears(charstring id) runs on MSC_ConnHdlr {
5313 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
5314 f_rslem_register(0, new_chan_nr);
5315 g_chan_nr := new_chan_nr;
5316 f_sleep(1.0);
5317
5318 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
5319 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5320 activate(as_Media());
5321
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005322 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005323 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02005324 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005325
5326 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
5327
5328 var PDU_BSSAP rx_bssap;
5329 var octetstring ho_command_str;
5330
5331 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
5332
5333 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
5334 log("Received L3 Info in HO Request Ack: ", ho_command_str);
5335 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
5336 log("L3 Info in HO Request Ack is ", ho_command);
5337
5338 var GsmArfcn arfcn;
5339 var RslChannelNr actual_new_chan_nr;
5340 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
5341 actual_new_chan_nr, arfcn);
5342
5343 if (actual_new_chan_nr != new_chan_nr) {
5344 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
5345 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
5346 setverdict(fail);
5347 return;
5348 }
5349 log("Handover Command chan_nr is", actual_new_chan_nr);
5350
Neels Hofmeyr61ca08d2019-05-06 23:52:22 +02005351 /* For deterministic test results, give some time for the MGW endpoint to be configured */
5352 f_sleep(1.0);
5353
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005354 /* Now the MSC forwards the RR Handover Command to the other BSC, which
5355 * tells the MS to handover to the new lchan. In this case, the MS
5356 * reports a Handover Failure to the old BSS, which forwards a BSSMAP
5357 * Handover Failure to the MSC. The procedure according to 3GPP TS
5358 * 48.008 3.1.5.3.2 "Handover Failure" is then that the MSC sends a
5359 * BSSMAP Clear Command: */
5360
5361 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
5362 var BssmapCause cause := enum2int(cause_val);
5363 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5364
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005365 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005366 setverdict(pass);
5367 f_sleep(1.0);
5368
5369 setverdict(pass);
5370}
5371testcase TC_ho_in_fail_msc_clears() runs on test_CT {
5372 var MSC_ConnHdlr vc_conn;
5373 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5374
5375 f_init(1, true);
5376 f_sleep(1.0);
5377
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005378 f_ctrs_bsc_and_bts_init();
5379
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005380 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5381 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005382
5383 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_msc_clears), pars);
5384 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005385
5386 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5387 f_ctrs_bsc_and_bts_add(0, "handover:stopped");
5388 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
5389 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:stopped");
5390 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005391 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005392}
5393
5394private function f_tc_ho_in_fail_msc_clears_after_ho_detect(charstring id) runs on MSC_ConnHdlr {
5395 /* Hack: the proper way would be to wait for the BSSMAP Handover Request ACK and extract the
5396 * actual assigned chan_nr from its L3 (RR Handover Command) message. But osmo-bsc starts acting
5397 * on the lchan even before we get a chance to evaluate the BSSMAP Handover Request ACK. So we
5398 * need to assume that osmo-bsc will activate TS 1 and already set up this lchan's RSL emulation
5399 * before we get started. */
5400 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
5401 f_rslem_register(0, new_chan_nr);
5402 g_chan_nr := new_chan_nr;
5403 f_sleep(1.0);
5404
5405 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
5406 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5407 activate(as_Media());
5408
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005409 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005410 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02005411 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005412
5413 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
5414
5415 var PDU_BSSAP rx_bssap;
5416 var octetstring ho_command_str;
5417
5418 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
5419
5420 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
5421 log("Received L3 Info in HO Request Ack: ", ho_command_str);
5422 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
5423 log("L3 Info in HO Request Ack is ", ho_command);
5424
5425 var GsmArfcn arfcn;
5426 var RslChannelNr actual_new_chan_nr;
5427 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
5428 actual_new_chan_nr, arfcn);
5429
5430 if (actual_new_chan_nr != new_chan_nr) {
5431 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
5432 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
5433 setverdict(fail);
5434 return;
5435 }
5436 log("Handover Command chan_nr is", actual_new_chan_nr);
5437
5438 /* Now the MSC forwards the RR Handover Command to the other BSC, which
5439 * tells the MS to handover to the new lchan. Here comes the new MS on
5440 * the new lchan with a Handover RACH: */
5441
5442 /* send handover detect */
5443
5444 RSL.send(ts_RSL_HANDO_DET(new_chan_nr));
5445
5446 BSSAP.receive(tr_BSSMAP_HandoverDetect);
5447
5448 /* The MSC chooses to clear the connection now, maybe we got the
5449 * Handover RACH on the new cell but the MS still signaled Handover
5450 * Failure to the old BSS? */
5451
5452 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
5453 var BssmapCause cause := enum2int(cause_val);
5454 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5455
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005456 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005457 f_sleep(1.0);
5458}
5459testcase TC_ho_in_fail_msc_clears_after_ho_detect() runs on test_CT {
5460 var MSC_ConnHdlr vc_conn;
5461 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5462
5463 f_init(1, true);
5464 f_sleep(1.0);
5465
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005466 f_ctrs_bsc_and_bts_init();
5467
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005468 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5469 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005470
5471 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_msc_clears_after_ho_detect), pars);
5472 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005473
5474 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5475 f_ctrs_bsc_and_bts_add(0, "handover:stopped");
5476 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
5477 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:stopped");
5478 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005479 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005480}
5481
5482/* The new BSS's lchan times out before the MSC decides that handover failed. */
5483private function f_tc_ho_in_fail_no_detect(charstring id) runs on MSC_ConnHdlr {
5484 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
5485 f_rslem_register(0, new_chan_nr);
5486 g_chan_nr := new_chan_nr;
5487 f_sleep(1.0);
5488
5489 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
5490 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5491 activate(as_Media());
5492
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005493 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005494 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02005495 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005496
5497 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
5498
5499 var PDU_BSSAP rx_bssap;
5500 var octetstring ho_command_str;
5501
5502 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
5503
5504 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
5505 log("Received L3 Info in HO Request Ack: ", ho_command_str);
5506 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
5507 log("L3 Info in HO Request Ack is ", ho_command);
5508
5509 var GsmArfcn arfcn;
5510 var RslChannelNr actual_new_chan_nr;
5511 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
5512 actual_new_chan_nr, arfcn);
5513
5514 if (actual_new_chan_nr != new_chan_nr) {
5515 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
5516 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
5517 setverdict(fail);
5518 return;
5519 }
5520 log("Handover Command chan_nr is", actual_new_chan_nr);
5521
5522 /* Now the MSC forwards the RR Handover Command to the other BSC, which
5523 * tells the MS to handover to the new lchan. But the MS never shows up
5524 * on the new lchan. */
5525
5526 BSSAP.receive(tr_BSSMAP_HandoverFailure);
5527
5528 /* Did osmo-bsc also send a Clear Request? */
5529 timer T := 0.5;
5530 T.start;
5531 alt {
5532 [] BSSAP.receive(tr_BSSMAP_ClearRequest);
5533 [] T.timeout { }
5534 }
5535
5536 /* MSC plays along with a Clear Command (no matter whether osmo-bsc
5537 * asked for it, this is a Handover Failure after all). */
5538
5539 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
5540 var BssmapCause cause := enum2int(cause_val);
5541 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5542
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005543 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005544 f_sleep(1.0);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005545}
5546testcase TC_ho_in_fail_no_detect() runs on test_CT {
5547 var MSC_ConnHdlr vc_conn;
5548 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5549
5550 f_init(1, true);
5551 f_sleep(1.0);
5552
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005553 f_ctrs_bsc_and_bts_init();
5554
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005555 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5556 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005557
5558 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_no_detect), pars);
5559 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005560
5561 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5562 f_ctrs_bsc_and_bts_add(0, "handover:error");
5563 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
5564 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:error");
5565 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005566 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005567}
5568
5569/* Same as f_tc_ho_in_fail_no_detect, but MSC fails to send a Clear Command */
5570private function f_tc_ho_in_fail_no_detect2(charstring id) runs on MSC_ConnHdlr {
5571 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
5572 f_rslem_register(0, new_chan_nr);
5573 g_chan_nr := new_chan_nr;
5574 f_sleep(1.0);
5575
5576 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
5577 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5578 activate(as_Media());
5579
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005580 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005581 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02005582 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005583
5584 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
5585
5586 var PDU_BSSAP rx_bssap;
5587 var octetstring ho_command_str;
5588
5589 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
5590
5591 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
5592 log("Received L3 Info in HO Request Ack: ", ho_command_str);
5593 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
5594 log("L3 Info in HO Request Ack is ", ho_command);
5595
5596 var GsmArfcn arfcn;
5597 var RslChannelNr actual_new_chan_nr;
5598 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
5599 actual_new_chan_nr, arfcn);
5600
5601 if (actual_new_chan_nr != new_chan_nr) {
5602 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
5603 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
5604 setverdict(fail);
5605 return;
5606 }
5607 log("Handover Command chan_nr is", actual_new_chan_nr);
5608
5609 /* Now the MSC forwards the RR Handover Command to the other BSC, which
5610 * tells the MS to handover to the new lchan. But the MS never shows up
5611 * on the new lchan. */
5612
5613 BSSAP.receive(tr_BSSMAP_HandoverFailure);
5614
5615 /* MSC plays dumb and sends no Clear Command */
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005616 var PDU_BSSAP rx_clear_request;
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02005617
5618 BSSAP.receive(tr_BSSMAP_ClearRequest) -> value rx_clear_request {
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005619 var BssmapCause cause := bit2int(rx_clear_request.pdu.bssmap.clearRequest.cause.causeValue);
5620 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5621 };
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005622 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005623 f_sleep(1.0);
5624}
5625testcase TC_ho_in_fail_no_detect2() runs on test_CT {
5626 var MSC_ConnHdlr vc_conn;
5627 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5628
5629 f_init(1, true);
5630 f_sleep(1.0);
5631
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005632 f_ctrs_bsc_and_bts_init();
5633
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005634 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5635 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005636
5637 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_no_detect2), pars);
5638 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005639
5640 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5641 f_ctrs_bsc_and_bts_add(0, "handover:error");
5642 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
5643 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:error");
5644 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005645 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005646}
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005647
Neels Hofmeyr91401012019-07-11 00:42:35 +02005648type record of charstring Commands;
5649
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005650private function f_bts_0_cfg(TELNETasp_PT pt, Commands cmds := {})
Neels Hofmeyr91401012019-07-11 00:42:35 +02005651{
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005652 f_vty_enter_cfg_bts(pt, 0);
Neels Hofmeyr91401012019-07-11 00:42:35 +02005653 for (var integer i := 0; i < sizeof(cmds); i := i+1) {
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005654 f_vty_transceive(pt, cmds[i]);
Neels Hofmeyr91401012019-07-11 00:42:35 +02005655 }
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005656 f_vty_transceive(pt, "end");
Neels Hofmeyr91401012019-07-11 00:42:35 +02005657}
5658
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01005659private function f_cs7_inst_0_cfg(TELNETasp_PT pt, Commands cmds := {})
5660{
5661 f_vty_enter_cfg_cs7_inst(pt, 0);
5662 for (var integer i := 0; i < sizeof(cmds); i := i+1) {
5663 f_vty_transceive(pt, cmds[i]);
5664 }
5665 f_vty_transceive(pt, "end");
5666}
5667
Neels Hofmeyr91401012019-07-11 00:42:35 +02005668private function f_probe_for_handover(charstring log_label,
5669 charstring log_descr,
5670 charstring handover_vty_cmd,
5671 boolean expect_handover,
5672 boolean is_inter_bsc_handover := false)
5673runs on MSC_ConnHdlr
5674{
Neels Hofmeyrb3fc8982020-05-11 00:16:42 +02005675 /* We're going to thwart any and all handover attempts, just be ready to handle (and ignore) handover target
5676 * lchans to be established on bts 1 or bts 2. */
5677 f_rslem_suspend(RSL1_PROC);
5678 f_rslem_suspend(RSL2_PROC);
5679
Neels Hofmeyr91401012019-07-11 00:42:35 +02005680 var RSL_Message rsl;
5681
5682 var charstring log_msg := " (expecting handover)"
5683 if (not expect_handover) {
5684 log_msg := " (expecting NO handover)";
5685 }
5686 log("f_probe_for_handover starting: " & log_label & ": " & log_descr & log_msg);
5687 f_vty_transceive(BSCVTY, handover_vty_cmd);
5688
Neels Hofmeyr91401012019-07-11 00:42:35 +02005689 timer T := 2.0;
5690 T.start;
5691
5692 alt {
5693 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr)) -> value rsl {
5694 var PDU_ML3_NW_MS l3 := dec_PDU_ML3_NW_MS(rsl.ies[2].body.l3_info.payload);
5695 log("Rx L3 from net: ", l3);
5696 if (ischosen(l3.msgs.rrm.handoverCommand)) {
5697 var RslChannelNr new_chan_nr;
5698 var GsmArfcn arfcn;
5699 f_ChDesc2RslChanNr(l3.msgs.rrm.handoverCommand.channelDescription2,
5700 new_chan_nr, arfcn);
5701 log("Handover to new chan ", new_chan_nr, " on ARFCN ", arfcn);
5702 log(l3.msgs.rrm.handoverCommand);
5703
5704 /* Need to register for new lchan on new BTS -- it's either bts 1 or bts 2. It doesn't really
5705 * matter on which BTS it really is, we're not going to follow through an entire handover
5706 * anyway. */
5707 f_rslem_register(0, new_chan_nr, RSL1_PROC);
5708 f_rslem_resume(RSL1_PROC);
5709 f_rslem_register(0, new_chan_nr, RSL2_PROC);
5710 f_rslem_resume(RSL2_PROC);
5711
5712 if (expect_handover and not is_inter_bsc_handover) {
5713 setverdict(pass);
5714 log("f_probe_for_handover(" & log_label & "): Got RSL Handover Command as expected.");
5715 } else {
5716 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected none, but got RSL Handover Command. "
5717 & log_label & ": " & log_descr);
5718 }
5719
5720 log("f_probe_for_handover(" & log_label & "): Ending the test: Handover Failure stops the procedure.");
5721 /* osmo-bsc has triggered Handover. That's all we need to know for this test, reply with
5722 * Handover Failure. */
5723 f_rsl_send_l3(ts_RRM_HandoverFailure('00'O));
5724
5725 /* target BTS is told to release lchan again; don't care which BTS nor what messages. */
5726 f_sleep(0.5);
5727 RSL1.clear;
5728 RSL2.clear;
5729 log("f_probe_for_handover(" & log_label & "): done (got RSL Handover Command)");
5730 break;
5731 } else {
5732 repeat;
5733 }
5734 }
5735 [] BSSAP.receive(tr_BSSMAP_HandoverRequired) {
5736 if (expect_handover and is_inter_bsc_handover) {
5737 setverdict(pass);
5738 log("f_probe_for_handover(" & log_label & "): Got BSSMAP Handover Required as expected.");
5739 } else {
5740 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected none, but got BSSMAP Handover Required. "
5741 & log_label & ": " & log_descr);
5742 }
5743
5744 log("f_probe_for_handover(" & log_label & "): done (got BSSMAP Handover Required)");
5745
5746 /* Note: f_tc_ho_neighbor_config_start() sets T7, the timeout for BSSMAP Handover Required, to
5747 * 1 second. There is no legal way to quickly abort a handover after a BSSMAP Handover Required,
5748 * setting a short timeout and waiting is the only way. */
5749 log("f_probe_for_handover(" & log_label & "): waiting for inter-BSC HO to time out...");
5750 f_sleep(1.5);
5751 log("f_probe_for_handover(" & log_label & "): ...done");
5752
5753 break;
5754 }
5755 [] T.timeout {
5756 if (expect_handover) {
5757 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected Handover, but got none. "
5758 & log_label & ": " & log_descr);
5759 } else {
5760 setverdict(pass);
5761 log("f_probe_for_handover(" & log_label & "): Got no Handover, as expected.");
5762 }
5763 log("f_probe_for_handover(" & log_label & "): done (got no Handover)");
5764 break;
5765 }
5766 }
5767
5768 f_rslem_resume(RSL1_PROC);
5769 f_rslem_resume(RSL2_PROC);
5770 f_sleep(3.0);
5771 RSL.clear;
5772
5773 log("f_probe_for_handover(" & log_label & "): done clearing");
5774}
5775
5776/* Test the effect of various neighbor configuration scenarios:
5777 *
5778 * To avoid complexity, block off any actual handover operation, and always remain on the lchan at bts 0.
5779 * Reconfigure the neighbors for bts 0, trigger a Handover, and probe whether osmo-bsc does or doesn't start HO.
5780 */
5781private function f_tc_ho_neighbor_config_start() runs on MSC_ConnHdlr {
5782 g_pars := f_gen_test_hdlr_pars();
5783 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
5784 var PDU_BSSAP ass_cmd := f_gen_ass_req();
5785 const OCT8 kc := '0001020304050607'O;
5786
5787 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
5788 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
5789
5790 /* Establish lchan at bts 0 */
5791 f_establish_fully(ass_cmd, exp_compl);
5792
5793 /* Shorten the inter-BSC Handover timeout, to not wait so long for inter-BSC Handovers */
5794 f_vty_enter_cfg_network(BSCVTY);
5795 f_vty_transceive(BSCVTY, "timer T7 1");
5796 f_vty_transceive(BSCVTY, "end");
5797}
5798
5799private function f_tc_ho_neighbor_config_1(charstring id) runs on MSC_ConnHdlr {
5800 f_tc_ho_neighbor_config_start();
5801
5802 /*
5803 * bts 0 ARFCN 871 BSIC 10
5804 * bts 1 ARFCN 871 BSIC 11
5805 * bts 2 ARFCN 871 BSIC 12
5806 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5807 */
5808
5809 log("f_tc_ho_neighbor_config: 1. No 'neighbor' config");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005810 f_bts_0_cfg(BSCVTY, {"no neighbors"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005811 f_probe_for_handover("1.a", "HO to bts 1 works, implicitly listed as neighbor (legacy behavior when none are configured)",
5812 "handover any to arfcn 871 bsic 11",
5813 true);
5814
5815 f_probe_for_handover("1.b", "HO to unknown cell does not start",
5816 "handover any to arfcn 13 bsic 39",
5817 false);
5818
5819 f_probe_for_handover("1.c", "HO to 871-12 is ambiguous = error",
5820 "handover any to arfcn 871 bsic 12",
5821 false);
5822
5823 f_probe_for_handover("1.d", "HO to 871-11 still works (verify that this test properly cleans up)",
5824 "handover any to arfcn 871 bsic 11",
5825 true);
5826}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005827testcase TC_ho_neighbor_config_1() runs on test_CT {
5828 var MSC_ConnHdlr vc_conn;
5829 f_init(3, true, guard_timeout := 60.0);
5830 f_sleep(1.0);
5831 f_ctrs_bsc_and_bts_init();
5832 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_1));
5833 vc_conn.done;
5834
5835 /* f_tc_ho_neighbor_config_start() */
5836 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5837 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5838
5839 /* 1.a */
5840 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
5841 * handover quickly by sending a Handover Failure message. */
5842 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5843 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5844 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5845 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
5846
5847 /* 1.b */
5848 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5849 f_ctrs_bsc_and_bts_add(0, "handover:error");
5850
5851 /* 1.c */
5852 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5853 f_ctrs_bsc_and_bts_add(0, "handover:error");
5854
5855 /* 1.d */
5856 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5857 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5858 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5859 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
5860
5861 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005862 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005863}
5864
Neels Hofmeyr91401012019-07-11 00:42:35 +02005865private function f_tc_ho_neighbor_config_2(charstring id) runs on MSC_ConnHdlr {
5866 f_tc_ho_neighbor_config_start();
5867
5868 /*
5869 * bts 0 ARFCN 871 BSIC 10
5870 * bts 1 ARFCN 871 BSIC 11
5871 * bts 2 ARFCN 871 BSIC 12
5872 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5873 */
5874
5875 log("f_tc_ho_neighbor_config: 2. explicit local neighbor: 'neighbor bts 1'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005876 f_bts_0_cfg(BSCVTY, {"neighbor bts 1"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005877 f_sleep(0.5);
5878
5879 f_probe_for_handover("2.a", "HO to bts 1 works, explicitly listed as neighbor",
5880 "handover any to arfcn 871 bsic 11",
5881 true);
5882
5883 f_probe_for_handover("2.b", "HO to bts 2 doesn't work, not listed as neighbor",
5884 "handover any to arfcn 871 bsic 12",
5885 false);
5886}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005887testcase TC_ho_neighbor_config_2() runs on test_CT {
5888 var MSC_ConnHdlr vc_conn;
5889 f_init(3, true, guard_timeout := 50.0);
5890 f_sleep(1.0);
5891 f_ctrs_bsc_and_bts_init();
5892 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_2));
5893 vc_conn.done;
5894
5895 /* f_tc_ho_neighbor_config_start() */
5896 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5897 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5898
5899 /* 2.a */
5900 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
5901 * handover quickly by sending a Handover Failure message. */
5902 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5903 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5904 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5905 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
5906
5907 /* 2.b */
5908 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5909 f_ctrs_bsc_and_bts_add(0, "handover:error");
5910
5911 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005912 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005913}
5914
Neels Hofmeyr91401012019-07-11 00:42:35 +02005915private function f_tc_ho_neighbor_config_3(charstring id) runs on MSC_ConnHdlr {
5916 f_tc_ho_neighbor_config_start();
5917
5918 /*
5919 * bts 0 ARFCN 871 BSIC 10
5920 * bts 1 ARFCN 871 BSIC 11
5921 * bts 2 ARFCN 871 BSIC 12
5922 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5923 */
5924
5925 log("f_tc_ho_neighbor_config: 3. explicit local neighbor: 'neighbor bts 2'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005926 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor bts 2"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005927 f_sleep(0.5);
5928
5929 f_probe_for_handover("3.a", "HO to bts 1 doesn't work, not listed as neighbor",
5930 "handover any to arfcn 871 bsic 11",
5931 false);
5932 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",
5933 "handover any to arfcn 871 bsic 12",
5934 true);
5935}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005936testcase TC_ho_neighbor_config_3() runs on test_CT {
5937 var MSC_ConnHdlr vc_conn;
5938 f_init(3, true, guard_timeout := 50.0);
5939 f_sleep(1.0);
5940 f_ctrs_bsc_and_bts_init();
5941 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_3));
5942 vc_conn.done;
5943
5944 /* f_tc_ho_neighbor_config_start() */
5945 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5946 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5947
5948 /* 3.a */
5949 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5950 f_ctrs_bsc_and_bts_add(0, "handover:error");
5951
5952 /* 3.b */
5953 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
5954 * handover quickly by sending a Handover Failure message. */
5955 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5956 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5957 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5958 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
5959
5960 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005961 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005962}
5963
Neels Hofmeyr91401012019-07-11 00:42:35 +02005964private function f_tc_ho_neighbor_config_4(charstring id) runs on MSC_ConnHdlr {
5965 f_tc_ho_neighbor_config_start();
5966
5967 /*
5968 * bts 0 ARFCN 871 BSIC 10
5969 * bts 1 ARFCN 871 BSIC 11
5970 * bts 2 ARFCN 871 BSIC 12
5971 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5972 */
5973
5974 log("f_tc_ho_neighbor_config: 4. explicit remote neighbor: 'neighbor lac 99 arfcn 123 bsic 45'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005975 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor lac 99 arfcn 123 bsic 45"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005976 f_sleep(0.5);
5977
5978 f_probe_for_handover("4.a", "HO to bts 1 doesn't work, not listed as neighbor",
5979 "handover any to arfcn 871 bsic 11",
5980 false);
5981 f_probe_for_handover("4.b", "HO to bts 2 doesn't work, not listed as neighbor",
5982 "handover any to arfcn 871 bsic 12",
5983 false);
5984 f_probe_for_handover("4.c", "HO to 123-45 triggers inter-BSC HO",
5985 "handover any to arfcn 123 bsic 45",
5986 true, true);
5987}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005988testcase TC_ho_neighbor_config_4() runs on test_CT {
5989 var MSC_ConnHdlr vc_conn;
5990 f_init(3, true, guard_timeout := 50.0);
5991 f_sleep(1.0);
5992 f_ctrs_bsc_and_bts_init();
5993 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_4));
5994 vc_conn.done;
5995
5996 /* f_tc_ho_neighbor_config_start() */
5997 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5998 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5999
6000 /* 4.a */
6001 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6002 f_ctrs_bsc_and_bts_add(0, "handover:error");
6003
6004 /* 4.b */
6005 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6006 f_ctrs_bsc_and_bts_add(0, "handover:error");
6007
6008 /* 4.c */
6009 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
6010 * handover quickly by timing out after the Handover Required message */
6011 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6012 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
6013 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
6014 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
6015
6016 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006017 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006018}
6019
Neels Hofmeyr91401012019-07-11 00:42:35 +02006020private function f_tc_ho_neighbor_config_5(charstring id) runs on MSC_ConnHdlr {
6021 f_tc_ho_neighbor_config_start();
6022
6023 /*
6024 * bts 0 ARFCN 871 BSIC 10
6025 * bts 1 ARFCN 871 BSIC 11
6026 * bts 2 ARFCN 871 BSIC 12
6027 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
6028 */
6029
6030 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 +02006031 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor lac 99 arfcn 871 bsic 12"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02006032 f_sleep(0.5);
6033
6034 f_probe_for_handover("5.a", "HO to 871-12 triggers inter-BSC HO (ignoring local cells with same ARFCN+BSIC)",
6035 "handover any to arfcn 871 bsic 12",
6036 true, true);
6037}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006038testcase TC_ho_neighbor_config_5() runs on test_CT {
6039 var MSC_ConnHdlr vc_conn;
6040 f_init(3, true);
6041 f_sleep(1.0);
6042 f_ctrs_bsc_and_bts_init();
6043 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_5));
6044 vc_conn.done;
6045
6046 /* f_tc_ho_neighbor_config_start() */
6047 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
6048 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
6049
6050 /* 5 */
6051 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
6052 * handover quickly by timing out after the Handover Required message */
6053 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6054 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
6055 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
6056 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
6057
6058 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006059 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006060}
6061
Neels Hofmeyr91401012019-07-11 00:42:35 +02006062private function f_tc_ho_neighbor_config_6(charstring id) runs on MSC_ConnHdlr {
6063 f_tc_ho_neighbor_config_start();
6064
6065 /*
6066 * bts 0 ARFCN 871 BSIC 10
6067 * bts 1 ARFCN 871 BSIC 11
6068 * bts 2 ARFCN 871 BSIC 12
6069 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
6070 */
6071
6072 log("f_tc_ho_neighbor_config: 6. config error: explicit local and remote neighbors with ambiguous ARFCN+BSIC:"
6073 & " 'neighbor bts 2; neighbor lac 99 arfcn 871 bsic 12'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02006074 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor bts 2", "neighbor lac 99 arfcn 871 bsic 12"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02006075 f_sleep(0.5);
6076
6077 f_probe_for_handover("6.a", "HO to 871-12 is ambiguous = error",
6078 "handover any to arfcn 871 bsic 12",
6079 false);
6080}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006081testcase TC_ho_neighbor_config_6() runs on test_CT {
6082 var MSC_ConnHdlr vc_conn;
6083 f_init(3, true);
6084 f_sleep(1.0);
6085 f_ctrs_bsc_and_bts_init();
6086 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_6));
6087 vc_conn.done;
6088
6089 /* f_tc_ho_neighbor_config_start() */
6090 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
6091 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
6092
6093 /* 6.a */
6094 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
6095 * handover quickly by timing out after the Handover Required message */
6096 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6097 f_ctrs_bsc_and_bts_add(0, "handover:error");
6098
6099 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006100 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006101}
6102
Neels Hofmeyr91401012019-07-11 00:42:35 +02006103private function f_tc_ho_neighbor_config_7(charstring id) runs on MSC_ConnHdlr {
6104 f_tc_ho_neighbor_config_start();
6105
6106 /*
6107 * bts 0 ARFCN 871 BSIC 10
6108 * bts 1 ARFCN 871 BSIC 11
6109 * bts 2 ARFCN 871 BSIC 12
6110 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
6111 */
6112
6113 log("f_tc_ho_neighbor_config: 7. explicit local and remote neighbors:"
6114 & " 'neighbor bts 2; neighbor lac 99 arfcn 123 bsic 45'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02006115 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor bts 2", "neighbor lac 99 arfcn 123 bsic 45"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02006116 f_sleep(0.5);
6117
6118 f_probe_for_handover("7.a", "HO to 871-12 does HO to bts 2",
6119 "handover any to arfcn 871 bsic 12",
6120 true);
6121 f_probe_for_handover("7.b", "HO to 123-45 triggers inter-BSC HO",
6122 "handover any to arfcn 123 bsic 45",
6123 true, true);
6124}
Neels Hofmeyr91401012019-07-11 00:42:35 +02006125testcase TC_ho_neighbor_config_7() runs on test_CT {
6126 var MSC_ConnHdlr vc_conn;
Neels Hofmeyrf2b88032020-06-16 00:35:04 +02006127 f_init(3, true, guard_timeout := 50.0);
Neels Hofmeyr91401012019-07-11 00:42:35 +02006128 f_sleep(1.0);
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006129 f_ctrs_bsc_and_bts_init();
Neels Hofmeyr91401012019-07-11 00:42:35 +02006130 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_7));
6131 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006132
6133 /* f_tc_ho_neighbor_config_start() */
6134 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
6135 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
6136
6137 /* 7.a */
6138 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
6139 * handover quickly by sending a Handover Failure message. */
6140 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6141 f_ctrs_bsc_and_bts_add(0, "handover:failed");
6142 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
6143 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
6144
6145 /* 7.b */
6146 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
6147 * handover quickly by timing out after the Handover Required message */
6148 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6149 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
6150 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
6151 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
6152
6153 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006154 f_shutdown_helper();
Neels Hofmeyr91401012019-07-11 00:42:35 +02006155}
6156
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01006157/* OS#3041: Open and close N connections in a normal fashion, and expect no
6158 * BSSMAP Reset just because of that. */
6159testcase TC_bssap_rlsd_does_not_cause_bssmap_reset() runs on test_CT {
6160 var default d;
6161 var integer i;
6162 var DchanTuple dt;
6163
6164 f_init();
6165
6166 /* Wait for initial BSSMAP Reset to pass */
6167 f_sleep(4.0);
6168
6169 d := activate(no_bssmap_reset());
6170
6171 /* Setup up a number of connections and RLSD them again from the MSC
6172 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
6173 * Let's do it some more times for good measure. */
Harald Weltec3260d92018-06-11 17:48:16 +02006174 for (i := 0; i < 4; i := i+1) {
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01006175 /* Since we're doing a lot of runs, give each one a fresh
6176 * T_guard from the top. */
6177 T_guard.start;
6178
6179 /* Setup a BSSAP connection and clear it right away. This is
6180 * the MSC telling the BSC about a planned release, it's not an
6181 * erratic loss of a connection. */
Harald Weltea1897182018-06-11 13:53:09 +02006182 dt := f_est_dchan(int2oct(i,1), 23+i, '00010203040506'O);
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01006183
6184 /* MSC disconnects (RLSD). */
6185 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
6186 }
6187
6188 /* In the buggy behavior, a timeout of 2 seconds happens between above
6189 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
6190 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
6191 f_sleep(4.0);
6192
6193 deactivate(d);
6194 f_shutdown_helper();
6195}
Harald Welte552620d2017-12-16 23:21:36 +01006196
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01006197/* OS#3041: Open and close N connections in a normal fashion, and expect no
6198 * BSSMAP Reset just because of that. Invoke the release by a BSSMAP Clear from
6199 * the MSC. */
6200testcase TC_bssmap_clear_does_not_cause_bssmap_reset() runs on test_CT {
6201 var default d;
6202 var integer i;
6203 var DchanTuple dt;
6204 var BSSAP_N_DATA_ind rx_di;
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01006205 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_CALL_CONTROL;
6206 var BssmapCause cause := enum2int(cause_val);
6207
6208 f_init();
6209
6210 /* Wait for initial BSSMAP Reset to pass */
6211 f_sleep(4.0);
6212
6213 d := activate(no_bssmap_reset());
6214
6215 /* Setup up a number of connections and RLSD them again from the MSC
6216 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
6217 * Let's do it some more times for good measure. */
6218 for (i := 0; i < 8; i := i+1) {
6219 /* Since we're doing a lot of runs, give each one a fresh
6220 * T_guard from the top. */
6221 T_guard.start;
6222
6223 /* Setup a BSSAP connection and clear it right away. This is
6224 * the MSC telling the BSC about a planned release, it's not an
6225 * erratic loss of a connection. */
Harald Weltea1897182018-06-11 13:53:09 +02006226 dt := f_est_dchan(int2oct(i,1), 23+i, '00010203040506'O);
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01006227
6228 /* Instruct BSC to clear channel */
6229 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
6230
6231 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02006232 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01006233 }
6234
6235 /* In the buggy behavior, a timeout of 2 seconds happens between above
6236 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
6237 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
6238 f_sleep(4.0);
6239
6240 deactivate(d);
6241 f_shutdown_helper();
6242}
6243
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01006244/* OS#3041: Open and close N connections in a normal fashion, and expect no
6245 * BSSMAP Reset just because of that. Close connections from the MS side with a
6246 * Release Ind on RSL. */
6247testcase TC_ms_rel_ind_does_not_cause_bssmap_reset() runs on test_CT {
6248 var default d;
6249 var integer i;
6250 var DchanTuple dt;
6251 var BSSAP_N_DATA_ind rx_di;
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01006252 var integer j;
6253
6254 f_init();
6255
6256 /* Wait for initial BSSMAP Reset to pass */
6257 f_sleep(4.0);
6258
6259 d := activate(no_bssmap_reset());
6260
6261 /* Setup up a number of connections and RLSD them again from the MSC
6262 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
6263 * Let's do it some more times for good measure. */
6264 for (i := 0; i < 8; i := i+1) {
6265 /* Since we're doing a lot of runs, give each one a fresh
6266 * T_guard from the top. */
6267 T_guard.start;
6268
6269 /* Setup a BSSAP connection and clear it right away. This is
6270 * the MSC telling the BSC about a planned release, it's not an
6271 * erratic loss of a connection. */
6272 dt := f_est_dchan('23'O, 23, '00010203040506'O);
6273
6274 /* simulate RLL REL IND */
6275 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0))));
6276
6277 /* expect Clear Request on MSC side */
6278 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
6279
6280 /* Instruct BSC to clear channel */
6281 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
6282 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
6283
6284 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02006285 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01006286 }
6287
6288 /* In the buggy behavior, a timeout of 2 seconds happens between above
6289 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
6290 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
6291 f_sleep(4.0);
6292
6293 deactivate(d);
6294 f_shutdown_helper();
6295}
6296
Harald Welte94e0c342018-04-07 11:33:23 +02006297/***********************************************************************
6298 * IPA style dynamic PDCH
6299 ***********************************************************************/
6300
6301private function f_dyn_ipa_pdch_act(integer bts_nr, integer trx_nr, integer ts_nr,
6302 template (omit) RSL_Cause nack := omit)
6303runs on test_CT {
6304 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(ts_nr));
6305 var RSL_Message rsl_unused;
6306 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
6307 f_vty_ts_action("pdch activate", bts_nr, trx_nr, ts_nr);
6308 /* expect the BSC to issue the related RSL command */
6309 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
6310 if (istemplatekind(nack, "omit")) {
6311 /* respond with a related acknowledgement */
6312 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
6313 } else {
6314 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_NACK(chan_nr, valueof(nack)));
6315 }
6316}
6317
6318private function f_dyn_ipa_pdch_deact(integer bts_nr, integer trx_nr, integer ts_nr,
6319 template (omit) RSL_Cause nack := omit)
6320runs on test_CT {
6321 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(ts_nr));
6322 var RSL_Message rsl_unused;
6323 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
6324 f_vty_ts_action("pdch deactivate", bts_nr, trx_nr, ts_nr);
6325 /* expect the BSC to issue the related RSL command */
6326 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_DEACT(chan_nr));
6327 if (istemplatekind(nack, "omit")) {
6328 /* respond with a related acknowledgement */
6329 f_ipa_tx(0, ts_RSL_IPA_PDCH_DEACT_ACK(chan_nr));
6330 } else {
6331 f_ipa_tx(0, ts_RSL_IPA_PDCH_DEACT_NACK(chan_nr, valueof(nack)));
6332 }
6333}
6334
6335private function f_ts_dyn_mode_get(integer bts_nr, integer trx_nr, integer ts_nr)
6336runs on test_CT return charstring {
6337 var charstring cmd, resp;
6338 cmd := "show timeslot "&int2str(bts_nr)&" "&int2str(trx_nr)&" "&int2str(ts_nr);
Stefan Sperlingcff13562018-11-13 15:24:06 +01006339 return f_vty_transceive_match_regexp_retry(BSCVTY, cmd, "*\((*)\)*", 0, 4, 1.0);
Harald Welte94e0c342018-04-07 11:33:23 +02006340}
6341
6342private function f_ts_dyn_mode_assert(integer bts_nr, integer trx_nr, integer ts_nr,
6343 template charstring exp)
6344runs on test_CT {
6345 var charstring mode := f_ts_dyn_mode_get(bts_nr, trx_nr, ts_nr);
6346 if (not match(mode, exp)) {
6347 setverdict(fail, "Unexpected TS Mode: ", mode);
Daniel Willmannafce8662018-07-06 23:11:32 +02006348 mtc.stop;
Harald Welte94e0c342018-04-07 11:33:23 +02006349 }
6350}
6351
6352private function f_ts_set_chcomb(integer bts_nr, integer trx_nr, integer ts_nr, charstring chcomb)
6353runs on test_CT {
6354 f_vty_enter_cfg_ts(BSCVTY, bts_nr, trx_nr, ts_nr);
6355 f_vty_transceive(BSCVTY, "phys_chan_config " & chcomb);
6356 f_vty_transceive(BSCVTY, "end");
6357}
6358
6359private const charstring TCHF_MODE := "TCH/F mode";
6360private const charstring TCHH_MODE := "TCH/H mode";
6361private const charstring PDCH_MODE := "PDCH mode";
6362private const charstring NONE_MODE := "NONE mode";
6363
6364/* Test IPA PDCH activation / deactivation triggered by VTY */
6365testcase TC_dyn_pdch_ipa_act_deact() runs on test_CT {
6366 var RSL_Message rsl_unused;
6367
6368 /* change Timeslot 6 before f_init() starts RSL */
6369 f_init_vty();
6370 f_ts_set_chcomb(0, 0, 6, "TCH/F_PDCH");
6371 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
6372
6373 f_init(1, false);
6374 f_sleep(1.0);
6375
6376 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
6377
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006378 log("TCH/F_PDCH pchan starts out in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02006379 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6380 /* The BSC will activate the dynamic PDCH by default, so confirm that */
6381 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
6382 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
6383 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006384 log("TCH/F_PDCH pchan, PDCH ACT was ACKed, so now in PDCH mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02006385 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
6386
6387 /* De-activate it via VTY */
6388 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
6389 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006390 log("TCH/F_PDCH pchan, PDCH DEACT via VTY, so now back in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02006391 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6392
6393 /* re-activate it via VTY */
6394 f_dyn_ipa_pdch_act(0, 0, chan_nr.tn);
6395 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006396 log("TCH/F_PDCH pchan, PDCH ACT via VTY, so now in PDCH mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02006397 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
6398
6399 /* and finally de-activate it again */
6400 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
6401 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006402 log("TCH/F_PDCH pchan, PDCH DEACT via VTY, so now back in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02006403 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6404
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02006405 /* clean up config */
6406 f_ts_set_chcomb(0, 0, 6, "PDCH");
6407
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006408 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02006409}
6410
6411/* Test IPA PDCH activation NACK */
6412testcase TC_dyn_pdch_ipa_act_nack() runs on test_CT {
6413 var RSL_Message rsl_unused;
6414
6415 /* change Timeslot 6 before f_init() starts RSL */
6416 f_init_vty();
6417 f_ts_set_chcomb(0, 0, 6, "TCH/F_PDCH");
6418 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
6419
6420 f_init(1, false);
6421 f_sleep(1.0);
6422
6423 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
6424
6425 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6426 /* The BSC will activate the dynamic PDCH by default, so confirm that */
6427 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
6428 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
6429 f_sleep(1.0);
6430 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
6431
6432 /* De-activate it via VTY */
6433 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
6434 f_sleep(1.0);
6435 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6436
6437 /* re-activate it via VTY, but fail that; check BSC still assumes TCH/F mode */
6438 f_dyn_ipa_pdch_act(0, 0, chan_nr.tn, RSL_ERR_EQUIPMENT_FAIL);
6439 f_sleep(1.0);
6440 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6441
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02006442 /* clean up config */
6443 f_ts_set_chcomb(0, 0, 6, "PDCH");
6444
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006445 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02006446}
6447
6448
6449/***********************************************************************
6450 * Osmocom style dynamic PDCH
6451 ***********************************************************************/
6452
6453private function f_dyn_osmo_pdch_act(integer bts_nr, integer trx_nr, integer ts_nr,
6454 template (omit) RSL_Cause nack := omit)
6455runs on test_CT {
6456 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(ts_nr));
6457 var RSL_Message rsl_unused;
6458 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
6459 /* FIXME: no VTY command to activate Osmocom PDCH !! */
6460 /* expect the BSC to issue the related RSL command */
6461 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT(chan_nr, ?));
6462 if (istemplatekind(nack, "omit")) {
6463 /* respond with a related acknowledgement */
6464 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342));
6465 } else {
6466 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, valueof(nack)));
6467 }
6468}
6469
6470private function f_dyn_osmo_pdch_deact(integer bts_nr, integer trx_nr, integer ts_nr,
6471 template (omit) RSL_Cause nack := omit)
6472runs on test_CT {
6473 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(ts_nr));
6474 var RSL_Message rsl_unused;
6475 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
6476 /* FIXME: no VTY command to activate Osmocom PDCH !! */
6477 /* expect the BSC to issue the related RSL command */
6478 rsl_unused := f_exp_ipa_rx(0, tr_RSL_RF_CHAN_REL(chan_nr));
6479 if (istemplatekind(nack, "omit")) {
6480 /* respond with a related acknowledgement */
6481 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(chan_nr));
6482 } else {
6483 //f_ipa_tx(0, ts_RSL_RF_CHAN_REL_NACK(chan_nr, valueof(nack)));
6484 }
6485}
6486
6487/* Test Osmocom dyn PDCH activation / deactivation triggered by VTY */
6488testcase TC_dyn_pdch_osmo_act_deact() runs on test_CT {
6489 var RSL_Message rsl_unused;
6490
6491 /* change Timeslot 6 before f_init() starts RSL */
6492 f_init_vty();
6493 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_PDCH");
6494 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
6495
6496 f_init(1, false);
6497 f_sleep(1.0);
6498
6499 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(6));
6500
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006501 log("TCH/F_TCH/H_PDCH pchan starts out in disabled mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02006502 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
6503 /* The BSC will activate the dynamic PDCH by default, so confirm that */
6504 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
6505
6506 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342));
6507 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006508 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 +02006509 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
6510
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02006511 /* clean up config */
6512 f_ts_set_chcomb(0, 0, 6, "PDCH");
6513
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006514 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02006515}
6516
6517/* Test Osmocom dyn PDCH activation NACK behavior */
6518testcase TC_dyn_pdch_osmo_act_nack() runs on test_CT {
6519 var RSL_Message rsl_unused;
6520
6521 /* change Timeslot 6 before f_init() starts RSL */
6522 f_init_vty();
6523 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_PDCH");
6524 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
6525
6526 f_init(1, false);
6527 f_sleep(1.0);
6528
6529 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(6));
6530
6531 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
6532 /* The BSC will activate the dynamic PDCH by default, so confirm that */
6533 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
6534
6535 /* NACK this activation and expect the "show timeslot" mode still to be NONE */
6536 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, RSL_ERR_EQUIPMENT_FAIL));
6537 f_sleep(1.0);
6538 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
6539
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02006540 /* clean up config */
6541 f_ts_set_chcomb(0, 0, 6, "PDCH");
6542
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006543 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02006544}
6545
Stefan Sperling0796a822018-10-05 13:01:39 +02006546testcase TC_chopped_ipa_ping() runs on test_CT {
Stefan Sperling554123f2018-10-09 14:12:30 +02006547 const Integers bsc_ipa_ports := {mp_bsc_rsl_port, mp_bsc_oml_port, mp_bsc_ctrl_port};
Stefan Sperling0796a822018-10-05 13:01:39 +02006548 for (var integer i := 0; i < lengthof(bsc_ipa_ports); i := i + 1) {
6549 IPA_Testing.f_run_TC_chopped_ipa_ping(mp_bsc_ip, bsc_ipa_ports[i], CONNECT_TO_SERVER);
6550 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006551 f_shutdown_helper();
Stefan Sperling0796a822018-10-05 13:01:39 +02006552}
6553
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02006554testcase TC_chopped_ipa_payload() runs on test_CT {
6555 const Integers bsc_ipa_ports := {mp_bsc_rsl_port, mp_bsc_oml_port
6556 /* TODO: mp_bsc_ctrl_port does not work yet */};
6557 for (var integer i := 0; i < lengthof(bsc_ipa_ports); i := i + 1) {
6558 IPA_Testing.f_run_TC_chopped_ipa_payload(mp_bsc_ip, bsc_ipa_ports[i], CONNECT_TO_SERVER);
6559 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006560 f_shutdown_helper();
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02006561}
6562
Pau Espin Pedrol8f773632019-11-05 11:46:53 +01006563/* Verify the BSC sends the MS Power Parameters IE during CHAN ACT to make sure
6564 the BTS does autonomous MS power control loop */
6565testcase TC_assignment_verify_ms_power_params_ie() runs on test_CT {
6566 var MSC_ConnHdlr vc_conn;
6567 var TestHdlrParams pars := f_gen_test_hdlr_pars();
6568 //pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
6569 pars.exp_ms_power_params := true;
6570
6571 f_init(1, true);
6572 f_sleep(1.0);
6573 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
6574 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006575 f_shutdown_helper();
Pau Espin Pedrol8f773632019-11-05 11:46:53 +01006576}
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02006577
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006578/***********************************************************************
6579 * MSC Pooling
6580 ***********************************************************************/
6581
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006582template MobileIdentityLV ts_MI_TMSI_NRI_LV(integer nri_v, integer nri_bitlen := 10) :=
Harald Weltebf397612021-01-14 20:39:46 +01006583 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 +02006584
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02006585private function f_expect_lchan_rel(RSL_DCHAN_PT rsl, template PDU_ML3_NW_MS exp_rr_rel_tmpl := tr_RRM_RR_RELEASE)
6586runs on MSC_ConnHdlr {
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02006587 interleave {
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02006588 [] rsl.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch exp_rr_rel_tmpl)) {
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02006589 f_logp(BSCVTY, "Got RSL RR Release");
6590 }
6591 [] rsl.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
6592 f_logp(BSCVTY, "Got RSL Deact SACCH");
6593 }
6594 [] rsl.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
6595 f_logp(BSCVTY, "Got RSL RF Chan Rel, sending Rel Ack");
6596 rsl.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
6597 break;
6598 }
6599 }
6600}
6601
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02006602private function f_perform_clear(RSL_DCHAN_PT rsl, template PDU_ML3_NW_MS exp_rr_rel_tmpl := tr_RRM_RR_RELEASE)
6603runs on MSC_ConnHdlr {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006604 f_logp(BSCVTY, "MSC instructs BSC to clear channel");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006605 BSSAP.send(ts_BSSMAP_ClearCommand(0));
6606 interleave {
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02006607 [] rsl.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch exp_rr_rel_tmpl)) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006608 f_logp(BSCVTY, "Got RSL RR Release");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006609 }
6610 [] rsl.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006611 f_logp(BSCVTY, "Got RSL Deact SACCH");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006612 }
6613 [] BSSAP.receive(tr_BSSMAP_ClearComplete) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006614 f_logp(BSCVTY, "Got BSSMAP Clear Complete");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006615 /* Also drop the SCCP connection */
6616 BSSAP.send(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_REQ);
6617 }
6618 [] rsl.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006619 f_logp(BSCVTY, "Got RSL RF Chan Rel, sending Rel Ack");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006620 rsl.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
6621 }
6622 }
6623}
6624
Neels Hofmeyr66e15092020-10-12 18:44:41 +00006625private 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 +02006626runs on MSC_ConnHdlr {
6627 timer T := 10.0;
6628 var octetstring l3_enc := enc_PDU_ML3_MS_NW(valueof(l3_info));
6629
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006630 f_logp(BSCVTY, "establish channel, send Complete Layer 3 Info");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006631 f_create_bssmap_exp(l3_enc);
6632
6633 /* RSL_Emulation.f_chan_est() on rsl:
6634 * This is basically code dup with s/RSL/rsl from:
6635 * RSL_Emulation.f_chan_est(g_pars.ra, l3_enc, g_pars.link_id, g_pars.fn);
6636 */
6637 var RSL_Message rx_rsl;
6638 var GsmRrMessage rr;
6639
6640 /* request a channel to be established */
6641 rsl.send(ts_RSLDC_ChanRqd(g_pars.ra, g_pars.fn));
6642 /* expect immediate assignment.
6643 * Code dup with s/RSL/rsl from:
6644 * rx_rsl := f_rx_or_fail(tr_RSL_IMM_ASSIGN);
6645 */
6646 timer Tt := 10.0;
6647
6648 /* request a channel to be established */
6649 Tt.start;
6650 alt {
6651 [] rsl.receive(tr_RSL_IMM_ASSIGN) -> value rx_rsl {
6652 Tt.stop;
6653 }
6654 [] rsl.receive {
6655 setverdict(fail, "Unexpected RSL message on DCHAN");
6656 mtc.stop;
6657 }
6658 [] Tt.timeout {
6659 setverdict(fail, "Timeout waiting for RSL on DCHAN");
6660 mtc.stop;
6661 }
6662 }
6663 rr := dec_GsmRrMessage(rx_rsl.ies[1].body.full_imm_ass_info.payload);
6664 g_chan_nr := rr.payload.imm_ass.chan_desc.chan_nr;
6665 rsl.send(ts_RSL_EST_IND(g_chan_nr, valueof(g_pars.link_id), l3_enc));
6666
6667
Neels Hofmeyr66e15092020-10-12 18:44:41 +00006668 if (expect_bssmap_l3) {
6669 f_logp(BSCVTY, "expect BSSAP Complete Layer 3 Info at MSC");
6670 var template PDU_BSSAP exp_l3_compl;
6671 exp_l3_compl := tr_BSSMAP_ComplL3()
6672 if (g_pars.aoip == false) {
6673 exp_l3_compl.pdu.bssmap.completeLayer3Information.codecList := omit;
6674 } else {
6675 exp_l3_compl.pdu.bssmap.completeLayer3Information.codecList := ?;
6676 }
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006677
Neels Hofmeyr66e15092020-10-12 18:44:41 +00006678 var PDU_BSSAP bssap;
6679 T.start;
6680 alt {
6681 [] BSSAP.receive(exp_l3_compl) -> value bssap {
6682 f_logp(BSCVTY, "received expected Complete Layer 3 Info at MSC");
6683 log("rx exp_l3_compl = ", bssap);
6684 }
6685 [] BSSAP.receive(tr_BSSMAP_ComplL3) {
6686 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received non-matching COMPLETE LAYER 3 INFORMATION");
6687 }
6688 [] T.timeout {
6689 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for COMPLETE LAYER 3 INFORMATION");
6690 }
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006691 }
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006692
Neels Hofmeyr66e15092020-10-12 18:44:41 +00006693 /* start ciphering, if requested */
6694 if (ispresent(g_pars.encr)) {
6695 f_logp(BSCVTY, "start ciphering");
6696 f_cipher_mode(g_pars.encr.enc_alg, g_pars.encr.enc_key);
6697 }
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006698 }
6699
6700 if (do_clear) {
6701 f_perform_clear(rsl);
6702 }
6703 setverdict(pass);
6704 f_sleep(1.0);
6705}
6706
6707private function f_tc_mscpool_compl_l3(charstring id) runs on MSC_ConnHdlr {
6708 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
6709 if (g_pars.mscpool.rsl_idx == 0) {
6710 f_perform_compl_l3(RSL, g_pars.mscpool.l3_info);
6711 } else if (g_pars.mscpool.rsl_idx == 1) {
6712 f_perform_compl_l3(RSL1, g_pars.mscpool.l3_info);
6713 } else if (g_pars.mscpool.rsl_idx == 2) {
6714 f_perform_compl_l3(RSL2, g_pars.mscpool.l3_info);
6715 }
6716}
6717
6718/* Various Complete Layer 3 by IMSI all end up with the first MSC, because the other MSCs are not connected. */
6719private function f_tc_mscpool_L3Compl_on_1_msc(charstring id) runs on MSC_ConnHdlr {
6720 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
6721 f_perform_compl_l3(RSL, ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000001'H)), '00F110'O) );
6722 f_perform_compl_l3(RSL, ts_CM_SERV_REQ(CM_TYPE_MO_SMS, valueof(ts_MI_IMSI_LV('001010000000002'H))) );
6723 f_perform_compl_l3(RSL, ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010000000003'H))) );
6724 f_perform_compl_l3(RSL, ts_ML3_MO_MM_IMSI_DET_Ind(valueof(ts_MI_IMSI_LV('001010000000004'H))) );
6725}
6726testcase TC_mscpool_L3Compl_on_1_msc() runs on test_CT {
6727
6728 f_init(1, true);
6729 f_sleep(1.0);
6730 var MSC_ConnHdlr vc_conn;
6731 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006732
6733 f_ctrs_msc_init();
6734
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006735 vc_conn := f_start_handler(refers(f_tc_mscpool_L3Compl_on_1_msc), pars);
6736 vc_conn.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006737
6738 f_ctrs_msc_expect(0, "mscpool:subscr:new", 4);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006739 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006740}
6741
6742/* Three Layer 3 Complete by IMSI are round-robin'ed across two connected MSCs */
6743/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6744 * just as well using only RSL. */
6745testcase TC_mscpool_L3Complete_by_imsi_round_robin() runs on test_CT {
6746
6747 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6748 f_sleep(1.0);
6749
6750 /* Control which MSC gets chosen next by the round-robin, otherwise
6751 * would be randomly affected by which other tests ran before this. */
6752 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6753
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006754 f_ctrs_msc_init();
6755
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006756 var MSC_ConnHdlr vc_conn1;
6757 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6758 pars1.mscpool.rsl_idx := 0;
6759 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000001'H)), '00F110'O));
6760 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6761 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006762 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006763
6764 var MSC_ConnHdlr vc_conn2;
6765 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6766 pars2.mscpool.rsl_idx := 1;
6767 pars2.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000002'H))));
6768 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6769 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006770 f_ctrs_msc_expect(1, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006771
6772 /* Test round-robin wrap to the first MSC */
6773 var MSC_ConnHdlr vc_conn3;
6774 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6775 pars3.mscpool.rsl_idx := 2;
6776 pars3.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010000000003'H))));
6777 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6778 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006779 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006780 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006781}
6782
6783/* Three LU by TMSI are round-robin'ed across two connected MSCs, because they contain the NULL-NRI 0
6784 * (configured in osmo-bsc.cfg). */
6785/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6786 * just as well using only RSL. */
6787testcase TC_mscpool_LU_by_tmsi_null_nri_0_round_robin() runs on test_CT {
6788
6789 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6790 f_sleep(1.0);
6791
6792 /* Control which MSC gets chosen next by the round-robin, otherwise
6793 * would be randomly affected by which other tests ran before this. */
6794 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6795
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006796 f_ctrs_msc_init();
6797
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006798 var MSC_ConnHdlr vc_conn1;
6799 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6800 pars1.mscpool.rsl_idx := 0;
6801 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(0)), '00F110'O));
6802 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6803 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006804 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006805
6806 var MSC_ConnHdlr vc_conn2;
6807 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6808 pars2.mscpool.rsl_idx := 1;
6809 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(0)), '00F110'O));
6810 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6811 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006812 f_ctrs_msc_expect(1, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006813
6814 /* Test round-robin wrap to the first MSC */
6815 var MSC_ConnHdlr vc_conn3;
6816 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6817 pars3.mscpool.rsl_idx := 2;
6818 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(0)), '00F110'O));
6819 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6820 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006821 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006822 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006823}
6824
6825/* Three LU by TMSI are round-robin'ed across two connected MSCs, because they contain the NULL-NRI 1
6826 * (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
6827 * NULL-NRI setting is stronger than that. */
6828/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6829 * just as well using only RSL. */
6830testcase TC_mscpool_LU_by_tmsi_null_nri_1_round_robin() runs on test_CT {
6831
6832 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6833 f_sleep(1.0);
6834
6835 /* Control which MSC gets chosen next by the round-robin, otherwise
6836 * would be randomly affected by which other tests ran before this. */
6837 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6838
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006839 f_ctrs_msc_init();
6840
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006841 var MSC_ConnHdlr vc_conn1;
6842 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6843 pars1.mscpool.rsl_idx := 0;
6844 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(1)), '00F110'O));
6845 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6846 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006847 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006848
6849 var MSC_ConnHdlr vc_conn2;
6850 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6851 pars2.mscpool.rsl_idx := 1;
6852 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(1)), '00F110'O));
6853 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6854 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006855 f_ctrs_msc_expect(1, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006856
6857 /* Test round-robin wrap to the first MSC */
6858 var MSC_ConnHdlr vc_conn3;
6859 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6860 pars3.mscpool.rsl_idx := 2;
6861 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(1)), '00F110'O));
6862 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6863 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006864 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006865 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006866}
6867
6868/* Three Layer 3 Complete by TMSI are round-robin'ed across two connected MSCs, because they contain an NRI not
6869 * assigned to any MSC (configured in osmo-bsc.cfg). */
6870/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6871 * just as well using only RSL. */
6872testcase TC_mscpool_L3Complete_by_tmsi_unassigned_nri_round_robin() runs on test_CT {
6873
6874 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6875 f_sleep(1.0);
6876
6877 /* Control which MSC gets chosen next by the round-robin, otherwise
6878 * would be randomly affected by which other tests ran before this. */
6879 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6880
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006881 f_ctrs_msc_init();
6882
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006883 var MSC_ConnHdlr vc_conn1;
6884 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6885 pars1.mscpool.rsl_idx := 0;
6886 /* An NRI that is not assigned to any MSC */
6887 pars1.mscpool.l3_info := valueof(ts_ML3_MO_MM_IMSI_DET_Ind(valueof(ts_MI_TMSI_NRI_LV(1023))));
6888 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6889 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006890 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006891
6892 var MSC_ConnHdlr vc_conn2;
6893 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6894 pars2.mscpool.rsl_idx := 1;
6895 /* An NRI that is not assigned to any MSC */
6896 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(768)), '00F110'O));
6897 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6898 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006899 f_ctrs_msc_expect(1, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006900
6901 /* Test round-robin wrap to the first MSC */
6902 var MSC_ConnHdlr vc_conn3;
6903 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6904 pars3.mscpool.rsl_idx := 2;
6905 /* An NRI that is not assigned to any MSC */
6906 pars3.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_SS_ACT, valueof(ts_MI_TMSI_NRI_LV(819))));
6907 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6908 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006909 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006910 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006911}
6912
6913/* Three Layer 3 Complete by TMSI are round-robin'ed across two connected MSCs, because they contain an NRI
6914 * assigned to an MSC that is currently not connected (configured in osmo-bsc.cfg). */
6915/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6916 * just as well using only RSL. */
6917testcase TC_mscpool_L3Complete_by_tmsi_valid_nri_msc_not_connected_round_robin() runs on test_CT {
6918
6919 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6920 f_sleep(1.0);
6921
6922 /* Control which MSC gets chosen next by the round-robin, otherwise
6923 * would be randomly affected by which other tests ran before this. */
6924 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6925
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006926 f_ctrs_msc_init();
6927
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006928 var MSC_ConnHdlr vc_conn1;
6929 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6930 pars1.mscpool.rsl_idx := 0;
6931 /* An NRI that is assigned to an unconnected MSC */
6932 pars1.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(512))));
6933 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6934 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006935 f_ctrs_msc_add(2, "mscpool:subscr:attach_lost");
6936 f_ctrs_msc_add(0, "mscpool:subscr:new");
6937 f_ctrs_msc_verify();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006938
6939 var MSC_ConnHdlr vc_conn2;
6940 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6941 pars2.mscpool.rsl_idx := 1;
6942 /* An NRI that is assigned to an unconnected MSC */
6943 pars2.mscpool.l3_info := valueof(ts_ML3_MO_MM_IMSI_DET_Ind(valueof(ts_MI_TMSI_NRI_LV(767))));
6944 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6945 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006946 f_ctrs_msc_add(2, "mscpool:subscr:attach_lost");
6947 f_ctrs_msc_add(1, "mscpool:subscr:new");
6948 f_ctrs_msc_verify();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006949
6950 /* Test round-robin wrap to the first MSC */
6951 var MSC_ConnHdlr vc_conn3;
6952 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6953 pars3.mscpool.rsl_idx := 2;
6954 /* An NRI that is assigned to an unconnected MSC */
6955 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(750)), '00F110'O));
6956 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6957 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006958 f_ctrs_msc_add(2, "mscpool:subscr:attach_lost");
6959 f_ctrs_msc_add(0, "mscpool:subscr:new");
6960 f_ctrs_msc_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006961 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006962}
6963
6964/* Three Layer 3 Complete by TMSI with valid NRI for the second MSC are all directed to the second MSC (configured in
6965 * osmo-bsc.cfg). */
6966/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6967 * just as well using only RSL. */
6968testcase TC_mscpool_L3Complete_by_tmsi_valid_nri_1() runs on test_CT {
6969
6970 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6971 f_sleep(1.0);
6972
6973 /* All TMSIs in this test point at the second MSC, set the round robin to point at the first MSC to make sure
6974 * this is not using round-robin. */
6975 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6976
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006977 f_ctrs_msc_init();
6978
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006979 var MSC_ConnHdlr vc_conn1;
6980 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 1);
6981 pars1.mscpool.rsl_idx := 0;
6982 /* An NRI of the second MSC's range (256-511) */
6983 pars1.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_SMS, valueof(ts_MI_TMSI_NRI_LV(256))));
6984 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6985 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006986 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006987
6988 var MSC_ConnHdlr vc_conn2;
6989 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6990 pars2.mscpool.rsl_idx := 1;
6991 /* An NRI of the second MSC's range (256-511) */
6992 pars2.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(260))));
6993 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6994 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006995 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006996
6997 var MSC_ConnHdlr vc_conn3;
6998 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 1);
6999 pars3.mscpool.rsl_idx := 2;
7000 /* An NRI of the second MSC's range (256-511) */
7001 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(511)), '00F110'O));
7002 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
7003 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007004 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007005 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007006}
7007
7008/* Layer 3 Complete by TMSI with valid NRI for the third MSC are directed to the third MSC (configured in osmo-bsc.cfg),
7009 * while a round-robin remains unaffected by that. */
7010/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
7011 * just as well using only RSL. */
7012testcase TC_mscpool_L3Complete_by_tmsi_valid_nri_2() runs on test_CT {
7013
7014 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
7015 f_sleep(1.0);
7016
7017 /* All TMSIs in this test point at the third MSC, set the round robin to point at the second MSC to make sure
7018 * this is not using round-robin. */
7019 f_vty_transceive(BSCVTY, "mscpool roundrobin next 1");
7020
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007021 f_ctrs_msc_init();
7022
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007023 var MSC_ConnHdlr vc_conn1;
7024 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 2);
7025 pars1.mscpool.rsl_idx := 0;
7026 /* An NRI of the third MSC's range (512-767) */
7027 pars1.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_SMS, valueof(ts_MI_TMSI_NRI_LV(512))));
7028 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
7029 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007030 f_ctrs_msc_expect(2, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007031
7032 var MSC_ConnHdlr vc_conn2;
7033 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 2);
7034 pars2.mscpool.rsl_idx := 1;
7035 /* An NRI of the third MSC's range (512-767) */
7036 pars2.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(678))));
7037 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
7038 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007039 f_ctrs_msc_expect(2, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007040
7041 /* The above forwardings to third MSC have not affected the round robin, which still points at the second MSC */
7042 var MSC_ConnHdlr vc_conn3;
7043 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 1);
7044 pars3.mscpool.rsl_idx := 2;
7045 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000013'H)), '00F110'O));
7046 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
7047 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007048 f_ctrs_msc_expect(1, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007049 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007050}
7051
7052/* LU with a TMSI but indicating a different PLMN in its previous LAI: ignore the NRI. */
7053/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
7054 * just as well using only RSL. */
7055testcase TC_mscpool_LU_by_tmsi_from_other_PLMN() runs on test_CT {
7056
7057 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
7058 f_sleep(1.0);
7059
7060 /* The TMSIs in this test points at the second MSC, but since it is from a different PLMN, round-robin is used
7061 * instead, and hits msc 0. */
7062 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
7063
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007064 f_ctrs_msc_init();
7065
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007066 /* An NRI of the second MSC's range (256-511), but a PLMN that doesn't match with osmo-bsc.cfg */
7067 var MSC_ConnHdlr vc_conn1;
7068 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
7069 pars1.mscpool.rsl_idx := 0;
7070 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(260)), '99F999'O));
7071 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
7072 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007073 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007074
7075 /* An NRI of the third MSC's range (512-767) and a matching PLMN gets directed by NRI. */
7076 var MSC_ConnHdlr vc_conn2;
7077 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 2);
7078 pars2.mscpool.rsl_idx := 1;
7079 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(555)), '00F110'O));
7080 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
7081 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007082 f_ctrs_msc_expect(2, "mscpool:subscr:known");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007083 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007084}
7085
7086/* Make sure that whichever MSC paged a subscriber will also get the Paging Response. Page by IMSI, which would be
7087 * round-robined to another MSC, to make sure the Paging->Response relation is stronger than the NRI->MSC mapping. */
7088private function f_tc_mscpool_paging_imsi(charstring id) runs on MSC_ConnHdlr {
7089 var template BSSMAP_FIELD_CellIdentificationList cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(0) } };
7090 //cid_list := { cIl_allInBSS := ''O };
7091 var RSL_ChanNeeded rsl_chneed := RSL_CHANNEED_SDCCH;
7092 var template BSSMAP_IE_ChannelNeeded bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
7093 var BSSAP_N_UNITDATA_req paging;
7094 var hexstring imsi := '001010000000123'H;
7095
7096 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
7097
Neels Hofmeyr90f80962020-06-12 16:16:55 +02007098 paging := valueof(ts_BSSAP_UNITDATA_req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007099 valueof(ts_BSSMAP_Paging(imsi, cid_list, omit, bssmap_chneed))));
7100 BSSAP.send(paging);
7101
7102 /* Register any RSL conn so that the Paging Command gets received here. With the current RSL_Emulation's main()
7103 * handling of '[bts_role] IPA_PT.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD()))' it doesn't matter at all which
7104 * channel number is picked here. */
7105 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(0, RSL_CHAN_NR_INVALID));
7106 f_rslem_register(0, new_chan_nr);
7107 RSL.receive(tr_RSL_PAGING_CMD(tr_MI_IMSI(imsi)));
7108 f_rslem_unregister(0, new_chan_nr);
7109
7110 /* Despite the round robin pointing at the second MSC ('roundrobin next 1'), the earlier Paging for the same IMSI
7111 * causes this Paging Response to go to the first MSC (bssap_idx := 0). */
7112 f_perform_compl_l3(RSL, ts_PAG_RESP(valueof(ts_MI_IMSI_LV(imsi))) );
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007113 f_sleep(1.0);
7114}
7115testcase TC_mscpool_paging_and_response_imsi() runs on test_CT {
7116 f_init(nr_bts := 1, handler_mode := true, nr_msc := 3);
7117 f_sleep(1.0);
7118
7119 /* Testing a Paging on the first MSC to get a Paging Response back to the first MSC. Set round robin to the
7120 * second MSC to make sure we're getting the Paging logic, not a coincidental round robin match. */
7121 f_vty_transceive(BSCVTY, "mscpool roundrobin next 1");
7122
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007123 f_ctrs_msc_init();
7124
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007125 var MSC_ConnHdlr vc_conn1;
7126 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
7127 pars1.mscpool.rsl_idx := 0;
Neels Hofmeyr90f80962020-06-12 16:16:55 +02007128 pars1.sccp_addr_bsc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_peer;
7129 pars1.sccp_addr_msc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_own;
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007130 vc_conn1 := f_start_handler(refers(f_tc_mscpool_paging_imsi), pars1);
7131 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007132 f_ctrs_msc_expect(0, "mscpool:subscr:paged");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007133 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007134}
7135
7136/* Make sure that whichever MSC paged a subscriber will also get the Paging Response. Page by TMSI with an NRI value
7137 * that matches a different MSC, to make sure the Paging->Response relation is stronger than the NRI->MSC mapping. */
7138private function f_tc_mscpool_paging_tmsi(charstring id) runs on MSC_ConnHdlr {
7139 var template BSSMAP_FIELD_CellIdentificationList cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(0) } };
7140 //cid_list := { cIl_allInBSS := ''O };
7141 var RSL_ChanNeeded rsl_chneed := RSL_CHANNEED_SDCCH;
7142 var template BSSMAP_IE_ChannelNeeded bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
7143 var integer nri_v := 300; /* <-- second MSC's NRI */
Harald Weltebf397612021-01-14 20:39:46 +01007144 var octetstring tmsi := f_gen_tmsi(suffix := 0, nri_v := nri_v);
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007145 var BSSAP_N_UNITDATA_req paging;
7146
7147 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
7148
Neels Hofmeyr90f80962020-06-12 16:16:55 +02007149 paging := valueof(ts_BSSAP_UNITDATA_req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007150 valueof(ts_BSSMAP_Paging('001010000000011'H, cid_list, tmsi, bssmap_chneed))));
7151 BSSAP.send(paging);
7152
7153 /* Register any RSL conn so that the Paging Command gets received here. With the current RSL_Emulation's main()
7154 * handling of '[bts_role] IPA_PT.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD()))' it doesn't matter at all which
7155 * channel number is picked here. */
7156 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(0, RSL_CHAN_NR_INVALID));
7157 f_rslem_register(0, new_chan_nr);
7158 RSL.receive(tr_RSL_PAGING_CMD(t_MI_TMSI(tmsi)));
7159 f_rslem_unregister(0, new_chan_nr);
7160
7161 /* Despite the NRI matching the second MSC (NRI from 'msc 1' in osmo-bsc.cfg) and round robin pointing at the
7162 * third MSC ('roundrobin next 2'), the earlier Paging for the same TMSI causes this Paging Response to go to
7163 * the first MSC (bssap_idx := 0). */
7164 f_perform_compl_l3(RSL, ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(nri_v))) );
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007165 f_sleep(1.0);
7166}
7167testcase TC_mscpool_paging_and_response_tmsi() runs on test_CT {
7168 f_init(nr_bts := 1, handler_mode := true, nr_msc := 3);
7169 f_sleep(1.0);
7170
7171 /* Testing a Paging on the first MSC to get a Paging Response back to the first MSC. Set round robin to the
7172 * third MSC to make sure we're getting the Paging logic, not a coincidental round robin match. */
7173 f_vty_transceive(BSCVTY, "mscpool roundrobin next 2");
7174
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007175 f_ctrs_msc_init();
7176
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007177 var MSC_ConnHdlr vc_conn1;
7178 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
7179 pars1.mscpool.rsl_idx := 0;
Neels Hofmeyr90f80962020-06-12 16:16:55 +02007180 pars1.sccp_addr_bsc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_peer;
7181 pars1.sccp_addr_msc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_own;
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007182 vc_conn1 := f_start_handler(refers(f_tc_mscpool_paging_tmsi), pars1);
7183 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007184 f_ctrs_msc_expect(0, "mscpool:subscr:paged");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007185 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007186}
7187
7188/* For round-robin, skip an MSC that has 'no allow-attach' set. */
7189/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
7190 * just as well using only RSL. */
7191testcase TC_mscpool_no_allow_attach_round_robin() runs on test_CT {
7192
7193 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
7194 f_sleep(1.0);
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00007195 /* Mark the second MSC as offloading, round-robin should skip this MSC now. */
7196 f_vty_msc_allow_attach(BSCVTY, {true, false, true});
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007197
7198 /* Control which MSC gets chosen next by the round-robin, otherwise
7199 * would be randomly affected by which other tests ran before this. */
7200 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
7201
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007202 f_ctrs_msc_init();
7203
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007204 var MSC_ConnHdlr vc_conn1;
7205 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
7206 pars1.mscpool.rsl_idx := 0;
7207 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000001'H)), '00F110'O));
7208 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
7209 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007210 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007211
7212 var MSC_ConnHdlr vc_conn2;
7213 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 2);
7214 pars2.mscpool.rsl_idx := 1;
7215 pars2.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000002'H))));
7216 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
7217 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007218 f_ctrs_msc_expect(2, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007219
7220 var MSC_ConnHdlr vc_conn3;
7221 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
7222 pars3.mscpool.rsl_idx := 2;
7223 pars3.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010000000003'H))));
7224 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
7225 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007226 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007227 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007228}
7229
7230/* An MSC that has 'no allow-attach' set should still serve subscribers that are already attached according to their
7231 * TMSI NRI. */
7232testcase TC_mscpool_no_allow_attach_valid_nri() runs on test_CT {
7233
7234 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
7235 f_sleep(1.0);
7236
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00007237 /* Mark the second MSC as offloading, round-robin should skip this MSC now. */
7238 f_vty_msc_allow_attach(BSCVTY, {true, false, true});
7239
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007240 /* Control which MSC gets chosen next by the round-robin, otherwise
7241 * would be randomly affected by which other tests ran before this. */
7242 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
7243
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007244 f_ctrs_msc_init();
7245
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007246 /* Round robin points at msc 0, but the valid NRI directs to msc 1, even though msc 1 has 'no allow-attach'. */
7247 var MSC_ConnHdlr vc_conn1;
7248 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 1);
7249 pars1.mscpool.rsl_idx := 0;
7250 /* An NRI of the second MSC's range (256-511) */
7251 pars1.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_TMSI_NRI_LV(260))));
7252 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
7253 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007254 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007255
7256 var MSC_ConnHdlr vc_conn2;
7257 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 0);
7258 pars2.mscpool.rsl_idx := 1;
7259 pars2.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000002'H))));
7260 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
7261 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007262 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007263
7264 var MSC_ConnHdlr vc_conn3;
7265 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 2);
7266 pars3.mscpool.rsl_idx := 2;
7267 pars3.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000003'H))));
7268 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
7269 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007270 f_ctrs_msc_expect(2, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007271 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007272}
7273
Philipp Maier783681c2020-07-16 16:47:06 +02007274/* Allow/Deny emergency calls globally via VTY */
7275private function f_vty_allow_emerg_msc(boolean allow) runs on test_CT {
7276 f_vty_enter_cfg_msc(BSCVTY, 0);
7277 if (allow) {
7278 f_vty_transceive(BSCVTY, "allow-emergency allow");
7279 } else {
7280 f_vty_transceive(BSCVTY, "allow-emergency deny");
7281 }
7282 f_vty_transceive(BSCVTY, "exit");
7283 f_vty_transceive(BSCVTY, "exit");
7284}
7285
7286/* Allow/Deny emergency calls per BTS via VTY */
7287private function f_vty_allow_emerg_bts(boolean allow, integer bts_nr) runs on test_CT {
7288 f_vty_enter_cfg_bts(BSCVTY, bts_nr);
7289 if (allow) {
7290 f_vty_transceive(BSCVTY, "rach emergency call allowed 1");
7291 } else {
7292 f_vty_transceive(BSCVTY, "rach emergency call allowed 0");
7293 }
7294 f_vty_transceive(BSCVTY, "exit");
7295 f_vty_transceive(BSCVTY, "exit");
Neels Hofmeyrb6ed80c2020-10-12 22:52:39 +00007296 f_vty_transceive(BSCVTY, "exit");
Philipp Maier783681c2020-07-16 16:47:06 +02007297}
7298
7299/* Begin assignmet procedure and send an EMERGENCY SETUP (RR) */
7300private function f_assignment_emerg_setup() runs on MSC_ConnHdlr {
7301 var PDU_ML3_MS_NW emerg_setup;
7302 var octetstring emerg_setup_enc;
7303 var RSL_Message emerg_setup_data_ind;
7304
7305 f_establish_fully(omit, omit);
7306
7307 emerg_setup := valueof(ts_ML3_MO_CC_EMERG_SETUP(1, valueof(ts_Bcap_voice)));
7308 emerg_setup_enc := enc_PDU_ML3_MS_NW(emerg_setup);
7309 emerg_setup_data_ind := valueof(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), emerg_setup_enc));
7310
7311 RSL.send(emerg_setup_data_ind);
7312}
7313
7314/* Test if the EMERGENCY SETUP gets passed on to the MSC via A when EMERGENCY
7315 * CALLS are permitted by the BSC config. */
7316private function f_TC_assignment_emerg_setup_allow(charstring id) runs on MSC_ConnHdlr {
7317 var PDU_BSSAP emerg_setup_data_ind_bssap;
7318 var PDU_ML3_MS_NW emerg_setup;
7319 timer T := 3.0;
7320
7321 f_assignment_emerg_setup()
7322
7323 T.start;
7324 alt {
7325 [] BSSAP.receive(tr_BSSAP_DTAP) -> value emerg_setup_data_ind_bssap {
7326 emerg_setup := dec_PDU_ML3_MS_NW(emerg_setup_data_ind_bssap.pdu.dtap);
7327 if (not isbound(emerg_setup.msgs.cc.emergencySetup)) {
7328 setverdict(fail, "no emergency setup");
7329 }
7330 }
7331 [] BSSAP.receive {
7332 setverdict(fail, "unexpected BSSAP message!");
7333 }
7334 [] T.timeout {
7335 setverdict(fail, "timout waiting for EMERGENCY SETUP!");
7336 }
7337 }
7338
7339 setverdict(pass);
7340}
7341
7342/* Test if the EMERGENCY SETUP gets blocked by the BSC if EMERGENCY CALLS are
7343 * forbidden by the BSC config. */
7344private function f_TC_assignment_emerg_setup_deny(charstring id) runs on MSC_ConnHdlr {
7345 var PDU_BSSAP emerg_setup_data_ind_bssap;
7346 timer T := 3.0;
7347
7348 f_assignment_emerg_setup()
7349
7350 T.start;
7351 alt {
7352 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
7353 setverdict(pass);
7354 }
7355 [] RSL.receive {
7356 setverdict(fail, "unexpected RSL message!");
7357 }
7358 [] T.timeout {
7359 setverdict(fail, "timout waiting for RR CHANNEL RELEASE!");
7360 }
7361 }
7362}
7363
7364/* EMERGENCY CALL situation #1, allowed globally and by BTS */
7365testcase TC_assignment_emerg_setup_allow() runs on test_CT {
7366 var TestHdlrParams pars := f_gen_test_hdlr_pars();
7367 var MSC_ConnHdlr vc_conn;
7368
7369 f_init(1, true);
7370 f_sleep(1.0);
7371
7372 f_vty_allow_emerg_msc(true);
7373 f_vty_allow_emerg_bts(true, 0);
7374 vc_conn := f_start_handler(refers(f_TC_assignment_emerg_setup_allow), pars);
7375 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007376 f_shutdown_helper();
Philipp Maier783681c2020-07-16 16:47:06 +02007377}
7378
7379/* EMERGENCY CALL situation #2, forbidden globally but allowed by BTS */
7380testcase TC_assignment_emerg_setup_deny_msc() runs on test_CT {
7381 var TestHdlrParams pars := f_gen_test_hdlr_pars();
7382 var MSC_ConnHdlr vc_conn;
7383
7384 f_init(1, true);
7385 f_sleep(1.0);
7386
7387 f_vty_allow_emerg_msc(false);
7388 f_vty_allow_emerg_bts(true, 0);
7389 vc_conn := f_start_handler(refers(f_TC_assignment_emerg_setup_deny), pars);
7390 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007391 f_shutdown_helper();
Philipp Maier783681c2020-07-16 16:47:06 +02007392}
7393
7394/* EMERGENCY CALL situation #3, allowed globally but forbidden by BTS */
7395testcase TC_assignment_emerg_setup_deny_bts() runs on test_CT {
7396 var TestHdlrParams pars := f_gen_test_hdlr_pars();
7397 var MSC_ConnHdlr vc_conn;
7398
7399 /* Note: This simulates a spec violation by the MS, correct MS
7400 * implementations would not try to establish an emergency call because
7401 * the system information tells in advance that emergency calls are
7402 * not forbidden */
7403
7404 f_init(1, true);
7405 f_sleep(1.0);
7406
7407 f_vty_allow_emerg_msc(true);
7408 f_vty_allow_emerg_bts(false, 0);
7409 vc_conn := f_start_handler(refers(f_TC_assignment_emerg_setup_deny), pars);
7410 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007411 f_shutdown_helper();
Philipp Maier783681c2020-07-16 16:47:06 +02007412}
7413
Philipp Maier82812002020-08-13 18:48:27 +02007414/* Test what happens when an emergency call arrives while all TCH channels are
7415 * busy, the BSC is expected to terminate one call in favor of the incoming
7416 * emergency call */
7417testcase TC_emerg_premption() runs on test_CT {
7418 var ASP_RSL_Unitdata rsl_ud;
7419 var integer i;
7420 var integer chreq_total, chreq_nochan;
7421 var RSL_Message rx_rsl;
7422 var RslChannelNr chan_nr;
7423
7424 f_init(1);
7425 f_sleep(1.0);
7426
7427 f_vty_allow_emerg_msc(true);
7428 f_vty_allow_emerg_bts(true, 0);
7429
7430 /* Fill up all channels on the BTS */
7431 chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total");
7432 chreq_nochan := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel");
7433 for (i := 0; i < NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS; i := i+1) {
7434 chan_nr := f_chreq_act_ack('33'O, i);
7435 }
7436 IPA_RSL[0].clear;
7437 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total",
7438 chreq_total + NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS);
7439
7440 /* Send Channel request for emegergency call */
7441 f_ipa_tx(0, ts_RSL_CHAN_RQD('A5'O, 23));
7442
7443 /* Expect the BSC to release one (the first) TCH/F on the BTS */
7444 chan_nr := valueof(t_RslChanNr_Bm(1));
7445 f_expect_chan_rel(0, chan_nr, expect_rr_chan_rel := false, expect_rll_rel_req := false);
7446
7447 /* Expect the BSC to send activate/assign the a channel for the emergency call */
7448 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7449 chan_nr := rx_rsl.ies[0].body.chan_nr;
7450 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 33));
7451 rx_rsl := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
Philipp Maier104f4c02020-09-11 18:12:18 +02007452
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007453 f_shutdown_helper();
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007454}
7455
7456/* Hopping parameters per a timeslot */
Vadim Yanitskiybc6654a2020-09-13 01:27:40 +07007457private type record length(0..64) of GsmArfcn ArfcnList;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007458private type record FHParamsTs {
7459 boolean enabled,
7460 uint6_t hsn,
7461 uint6_t maio,
7462 ArfcnList ma
7463};
7464
7465/* Hopping parameters per a transceiver */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007466private type record FHParamsTrx {
7467 GsmArfcn arfcn,
7468 FHParamsTs ts[8]
7469};
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007470
7471/* Randomly generate the hopping parameters for the given timeslot numbers */
7472private function f_TC_fh_params_gen(template integer tr_tn := (1, 3, 5))
7473runs on test_CT return FHParamsTrx {
7474 var FHParamsTrx fhp;
7475
Vadim Yanitskiy3e997362020-09-05 21:08:34 +07007476 /* Generate a random ARFCN, including ARFCN 0 */
7477 fhp.arfcn := f_rnd_int(3);
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007478
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007479 for (var integer tn := 0; tn < 8; tn := tn + 1) {
7480 if (not match(tn, tr_tn)) {
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007481 fhp.ts[tn].enabled := false;
7482 fhp.ts[tn].ma := { };
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007483 continue;
7484 }
7485
7486 /* Random HSN / MAIO values: 0..63 */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007487 fhp.ts[tn].hsn := f_rnd_int(64);
7488 fhp.ts[tn].maio := f_rnd_int(64);
7489 fhp.ts[tn].ma := { };
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007490
7491 /* Random Mobile Allocation (hopping channels) */
7492 var integer ma_len := 2 + f_rnd_int(9); /* 2..10 channels */
7493 var integer step := 3 + f_rnd_int(4); /* 3..6 stepping */
7494 for (var integer i := 1; i <= ma_len; i := i + 1) {
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007495 fhp.ts[tn].ma := fhp.ts[tn].ma & { i * step };
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007496 }
7497
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007498 fhp.ts[tn].enabled := true;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007499 }
7500
7501 log("f_TC_fh_params_gen(): ", fhp);
7502 return fhp;
7503}
7504
7505/* Make sure that the given Channel Description IE matches the hopping configuration */
7506private function f_TC_fh_params_match_chan_desc(in FHParamsTrx fhp, in ChannelDescription cd)
7507{
7508 var template (present) ChannelDescription tr_cd;
7509 var template (present) MaioHsn tr_maio_hsn;
7510 var uint3_t tn := cd.chan_nr.tn;
7511
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007512 if (fhp.ts[tn].enabled) {
7513 tr_maio_hsn := tr_HsnMaio(fhp.ts[tn].hsn, fhp.ts[tn].maio);
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007514 tr_cd := tr_ChanDescH1(cd.chan_nr, tr_maio_hsn);
7515 } else {
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007516 tr_cd := tr_ChanDescH0(cd.chan_nr, fhp.arfcn);
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007517 }
7518
7519 if (not match(cd, tr_cd)) {
7520 setverdict(fail, "Channel Description IE does not match: ",
7521 cd, " vs expected ", tr_cd);
7522 }
7523}
7524
7525/* Make sure that the given Mobile Allocation IE matches the hopping configuration */
7526private function f_TC_fh_params_match_ma(in FHParamsTrx fhp, uint3_t tn,
7527 in MobileAllocationLV ma)
7528{
7529 var template MobileAllocationLV tr_ma := f_TC_fh_params_gen_tr_ma(fhp, tn, ma);
7530
7531 if (not match(ma, tr_ma)) {
7532 setverdict(fail, "Mobile Allocation IE does not match (tn := ",
7533 tn, "): ", ma, " vs expected: ", tr_ma);
7534 } else {
7535 setverdict(pass);
7536 }
7537}
7538
7539private function f_TC_fh_params_gen_tr_ma(in FHParamsTrx fhp, uint3_t tn,
7540 in MobileAllocationLV ma)
7541return template MobileAllocationLV {
7542 /* Mobile Allocation IE is expected to be empty if hopping is not enabled */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007543 if (not fhp.ts[tn].enabled) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007544 return { len := 0, ma := ''B };
7545 }
7546
7547 var bitstring full_mask := f_pad_bit(''B, 1024, '0'B);
7548 var bitstring slot_mask := f_pad_bit(''B, 1024, '0'B);
7549 var bitstring ma_mask := ''B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007550
7551 /* Compose the full bit-mask (all channels, up to 1024 entries) */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007552 for (var integer i := 0; i < lengthof(fhp.ts); i := i + 1) {
7553 for (var integer j := 0; j < lengthof(fhp.ts[i].ma); j := j + 1) {
7554 if (full_mask[fhp.ts[i].ma[j]] == '1'B)
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007555 { continue; }
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007556 full_mask[fhp.ts[i].ma[j]] := '1'B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007557 }
7558 }
7559
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007560 /* Take ARFCN of the TRX itself into account */
7561 full_mask[fhp.arfcn] := '1'B;
7562
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007563 /* Compose a bit-mask for the given timeslot number */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007564 for (var integer i := 0; i < lengthof(fhp.ts[tn].ma); i := i + 1) {
7565 slot_mask[fhp.ts[tn].ma[i]] := '1'B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007566 }
7567
7568 /* Finally, compose the Mobile Allocation bit-mask */
Vadim Yanitskiy3e997362020-09-05 21:08:34 +07007569 for (var integer i := 1; i < lengthof(full_mask); i := i + 1) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007570 if (full_mask[i] != '1'B)
7571 { continue; }
7572
7573 /* FIXME: ma_mask := ma_mask & slot_mask[i]; // triggers a bug in TITAN */
7574 if (slot_mask[i] == '1'B) {
7575 ma_mask := ma_mask & '1'B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007576 } else {
7577 ma_mask := ma_mask & '0'B;
7578 }
7579 }
7580
Vadim Yanitskiy3e997362020-09-05 21:08:34 +07007581 /* ARFCN 0 (if present) goes to the last position of the bit-mask */
7582 if (full_mask[0] == '1'B) {
7583 /* FIXME: ma_mask := ma_mask & slot_mask[0]; // triggers a bug in TITAN */
7584 if (slot_mask[0] == '1'B) {
7585 ma_mask := ma_mask & '1'B;
7586 } else {
7587 ma_mask := ma_mask & '0'B;
7588 }
7589 }
7590
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007591 /* Ensure that ma_mask is octet-aligned */
Vadim Yanitskiy2aa02522020-09-06 14:05:23 +07007592 var integer ma_mask_len := (lengthof(ma_mask) + 8 - 1) / 8;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007593 ma_mask := f_pad_bit(ma_mask, ma_mask_len * 8, '0'B);
7594
7595 return { len := ma_mask_len, ma := ma_mask };
7596}
7597
7598/* Configure the hopping parameters in accordance with the given record */
7599private function f_TC_fh_params_set(in FHParamsTrx fhp,
7600 uint8_t bts_nr := 0,
7601 uint8_t trx_nr := 0)
7602runs on test_CT {
7603 /* Enter the configuration node for the given BTS/TRX numbers */
7604 f_vty_enter_cfg_trx(BSCVTY, bts_nr, trx_nr);
7605
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007606 f_vty_transceive(BSCVTY, "arfcn " & int2str(fhp.arfcn));
7607
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007608 for (var integer tn := 0; tn < lengthof(fhp.ts); tn := tn + 1) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007609 f_vty_transceive(BSCVTY, "timeslot " & int2str(tn));
7610
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007611 if (not fhp.ts[tn].enabled) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007612 f_vty_transceive(BSCVTY, "hopping enabled 0");
7613 f_vty_transceive(BSCVTY, "exit"); /* go back */
7614 continue;
7615 }
7616
7617 /* Configure HSN / MAIO values */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007618 f_vty_transceive(BSCVTY, "hopping sequence-number " & int2str(fhp.ts[tn].hsn));
7619 f_vty_transceive(BSCVTY, "hopping maio " & int2str(fhp.ts[tn].maio));
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007620
7621 /* Configure the Mobile Allocation (hopping channels) */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007622 for (var integer i := 0; i < lengthof(fhp.ts[tn].ma); i := i + 1) {
7623 f_vty_transceive(BSCVTY, "hopping arfcn add " & int2str(fhp.ts[tn].ma[i]));
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007624 }
7625
7626 f_vty_transceive(BSCVTY, "hopping enabled 1");
7627 f_vty_transceive(BSCVTY, "exit"); /* go back */
7628 }
7629
7630 f_vty_transceive(BSCVTY, "end");
7631}
7632
7633/* Disable frequency hopping on all timeslots */
7634private function f_TC_fh_params_unset(in FHParamsTrx fhp,
7635 uint8_t bts_nr := 0,
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007636 uint8_t trx_nr := 0,
7637 GsmArfcn arfcn := 871)
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007638runs on test_CT {
7639 /* Enter the configuration node for the given BTS/TRX numbers */
7640 f_vty_enter_cfg_trx(BSCVTY, bts_nr, trx_nr);
7641
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007642 f_vty_transceive(BSCVTY, "arfcn " & int2str(arfcn));
7643
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007644 for (var integer tn := 0; tn < lengthof(fhp.ts); tn := tn + 1) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007645 f_vty_transceive(BSCVTY, "timeslot " & int2str(tn));
7646
7647 /* Delete all ARFCNs from the Mobile Allocation (if any) */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007648 for (var integer i := 0; i < lengthof(fhp.ts[tn].ma); i := i + 1) {
7649 f_vty_transceive(BSCVTY, "hopping arfcn del " & int2str(fhp.ts[tn].ma[i]));
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007650 }
7651
7652 f_vty_transceive(BSCVTY, "hopping enabled 0");
7653 f_vty_transceive(BSCVTY, "exit"); /* go back */
7654 }
7655
7656 f_vty_transceive(BSCVTY, "end");
7657 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7658}
7659
7660/* Verify presence and correctness of the hopping parameters (HSN, MAIO)
7661 * in the Channel Identification IE of the RSL CHANnel ACTIVation message. */
7662testcase TC_fh_params_chan_activ() runs on test_CT {
7663 var FHParamsTrx fhp := f_TC_fh_params_gen();
7664 var RSL_Message rsl_msg;
7665 var RSL_IE_Body ie;
7666
7667 f_init_vty();
7668
7669 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
7670 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7671
7672 f_init(1);
7673
7674 /* CS domain: 3 (SDCCH/4+CBCH) + 4 (TCH/F) + 2 (TCH/H) channels available */
7675 for (var integer i := 0; i < 9; i := i + 1) {
7676 f_ipa_tx(0, ts_RSL_CHAN_RQD(f_rnd_ra_cs(), 23));
7677 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7678
7679 /* Make sure that Channel Identification IE is present */
7680 if (not f_rsl_find_ie(rsl_msg, RSL_IE_CHAN_IDENT, ie)) {
7681 setverdict(fail, "RSL Channel Identification IE is absent");
7682 continue;
7683 }
7684
7685 /* Make sure that hopping parameters (HSN/MAIO) match */
7686 f_TC_fh_params_match_chan_desc(fhp, ie.chan_ident.ch_desc.v);
7687
7688 /* "Mobile Allocation shall be included but empty" - let's check this */
7689 if (ie.chan_ident.ma.v.len != 0) {
7690 setverdict(fail, "Mobile Allocation IE is not empty: ",
7691 ie.chan_ident.ma, ", despite it shall be");
7692 continue;
7693 }
7694 }
7695
7696 /* Disable frequency hopping */
7697 f_TC_fh_params_unset(fhp);
7698
Vadim Yanitskiy21726312020-09-04 01:45:36 +07007699 f_shutdown_helper();
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007700}
7701
7702/* Verify the hopping parameters (HSN, MAIO, MA) in (RR) Immediate Assignment */
7703testcase TC_fh_params_imm_ass() runs on test_CT {
7704 var FHParamsTrx fhp := f_TC_fh_params_gen();
7705 var RSL_Message rsl_msg;
7706 var RSL_IE_Body ie;
7707
7708 f_init_vty();
7709
7710 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
7711 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7712
7713 f_init(1);
7714
7715 /* CS domain: 3 (SDCCH/4+CBCH) + 4 (TCH/F) + 2 (TCH/H) channels available */
7716 for (var integer i := 0; i < 9; i := i + 1) {
7717 f_ipa_tx(0, ts_RSL_CHAN_RQD(f_rnd_ra_cs(), 23));
7718 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7719
7720 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(rsl_msg.ies[0].body.chan_nr, 33));
7721 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeC(RSL_MT_IMMEDIATE_ASSIGN_CMD));
7722
7723 /* Make sure that Full Immediate Assign Info IE is present */
7724 if (not f_rsl_find_ie(rsl_msg, RSL_IE_FULL_IMM_ASS_INFO, ie)) {
7725 setverdict(fail, "RSL Full Immediate Assign Info IE is absent");
7726 continue;
7727 }
7728
7729 /* Decode the actual Immediate Assignment message */
7730 var GsmRrMessage rr_msg := dec_GsmRrMessage(ie.full_imm_ass_info.payload);
7731 if (not match(rr_msg.header, t_RrHeader(IMMEDIATE_ASSIGNMENT, ?))) {
7732 setverdict(fail, "Failed to match Immediate Assignment: ", rr_msg);
7733 continue;
7734 }
7735
7736 /* Make sure that hopping parameters (HSN/MAIO) match */
7737 f_TC_fh_params_match_chan_desc(fhp, rr_msg.payload.imm_ass.chan_desc);
7738
7739 /* Make sure that the Mobile Allocation IE matches */
7740 f_TC_fh_params_match_ma(fhp, rr_msg.payload.imm_ass.chan_desc.chan_nr.tn,
7741 rr_msg.payload.imm_ass.mobile_allocation);
7742 }
7743
7744 /* Disable frequency hopping */
7745 f_TC_fh_params_unset(fhp);
Philipp Maier82812002020-08-13 18:48:27 +02007746
Vadim Yanitskiy21726312020-09-04 01:45:36 +07007747 f_shutdown_helper();
Philipp Maier82812002020-08-13 18:48:27 +02007748}
7749
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07007750/* Verify the hopping parameters (HSN, MAIO, MA) in (RR) Assignment Command */
7751testcase TC_fh_params_assignment_cmd() runs on test_CT {
7752 var FHParamsTrx fhp := f_TC_fh_params_gen();
7753 var RSL_Message rsl_msg;
7754 var RSL_IE_Body ie;
7755
7756 f_init_vty();
7757
7758 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
7759 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7760
7761 f_init(1);
7762
7763 /* HACK: work around "Couldn't find Expect for CRCX" */
7764 vc_MGCP.stop;
7765
7766 var template PDU_BSSAP ass_cmd := f_gen_ass_req();
7767 ass_cmd.pdu.bssmap.assignmentRequest.codecList := ts_BSSMAP_IE_CodecList({ts_CodecFR});
7768
7769 /* CS domain (TCH): 4 (TCH/F) + 2 (TCH/H) channels available
7770 * NOTE: only 3 SDCCH/4 channels are available on CCCH+SDCCH4+CBCH */
7771 for (var integer i := 0; i < 3; i := i + 1) {
7772 /* Establish a dedicated channel, so we can trigger (late) TCH assignment */
7773 var DchanTuple dt := f_est_dchan(f_rnd_ra_cs(), 23, f_rnd_octstring(16));
7774
7775 /* Send a BSSMAP Assignment Command, expect CHANnel ACTIVation */
7776 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ass_cmd));
7777 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7778
7779 /* ACKnowledge CHANnel ACTIVation, expect RSL DATA REQuest */
7780 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(rsl_msg.ies[0].body.chan_nr, 33));
7781 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeR(RSL_MT_DATA_REQ));
7782
7783 /* Make sure that L3 Information IE is present */
7784 if (not f_rsl_find_ie(rsl_msg, RSL_IE_L3_INFO, ie)) {
7785 setverdict(fail, "RSL L3 Information IE is absent");
7786 continue;
7787 }
7788
7789 /* Decode the L3 message and make sure it is (RR) Assignment Command */
7790 var GsmRrL3Message l3_msg := dec_GsmRrL3Message(ie.l3_info.payload);
7791 if (not match(l3_msg.header, t_RrL3Header(ASSIGNMENT_COMMAND))) {
7792 setverdict(fail, "Failed to match Assignment Command: ", l3_msg);
7793 continue;
7794 }
7795
7796 /* Make sure that hopping parameters (HSN/MAIO) match */
7797 var ChannelDescription chan_desc := l3_msg.payload.ass_cmd.chan_desc;
7798 f_TC_fh_params_match_chan_desc(fhp, chan_desc);
7799
7800 /* Make sure that Cell Channel Description IE is present if FH is enabled */
7801 if (chan_desc.h and not ispresent(l3_msg.payload.ass_cmd.cell_chan_desc)) {
Vadim Yanitskiy38d069d2020-09-02 17:18:57 +07007802 setverdict(fail, "FH enabled, but Cell Channel Description IE is absent");
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07007803 continue;
7804 }
7805
7806 /* Make sure that the Mobile Allocation IE matches (if present) */
7807 var boolean ma_present := ispresent(l3_msg.payload.ass_cmd.mobile_allocation);
7808 if (chan_desc.h and ma_present) {
7809 f_TC_fh_params_match_ma(fhp, chan_desc.chan_nr.tn,
7810 l3_msg.payload.ass_cmd.mobile_allocation.v);
7811 } else if (chan_desc.h and not ma_present) {
7812 setverdict(fail, "FH enabled, but Mobile Allocation IE is absent");
7813 continue;
7814 } else if (not chan_desc.h and ma_present) {
7815 setverdict(fail, "FH disabled, but Mobile Allocation IE is present");
7816 continue;
7817 }
7818 }
7819
7820 /* Give the IUT some time to release all channels */
7821 f_sleep(3.0);
7822
7823 /* Disable frequency hopping */
7824 f_TC_fh_params_unset(fhp);
7825
Vadim Yanitskiy21726312020-09-04 01:45:36 +07007826 f_shutdown_helper();
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07007827}
7828
Vadim Yanitskiy8f5430d2020-09-02 18:51:38 +07007829/* Verify the hopping parameters (HSN, MAIO, MA) in (RR) Handover Command */
7830private function f_TC_fh_params_handover_cmd(in FHParamsTrx fhp)
7831runs on test_CT {
7832 var RSL_Message rsl_msg;
7833 var RSL_IE_Body ie;
7834 var DchanTuple dt;
7835
7836 /* Establish a dedicated channel, so we can trigger handover */
7837 dt := f_est_dchan(f_rnd_ra_cs(), 23, f_rnd_octstring(16));
7838
7839 /* Trigger handover from BTS0 to BTS1 */
7840 f_bts_0_cfg(BSCVTY, { "neighbor bts 1" });
7841 f_vty_handover(BSCVTY, 0, 0, dt.rsl_chan_nr, 1);
7842
7843 /* Expect RSL CHANnel ACTIVation on BTS1/TRX0/TS1 */
7844 rsl_msg := f_exp_ipa_rx(1, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7845
7846 /* ACKnowledge channel activation and expect (RR) Handover Command */
7847 f_ipa_tx(1, ts_RSL_CHAN_ACT_ACK(rsl_msg.ies[0].body.chan_nr, 33));
7848 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeR(RSL_MT_DATA_REQ));
7849
7850 /* Make sure that L3 Information IE is present */
7851 if (not f_rsl_find_ie(rsl_msg, RSL_IE_L3_INFO, ie)) {
7852 setverdict(fail, "RSL L3 Information IE is absent");
7853 return;
7854 }
7855
7856 /* Decode the L3 message and make sure it is (RR) Handover Command */
7857 var GsmRrL3Message l3_msg := dec_GsmRrL3Message(ie.l3_info.payload);
7858 if (not match(l3_msg.header, t_RrL3Header(HANDOVER_COMMAND))) {
7859 setverdict(fail, "Failed to match Handover Command: ", l3_msg);
7860 return;
7861 }
7862
7863 /* Make sure that we've got SDCCH/8 on TS1 (expected to be hopping) */
7864 var ChannelDescription chan_desc := l3_msg.payload.ho_cmd.chan_desc;
7865 if (not match(chan_desc.chan_nr, t_RslChanNr_SDCCH8(1, ?))) {
7866 setverdict(fail, "Unexpected channel number: ", chan_desc.chan_nr);
7867 return;
7868 }
7869
7870 /* Make sure that hopping parameters (HSN/MAIO) match */
7871 f_TC_fh_params_match_chan_desc(fhp, chan_desc);
7872
7873 /* Make sure that Cell Channel Description IE is present */
7874 if (not ispresent(l3_msg.payload.ho_cmd.cell_chan_desc)) {
7875 setverdict(fail, "FH enabled, but Cell Channel Description IE is absent");
7876 return;
7877 }
7878
7879 /* Make sure that the Mobile Allocation (after time) IE is present and matches */
7880 var boolean ma_present := ispresent(l3_msg.payload.ho_cmd.mobile_allocation);
7881 if (ma_present) {
7882 f_TC_fh_params_match_ma(fhp, chan_desc.chan_nr.tn,
7883 l3_msg.payload.ho_cmd.mobile_allocation.v);
7884 } else {
7885 setverdict(fail, "FH enabled, but Mobile Allocation IE is absent");
7886 return;
7887 }
7888}
7889testcase TC_fh_params_handover_cmd() runs on test_CT {
7890 var FHParamsTrx fhp := f_TC_fh_params_gen();
7891
7892 f_init_vty();
7893
7894 /* (Re)configure TS0 as BCCH and TS1 as SDCCH8 on BTS1/TRX0 */
7895 f_vty_enter_cfg_trx(BSCVTY, bts := 1, trx := 0);
7896
7897 f_vty_transceive(BSCVTY, "timeslot 0");
7898 f_vty_transceive(BSCVTY, "phys_chan_config ccch");
7899 f_vty_transceive(BSCVTY, "exit"); /* go back */
7900
7901 f_vty_transceive(BSCVTY, "timeslot 1");
7902 f_vty_transceive(BSCVTY, "phys_chan_config sdcch8");
7903 f_vty_transceive(BSCVTY, "end"); /* we're done */
7904
7905 f_TC_fh_params_set(fhp, 1); /* Enable frequency hopping on BTS1 */
7906 f_vty_transceive(BSCVTY, "drop bts connection 1 oml");
7907
7908 f_init(2);
7909
7910 f_TC_fh_params_handover_cmd(fhp);
7911
7912 /* Disable frequency hopping on BTS1 */
7913 f_TC_fh_params_unset(fhp, 1);
7914
7915 /* (Re)configure TS0 as CCCH+SDCCH4+CBCH and TS1 as TCH/F */
7916 f_vty_enter_cfg_trx(BSCVTY, bts := 1, trx := 0);
7917
7918 f_vty_transceive(BSCVTY, "timeslot 0");
7919 f_vty_transceive(BSCVTY, "phys_chan_config ccch+sdcch4+cbch");
7920 f_vty_transceive(BSCVTY, "exit"); /* go back */
7921
7922 f_vty_transceive(BSCVTY, "timeslot 1");
7923 f_vty_transceive(BSCVTY, "phys_chan_config tch/f");
7924 f_vty_transceive(BSCVTY, "end"); /* we're done */
7925
7926 f_shutdown_helper();
7927}
7928
Vadim Yanitskiyca974032020-09-01 07:20:39 +07007929/* Verify the hopping parameters in System Information Type 4 */
7930testcase TC_fh_params_si4_cbch() runs on test_CT {
7931 var FHParamsTrx fhp := f_TC_fh_params_gen(tr_tn := 1);
7932 var ASP_RSL_Unitdata rx_rsl_ud;
7933 timer T := 5.0;
7934
7935 f_init_vty();
7936
7937 /* (Re)configure TS0 as BCCH and TS1 as SDCCH8+CBCH */
7938 f_vty_enter_cfg_trx(BSCVTY, trx := 0);
7939
7940 f_vty_transceive(BSCVTY, "timeslot 0");
7941 f_vty_transceive(BSCVTY, "phys_chan_config ccch");
7942 f_vty_transceive(BSCVTY, "exit"); /* go back */
7943
7944 f_vty_transceive(BSCVTY, "timeslot 1");
7945 f_vty_transceive(BSCVTY, "phys_chan_config sdcch8+cbch");
7946 f_vty_transceive(BSCVTY, "end"); /* we're done */
7947
7948 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
7949 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7950
7951 f_init(1);
7952
7953 T.start;
7954 alt {
7955 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_BCCH_INFO(RSL_SYSTEM_INFO_4))) -> value rx_rsl_ud {
7956 var RSL_IE_Body ie := rx_rsl_ud.rsl.ies[2].body; /* FULL BCCH Information IE */
7957 var SystemInformation si := dec_SystemInformation(ie.other.payload);
7958
7959 /* Make sure that what we decoded is System Information Type 4 */
7960 if (si.header.message_type != SYSTEM_INFORMATION_TYPE_4) {
7961 setverdict(fail, "RSL FULL BCCH Information IE contains: ", si);
7962 repeat;
7963 }
7964
7965 /* Make sure that CBCH Channel Description IE is present */
7966 if (not ispresent(si.payload.si4.cbch_chan_desc)) {
7967 setverdict(fail, "CBCH Channel Description IE is absent");
7968 break;
7969 }
7970
7971 /* Finally, check the hopping parameters (HSN, MAIO) */
7972 var ChannelDescription chan_desc := si.payload.si4.cbch_chan_desc.v;
7973 f_TC_fh_params_match_chan_desc(fhp, chan_desc);
7974
7975 /* 3GPP TS 44.018, section 9.1.36.2 "CBCH Mobile Allocation":
7976 * The CBCH Mobile Allocation IE *shall* be present if FH is enabled. */
7977 if (chan_desc.h and not ispresent(si.payload.si4.cbch_mobile_alloc)) {
7978 setverdict(fail, "FH enabled, but Mobile Allocation IE is absent");
7979 break;
7980 } else if (chan_desc.h and ispresent(si.payload.si4.cbch_mobile_alloc)) {
7981 f_TC_fh_params_match_ma(fhp, chan_desc.chan_nr.tn,
7982 si.payload.si4.cbch_mobile_alloc.v);
7983 }
7984 }
7985 [] IPA_RSL[0].receive { repeat; }
7986 [] T.timeout {
7987 setverdict(fail, "Timeout waiting for RSL BCCH INFOrmation (SI4)");
7988 }
7989 }
7990
7991 /* Disable frequency hopping */
7992 f_TC_fh_params_unset(fhp);
7993
Vadim Yanitskiy8bc46012020-09-06 12:38:01 +07007994 /* (Re)configure TS0 as CCCH+SDCCH4+CBCH and TS1 as TCH/F */
Vadim Yanitskiyca974032020-09-01 07:20:39 +07007995 f_vty_enter_cfg_trx(BSCVTY, trx := 0);
7996
7997 f_vty_transceive(BSCVTY, "timeslot 0");
Vadim Yanitskiy8bc46012020-09-06 12:38:01 +07007998 f_vty_transceive(BSCVTY, "phys_chan_config ccch+sdcch4+cbch");
Vadim Yanitskiyca974032020-09-01 07:20:39 +07007999 f_vty_transceive(BSCVTY, "exit"); /* go back */
8000
8001 f_vty_transceive(BSCVTY, "timeslot 1");
8002 f_vty_transceive(BSCVTY, "phys_chan_config tch/f");
8003 f_vty_transceive(BSCVTY, "end"); /* we're done */
8004
Vadim Yanitskiy21726312020-09-04 01:45:36 +07008005 f_shutdown_helper();
Vadim Yanitskiyca974032020-09-01 07:20:39 +07008006}
8007
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008008template (value) PDU_BSSAP_LE ts_BSSMAP_LE_BSSLAP(template (value) BSSLAP_PDU bsslap)
8009 := ts_BSSMAP_LE_ConnInfo(BSSMAP_LE_PROT_BSSLAP, data := enc_BSSLAP_PDU(valueof(bsslap)));
8010
8011private function f_match_bsslap(PDU_BSSAP_LE got_bsslap_msg,
8012 template (present) BSSLAP_PDU expect_bsslap)
8013{
8014 var BSSLAP_PDU bsslap := dec_BSSLAP_PDU(got_bsslap_msg.pdu.bssmap.co_info.bsslap_apdu.data);
8015 if (not match(bsslap, expect_bsslap)) {
8016 log("EXPECTING BSSLAP: ", expect_bsslap);
8017 log("GOT BSSLAP: ", bsslap);
8018 setverdict(fail, "BSSLAP is not as expected");
8019 mtc.stop;
8020 }
8021 setverdict(pass);
8022}
8023
8024/* GAD: this is an Ellipsoid point with uncertainty circle, encoded as in 3GPP TS 23.032 §7.3.2. */
8025const octetstring gad_ell_point_unc_circle := '10b0646d0d5f6627'O;
8026
8027private function f_expect_bsslap(template (present) BSSLAP_PDU expect_rx_bsslap) runs on MSC_ConnHdlr {
8028 var PDU_BSSAP_LE rx_bsslap;
8029 BSSAP_LE.receive(tr_BSSMAP_LE_ConnInfo(BSSMAP_LE_PROT_BSSLAP, ?)) -> value(rx_bsslap);
8030 f_match_bsslap(rx_bsslap, expect_rx_bsslap);
8031}
8032
8033/* With an active lchan, start BSSMAP Perform Location Request on A interface, starting BSSMAP-LE Perform Location
8034 * Request on Lb interface. Either with or without the SMLC doing a BSSLAP TA Request. */
8035private function f_lcs_loc_req_for_active_ms(boolean do_ta_request := false) runs on MSC_ConnHdlr {
8036 f_sleep(1.0);
8037
8038 f_establish_fully(omit, omit);
8039 f_bssap_le_register_imsi(g_pars.imsi, omit);
8040
8041 BSSAP.send(valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
8042 ts_CellId_CGI('262'H, '42'H, 23, 42))));
8043
8044 var PDU_BSSAP_LE plr;
8045 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
8046
8047 if (not do_ta_request) {
8048 /* verify TA Layer 3 in APDU. First the APDU type (BSSLAP), then the BSSLAP data contents. */
8049 var template BSSMAP_LE_IE_APDU expect_apdu := tr_BSSMAP_LE_APDU(BSSMAP_LE_PROT_BSSLAP, ?);
8050 if (not match(plr.pdu.bssmap.perf_loc_req.bsslap_apdu, expect_apdu)) {
8051 log("EXPECTING BSSMAP-LE APDU IE ", expect_apdu);
8052 log("GOT BSSMAP-LE APDU IE ", plr.pdu.bssmap.perf_loc_req.bsslap_apdu);
8053 setverdict(fail, "BSSMAP-LE APDU IE is not as expected");
8054 mtc.stop;
8055 }
8056 var template BSSLAP_PDU expect_ta_layer3 := tr_BSSLAP_TA_Layer3(tr_BSSLAP_IE_TA(0));
8057 var BSSLAP_PDU bsslap := dec_BSSLAP_PDU(plr.pdu.bssmap.perf_loc_req.bsslap_apdu.data);
8058 if (not match(bsslap, expect_ta_layer3)) {
8059 log("EXPECTING BSSLAP TA Layer 3: ", expect_ta_layer3);
8060 log("GOT BSSLAP: ", bsslap);
8061 setverdict(fail, "BSSLAP is not as expected");
8062 mtc.stop;
8063 }
8064 /* OsmoBSC directly sent the TA as BSSLAP APDU in the BSSMAP-LE Perform Location Request to the SMLC. The SMLC
8065 * has no need to request the TA from the BSC and directly responds. */
8066 } else {
8067 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
8068 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
8069 f_expect_bsslap(tr_BSSLAP_TA_Resp(?, ?));
8070 }
8071
8072 /* SMLC got the TA from the BSC, now responds with geo information data. */
8073 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(gad_ell_point_unc_circle, omit));
8074 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
8075 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(tr_BSSMAP_IE_LocationEstimate(gad_ell_point_unc_circle)));
8076
8077 /* The LCS was using an active A-interface conn. It should still remain active after this. */
8078 f_mo_l3_transceive();
8079
8080 f_perform_clear(RSL);
8081
8082 f_sleep(2.0);
8083 setverdict(pass);
8084}
8085
8086/* With an active lchan, start BSSMAP Perform Location Request on A interface, starting BSSMAP-LE Perform Location
8087 * Request on Lb interface. Without the SMLC doing a BSSLAP TA Request. */
8088private function f_tc_lcs_loc_req_for_active_ms(charstring id) runs on MSC_ConnHdlr {
8089 f_lcs_loc_req_for_active_ms(false);
8090}
8091testcase TC_lcs_loc_req_for_active_ms() runs on test_CT {
8092 var MSC_ConnHdlr vc_conn;
8093 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8094
8095 f_init(1, true);
8096 f_sleep(1.0);
8097 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_active_ms), pars);
8098 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008099 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008100}
8101
8102/* With an active lchan, start BSSMAP Perform Location Request on A interface, starting BSSMAP-LE Perform Location
8103 * Request on Lb interface. With the SMLC doing a BSSLAP TA Request. */
8104private function f_tc_lcs_loc_req_for_active_ms_ta_req(charstring id) runs on MSC_ConnHdlr {
8105 f_lcs_loc_req_for_active_ms(true);
8106}
8107testcase TC_lcs_loc_req_for_active_ms_ta_req() runs on test_CT {
8108 var MSC_ConnHdlr vc_conn;
8109 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8110
8111 f_init(1, true);
8112 f_sleep(1.0);
8113 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_active_ms_ta_req), pars);
8114 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008115 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008116}
8117
8118/* Clear the A-interface conn only, without doing anything on Abis. Useful for LCS, for cases where there is only an A
8119 * conn without an active lchan. */
8120private function f_clear_A_conn() runs on MSC_ConnHdlr
8121{
8122 var BssmapCause cause := 0;
8123 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
8124 BSSAP.receive(tr_BSSMAP_ClearComplete);
8125 BSSAP.send(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_REQ);
8126
8127 timer no_more_bssap := 5.0;
8128 no_more_bssap.start;
8129 alt {
8130 [] no_more_bssap.timeout { break; }
8131 [] BSSAP.receive(tr_BSSAP_BSSMAP) {
8132 setverdict(fail, "Expected no more BSSAP after Clear Complete");
8133 mtc.stop;
8134 }
8135 }
8136 setverdict(pass);
8137}
8138
8139/* Verify that the A-interface connection is still working, and then clear it, without doing anything on Abis. Useful
8140 * for LCS, for cases where there is only an A conn without an active lchan. */
8141private function f_verify_active_A_conn_and_clear() runs on MSC_ConnHdlr
8142{
8143 f_logp(BSCVTY, "f_verify_active_A_conn_and_clear: test A link, then clear");
8144
8145 /* When an lchan is active, we can send some L3 data from the BTS side and verify that it shows up on the other
8146 * side towards the MSC. When there is no lchan, this is not possible. To probe whether the A-interface
8147 * connection is still up, we need something that echos back on the A-interface. Another LCS request! */
8148 BSSAP.send(valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
8149 ts_CellId_CGI('262'H, '42'H, 23, 42))));
8150 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?));
8151
8152 /* Right, the Perform Location Request showed up on Lb, now we can clear the A conn. */
8153 f_clear_A_conn();
8154 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocAbort(BSSMAP_LE_LCS_CAUSE_REQUEST_ABORTED));
8155 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
8156}
8157
8158/* With *no* active lchan, start BSSMAP Perform Location Request on A interface, starting BSSMAP-LE Perform Location
8159 * Request on Lb interface. BSC will Page for the subscriber as soon as we (virtual SMLC) request the TA via BSSLAP.
8160 */
8161private function f_tc_lcs_loc_req_for_idle_ms(charstring id) runs on MSC_ConnHdlr {
8162 f_sleep(1.0);
8163
8164 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
8165 f_bssap_le_register_imsi(g_pars.imsi, omit);
8166
8167 /* Register to receive the Paging Command */
8168 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
8169 g_chan_nr := new_chan_nr;
8170 f_rslem_register(0, g_chan_nr);
8171
8172 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
8173 valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
8174 ts_CellId_CGI('001'H, '01'H, 1, 0)))));
8175 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
8176
8177 var PDU_BSSAP_LE plr;
8178 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
8179
8180 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
8181 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
8182
8183 /* OsmoBSC needs to Page */
8184 RSL.receive(tr_RSL_PAGING_CMD(tr_MI_IMSI(g_pars.imsi)));
8185 f_logp(BSCVTY, "got Paging Command");
8186
8187 /* MS requests channel. Since the Paging was for LCS, the Paging Response does not trigger a Complete Layer 3 to
8188 * the MSC, and releases the lchan directly. */
8189 f_perform_compl_l3(RSL, ts_PAG_RESP(valueof(ts_MI_IMSI_LV(g_pars.imsi))), do_clear := false, expect_bssmap_l3 := false);
8190 f_expect_lchan_rel(RSL);
8191
8192 /* From the Paging Response, the TA is now known to the BSC, and it responds to the SMLC. */
8193
8194 f_expect_bsslap(tr_BSSLAP_TA_Resp(?, ?));
8195
8196 /* SMLC got the TA from the BSC, now responds with geo information data. */
8197 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(gad_ell_point_unc_circle, omit));
8198 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
8199
8200 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(tr_BSSMAP_IE_LocationEstimate(gad_ell_point_unc_circle)));
8201
8202 /* The lchan is gone, the A-interface conn was created for the LCS only.
8203 * Still it is clearly the MSC's job to decide whether to tear down the conn or not. */
8204 f_verify_active_A_conn_and_clear();
8205
8206 f_sleep(2.0);
8207 setverdict(pass);
8208}
8209testcase TC_lcs_loc_req_for_idle_ms() runs on test_CT {
8210 var MSC_ConnHdlr vc_conn;
8211 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8212
8213 f_init(1, true);
8214 f_sleep(1.0);
8215
8216 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
8217 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
8218
8219 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_idle_ms), pars);
8220 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008221 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008222}
8223
8224/* With no active lchan, start BSSMAP Perform Location Request on A interface, but omit IMSI; expect failure response.
8225 */
8226private function f_tc_lcs_loc_req_no_subscriber(charstring id) runs on MSC_ConnHdlr {
8227 f_sleep(1.0);
8228
8229 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
8230 f_bssap_le_register_imsi(g_pars.imsi, omit);
8231
8232 /* provoke an abort by omitting both IMSI and IMEI */
8233 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
8234 valueof(ts_BSSMAP_Perform_Location_Request(omit,
8235 ts_CellId_CGI('262'H, '42'H, 23, 42)))));
8236 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
8237
8238 /* BSC tells MSC about failure */
8239 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(
8240 locationEstimate := omit, positioningData := omit,
8241 lCS_Cause := tr_BSSMAP_LcsCause(BSSMAP_LCS_CAUSE_DATA_MISSING_IN_REQ)));
8242
8243 /* There is no lchan. Still the MSC's job to decide whether to tear down the conn or not. */
8244 f_verify_active_A_conn_and_clear();
8245
8246 f_sleep(2.0);
8247 setverdict(pass);
8248}
8249testcase TC_lcs_loc_req_no_subscriber() runs on test_CT {
8250 var MSC_ConnHdlr vc_conn;
8251 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8252
8253 f_init(1, true);
8254 f_sleep(1.0);
8255
8256 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
8257 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
8258
8259 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_no_subscriber), pars);
8260 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008261 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008262}
8263
8264/* With an active lchan, start a Perform Location Request on the A-interface, but virtual SMLC does not answer with
8265 * BSSMAP-LE Perform Location Response (before or after sending a BSSLAP TA Request) */
8266private function f_lcs_loc_req_for_active_ms_le_timeout(boolean do_ta) runs on MSC_ConnHdlr {
8267 f_sleep(1.0);
8268
8269 f_establish_fully(omit, omit);
8270 f_bssap_le_register_imsi(g_pars.imsi, omit);
8271
8272 BSSAP.send(valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
8273 ts_CellId_CGI('262'H, '42'H, 23, 42))));
8274
8275 var PDU_BSSAP_LE plr;
8276 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
8277
8278 if (do_ta) {
8279 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
8280 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
8281 f_expect_bsslap(tr_BSSLAP_TA_Resp(?, ?));
8282 }
8283
8284 /* SMLC fails to respond, BSC runs into timeout */
8285 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocAbort(BSSMAP_LE_LCS_CAUSE_SYSTEM_FAILURE));
8286 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
8287
8288 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(
8289 locationEstimate := omit, positioningData := omit,
8290 lCS_Cause := tr_BSSMAP_LcsCause(BSSMAP_LCS_CAUSE_SYSTEM_FAILURE)));
8291
8292 /* There is no lchan. Still the MSC's job to decide whether to tear down the conn or not. */
8293 f_verify_active_A_conn_and_clear();
8294
8295 f_sleep(2.0);
8296 setverdict(pass);
8297}
8298
8299/* With an active lchan, start a Perform Location Request on the A-interface, but virtual SMLC does not answer with
8300 * BSSMAP-LE Perform Location Response, without sending a BSSLAP TA Request. */
8301private function f_tc_lcs_loc_req_for_active_ms_le_timeout(charstring id) runs on MSC_ConnHdlr {
8302 f_lcs_loc_req_for_active_ms_le_timeout(false);
8303}
8304
8305testcase TC_lcs_loc_req_for_active_ms_le_timeout() runs on test_CT {
8306 var MSC_ConnHdlr vc_conn;
8307 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8308
8309 f_init(1, true);
8310 f_sleep(1.0);
8311 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_active_ms_le_timeout), pars);
8312 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008313 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008314}
8315
8316/* With an active lchan, start a Perform Location Request on the A-interface, but virtual SMLC does not answer with
8317 * BSSMAP-LE Perform Location Response, after sending a BSSLAP TA Request. */
8318private function f_tc_lcs_loc_req_for_active_ms_le_timeout2(charstring id) runs on MSC_ConnHdlr {
8319 f_lcs_loc_req_for_active_ms_le_timeout(true);
8320}
8321
8322testcase TC_lcs_loc_req_for_active_ms_le_timeout2() runs on test_CT {
8323 var MSC_ConnHdlr vc_conn;
8324 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8325
8326 f_init(1, true);
8327 f_sleep(1.0);
8328 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_active_ms_le_timeout2), pars);
8329 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008330 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008331}
8332
8333/* With *no* active lchan, start a Perform Location Request, expecting that the MS will be Paged. */
8334private function f_tc_lcs_loc_req_for_idle_ms_no_pag_resp(charstring id) runs on MSC_ConnHdlr {
8335 f_sleep(1.0);
8336
8337 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
8338 f_bssap_le_register_imsi(g_pars.imsi, omit);
8339
8340 /* Register to receive the Paging Command */
8341 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
8342 g_chan_nr := new_chan_nr;
8343 f_rslem_register(0, g_chan_nr);
8344
8345 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
8346 valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
8347 ts_CellId_CGI('001'H, '01'H, 1, 0)))));
8348 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
8349
8350 var PDU_BSSAP_LE plr;
8351 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
8352
8353 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
8354 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
8355
8356 /* OsmoBSC needs to Page */
8357 var PDU_BSSAP_LE rx_bsslap;
8358 alt {
8359 [] RSL.receive(tr_RSL_PAGING_CMD(tr_MI_IMSI(g_pars.imsi))) {
8360 f_logp(BSCVTY, "got Paging Command");
8361 repeat;
8362 }
8363 [] BSSAP_LE.receive(tr_BSSMAP_LE_ConnInfo(BSSMAP_LE_PROT_BSSLAP, ?)) -> value(rx_bsslap) {
8364 /* MS does not respond to Paging, TA Req runs into timeout. */
8365 f_match_bsslap(rx_bsslap, tr_BSSLAP_Abort(?));
8366 }
8367 }
8368
8369 /* SMLC responds with failure */
8370 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(omit, BSSMAP_LE_LCS_CAUSE_REQUEST_ABORTED));
8371 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
8372
8373 /* BSC tells MSC about failure */
8374 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(
8375 locationEstimate := omit, positioningData := omit,
8376 lCS_Cause := tr_BSSMAP_LcsCause(BSSMAP_LCS_CAUSE_REQUEST_ABORTED)));
8377
8378 /* There is no lchan. Still the MSC's job to decide whether to tear down the conn or not. */
8379 f_verify_active_A_conn_and_clear();
8380
8381 f_sleep(2.0);
8382 setverdict(pass);
8383}
8384testcase TC_lcs_loc_req_for_idle_ms_no_pag_resp() runs on test_CT {
8385 var MSC_ConnHdlr vc_conn;
8386 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8387
8388 f_init(1, true);
8389 f_sleep(1.0);
8390
8391 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
8392 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
8393
8394 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_idle_ms_no_pag_resp), pars);
8395 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008396 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008397}
8398
8399/* During an ongoing Location Request, the MS sends a CM Service Request. Expect the same A-conn to be re-used / taken
8400 * over. */
8401private function f_tc_cm_service_during_lcs_loc_req(charstring id) runs on MSC_ConnHdlr {
8402 f_sleep(1.0);
8403
8404 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
8405 f_bssap_le_register_imsi(g_pars.imsi, omit);
8406
8407 /* Register to receive the Paging Command */
8408 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
8409 g_chan_nr := new_chan_nr;
8410 f_rslem_register(0, g_chan_nr);
8411
8412 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
8413 valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
8414 ts_CellId_CGI('001'H, '01'H, 1, 0)))));
8415 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
8416
8417 var PDU_BSSAP_LE plr;
8418 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
8419
8420 /* As the A-interface conn was established for LCS, the MS coincidentally decides to issue a CM Service Request
8421 * and establish Layer 3. It should use the existing A-interface conn. */
8422 f_perform_compl_l3(RSL, valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV(g_pars.imsi)))),
8423 do_clear := false, expect_bssmap_l3 := true);
8424
8425 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
8426 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
8427
8428 /* OsmoBSC already has an lchan, no need to Page, just returns the TA */
8429 f_expect_bsslap(tr_BSSLAP_TA_Resp(?, ?));
8430
8431 /* SMLC got the TA from the BSC, now responds with geo information data. */
8432 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(gad_ell_point_unc_circle, omit));
8433 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
8434 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(tr_BSSMAP_IE_LocationEstimate(gad_ell_point_unc_circle)));
8435
8436 /* The lchan should still exist, it was from a CM Service Request. */
8437 f_mo_l3_transceive();
8438
8439 f_perform_clear(RSL);
8440
8441 f_sleep(2.0);
8442 setverdict(pass);
8443}
8444testcase TC_cm_service_during_lcs_loc_req() runs on test_CT {
8445 var MSC_ConnHdlr vc_conn;
8446 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8447
8448 f_init(1, true);
8449 f_sleep(1.0);
8450
8451 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
8452 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
8453
8454 vc_conn := f_start_handler(refers(f_tc_cm_service_during_lcs_loc_req), pars);
8455 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008456 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008457}
8458
8459/* During an ongoing Perform Location Request, do a Handover, an expect a BSSLAP Reset message from the BSC to indicate
8460 * the new lchan after handover. */
8461private function f_tc_ho_during_lcs_loc_req(charstring id) runs on MSC_ConnHdlr {
8462 f_sleep(1.0);
8463
8464 f_establish_fully(omit, omit);
8465 f_bssap_le_register_imsi(g_pars.imsi, omit);
8466
8467 BSSAP.send(valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
8468 ts_CellId_CGI('262'H, '42'H, 23, 42))));
8469
8470 var PDU_BSSAP_LE plr;
8471 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
8472
8473 /* SMLC ponders the Location Request, in the meantime the BSC decides to handover */
8474 f_bts_0_cfg(BSCVTY, {"neighbor bts 1"});
8475
8476 var HandoverState hs := {
8477 rr_ho_cmpl_seen := false,
8478 handover_done := false,
8479 old_chan_nr := -
8480 };
8481 /* issue hand-over command on VTY */
8482 f_vty_handover(BSCVTY, 0, 0, g_chan_nr, 1);
8483 /* temporarily suspend DChan processing on BTS1 to avoid race with RSLEM_register */
8484 f_rslem_suspend(RSL1_PROC);
8485
8486 /* From the MGW perspective, a handover is is characterized by
8487 * performing one MDCX operation with the MGW. So we expect to see
8488 * one more MDCX during handover. */
8489 g_media.mgcp_conn[0].mdcx_seen_exp := g_media.mgcp_conn[0].crcx_seen_exp + 1;
8490
8491 alt {
8492 [] as_handover(hs);
8493 }
8494
8495 var PDU_BSSAP_LE rx_bsslap;
8496
8497 interleave {
8498 /* Expect the BSC to inform the MSC about the handover */
8499 [] BSSAP.receive(tr_BSSMAP_HandoverPerformed);
8500
8501 /* Expect the BSC to inform the SMLC about the handover */
8502 [] BSSAP_LE.receive(tr_BSSMAP_LE_ConnInfo(BSSMAP_LE_PROT_BSSLAP, ?)) -> value(rx_bsslap) {
8503 f_match_bsslap(rx_bsslap, tr_BSSLAP_Reset(BSSLAP_CAUSE_INTRA_BSS_HO));
8504 }
8505 }
8506
8507 /* SMLC now responds with geo information data. */
8508 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(gad_ell_point_unc_circle, omit));
8509 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
8510 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(tr_BSSMAP_IE_LocationEstimate(gad_ell_point_unc_circle)));
8511
8512 /* lchan still active */
8513 f_mo_l3_transceive(RSL1);
8514
8515 /* MSC decides it is done now. */
8516 f_perform_clear(RSL1);
8517
8518 f_sleep(2.0);
8519 setverdict(pass);
8520}
8521testcase TC_ho_during_lcs_loc_req() runs on test_CT {
8522 var MSC_ConnHdlr vc_conn;
8523 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8524
8525 f_init(2, true);
8526 f_sleep(1.0);
8527 vc_conn := f_start_handler(refers(f_tc_ho_during_lcs_loc_req), pars);
8528 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008529 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008530}
8531
Neels Hofmeyrbf037052020-10-28 22:52:02 +00008532/* Attempt Complete Layer 3 without any MSC available (OS#4832) */
8533private function f_tc_no_msc(charstring id) runs on MSC_ConnHdlr {
8534 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
8535
8536 /* Also disable attach for the single connected MSC */
8537 f_vty_msc_allow_attach(BSCVTY, { false });
8538
8539 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) ));
8540 f_chan_est(g_pars.ra, l3_enc, g_pars.link_id, g_pars.fn);
8541
8542 /* No MSC is found, expecting a proper release on RSL */
8543 interleave {
8544 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
8545 f_logp(BSCVTY, "Got RSL RR Release");
8546 }
8547 [] RSL.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
8548 f_logp(BSCVTY, "Got RSL Deact SACCH");
8549 }
8550 [] RSL.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
8551 f_logp(BSCVTY, "Got RSL RF Chan Rel, sending Rel Ack");
8552 RSL.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
8553 }
8554 }
8555 setverdict(pass);
8556}
8557testcase TC_no_msc() runs on test_CT {
8558
8559 f_init(1, true);
8560 f_sleep(1.0);
8561 var MSC_ConnHdlr vc_conn;
8562 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8563
8564 f_ctrs_bsc_init(counternames_bsc_mscpool);
8565
8566 vc_conn := f_start_handler(refers(f_tc_no_msc), pars);
8567 vc_conn.done;
8568
8569 f_ctrs_bsc_add("mscpool:subscr:no_msc");
8570 f_ctrs_bsc_verify();
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008571 f_shutdown_helper();
Neels Hofmeyrbf037052020-10-28 22:52:02 +00008572}
8573
Harald Welte0ea2d5e2018-04-07 21:40:29 +02008574/* Dyn PDCH todo:
8575 * activate OSMO as TCH/F
8576 * activate OSMO as TCH/H
8577 * does the BSC-located PCU socket get the updated INFO?
8578 * what if no PCU is connected at the time?
8579 * is the info correct on delayed PCU (re)connect?
8580 */
Harald Welte94e0c342018-04-07 11:33:23 +02008581
Neels Hofmeyr87857ec2021-04-25 16:17:47 +00008582private function f_TC_refuse_mode_modif_to_vamos(charstring id) runs on MSC_ConnHdlr {
8583 var PDU_BSSAP ass_cmd := f_gen_ass_req(g_pars.use_osmux);
8584 var template PDU_BSSAP exp_compl := f_gen_exp_compl(g_pars.use_osmux);
8585
8586 /* puzzle together the ASSIGNMENT REQ for given codec[s] */
8587 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
8588 ass_cmd.pdu.bssmap.assignmentRequest.codecList := g_pars.ass_codec_list;
8589 exp_compl.pdu.bssmap.assignmentComplete.speechCodec.codecElements[0] :=
8590 g_pars.ass_codec_list.codecElements[0];
8591 if (isvalue(g_pars.expect_mr_s0_s7)) {
8592 exp_compl.pdu.bssmap.assignmentComplete.speechCodec.codecElements[0].s0_7 :=
8593 g_pars.expect_mr_s0_s7;
8594 }
8595 }
8596 ass_cmd.pdu.bssmap.assignmentRequest.channelType :=
8597 f_BSSMAP_chtype_from_codec(g_pars.ass_codec_list.codecElements[0]);
8598 log("expecting ASS COMPL like this: ", exp_compl);
8599
8600 f_establish_fully(ass_cmd, exp_compl);
8601
8602 f_vty_transceive(BSCVTY, "vamos modify first");
8603
8604 var RSL_Message rsl;
8605
8606 timer T := 5.0;
8607 T.start;
8608 alt {
8609 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr)) -> value rsl {
8610 var PDU_ML3_NW_MS l3 := dec_PDU_ML3_NW_MS(rsl.ies[2].body.l3_info.payload);
8611 log("Rx L3 from net: ", l3);
8612 if (ischosen(l3.msgs.rrm.channelModeModify)) {
8613 setverdict(fail, "Mode Modify to VAMOS succeeded even though BTS does not support VAMOS");
8614 mtc.stop;
8615 }
8616 }
8617 [] RSL.receive(tr_RSL_MODE_MODIFY_REQ(g_chan_nr, ?)) -> value rsl {
8618 setverdict(fail, "Mode Modify to VAMOS succeeded even though BTS does not support VAMOS");
8619 mtc.stop;
8620 }
8621 [] T.timeout {
8622 /* The BTS does not exhibit BTS_FEAT_VAMOS, so no VAMOS related Mode Modify should happen. */
8623 setverdict(pass);
8624 }
8625 }
8626 T.stop;
8627}
8628
8629/* The BSC does *not* indicate BTS_FEAT_VAMOS; make sure that a channel Mode Modify to VAMOS mode is refused by
8630 * osmo-bsc. */
8631testcase TC_refuse_mode_modif_to_vamos() runs on test_CT {
8632 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8633 var MSC_ConnHdlr vc_conn;
8634
8635 f_init(1, true);
8636 f_sleep(1.0);
8637
8638 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
8639 vc_conn := f_start_handler(refers(f_TC_refuse_mode_modif_to_vamos), pars);
8640 vc_conn.done;
8641 f_shutdown_helper();
8642}
8643
8644/* The BSC does *not* indicate BTS_FEAT_VAMOS; make sure that a channel activation to VAMOS mode is refused by osmo-bsc.
8645 */
8646testcase TC_refuse_chan_act_to_vamos() runs on test_CT {
8647 f_init_vty();
8648
8649 f_init(1, false);
8650 f_sleep(1.0);
8651
8652 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 1 sub-slot 0 activate-vamos fr");
8653
8654 var ASP_RSL_Unitdata rx_rsl_ud;
8655 timer T := 5.0;
8656
8657 T.start;
8658 alt {
8659 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(?, IPAC_PROTO_RSL_TRX0)) -> value rx_rsl_ud {
8660 if (rx_rsl_ud.rsl.msg_type == RSL_MT_CHAN_ACTIV) {
8661 T.stop;
8662 setverdict(fail, "CHANnel ACTivate in VAMOS mode succeeded even though BTS does not support VAMOS");
8663 mtc.stop;
8664 }
8665 repeat;
8666 }
8667 [] T.timeout {
8668 /* The BTS does not exhibit BTS_FEAT_VAMOS, so no VAMOS related CHANnel ACTivate should happen. */
8669 setverdict(pass);
8670 }
8671 }
8672}
8673
8674
Harald Welte28d943e2017-11-25 15:00:50 +01008675control {
Harald Welte898113b2018-01-31 18:32:21 +01008676 /* CTRL interface testing */
Harald Welte4003d112017-12-09 22:35:39 +01008677 execute( TC_ctrl_msc_connection_status() );
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01008678 execute( TC_ctrl_msc0_connection_status() );
Harald Welte96c94412017-12-09 03:12:45 +01008679 execute( TC_ctrl() );
Neels Hofmeyrf246a922020-05-13 02:27:10 +02008680 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_SCCPlite_SERVER) {
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +02008681 execute( TC_ctrl_location() );
8682 }
Harald Welte898113b2018-01-31 18:32:21 +01008683
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02008684 execute( TC_si_default() );
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02008685 execute( TC_si2quater_2_earfcns() );
8686 execute( TC_si2quater_3_earfcns() );
8687 execute( TC_si2quater_4_earfcns() );
8688 execute( TC_si2quater_5_earfcns() );
8689 execute( TC_si2quater_6_earfcns() );
Neels Hofmeyrad132f22020-07-08 02:20:16 +02008690 execute( TC_si2quater_12_earfcns() );
8691 execute( TC_si2quater_23_earfcns() );
8692 execute( TC_si2quater_32_earfcns() );
8693 execute( TC_si2quater_33_earfcns() );
8694 execute( TC_si2quater_42_earfcns() );
8695 execute( TC_si2quater_48_earfcns() );
8696 execute( TC_si2quater_49_earfcns() );
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02008697 execute( TC_si_acc_rotate() );
Alexander Couzens4ad3a352020-09-10 22:29:12 +02008698 execute( TC_si_acc_ramp_rotate() );
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02008699
Harald Welte898113b2018-01-31 18:32:21 +01008700 /* RSL DCHAN Channel ACtivation / Deactivation */
Harald Welteae026692017-12-09 01:03:01 +01008701 execute( TC_chan_act_noreply() );
Harald Welte4003d112017-12-09 22:35:39 +01008702 execute( TC_chan_act_counter() );
Harald Welteae026692017-12-09 01:03:01 +01008703 execute( TC_chan_act_ack_noest() );
Philipp Maier9c60a622020-07-09 15:08:46 +02008704 execute( TC_chan_act_ack_noest_emerg() );
Philipp Maier606f07d2020-08-12 17:21:58 +02008705 execute( TC_chan_rqd_emerg_deny() );
Harald Welteae026692017-12-09 01:03:01 +01008706 execute( TC_chan_act_ack_est_ind_noreply() );
8707 execute( TC_chan_act_ack_est_ind_refused() );
Harald Welte618ef642017-12-14 14:58:20 +01008708 execute( TC_chan_act_nack() );
Harald Welte799c97b2017-12-14 17:50:30 +01008709 execute( TC_chan_exhaustion() );
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07008710 execute( TC_chan_deact_silence() );
Harald Welte4003d112017-12-09 22:35:39 +01008711 execute( TC_chan_rel_rll_rel_ind() );
8712 execute( TC_chan_rel_conn_fail() );
8713 execute( TC_chan_rel_hard_clear() );
Pau Espin Pedrol841b90d2021-04-15 16:42:52 +02008714 execute( TC_chan_rel_last_eutran_plmn_hard_clear_no_csfb() );
8715 execute( TC_chan_rel_last_eutran_plmn_hard_clear_csfb() );
Harald Welte99787102019-02-04 10:41:36 +01008716 execute( TC_chan_rel_hard_clear_csfb() );
Harald Welted8c36cd2017-12-09 23:05:31 +01008717 execute( TC_chan_rel_hard_rlsd() );
Harald Welte550daf92018-06-11 19:22:13 +02008718 execute( TC_chan_rel_hard_rlsd_ms_dead() );
Harald Welte85804d42017-12-10 14:11:58 +01008719 execute( TC_chan_rel_a_reset() );
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01008720 execute( TC_chan_rel_sccp_tiar_timeout() );
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02008721 execute( TC_chan_rel_rr_cause() );
Harald Welte6f521d82017-12-11 19:52:02 +01008722
Harald Weltecfe2c962017-12-15 12:09:32 +01008723 execute( TC_outbound_connect() );
Harald Welte898113b2018-01-31 18:32:21 +01008724
8725 /* Assignment related */
Harald Welte16a4adf2017-12-14 18:54:01 +01008726 execute( TC_assignment_cic_only() );
Harald Welte235ebf12017-12-15 14:18:16 +01008727 execute( TC_assignment_csd() );
8728 execute( TC_assignment_ctm() );
8729 execute( TC_assignment_sign() );
Pau Espin Pedrol07866632020-09-03 19:10:55 +02008730 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
8731 execute( TC_assignment_aoip_tla_v6() );
8732 }
Harald Welte235ebf12017-12-15 14:18:16 +01008733 execute( TC_assignment_fr_a5_0() );
8734 execute( TC_assignment_fr_a5_1() );
Neels Hofmeyrf246a922020-05-13 02:27:10 +02008735 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welte8f67d1d2018-05-25 20:38:42 +02008736 execute( TC_assignment_fr_a5_1_codec_missing() );
8737 }
Harald Welte235ebf12017-12-15 14:18:16 +01008738 execute( TC_assignment_fr_a5_3() );
8739 execute( TC_assignment_fr_a5_4() );
Harald Welte3c86ea02018-05-10 22:28:05 +02008740 execute( TC_ciph_mode_a5_0() );
8741 execute( TC_ciph_mode_a5_1() );
8742 execute( TC_ciph_mode_a5_3() );
Harald Welte16a4adf2017-12-14 18:54:01 +01008743
Harald Welte60aa5762018-03-21 19:33:13 +01008744 execute( TC_assignment_codec_fr() );
Neels Hofmeyr559d5d02021-04-16 16:50:49 +02008745 execute( TC_assignment_codec_fr_by_mode_modify() );
Harald Welte60aa5762018-03-21 19:33:13 +01008746 execute( TC_assignment_codec_hr() );
8747 execute( TC_assignment_codec_efr() );
8748 execute( TC_assignment_codec_amr_f() );
8749 execute( TC_assignment_codec_amr_h() );
Philipp Maier8a581d22019-03-26 18:32:48 +01008750
Neels Hofmeyrf246a922020-05-13 02:27:10 +02008751 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Philipp Maier8a581d22019-03-26 18:32:48 +01008752 execute( TC_assignment_codec_amr_f_S1() );
8753 execute( TC_assignment_codec_amr_h_S1() );
8754 execute( TC_assignment_codec_amr_f_S124() );
8755 execute( TC_assignment_codec_amr_h_S124() );
8756 execute( TC_assignment_codec_amr_f_S0() );
8757 execute( TC_assignment_codec_amr_f_S02() );
8758 execute( TC_assignment_codec_amr_f_S024() );
8759 execute( TC_assignment_codec_amr_f_S0247() );
8760 execute( TC_assignment_codec_amr_h_S0() );
8761 execute( TC_assignment_codec_amr_h_S02() );
8762 execute( TC_assignment_codec_amr_h_S024() );
8763 execute( TC_assignment_codec_amr_h_S0247() );
8764 execute( TC_assignment_codec_amr_f_S01234567() );
8765 execute( TC_assignment_codec_amr_f_S0234567() );
8766 execute( TC_assignment_codec_amr_f_zero() );
8767 execute( TC_assignment_codec_amr_f_unsupp() );
8768 execute( TC_assignment_codec_amr_h_S7() );
Neels Hofmeyr21863562020-11-26 00:34:33 +00008769 execute( TC_assignment_codec_amr_f_start_mode_auto() );
8770 execute( TC_assignment_codec_amr_h_start_mode_auto() );
Neels Hofmeyr3eb94562020-11-26 02:40:26 +00008771 execute( TC_assignment_codec_amr_f_start_mode_4() );
8772 execute( TC_assignment_codec_amr_h_start_mode_4() );
Neels Hofmeyr454d7922020-11-26 02:24:57 +00008773 execute( TC_assignment_codec_amr_startmode_cruft() );
Philipp Maier8a581d22019-03-26 18:32:48 +01008774 }
Harald Welte60aa5762018-03-21 19:33:13 +01008775
Philipp Maierac09bfc2019-01-08 13:41:39 +01008776 execute( TC_assignment_codec_fr_exhausted_req_hr() );
8777 execute( TC_assignment_codec_fr_exhausted_req_fr() );
8778 execute( TC_assignment_codec_fr_exhausted_req_fr_hr() );
8779 execute( TC_assignment_codec_fr_exhausted_req_hr_fr() );
8780 execute( TC_assignment_codec_hr_exhausted_req_fr() );
8781 execute( TC_assignment_codec_hr_exhausted_req_hr() );
8782 execute( TC_assignment_codec_hr_exhausted_req_hr_fr() );
8783 execute( TC_assignment_codec_hr_exhausted_req_fr_hr() );
8784 execute( TC_assignment_codec_req_hr_fr() );
8785 execute( TC_assignment_codec_req_fr_hr() );
8786
Pau Espin Pedrol58cf6822019-05-28 18:11:33 +02008787 if (mp_enable_osmux_test) {
8788 execute( TC_assignment_osmux() );
8789 }
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02008790
Harald Welte898113b2018-01-31 18:32:21 +01008791 /* RLL Establish Indication on inactive DCHAN / SAPI */
Harald Welte5cd20ed2017-12-13 21:03:20 +01008792 execute( TC_rll_est_ind_inact_lchan() );
8793 execute( TC_rll_est_ind_inval_sapi1() );
8794 execute( TC_rll_est_ind_inval_sapi3() );
8795 execute( TC_rll_est_ind_inval_sacch() );
8796
Vadim Yanitskiy61f784a2020-10-01 21:12:19 +07008797 /* DLCI / RSL Link ID conversion for MO/MT messages on SAPI0/SAPI3 */
8798 execute( TC_tch_dlci_link_id_sapi() );
8799
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07008800 /* SAPI N Reject triggered by RLL establishment failures */
8801 execute( TC_rll_rel_ind_sapi_n_reject() );
8802 execute( TC_rll_err_ind_sapi_n_reject() );
8803 execute( TC_rll_timeout_sapi_n_reject() );
8804
Harald Welte898113b2018-01-31 18:32:21 +01008805 /* Paging related tests */
Harald Welte6f521d82017-12-11 19:52:02 +01008806 execute( TC_paging_imsi_nochan() );
8807 execute( TC_paging_tmsi_nochan() );
8808 execute( TC_paging_tmsi_any() );
8809 execute( TC_paging_tmsi_sdcch() );
8810 execute( TC_paging_tmsi_tch_f() );
8811 execute( TC_paging_tmsi_tch_hf() );
8812 execute( TC_paging_imsi_nochan_cgi() );
8813 execute( TC_paging_imsi_nochan_lac_ci() );
8814 execute( TC_paging_imsi_nochan_ci() );
8815 execute( TC_paging_imsi_nochan_lai() );
8816 execute( TC_paging_imsi_nochan_lac() );
8817 execute( TC_paging_imsi_nochan_all() );
Harald Welte751d3eb2018-01-31 15:51:06 +01008818 execute( TC_paging_imsi_nochan_plmn_lac_rnc() );
8819 execute( TC_paging_imsi_nochan_rnc() );
8820 execute( TC_paging_imsi_nochan_lac_rnc() );
8821 execute( TC_paging_imsi_nochan_lacs() );
8822 execute( TC_paging_imsi_nochan_lacs_empty() );
Stefan Sperling049a86e2018-03-20 15:51:00 +01008823 execute( TC_paging_imsi_nochan_cgi_unknown_cid() );
Harald Welte10985002017-12-12 09:29:15 +01008824 execute( TC_paging_imsi_a_reset() );
Harald Weltee65d40e2017-12-13 00:09:06 +01008825 execute( TC_paging_imsi_load() );
Philipp Maier779a7922018-02-16 11:00:37 +01008826 execute( TC_paging_counter() );
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01008827 execute( TC_paging_resp_unsol() );
Harald Welte4e9b9cc2017-12-14 18:31:02 +01008828
8829 execute( TC_rsl_drop_counter() );
Stefan Sperling830dc9d2018-02-12 21:08:28 +01008830 execute( TC_rsl_unknown_unit_id() );
8831
8832 execute( TC_oml_unknown_unit_id() );
Harald Welte898113b2018-01-31 18:32:21 +01008833
8834 execute( TC_classmark() );
Harald Welteeddf0e92020-06-21 19:42:15 +02008835 execute( TC_common_id() );
Harald Welte898113b2018-01-31 18:32:21 +01008836 execute( TC_unsol_ass_fail() );
Harald Welteea99a002018-01-31 20:46:43 +01008837 execute( TC_unsol_ass_compl() );
Harald Weltefbf9b5e2018-01-31 20:41:23 +01008838 execute( TC_unsol_ho_fail() );
Harald Weltee3bd6582018-01-31 22:51:25 +01008839 execute( TC_err_82_short_msg() );
Harald Weltee9e02e42018-01-31 23:36:25 +01008840 execute( TC_err_84_unknown_msg() );
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01008841
Harald Welte261af4b2018-02-12 21:20:39 +01008842 execute( TC_ho_int() );
Neels Hofmeyr5f144212020-11-03 15:41:58 +00008843 execute( TC_ho_int_radio_link_failure() );
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01008844
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01008845 execute( TC_ho_out_of_this_bsc() );
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02008846 execute( TC_ho_out_fail_no_msc_response() );
8847 execute( TC_ho_out_fail_rr_ho_failure() );
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02008848 execute( TC_ho_out_fail_no_result_after_ho_cmd() );
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01008849
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01008850 execute( TC_ho_into_this_bsc() );
Pau Espin Pedrol07866632020-09-03 19:10:55 +02008851 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
8852 execute( TC_ho_into_this_bsc_tla_v6() );
8853 }
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02008854 execute( TC_srvcc_eutran_to_geran() );
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02008855 execute( TC_srvcc_eutran_to_geran_ho_out() );
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01008856 execute( TC_ho_in_fail_msc_clears() );
8857 execute( TC_ho_in_fail_msc_clears_after_ho_detect() );
8858 execute( TC_ho_in_fail_no_detect() );
8859 execute( TC_ho_in_fail_no_detect2() );
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01008860
Neels Hofmeyr91401012019-07-11 00:42:35 +02008861 execute( TC_ho_neighbor_config_1() );
8862 execute( TC_ho_neighbor_config_2() );
8863 execute( TC_ho_neighbor_config_3() );
8864 execute( TC_ho_neighbor_config_4() );
8865 execute( TC_ho_neighbor_config_5() );
8866 execute( TC_ho_neighbor_config_6() );
8867 execute( TC_ho_neighbor_config_7() );
8868
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01008869 execute( TC_bssap_rlsd_does_not_cause_bssmap_reset() );
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01008870 execute( TC_bssmap_clear_does_not_cause_bssmap_reset() );
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01008871 execute( TC_ms_rel_ind_does_not_cause_bssmap_reset() );
Harald Welte94e0c342018-04-07 11:33:23 +02008872
8873 execute( TC_dyn_pdch_ipa_act_deact() );
8874 execute( TC_dyn_pdch_ipa_act_nack() );
8875 execute( TC_dyn_pdch_osmo_act_deact() );
8876 execute( TC_dyn_pdch_osmo_act_nack() );
Harald Welte99f3ca02018-06-14 13:40:29 +02008877
Stefan Sperling0796a822018-10-05 13:01:39 +02008878 execute( TC_chopped_ipa_ping() );
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02008879 execute( TC_chopped_ipa_payload() );
Stefan Sperling0796a822018-10-05 13:01:39 +02008880
Pau Espin Pedrol8f773632019-11-05 11:46:53 +01008881 /* Power control related */
8882 execute( TC_assignment_verify_ms_power_params_ie() );
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008883
8884 /* MSC pooling */
8885 /* FIXME: in SCCPlite, indicating how many MSCs should be connected does currently not work. Since
8886 * RESET->RESET-ACK is unconditionally negotiated for all configured MSCs, they always all appear as connected
8887 * to osmo-bsc. The MSC pooling tests however require disconnecting selected MSCs, and hence don't work out as
8888 * intended on SCCPlite. So for now, run these only for SCCP/M3UA. */
8889 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
8890 execute( TC_mscpool_L3Compl_on_1_msc() );
8891 execute( TC_mscpool_L3Complete_by_imsi_round_robin() );
8892 execute( TC_mscpool_LU_by_tmsi_null_nri_0_round_robin() );
8893 execute( TC_mscpool_LU_by_tmsi_null_nri_1_round_robin() );
8894 execute( TC_mscpool_L3Complete_by_tmsi_unassigned_nri_round_robin() );
8895 execute( TC_mscpool_L3Complete_by_tmsi_valid_nri_msc_not_connected_round_robin() );
8896 execute( TC_mscpool_L3Complete_by_tmsi_valid_nri_1() );
8897 execute( TC_mscpool_L3Complete_by_tmsi_valid_nri_2() );
8898 execute( TC_mscpool_LU_by_tmsi_from_other_PLMN() );
8899 execute( TC_mscpool_paging_and_response_imsi() );
8900 execute( TC_mscpool_paging_and_response_tmsi() );
8901 execute( TC_mscpool_no_allow_attach_round_robin() );
8902 execute( TC_mscpool_no_allow_attach_valid_nri() );
8903 }
8904
Harald Welte99f3ca02018-06-14 13:40:29 +02008905 /* at bottom as they might crash OsmoBSC before OS#3182 is fixed */
8906 execute( TC_early_conn_fail() );
8907 execute( TC_late_conn_fail() );
8908
Philipp Maier783681c2020-07-16 16:47:06 +02008909 /* Emergency call handling (deny / allow) */
8910 execute( TC_assignment_emerg_setup_allow() );
8911 execute( TC_assignment_emerg_setup_deny_msc() );
8912 execute( TC_assignment_emerg_setup_deny_bts() );
Philipp Maier82812002020-08-13 18:48:27 +02008913 execute( TC_emerg_premption() );
8914
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008915 /* Frequency hopping parameters handling */
8916 execute( TC_fh_params_chan_activ() );
8917 execute( TC_fh_params_imm_ass() );
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07008918 execute( TC_fh_params_assignment_cmd() );
Vadim Yanitskiy8f5430d2020-09-02 18:51:38 +07008919 execute( TC_fh_params_handover_cmd() );
Vadim Yanitskiyca974032020-09-01 07:20:39 +07008920 execute( TC_fh_params_si4_cbch() );
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008921
8922 if (mp_enable_lcs_tests) {
8923 execute( TC_lcs_loc_req_for_active_ms() );
8924 execute( TC_lcs_loc_req_for_active_ms_ta_req() );
8925 execute( TC_lcs_loc_req_for_idle_ms() );
8926 execute( TC_lcs_loc_req_no_subscriber() );
8927 execute( TC_lcs_loc_req_for_active_ms_le_timeout() );
8928 execute( TC_lcs_loc_req_for_active_ms_le_timeout2() );
8929 execute( TC_lcs_loc_req_for_idle_ms_no_pag_resp() );
8930 execute( TC_cm_service_during_lcs_loc_req() );
8931 execute( TC_ho_during_lcs_loc_req() );
8932 }
Neels Hofmeyrbf037052020-10-28 22:52:02 +00008933
8934 execute( TC_no_msc() );
Neels Hofmeyr87857ec2021-04-25 16:17:47 +00008935
8936 execute( TC_refuse_chan_act_to_vamos() );
8937 execute( TC_refuse_mode_modif_to_vamos() );
Harald Welte28d943e2017-11-25 15:00:50 +01008938}
8939
8940}