blob: dc94b74f70dee57542f97cf32c5a247ba55c5012 [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;
Philipp Maiera2083892020-09-21 14:18:36 +0200674
675 boolean mp_media_mgw_offer_ipv6 := true;
Harald Weltea4ca4462018-02-09 00:17:14 +0100676}
677
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200678private function f_gen_test_hdlr_pars(integer bssap_idx := 0) return TestHdlrParams {
Philipp Maier48604732018-10-09 15:00:37 +0200679
680 var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200681 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Philipp Maier48604732018-10-09 15:00:37 +0200682 pars.aoip := true;
683 } else {
684 pars.aoip := false;
685 }
Pau Espin Pedrol8f30ccd2019-11-01 17:30:57 +0100686 pars.exp_ms_power_level := mp_exp_ms_power_level;
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200687 pars.mscpool.bssap_idx := bssap_idx;
Philipp Maiera2083892020-09-21 14:18:36 +0200688 pars.media_mgw_offer_ipv6 := mp_media_mgw_offer_ipv6;
Philipp Maier48604732018-10-09 15:00:37 +0200689
690 return pars;
691}
692
Neels Hofmeyr22c3f792020-06-17 02:49:28 +0200693/* Convenience functions for rate counters using g_ctr_msc. */
694
695private function f_ctrs_msc_init(integer mscs_count := NUM_MSC, CounterNameVals counternames := counternames_msc_mscpool) runs on test_CT {
696 g_ctr_msc := f_counter_name_vals_get_n(IPA_CTRL, "msc", mscs_count, counternames);
697 log("initial msc rate counters: ", g_ctr_msc);
698}
699
700private function f_ctrs_msc_add(integer msc_nr, charstring countername, integer val := 1) runs on test_CT {
Neels Hofmeyr9656e922020-06-30 01:27:01 +0200701 f_counter_name_vals_list_add(g_ctr_msc, msc_nr, countername, val);
Neels Hofmeyr22c3f792020-06-17 02:49:28 +0200702}
703
704/* f_ctrs_msc_init();
705 * f_do_thing(on_msc := 0);
706 * f_do_thing(on_msc := 0);
707 * f_do_other(on_msc := 1);
708 * f_ctrs_msc_add(0, "thing", 2);
709 * f_ctrs_msc_add(1, "other");
710 * f_ctrs_msc_verify();
711 */
712private function f_ctrs_msc_verify() runs on test_CT {
713 log("verifying msc rate counters: ", g_ctr_msc);
714 f_counter_name_vals_expect_n(IPA_CTRL, "msc", g_ctr_msc);
715}
716
717/* convenience: f_ctrs_msc_add() and f_ctrs_msc_verify() in one call.
718 * f_ctrs_msc_init();
719 * f_do_thing(on_msc := 0);
720 * f_do_thing(on_msc := 0);
721 * f_do_thing(on_msc := 0);
722 * f_ctrs_msc_expect(0, "thing", 3);
723 */
724private function f_ctrs_msc_expect(integer msc_nr, charstring countername, integer val := 1) runs on test_CT {
725 f_ctrs_msc_add(msc_nr, countername, val);
726 f_ctrs_msc_verify();
727}
728
Neels Hofmeyr12941bd2020-08-29 03:21:26 +0000729/* Convenience functions for rate counters using g_ctr_bts, always also including g_ctr_bsc. */
730
731private function f_ctrs_bsc_and_bts_init(integer bts_count := NUM_BTS, CounterNameVals counternames := counternames_bsc_bts_handover) runs on test_CT {
732 g_ctr_bts := f_counter_name_vals_get_n(IPA_CTRL, "bts", bts_count, counternames);
733 log("initial bts rate counters: ", g_ctr_bts);
734 f_ctrs_bsc_init(counternames);
735}
736
737private function f_ctrs_bsc_and_bts_add(integer bts_nr, charstring countername, integer val := 1) runs on test_CT {
738 f_counter_name_vals_list_add(g_ctr_bts, bts_nr, countername, val);
739 f_ctrs_bsc_add(countername, val);
740}
741
742/* f_ctrs_bsc_and_bts_init();
743 * f_do_thing(on_bts := 0);
744 * f_do_thing(on_bts := 0);
745 * f_do_other(on_bts := 1);
746 * f_ctrs_bsc_and_bts_add(0, "thing", 2);
747 * f_ctrs_bsc_and_bts_add(1, "other");
748 * f_ctrs_bsc_and_bts_verify();
749 */
750private function f_ctrs_bsc_and_bts_verify() runs on test_CT {
751 f_counter_name_vals_expect_n(IPA_CTRL, "bts", g_ctr_bts);
752 f_ctrs_bsc_verify();
753}
754
755/* convenience: f_ctrs_bsc_and_bts_add() and f_ctrs_bsc_and_bts_verify() in one call.
756 * f_ctrs_bsc_and_bts_init();
757 * f_do_thing(on_bts := 0);
758 * f_do_thing(on_bts := 0);
759 * f_do_thing(on_bts := 0);
760 * f_ctrs_bsc_and_bts_expect(0, "thing", 3);
761 */
762private function f_ctrs_bsc_and_bts_expect(integer bts_nr, charstring countername, integer val := 1) runs on test_CT {
763 f_ctrs_bsc_and_bts_add(bts_nr, countername, val);
764 f_ctrs_bsc_and_bts_verify();
765}
766
767
768/* Convenience functions for rate counters using g_ctr_bsc. */
769
770private function f_ctrs_bsc_init(CounterNameVals counternames := counternames_bsc_bts_handover) runs on test_CT {
771 g_ctr_bsc := f_counter_name_vals_get_n(IPA_CTRL, "bsc", 1, counternames);
772 log("initial bsc rate counters: ", g_ctr_bsc);
773}
774
775private function f_ctrs_bsc_add(charstring countername, integer val := 1) runs on test_CT {
776 f_counter_name_vals_list_add(g_ctr_bsc, 0, countername, val);
777}
778
779/* f_ctrs_bsc_init();
780 * f_do_thing();
781 * f_do_thing();
782 * f_do_other();
783 * f_ctrs_bsc_add("thing", 2);
784 * f_ctrs_bsc_add("other");
785 * f_ctrs_bsc_verify();
786 */
787private function f_ctrs_bsc_verify() runs on test_CT {
788 f_counter_name_vals_expect_n(IPA_CTRL, "bsc", g_ctr_bsc);
789}
790
791/* convenience: f_ctrs_bsc_add() and f_ctrs_bsc_verify() in one call.
792 * f_ctrs_bsc_init();
793 * f_do_thing();
794 * f_ctrs_bsc_expect("thing", 1);
795 */
796private function f_ctrs_bsc_expect(charstring countername, integer val := 1) runs on test_CT {
797 f_ctrs_bsc_add(countername, val);
798 f_ctrs_bsc_verify();
799}
800
Neels Hofmeyr22c3f792020-06-17 02:49:28 +0200801
Philipp Maier282ca4b2018-02-27 17:17:00 +0100802private function f_shutdown_helper() runs on test_CT {
Daniel Willmann637ef6c2018-07-25 10:49:09 +0200803 all component.stop;
Philipp Maier282ca4b2018-02-27 17:17:00 +0100804 setverdict(pass);
Daniel Willmannafce8662018-07-06 23:11:32 +0200805 mtc.stop;
Philipp Maier282ca4b2018-02-27 17:17:00 +0100806}
807
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200808private function f_legacy_bssap_reset(integer bssap_idx := 0) runs on test_CT {
Harald Weltea4ca4462018-02-09 00:17:14 +0100809 var BSSAP_N_UNITDATA_ind ud_ind;
Pau Espin Pedrol24c05992020-09-01 12:54:12 +0200810 var boolean reset_received := false;
Harald Weltea4ca4462018-02-09 00:17:14 +0100811 timer T := 5.0;
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200812 BSSAP.send(ts_BSSAP_UNITDATA_req(g_bssap[bssap_idx].sccp_addr_peer, g_bssap[bssap_idx].sccp_addr_own,
813 ts_BSSMAP_Reset(0, g_osmux_enabled)));
Harald Weltea4ca4462018-02-09 00:17:14 +0100814 T.start;
815 alt {
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200816 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(g_bssap[bssap_idx].sccp_addr_own, g_bssap[bssap_idx].sccp_addr_peer,
817 tr_BSSMAP_ResetAck(g_osmux_enabled))) {
Neels Hofmeyr4f5d7be2020-10-16 16:28:16 +0200818 log("BSSMAP: Received RESET-ACK in response to RESET, we're ready to go!");
Harald Weltea4ca4462018-02-09 00:17:14 +0100819 }
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200820 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset(g_osmux_enabled))) -> value ud_ind {
Neels Hofmeyr4f5d7be2020-10-16 16:28:16 +0200821 log("BSSMAP: Respoding to inbound RESET with RESET-ACK");
Harald Weltea4ca4462018-02-09 00:17:14 +0100822 BSSAP.send(ts_BSSAP_UNITDATA_req(ud_ind.callingAddress, ud_ind.calledAddress,
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200823 ts_BSSMAP_ResetAck(g_osmux_enabled)));
Pau Espin Pedrol24c05992020-09-01 12:54:12 +0200824 reset_received := true;
Harald Weltea4ca4462018-02-09 00:17:14 +0100825 repeat;
826 }
827 [] BSSAP.receive { repeat; }
Pau Espin Pedrol24c05992020-09-01 12:54:12 +0200828 [] T.timeout {
Neels Hofmeyr4f5d7be2020-10-16 16:28:16 +0200829 log("BSSMAP: Timeout waiting for RESET-ACK after sending RESET");
Pau Espin Pedrol24c05992020-09-01 12:54:12 +0200830 /* If we received a RESET after ours was sent, it
831 may be a race condition where the other peer beacame
832 available after we sent it, but we are in a desired
833 state anyway, so go forward. */
834 if (not reset_received) {
835 setverdict(fail);
836 }
837 }
Harald Weltea4ca4462018-02-09 00:17:14 +0100838 }
Harald Welte28d943e2017-11-25 15:00:50 +0100839}
840
Harald Welteae026692017-12-09 01:03:01 +0100841type record IPA_Client {
Harald Welte21b46bd2017-12-17 19:46:32 +0100842 /* IPA Emulation component reference */
Harald Welteae026692017-12-09 01:03:01 +0100843 IPA_Emulation_CT vc_IPA,
Harald Welte21b46bd2017-12-17 19:46:32 +0100844 /* Unit-ID and other CCM parameters to use for IPA client emulation */
Harald Welteae026692017-12-09 01:03:01 +0100845 IPA_CCM_Parameters ccm_pars,
Harald Welte21b46bd2017-12-17 19:46:32 +0100846 /* String identifier for this IPA Client */
Harald Welte624f9632017-12-16 19:26:04 +0100847 charstring id,
Harald Welte21b46bd2017-12-17 19:46:32 +0100848 /* Associated RSL Emulation Component (if any). Only used in "Handler mode" */
Harald Welte624f9632017-12-16 19:26:04 +0100849 RSL_Emulation_CT vc_RSL optional
Harald Welte28d943e2017-11-25 15:00:50 +0100850}
851
Harald Welte21b46bd2017-12-17 19:46:32 +0100852/*! Start the IPA/RSL related bits for one IPA_Client.
853 * \param clnt IPA_Client for which to establish
854 * \param bsc_host IP address / hostname of the BSC
855 * \param bsc_port TCP port number of the BSC
856 * \param i number identifying this BTS
857 * \param handler_mode Start an RSL_Emulation_CT component (true) or not (false) */
Harald Welte624f9632017-12-16 19:26:04 +0100858function f_ipa_rsl_start(inout IPA_Client clnt, charstring bsc_host, PortNumber bsc_port, integer i,
859 boolean handler_mode := false)
Harald Welte28d943e2017-11-25 15:00:50 +0100860runs on test_CT {
Harald Welteae026692017-12-09 01:03:01 +0100861 timer T := 10.0;
862
Harald Welte96c94412017-12-09 03:12:45 +0100863 clnt.id := "IPA" & int2str(i) & "-RSL";
Harald Welteae026692017-12-09 01:03:01 +0100864 clnt.vc_IPA := IPA_Emulation_CT.create(clnt.id & "-IPA");
865 clnt.ccm_pars := c_IPA_default_ccm_pars;
866 clnt.ccm_pars.name := "Osmocom TTCN-3 BTS Simulator";
867 clnt.ccm_pars.unit_id := int2str(1234+i) & "/0/0";
Harald Welte624f9632017-12-16 19:26:04 +0100868 if (handler_mode) {
869 clnt.vc_RSL := RSL_Emulation_CT.create(clnt.id & "-RSL");
Harald Welte89ab1912018-02-23 18:56:29 +0100870 connect(clnt.vc_RSL:CCHAN_PT, self:RSL_CCHAN[i]);
Harald Welte624f9632017-12-16 19:26:04 +0100871 }
Harald Welteae026692017-12-09 01:03:01 +0100872
873 map(clnt.vc_IPA:IPA_PORT, system:IPA_CODEC_PT);
Harald Welte624f9632017-12-16 19:26:04 +0100874 if (handler_mode) {
875 connect(clnt.vc_IPA:IPA_RSL_PORT, clnt.vc_RSL:IPA_PT);
876 } else {
877 connect(clnt.vc_IPA:IPA_RSL_PORT, self:IPA_RSL[i]);
878 }
Harald Welteae026692017-12-09 01:03:01 +0100879
Harald Welte5d1a2202017-12-13 19:51:29 +0100880 clnt.vc_IPA.start(IPA_Emulation.main_client(bsc_host, bsc_port, "", 10000+i, clnt.ccm_pars));
Harald Welte624f9632017-12-16 19:26:04 +0100881 if (handler_mode) {
882 clnt.vc_RSL.start(RSL_Emulation.main());
883 return;
884 }
Harald Welteae026692017-12-09 01:03:01 +0100885
886 /* wait for IPA RSL link to connect and send ID ACK */
887 T.start;
888 alt {
Vadim Yanitskiya2afacc2020-05-18 21:16:19 +0700889 [] IPA_RSL[i].receive(tr_ASP_IPA_EV(ASP_IPA_EVENT_ID_ACK)) {
Harald Welteae026692017-12-09 01:03:01 +0100890 T.stop;
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +0700891 IPA_RSL[i].send(ts_ASP_RSL_UD(ts_RSL_PAGING_LOAD_IND(23)));
Harald Welteae026692017-12-09 01:03:01 +0100892 }
Harald Welte60e823a2017-12-10 14:10:59 +0100893 [] IPA_RSL[i].receive(ASP_IPA_Event:?) { repeat }
Harald Welteae026692017-12-09 01:03:01 +0100894 [] IPA_RSL[i].receive { repeat }
895 [] T.timeout {
Harald Welte96c94412017-12-09 03:12:45 +0100896 setverdict(fail, "Timeout RSL waiting for ASP_IPA_EVENT_ID_ACK");
Daniel Willmannafce8662018-07-06 23:11:32 +0200897 mtc.stop;
Harald Welteae026692017-12-09 01:03:01 +0100898 }
899 }
900}
901
Harald Welte12055472018-03-17 20:10:08 +0100902function f_ipa_rsl_stop(inout IPA_Client clnt) runs on test_CT {
903 if (not isbound(clnt) or not isbound(clnt.vc_IPA)) {
904 return;
905 }
906 clnt.vc_IPA.stop;
907 if (isbound(clnt.vc_RSL)) {
908 clnt.vc_RSL.stop;
909 }
910}
911
Harald Welte21b46bd2017-12-17 19:46:32 +0100912/* Wait for the OML connection to be brought up by the external osmo-bts-omldummy */
Harald Weltea5d2ab22017-12-09 14:21:42 +0100913function f_wait_oml(integer bts_nr, charstring status, float secs_max) runs on test_CT {
914 timer T := secs_max;
915 T.start;
916 while (true) {
917 if (f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-connection-state") == status) {
918 T.stop;
Harald Weltebd868bd2017-12-10 18:28:40 +0100919 /* the 'degraded' state exists from OML connection time, and we have to wait
920 * until all MO's are initialized */
921 T.start(1.0);
922 T.timeout;
Harald Weltea5d2ab22017-12-09 14:21:42 +0100923 return;
924 }
Harald Weltef0d6ac62017-12-17 17:02:21 +0100925 f_sleep(0.1);
Harald Weltea5d2ab22017-12-09 14:21:42 +0100926 if (not T.running) {
Max99253902018-11-16 17:57:39 +0100927 setverdict(fail, "Timeout waiting for BTS" & int2str(bts_nr) & " oml-connection-state ", status);
Daniel Willmannafce8662018-07-06 23:11:32 +0200928 mtc.stop;
Harald Weltea5d2ab22017-12-09 14:21:42 +0100929 }
930 }
931}
932
Harald Welte21b46bd2017-12-17 19:46:32 +0100933/* global altstep for global guard timer; also takes care of responding RESET witH RESET-ACK */
Harald Welteae026692017-12-09 01:03:01 +0100934altstep as_Tguard() runs on test_CT {
Harald Welte60e823a2017-12-10 14:10:59 +0100935 var BSSAP_N_UNITDATA_ind ud_ind;
Neels Hofmeyrcc3f76a2018-03-12 01:43:25 +0100936 [] T_guard.timeout {
937 setverdict(fail, "Timeout of T_guard");
Daniel Willmannafce8662018-07-06 23:11:32 +0200938 mtc.stop;
Neels Hofmeyrcc3f76a2018-03-12 01:43:25 +0100939 }
Harald Welte60e823a2017-12-10 14:10:59 +0100940 /* always respond with RESET ACK to RESET */
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200941 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset(g_osmux_enabled))) -> value ud_ind {
Harald Welte60e823a2017-12-10 14:10:59 +0100942 BSSAP.send(ts_BSSAP_UNITDATA_req(ud_ind.callingAddress, ud_ind.calledAddress,
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200943 ts_BSSMAP_ResetAck(g_osmux_enabled)));
Harald Welte69c1c262017-12-13 21:02:08 +0100944 repeat;
Harald Welte60e823a2017-12-10 14:10:59 +0100945 }
Harald Welte28d943e2017-11-25 15:00:50 +0100946}
947
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +0100948altstep no_bssmap_reset() runs on test_CT {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200949 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset(g_osmux_enabled))) {
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +0100950 setverdict(fail, "unexpected BSSMAP Reset");
Daniel Willmannafce8662018-07-06 23:11:32 +0200951 mtc.stop;
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +0100952 }
953}
954
Daniel Willmann191e0d92018-01-17 12:44:35 +0100955function f_init_mgcp(charstring id) runs on test_CT {
956 id := id & "-MGCP";
957
958 var MGCPOps ops := {
959 create_cb := refers(MGCP_Emulation.ExpectedCreateCallback),
960 unitdata_cb := refers(MGCP_Emulation.DummyUnitdataCallback)
961 };
962 var MGCP_conn_parameters mgcp_pars := {
963 callagent_ip := mp_bsc_ip,
Harald Welte9e4273e2018-01-29 22:01:22 +0100964 callagent_udp_port := -1,
Daniel Willmann191e0d92018-01-17 12:44:35 +0100965 mgw_ip := mp_test_ip,
Pau Espin Pedrol1a026a52019-06-18 17:21:52 +0200966 mgw_udp_port := 2427,
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +0200967 /* Enable it for SCCPlite, since we have 2 MGCP sockets towards MGW (UDP one +
968 the on with MGCP over IPA forwarded from MSC one) */
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200969 multi_conn_mode := (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_SCCPlite_SERVER)
Daniel Willmann191e0d92018-01-17 12:44:35 +0100970 };
971
972 vc_MGCP := MGCP_Emulation_CT.create(id);
973 vc_MGCP.start(MGCP_Emulation.main(ops, mgcp_pars, id));
974}
975
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200976/* Enable or disable (current default) Osmux. When enabling, BSSMAP Reset
977 * contains extra IE (OsmuxSupport) and osmo-bsc will handle AssignReq with
978 * OsmuxCID IE.
979 */
980private function f_vty_allow_osmux(boolean allow) runs on test_CT {
981 f_vty_enter_cfg_msc(BSCVTY, 0);
982 if (allow) {
983 f_vty_transceive(BSCVTY, "osmux on");
984 } else {
985 f_vty_transceive(BSCVTY, "osmux off");
986 }
987 f_vty_transceive(BSCVTY, "exit");
988 f_vty_transceive(BSCVTY, "exit");
989 g_osmux_enabled := allow;
990}
991
Max2253c0b2018-11-06 19:28:05 +0100992function f_init_vty(charstring id := "foo") runs on test_CT {
Harald Welte94e0c342018-04-07 11:33:23 +0200993 if (BSCVTY.checkstate("Mapped")) {
994 /* skip initialization if already executed once */
995 return;
996 }
Harald Weltebc03c762018-02-12 18:09:38 +0100997 map(self:BSCVTY, system:BSCVTY);
998 f_vty_set_prompts(BSCVTY);
999 f_vty_transceive(BSCVTY, "enable");
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01001000 f_cs7_inst_0_cfg(BSCVTY, {"sccp-timer ias " & int2str(g_bsc_sccp_timer_ias),
1001 "sccp-timer iar " & int2str(g_bsc_sccp_timer_iar)});
Harald Weltebc03c762018-02-12 18:09:38 +01001002}
1003
Neels Hofmeyr767548a2020-08-09 20:26:07 +00001004private function f_logp(TELNETasp_PT pt, charstring log_msg)
Neels Hofmeyr4f118412020-06-04 15:25:10 +02001005{
1006 // log on TTCN3 log output
1007 log(log_msg);
1008 // log in stderr log
Neels Hofmeyr767548a2020-08-09 20:26:07 +00001009 f_vty_transceive(pt, "logp lglobal notice TTCN3 f_logp(): " & log_msg);
Neels Hofmeyr4f118412020-06-04 15:25:10 +02001010}
1011
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02001012private function f_sysinfo_seen(integer rsl_idx, RSL_Message rsl) runs on test_CT
1013{
1014 if (rsl_idx >= lengthof(g_system_information)) {
1015 g_system_information[rsl_idx] := SystemInformationConfig_omit
1016 }
1017 f_sysinfo_dec_raw(g_system_information[rsl_idx], rsl);
1018}
1019
1020altstep as_catch_RSL_sysinfo(integer rsl_idx) runs on test_CT {
1021 var ASP_RSL_Unitdata rx_rsl_ud;
1022
1023 /* For handler_mode := false, receiving the RSL bootstrap messages directly on IPA_RSL */
1024 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_NO_BCCH_INFO)) -> value rx_rsl_ud {
1025 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1026 repeat;
1027 }
1028 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_BCCH_INFO)) -> value rx_rsl_ud {
1029 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1030 repeat;
1031 }
1032 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_NO_SACCH_FILL)) -> value rx_rsl_ud {
1033 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1034 repeat;
1035 }
1036 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_SACCH_FILL)) -> value rx_rsl_ud {
1037 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1038 repeat;
1039 }
1040
1041 /* For handler_mode := true, receiving the RSL bootstrap messages via RSL_Emulation */
1042 [] RSL_CCHAN[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_NO_BCCH_INFO)) -> value rx_rsl_ud {
1043 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1044 repeat;
1045 }
1046 [] RSL_CCHAN[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_BCCH_INFO)) -> value rx_rsl_ud {
1047 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1048 repeat;
1049 }
1050 [] RSL_CCHAN[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_NO_SACCH_FILL)) -> value rx_rsl_ud {
1051 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1052 repeat;
1053 }
1054 [] RSL_CCHAN[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_SACCH_FILL)) -> value rx_rsl_ud {
1055 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1056 repeat;
1057 }
1058}
1059
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001060/* TODO: use BooleanList from COMMON/src/General_Types.ttcn */
1061private type record of boolean my_BooleanList;
1062
1063private function f_vty_msc_allow_attach(TELNETasp_PT pt, my_BooleanList allow_attach_list)
1064{
Neels Hofmeyr8f576712020-08-12 22:49:53 +00001065 var charstring config := f_vty_transceive_ret(pt, "show running-config");
1066
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001067 for (var integer msc_nr := 0; msc_nr < sizeof(allow_attach_list); msc_nr := msc_nr+1) {
Neels Hofmeyr8f576712020-08-12 22:49:53 +00001068 if (f_strstr(config, "\nmsc " & int2str(msc_nr) & "\n") < 0) {
1069 /* There is no 'msc N' for this msc_nr in the running config, so don't create an empty msc by
1070 * stepping into that config node. */
1071 log("msc ", msc_nr, " is not configured, skipping");
1072 continue;
1073 }
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001074 f_vty_enter_cfg_msc(pt, msc_nr);
1075 if (allow_attach_list[msc_nr]) {
1076 /* strict := false: ignore if osmo-bsc does not support this config option (latest build) */
1077 f_vty_transceive(pt, "allow-attach", strict := false);
1078 } else {
1079 f_vty_transceive(pt, "no allow-attach", strict := false);
1080 }
1081 f_vty_transceive(pt, "exit");
1082 f_vty_transceive(pt, "exit");
1083 }
1084}
1085
Harald Welte21b46bd2017-12-17 19:46:32 +01001086/* global initialization function
1087 * \param nr_bts Number of BTSs we should start/bring up
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001088 * \param handler_mode Start an RSL_Emulation_CT component (true) or not (false).
1089 * \param nr_msc Number of virtual MSCs to bring up to connect to osmo-bsc.
1090 */
1091function f_init(integer nr_bts := NUM_BTS, boolean handler_mode := false, boolean allow_osmux := false,
Neels Hofmeyr4fbad7f2020-06-16 00:30:47 +02001092 integer nr_msc := 1, float guard_timeout := 30.0) runs on test_CT {
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001093 var integer bssap_idx;
Harald Welte28d943e2017-11-25 15:00:50 +01001094
Harald Welteae026692017-12-09 01:03:01 +01001095 if (g_initialized) {
1096 return;
Harald Welte28d943e2017-11-25 15:00:50 +01001097 }
Harald Welteae026692017-12-09 01:03:01 +01001098 g_initialized := true;
1099
Neels Hofmeyr4fbad7f2020-06-16 00:30:47 +02001100 T_guard.start(guard_timeout);
Daniel Willmanne68f9272018-11-27 15:15:28 +01001101 activate(as_Tguard());
1102
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001103 f_init_vty("VirtMSC");
Pau Espin Pedrol58cf6822019-05-28 18:11:33 +02001104 if (mp_enable_osmux_test) {
1105 f_vty_allow_osmux(allow_osmux);
1106 }
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001107
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001108 var my_BooleanList allow_attach := { false, false, false };
Daniel Willmannebdecc02020-08-12 15:30:17 +02001109 f_init_statsd("VirtMSC", vc_STATSD, mp_test_ip, mp_bsc_statsd_port);
1110
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001111 for (bssap_idx := 0; bssap_idx < nr_msc; bssap_idx := bssap_idx+1) {
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001112 allow_attach[bssap_idx] := true;
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001113 /* Call a function of our 'parent component' RAN_Adapter_CT to start the
1114 * MSC-side BSSAP emulation */
1115 if (handler_mode) {
1116 var RanOps ranops := MSC_RanOps;
1117 ranops.use_osmux := g_osmux_enabled;
1118 f_ran_adapter_init(g_bssap[bssap_idx], mp_bssap_cfg[bssap_idx], "VirtMSC", ranops);
1119 connect(self:SCCPLITE_IPA_CTRL, g_bssap[bssap_idx].vc_RAN:CTRL_CLIENT);
1120 f_ran_adapter_start(g_bssap[bssap_idx]);
1121 } else {
1122 f_ran_adapter_init(g_bssap[bssap_idx], mp_bssap_cfg[bssap_idx], "VirtMSC", omit);
1123 connect(self:BSSAP, g_bssap[bssap_idx].vc_SCCP:SCCP_SP_PORT);
1124 f_ran_adapter_start(g_bssap[bssap_idx]);
1125 f_legacy_bssap_reset();
1126 }
Harald Welte67089ee2018-01-17 22:19:03 +01001127 }
Harald Welted5833a82018-05-27 16:52:56 +02001128
Neels Hofmeyrcfe44062020-10-15 02:28:08 +02001129 if (mp_enable_lcs_tests) {
1130 if (handler_mode) {
1131 f_bssap_le_adapter_init(g_bssap_le, mp_bssap_le_cfg, "VirtSMLC", SMLC_BssapLeOps);
1132 } else {
1133 f_bssap_le_adapter_init(g_bssap_le, mp_bssap_le_cfg, "VirtSMLC", omit);
1134 connect(self:BSSAP_LE, g_bssap_le.vc_SCCP:SCCP_SP_PORT);
1135 }
1136 f_bssap_le_adapter_start(g_bssap_le);
Harald Welte47cd0e32020-08-21 12:39:11 +02001137 }
Harald Welte47cd0e32020-08-21 12:39:11 +02001138
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001139 /* start the test with exactly all enabled MSCs allowed to attach */
1140 f_vty_msc_allow_attach(BSCVTY, allow_attach);
1141
Pau Espin Pedrol9a5b8ff2021-01-04 19:01:31 +01001142 f_ipa_ctrl_start_client(mp_bsc_ip, mp_bsc_ctrl_port);
Harald Welte28d943e2017-11-25 15:00:50 +01001143
Daniel Willmann191e0d92018-01-17 12:44:35 +01001144 f_init_mgcp("VirtMSC");
1145
Neels Hofmeyr0b7365b2020-07-04 00:52:34 +02001146 for (var integer i := 0; i < nr_bts; i := i+1) {
1147 f_init_bts(i, handler_mode);
Harald Welte696ddb62017-12-08 14:01:43 +01001148 }
Neels Hofmeyr0b7365b2020-07-04 00:52:34 +02001149}
Harald Welte696ddb62017-12-08 14:01:43 +01001150
Neels Hofmeyr0b7365b2020-07-04 00:52:34 +02001151function f_init_bts(integer bts_idx := 0, boolean handler_mode := false)
1152runs on test_CT {
1153 /* wait until osmo-bts-omldummy has respawned */
1154 f_wait_oml(bts_idx, "degraded", 5.0);
1155
1156 /* start RSL connection */
1157 f_ipa_rsl_start(bts[bts_idx].rsl, mp_bsc_ip, mp_bsc_rsl_port, bts_idx, handler_mode);
1158 /* wait until BSC tells us "connected" */
1159 f_wait_oml(bts_idx, "connected", 5.0);
Harald Welte28d943e2017-11-25 15:00:50 +01001160}
1161
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02001162function f_init_bts_and_check_sysinfo(integer bts_idx := 0, boolean handler_mode := false,
1163 template SystemInformationConfig expect_si)
1164runs on test_CT {
1165 var default sysinfo := activate(as_catch_RSL_sysinfo(bts_idx));
1166
1167 f_init_bts(bts_idx, handler_mode);
1168
1169 /* Give some time to (hopefully/most likely) collect all system informations from RSL startup.
1170 * We could stop as soon as all expected SI are received, but then we might miss SI that we don't expect and
1171 * that might be sent afterwards. So rather give a generous timeout and be quite sure to catch all SI.
1172 */
1173 f_sleep(5.0);
1174 log("RSL ", bts_idx, " SYSTEM INFORMATION: ", g_system_information[bts_idx]);
1175
1176 deactivate(sysinfo);
1177
1178 if (match(g_system_information[bts_idx], expect_si)) {
1179 setverdict(pass);
1180 } else {
1181 log("RSL ", bts_idx, ": EXPECTED SI: ", expect_si);
1182 log("RSL ", bts_idx, ": GOT SI: ", g_system_information[bts_idx]);
1183 setverdict(fail, "received SI does not match expectations");
1184 return;
1185 }
1186}
1187
Maxd4e56962018-10-31 19:08:25 +01001188/* expect to receive a RSL message matching a specified template on a given BTS / stream */
Harald Welte65e419a2020-08-21 12:38:33 +02001189function 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 +01001190runs on test_CT return RSL_Message {
1191 var ASP_RSL_Unitdata rx_rsl_ud;
1192 timer T := t_secs;
1193
1194 T.start;
1195 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001196 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(t_rx, sid)) -> value rx_rsl_ud {
Harald Welteae026692017-12-09 01:03:01 +01001197 T.stop;
1198 }
1199 [] IPA_RSL[bts_nr].receive { repeat; }
Harald Welteb2917702017-12-10 15:48:52 +01001200 [] T.timeout {
1201 setverdict(fail, "Timeout expecting ", t_rx);
Daniel Willmannafce8662018-07-06 23:11:32 +02001202 mtc.stop;
Harald Welteb2917702017-12-10 15:48:52 +01001203 }
Harald Welteae026692017-12-09 01:03:01 +01001204 }
1205 return rx_rsl_ud.rsl;
1206}
1207
Harald Welte21b46bd2017-12-17 19:46:32 +01001208/* helper function to transmit RSL on a given BTS/stream */
Harald Welte65e419a2020-08-21 12:38:33 +02001209function 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 +01001210runs on test_CT {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001211 IPA_RSL[bts_nr].send(ts_ASP_RSL_UD(t_tx, sid));
Harald Welteae026692017-12-09 01:03:01 +01001212}
1213
1214
Harald Welte4003d112017-12-09 22:35:39 +01001215/* verify we get a CHAN_ACT after CHAN RQD */
Harald Welteae026692017-12-09 01:03:01 +01001216testcase TC_chan_act_noreply() runs on test_CT {
1217 var BSSAP_N_UNITDATA_ind ud_ind;
Harald Welte930d0a72018-03-22 22:08:40 +01001218 var RSL_Message rsl_unused;
Harald Welte28d943e2017-11-25 15:00:50 +01001219
Harald Welte89d42e82017-12-17 16:42:41 +01001220 f_init(1);
Harald Welte28d943e2017-11-25 15:00:50 +01001221
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001222 IPA_RSL[0].send(ts_ASP_RSL_UD(ts_RSL_CHAN_RQD('23'O, 23)));
Harald Welte930d0a72018-03-22 22:08:40 +01001223 rsl_unused := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001224 f_shutdown_helper();
Harald Welte28d943e2017-11-25 15:00:50 +01001225}
1226
Harald Welte4003d112017-12-09 22:35:39 +01001227/* verify if the "chreq:total" counter increments as expected */
1228testcase TC_chan_act_counter() runs on test_CT {
1229 var BSSAP_N_UNITDATA_ind ud_ind;
1230 var integer chreq_total;
Harald Welte930d0a72018-03-22 22:08:40 +01001231 var RSL_Message rsl_unused;
Harald Welte4003d112017-12-09 22:35:39 +01001232
Harald Welte89d42e82017-12-17 16:42:41 +01001233 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01001234
1235 chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total");
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001236 IPA_RSL[0].send(ts_ASP_RSL_UD(ts_RSL_CHAN_RQD('23'O, 23)));
Harald Welte930d0a72018-03-22 22:08:40 +01001237 rsl_unused := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
Harald Welte4003d112017-12-09 22:35:39 +01001238 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total", chreq_total+1);
1239
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001240 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01001241}
1242
Harald Welteae026692017-12-09 01:03:01 +01001243/* CHAN RQD -> CHAN ACT -> CHAN ACT ACK -> RF CHAN REL */
Philipp Maier9c60a622020-07-09 15:08:46 +02001244private function f_TC_chan_act_ack_noest(OCT1 ra := '23'O) runs on test_CT {
Harald Welteae026692017-12-09 01:03:01 +01001245 var RSL_Message rx_rsl;
1246
Harald Welteae026692017-12-09 01:03:01 +01001247 /* Send CHAN RQD and wait for allocation; acknowledge it */
Philipp Maier9c60a622020-07-09 15:08:46 +02001248 var RslChannelNr chan_nr := f_chreq_act_ack(ra);
Harald Welteae026692017-12-09 01:03:01 +01001249
1250 /* expect BSC to disable the channel again if there's no RLL EST IND */
1251 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX);
1252
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001253 f_shutdown_helper();
Harald Welteae026692017-12-09 01:03:01 +01001254}
1255
Philipp Maier9c60a622020-07-09 15:08:46 +02001256/* Normal variant */
1257testcase TC_chan_act_ack_noest() runs on test_CT {
Philipp Maieraf58db22020-08-12 17:24:40 +02001258 f_init(1);
Philipp Maier9c60a622020-07-09 15:08:46 +02001259 f_TC_chan_act_ack_noest();
1260}
1261
1262/* Emergency call variant */
1263testcase TC_chan_act_ack_noest_emerg() runs on test_CT {
1264 /* See also: 3GPP TS 04.08, Table 9.9, ra=101xxxxx */
Philipp Maieraf58db22020-08-12 17:24:40 +02001265 f_init(1);
1266 f_vty_allow_emerg_bts(true, 0);
Philipp Maier9c60a622020-07-09 15:08:46 +02001267 f_TC_chan_act_ack_noest(ra := 'A5'O);
1268}
1269
Philipp Maier606f07d2020-08-12 17:21:58 +02001270/* Emergency call variant, but emergency calls are not allowed */
1271testcase TC_chan_rqd_emerg_deny() runs on test_CT {
1272 /* See also: 3GPP TS 04.08, Table 9.9, ra=101xxxxx */
1273
1274 var RSL_Message rx_rsl;
1275 var GsmRrMessage rr;
1276
1277 f_init(1);
1278 f_vty_allow_emerg_bts(false, 0);
1279
1280 IPA_RSL[0].clear;
1281 f_ipa_tx(0, ts_RSL_CHAN_RQD('A5'O, 23));
1282
1283 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeC(RSL_MT_IMMEDIATE_ASSIGN_CMD));
1284 rr := dec_GsmRrMessage(rx_rsl.ies[1].body.full_imm_ass_info.payload);
1285 if (rr.header.message_type == IMMEDIATE_ASSIGNMENT_REJECT) {
1286 setverdict(pass);
1287 } else {
1288 setverdict(fail, "immediate assignment not rejected");
1289 }
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01001290
1291 f_shutdown_helper();
Philipp Maier606f07d2020-08-12 17:21:58 +02001292}
1293
Harald Welteae026692017-12-09 01:03:01 +01001294/* Test behavior if MSC never answers to CR */
1295testcase TC_chan_act_ack_est_ind_noreply() runs on test_CT {
Harald Weltef77aef62018-01-28 15:35:42 +01001296 var RslLinkId main_dcch := valueof(ts_RslLinkID_DCCH(0));
1297 var IpaStreamId sid := IPAC_PROTO_RSL_TRX0;
Harald Welteae026692017-12-09 01:03:01 +01001298 var RSL_Message rx_rsl;
Harald Weltef77aef62018-01-28 15:35:42 +01001299 var ASP_RSL_Unitdata rx_rsl_ud;
Harald Welteae026692017-12-09 01:03:01 +01001300
Harald Welte89d42e82017-12-17 16:42:41 +01001301 f_init(1);
Harald Welteae026692017-12-09 01:03:01 +01001302
1303 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +01001304 var RslChannelNr chan_nr := f_chreq_act_ack();
Harald Welteae026692017-12-09 01:03:01 +01001305
1306 var octetstring l3 := '00010203040506'O
1307 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
1308
1309 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3)));
1310
1311 /* expect BSC to disable the channel again if there's no response from MSC */
Harald Weltef77aef62018-01-28 15:35:42 +01001312 /* MS waits 20s (T3210) at LU; 10s (T3230) at CM SERV REQ and 5s (T3220) AT detach */
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001313 f_expect_chan_rel(0, chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001314 f_shutdown_helper();
Harald Welteae026692017-12-09 01:03:01 +01001315}
1316
1317/* Test behavior if MSC answers with CREF to CR */
1318testcase TC_chan_act_ack_est_ind_refused() runs on test_CT {
1319 var BSSAP_N_CONNECT_ind rx_c_ind;
1320 var RSL_Message rx_rsl;
1321
Harald Welte89d42e82017-12-17 16:42:41 +01001322 f_init(1);
Harald Welteae026692017-12-09 01:03:01 +01001323
1324 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +01001325 var RslChannelNr chan_nr := f_chreq_act_ack();
Harald Welteae026692017-12-09 01:03:01 +01001326
1327 var octetstring l3 := '00010203040506'O
1328 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
1329
1330 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
1331 BSSAP.send(ts_BSSAP_DISC_req(rx_c_ind.connectionId, 0));
1332
1333 /* expect BSC to disable the channel */
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001334 f_expect_chan_rel(0, chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001335 f_shutdown_helper();
Harald Welteae026692017-12-09 01:03:01 +01001336}
1337
Harald Welte618ef642017-12-14 14:58:20 +01001338/* CHAN RQD -> CHAN ACT -> CHAN ACT NACK -> RF CHAN REL */
1339testcase TC_chan_act_nack() runs on test_CT {
1340 var RSL_Message rx_rsl;
1341 var integer chact_nack;
1342
Harald Welte89d42e82017-12-17 16:42:41 +01001343 f_init(1);
Harald Welte618ef642017-12-14 14:58:20 +01001344
1345 chact_nack := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chan_act:nack");
1346
1347 f_ipa_tx(0, ts_RSL_CHAN_RQD('33'O, 33));
1348 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
1349 var RslChannelNr chan_nr := rx_rsl.ies[0].body.chan_nr;
1350
1351 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, RSL_ERR_EQUIPMENT_FAIL));
1352
1353 /* wait for some time to hope the NACK arrives before the CTRL GET below */
1354 f_sleep(0.5);
1355
1356 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chan_act:nack", chact_nack+1);
1357
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001358 f_shutdown_helper();
Harald Welte618ef642017-12-14 14:58:20 +01001359}
1360
Harald Welte799c97b2017-12-14 17:50:30 +01001361/* Test for channel exhaustion due to RACH overload */
1362testcase TC_chan_exhaustion() runs on test_CT {
1363 var ASP_RSL_Unitdata rsl_ud;
1364 var integer i;
1365 var integer chreq_total, chreq_nochan;
1366
Harald Welte89d42e82017-12-17 16:42:41 +01001367 f_init(1);
Harald Welte799c97b2017-12-14 17:50:30 +01001368
1369 chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total");
1370 chreq_nochan := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel");
1371
Pau Espin Pedrolfe200d72018-12-10 12:41:04 +01001372 /* GSM 04.08 Table 9.9a:
1373 * RA = '33'O -> Establishment cause = 0011xxxx (MS dual rate capable and asks for "TCH/H or TCH/F").
1374 * With current setup, expect 4xSDCCH + 4xTCH/F + 1xTCH/H to succeed */
Philipp Maiercb6cc482018-03-26 13:08:00 +02001375 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 +01001376 var RslChannelNr chan_nr := f_chreq_act_ack('33'O, i);
Harald Welte799c97b2017-12-14 17:50:30 +01001377 }
1378
1379 IPA_RSL[0].clear;
1380
Harald Weltedd8cbf32018-01-28 12:07:52 +01001381 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total",
Philipp Maiercb6cc482018-03-26 13:08:00 +02001382 chreq_total + NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS);
Harald Welte799c97b2017-12-14 17:50:30 +01001383
1384 /* now expect additional channel activations to fail */
1385 f_ipa_tx(0, ts_RSL_CHAN_RQD('42'O, 42));
1386
1387 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001388 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV))) {
Harald Welte799c97b2017-12-14 17:50:30 +01001389 setverdict(fail, "Received CHAN ACT ACK without resources?!?");
1390 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001391 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_IMM_ASSIGN(?))) -> value rsl_ud {
Harald Welte799c97b2017-12-14 17:50:30 +01001392 var GsmRrMessage rr;
1393 /* match on IMM ASS REJ */
1394 rr := dec_GsmRrMessage(rsl_ud.rsl.ies[1].body.full_imm_ass_info.payload);
1395 if (rr.header.message_type == IMMEDIATE_ASSIGNMENT_REJECT) {
1396 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total",
Philipp Maiercb6cc482018-03-26 13:08:00 +02001397 chreq_total + NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS+1);
Harald Welte799c97b2017-12-14 17:50:30 +01001398 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel",
1399 chreq_nochan+1);
1400 setverdict(pass);
1401 } else {
1402 repeat;
1403 }
1404 }
1405 [] IPA_RSL[0].receive { repeat; }
1406 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001407 f_shutdown_helper();
Harald Welte799c97b2017-12-14 17:50:30 +01001408}
1409
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07001410/* Test channel deactivation due to silence from MS */
1411testcase TC_chan_deact_silence() runs on test_CT {
1412 var RslChannelNr chan_nr;
1413
1414 f_init(1);
1415
1416 /* Request for a dedicated channel */
1417 chan_nr := f_chreq_act_ack('23'O);
1418
1419 /* Wait some time until the channel is released */
1420 f_sleep(2.0);
1421
1422 /* Expect CHANnel RELease */
1423 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001424 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL))) {
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07001425 log("Received CHANnel RELease");
1426 setverdict(pass);
1427 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001428 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_IMM_ASSIGN(?))) {
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07001429 /* See OS#3709, OsmoBSC should not send Immediate
1430 * Assignment Reject since a dedicated channel was
1431 * already allocated, and Immediate Assignment was
1432 * already sent. */
1433 setverdict(fail, "Unexpected Immediate Assignment!");
1434 }
1435 [] IPA_RSL[0].receive {
1436 setverdict(fail, "Unexpected RSL message!");
1437 }
1438 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001439 f_shutdown_helper();
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07001440}
1441
Harald Weltecfe2c962017-12-15 12:09:32 +01001442/***********************************************************************
1443 * Assignment Testing
1444 ***********************************************************************/
1445
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02001446/* Verify that the BSC refuses any BSSAP connection from the MSC (They are all BSC->MSC direction,
1447 * except for the inter-BSC handover, MT side) */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001448testcase TC_outbound_connect(integer bssap_idx := 0) runs on test_CT {
Harald Welte89d42e82017-12-17 16:42:41 +01001449 f_init(1);
Harald Weltecfe2c962017-12-15 12:09:32 +01001450
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001451 BSSAP.send(ts_BSSAP_CONNECT_req(g_bssap[bssap_idx].sccp_addr_peer, g_bssap[bssap_idx].sccp_addr_own,
1452 2342, ts_BSSMAP_AssignmentReq));
Harald Weltecfe2c962017-12-15 12:09:32 +01001453 BSSAP.receive(tr_BSSAP_DISC_ind(2342, ?, ?));
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001454 f_shutdown_helper();
Harald Weltecfe2c962017-12-15 12:09:32 +01001455}
1456
Harald Welte16a4adf2017-12-14 18:54:01 +01001457/* Test behavior if MSC answers with CREF to CR */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001458testcase TC_assignment_cic_only(integer bssap_idx := 0) runs on test_CT {
Harald Welte16a4adf2017-12-14 18:54:01 +01001459 var BSSAP_N_CONNECT_ind rx_c_ind;
1460 var RSL_Message rx_rsl;
1461 var DchanTuple dt;
1462
Harald Welte89d42e82017-12-17 16:42:41 +01001463 f_init(1);
Harald Welte16a4adf2017-12-14 18:54:01 +01001464
1465 dt := f_est_dchan('23'O, 23, '00000000'O);
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001466 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welte17b27da2018-05-25 20:33:53 +02001467 /* send assignment without AoIP IEs */
1468 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_AssignmentReq(ts_BSSMAP_IE_CIC(0, 1))));
1469 } else {
1470 /* Send assignmetn without CIC in IPA case */
1471 var BSSMAP_IE_AoIP_TransportLayerAddress tla :=
1472 valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342));
1473 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_AssignmentReq(omit, tla)));
1474 }
Harald Welte16a4adf2017-12-14 18:54:01 +01001475 alt {
1476 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentComplete)) {
1477 setverdict(fail, "AoIP BSC cannot accept ASSIGNMENT without AoIP Transport IE");
1478 }
Harald Welte235ebf12017-12-15 14:18:16 +01001479 /* TODO: Actually expect GSM0808_CAUSE_REQ_A_IF_TYPE_NOT_SUPP */
Harald Welte16a4adf2017-12-14 18:54:01 +01001480 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentFail)) {
1481 setverdict(pass);
1482 }
1483 [] BSSAP.receive { repeat; }
1484 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001485 f_shutdown_helper();
Harald Welte16a4adf2017-12-14 18:54:01 +01001486}
1487
Harald Welteed848512018-05-24 22:27:58 +02001488/* generate an assignment request for either AoIP or SCCPlite */
Pau Espin Pedrol07866632020-09-03 19:10:55 +02001489function 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 +02001490 var PDU_BSSAP ass_cmd;
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001491 var BSSMAP_IE_Osmo_OsmuxCID osmux_cid := valueof(ts_OsmuxCID(0));
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001492 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welteed848512018-05-24 22:27:58 +02001493 var BSSMAP_IE_AoIP_TransportLayerAddress tla :=
Pau Espin Pedrol07866632020-09-03 19:10:55 +02001494 valueof(f_ts_BSSMAP_IE_AoIP_TLA(aoip_tla, 2342));
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001495 if (osmux_enabled) {
1496 ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla, osmux_cid));
1497 } else {
1498 ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla));
1499 }
Harald Welteed848512018-05-24 22:27:58 +02001500 } else {
1501 var BSSMAP_IE_CircuitIdentityCode cic := valueof(ts_BSSMAP_IE_CIC(0,1));
Pau Espin Pedrol096d73d2019-06-06 12:49:17 +02001502 ass_cmd := valueof(ts_BSSMAP_AssignmentReq(cic, omit));
Harald Welteed848512018-05-24 22:27:58 +02001503 }
1504 return ass_cmd;
1505}
1506
Pau Espin Pedrol07866632020-09-03 19:10:55 +02001507function f_gen_handover_req(integer bssap_idx := 0, charstring aoip_tla := "1.2.3.4") return PDU_BSSAP {
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01001508 var PDU_BSSAP ho_req;
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001509 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01001510 var BSSMAP_IE_AoIP_TransportLayerAddress tla :=
Pau Espin Pedrol07866632020-09-03 19:10:55 +02001511 valueof(f_ts_BSSMAP_IE_AoIP_TLA(aoip_tla, 2342));
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01001512 ho_req := valueof(ts_BSSMAP_HandoverRequest(omit, tla));
1513 } else {
1514 var BSSMAP_IE_CircuitIdentityCode cic := valueof(ts_BSSMAP_IE_CIC(0,1));
1515 ho_req := valueof(ts_BSSMAP_HandoverRequest(cic, omit));
1516 }
1517 return ho_req;
1518}
1519
Harald Welteed848512018-05-24 22:27:58 +02001520/* generate an assignment complete template for either AoIP or SCCPlite */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001521function f_gen_exp_compl(boolean expect_osmux := false, integer bssap_idx := 0) return template PDU_BSSAP {
Harald Welteed848512018-05-24 22:27:58 +02001522 var template PDU_BSSAP exp_compl;
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001523 var BSSMAP_IE_Osmo_OsmuxCID osmux_cid := valueof(ts_OsmuxCID(0));
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001524 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001525 if (expect_osmux) {
1526 exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?, osmux_cid);
1527 } else {
1528 exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?, omit);
1529 }
Harald Welteed848512018-05-24 22:27:58 +02001530 } else {
1531 /* CIC is optional "*" as the MSC allocated it */
Pau Espin Pedrol096d73d2019-06-06 12:49:17 +02001532 exp_compl := tr_BSSMAP_AssignmentComplete(*, omit);
Harald Welteed848512018-05-24 22:27:58 +02001533 }
1534 return exp_compl;
1535}
1536
Harald Welte235ebf12017-12-15 14:18:16 +01001537/* Run everything required up to sending a caller-specified assignment command and expect response */
1538function f_assignment_exp(PDU_BSSAP ass_cmd, template PDU_BSSAP exp, charstring fail_text)
1539runs on test_CT {
1540 var BSSAP_N_CONNECT_ind rx_c_ind;
1541 var RSL_Message rx_rsl;
1542 var DchanTuple dt;
1543
Harald Welte89d42e82017-12-17 16:42:41 +01001544 f_init(1);
Harald Welte235ebf12017-12-15 14:18:16 +01001545
1546 dt := f_est_dchan('23'O, 23, '00000000'O);
1547 /* send assignment without AoIP IEs */
1548 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ass_cmd));
1549 alt {
1550 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentComplete)) {
1551 if (ischosen(exp.pdu.bssmap.assignmentComplete)) {
1552 setverdict(pass);
1553 } else {
1554 setverdict(fail, fail_text);
1555 }
1556 }
1557 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentFail)) {
1558 if (ischosen(exp.pdu.bssmap.assignmentFailure)) {
1559 setverdict(pass);
1560 } else {
1561 setverdict(fail, fail_text);
1562 }
1563 }
1564 [] BSSAP.receive { repeat; }
1565 }
1566}
1567testcase TC_assignment_csd() runs on test_CT {
1568 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +02001569 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte235ebf12017-12-15 14:18:16 +01001570 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeCSD);
1571 //exp_fail.pdu.bssmap.assignmentFailure.cause.causeValue := int2bit(enum2int(GSM0808_CAUSE_REQ_CODEC_TYPE_OR_CONFIG_UNAVAIL), 7);
1572 f_assignment_exp(ass_cmd, exp_fail, "BSC accepted Assignment for CSD");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001573 f_shutdown_helper();
Harald Welte235ebf12017-12-15 14:18:16 +01001574}
1575
1576testcase TC_assignment_ctm() runs on test_CT {
1577 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +02001578 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte235ebf12017-12-15 14:18:16 +01001579 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeCTM);
1580 //exp_fail.pdu.bssmap.assignmentFailure.cause.causeValue := int2bit(enum2int(GSM0808_CAUSE_REQ_CODEC_TYPE_OR_CONFIG_UNAVAIL), 7);
1581 f_assignment_exp(ass_cmd, exp_fail, "BSC accepted Assignment for Speech+CTM");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001582 f_shutdown_helper();
Harald Welte235ebf12017-12-15 14:18:16 +01001583}
1584
Harald Welte4003d112017-12-09 22:35:39 +01001585type record DchanTuple {
1586 integer sccp_conn_id,
1587 RslChannelNr rsl_chan_nr
Harald Weltea5d2ab22017-12-09 14:21:42 +01001588}
1589
Harald Welted6939652017-12-13 21:02:46 +01001590/* Send CHAN RQD and wait for allocation; acknowledge it */
1591private function f_chreq_act_ack(OCT1 ra := '23'O, GsmFrameNumber fn := 23)
1592runs on test_CT return RslChannelNr {
1593 var RSL_Message rx_rsl;
1594 f_ipa_tx(0, ts_RSL_CHAN_RQD(ra, fn));
1595 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
1596 var RslChannelNr chan_nr := rx_rsl.ies[0].body.chan_nr;
1597 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, fn+10));
Daniel Willmannf4ac4ce2018-08-02 14:06:30 +02001598 rx_rsl := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
Harald Welted6939652017-12-13 21:02:46 +01001599 return chan_nr;
1600}
1601
Harald Welte4003d112017-12-09 22:35:39 +01001602/* helper function to establish a dedicated channel via BTS and MSC */
1603function f_est_dchan(OCT1 ra, GsmFrameNumber fn, octetstring l3)
1604runs on test_CT return DchanTuple {
1605 var BSSAP_N_CONNECT_ind rx_c_ind;
Harald Welte4003d112017-12-09 22:35:39 +01001606 var DchanTuple dt;
Harald Weltea5d2ab22017-12-09 14:21:42 +01001607
Harald Welte4003d112017-12-09 22:35:39 +01001608 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +01001609 dt.rsl_chan_nr := f_chreq_act_ack(ra, fn);
Harald Welte4003d112017-12-09 22:35:39 +01001610
1611 f_ipa_tx(0, ts_RSL_EST_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
1612
1613 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
1614 dt.sccp_conn_id := rx_c_ind.connectionId;
1615 BSSAP.send(ts_BSSAP_CONNECT_res(dt.sccp_conn_id));
1616
1617 return dt;
Harald Weltea5d2ab22017-12-09 14:21:42 +01001618}
1619
Harald Welte641fcbe2018-06-14 10:58:35 +02001620/* expect RF CAN REL from BTS, acknowledge it and clear the MSC side */
1621private function f_exp_chan_rel_and_clear(DchanTuple dt, integer bts_nr := 0) runs on test_CT {
1622 var RSL_Message rx_rsl;
1623 /* expect BSC to disable the channel */
1624 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX);
1625 /* respond with CHAN REL ACK */
1626 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
1627
1628 /* expect Clear Complete from BSC */
1629 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete));
1630
1631 /* MSC disconnects as instructed. */
1632 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1633}
1634
Harald Welte4003d112017-12-09 22:35:39 +01001635/* Test behavior of channel release after unilateral RLL REL IND (DISC from MS) */
1636testcase TC_chan_rel_rll_rel_ind() runs on test_CT {
Neels Hofmeyr27f64362018-03-12 01:44:00 +01001637 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +01001638 var DchanTuple dt;
Harald Welte96c94412017-12-09 03:12:45 +01001639
Harald Welte89d42e82017-12-17 16:42:41 +01001640 f_init(1);
Harald Welte96c94412017-12-09 03:12:45 +01001641
Harald Welte4003d112017-12-09 22:35:39 +01001642 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1643
1644 /* simulate RLL REL IND */
1645 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0))));
1646
Neels Hofmeyr27f64362018-03-12 01:44:00 +01001647 /* expect Clear Request on MSC side */
1648 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
1649
1650 /* Instruct BSC to clear channel */
1651 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
1652 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
1653
Harald Welte4003d112017-12-09 22:35:39 +01001654 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02001655 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyr27f64362018-03-12 01:44:00 +01001656
1657 /* wait for SCCP emulation to do its job */
1658 f_sleep(1.0);
Harald Welte4003d112017-12-09 22:35:39 +01001659
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001660 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01001661}
1662
1663/* Test behavior of channel release after CONN FAIL IND from BTS */
1664testcase TC_chan_rel_conn_fail() runs on test_CT {
1665 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +01001666 var DchanTuple dt;
1667
Harald Welte89d42e82017-12-17 16:42:41 +01001668 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01001669
1670 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1671
1672 /* simulate CONN FAIL IND */
Harald Weltea8ed9062017-12-14 09:46:01 +01001673 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 +01001674 /* TODO: different cause values? */
1675
Harald Welte4003d112017-12-09 22:35:39 +01001676 /* expect Clear Request from BSC */
1677 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
1678
1679 /* Instruct BSC to clear channel */
1680 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
1681 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
1682
Harald Welte6ff76ea2018-01-28 13:08:01 +01001683 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02001684 f_exp_chan_rel_and_clear(dt, 0);
Harald Welte4003d112017-12-09 22:35:39 +01001685
1686 /* wait for SCCP emulation to do its job */
1687 f_sleep(1.0);
1688
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001689 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01001690}
1691
Harald Welte99f3ca02018-06-14 13:40:29 +02001692/* Test behavior of early CONN FAIL IND from BTS (before EST IND!) */
1693/* See also https://www.osmocom.org/issues/3182 */
1694testcase TC_early_conn_fail() runs on test_CT {
1695 var RSL_Message rx_rsl;
1696 var DchanTuple dt;
1697
1698 f_init(1);
1699
1700 /* BTS->BSC: Send CHAN RQD and wait for allocation; acknowledge it */
Harald Weltec46ea3c2020-10-10 18:46:12 +02001701 dt.rsl_chan_nr := f_chreq_act_ack(f_rnd_ra_cs(), 23);
Harald Welte99f3ca02018-06-14 13:40:29 +02001702
1703 /* BTS->BSC: simulate CONN FAIL IND */
1704 f_ipa_tx(0, ts_RSL_CONN_FAIL_IND(dt.rsl_chan_nr, RSL_ERR_RADIO_LINK_FAIL));
1705
1706 /* BTS->BSC: Expect RF channel release from BSC on Abis */
1707 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), 10.0);
1708
1709 /* BTS<-BSC: respond with CHAN REL ACK */
1710 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
1711
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001712 f_shutdown_helper();
Harald Welte99f3ca02018-06-14 13:40:29 +02001713}
1714
1715/* Test behavior of late CONN FAIL IND from BTS (ater REL IND!) */
1716/* See also https://www.osmocom.org/issues/3182 */
1717testcase TC_late_conn_fail() runs on test_CT {
1718 var RSL_Message rx_rsl;
1719 var DchanTuple dt;
1720
1721 f_init(1);
1722
1723 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1724
1725 /* BSC<-MSC: Instruct BSC to clear connection */
1726 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(0)));
1727
1728 /* BTS->BSC: expect BSC to deactivate SACCH */
1729 rx_rsl := f_exp_ipa_rx(0, tr_RSL_DEACT_SACCH(dt.rsl_chan_nr));
1730
1731 /* BTS->BSC: simulate a late CONN FAIL IND from BTS */
1732 f_ipa_tx(0, ts_RSL_CONN_FAIL_IND(dt.rsl_chan_nr, RSL_ERR_RADIO_LINK_FAIL));
1733
1734 /* BTS<-BSC: Expect RF channel release from BSC on Abis */
1735 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), 10.0);
1736 /* BTS->BSC: respond with CHAN REL ACK */
1737 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
1738
1739 /* BSC->MSC: expect Clear Complete from BSC */
1740 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete));
1741
1742 /* BSC<-MSC: MSC disconnects as requested. */
1743 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1744
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001745 f_shutdown_helper();
Harald Welte99f3ca02018-06-14 13:40:29 +02001746}
1747
Neels Hofmeyrf44ccd12018-11-05 19:15:23 +01001748function f_expect_chan_rel(integer bts_nr, RslChannelNr rsl_chan_nr,
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001749 boolean expect_deact_sacch := true,
1750 boolean expect_rr_chan_rel := true,
1751 boolean expect_rll_rel_req := true,
Harald Welte99787102019-02-04 10:41:36 +01001752 boolean handle_rll_rel := true,
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001753 boolean is_csfb := false,
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001754 template CellSelIndValue csfb_expect_cells := omit,
1755 template RR_Cause expect_rr_cause := ?
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001756 ) runs on test_CT {
Harald Welte91d54a52018-01-28 15:35:07 +01001757
1758 var RslLinkId main_dcch := valueof(ts_RslLinkID_DCCH(0));
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001759 var boolean got_deact_sacch := false;
1760 var boolean got_rr_chan_rel := false;
1761 var boolean got_rll_rel_req := false;
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001762 var ASP_RSL_Unitdata ud;
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001763 var RSL_IE_Body l3_ie;
1764 var PDU_ML3_NW_MS l3;
1765 var RR_Cause got_cause;
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001766 log("f_expect_chan_rel() expecting: expect_deact_sacch=", expect_deact_sacch, " expect_rr_chan_rel=", expect_rr_chan_rel,
1767 " expect_rll_rel_req=", expect_rll_rel_req);
Harald Welte91d54a52018-01-28 15:35:07 +01001768 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001769 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_DEACT_SACCH(rsl_chan_nr))) {
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001770 got_deact_sacch := true;
Harald Welte91d54a52018-01-28 15:35:07 +01001771 repeat;
1772 }
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001773 [is_csfb] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_DATA_REQ(rsl_chan_nr, ?, decmatch tr_RRM_RR_RELEASE_CSFB))) -> value ud {
Harald Welte99787102019-02-04 10:41:36 +01001774 got_rr_chan_rel := true;
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001775
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001776 if (f_rsl_find_ie(ud.rsl, RSL_IE_L3_INFO, l3_ie) == false) {
1777 setverdict(fail, "cannot find L3");
1778 mtc.stop;
1779 }
1780 l3 := dec_PDU_ML3_NW_MS(l3_ie.l3_info.payload);
1781
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001782 if (not istemplatekind(csfb_expect_cells, "omit")) {
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001783 var CellSelIndValue cells := dec_CellSelIndValue(
1784 l3.msgs.rrm.channelRelease.cellSelectionIndicator.cellSelectionIndicatorValue);
1785
1786 log("GOT RR CHANNEL RELEASE CSFB CELLS: ", cells);
1787 if (match(cells, csfb_expect_cells)) {
1788 setverdict(pass);
1789 } else {
1790 log("EXPECTED CSFB CELLS: ", csfb_expect_cells);
1791 setverdict(fail, "Received CSFB cells list on RR Channel Release does not match expectations");
1792 }
1793 }
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001794
1795 if (not istemplatekind(expect_rr_cause, "omit")) {
1796 int2enum(oct2int(l3.msgs.rrm.channelRelease.rRCause.valuePart), got_cause);
1797 log("GOT CAUSE CODE: ", l3.msgs.rrm.channelRelease.rRCause.valuePart, " = ", got_cause);
1798 if (match(got_cause, expect_rr_cause)) {
1799 setverdict(pass);
1800 } else {
1801 log("EXPECTED CAUSE CODE: ", expect_rr_cause);
1802 setverdict(fail, "Received RR Channel Release Cause code does not match expectations");
1803 }
1804 }
Harald Welte99787102019-02-04 10:41:36 +01001805 repeat;
1806 }
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001807 [not is_csfb] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_DATA_REQ(rsl_chan_nr, ?, decmatch tr_RRM_RR_RELEASE))) -> value ud {
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001808 got_rr_chan_rel := true;
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001809
1810 if (not istemplatekind(expect_rr_cause, "omit")) {
1811 if (f_rsl_find_ie(ud.rsl, RSL_IE_L3_INFO, l3_ie) == false) {
1812 setverdict(fail, "cannot find L3");
1813 mtc.stop;
1814 }
1815 l3 := dec_PDU_ML3_NW_MS(l3_ie.l3_info.payload);
1816
1817 int2enum(oct2int(l3.msgs.rrm.channelRelease.rRCause.valuePart), got_cause);
1818 log("GOT CAUSE CODE: ", l3.msgs.rrm.channelRelease.rRCause.valuePart, " = ", got_cause);
1819 if (match(got_cause, expect_rr_cause)) {
1820 setverdict(pass);
1821 } else {
1822 log("EXPECTED CAUSE CODE: ", expect_rr_cause);
1823 setverdict(fail, "Received RR Channel Release Cause code does not match expectations");
1824 }
1825 }
Neels Hofmeyr211169d2018-11-07 00:37:29 +01001826 repeat;
1827 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001828 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_REL_REQ(rsl_chan_nr, ?))) {
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001829 got_rll_rel_req := true;
Harald Welte91d54a52018-01-28 15:35:07 +01001830 /* FIXME: Why are we getting this for LinkID SACCH? */
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001831 if (handle_rll_rel) {
1832 f_ipa_tx(0, ts_RSL_REL_CONF(rsl_chan_nr, main_dcch));
1833 }
Harald Welte91d54a52018-01-28 15:35:07 +01001834 repeat;
1835 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001836 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL))) {
Harald Welte91d54a52018-01-28 15:35:07 +01001837 /* respond with CHAN REL ACK */
1838 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(rsl_chan_nr));
1839 }
1840 /* ignore any user data */
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001841 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeR(?))) {
Harald Welte91d54a52018-01-28 15:35:07 +01001842 repeat;
1843 }
1844 }
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001845
1846 log("f_expect_chan_rel() summary: got_deact_sacch=", got_deact_sacch, " got_rr_chan_rel=", got_rr_chan_rel,
1847 " got_rll_rel_req=", got_rll_rel_req);
1848
1849 if (expect_deact_sacch != got_deact_sacch) {
1850 setverdict(fail, "f_expect_chan_rel(): expect_deact_sacch=", expect_deact_sacch, " got_deact_sacch=", got_deact_sacch);
1851 }
1852 if (expect_rr_chan_rel != got_rr_chan_rel) {
1853 setverdict(fail, "f_expect_chan_rel(): expect_rr_chan_rel=", expect_rr_chan_rel, " got_rr_chan_rel=", got_rr_chan_rel);
1854 }
1855 if (expect_rll_rel_req != got_rll_rel_req) {
1856 setverdict(fail, "f_expect_chan_rel(): expect_rll_rel_req=", expect_rll_rel_req, " got_rll_rel_req=", got_rll_rel_req);
1857 }
Harald Welte91d54a52018-01-28 15:35:07 +01001858}
1859
Harald Welte4003d112017-12-09 22:35:39 +01001860/* Test behavior of channel release after hard Clear Command from MSC */
1861testcase TC_chan_rel_hard_clear() runs on test_CT {
1862 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +01001863 var DchanTuple dt;
Harald Welte4003d112017-12-09 22:35:39 +01001864
Harald Welte89d42e82017-12-17 16:42:41 +01001865 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01001866
1867 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1868
1869 /* Instruct BSC to clear channel */
1870 var BssmapCause cause := 0;
1871 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
1872
1873 /* expect Clear Complete from BSC on A */
1874 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
1875 /* release the SCCP connection */
1876 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1877 }
1878
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001879 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001880 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01001881}
1882
Harald Welte99787102019-02-04 10:41:36 +01001883/* Test behavior of channel release after Clear Command with CSFB indicator from MSC */
1884testcase TC_chan_rel_hard_clear_csfb() runs on test_CT {
1885 var BSSAP_N_DATA_ind rx_di;
1886 var DchanTuple dt;
1887
1888 f_init(1);
1889
1890 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1891
1892 /* Instruct BSC to clear channel */
1893 var BssmapCause cause := 0;
1894 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommandCSFB(cause)));
1895
1896 /* expect Clear Complete from BSC on A */
1897 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
1898 /* release the SCCP connection */
1899 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1900 }
1901
1902 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false, is_csfb := true);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001903 f_shutdown_helper();
Harald Welte99787102019-02-04 10:41:36 +01001904}
1905
Harald Welted8c36cd2017-12-09 23:05:31 +01001906/* Test behavior of channel release after hard RLSD from MSC */
1907testcase TC_chan_rel_hard_rlsd() runs on test_CT {
Harald Welted8c36cd2017-12-09 23:05:31 +01001908 var DchanTuple dt;
Harald Welted8c36cd2017-12-09 23:05:31 +01001909
Harald Welte89d42e82017-12-17 16:42:41 +01001910 f_init(1);
Harald Welted8c36cd2017-12-09 23:05:31 +01001911
1912 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1913
1914 /* release the SCCP connection */
1915 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1916
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001917 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001918 f_shutdown_helper();
Harald Welted8c36cd2017-12-09 23:05:31 +01001919}
1920
Harald Welte550daf92018-06-11 19:22:13 +02001921/* Test behavior of channel release after hard RLSD from MSC and MS is not responding to RLL REL REQ */
1922testcase TC_chan_rel_hard_rlsd_ms_dead() runs on test_CT {
1923 var DchanTuple dt;
1924
1925 f_init(1);
1926
1927 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1928
1929 /* release the SCCP connection */
1930 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1931
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001932 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001933 f_shutdown_helper();
Harald Welte550daf92018-06-11 19:22:13 +02001934}
1935
Harald Welte85804d42017-12-10 14:11:58 +01001936/* Test behavior of channel release after BSSMAP RESET from MSC */
1937testcase TC_chan_rel_a_reset() runs on test_CT {
Harald Welte85804d42017-12-10 14:11:58 +01001938 var DchanTuple dt;
Harald Welte85804d42017-12-10 14:11:58 +01001939
Harald Welte89d42e82017-12-17 16:42:41 +01001940 f_init(1);
Harald Welte85804d42017-12-10 14:11:58 +01001941
1942 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1943
1944 /* Clear the queue, it might still contain stuff like IMMEDIATE ASSIGN */
1945 IPA_RSL[0].clear;
1946
1947 /* perform BSSAP RESET, expect RESET ACK and DISC.ind on connection */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001948 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 +01001949 interleave {
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001950 [] 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 +01001951 [] BSSAP.receive(tr_BSSAP_DISC_ind(dt.sccp_conn_id, ?, ?)) { }
1952 }
1953
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001954 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 Welte85804d42017-12-10 14:11:58 +01001956}
1957
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01001958/* Verify T(iar) triggers and releases the channel */
1959testcase TC_chan_rel_sccp_tiar_timeout() runs on test_CT {
1960 var DchanTuple dt;
1961
1962 /* Set T(iar) in BSC low enough that it will trigger before other side
1963 has time to keep alive with a T(ias). Keep recommended ratio of
1964 T(iar) >= T(ias)*2 */
1965 g_bsc_sccp_timer_ias := 2;
1966 g_bsc_sccp_timer_iar := 5;
1967
1968 f_init(1);
1969
1970 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1971 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001972 f_shutdown_helper();
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01001973}
1974
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001975private function f_tc_chan_rel_rr_cause(myBSSMAP_Cause clear_cmd_cause, template RR_Cause expect_rr_cause)
1976runs on test_CT
1977{
1978 var DchanTuple dt;
1979
1980 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1981 var BssmapCause cause := 0;
1982 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(enum2int(clear_cmd_cause))));
1983 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
1984 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1985 }
1986
1987 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 +02001988}
1989
1990/* Test that Clear Command cause codes affect the RR Channel Release cause code */
1991testcase TC_chan_rel_rr_cause() runs on test_CT {
1992 f_init(1);
1993
1994 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_CALL_CONTROL, GSM48_RR_CAUSE_NORMAL);
1995 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_HANDOVER_SUCCESSFUL, GSM48_RR_CAUSE_NORMAL);
1996 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_PREEMPTION, GSM48_RR_CAUSE_PREMPTIVE_REL);
1997 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_RADIO_INTERFACE_MESSAGE_FAILURE, GSM48_RR_CAUSE_PROT_ERROR_UNSPC);
1998 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_RADIO_INTERFACE_FAILURE, GSM48_RR_CAUSE_ABNORMAL_UNSPEC);
1999 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_EQUIPMENT_FAILURE, GSM48_RR_CAUSE_ABNORMAL_UNSPEC);
Vadim Yanitskiye18aebb2021-01-03 13:10:43 +01002000
2001 f_shutdown_helper();
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02002002}
2003
Harald Welte5cd20ed2017-12-13 21:03:20 +01002004/* Test behavior if RSL EST IND for non-active channel */
2005testcase TC_rll_est_ind_inact_lchan() runs on test_CT {
2006 timer T := 2.0;
2007
Harald Welte89d42e82017-12-17 16:42:41 +01002008 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01002009
2010 var octetstring l3 := '00010203040506'O;
2011 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
2012 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
2013
2014 T.start;
2015 alt {
2016 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
2017 setverdict(fail, "MSC received COMPL L3 for non-active lchan");
2018 }
2019 [] BSSAP.receive {}
2020 [] IPA_RSL[0].receive {}
2021 [] T.timeout {}
2022 }
2023
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002024 f_shutdown_helper();
Harald Welte5cd20ed2017-12-13 21:03:20 +01002025}
2026
2027/* Test behavior if RSL EST IND for invalid SAPI */
2028testcase TC_rll_est_ind_inval_sapi1() runs on test_CT {
2029 var RslChannelNr chan_nr;
2030
Harald Welte89d42e82017-12-17 16:42:41 +01002031 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01002032
2033 chan_nr := f_chreq_act_ack()
2034
2035 var octetstring l3 := '00010203040506'O;
2036 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(1)), l3));
2037
2038 timer T := 2.0;
2039 T.start;
2040 alt {
2041 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
2042 setverdict(fail, "MSC received COMPL L3 for invalid SAPI 1");
2043 }
2044 [] BSSAP.receive { repeat; }
2045 [] IPA_RSL[0].receive { repeat; }
2046 [] T.timeout {}
2047 }
2048
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002049 f_shutdown_helper();
Harald Welte5cd20ed2017-12-13 21:03:20 +01002050}
2051
2052/* Test behavior if RSL EST IND for invalid SAPI */
2053testcase TC_rll_est_ind_inval_sapi3() runs on test_CT {
2054 timer T := 2.0;
2055
Harald Welte89d42e82017-12-17 16:42:41 +01002056 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01002057
2058 var RslChannelNr chan_nr := f_chreq_act_ack();
2059
2060 var octetstring l3 := '00010203040506'O;
2061 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(3)), l3));
2062
2063 T.start;
2064 alt {
2065 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
2066 setverdict(fail, "MSC received COMPL L3 for invalid SAPI 3");
2067 }
2068 [] BSSAP.receive { repeat; }
2069 [] IPA_RSL[0].receive { repeat; }
2070 [] T.timeout {}
2071 }
2072
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002073 f_shutdown_helper();
Harald Welte5cd20ed2017-12-13 21:03:20 +01002074}
2075
2076/* Test behavior if RSL EST IND for invalid SACCH */
2077testcase TC_rll_est_ind_inval_sacch() runs on test_CT {
2078 timer T := 2.0;
2079
Harald Welte89d42e82017-12-17 16:42:41 +01002080 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01002081
2082 var RslChannelNr chan_nr := f_chreq_act_ack();
2083
2084 var octetstring l3 := '00010203040506'O;
2085 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_SACCH(0)), l3));
2086
2087 T.start;
2088 alt {
2089 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
2090 setverdict(fail, "MSC received COMPL L3 for invalid Link SACCH");
2091 }
2092 [] BSSAP.receive { repeat; }
2093 [] IPA_RSL[0].receive { repeat; }
2094 [] T.timeout {}
2095 }
2096
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002097 f_shutdown_helper();
Harald Welte5cd20ed2017-12-13 21:03:20 +01002098}
2099
Vadim Yanitskiy61f784a2020-10-01 21:12:19 +07002100/* Verify DLCI / RSL Link ID conversion for MO/MT messages on SAPI0/SAPI3 */
2101private function f_TC_tch_dlci_link_id_sapi(charstring id) runs on MSC_ConnHdlr {
2102 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2103 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2104
2105 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2106 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
2107
2108 f_establish_fully(ass_cmd, exp_compl);
2109
2110 /* SAPI0 has already been established by f_establish_fully(), establish SAPI3 */
2111 RSL.send(ts_RSL_EST_IND(g_chan_nr, ts_RslLinkID_SACCH(3), '0904'O));
2112 /* Expect BSSAP/DTAP on SAPI3 (DLCI IE) */
2113 BSSAP.receive(PDU_BSSAP:{
2114 discriminator := '1'B,
2115 spare := '0000000'B,
2116 dlci := 'C3'O,
2117 lengthIndicator := ?,
2118 pdu := { dtap := '0904'O }
2119 });
2120
2121 /* Send messages on DCCH/SAPI0 and ACCH/SAPI3 */
2122 for (var integer i := 0; i < 32; i := i + 1) {
2123 var octetstring l3 := '09'O & f_rnd_octstring(14);
2124 var template (value) RslLinkId link_id;
2125 var template (value) OCT1 dlci;
2126
2127 if (i mod 2 == 0) {
2128 /* SAPI0 on FACCH or SDCCH */
2129 link_id := ts_RslLinkID_DCCH(0);
2130 dlci := '80'O;
2131 } else {
2132 /* SAPI3 on SACCH */
2133 link_id := ts_RslLinkID_SACCH(3);
2134 dlci := 'C3'O;
2135 }
2136
2137 /* Send MO message: RSL -> BSSAP */
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00002138 f_mo_l3_transceive(RSL, link_id, dlci, l3);
Vadim Yanitskiy61f784a2020-10-01 21:12:19 +07002139 /* Send MT message: BSSAP -> RSL */
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00002140 f_mt_l3_transceive(RSL, link_id, dlci, l3);
Vadim Yanitskiy61f784a2020-10-01 21:12:19 +07002141 }
2142}
2143testcase TC_tch_dlci_link_id_sapi() runs on test_CT {
2144 var TestHdlrParams pars := f_gen_test_hdlr_pars();
2145 var MSC_ConnHdlr vc_conn;
2146
2147 f_init(1, true);
2148 f_sleep(1.0);
2149
2150 vc_conn := f_start_handler(refers(f_TC_tch_dlci_link_id_sapi), pars);
2151 vc_conn.done;
2152
2153 f_shutdown_helper();
2154}
2155
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07002156private function f_exp_sapi_n_reject(template (present) GsmSapi sapi := ?,
2157 template myBSSMAP_Cause cause := ?,
2158 float T_val := 2.0)
2159runs on test_CT {
2160 var BSSAP_N_DATA_ind rx_di;
2161 timer T;
2162
2163 var template BSSMAP_IE_Cause tr_cause := tr_BSSMAP_IE_Cause(cause);
2164 var template PDU_BSSAP tr_pdu := tr_BSSMAP_SAPInReject(sapi);
2165
2166 T.start(T_val);
2167 alt {
2168 [] BSSAP.receive(tr_BSSAP_DATA_ind(?, tr_pdu)) -> value rx_di {
2169 var BSSMAP_IE_Cause rx_cause := rx_di.userData.pdu.bssmap.sAPInReject.cause;
2170 if (not match(rx_cause, tr_cause)) {
2171 setverdict(fail, "Rx unexpected Cause IE: ",
2172 rx_cause, " vs expected ", tr_cause);
2173 }
2174 setverdict(pass);
2175 }
2176 [] BSSAP.receive(BSSAP_N_DATA_ind:?) -> value rx_di {
2177 setverdict(fail, "Rx unexpected BSSAP PDU: ", rx_di);
2178 }
2179 [] T.timeout {
2180 setverdict(fail, "Timeout waiting for BSSMAP SAPI N Reject");
2181 }
2182 }
2183}
2184
2185/* Check if we get SAPI N Reject on receipt of unexpected RLL RELease INDication */
2186testcase TC_rll_rel_ind_sapi_n_reject() runs on test_CT {
2187 var octetstring rnd_data := f_rnd_octstring(16);
2188 var RSL_Message rx_rsl;
2189 var DchanTuple dt;
2190
2191 f_init(1);
2192
2193 /* MS establishes a SAPI=0 link on DCCH */
2194 dt := f_est_dchan(f_rnd_ra_cs(), 23, rnd_data);
2195
2196 /* MSC sends some data on (not yet established) SAPI=3 link */
2197 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSAP_DTAP(rnd_data, '03'O)));
2198 /* BSC attempts to establish a SAPI=3 link on DCCH */
2199 rx_rsl := f_exp_ipa_rx(0, tr_RSL_EST_REQ(dt.rsl_chan_nr, tr_RslLinkID_DCCH(3)));
2200
2201 /* MS sends unexpected RELease INDication on SAPI=3 */
2202 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, ts_RslLinkID_DCCH(3)));
2203 /* We expect to receive BSSMAP SAPI N Reject message from the BSC */
2204 f_exp_sapi_n_reject(3, GSM0808_CAUSE_MS_NOT_EQUIPPED);
2205
2206 /* Clean up the connection */
2207 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2208 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
2209
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002210 f_shutdown_helper();
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07002211}
2212
2213/* Check if we get SAPI N Reject on receipt of unexpected RLL ERROR INDication */
2214testcase TC_rll_err_ind_sapi_n_reject() runs on test_CT {
2215 var octetstring rnd_data := f_rnd_octstring(16);
2216 var RSL_Message rx_rsl;
2217 var DchanTuple dt;
2218
2219 f_init(1);
2220
2221 /* MS establishes a SAPI=0 link on DCCH */
2222 dt := f_est_dchan(f_rnd_ra_cs(), 23, rnd_data);
2223
2224 /* MSC sends some data on (not yet established) SAPI=3 link */
2225 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSAP_DTAP(rnd_data, '03'O)));
2226 /* BSC attempts to establish a SAPI=3 link on DCCH */
2227 rx_rsl := f_exp_ipa_rx(0, tr_RSL_EST_REQ(dt.rsl_chan_nr, tr_RslLinkID_DCCH(3)));
2228
2229 /* BTS sends unexpected ERROR INDication on SAPI=3 */
2230 f_ipa_tx(0, ts_RSL_ERROR_IND(dt.rsl_chan_nr, ts_RslLinkID_DCCH(3), ''O));
2231 /* We expect to receive BSSMAP SAPI N Reject message from the BSC */
2232 f_exp_sapi_n_reject(3, GSM0808_CAUSE_BSS_NOT_EQUIPPED);
2233
2234 /* Clean up the connection */
2235 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2236 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
2237
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002238 f_shutdown_helper();
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07002239}
2240
2241/* Check if we get SAPI N Reject due to a SAPI=3 link establishment timeout */
2242testcase TC_rll_timeout_sapi_n_reject() runs on test_CT {
2243 var octetstring rnd_data := f_rnd_octstring(16);
2244 var RSL_Message rx_rsl;
2245 var DchanTuple dt;
2246
2247 f_init(1);
2248
2249 /* MS establishes a SAPI=0 link on DCCH */
2250 dt := f_est_dchan(f_rnd_ra_cs(), 23, rnd_data);
2251
2252 /* MSC sends some data on (not yet established) SAPI=3 link */
2253 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSAP_DTAP(rnd_data, '03'O)));
2254 /* BSC attempts to establish a SAPI=3 link on DCCH */
2255 rx_rsl := f_exp_ipa_rx(0, tr_RSL_EST_REQ(dt.rsl_chan_nr, tr_RslLinkID_DCCH(3)));
2256
2257 /* MS does not respond, so the link establishment timeout triggers SAPI N Reject */
2258 f_exp_sapi_n_reject(3, GSM0808_CAUSE_BSS_NOT_EQUIPPED, T_val := 8.0);
2259
2260 /* Clean up the connection */
2261 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2262 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
2263
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002264 f_shutdown_helper();
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07002265}
2266
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02002267testcase TC_si_default() runs on test_CT {
2268 f_init(0);
2269 f_init_bts_and_check_sysinfo(0, expect_si := SystemInformationConfig_default);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002270 f_shutdown_helper();
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02002271}
Harald Welte4003d112017-12-09 22:35:39 +01002272
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002273/* We're testing SI2quater with lists of EARFCNs. Instead of just incrementing EARFCNs, also pick some from the edges of
2274 * the entire value range. This function provides the same EARFCN numbers for the same earfcn_index */
2275private function f_test_si2quater_earfcn_by_idx(integer earfcn_index) return uint16_t
2276{
2277 select (earfcn_index) {
2278 case (0) {
2279 /* E-ARFCN 111 is already added in the osmo-bsc.cfg */
2280 return 111;
2281 }
2282 case (1) {
2283 return 1;
2284 }
2285 case (2) {
2286 return 0;
2287 }
2288 case (3) {
2289 return 65535;
2290 }
2291 case else {
2292 return 23 * (earfcn_index - 3);
2293 }
2294 }
2295}
2296
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002297function f_test_si2quater(integer total_earfcns, template SystemInformationConfig expect_si,
2298 template CellSelIndValue expect_cells := omit) runs on test_CT {
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002299
2300 f_init(0);
2301
2302 /* E-ARFCN 111 is already added in the osmo-bsc.cfg, so only add more arfcns if total_earfcns > 1 */
2303 for (var integer i := 1; i < total_earfcns; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002304 f_bts_0_cfg(BSCVTY, {"si2quater neighbor-list add earfcn " & int2str(f_test_si2quater_earfcn_by_idx(i))
2305 & " thresh-hi 20 thresh-lo 10 prio 3 qrxlv 22 meas 3"});
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002306 }
2307
2308 f_init_bts_and_check_sysinfo(0, expect_si := expect_si);
2309
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002310 if (not istemplatekind(expect_cells, "omit")) {
2311 /* Also check that RR Channel Release contains these EARFCNs.
2312 * (copied code from TC_chan_rel_hard_clear_csfb) */
2313 var BSSAP_N_DATA_ind rx_di;
2314 var DchanTuple dt;
2315
2316 dt := f_est_dchan('23'O, 23, '00010203040506'O);
2317
2318 /* Instruct BSC to clear channel */
2319 var BssmapCause cause := 0;
2320 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommandCSFB(cause)));
2321
2322 /* expect Clear Complete from BSC on A */
2323 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
2324 /* release the SCCP connection */
2325 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2326 }
2327
2328 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false, is_csfb := true,
2329 csfb_expect_cells := expect_cells);
2330 }
2331
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002332 for (var integer i := 1; i < total_earfcns; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002333 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 +02002334 }
2335}
2336
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002337private function f_tr_si2quater_earfcns(integer count) return template SI2quaterRestOctetsList
2338{
2339 var template SI2quaterRestOctetsList si2quater := {};
2340 var integer si2quater_count := (count + 2) / 3;
2341
2342 for (var integer i := 0; i < count; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002343 var integer earfcn := f_test_si2quater_earfcn_by_idx(i);
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002344 var integer index := i / 3;
2345 var integer earfcn_index := i mod 3;
2346 if (index >= lengthof(si2quater)) {
2347 si2quater[index] := tr_SI2quaterRestOctets_EUTRAN(index := index, count := si2quater_count - 1);
2348 }
2349 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);
2350 }
2351
2352 return si2quater;
2353}
2354
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002355private function f_tr_rr_chan_rel_earfcns(integer count) return template CellSelIndValue
2356{
2357 var template CellSelIndValue_EUTRAN_Descrs cells := {};
2358
Alexander Couzensf74b5cb2020-09-10 22:28:40 +02002359 /* the lte neighbors must match the config & vty to pass this test */
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002360 for (var integer i := 0; i < count; i := i + 1) {
2361 var integer earfcn := f_test_si2quater_earfcn_by_idx(i);
Alexander Couzensf74b5cb2020-09-10 22:28:40 +02002362 cells[i] := tr_CellSelIndValue_EUTRAN_Descr(earfcn, '1'B, 3);
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002363 }
2364
2365 return tr_CellSelIndValue_EUTRAN(cells);
2366}
2367
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002368private function f_tc_si2quater_n_earfcns(integer n) runs on test_CT
2369{
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002370 var template SystemInformationConfig sic := SystemInformationConfig_default;
Pau Espin Pedrol8ab62e42020-12-18 16:19:11 +01002371 sic.si2quater := f_tr_si2quater_earfcns(n);
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002372 var template CellSelIndValue cells := f_tr_rr_chan_rel_earfcns(n);
2373 f_test_si2quater(n, sic, cells);
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002374}
2375
2376testcase TC_si2quater_2_earfcns() runs on test_CT {
2377 f_tc_si2quater_n_earfcns(2);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002378 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002379}
2380
2381testcase TC_si2quater_3_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002382 f_tc_si2quater_n_earfcns(3);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002383 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002384}
2385
2386testcase TC_si2quater_4_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002387 f_tc_si2quater_n_earfcns(4);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002388 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002389}
2390
2391testcase TC_si2quater_5_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002392 f_tc_si2quater_n_earfcns(5);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002393 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002394}
2395
2396testcase TC_si2quater_6_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002397 f_tc_si2quater_n_earfcns(6);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002398 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002399}
2400
2401testcase TC_si2quater_12_earfcns() runs on test_CT {
2402 f_tc_si2quater_n_earfcns(12);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002403 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002404}
2405
2406testcase TC_si2quater_23_earfcns() runs on test_CT {
2407 f_tc_si2quater_n_earfcns(23);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002408 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002409}
2410
2411testcase TC_si2quater_32_earfcns() runs on test_CT {
2412 f_tc_si2quater_n_earfcns(32);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002413 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002414}
2415
2416testcase TC_si2quater_33_earfcns() runs on test_CT {
2417 f_tc_si2quater_n_earfcns(33);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002418 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002419}
2420
2421testcase TC_si2quater_42_earfcns() runs on test_CT {
2422 f_tc_si2quater_n_earfcns(42);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002423 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002424}
2425
2426testcase TC_si2quater_48_earfcns() runs on test_CT {
2427 f_tc_si2quater_n_earfcns(48);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002428 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002429}
2430
2431/* verify the VTY error response when adding too many EARFCNs, and showing that osmo-bsc still sends 16 SI2quater with
2432 * 48 EARFCNs. */
2433testcase TC_si2quater_49_earfcns() runs on test_CT {
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002434 var template SystemInformationConfig sic := SystemInformationConfig_default;
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002435 sic.si2quater := f_tr_si2quater_earfcns(48); /* 48, not 49! */
2436 f_init(0);
2437
2438 for (var integer i := 1; i < 48; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002439 f_bts_0_cfg(BSCVTY, {"si2quater neighbor-list add earfcn " & int2str(f_test_si2quater_earfcn_by_idx(i))
2440 & " thresh-hi 20 thresh-lo 10 prio 3 qrxlv 22 meas 3"});
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002441 }
2442
2443 /* The 49th EARFCN no longer fits, expect VTY error */
2444 f_vty_enter_cfg_bts(BSCVTY, 0);
2445 var charstring vty_error;
2446 vty_error := f_vty_transceive_ret(BSCVTY,
2447 "si2quater neighbor-list add earfcn 70 thresh-hi 20 thresh-lo 10 prio 3 qrxlv 22 meas 3")
2448 f_vty_transceive(BSCVTY, "end");
2449
2450 if (f_strstr(vty_error, "Unable to add ARFCN 70") >= 0) {
2451 log("Got expected VTY error: ", vty_error);
2452 setverdict(pass);
2453 } else {
2454 setverdict(fail, "Expected the 49th EUTRAN ARFCN to be rejected by vty config, got: ", vty_error);
2455 }
2456
2457 f_init_bts_and_check_sysinfo(0, expect_si := sic);
2458
2459 for (var integer i := 1; i < 48; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002460 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 +02002461 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002462 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002463}
2464
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002465private function f_acc09_count_allowed(AccessControlClass acc) return uint8_t
2466{
2467 var uint8_t count := 0;
2468 for (var integer i := 5; i < 16; i := i + 1) {
2469 if (acc[i] == '0'B) { /* the list marks barred, we count allowed */
2470 count := count + 1;
2471 }
2472 }
2473 return count;
2474}
2475
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002476private function f_recv_next_si1(integer rsl_idx := 0) runs on test_CT return SystemInformationType1
2477{
2478 var ASP_RSL_Unitdata rx_rsl_ud;
2479 var SystemInformationType1 last_si1;
2480
2481 timer T := 30.0;
2482 T.start;
2483 alt {
2484 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD((tr_RSL_NO_BCCH_INFO,
2485 tr_RSL_BCCH_INFO,
2486 tr_RSL_NO_SACCH_FILL,
2487 tr_RSL_SACCH_FILL))
2488 ) -> value rx_rsl_ud {
2489 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
2490 if (g_system_information[rsl_idx].si1 == omit) {
2491 repeat;
2492 }
2493 last_si1 := g_system_information[rsl_idx].si1;
2494 g_system_information[rsl_idx].si1 := omit;
2495 T.stop;
2496 }
Vadim Yanitskiy79ebd5e2021-01-04 00:12:55 +01002497 [] IPA_RSL[rsl_idx].receive { repeat; }
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002498 [] T.timeout { setverdict(fail, "Timeout receiving next SI1"); }
2499 }
2500 return last_si1;
2501}
2502
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002503/* verify ACC rotate feature */
2504testcase TC_si_acc_rotate() runs on test_CT {
2505 var template SystemInformationConfig sic := SystemInformationConfig_default;
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002506 var SystemInformationType1 last_si1;
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002507 var AccessControlClass acc;
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002508 var uint8_t count;
2509 var integer times_allowed[10] := { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
2510
2511 f_init(0, guard_timeout := 60.0);
2512
2513 f_bts_0_cfg(BSCVTY, {"rach access-control-class 5 barred",
2514 "access-control-class-rotate 3",
2515 "access-control-class-rotate-quantum 1"});
2516
2517 /* Init and get first sysinfo */
2518 f_init_bts_and_check_sysinfo(0, expect_si := ?);
2519
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002520 for (var integer i:= 0; i < 20; i := i + 1) {
2521 last_si1 := f_recv_next_si1(0);
2522 acc := last_si1.rach_control.acc;
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002523 count := f_acc09_count_allowed(acc);
2524 log("RSL: GOT SI1 ACC len=", count, ": ", acc);
2525
2526 if (count != 3) {
2527 log("RSL: EXPECTED SI ACC len=3");
2528 setverdict(fail, "received SI does not match expectations");
2529 break;
2530 }
2531
2532 for (var integer j := 0; j < 10; j := j + 1) {
2533 if (acc[16 - 1 - j] == '0'B) { /* the list marks barred, we count allowed */
2534 times_allowed[j] := times_allowed[j] + 1;
2535 }
2536 }
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002537 }
2538
2539 for (var integer j := 0; j < 10; j := j + 1) {
2540 log("ACC", j, " allowed ", times_allowed[j], " times" );
2541 if (j != 5 and times_allowed[j] < 3) {
2542 setverdict(fail, "ACC", j, " ERROR: allowed ", times_allowed[j], " < 1 times");
2543 } else if (j == 5 and times_allowed[j] > 0) {
2544 setverdict(fail, "ACC", j, " ERROR: allowed ", times_allowed[j], " > 0 times");
2545 }
2546 }
2547
2548 f_bts_0_cfg(BSCVTY, {"access-control-class-rotate 10",
2549 "rach access-control-class 5 allowed"});
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002550 f_shutdown_helper();
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002551}
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002552
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002553/* verify ACC startup ramp+rotate feature */
2554testcase TC_si_acc_ramp_rotate() runs on test_CT {
2555 var template SystemInformationConfig sic := SystemInformationConfig_default;
2556 var SystemInformationType1 last_si1;
2557 var AccessControlClass acc;
2558 var ASP_RSL_Unitdata rx_rsl_ud;
2559 var uint8_t count;
2560 var uint8_t prev_count;
2561 var integer times_allowed[10] := { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
2562
2563 f_init(0, guard_timeout := 80.0);
2564
2565 f_bts_0_cfg(BSCVTY, {"rach access-control-class 4 barred",
2566 "access-control-class-rotate 0",
2567 "access-control-class-rotate-quantum 1",
2568 "access-control-class-ramping",
2569 "access-control-class-ramping-step-interval 5",
2570 "access-control-class-ramping-step-size 5"});
2571
2572 /* Init and get first sysinfo */
2573 f_init_bts_and_check_sysinfo(0, expect_si := ?);
2574 last_si1 := g_system_information[0].si1;
2575 acc := last_si1.rach_control.acc;
2576 count := f_acc09_count_allowed(acc);
2577 /* Adm subset size was set to 0 above, so wait until all ACC are barred */
2578 while (count > 0) {
2579 last_si1 := f_recv_next_si1(0);
2580 acc := last_si1.rach_control.acc;
2581 count := f_acc09_count_allowed(acc);
2582 log("RSL: wait len()=0: GOT SI1 ACC len=", count, ": ", acc);
2583 }
2584
2585 /* Increase adm subset size, we should see ramping start up */
2586 f_bts_0_cfg(BSCVTY, {"access-control-class-rotate 10"});
2587 prev_count := 0;
2588 while (true) {
2589 last_si1 := f_recv_next_si1(0);
2590 acc := last_si1.rach_control.acc;
2591 count := f_acc09_count_allowed(acc);
2592 log("RSL: GOT SI1 ACC len=", count, ": ", acc);
2593
2594 if (prev_count > count) {
2595 setverdict(fail, "ACC allowed count dropped while expecting grow: ", prev_count, " -> ", count);
2596 break;
2597 }
2598
2599 if (count == 9) {
2600 break; /* Maximum reached (10 - 1 perm barred), done here */
2601 }
2602
2603 prev_count := count;
2604 }
2605
2606 setverdict(pass);
2607
2608 f_bts_0_cfg(BSCVTY, {"access-control-class-rotate 10",
2609 "rach access-control-class 4 allowed",
2610 "no access-control-class-ramping"});
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002611 f_shutdown_helper();
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002612}
2613
Harald Welte4003d112017-12-09 22:35:39 +01002614testcase TC_ctrl_msc_connection_status() runs on test_CT {
2615 var charstring ctrl_resp;
2616
Harald Welte89d42e82017-12-17 16:42:41 +01002617 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01002618
2619 /* See https://osmocom.org/issues/2729 */
2620 f_ctrl_get_exp(IPA_CTRL, "msc_connection_status", "connected");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002621 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01002622}
2623
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01002624testcase TC_ctrl_msc0_connection_status() runs on test_CT {
2625 var charstring ctrl_resp;
2626
2627 f_init(1);
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01002628
2629 f_ctrl_get_exp(IPA_CTRL, "msc.0.connection_status", "connected");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002630 f_shutdown_helper();
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01002631}
2632
Harald Welte4003d112017-12-09 22:35:39 +01002633testcase TC_ctrl() runs on test_CT {
2634 var charstring ctrl_resp;
2635
Harald Welte89d42e82017-12-17 16:42:41 +01002636 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01002637
2638 /* all below values must match the osmo-bsc.cfg config file used */
2639
Harald Welte6a129692018-03-17 17:30:14 +01002640 f_ctrl_get_exp(IPA_CTRL, "mcc", "001");
2641 f_ctrl_get_exp(IPA_CTRL, "mnc", "01");
Oliver Smith75aa0202019-08-19 14:17:50 +02002642 f_ctrl_get_exp(IPA_CTRL, "number-of-bts", "4");
Harald Welte4003d112017-12-09 22:35:39 +01002643
2644 var integer bts_nr := 0;
2645 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "location-area-code", "1");
2646 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "cell-identity", "0");
2647 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "oml-connection-state", "connected");
2648 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "gprs-mode", "gprs");
2649 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "rf_state", "operational,unlocked,on");
2650 f_ctrl_get_exp_trx(IPA_CTRL, bts_nr, 0, "arfcn", "871");
2651 f_ctrl_get_exp_trx(IPA_CTRL, bts_nr, 0, "max-power-reduction", "20");
2652
2653 var integer uptime := str2int(f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-uptime"));
2654 f_sleep(2.0);
2655 if (str2int(f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-uptime")) < uptime+1) {
2656 setverdict(fail, "oml-uptime not incrementing as expected");
2657 }
2658 /* TODO: Disconnect RSL, imply that OML is disconnected and check for uptime zero? */
2659
2660 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted", 0);
2661
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002662 f_shutdown_helper();
Harald Welte96c94412017-12-09 03:12:45 +01002663}
2664
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +02002665/* Verify that Upon receival of SET "location", BSC forwards a TRAP
2666 "location-state" over the SCCPlite IPA conn */
2667testcase TC_ctrl_location() runs on test_CT {
2668 var MSC_ConnHdlr vc_conn;
2669 var integer bts_nr := 0;
2670
2671 f_init(1, true);
2672 f_sleep(1.0);
2673
2674 f_ctrl_set_bts(IPA_CTRL, bts_nr, "location", "1234567,fix3d,0.340000,0.560000,0.780000");
2675 f_ctrl_exp_trap(SCCPLITE_IPA_CTRL, "bts." & int2str(bts_nr) & ".location-state",
2676 "1234567,fix3d,0.340000,0.560000,0.780000,operational,unlocked,on,001,01");
2677
2678 f_ctrl_set(SCCPLITE_IPA_CTRL, "rf_locked", "1");
2679 f_sleep(2.0);
2680
2681 f_ctrl_set_bts(IPA_CTRL, bts_nr, "location", "1234888,fix3d,0.350000,0.570000,0.790000");
2682 f_ctrl_exp_trap(SCCPLITE_IPA_CTRL, "bts." & int2str(bts_nr) & ".location-state",
2683 "1234888,fix3d,0.350000,0.570000,0.790000,operational,locked,off,001,01");
2684
2685 /* should match the one from config */
2686 f_ctrl_set(SCCPLITE_IPA_CTRL, "rf_locked", "0");
2687
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002688 f_shutdown_helper();
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +02002689}
2690
Harald Welte6f521d82017-12-11 19:52:02 +01002691
2692/***********************************************************************
2693 * Paging Testing
2694 ***********************************************************************/
2695
2696type record Cell_Identity {
2697 GsmMcc mcc,
2698 GsmMnc mnc,
2699 GsmLac lac,
2700 GsmCellId ci
2701};
Harald Welte24135bd2018-03-17 19:27:53 +01002702private const Cell_Identity cid := { '001'H, '01'H, 1, 0 };
Stefan Sperling049a86e2018-03-20 15:51:00 +01002703private const Cell_Identity unknown_cid := { '678'H, 'f90'H, 1, 0 };
Harald Welte6f521d82017-12-11 19:52:02 +01002704
Harald Welte5d1a2202017-12-13 19:51:29 +01002705type set of integer BtsIdList;
2706
2707private function f_bts_in_list(integer bts_id, BtsIdList bts_ids) return boolean {
2708 for (var integer j := 0; j < sizeof(bts_ids); j := j + 1) {
2709 if (bts_id == bts_ids[j]) {
2710 return true;
2711 }
2712 }
2713 return false;
2714}
Harald Welte6f521d82017-12-11 19:52:02 +01002715
2716/* core paging test helper function; used by most paging test cases */
2717private function f_pageing_helper(hexstring imsi,
2718 template BSSMAP_FIELD_CellIdentificationList cid_list,
Harald Welte5d1a2202017-12-13 19:51:29 +01002719 BtsIdList bts_ids := { 0 },
Harald Welte6f521d82017-12-11 19:52:02 +01002720 template RSL_ChanNeeded rsl_chneed := omit,
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002721 template (omit) OCT4 tmsi := omit) runs on test_CT
Harald Welte6f521d82017-12-11 19:52:02 +01002722{
2723 var template BSSMAP_IE_ChannelNeeded bssmap_chneed;
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002724 var template MobileIdentityV mi;
Harald Welte6f521d82017-12-11 19:52:02 +01002725 var RSL_Message rx_rsl;
2726 var integer paging_group := hex2int(imsi[lengthof(imsi)-1]);
Harald Welte5d1a2202017-12-13 19:51:29 +01002727 var integer i;
Harald Welte6f521d82017-12-11 19:52:02 +01002728
2729 f_init();
Harald Welte6f521d82017-12-11 19:52:02 +01002730
2731 /* Clear the queue, it might still contain stuff like BCCH FILLING */
Harald Weltec3068592018-03-17 19:55:31 +01002732 for (i := 0; i < NUM_BTS; i := i + 1) {
2733 IPA_RSL[i].clear;
Harald Welte5d1a2202017-12-13 19:51:29 +01002734 }
Harald Welte6f521d82017-12-11 19:52:02 +01002735
2736 if (isvalue(rsl_chneed)) {
2737 /* The values of 08.08 3.2.2.36 and 08.58 9.3.40 are luckily identical */
2738 bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
2739 } else {
2740 bssmap_chneed := omit;
2741 }
2742
Neels Hofmeyrf246a922020-05-13 02:27:10 +02002743 BSSAP.send(ts_BSSAP_UNITDATA_req(g_bssap[0].sccp_addr_peer, g_bssap[0].sccp_addr_own,
2744 ts_BSSMAP_Paging(imsi, cid_list, tmsi, bssmap_chneed)));
Harald Welte6f521d82017-12-11 19:52:02 +01002745
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002746 if (not istemplatekind(tmsi, "omit")) {
2747 mi := t_MI_TMSI(tmsi);
Harald Welte6f521d82017-12-11 19:52:02 +01002748 } else {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002749 mi := tr_MI_IMSI(imsi);
Harald Welte6f521d82017-12-11 19:52:02 +01002750 }
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002751
Harald Welte5d1a2202017-12-13 19:51:29 +01002752 for (i := 0; i < sizeof(bts_ids); i := i + 1) {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002753 rx_rsl := f_exp_ipa_rx(bts_ids[i], tr_RSL_PAGING_CMD(mi));
Harald Welte5d1a2202017-12-13 19:51:29 +01002754 /* check channel type, paging group */
2755 if (rx_rsl.ies[1].body.paging_group != paging_group) {
2756 setverdict(fail, "Paging for wrong paging group");
2757 }
2758 if (ispresent(rsl_chneed) and
2759 rx_rsl.ies[3].body.chan_needed.chan_needed != valueof(rsl_chneed)) {
2760 setverdict(fail, "RSL Channel Needed != BSSMAP Channel Needed");
2761 }
Harald Welte6f521d82017-12-11 19:52:02 +01002762 }
Harald Welte2fccd982018-01-31 15:48:19 +01002763 f_sleep(2.0);
Harald Welte5d1a2202017-12-13 19:51:29 +01002764 /* do a quick check on all not-included BTSs if they received paging */
2765 for (i := 0; i < NUM_BTS; i := i + 1) {
2766 timer T := 0.1;
2767 if (f_bts_in_list(i, bts_ids)) {
2768 continue;
2769 }
2770 T.start;
2771 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07002772 [] IPA_RSL[i].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(mi))) {
Harald Welte5d1a2202017-12-13 19:51:29 +01002773 setverdict(fail, "Paging on BTS ", i, " which is not part of ", bts_ids);
2774 }
2775 [] IPA_RSL[i].receive { repeat; }
2776 [] T.timeout { }
2777 }
Harald Welte6f521d82017-12-11 19:52:02 +01002778 }
2779
2780 setverdict(pass);
2781}
2782
Harald Welte5d1a2202017-12-13 19:51:29 +01002783const BtsIdList c_BtsId_all := { 0, 1, 2 };
Harald Welte751d3eb2018-01-31 15:51:06 +01002784const BtsIdList c_BtsId_none := { };
Harald Welte5d1a2202017-12-13 19:51:29 +01002785const BtsIdList c_BtsId_LAC1 := { 0, 1 };
2786const BtsIdList c_BtsId_LAC2 := { 2 };
2787
Harald Welte6f521d82017-12-11 19:52:02 +01002788/* PAGING by IMSI + TMSI */
2789testcase TC_paging_imsi_nochan() runs on test_CT {
2790 var BSSMAP_FIELD_CellIdentificationList cid_list;
2791 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Philipp Maier8c04b0a2018-02-23 13:48:48 +01002792 f_pageing_helper('001010100000001'H, cid_list, c_BtsId_all, omit, omit);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002793 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002794}
2795
2796/* PAGING by IMSI + TMSI */
2797testcase TC_paging_tmsi_nochan() runs on test_CT {
2798 var BSSMAP_FIELD_CellIdentificationList cid_list;
2799 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002800 f_pageing_helper('001010100000001'H, cid_list, c_BtsId_all, omit, 'A1B2C301'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002801 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002802}
2803
2804/* Paging with different "channel needed' values */
2805testcase TC_paging_tmsi_any() runs on test_CT {
2806 var BSSMAP_FIELD_CellIdentificationList cid_list;
2807 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002808 f_pageing_helper('001010100000002'H, cid_list, c_BtsId_all, RSL_CHANNEED_ANY, 'A1B2C302'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002809 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002810}
2811testcase TC_paging_tmsi_sdcch() runs on test_CT {
2812 var BSSMAP_FIELD_CellIdentificationList cid_list;
2813 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002814 f_pageing_helper('001010100000003'H, cid_list, c_BtsId_all, RSL_CHANNEED_SDCCH, 'A1B2C303'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002815 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002816}
2817testcase TC_paging_tmsi_tch_f() runs on test_CT {
2818 var BSSMAP_FIELD_CellIdentificationList cid_list;
2819 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002820 f_pageing_helper('001010000000004'H, cid_list, c_BtsId_all, RSL_CHANNEED_TCH_F, 'A1B2C304'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002821 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002822}
2823testcase TC_paging_tmsi_tch_hf() runs on test_CT {
2824 var BSSMAP_FIELD_CellIdentificationList cid_list;
2825 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002826 f_pageing_helper('001010000000005'H, cid_list, c_BtsId_all, RSL_CHANNEED_TCH_ForH, 'A1B2C305'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002827 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002828}
2829
2830/* Paging by CGI */
2831testcase TC_paging_imsi_nochan_cgi() runs on test_CT {
2832 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2833 cid_list := { cIl_CGI := { ts_BSSMAP_CI_CGI(cid.mcc, cid.mnc, cid.lac, cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002834 f_pageing_helper('001010000000006'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01002835 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002836}
2837
2838/* Paging by LAC+CI */
2839testcase TC_paging_imsi_nochan_lac_ci() runs on test_CT {
2840 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2841 cid_list := { cIl_LAC_CI := { ts_BSSMAP_CI_LAC_CI(cid.lac, cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002842 f_pageing_helper('001010000000007'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01002843 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002844}
2845
2846/* Paging by CI */
2847testcase TC_paging_imsi_nochan_ci() runs on test_CT {
2848 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2849 cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002850 f_pageing_helper('001010000000008'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01002851 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002852}
2853
2854/* Paging by LAI */
2855testcase TC_paging_imsi_nochan_lai() runs on test_CT {
2856 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2857 cid_list := { cIl_LAI := { ts_BSSMAP_CI_LAI(cid.mcc, cid.mnc, cid.lac) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002858 f_pageing_helper('001010000000009'H, cid_list, c_BtsId_LAC1);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002859 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002860}
2861
2862/* Paging by LAC */
2863testcase TC_paging_imsi_nochan_lac() runs on test_CT {
2864 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2865 cid_list := { cIl_LAC := { ts_BSSMAP_CI_LAC(cid.lac) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002866 f_pageing_helper('001010000000010'H, cid_list, c_BtsId_LAC1);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002867 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002868}
2869
2870/* Paging by "all in BSS" */
2871testcase TC_paging_imsi_nochan_all() runs on test_CT {
2872 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2873 cid_list := { cIl_allInBSS := ''O };
Harald Welte5d1a2202017-12-13 19:51:29 +01002874 f_pageing_helper('001010000000011'H, cid_list, c_BtsId_all);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002875 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002876}
2877
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002878/* Paging by PLMN+LAC+RNC; We do not implement this; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01002879testcase TC_paging_imsi_nochan_plmn_lac_rnc() runs on test_CT {
2880 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2881 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 +01002882 f_pageing_helper('001010000000012'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002883 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002884}
Harald Welte6f521d82017-12-11 19:52:02 +01002885
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002886/* Paging by RNC; We do not implement this; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01002887testcase TC_paging_imsi_nochan_rnc() runs on test_CT {
2888 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2889 cid_list := { cIl_RNC := { int2oct(13, 2) } };
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002890 f_pageing_helper('001010000000013'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002891 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002892}
2893
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002894/* Paging by LAC+RNC; We do not implement; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01002895testcase TC_paging_imsi_nochan_lac_rnc() runs on test_CT {
2896 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2897 cid_list := { cIl_LAC_RNC := { ts_BSSMAP_CI_LAC_RNC(cid.lac, 14) } };
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002898 f_pageing_helper('001010000000014'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002899 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002900}
2901
Harald Welte6f521d82017-12-11 19:52:02 +01002902/* Paging on multiple cells (multiple entries in list): Verify all of them page */
Harald Welte751d3eb2018-01-31 15:51:06 +01002903testcase TC_paging_imsi_nochan_lacs() runs on test_CT {
2904 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2905 cid_list := { cIl_LAC := { ts_BSSMAP_CI_LAC(1), ts_BSSMAP_CI_LAC(2) } };
2906 f_pageing_helper('001010000000015'H, cid_list, c_BtsId_all);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002907 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002908}
2909
2910/* Paging on empty list: Verify none of them page */
2911testcase TC_paging_imsi_nochan_lacs_empty() runs on test_CT {
2912 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2913 cid_list := { cIl_LAC := { } };
2914 f_pageing_helper('001010000000016'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002915 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002916}
2917
Stefan Sperling049a86e2018-03-20 15:51:00 +01002918/* Paging by CGI with unknown MCC/MNC: Verify nothing is paged. */
2919testcase TC_paging_imsi_nochan_cgi_unknown_cid() runs on test_CT {
2920 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2921 cid_list := { cIl_CGI := { ts_BSSMAP_CI_CGI(unknown_cid.mcc, unknown_cid.mnc, unknown_cid.lac, unknown_cid.ci) } };
2922 f_pageing_helper('001010000000006'H, cid_list, c_BtsId_none);
2923 f_shutdown_helper();
2924}
2925
Harald Welte6f521d82017-12-11 19:52:02 +01002926/* Verify paging retransmission interval + count */
2927/* Verify paging stops after channel establishment */
Harald Welte6f521d82017-12-11 19:52:02 +01002928/* Test behavior under paging overload */
Harald Welteae026692017-12-09 01:03:01 +01002929
Harald Weltee65d40e2017-12-13 00:09:06 +01002930/* Verify PCH load */
2931testcase TC_paging_imsi_load() runs on test_CT {
2932 var BSSMAP_FIELD_CellIdentificationList cid_list;
2933 timer T := 4.0;
Harald Welte2caa1062018-03-17 18:19:05 +01002934 timer T_retrans := 1.0;
Harald Weltee65d40e2017-12-13 00:09:06 +01002935 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002936 f_pageing_helper('001010123456789'H, cid_list, c_BtsId_all);
Harald Weltee65d40e2017-12-13 00:09:06 +01002937
2938 /* tell BSC there is no paging space anymore */
2939 f_ipa_tx(0, ts_RSL_PAGING_LOAD_IND(0));
Harald Welte3b57ab52018-03-17 18:01:10 +01002940 f_sleep(0.2);
2941 IPA_RSL[0].clear;
Harald Weltee65d40e2017-12-13 00:09:06 +01002942
2943 /* Wait for 4 seconds if any more PAGING CMD are received on RSL. Normally,
2944 * there would be 8 retransmissions during 4 seconds */
2945 T.start;
Harald Welte2caa1062018-03-17 18:19:05 +01002946 T_retrans.start;
Harald Weltee65d40e2017-12-13 00:09:06 +01002947 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07002948 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Weltee65d40e2017-12-13 00:09:06 +01002949 setverdict(fail, "Received PAGING after LOAD_IND(0)");
Daniel Willmannafce8662018-07-06 23:11:32 +02002950 mtc.stop;
Harald Weltee65d40e2017-12-13 00:09:06 +01002951 }
Harald Welte2caa1062018-03-17 18:19:05 +01002952 [] T_retrans.timeout {
2953 /* re-trnsmit the zero-space LOAD IND to avoid BSC 'auto credit' */
2954 f_ipa_tx(0, ts_RSL_PAGING_LOAD_IND(0));
2955 T_retrans.start;
2956 repeat;
2957 }
Harald Weltee65d40e2017-12-13 00:09:06 +01002958 [] T.timeout {
2959 setverdict(pass);
2960 }
2961 }
Philipp Maier282ca4b2018-02-27 17:17:00 +01002962
2963 f_shutdown_helper();
Harald Weltee65d40e2017-12-13 00:09:06 +01002964}
2965
Harald Welte235ebf12017-12-15 14:18:16 +01002966/* Verify Paging Counter */
Harald Welte1ff69992017-12-14 12:31:17 +01002967testcase TC_paging_counter() runs on test_CT {
2968 var BSSMAP_FIELD_CellIdentificationList cid_list;
2969 timer T := 4.0;
2970 var integer i;
2971 var integer paging_attempted_bsc;
2972 var integer paging_attempted_bts[NUM_BTS];
2973 var integer paging_expired_bts[NUM_BTS];
2974 cid_list := valueof(ts_BSSMAP_CIL_noCell);
2975
2976 f_init();
2977
2978 /* read counters before paging */
2979 paging_attempted_bsc := f_ctrl_get_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted");
2980 for (i := 0; i < NUM_BTS; i := i+1) {
2981 paging_attempted_bts[i] := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", i, "paging:attempted");
2982 paging_expired_bts[i] := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", i, "paging:expired");
2983 }
2984
2985 f_pageing_helper('001230000000001'H, cid_list, c_BtsId_all);
2986
2987 /* expect the attempted pages on BSC and each BTSs to have incremented by one */
2988 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted", paging_attempted_bsc+1);
2989 for (i := 0; i < NUM_BTS; i := i+1) {
2990 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", i, "paging:attempted",
2991 paging_attempted_bts[i]+1);
2992 }
2993
2994 /* assume that 12s later the paging on all BTSs have expired and hence incremented by 1 */
2995 f_sleep(12.0);
2996 for (i := 0; i < NUM_BTS; i := i+1) {
2997 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", i, "paging:expired",
2998 paging_expired_bts[i]+1);
2999 }
Harald Welte1ff69992017-12-14 12:31:17 +01003000
Philipp Maier282ca4b2018-02-27 17:17:00 +01003001 f_shutdown_helper();
Harald Welte1ff69992017-12-14 12:31:17 +01003002}
3003
3004
Harald Welte10985002017-12-12 09:29:15 +01003005/* Verify paging stops after A-RESET */
3006testcase TC_paging_imsi_a_reset() runs on test_CT {
3007 var BSSMAP_FIELD_CellIdentificationList cid_list;
3008 timer T := 3.0;
3009 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01003010 f_pageing_helper('001010123456789'H, cid_list, c_BtsId_all);
Harald Welte10985002017-12-12 09:29:15 +01003011
3012 /* Perform a BSSMAP Reset and wait for ACK */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003013 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 +01003014 alt {
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003015 [] 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 +01003016 [] BSSAP.receive { repeat; }
3017 }
3018
Daniel Willmanncbef3982018-07-30 09:22:40 +02003019 /* Wait to avoid a possible race condition if a paging message is
3020 * received right before the reset ACK. */
3021 f_sleep(0.2);
3022
Harald Welte10985002017-12-12 09:29:15 +01003023 /* Clear the queue, it might still contain stuff like BCCH FILLING */
Philipp Maier1e6b4422018-02-23 14:02:13 +01003024 for (var integer i := 0; i < sizeof(IPA_RSL); i := i+1) {
3025 IPA_RSL[i].clear;
3026 }
Harald Welte10985002017-12-12 09:29:15 +01003027
3028 /* Wait for 3 seconds if any more PAGING CMD are received on RSL */
3029 T.start;
3030 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07003031 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Welte10985002017-12-12 09:29:15 +01003032 setverdict(fail, "Received PAGING after A-RESET");
Daniel Willmannafce8662018-07-06 23:11:32 +02003033 mtc.stop;
Harald Welte10985002017-12-12 09:29:15 +01003034 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07003035 [] IPA_RSL[1].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Welte5d1a2202017-12-13 19:51:29 +01003036 setverdict(fail, "Received PAGING after A-RESET");
Daniel Willmannafce8662018-07-06 23:11:32 +02003037 mtc.stop;
Harald Welte5d1a2202017-12-13 19:51:29 +01003038 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07003039 [] IPA_RSL[2].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Welte5d1a2202017-12-13 19:51:29 +01003040 setverdict(fail, "Received PAGING after A-RESET");
Daniel Willmannafce8662018-07-06 23:11:32 +02003041 mtc.stop;
Harald Welte5d1a2202017-12-13 19:51:29 +01003042 }
Harald Welte10985002017-12-12 09:29:15 +01003043 [] T.timeout {
3044 setverdict(pass);
3045 }
3046 }
Philipp Maier282ca4b2018-02-27 17:17:00 +01003047
3048 f_shutdown_helper();
Harald Welte10985002017-12-12 09:29:15 +01003049}
Harald Welteae026692017-12-09 01:03:01 +01003050
Philipp Maierf45824a2019-08-14 14:44:10 +02003051/* Verify how we handle unsolicited Paging Response. In case of an unsolicit
3052 * paging response we can not know which MSC is in charge, so we will blindly
3053 * pick the first configured MSC. This behavior is required in order to make
3054 * MT-CSFB calls working because in those cases the BSC can not know that the
3055 * MSC has already paged the subscriver via SGs. So any MT-CSFB call will look
3056 * like an unsolicited Paging Response to the MSC.
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003057 */
3058testcase TC_paging_resp_unsol() runs on test_CT {
3059
3060 f_init(1);
Philipp Maierf45824a2019-08-14 14:44:10 +02003061 timer T := 5.0;
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003062
3063 var BSSAP_N_CONNECT_ind rx_c_ind;
3064 var DchanTuple dt;
3065 var PDU_ML3_MS_NW l3 := valueof(ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010008880018'H))));
Philipp Maierf45824a2019-08-14 14:44:10 +02003066 var octetstring rr_pag_resp := enc_PDU_ML3_MS_NW(l3);
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003067
3068 /* Send CHAN RQD and wait for allocation; acknowledge it */
3069 dt.rsl_chan_nr := f_chreq_act_ack();
3070
3071 /* Send unsolicited Paging response (no matching Paging CMD stored in BSC) */
3072 f_ipa_tx(0, ts_RSL_EST_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)), enc_PDU_ML3_MS_NW(l3)));
3073
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003074
Philipp Maierf45824a2019-08-14 14:44:10 +02003075 /* Expevct a CR with a matching Paging response on the A-Interface */
3076 T.start;
3077 alt {
3078 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(rr_pag_resp))) {
3079 setverdict(pass);
3080 }
3081 [] BSSAP.receive {
3082 setverdict(fail, "Received unexpected message on A-Interface!");
3083 }
3084 [] T.timeout {
3085 setverdict(fail, "Received nothing on A-Interface!");
3086 }
3087 }
3088
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003089 f_shutdown_helper();
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003090}
3091
Harald Welte4e9b9cc2017-12-14 18:31:02 +01003092/* Test RSL link drop causes counter increment */
3093testcase TC_rsl_drop_counter() runs on test_CT {
3094 var integer rsl_fail;
3095
Harald Welte89d42e82017-12-17 16:42:41 +01003096 f_init(1);
Harald Welte4e9b9cc2017-12-14 18:31:02 +01003097
3098 rsl_fail := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "rsl_fail");
3099
3100 bts[0].rsl.vc_IPA.stop;
3101
3102 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "rsl_fail", rsl_fail+1);
3103
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003104 f_shutdown_helper();
Harald Welte4e9b9cc2017-12-14 18:31:02 +01003105}
3106
3107/* TODO: Test OML link drop causes counter increment */
3108
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003109/* The body of TC_rsl_unknown_unit_id() and TC_oml_unknown_unit_id() tests. */
3110function f_ipa_unknown_unit_id(integer mp_bsc_ipa_port) runs on test_CT return boolean {
3111 timer T := 10.0;
3112
3113 bts[0].rsl.id := "IPA-0-RSL";
3114 bts[0].rsl.vc_IPA := IPA_Emulation_CT.create(bts[0].rsl.id & "-IPA");
3115 bts[0].rsl.ccm_pars := c_IPA_default_ccm_pars;
3116 bts[0].rsl.ccm_pars.name := "Osmocom TTCN-3 BTS Simulator";
Oliver Smith92c2bdb2019-08-20 15:11:24 +02003117 bts[0].rsl.ccm_pars.unit_id := "99/0/0"; /* value which is unknown at BTS */
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003118
Pau Espin Pedrol9a5b8ff2021-01-04 19:01:31 +01003119 f_ipa_ctrl_start_client(mp_bsc_ip, mp_bsc_ctrl_port);
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003120
3121 f_init_mgcp("VirtMSC");
3122
3123 /* start RSL/OML connection (XXX re-uses RSL port/protocol definitions for OML) */
3124 map(bts[0].rsl.vc_IPA:IPA_PORT, system:IPA);
3125 connect(bts[0].rsl.vc_IPA:IPA_RSL_PORT, self:IPA_RSL[0]);
3126 bts[0].rsl.vc_IPA.start(IPA_Emulation.main_client(mp_bsc_ip, mp_bsc_ipa_port, "", 10000, bts[0].rsl.ccm_pars));
3127
3128 /* wait for IPA OML link to connect and then disconnect */
3129 T.start;
3130 alt {
Vadim Yanitskiya2afacc2020-05-18 21:16:19 +07003131 [] IPA_RSL[0].receive(tr_ASP_IPA_EV(ASP_IPA_EVENT_DOWN)) {
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003132 T.stop;
3133 return true;
3134 }
3135 [] IPA_RSL[0].receive { repeat }
3136 [] T.timeout {
Daniel Willmannafce8662018-07-06 23:11:32 +02003137 return false;
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003138 }
3139 }
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003140 return false;
3141}
3142
3143/* BSC should close an RSL connection from a BTS with unknown unit ID (OS#2714). */
3144testcase TC_rsl_unknown_unit_id() runs on test_CT {
3145 if (f_ipa_unknown_unit_id(mp_bsc_rsl_port)) {
3146 setverdict(pass);
3147 } else {
3148 setverdict(fail, "Timeout RSL waiting for connection to close");
3149 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003150 f_shutdown_helper();
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003151}
3152
3153
3154/* BSC should close an RSL connection from a BTS with unknown unit ID (OS#2714). */
3155testcase TC_oml_unknown_unit_id() runs on test_CT {
3156 if (f_ipa_unknown_unit_id(mp_bsc_oml_port)) {
3157 setverdict(pass);
3158 } else {
3159 setverdict(fail, "Timeout OML waiting for connection to close");
3160 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003161 f_shutdown_helper();
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003162}
3163
3164
Harald Weltec1a2fff2017-12-17 11:06:19 +01003165/***********************************************************************
Harald Welte6811d102019-04-14 22:23:14 +02003166 * "New world" test cases using RSL_Emulation + RAN_Emulation
Harald Weltec1a2fff2017-12-17 11:06:19 +01003167 ***********************************************************************/
3168
Harald Welte6811d102019-04-14 22:23:14 +02003169import from RAN_Emulation all;
Harald Welte47cd0e32020-08-21 12:39:11 +02003170import from BSSAP_LE_Emulation all;
Harald Weltec1a2fff2017-12-17 11:06:19 +01003171import from RSL_Emulation all;
3172import from MSC_ConnectionHandler all;
3173
3174type function void_fn(charstring id) runs on MSC_ConnHdlr;
3175
Harald Welte336820c2018-05-31 20:34:52 +02003176/* helper function to create and connect a MSC_ConnHdlr component */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003177private function f_connect_handler(inout MSC_ConnHdlr vc_conn, integer bssap_idx := 0) runs on test_CT {
3178 connect(vc_conn:RAN, g_bssap[bssap_idx].vc_RAN:PROC);
Daniel Willmann191e0d92018-01-17 12:44:35 +01003179 connect(vc_conn:MGCP_PROC, vc_MGCP:MGCP_PROC);
Harald Weltec1a2fff2017-12-17 11:06:19 +01003180 connect(vc_conn:RSL, bts[0].rsl.vc_RSL:CLIENT_PT);
Harald Weltef70df652018-01-29 22:00:23 +01003181 connect(vc_conn:RSL_PROC, bts[0].rsl.vc_RSL:RSL_PROC);
Philipp Maier88f4ae82018-03-01 14:00:58 +01003182 if (isvalue(bts[1])) {
Philipp Maier956a92f2018-02-16 10:58:07 +01003183 connect(vc_conn:RSL1, bts[1].rsl.vc_RSL:CLIENT_PT);
3184 connect(vc_conn:RSL1_PROC, bts[1].rsl.vc_RSL:RSL_PROC);
3185 }
Neels Hofmeyr91401012019-07-11 00:42:35 +02003186 if (isvalue(bts[2])) {
3187 connect(vc_conn:RSL2, bts[2].rsl.vc_RSL:CLIENT_PT);
3188 connect(vc_conn:RSL2_PROC, bts[2].rsl.vc_RSL:RSL_PROC);
3189 }
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003190 connect(vc_conn:BSSAP, g_bssap[bssap_idx].vc_RAN:CLIENT);
Neels Hofmeyrcfe44062020-10-15 02:28:08 +02003191 if (mp_enable_lcs_tests) {
3192 connect(vc_conn:BSSAP_LE, g_bssap_le.vc_BSSAP_LE:CLIENT);
3193 connect(vc_conn:BSSAP_LE_PROC, g_bssap_le.vc_BSSAP_LE:PROC);
3194 }
Daniel Willmann191e0d92018-01-17 12:44:35 +01003195 connect(vc_conn:MGCP, vc_MGCP:MGCP_CLIENT);
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02003196 connect(vc_conn:MGCP_MULTI, vc_MGCP:MGCP_CLIENT_MULTI);
Daniel Willmannebdecc02020-08-12 15:30:17 +02003197 connect(vc_conn:STATSD_PROC, vc_STATSD:STATSD_PROC);
Harald Welte336820c2018-05-31 20:34:52 +02003198}
3199
3200function f_start_handler(void_fn fn, template (omit) TestHdlrParams pars := omit)
3201runs on test_CT return MSC_ConnHdlr {
3202 var charstring id := testcasename();
3203 var MSC_ConnHdlr vc_conn;
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003204 var integer bssap_idx := 0;
3205 if (isvalue(pars)) {
3206 bssap_idx := valueof(pars).mscpool.bssap_idx;
3207 }
Harald Welte336820c2018-05-31 20:34:52 +02003208 vc_conn := MSC_ConnHdlr.create(id);
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003209 f_connect_handler(vc_conn, bssap_idx);
Neels Hofmeyr1708d1b2020-10-10 16:56:48 +02003210 /* Emit a marker to appear in the SUT's own logging output */
3211 f_logp(BSCVTY, testcasename() & "() start");
Harald Weltea0630032018-03-20 21:09:55 +01003212 vc_conn.start(f_handler_init(fn, id, pars));
Harald Weltec1a2fff2017-12-17 11:06:19 +01003213 return vc_conn;
3214}
3215
Harald Weltea0630032018-03-20 21:09:55 +01003216/* first function inside ConnHdlr component; sets g_pars + starts function */
3217private function f_handler_init(void_fn fn, charstring id, template (omit) TestHdlrParams pars := omit)
3218runs on MSC_ConnHdlr {
3219 if (isvalue(pars)) {
3220 g_pars := valueof(pars);
3221 }
3222 fn.apply(id);
3223}
3224
Harald Welte3c86ea02018-05-10 22:28:05 +02003225/* Establish signalling channel (non-assignment case) followed by cipher mode */
3226private function f_tc_ciph_mode_a5(charstring id) runs on MSC_ConnHdlr {
Harald Welteed848512018-05-24 22:27:58 +02003227 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3228 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte3c86ea02018-05-10 22:28:05 +02003229 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeSIGNAL);
Philipp Maier23000732018-05-18 11:25:37 +02003230 ass_cmd.pdu.bssmap.assignmentRequest.circuitIdentityCode := omit;
3231 ass_cmd.pdu.bssmap.assignmentRequest.aoIPTransportLayer := omit;
3232 exp_compl.pdu.bssmap.assignmentComplete.circuitIdentityCode := omit;
3233 exp_compl.pdu.bssmap.assignmentComplete.aoIPTransportLayer := omit;
Harald Welte3c86ea02018-05-10 22:28:05 +02003234
Philipp Maier23000732018-05-18 11:25:37 +02003235 f_establish_fully(ass_cmd, exp_compl);
Harald Welte3c86ea02018-05-10 22:28:05 +02003236}
3237testcase TC_ciph_mode_a5_0() runs on test_CT {
3238 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003239 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02003240 pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
3241
3242 f_init(1, true);
3243 f_sleep(1.0);
3244 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
3245 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003246 f_shutdown_helper();
Harald Welte3c86ea02018-05-10 22:28:05 +02003247}
3248testcase TC_ciph_mode_a5_1() runs on test_CT {
3249 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003250 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02003251 pars.encr := valueof(t_EncrParams('02'O, f_rnd_octstring(8)));
3252
3253 f_init(1, true);
3254 f_sleep(1.0);
3255 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
3256 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003257 f_shutdown_helper();
Harald Welte3c86ea02018-05-10 22:28:05 +02003258}
3259testcase TC_ciph_mode_a5_3() runs on test_CT {
3260 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003261 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02003262 pars.encr := valueof(t_EncrParams('08'O, f_rnd_octstring(8)));
3263
3264 f_init(1, true);
3265 f_sleep(1.0);
3266 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
3267 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003268 f_shutdown_helper();
Harald Welte3c86ea02018-05-10 22:28:05 +02003269}
3270
Pau Espin Pedrol07866632020-09-03 19:10:55 +02003271/* establish initial channel, enable ciphering followed by assignment to ciphered channel */
3272private function f_tc_assignment_aoip_tla_v6(charstring id) runs on MSC_ConnHdlr {
3273 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3274 var PDU_BSSAP ass_cmd := f_gen_ass_req(aoip_tla := "::3");
3275 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3276 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
3277
3278 f_establish_fully(ass_cmd, exp_compl);
3279}
3280testcase TC_assignment_aoip_tla_v6() runs on test_CT {
3281 var MSC_ConnHdlr vc_conn;
3282 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3283
3284 f_init(1, true);
3285 f_sleep(1.0);
3286 vc_conn := f_start_handler(refers(f_tc_assignment_aoip_tla_v6), pars);
3287 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003288 f_shutdown_helper();
Pau Espin Pedrol07866632020-09-03 19:10:55 +02003289}
3290
Harald Welte3c86ea02018-05-10 22:28:05 +02003291
3292/* establish initial channel, enable ciphering followed by assignment to ciphered channel */
Harald Welte651fcdc2018-05-10 20:23:16 +02003293private function f_tc_assignment_fr_a5(charstring id) runs on MSC_ConnHdlr {
Harald Welteed848512018-05-24 22:27:58 +02003294 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3295 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Weltec1a2fff2017-12-17 11:06:19 +01003296
Harald Welte552620d2017-12-16 23:21:36 +01003297 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3298 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Welte73cd2712017-12-17 00:44:52 +01003299
Harald Weltea0630032018-03-20 21:09:55 +01003300 f_establish_fully(ass_cmd, exp_compl);
Harald Welte552620d2017-12-16 23:21:36 +01003301}
Harald Welte552620d2017-12-16 23:21:36 +01003302testcase TC_assignment_fr_a5_0() 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 Welte651fcdc2018-05-10 20:23:16 +02003305 pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
Harald Welte552620d2017-12-16 23:21:36 +01003306
Harald Welte89d42e82017-12-17 16:42:41 +01003307 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01003308 f_sleep(1.0);
Harald Welte651fcdc2018-05-10 20:23:16 +02003309 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
Harald Welte552620d2017-12-16 23:21:36 +01003310 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003311 f_shutdown_helper();
Harald Welte552620d2017-12-16 23:21:36 +01003312}
Harald Welte552620d2017-12-16 23:21:36 +01003313testcase TC_assignment_fr_a5_1() runs on test_CT {
Harald Weltec1a2fff2017-12-17 11:06:19 +01003314 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003315 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02003316 pars.encr := valueof(t_EncrParams('02'O, f_rnd_octstring(8)));
Harald Weltec1a2fff2017-12-17 11:06:19 +01003317
Harald Welte89d42e82017-12-17 16:42:41 +01003318 f_init(1, true);
Harald Weltec1a2fff2017-12-17 11:06:19 +01003319 f_sleep(1.0);
Harald Welte651fcdc2018-05-10 20:23:16 +02003320 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
3321 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003322 f_shutdown_helper();
Harald Welte651fcdc2018-05-10 20:23:16 +02003323}
3324testcase TC_assignment_fr_a5_3() runs on test_CT {
3325 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003326 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02003327 pars.encr := valueof(t_EncrParams('08'O, f_rnd_octstring(8)));
Harald Weltec1a2fff2017-12-17 11:06:19 +01003328
Harald Welte651fcdc2018-05-10 20:23:16 +02003329 f_init(1, true);
3330 f_sleep(1.0);
3331 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
Harald Weltec1a2fff2017-12-17 11:06:19 +01003332 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003333 f_shutdown_helper();
Harald Weltec1a2fff2017-12-17 11:06:19 +01003334}
3335
Harald Welte552620d2017-12-16 23:21:36 +01003336/* Expect ASSIGNMENT FAIL if mandatory IE is missing */
3337private function f_tc_assignment_fr_a5_1_codec_missing(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02003338 g_pars := f_gen_test_hdlr_pars();
Harald Welte552620d2017-12-16 23:21:36 +01003339 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +02003340 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte552620d2017-12-16 23:21:36 +01003341 const OCT8 kc := '0001020304050607'O;
3342
3343 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02003344 /* Omit: ass_cmd.pdu.bssmap.assignmentRequest.codecList */
3345
Harald Weltea0630032018-03-20 21:09:55 +01003346 f_establish_fully(ass_cmd, exp_fail);
Harald Welte552620d2017-12-16 23:21:36 +01003347}
Harald Welte552620d2017-12-16 23:21:36 +01003348testcase TC_assignment_fr_a5_1_codec_missing() runs on test_CT {
3349 var MSC_ConnHdlr vc_conn;
3350
Harald Welte89d42e82017-12-17 16:42:41 +01003351 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01003352 f_sleep(1.0);
3353
Harald Welte8863fa12018-05-10 20:15:27 +02003354 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5_1_codec_missing));
Harald Welte552620d2017-12-16 23:21:36 +01003355 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003356 f_shutdown_helper();
Harald Welte552620d2017-12-16 23:21:36 +01003357}
3358
Harald Welte552620d2017-12-16 23:21:36 +01003359private function f_tc_assignment_fr_a5_4(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02003360 g_pars := f_gen_test_hdlr_pars();
Harald Welteed848512018-05-24 22:27:58 +02003361 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3362 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte552620d2017-12-16 23:21:36 +01003363 const OCT8 kc := '0001020304050607'O;
3364 const OCT16 kc128 := kc & kc;
3365
3366 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3367 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Weltea0630032018-03-20 21:09:55 +01003368 f_establish_fully(ass_cmd, exp_compl);
Harald Welte38b2a102017-12-23 02:42:58 +01003369 f_cipher_mode('10'O, kc, kc128, true);
Harald Welte552620d2017-12-16 23:21:36 +01003370 /* TODO: expect GSM0808_CAUSE_CIPHERING_ALGORITHM_NOT_SUPPORTED cause value */
Harald Welte552620d2017-12-16 23:21:36 +01003371}
Harald Welte552620d2017-12-16 23:21:36 +01003372testcase TC_assignment_fr_a5_4() runs on test_CT {
3373 var MSC_ConnHdlr vc_conn;
3374
Harald Welte89d42e82017-12-17 16:42:41 +01003375 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01003376 f_sleep(1.0);
3377
Harald Welte8863fa12018-05-10 20:15:27 +02003378 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5_4));
Harald Welte552620d2017-12-16 23:21:36 +01003379 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003380 f_shutdown_helper();
Harald Welte552620d2017-12-16 23:21:36 +01003381}
3382
3383
Harald Welte4532e0a2017-12-23 02:05:44 +01003384private function f_tc_assignment_sign(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02003385 g_pars := f_gen_test_hdlr_pars();
Harald Welte4532e0a2017-12-23 02:05:44 +01003386 var template PDU_BSSAP exp_compl := tr_BSSMAP_AssignmentComplete(omit, omit);
Philipp Maier48604732018-10-09 15:00:37 +02003387 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte4532e0a2017-12-23 02:05:44 +01003388 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeSIGNAL);
Daniel Willmannebdecc02020-08-12 15:30:17 +02003389
3390 f_statsd_reset();
Harald Weltea0630032018-03-20 21:09:55 +01003391 f_establish_fully(ass_cmd, exp_compl);
Daniel Willmannebdecc02020-08-12 15:30:17 +02003392
3393 var StatsDExpects expect := {
Daniel Willmannc5398f72020-09-21 10:41:35 +02003394 { name := "TTCN3.bts.0.chreq.total", mtype := "c", min := 1, max := 1},
3395 { name := "TTCN3.bts.0.chreq.successful", mtype := "c", min := 1, max := 1},
Daniel Willmannebdecc02020-08-12 15:30:17 +02003396 { name := "TTCN3.bsc.0.assignment.attempted", mtype := "c", min := 1, max := 1},
3397 { name := "TTCN3.bsc.0.assignment.completed", mtype := "c", min := 1, max := 1}
3398 };
3399 f_statsd_expect(expect);
Harald Welte4532e0a2017-12-23 02:05:44 +01003400}
3401
3402testcase TC_assignment_sign() runs on test_CT {
3403 var MSC_ConnHdlr vc_conn;
3404
3405 f_init(1, true);
3406 f_sleep(1.0);
3407
Harald Welte8863fa12018-05-10 20:15:27 +02003408 vc_conn := f_start_handler(refers(f_tc_assignment_sign));
Harald Welte4532e0a2017-12-23 02:05:44 +01003409 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003410 f_shutdown_helper();
Harald Welte4532e0a2017-12-23 02:05:44 +01003411}
3412
Harald Welte60aa5762018-03-21 19:33:13 +01003413/***********************************************************************
3414 * Codec (list) testing
3415 ***********************************************************************/
3416
3417/* check if the given rsl_mode is compatible with the a_elem */
3418private function f_match_codec(BSSMAP_FIELD_CodecElement a_elem, RSL_IE_ChannelMode rsl_mode)
3419return boolean {
3420 select (a_elem.codecType) {
3421 case (GSM_FR) {
3422 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM1))) {
3423 return true;
3424 }
3425 }
3426 case (GSM_HR) {
3427 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1))) {
3428 return true;
3429 }
3430 }
3431 case (GSM_EFR) {
3432 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM2))) {
3433 return true;
3434 }
3435 }
3436 case (FR_AMR) {
3437 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM3))) {
3438 return true;
3439 }
3440 }
3441 case (HR_AMR) {
3442 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM3))) {
3443 return true;
3444 }
3445 }
3446 case else { }
3447 }
3448 return false;
3449}
3450
3451/* check if the given rsl_mode is compatible with the a_list */
3452private function f_match_codecs(BSSMAP_IE_SpeechCodecList a_list, RSL_IE_ChannelMode rsl_mode)
3453return boolean {
3454 for (var integer i := 0; i < sizeof(a_list); i := i+1) {
3455 if (f_match_codec(a_list.codecElements[i], rsl_mode)) {
3456 return true;
3457 }
3458 }
3459 return false;
3460}
3461
3462/* determine BSSMAP_IE_ChannelType from *first* element of BSSMAP_FIELD_CodecElement */
Philipp Maier61f6b572018-07-06 14:03:38 +02003463function f_BSSMAP_chtype_from_codec(BSSMAP_FIELD_CodecElement a_elem)
Harald Welte60aa5762018-03-21 19:33:13 +01003464return BSSMAP_IE_ChannelType {
3465 /* FIXME: actually look at all elements of BSSMAP_IE_SpeechCodecList */
3466 var BSSMAP_IE_ChannelType ret := valueof(ts_BSSMAP_IE_ChannelType);
3467 select (a_elem.codecType) {
3468 case (GSM_FR) {
3469 ret.channelRateAndType := ChRate_TCHF;
3470 ret.speechId_DataIndicator := Spdi_TCHF_FR;
3471 }
3472 case (GSM_HR) {
3473 ret.channelRateAndType := ChRate_TCHH;
3474 ret.speechId_DataIndicator := Spdi_TCHH_HR;
3475 }
3476 case (GSM_EFR) {
3477 ret.channelRateAndType := ChRate_TCHF;
3478 ret.speechId_DataIndicator := Spdi_TCHF_EFR;
3479 }
3480 case (FR_AMR) {
3481 ret.channelRateAndType := ChRate_TCHF;
3482 ret.speechId_DataIndicator := Spdi_TCHF_AMR;
3483 }
3484 case (HR_AMR) {
3485 ret.channelRateAndType := ChRate_TCHH;
3486 ret.speechId_DataIndicator := Spdi_TCHH_AMR;
3487 }
3488 case else {
3489 setverdict(fail, "Unsupported codec ", a_elem);
Daniel Willmannafce8662018-07-06 23:11:32 +02003490 mtc.stop;
Harald Welte60aa5762018-03-21 19:33:13 +01003491 }
3492 }
3493 return ret;
3494}
3495
Harald Weltea63b9102018-03-22 20:36:16 +01003496private function f_rsl_chmod_tmpl_from_codec(BSSMAP_FIELD_CodecElement a_elem)
3497return template RSL_IE_Body {
3498 var template RSL_IE_Body mode_ie := {
3499 chan_mode := {
3500 len := ?,
3501 reserved := ?,
3502 dtx_d := ?,
3503 dtx_u := ?,
3504 spd_ind := RSL_SPDI_SPEECH,
3505 ch_rate_type := -,
3506 coding_alg_rate := -
3507 }
3508 }
3509
3510 select (a_elem.codecType) {
3511 case (GSM_FR) {
3512 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
3513 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM1;
3514 }
3515 case (GSM_HR) {
3516 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_H;
3517 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM1;
3518 }
3519 case (GSM_EFR) {
3520 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
3521 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM2;
3522 }
3523 case (FR_AMR) {
3524 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
3525 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM3;
3526 }
3527 case (HR_AMR) {
3528 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_H;
3529 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM3;
3530 }
3531 }
3532 return mode_ie;
3533}
3534
Harald Welte60aa5762018-03-21 19:33:13 +01003535type record CodecListTest {
3536 BSSMAP_IE_SpeechCodecList codec_list,
3537 charstring id
3538}
3539type record of CodecListTest CodecListTests
3540
3541private function f_TC_assignment_codec(charstring id) runs on MSC_ConnHdlr {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02003542 var PDU_BSSAP ass_cmd := f_gen_ass_req(g_pars.use_osmux);
3543 var template PDU_BSSAP exp_compl := f_gen_exp_compl(g_pars.use_osmux);
Harald Welte60aa5762018-03-21 19:33:13 +01003544
3545 /* puzzle together the ASSIGNMENT REQ for given codec[s] */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003546 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welte79f3f542018-05-25 20:02:37 +02003547 ass_cmd.pdu.bssmap.assignmentRequest.codecList := g_pars.ass_codec_list;
3548 exp_compl.pdu.bssmap.assignmentComplete.speechCodec.codecElements[0] :=
3549 g_pars.ass_codec_list.codecElements[0];
Philipp Maierd0e64b02019-03-13 14:15:23 +01003550 if (isvalue(g_pars.expect_mr_s0_s7)) {
3551 exp_compl.pdu.bssmap.assignmentComplete.speechCodec.codecElements[0].s0_7 :=
3552 g_pars.expect_mr_s0_s7;
3553 }
Harald Welte79f3f542018-05-25 20:02:37 +02003554 }
Harald Welte60aa5762018-03-21 19:33:13 +01003555 ass_cmd.pdu.bssmap.assignmentRequest.channelType :=
3556 f_BSSMAP_chtype_from_codec(g_pars.ass_codec_list.codecElements[0]);
Harald Welte60aa5762018-03-21 19:33:13 +01003557 log("expecting ASS COMPL like this: ", exp_compl);
3558
3559 f_establish_fully(ass_cmd, exp_compl);
Harald Weltea63b9102018-03-22 20:36:16 +01003560
3561 /* Verify that the RSL-side activation actually matches our expectations */
3562 var RSL_Message rsl := f_rslem_get_last_act(RSL_PROC, 0, g_chan_nr);
3563
3564 var RSL_IE_Body mode_ie;
3565 if (f_rsl_find_ie(rsl, RSL_IE_CHAN_MODE, mode_ie) == false) {
3566 setverdict(fail, "Couldn't find CHAN_MODE IE");
Daniel Willmannafce8662018-07-06 23:11:32 +02003567 mtc.stop;
Harald Weltea63b9102018-03-22 20:36:16 +01003568 }
3569 var template RSL_IE_Body t_mode_ie := f_rsl_chmod_tmpl_from_codec(g_pars.ass_codec_list.codecElements[0]);
3570 if (not match(mode_ie, t_mode_ie)) {
3571 setverdict(fail, "RSL Channel Mode IE doesn't match expectation");
3572 }
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003573
3574 var RSL_IE_Body mr_conf;
3575 if (g_pars.expect_mr_conf_ie != omit) {
3576 if (f_rsl_find_ie(rsl, RSL_IE_MR_CONFIG, mr_conf) == false) {
3577 setverdict(fail, "Missing MR CONFIG IE in RSL Chan Activ");
Daniel Willmannafce8662018-07-06 23:11:32 +02003578 mtc.stop;
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003579 }
3580 log("found RSL MR CONFIG IE: ", mr_conf);
3581
3582 if (not match(mr_conf, g_pars.expect_mr_conf_ie)) {
3583 setverdict(fail, "RSL MR CONFIG IE does not match expectation. Expected: ",
3584 g_pars.expect_mr_conf_ie);
3585 }
3586 } else {
3587 if (f_rsl_find_ie(rsl, RSL_IE_MR_CONFIG, mr_conf) == true) {
3588 log("found RSL MR CONFIG IE: ", mr_conf);
3589 setverdict(fail, "Found MR CONFIG IE in RSL Chan Activ, expecting omit");
Daniel Willmannafce8662018-07-06 23:11:32 +02003590 mtc.stop;
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003591 }
3592 }
Harald Welte60aa5762018-03-21 19:33:13 +01003593}
3594
Philipp Maierd0e64b02019-03-13 14:15:23 +01003595private function f_TC_assignment_codec_fail(charstring id) runs on MSC_ConnHdlr {
3596
3597 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3598 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
3599
3600 /* puzzle together the ASSIGNMENT REQ for given codec[s] */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003601 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Philipp Maierd0e64b02019-03-13 14:15:23 +01003602 ass_cmd.pdu.bssmap.assignmentRequest.codecList := g_pars.ass_codec_list;
3603 }
3604 ass_cmd.pdu.bssmap.assignmentRequest.channelType :=
3605 f_BSSMAP_chtype_from_codec(g_pars.ass_codec_list.codecElements[0]);
3606 log("expecting ASS FAIL like this: ", exp_fail);
3607
3608 f_establish_fully(ass_cmd, exp_fail);
3609}
3610
Harald Welte60aa5762018-03-21 19:33:13 +01003611testcase TC_assignment_codec_fr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003612 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003613 var MSC_ConnHdlr vc_conn;
3614
3615 f_init(1, true);
3616 f_sleep(1.0);
3617
3618 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Welte8863fa12018-05-10 20:15:27 +02003619 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003620 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003621 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01003622}
3623
3624testcase TC_assignment_codec_hr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003625 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003626 var MSC_ConnHdlr vc_conn;
3627
3628 f_init(1, true);
3629 f_sleep(1.0);
3630
3631 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
Harald Welte8863fa12018-05-10 20:15:27 +02003632 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003633 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003634 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01003635}
3636
3637testcase TC_assignment_codec_efr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003638 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003639 var MSC_ConnHdlr vc_conn;
3640
3641 f_init(1, true);
3642 f_sleep(1.0);
3643
3644 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecEFR}));
Harald Welte8863fa12018-05-10 20:15:27 +02003645 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003646 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003647 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01003648}
3649
Philipp Maierd0e64b02019-03-13 14:15:23 +01003650/* Allow 5,90k only (current default config) */
3651private function f_allow_amr_rate_5_90k() runs on test_CT {
Neels Hofmeyr2a5670b2020-11-25 23:39:57 +00003652 f_vty_cfg_msc(BSCVTY, 0, {
3653 "amr-config 12_2k forbidden",
3654 "amr-config 10_2k forbidden",
3655 "amr-config 7_95k forbidden",
3656 "amr-config 7_40k forbidden",
3657 "amr-config 6_70k forbidden",
3658 "amr-config 5_90k allowed",
3659 "amr-config 5_15k forbidden",
3660 "amr-config 4_75k forbidden"
3661 });
Philipp Maierd0e64b02019-03-13 14:15:23 +01003662}
3663
3664/* Allow 4,75k, 5,90k, 4,70k and 12,2k, which are the most common rates
3665 * ("Config-NB-Code = 1") */
3666private function f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k() runs on test_CT {
Neels Hofmeyr2a5670b2020-11-25 23:39:57 +00003667 f_vty_cfg_msc(BSCVTY, 0, {
3668 "amr-config 12_2k allowed",
3669 "amr-config 10_2k forbidden",
3670 "amr-config 7_95k forbidden",
3671 "amr-config 7_40k allowed",
3672 "amr-config 6_70k forbidden",
3673 "amr-config 5_90k allowed",
3674 "amr-config 5_15k forbidden",
3675 "amr-config 4_75k allowed"
3676 });
Philipp Maierd0e64b02019-03-13 14:15:23 +01003677}
3678
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003679private function f_vty_amr_start_mode_set(boolean fr, charstring startmode) runs on test_CT {
3680 var charstring tch;
3681 if (fr) {
3682 tch := "tch-f";
3683 } else {
3684 tch := "tch-h";
3685 }
3686 f_vty_cfg_bts(BSCVTY, 0, { "amr " & tch & " start-mode " & startmode });
3687}
3688
3689/* Set the AMR start-mode for this TCH back to the default configuration. */
3690private function f_vty_amr_start_mode_restore(boolean fr) runs on test_CT {
3691 f_vty_amr_start_mode_set(fr, "auto");
3692}
3693
Harald Welte60aa5762018-03-21 19:33:13 +01003694testcase TC_assignment_codec_amr_f() 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;
Philipp Maier7695a0d2018-09-27 17:52:14 +02003697
3698 /* Note: This setups the codec configuration. The parameter payload in
3699 * mr_conf must be consistant with the parameter codecElements in pars
3700 * and also must match the amr-config in osmo-bsc.cfg! */
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003701 var RSL_IE_Body mr_conf := {
3702 other := {
3703 len := 2,
3704 payload := '2804'O
3705 }
3706 };
Harald Welte60aa5762018-03-21 19:33:13 +01003707
Philipp Maier7695a0d2018-09-27 17:52:14 +02003708 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
Philipp Maier806f8f12019-03-12 12:13:41 +01003709 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
Philipp Maier7695a0d2018-09-27 17:52:14 +02003710 pars.ass_codec_list.codecElements[0].s8_15 := '01010111'B;
3711 pars.expect_mr_conf_ie := mr_conf;
3712
Harald Welte60aa5762018-03-21 19:33:13 +01003713 f_init(1, true);
3714 f_sleep(1.0);
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003715 f_vty_amr_start_mode_set(true, "1");
Harald Welte60aa5762018-03-21 19:33:13 +01003716
Harald Welte8863fa12018-05-10 20:15:27 +02003717 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003718 vc_conn.done;
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003719
3720 f_vty_amr_start_mode_restore(true);
Vadim Yanitskiy292e5962021-01-03 14:18:47 +01003721 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01003722}
3723
3724testcase TC_assignment_codec_amr_h() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003725 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003726 var MSC_ConnHdlr vc_conn;
Philipp Maier7695a0d2018-09-27 17:52:14 +02003727
3728 /* See note above */
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003729 var RSL_IE_Body mr_conf := {
3730 other := {
3731 len := 2,
3732 payload := '2804'O
3733 }
3734 };
Harald Welte60aa5762018-03-21 19:33:13 +01003735
Philipp Maier7695a0d2018-09-27 17:52:14 +02003736 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
Philipp Maier806f8f12019-03-12 12:13:41 +01003737 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
Philipp Maier7695a0d2018-09-27 17:52:14 +02003738 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
3739 pars.expect_mr_conf_ie := mr_conf;
3740
Harald Welte60aa5762018-03-21 19:33:13 +01003741 f_init(1, true);
3742 f_sleep(1.0);
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003743 f_vty_amr_start_mode_set(false, "1");
Harald Welte60aa5762018-03-21 19:33:13 +01003744
Harald Welte8863fa12018-05-10 20:15:27 +02003745 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003746 vc_conn.done;
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003747
3748 f_vty_amr_start_mode_restore(false);
Vadim Yanitskiy292e5962021-01-03 14:18:47 +01003749 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01003750}
3751
Neels Hofmeyr454d7922020-11-26 02:24:57 +00003752/* 'amr start-mode auto' should not keep the (unused) 'smod' bits from previous configuration */
3753testcase TC_assignment_codec_amr_startmode_cruft() runs on test_CT {
3754 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3755 var MSC_ConnHdlr vc_conn;
3756
3757 var RSL_IE_Body mr_conf := {
3758 other := {
3759 len := 2,
3760 payload := '2004'O /* <- expect ICMI=0, smod=00 */
3761 }
3762 };
3763
3764 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
3765 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
3766 pars.ass_codec_list.codecElements[0].s8_15 := '01010111'B;
3767 pars.expect_mr_conf_ie := mr_conf;
3768
3769 f_init(1, true);
3770 f_sleep(1.0);
3771
3772 /* First set nonzero start mode bits */
3773 f_vty_amr_start_mode_set(true, "4");
3774 /* Now set to auto, and expect the startmode bits to be zero in the message, i.e. ensure that osmo-bsc does not
3775 * let the startmode bits stick around and has deterministic MultiRate config for 'start-mode auto'; that is
3776 * ensured by above '2004'O, where 'x0xx'O indicates ICMI = 0, spare = 0, smod = 00. */
3777 f_vty_amr_start_mode_set(true, "auto");
3778
3779 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
3780 vc_conn.done;
Neels Hofmeyr454d7922020-11-26 02:24:57 +00003781
3782 /* Clear the startmode bits to not affect subsequent tests, in case the bits should indeed stick around. */
3783 f_vty_amr_start_mode_set(true, "1");
3784 f_vty_amr_start_mode_restore(true);
Vadim Yanitskiy292e5962021-01-03 14:18:47 +01003785 f_shutdown_helper();
Neels Hofmeyr454d7922020-11-26 02:24:57 +00003786}
3787
Neels Hofmeyr21863562020-11-26 00:34:33 +00003788function f_TC_assignment_codec_amr(boolean fr, octetstring mrconf, bitstring s8_s0, bitstring exp_s8_s0,
3789 charstring start_mode := "1")
Philipp Maierd0e64b02019-03-13 14:15:23 +01003790runs on test_CT {
3791
3792 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3793 var MSC_ConnHdlr vc_conn;
3794
3795 /* See note above */
3796 var RSL_IE_Body mr_conf := {
3797 other := {
3798 len := lengthof(mrconf),
3799 payload := mrconf
3800 }
3801 };
3802
3803 if (fr) {
3804 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
3805 } else {
3806 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
3807 }
3808 pars.ass_codec_list.codecElements[0].s0_7 := s8_s0;
3809 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
3810 pars.expect_mr_conf_ie := mr_conf;
3811 pars.expect_mr_s0_s7 := exp_s8_s0;
3812
3813 f_init(1, true);
3814 f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k();
Neels Hofmeyr21863562020-11-26 00:34:33 +00003815 f_vty_amr_start_mode_set(fr, start_mode);
Philipp Maierd0e64b02019-03-13 14:15:23 +01003816 f_sleep(1.0);
3817
3818 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
3819 vc_conn.done;
3820 f_allow_amr_rate_5_90k();
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003821 f_vty_amr_start_mode_restore(fr);
Philipp Maierd0e64b02019-03-13 14:15:23 +01003822}
3823
3824function f_TC_assignment_codec_amr_fail(boolean fr, bitstring s8_s0)
3825runs on test_CT {
3826
3827 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3828 var MSC_ConnHdlr vc_conn;
3829
3830 if (fr) {
3831 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
3832 } else {
3833 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
3834 }
3835 pars.ass_codec_list.codecElements[0].s0_7 := s8_s0;
3836 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
3837
3838 f_init(1, true);
3839 f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k();
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003840 f_vty_amr_start_mode_set(fr, "1");
Philipp Maierd0e64b02019-03-13 14:15:23 +01003841 f_sleep(1.0);
3842
3843 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fail), pars);
3844 vc_conn.done;
3845 f_allow_amr_rate_5_90k();
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003846 f_vty_amr_start_mode_restore(fr);
Philipp Maierd0e64b02019-03-13 14:15:23 +01003847}
3848
3849
3850/* Set S1, we expect an AMR multirate configuration IE with all four rates
3851 * set. */
3852testcase TC_assignment_codec_amr_f_S1() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003853 f_TC_assignment_codec_amr(true, '289520882208'O, '00000010'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003854 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003855}
3856
3857/* Set S1, we expect an AMR multirate configuration IE with the lower three
3858 * rates set. */
3859testcase TC_assignment_codec_amr_h_S1() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003860 f_TC_assignment_codec_amr(false, '2815208820'O, '00000010'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003861 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003862}
3863
3864/* Set S1 and two other rates, we expect an AMR MULTIRATE CONFIGURATION IE with
3865 * all four rates (and only S1 set in the ASSIGNMENT COMPLETE) */
3866testcase TC_assignment_codec_amr_f_S124() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003867 f_TC_assignment_codec_amr(true, '289520882208'O, '00010110'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003868 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003869}
3870
3871/* Set S1 and two other rates, we expect an AMR MULTIRATE CONFIGURATION IE with
3872 * all four rates (and only S1 set in the ASSIGNMENT COMPLETE) */
3873testcase TC_assignment_codec_amr_h_S124() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003874 f_TC_assignment_codec_amr(false, '2815208820'O, '00010110'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003875 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003876}
3877
3878/* The following block of tests selects more and more rates until all four
3879 * possible rates are in the active set (full rate) */
3880testcase TC_assignment_codec_amr_f_S0() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003881 f_TC_assignment_codec_amr(true, '2801'O, '00000001'B, '00000001'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003882 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003883}
3884
3885testcase TC_assignment_codec_amr_f_S02() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003886 f_TC_assignment_codec_amr(true, '28052080'O, '00000101'B, '00000101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003887 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003888}
3889
3890testcase TC_assignment_codec_amr_f_S024() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003891 f_TC_assignment_codec_amr(true, '2815208820'O, '00010101'B, '00010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003892 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003893}
3894
3895testcase TC_assignment_codec_amr_f_S0247() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003896 f_TC_assignment_codec_amr(true, '289520882208'O, '10010101'B, '10010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003897 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003898}
3899
3900/* The following block of tests selects more and more rates until all three
3901 * possible rates are in the active set (half rate) */
3902testcase TC_assignment_codec_amr_h_S0() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003903 f_TC_assignment_codec_amr(false, '2801'O, '00000001'B, '00000001'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003904 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003905}
3906
3907testcase TC_assignment_codec_amr_h_S02() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003908 f_TC_assignment_codec_amr(false, '28052080'O, '00000101'B, '00000101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003909 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003910}
3911
3912testcase TC_assignment_codec_amr_h_S024() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003913 f_TC_assignment_codec_amr(false, '2815208820'O, '00010101'B, '00010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003914 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003915}
3916
3917/* The following block tests what happens when the MSC does offer rate
3918 * configurations that are not supported by the BSC. Normally such situations
3919 * should not happen because the MSC gets informed by the BSC in advance via
3920 * the L3 COMPLETE message which rates are applicable. The MSC should not try
3921 * to offer rates that are not applicable anyway. */
3922
3923testcase TC_assignment_codec_amr_h_S0247() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003924 /* Try to include 12,2k in into the active set even though the channel
3925 * is half rate only. The BSC is expected to remove the 12,0k */
3926 f_TC_assignment_codec_amr(false, '2815208820'O, '10010101'B, '00010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003927 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003928}
3929
3930testcase TC_assignment_codec_amr_f_S01234567() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003931 /* See what happens when all rates are selected at once. Since then
3932 * Also S1 is selected, this setting will be prefered and we should
3933 * get 12.2k, 7,40k, 5,90k, and 4,75k in the active set. */
3934 f_TC_assignment_codec_amr(true, '289520882208'O, '11111111'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003935 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003936}
3937
3938testcase TC_assignment_codec_amr_f_S0234567() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003939 /* Same as above, but with S1 missing, the MSC is then expected to
3940 * select the currently supported rates, which are also 12.2k, 7,40k,
3941 * 5,90k, and 4,75k, into the active set. */
3942 f_TC_assignment_codec_amr(true, '289520882208'O, '11111101'B, '10010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003943 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003944}
3945
3946testcase TC_assignment_codec_amr_f_zero() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003947 /* Try to select no rates at all */
3948 f_TC_assignment_codec_amr_fail(true, '00000000'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003949 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003950}
3951
3952testcase TC_assignment_codec_amr_f_unsupp() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003953 /* Try to select only unsupported rates */
3954 f_TC_assignment_codec_amr_fail(true, '01101000'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003955 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003956}
3957
3958testcase TC_assignment_codec_amr_h_S7() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003959 /* Try to select 12,2k for half rate */
3960 f_TC_assignment_codec_amr_fail(false, '10000000'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003961 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003962}
3963
Neels Hofmeyr21863562020-11-26 00:34:33 +00003964testcase TC_assignment_codec_amr_f_start_mode_auto() runs on test_CT {
3965 f_TC_assignment_codec_amr(true, '209520882208'O, '11111111'B, '00000010'B,
3966 start_mode := "auto");
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01003967 f_shutdown_helper();
Neels Hofmeyr21863562020-11-26 00:34:33 +00003968}
3969
3970testcase TC_assignment_codec_amr_h_start_mode_auto() runs on test_CT {
3971 f_TC_assignment_codec_amr(false, '2015208820'O, '10010101'B, '00010101'B,
3972 start_mode := "auto");
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01003973 f_shutdown_helper();
Neels Hofmeyr21863562020-11-26 00:34:33 +00003974}
3975
Neels Hofmeyr3eb94562020-11-26 02:40:26 +00003976testcase TC_assignment_codec_amr_f_start_mode_4() runs on test_CT {
Vadim Yanitskiy7815f482021-01-03 17:07:37 +01003977 /* "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 +00003978 f_TC_assignment_codec_amr(true, '2b9520882208'O, '11111111'B, '00000010'B,
3979 start_mode := "4");
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01003980 f_shutdown_helper();
Neels Hofmeyr3eb94562020-11-26 02:40:26 +00003981}
3982
3983testcase TC_assignment_codec_amr_h_start_mode_4() runs on test_CT {
Vadim Yanitskiy7815f482021-01-03 17:07:37 +01003984 /* "amr tch-h modes 0 2 4" => total 3 modes and start mode 4 => '10'B on the wire */
3985 f_TC_assignment_codec_amr(false, '2a15208820'O, '10010101'B, '00010101'B,
Neels Hofmeyr3eb94562020-11-26 02:40:26 +00003986 start_mode := "4");
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01003987 f_shutdown_helper();
Neels Hofmeyr3eb94562020-11-26 02:40:26 +00003988}
3989
Philipp Maierac09bfc2019-01-08 13:41:39 +01003990private function f_disable_all_tch_f() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01003991 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 1 sub-slot 0 borken");
3992 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 2 sub-slot 0 borken");
3993 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 3 sub-slot 0 borken");
3994 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 4 sub-slot 0 borken");
Philipp Maierac09bfc2019-01-08 13:41:39 +01003995}
3996
3997private function f_disable_all_tch_h() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01003998 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 0 borken");
3999 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 1 borken");
Philipp Maierac09bfc2019-01-08 13:41:39 +01004000}
4001
4002private function f_enable_all_tch() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01004003 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 1 sub-slot 0 unused");
4004 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 2 sub-slot 0 unused");
4005 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 3 sub-slot 0 unused");
4006 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 4 sub-slot 0 unused");
4007 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 0 unused");
4008 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 1 unused");
Philipp Maierac09bfc2019-01-08 13:41:39 +01004009}
4010
4011/* Allow HR only */
4012private function f_TC_assignment_codec_xr_exhausted_req_hr(charstring id) runs on MSC_ConnHdlr {
4013 g_pars := f_gen_test_hdlr_pars();
4014 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4015 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4016 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4017 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '09'O;
4018 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '05'O;
4019 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
4020 f_establish_fully(ass_cmd, exp_compl);
4021}
4022
4023/* Allow FR only */
4024private function f_TC_assignment_codec_xr_exhausted_req_fr(charstring id) runs on MSC_ConnHdlr {
4025 g_pars := f_gen_test_hdlr_pars();
4026 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4027 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4028 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4029 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '08'O;
4030 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '01'O;
4031 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4032 f_establish_fully(ass_cmd, exp_compl);
4033}
4034
4035/* Allow HR only (expect assignment failure) */
4036private function f_TC_assignment_codec_xr_exhausted_req_hr_fail(charstring id) runs on MSC_ConnHdlr {
4037 g_pars := f_gen_test_hdlr_pars();
4038 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4039 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
4040 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4041 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '09'O;
4042 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '05'O;
4043 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
4044 f_establish_fully(ass_cmd, exp_fail);
4045}
4046
4047/* Allow FR only (expect assignment failure) */
4048private function f_TC_assignment_codec_xr_exhausted_req_fr_fail(charstring id) runs on MSC_ConnHdlr {
4049 g_pars := f_gen_test_hdlr_pars();
4050 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4051 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
4052 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4053 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '08'O;
4054 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '01'O;
4055 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4056 f_establish_fully(ass_cmd, exp_fail);
4057}
4058
4059/* Allow FR and HR, but prefer FR */
4060private function f_TC_assignment_codec_fr_exhausted_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
4061 g_pars := f_gen_test_hdlr_pars();
4062 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4063 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4064 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4065 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
4066 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
4067 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
4068 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
4069 f_establish_fully(ass_cmd, exp_compl);
4070}
4071
4072/* Allow FR and HR, but prefer HR */
4073private function f_TC_assignment_codec_fr_exhausted_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
4074 g_pars := f_gen_test_hdlr_pars();
4075 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4076 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4077 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4078 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
4079 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
4080 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
4081 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
4082 f_establish_fully(ass_cmd, exp_compl);
4083}
4084
4085/* Allow FR and HR, but prefer FR */
4086private function f_TC_assignment_codec_hr_exhausted_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
4087 g_pars := f_gen_test_hdlr_pars();
4088 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4089 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4090 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4091 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
4092 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
4093 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
4094 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
4095 f_establish_fully(ass_cmd, exp_compl);
4096}
4097
4098/* Allow FR and HR, but prefer HR */
4099private function f_TC_assignment_codec_hr_exhausted_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
4100 g_pars := f_gen_test_hdlr_pars();
4101 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4102 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4103 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4104 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
4105 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
4106 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
4107 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
4108 f_establish_fully(ass_cmd, exp_compl);
4109}
4110
4111/* Request a HR channel while all FR channels are exhausted, this is expected
4112 * to work without conflicts */
4113testcase TC_assignment_codec_fr_exhausted_req_hr() runs on test_CT {
4114 var MSC_ConnHdlr vc_conn;
4115 f_init(1, true);
4116 f_sleep(1.0);
4117 f_enable_all_tch();
4118 f_disable_all_tch_f();
4119 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_hr));
4120 vc_conn.done;
4121 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004122 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004123}
4124
4125/* Request a FR channel while all FR channels are exhausted, this is expected
4126 * to fail. */
4127testcase TC_assignment_codec_fr_exhausted_req_fr() runs on test_CT {
4128 var MSC_ConnHdlr vc_conn;
4129 f_init(1, true);
4130 f_sleep(1.0);
4131 f_enable_all_tch();
4132 f_disable_all_tch_f();
4133 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_fr_fail));
4134 vc_conn.done;
4135 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004136 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004137}
4138
4139/* Request a FR (prefered) or alternatively a HR channel while all FR channels
4140 * are exhausted, this is expected to be resolved by selecting a HR channel. */
4141testcase TC_assignment_codec_fr_exhausted_req_fr_hr() runs on test_CT {
4142 var MSC_ConnHdlr vc_conn;
4143 f_init(1, true);
4144 f_sleep(1.0);
4145 f_enable_all_tch();
4146 f_disable_all_tch_f();
4147 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fr_exhausted_req_fr_hr));
4148 vc_conn.done;
4149 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004150 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004151}
4152
4153/* Request a HR (prefered) or alternatively a FR channel while all FR channels
4154 * are exhausted, this is expected to work without conflicts. */
4155testcase TC_assignment_codec_fr_exhausted_req_hr_fr() runs on test_CT {
4156 var MSC_ConnHdlr vc_conn;
4157 f_init(1, true);
4158 f_sleep(1.0);
4159 f_enable_all_tch();
4160 f_disable_all_tch_f();
4161 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fr_exhausted_req_hr_fr));
4162 vc_conn.done;
4163 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004164 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004165}
4166
4167/* Request a FR channel while all HR channels are exhausted, this is expected
4168 * to work without conflicts */
4169testcase TC_assignment_codec_hr_exhausted_req_fr() runs on test_CT {
4170 var MSC_ConnHdlr vc_conn;
4171 f_init(1, true);
4172 f_sleep(1.0);
4173 f_enable_all_tch();
4174 f_disable_all_tch_h();
4175 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_fr));
4176 vc_conn.done;
4177 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004178 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004179}
4180
4181/* Request a HR channel while all HR channels are exhausted, this is expected
4182 * to fail. */
4183testcase TC_assignment_codec_hr_exhausted_req_hr() runs on test_CT {
4184 var MSC_ConnHdlr vc_conn;
4185 f_init(1, true);
4186 f_sleep(1.0);
4187 f_enable_all_tch();
4188 f_disable_all_tch_h();
4189 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_hr_fail));
4190 vc_conn.done;
4191 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004192 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004193}
4194
4195/* Request a HR (prefered) or alternatively a FR channel while all HR channels
4196 * are exhausted, this is expected to be resolved by selecting a FR channel. */
4197testcase TC_assignment_codec_hr_exhausted_req_hr_fr() runs on test_CT {
4198 var MSC_ConnHdlr vc_conn;
4199 f_init(1, true);
4200 f_sleep(1.0);
4201 f_enable_all_tch();
4202 f_disable_all_tch_h();
4203 vc_conn := f_start_handler(refers(f_TC_assignment_codec_hr_exhausted_req_hr_fr));
4204 vc_conn.done;
4205 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004206 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004207}
4208
4209/* Request a FR (prefered) or alternatively a HR channel while all HR channels
4210 * are exhausted, this is expected to work without conflicts. */
4211testcase TC_assignment_codec_hr_exhausted_req_fr_hr() runs on test_CT {
4212 var MSC_ConnHdlr vc_conn;
4213 f_init(1, true);
4214 f_sleep(1.0);
4215 f_enable_all_tch();
4216 f_disable_all_tch_h();
4217 vc_conn := f_start_handler(refers(f_TC_assignment_codec_hr_exhausted_req_fr_hr));
4218 vc_conn.done;
4219 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004220 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004221}
4222
4223/* Allow FR and HR, but prefer HR */
4224private function f_TC_assignment_codec_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
4225 g_pars := f_gen_test_hdlr_pars();
4226 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4227 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4228 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4229 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
4230 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
4231 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
4232 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
4233 f_establish_fully(ass_cmd, exp_compl);
4234}
4235
4236/* Allow FR and HR, but prefer FR */
4237private function f_TC_assignment_codec_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
4238 g_pars := f_gen_test_hdlr_pars();
4239 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4240 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4241 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4242 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
4243 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
4244 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
4245 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
4246 f_establish_fully(ass_cmd, exp_compl);
4247}
4248
4249/* Request a HR (prefered) or alternatively a FR channel, it is expected that
4250 * HR, which is the prefered type, is selected. */
4251testcase TC_assignment_codec_req_hr_fr() runs on test_CT {
4252 var MSC_ConnHdlr vc_conn;
4253 f_init(1, true);
4254 f_sleep(1.0);
4255 f_enable_all_tch();
4256 vc_conn := f_start_handler(refers(f_TC_assignment_codec_req_hr_fr));
4257 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004258 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004259}
4260
4261/* Request a FR (prefered) or alternatively a HR channel, it is expected that
4262 * FR, which is the prefered type, is selected. */
4263testcase TC_assignment_codec_req_fr_hr() runs on test_CT {
4264 var MSC_ConnHdlr vc_conn;
4265 f_init(1, true);
4266 f_sleep(1.0);
4267 f_enable_all_tch();
4268 vc_conn := f_start_handler(refers(f_TC_assignment_codec_req_fr_hr));
4269 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004270 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004271}
4272
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02004273testcase TC_assignment_osmux() runs on test_CT {
4274 var TestHdlrParams pars := f_gen_test_hdlr_pars();
4275 var MSC_ConnHdlr vc_conn;
4276
4277 /* See note above */
4278 var RSL_IE_Body mr_conf := {
4279 other := {
4280 len := 2,
4281 payload := '2804'O
4282 }
4283 };
4284
4285 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
4286 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
4287 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
4288 pars.expect_mr_conf_ie := mr_conf;
4289 pars.use_osmux := true;
4290
4291 f_init(1, true, true);
4292 f_sleep(1.0);
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00004293 f_vty_amr_start_mode_set(false, "1");
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02004294
4295 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
4296 vc_conn.done;
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00004297
4298 f_vty_amr_start_mode_restore(false);
Vadim Yanitskiy292e5962021-01-03 14:18:47 +01004299 f_shutdown_helper();
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02004300}
4301
Neels Hofmeyr92b12b72018-09-18 14:30:23 +02004302/* test the procedure of the MSC requesting a Classmark Update:
4303 * a) BSSMAP Classmark Request should result in RR CLASSMARK ENQUIRY,
4304 * b) L3 RR CLASSMARK CHANGE should result in BSSMAP CLASSMARK UPDATE */
Harald Welte898113b2018-01-31 18:32:21 +01004305private function f_tc_classmark(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004306 g_pars := f_gen_test_hdlr_pars();
4307
Harald Weltea0630032018-03-20 21:09:55 +01004308 f_create_chan_and_exp();
Harald Welte898113b2018-01-31 18:32:21 +01004309 /* we should now have a COMPL_L3 at the MSC */
4310 BSSAP.receive(tr_BSSMAP_ComplL3);
4311
Neels Hofmeyr92b12b72018-09-18 14:30:23 +02004312 BSSAP.send(ts_BSSMAP_ClassmarkRequest);
4313 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_CM_ENQUIRY));
4314
Harald Welte898113b2018-01-31 18:32:21 +01004315 f_rsl_send_l3(ts_RRM_CM_CHG(valueof(ts_CM2)));
4316 BSSAP.receive(tr_BSSMAP_ClassmarkUpd(?, omit));
4317 setverdict(pass);
4318}
4319testcase TC_classmark() runs on test_CT {
4320 var MSC_ConnHdlr vc_conn;
4321 f_init(1, true);
4322 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004323 vc_conn := f_start_handler(refers(f_tc_classmark));
Harald Welte898113b2018-01-31 18:32:21 +01004324 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004325 f_shutdown_helper();
Harald Welte898113b2018-01-31 18:32:21 +01004326}
4327
Harald Welteeddf0e92020-06-21 19:42:15 +02004328/* Send a CommonID from the simulated MSC and verify that the information is used to
4329 * fill BSC-internal data structures (specifically, bsc_subscr associated with subscr_conn) */
4330private function f_tc_common_id(charstring id) runs on MSC_ConnHdlr {
4331 g_pars := f_gen_test_hdlr_pars();
4332 f_MscConnHdlr_init_vty();
4333
4334 f_create_chan_and_exp();
4335 /* we should now have a COMPL_L3 at the MSC */
4336 BSSAP.receive(tr_BSSMAP_ComplL3);
4337
4338 /* Send CommonID */
4339 BSSAP.send(ts_BSSMAP_CommonId(g_pars.imsi));
4340
4341 /* Use VTY to verify that the IMSI of the subscr_conn is set */
4342 var charstring regex := "*(IMSI: " & hex2str(g_pars.imsi) & ")*";
4343 f_vty_transceive_match_regexp_retry(BSCVTY, "show conns", regex, 0, 4, 1.0);
4344
4345 setverdict(pass);
4346}
4347testcase TC_common_id() runs on test_CT {
4348 var MSC_ConnHdlr vc_conn;
4349 f_init(1, true);
4350 f_sleep(1.0);
4351 vc_conn := f_start_handler(refers(f_tc_common_id));
4352 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004353 f_shutdown_helper();
Harald Welteeddf0e92020-06-21 19:42:15 +02004354}
4355
Harald Weltee3bd6582018-01-31 22:51:25 +01004356private function f_est_single_l3(template PDU_ML3_MS_NW l3) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004357 g_pars := f_gen_test_hdlr_pars();
Harald Weltea0630032018-03-20 21:09:55 +01004358 f_create_chan_and_exp();
Harald Welte898113b2018-01-31 18:32:21 +01004359 /* we should now have a COMPL_L3 at the MSC */
4360 BSSAP.receive(tr_BSSMAP_ComplL3);
4361
Harald Weltee3bd6582018-01-31 22:51:25 +01004362 /* send the single message we want to send */
4363 f_rsl_send_l3(l3);
4364}
4365
4366private function f_bssap_expect_nothing(float sec := 5.00) runs on MSC_ConnHdlr {
4367 timer T := sec;
4368 var PDU_BSSAP bssap;
Harald Welte898113b2018-01-31 18:32:21 +01004369 T.start;
4370 alt {
Harald Weltee3bd6582018-01-31 22:51:25 +01004371 [] BSSAP.receive(PDU_BSSAP:?) -> value bssap {
4372 setverdict(fail, "Unexpected BSSMAP ", bssap);
Daniel Willmannafce8662018-07-06 23:11:32 +02004373 mtc.stop;
Harald Welte898113b2018-01-31 18:32:21 +01004374 }
4375 [] T.timeout {
4376 setverdict(pass);
4377 }
4378 }
4379}
4380
Harald Weltee3bd6582018-01-31 22:51:25 +01004381/* unsolicited ASSIGNMENT FAIL (without ASSIGN) from MS shouldn't bring BSC down */
4382private function f_tc_unsol_ass_fail(charstring id) runs on MSC_ConnHdlr {
4383 f_est_single_l3(ts_RRM_AssignmentFailure('00'O));
4384 f_bssap_expect_nothing();
4385}
Harald Welte898113b2018-01-31 18:32:21 +01004386testcase TC_unsol_ass_fail() runs on test_CT {
4387 var MSC_ConnHdlr vc_conn;
4388 f_init(1, true);
4389 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004390 vc_conn := f_start_handler(refers(f_tc_unsol_ass_fail));
Harald Welte898113b2018-01-31 18:32:21 +01004391 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004392 f_shutdown_helper();
Harald Welte898113b2018-01-31 18:32:21 +01004393}
Harald Welte552620d2017-12-16 23:21:36 +01004394
Harald Welteea99a002018-01-31 20:46:43 +01004395
4396/* unsolicited ASSIGNMENT COMPLETE (without ASSIGN) from MS shouldn't bring BSC down */
4397private function f_tc_unsol_ass_compl(charstring id) runs on MSC_ConnHdlr {
Harald Weltee3bd6582018-01-31 22:51:25 +01004398 f_est_single_l3(ts_RRM_AssignmentComplete('00'O));
4399 f_bssap_expect_nothing();
Harald Welteea99a002018-01-31 20:46:43 +01004400}
4401testcase TC_unsol_ass_compl() runs on test_CT {
4402 var MSC_ConnHdlr vc_conn;
4403 f_init(1, true);
4404 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004405 vc_conn := f_start_handler(refers(f_tc_unsol_ass_compl));
Harald Welteea99a002018-01-31 20:46:43 +01004406 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004407 f_shutdown_helper();
Harald Welteea99a002018-01-31 20:46:43 +01004408}
4409
4410
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004411/* unsolicited HANDOVER FAIL (without ASSIGN) from MS shouldn't bring BSC down */
4412private function f_tc_unsol_ho_fail(charstring id) runs on MSC_ConnHdlr {
Harald Weltee3bd6582018-01-31 22:51:25 +01004413 f_est_single_l3(ts_RRM_HandoverFailure('00'O));
4414 f_bssap_expect_nothing();
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004415}
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004416testcase TC_unsol_ho_fail() runs on test_CT {
4417 var MSC_ConnHdlr vc_conn;
4418 f_init(1, true);
4419 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004420 vc_conn := f_start_handler(refers(f_tc_unsol_ho_fail));
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004421 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004422 f_shutdown_helper();
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004423}
4424
4425
Harald Weltee3bd6582018-01-31 22:51:25 +01004426/* short message from MS should be ignored */
4427private function f_tc_err_82_short_msg(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004428 g_pars := f_gen_test_hdlr_pars();
Harald Weltea0630032018-03-20 21:09:55 +01004429 f_create_chan_and_exp();
Harald Weltee3bd6582018-01-31 22:51:25 +01004430 /* we should now have a COMPL_L3 at the MSC */
4431 BSSAP.receive(tr_BSSMAP_ComplL3);
4432
4433 /* send short message */
4434 RSL.send(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), ''O));
4435 f_bssap_expect_nothing();
4436}
4437testcase TC_err_82_short_msg() runs on test_CT {
4438 var MSC_ConnHdlr vc_conn;
4439 f_init(1, true);
4440 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004441 vc_conn := f_start_handler(refers(f_tc_err_82_short_msg));
Harald Weltee3bd6582018-01-31 22:51:25 +01004442 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004443 f_shutdown_helper();
Harald Weltee3bd6582018-01-31 22:51:25 +01004444}
4445
4446
Harald Weltee9e02e42018-01-31 23:36:25 +01004447/* 24.008 8.4 Unknown message must trigger RR STATUS */
4448private function f_tc_err_84_unknown_msg(charstring id) runs on MSC_ConnHdlr {
4449 f_est_single_l3(ts_RRM_UL_REL('00'O));
4450 timer T := 3.0
4451 alt {
4452 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_STATUS)) {
4453 setverdict(pass);
4454 }
4455 [] BSSAP.receive { setverdict(fail, "unexpected BSSAP"); }
Harald Welte458fd372018-03-21 11:26:23 +01004456 [] T.timeout { setverdict(fail, "Timeout waiting for RR STATUS"); }
Harald Weltee9e02e42018-01-31 23:36:25 +01004457 }
4458}
4459testcase TC_err_84_unknown_msg() runs on test_CT {
4460 var MSC_ConnHdlr vc_conn;
4461 f_init(1, true);
4462 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004463 vc_conn := f_start_handler(refers(f_tc_err_84_unknown_msg));
Harald Weltee9e02e42018-01-31 23:36:25 +01004464 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004465 f_shutdown_helper();
Harald Weltee9e02e42018-01-31 23:36:25 +01004466}
4467
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004468/***********************************************************************
4469 * Handover
4470 ***********************************************************************/
4471
Harald Welte94e0c342018-04-07 11:33:23 +02004472/* execute a "bts <0-255> trx <0-255> timeslot <0-7> " command on given Dchan */
4473private function f_vty_ts_action(charstring suffix, integer bts_nr, integer trx_nr, integer ts_nr)
4474runs on test_CT {
4475 var charstring cmd := "bts "&int2str(bts_nr)&" trx "&int2str(trx_nr)&
4476 " timeslot "&int2str(ts_nr)&" ";
4477 f_vty_transceive(BSCVTY, cmd & suffix);
4478}
4479
Harald Welte261af4b2018-02-12 21:20:39 +01004480/* 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 +07004481private function f_vty_ss_action(TELNETasp_PT pt, charstring suffix,
4482 uint8_t bts_nr, uint8_t trx_nr,
4483 in RslChannelNr chan_nr)
4484{
Harald Welte261af4b2018-02-12 21:20:39 +01004485 /* FIXME: resolve those from component-global state */
4486 var integer ts_nr := chan_nr.tn;
4487 var integer ss_nr;
4488 if (ischosen(chan_nr.u.ch0)) {
4489 ss_nr := 0;
4490 } else if (ischosen(chan_nr.u.lm)) {
4491 ss_nr := chan_nr.u.lm.sub_chan;
4492 } else if (ischosen(chan_nr.u.sdcch4)) {
4493 ss_nr := chan_nr.u.sdcch4.sub_chan;
4494 } else if (ischosen(chan_nr.u.sdcch8)) {
4495 ss_nr := chan_nr.u.sdcch8.sub_chan;
4496 } else {
4497 setverdict(fail, "Invalid ChanNr ", chan_nr);
Daniel Willmannafce8662018-07-06 23:11:32 +02004498 mtc.stop;
Harald Welte261af4b2018-02-12 21:20:39 +01004499 }
4500
4501 var charstring cmd := "bts "&int2str(bts_nr)&" trx "&int2str(trx_nr)&
4502 " timeslot "&int2str(ts_nr)&" sub-slot "&int2str(ss_nr)&" ";
Vadim Yanitskiy00070722020-09-02 17:27:57 +07004503 f_vty_transceive(pt, cmd & suffix);
Harald Welte261af4b2018-02-12 21:20:39 +01004504}
4505
Neels Hofmeyr91401012019-07-11 00:42:35 +02004506/* Even though the VTY command to trigger handover takes a new BTS number as argument, behind the scenes osmo-bsc always
4507 * translates that to a target ARFCN+BSIC first. See bsc_vty.c trigger_ho_or_as(), which puts the selected BTS' neighbor
4508 * ident key (ARFCN + BSIC) in the struct passed on to handover_request(). handover_start() then resolves that to a
4509 * viable actual neighbor cell. So from the internal osmo-bsc perspective, we always request handover to an ARFCN + BSIC
4510 * pair, not really to a specific BTS number. */
Vadim Yanitskiy00070722020-09-02 17:27:57 +07004511private function f_vty_handover(TELNETasp_PT pt, uint8_t bts_nr, uint8_t trx_nr,
4512 in RslChannelNr chan_nr, uint8_t new_bts_nr)
4513{
4514 f_vty_ss_action(pt, "handover " & int2str(new_bts_nr), bts_nr, trx_nr, chan_nr);
Harald Welte261af4b2018-02-12 21:20:39 +01004515}
4516
4517/* intra-BSC hand-over between BTS0 and BTS1 */
4518private function f_tc_ho_int(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004519 g_pars := f_gen_test_hdlr_pars();
Harald Welteed848512018-05-24 22:27:58 +02004520 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4521 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte261af4b2018-02-12 21:20:39 +01004522 const OCT8 kc := '0001020304050607'O;
4523
4524 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4525 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4526
Harald Weltea0630032018-03-20 21:09:55 +01004527 f_establish_fully(ass_cmd, exp_compl);
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004528 f_bts_0_cfg(BSCVTY, {"neighbor bts 1"});
Harald Welte261af4b2018-02-12 21:20:39 +01004529
4530 var HandoverState hs := {
4531 rr_ho_cmpl_seen := false,
4532 handover_done := false,
4533 old_chan_nr := -
4534 };
4535 /* issue hand-over command on VTY */
Vadim Yanitskiy00070722020-09-02 17:27:57 +07004536 f_vty_handover(BSCVTY, 0, 0, g_chan_nr, 1);
Harald Welte261af4b2018-02-12 21:20:39 +01004537 /* temporarily suspend DChan processing on BTS1 to avoid race with RSLEM_register */
4538 f_rslem_suspend(RSL1_PROC);
Philipp Maier3e2af5d2018-07-11 17:01:05 +02004539
4540 /* From the MGW perspective, a handover is is characterized by
4541 * performing one MDCX operation with the MGW. So we expect to see
4542 * one more MDCX during handover. */
4543 g_media.mgcp_conn[0].mdcx_seen_exp := g_media.mgcp_conn[0].crcx_seen_exp + 1;
4544
Harald Welte261af4b2018-02-12 21:20:39 +01004545 alt {
4546 [] as_handover(hs);
Harald Welte261af4b2018-02-12 21:20:39 +01004547 }
Philipp Maier3e2af5d2018-07-11 17:01:05 +02004548
Philipp Maier4dae0652018-11-12 12:03:26 +01004549 /* Since this is an internal handover we expect the BSC to inform the
4550 * MSC about the event */
4551 BSSAP.receive(tr_BSSMAP_HandoverPerformed);
4552
Philipp Maier3e2af5d2018-07-11 17:01:05 +02004553 /* Check the amount of MGCP transactions is still consistant with the
4554 * test expectation */
4555 f_check_mgcp_expectations()
Neels Hofmeyr861a4c12018-11-07 01:23:17 +01004556 f_sleep(0.5);
Harald Welte261af4b2018-02-12 21:20:39 +01004557}
4558
4559testcase TC_ho_int() runs on test_CT {
4560 var MSC_ConnHdlr vc_conn;
4561 f_init(2, true);
4562 f_sleep(1.0);
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004563
4564 f_ctrs_bsc_and_bts_init();
4565
Harald Welte8863fa12018-05-10 20:15:27 +02004566 vc_conn := f_start_handler(refers(f_tc_ho_int));
Harald Welte261af4b2018-02-12 21:20:39 +01004567 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004568
4569 /* from f_establish_fully() */
4570 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4571 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4572 /* from handover */
4573 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4574 f_ctrs_bsc_and_bts_add(0, "handover:completed");
4575 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
4576 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:completed");
4577 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004578 f_shutdown_helper();
Harald Welte261af4b2018-02-12 21:20:39 +01004579}
Harald Weltee9e02e42018-01-31 23:36:25 +01004580
Neels Hofmeyr5f144212020-11-03 15:41:58 +00004581/* intra-BSC hand-over with CONNection FAILure and cause Radio Link Failure: check RR release cause */
4582private function f_tc_ho_int_radio_link_failure(charstring id) runs on MSC_ConnHdlr {
4583 g_pars := f_gen_test_hdlr_pars();
4584 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4585 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4586 const OCT8 kc := '0001020304050607'O;
4587
4588 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4589 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4590
4591 f_establish_fully(ass_cmd, exp_compl);
4592 f_bts_0_cfg(BSCVTY, {"neighbor bts 1"});
4593
4594 var HandoverState hs := {
4595 rr_ho_cmpl_seen := false,
4596 handover_done := false,
4597 old_chan_nr := -
4598 };
4599 /* issue hand-over command on VTY */
4600 f_vty_handover(BSCVTY, 0, 0, g_chan_nr, 1);
4601 /* temporarily suspend DChan processing on BTS1 to avoid race with RSLEM_register */
4602 f_rslem_suspend(RSL1_PROC);
4603
4604 /* From the MGW perspective, a handover is is characterized by
4605 * performing one MDCX operation with the MGW. So we expect to see
4606 * one more MDCX during handover. */
4607 g_media.mgcp_conn[0].mdcx_seen_exp := g_media.mgcp_conn[0].crcx_seen_exp + 1;
4608
4609 var RSL_Message rsl;
4610 var PDU_ML3_NW_MS l3;
4611 var RslChannelNr new_chan_nr;
4612 var GsmArfcn arfcn;
4613 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr)) -> value rsl {
4614 l3 := dec_PDU_ML3_NW_MS(rsl.ies[2].body.l3_info.payload);
4615 if (not ischosen(l3.msgs.rrm.handoverCommand)) {
4616 setverdict(fail, "Expected handoverCommand");
4617 mtc.stop;
4618 }
4619 }
4620 f_ChDesc2RslChanNr(l3.msgs.rrm.handoverCommand.channelDescription2,
4621 new_chan_nr, arfcn);
4622
4623 f_rslem_register(0, new_chan_nr, RSL1_PROC);
4624
4625 /* resume processing of RSL DChan messages, which was temporarily suspended
4626 * before performing a hand-over */
4627 f_rslem_resume(RSL1_PROC);
4628 RSL1.receive(tr_RSL_IPA_CRCX(new_chan_nr));
4629
4630 f_sleep(1.0);
4631
4632 /* Handover fails because no HANDO DET appears on the new lchan,
4633 * and the old lchan reports a Radio Link Failure. */
4634 RSL.send(ts_RSL_CONN_FAIL_IND(g_chan_nr, RSL_ERR_RADIO_LINK_FAIL));
4635
4636 var PDU_BSSAP rx_clear_request;
4637 BSSAP.receive(tr_BSSMAP_ClearRequest) -> value rx_clear_request;
4638 var BssmapCause cause := bit2int(rx_clear_request.pdu.bssmap.clearRequest.cause.causeValue);
4639 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
4640
4641 var RR_Cause rr_cause := GSM48_RR_CAUSE_ABNORMAL_UNSPEC;
4642
4643 var MgcpCommand mgcp;
4644 interleave {
4645 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE(int2oct(enum2int(rr_cause), 1)))) {}
4646 [] RSL.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {}
4647 [] RSL.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
4648 RSL.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
4649 }
4650 [] RSL1.receive(tr_RSL_DEACT_SACCH(new_chan_nr)) {}
4651 [] RSL1.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
4652 RSL1.send(ts_RSL_RF_CHAN_REL_ACK(new_chan_nr));
4653 }
4654 [] BSSAP.receive(tr_BSSMAP_ClearComplete) {}
4655 }
4656
4657 f_sleep(0.5);
4658 setverdict(pass);
4659}
4660testcase TC_ho_int_radio_link_failure() runs on test_CT {
4661 var MSC_ConnHdlr vc_conn;
4662 f_init(2, true);
4663 f_sleep(1.0);
4664
4665 f_ctrs_bsc_and_bts_init();
4666
4667 vc_conn := f_start_handler(refers(f_tc_ho_int_radio_link_failure));
4668 vc_conn.done;
4669
4670 /* from f_establish_fully() */
4671 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4672 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4673 /* from handover */
4674 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4675 f_ctrs_bsc_and_bts_add(0, "handover:stopped");
4676 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
4677 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:stopped");
4678 f_ctrs_bsc_and_bts_verify();
4679 f_shutdown_helper();
4680}
4681
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004682/* Expecting MGCP to DLCX the endpoint's two connections: towards BTS and towards MSC */
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004683private function f_expect_dlcx_conns() runs on MSC_ConnHdlr {
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004684 var MgcpCommand mgcp;
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02004685 var template MgcpResponse mgcp_resp;
4686 var MGCP_RecvFrom mrf;
4687 var template MgcpMessage msg_resp;
4688 var template MgcpMessage msg_dlcx := {
4689 command := tr_DLCX()
4690 }
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004691
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02004692 if (g_pars.aoip) {
4693 MGCP.receive(tr_DLCX()) -> value mgcp {
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004694 log("Got first DLCX: ", mgcp);
4695 MGCP.send(ts_DLCX_ACK2(mgcp.line.trans_id));
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02004696 };
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004697
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004698 MGCP.receive(tr_DLCX()) -> value mgcp {
4699 log("Got second DLCX: ", mgcp);
4700 MGCP.send(ts_DLCX_ACK2(mgcp.line.trans_id));
4701 };
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02004702 } else {
4703 /* For SCCPLite, BSC doesn't handle the MSC-side */
4704 MGCP_MULTI.receive(tr_MGCP_RecvFrom_any(msg_dlcx)) -> value mrf {
4705 log("Got first DLCX: ", mrf.msg.command);
4706 msg_resp := {
4707 response := ts_DLCX_ACK2(mrf.msg.command.line.trans_id)
4708 }
4709 MGCP_MULTI.send(t_MGCP_SendToMrf(mrf, msg_resp));
4710 };
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004711 }
4712
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004713 BSSAP.receive(tr_BSSMAP_ClearComplete);
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004714}
4715
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004716private function f_tc_ho_out_of_this_bsc(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004717 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004718
4719 var PDU_BSSAP ass_req := f_gen_ass_req();
4720 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4721 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4722 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4723 f_establish_fully(ass_req, exp_compl);
4724
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004725 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004726 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
4727
4728 BSSAP.receive(tr_BSSMAP_HandoverRequired);
4729
4730 f_sleep(0.5);
4731 /* The MSC negotiates Handover Request and Handover Request Ack with
4732 * the other BSS and comes back with a BSSMAP Handover Command
4733 * containing an RR Handover Command coming from the target BSS... */
4734
4735 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
4736 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
4737 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
4738 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
4739 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
4740
4741 /* expect the Handover Command to go out on RR */
4742 var RSL_Message rsl_ho_cmd
4743 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
4744 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
4745 var RSL_IE_Body rsl_ho_cmd_l3;
4746 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
4747 log("RSL message contains no L3 Info IE, expected RR Handover Command");
4748 setverdict(fail);
4749 } else {
4750 log("Found L3 Info: ", rsl_ho_cmd_l3);
4751 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
4752 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
4753 setverdict(fail);
4754 } else {
4755 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
4756 setverdict(pass);
4757 }
4758 }
4759
4760 /* When the other BSS has reported a completed handover, this side is
4761 * torn down. */
4762
4763 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_HANDOVER_SUCCESSFUL;
4764 var BssmapCause cause := enum2int(cause_val);
4765 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
4766
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004767 f_expect_dlcx_conns();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004768 setverdict(pass);
4769 f_sleep(1.0);
4770}
4771testcase TC_ho_out_of_this_bsc() runs on test_CT {
4772 var MSC_ConnHdlr vc_conn;
4773
4774 f_init(1, true);
4775 f_sleep(1.0);
4776
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004777 f_ctrs_bsc_and_bts_init();
4778
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004779 vc_conn := f_start_handler(refers(f_tc_ho_out_of_this_bsc));
4780 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004781
4782 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4783 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4784 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4785 f_ctrs_bsc_and_bts_add(0, "handover:completed");
4786 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
4787 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:completed");
4788 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004789 f_shutdown_helper();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004790}
4791
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00004792private function f_mo_l3_transceive(RSL_DCHAN_PT rsl := RSL,
4793 template (value) RslLinkId link_id := ts_RslLinkID_DCCH(0),
Vadim Yanitskiy2ef6a2f2020-10-08 23:17:32 +07004794 template (present) OCT1 dlci := ?,
Vadim Yanitskiyb93aa432020-10-01 14:23:11 +07004795 octetstring l3 := '0123456789'O)
4796runs on MSC_ConnHdlr {
Neels Hofmeyr43654812020-09-25 01:35:35 +02004797 /* The old lchan and conn should still be active. See that arbitrary L3
4798 * is still going through. */
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00004799 rsl.send(ts_RSL_DATA_IND(g_chan_nr, link_id, l3));
Neels Hofmeyr43654812020-09-25 01:35:35 +02004800 var template PDU_BSSAP exp_data := {
4801 discriminator := '1'B,
4802 spare := '0000000'B,
Vadim Yanitskiyb93aa432020-10-01 14:23:11 +07004803 dlci := dlci,
4804 lengthIndicator := lengthof(l3),
Neels Hofmeyr43654812020-09-25 01:35:35 +02004805 pdu := {
4806 dtap := l3
4807 }
4808 };
4809 BSSAP.receive(exp_data);
4810 setverdict(pass);
4811}
4812
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00004813private function f_mt_l3_transceive(RSL_DCHAN_PT rsl := RSL,
4814 template (present) RslLinkId link_id := tr_RslLinkID_DCCH(0),
Vadim Yanitskiy0033a3b2020-10-01 22:21:16 +07004815 template (value) OCT1 dlci := '00'O,
4816 octetstring l3 := '0123456789'O)
4817runs on MSC_ConnHdlr {
4818 BSSAP.send(PDU_BSSAP:{
4819 discriminator := '1'B,
4820 spare := '0000000'B,
4821 dlci := dlci,
4822 lengthIndicator := lengthof(l3),
4823 pdu := {
4824 dtap := l3
4825 }
4826 });
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00004827 rsl.receive(tr_RSL_DATA_REQ(g_chan_nr, link_id, l3));
Vadim Yanitskiy0033a3b2020-10-01 22:21:16 +07004828 setverdict(pass);
4829}
4830
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004831/* BSC asks for inter-BSC HO, but the MSC decides that it won't happen and
4832 * simply never sends a BSSMAP Handover Command. */
4833private function f_tc_ho_out_fail_no_msc_response(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01004834 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004835
4836 var PDU_BSSAP ass_req := f_gen_ass_req();
4837 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4838 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4839 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4840 f_establish_fully(ass_req, exp_compl);
4841
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004842 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004843 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
4844
4845 BSSAP.receive(tr_BSSMAP_HandoverRequired);
4846
4847 /* osmo-bsc should time out 10 seconds after the handover started.
4848 * Let's give it a bit extra. */
4849 f_sleep(15.0);
4850
Vadim Yanitskiy74ae5eb2020-10-01 22:13:29 +07004851 f_mo_l3_transceive();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004852 f_sleep(1.0);
4853}
4854testcase TC_ho_out_fail_no_msc_response() runs on test_CT {
4855 var MSC_ConnHdlr vc_conn;
4856
4857 f_init(1, true);
4858 f_sleep(1.0);
4859
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004860 f_ctrs_bsc_and_bts_init();
4861
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004862 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_no_msc_response));
4863 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004864
4865 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4866 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4867 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4868 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
4869 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
4870 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
4871 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004872 f_shutdown_helper();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004873}
4874
4875/* BSC asks for inter-BSC HO, receives BSSMAP Handover Command, but MS reports
4876 * RR Handover Failure. */
4877private function f_tc_ho_out_fail_rr_ho_failure(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01004878 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004879
4880 var PDU_BSSAP ass_req := f_gen_ass_req();
4881 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4882 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4883 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4884 f_establish_fully(ass_req, exp_compl);
4885
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004886 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004887 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
4888
4889 BSSAP.receive(tr_BSSMAP_HandoverRequired);
4890
4891 f_sleep(0.5);
4892 /* The MSC negotiates Handover Request and Handover Request Ack with
4893 * the other BSS and comes back with a BSSMAP Handover Command
4894 * containing an RR Handover Command coming from the target BSS... */
4895
4896 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
4897 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
4898 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
4899 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
4900 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
4901
4902 /* expect the Handover Command to go out on RR */
4903 var RSL_Message rsl_ho_cmd
4904 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
4905 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
4906 var RSL_IE_Body rsl_ho_cmd_l3;
4907 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
4908 log("RSL message contains no L3 Info IE, expected RR Handover Command");
4909 setverdict(fail);
4910 } else {
4911 log("Found L3 Info: ", rsl_ho_cmd_l3);
4912 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
4913 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
4914 setverdict(fail);
4915 } else {
4916 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
4917 setverdict(pass);
4918 }
4919 }
4920
4921 f_sleep(0.2);
4922 f_rsl_send_l3(ts_RRM_HandoverFailure('00'O));
4923
4924 /* Should tell the MSC about the failure */
4925 BSSAP.receive(tr_BSSMAP_HandoverFailure);
4926
4927 f_sleep(1.0);
4928
Vadim Yanitskiy74ae5eb2020-10-01 22:13:29 +07004929 f_mo_l3_transceive();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004930 f_sleep(1.0);
4931
4932 setverdict(pass);
4933 f_sleep(1.0);
4934}
4935testcase TC_ho_out_fail_rr_ho_failure() runs on test_CT {
4936 var MSC_ConnHdlr vc_conn;
4937
4938 f_init(1, true);
4939 f_sleep(1.0);
4940
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004941 f_ctrs_bsc_and_bts_init();
4942
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004943 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_rr_ho_failure));
4944 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004945
4946 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4947 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4948 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4949 f_ctrs_bsc_and_bts_add(0, "handover:failed");
4950 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
4951 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:failed");
4952 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004953 f_shutdown_helper();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004954}
4955
Neels Hofmeyr10f2bfa2019-07-09 19:33:29 +02004956/* BSC asks for inter-BSC-out HO, receives BSSMAP Handover Command, but then no reply is received about HO outcome
4957 * (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 +02004958 * and the lchan is released. */
4959private function f_tc_ho_out_fail_no_result_after_ho_cmd(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01004960 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004961
4962 var PDU_BSSAP ass_req := f_gen_ass_req();
4963 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4964 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4965 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4966 f_establish_fully(ass_req, exp_compl);
4967
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004968 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004969 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
4970
4971 BSSAP.receive(tr_BSSMAP_HandoverRequired);
4972
4973 f_sleep(0.5);
4974 /* The MSC negotiates Handover Request and Handover Request Ack with
4975 * the other BSS and comes back with a BSSMAP Handover Command
4976 * containing an RR Handover Command coming from the target BSS... */
4977
4978 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
4979 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
4980 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
4981 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
4982 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
4983
4984 /* expect the Handover Command to go out on RR */
4985 var RSL_Message rsl_ho_cmd
4986 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
4987 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
4988 var RSL_IE_Body rsl_ho_cmd_l3;
4989 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
4990 log("RSL message contains no L3 Info IE, expected RR Handover Command");
4991 setverdict(fail);
4992 } else {
4993 log("Found L3 Info: ", rsl_ho_cmd_l3);
4994 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
4995 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
4996 setverdict(fail);
4997 } else {
4998 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
4999 setverdict(pass);
5000 }
5001 }
5002
Neels Hofmeyr10f2bfa2019-07-09 19:33:29 +02005003 /* We get neither success nor failure report from the remote BSS. Eventually T8 times out and we run into 3GPP
5004 * TS 48.008 3.1.5.3.3 "Abnormal Conditions": Clear Request should go to the MSC, and RR should be released
5005 * after Clear Command */
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005006
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005007 var PDU_BSSAP rx_clear_request;
Neels Hofmeyre1797aa2019-07-09 19:34:04 +02005008 BSSAP.receive(tr_BSSMAP_ClearRequest) -> value rx_clear_request;
5009 log("Got BSSMAP Clear Request");
5010 /* Instruct BSC to clear channel */
5011 var BssmapCause cause := bit2int(rx_clear_request.pdu.bssmap.clearRequest.cause.causeValue);
5012 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5013
5014 var MgcpCommand mgcp;
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005015 interleave {
Neels Hofmeyr861a4c12018-11-07 01:23:17 +01005016 [] RSL.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
5017 log("Got Deact SACCH");
5018 }
Harald Welte924b6ea2019-02-04 01:05:34 +01005019 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
Neels Hofmeyr211169d2018-11-07 00:37:29 +01005020 log("Got RR Release");
5021 }
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005022 [] RSL.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
5023 log("Got RF Chan Rel");
5024 RSL.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
5025 }
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005026 }
5027
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005028 f_expect_dlcx_conns();
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02005029
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005030 setverdict(pass);
5031 f_sleep(1.0);
5032}
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02005033testcase TC_ho_out_fail_no_result_after_ho_cmd() runs on test_CT {
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005034 var MSC_ConnHdlr vc_conn;
5035
5036 f_init(1, true);
5037 f_sleep(1.0);
5038
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005039 f_ctrs_bsc_and_bts_init();
5040
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02005041 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_no_result_after_ho_cmd));
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005042 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005043
5044 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5045 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5046 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5047 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
5048 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
5049 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
5050 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005051 f_shutdown_helper();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005052}
5053
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005054private function f_tc_ho_into_this_bsc(charstring id) runs on MSC_ConnHdlr {
5055 /* Hack: the proper way would be to wait for the BSSMAP Handover Request ACK and extract the
5056 * actual assigned chan_nr from its L3 (RR Handover Command) message. But osmo-bsc starts acting
5057 * on the lchan even before we get a chance to evaluate the BSSMAP Handover Request ACK. So we
5058 * need to assume that osmo-bsc will activate TS 1 and already set up this lchan's RSL emulation
5059 * before we get started. */
5060 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
5061 f_rslem_register(0, new_chan_nr);
5062 g_chan_nr := new_chan_nr;
5063 f_sleep(1.0);
5064
5065 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
5066 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5067 activate(as_Media());
5068
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005069 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Pau Espin Pedrol07866632020-09-03 19:10:55 +02005070 f_gen_handover_req(aoip_tla := g_pars.host_aoip_tla)));
Harald Welte6811d102019-04-14 22:23:14 +02005071 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005072
5073 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
5074
5075 var PDU_BSSAP rx_bssap;
5076 var octetstring ho_command_str;
5077
5078 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
Pau Espin Pedrol76ba5412019-06-10 11:00:33 +02005079
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005080 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
5081 log("Received L3 Info in HO Request Ack: ", ho_command_str);
5082 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
5083 log("L3 Info in HO Request Ack is ", ho_command);
5084
5085 var GsmArfcn arfcn;
5086 var RslChannelNr actual_new_chan_nr;
5087 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
5088 actual_new_chan_nr, arfcn);
5089
5090 if (actual_new_chan_nr != new_chan_nr) {
5091 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
5092 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
5093 setverdict(fail);
5094 return;
5095 }
5096 log("Handover Command chan_nr is", actual_new_chan_nr);
5097
5098 /* Now the MSC forwards the RR Handover Command to the other BSC, which
5099 * tells the MS to handover to the new lchan. Here comes the new MS on
5100 * the new lchan with a Handover RACH: */
5101
5102 /* send handover detect */
5103
5104 RSL.send(ts_RSL_HANDO_DET(new_chan_nr));
5105
5106 BSSAP.receive(tr_BSSMAP_HandoverDetect);
5107
5108 /* send handover complete over the new channel */
5109
5110 var PDU_ML3_MS_NW l3_tx := valueof(ts_RRM_HandoverComplete('00'O));
5111 RSL.send(ts_RSL_EST_IND(new_chan_nr, valueof(ts_RslLinkID_DCCH(0)),
5112 enc_PDU_ML3_MS_NW(l3_tx)));
5113
5114 BSSAP.receive(tr_BSSMAP_HandoverComplete);
5115 setverdict(pass);
5116}
Pau Espin Pedrol07866632020-09-03 19:10:55 +02005117function f_tc_ho_into_this_bsc_main(TestHdlrParams pars) runs on test_CT {
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005118 var MSC_ConnHdlr vc_conn;
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005119
5120 f_init(1, true);
5121 f_sleep(1.0);
5122
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005123 f_ctrs_bsc_and_bts_init();
5124
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005125 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5126 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005127
5128 vc_conn := f_start_handler(refers(f_tc_ho_into_this_bsc), pars);
5129 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005130
5131 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5132 f_ctrs_bsc_and_bts_add(0, "handover:completed");
5133 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
5134 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:completed");
5135 f_ctrs_bsc_and_bts_verify();
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01005136 f_shutdown_helper();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005137}
5138
Pau Espin Pedrol07866632020-09-03 19:10:55 +02005139testcase TC_ho_into_this_bsc() runs on test_CT {
5140 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5141 f_tc_ho_into_this_bsc_main(pars);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005142 f_shutdown_helper();
Pau Espin Pedrol07866632020-09-03 19:10:55 +02005143}
5144
5145testcase TC_ho_into_this_bsc_tla_v6() runs on test_CT {
5146 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5147 pars.host_aoip_tla := "::6";
5148 f_tc_ho_into_this_bsc_main(pars);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005149 f_shutdown_helper();
Pau Espin Pedrol07866632020-09-03 19:10:55 +02005150}
5151
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005152private function f_tc_ho_in_fail_msc_clears(charstring id) runs on MSC_ConnHdlr {
5153 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
5154 f_rslem_register(0, new_chan_nr);
5155 g_chan_nr := new_chan_nr;
5156 f_sleep(1.0);
5157
5158 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
5159 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5160 activate(as_Media());
5161
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005162 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005163 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02005164 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005165
5166 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
5167
5168 var PDU_BSSAP rx_bssap;
5169 var octetstring ho_command_str;
5170
5171 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
5172
5173 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
5174 log("Received L3 Info in HO Request Ack: ", ho_command_str);
5175 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
5176 log("L3 Info in HO Request Ack is ", ho_command);
5177
5178 var GsmArfcn arfcn;
5179 var RslChannelNr actual_new_chan_nr;
5180 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
5181 actual_new_chan_nr, arfcn);
5182
5183 if (actual_new_chan_nr != new_chan_nr) {
5184 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
5185 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
5186 setverdict(fail);
5187 return;
5188 }
5189 log("Handover Command chan_nr is", actual_new_chan_nr);
5190
Neels Hofmeyr61ca08d2019-05-06 23:52:22 +02005191 /* For deterministic test results, give some time for the MGW endpoint to be configured */
5192 f_sleep(1.0);
5193
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005194 /* Now the MSC forwards the RR Handover Command to the other BSC, which
5195 * tells the MS to handover to the new lchan. In this case, the MS
5196 * reports a Handover Failure to the old BSS, which forwards a BSSMAP
5197 * Handover Failure to the MSC. The procedure according to 3GPP TS
5198 * 48.008 3.1.5.3.2 "Handover Failure" is then that the MSC sends a
5199 * BSSMAP Clear Command: */
5200
5201 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
5202 var BssmapCause cause := enum2int(cause_val);
5203 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5204
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005205 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005206 setverdict(pass);
5207 f_sleep(1.0);
5208
5209 setverdict(pass);
5210}
5211testcase TC_ho_in_fail_msc_clears() runs on test_CT {
5212 var MSC_ConnHdlr vc_conn;
5213 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5214
5215 f_init(1, true);
5216 f_sleep(1.0);
5217
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005218 f_ctrs_bsc_and_bts_init();
5219
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005220 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5221 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005222
5223 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_msc_clears), pars);
5224 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005225
5226 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5227 f_ctrs_bsc_and_bts_add(0, "handover:stopped");
5228 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
5229 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:stopped");
5230 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005231 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005232}
5233
5234private function f_tc_ho_in_fail_msc_clears_after_ho_detect(charstring id) runs on MSC_ConnHdlr {
5235 /* Hack: the proper way would be to wait for the BSSMAP Handover Request ACK and extract the
5236 * actual assigned chan_nr from its L3 (RR Handover Command) message. But osmo-bsc starts acting
5237 * on the lchan even before we get a chance to evaluate the BSSMAP Handover Request ACK. So we
5238 * need to assume that osmo-bsc will activate TS 1 and already set up this lchan's RSL emulation
5239 * before we get started. */
5240 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
5241 f_rslem_register(0, new_chan_nr);
5242 g_chan_nr := new_chan_nr;
5243 f_sleep(1.0);
5244
5245 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
5246 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5247 activate(as_Media());
5248
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005249 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005250 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02005251 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005252
5253 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
5254
5255 var PDU_BSSAP rx_bssap;
5256 var octetstring ho_command_str;
5257
5258 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
5259
5260 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
5261 log("Received L3 Info in HO Request Ack: ", ho_command_str);
5262 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
5263 log("L3 Info in HO Request Ack is ", ho_command);
5264
5265 var GsmArfcn arfcn;
5266 var RslChannelNr actual_new_chan_nr;
5267 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
5268 actual_new_chan_nr, arfcn);
5269
5270 if (actual_new_chan_nr != new_chan_nr) {
5271 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
5272 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
5273 setverdict(fail);
5274 return;
5275 }
5276 log("Handover Command chan_nr is", actual_new_chan_nr);
5277
5278 /* Now the MSC forwards the RR Handover Command to the other BSC, which
5279 * tells the MS to handover to the new lchan. Here comes the new MS on
5280 * the new lchan with a Handover RACH: */
5281
5282 /* send handover detect */
5283
5284 RSL.send(ts_RSL_HANDO_DET(new_chan_nr));
5285
5286 BSSAP.receive(tr_BSSMAP_HandoverDetect);
5287
5288 /* The MSC chooses to clear the connection now, maybe we got the
5289 * Handover RACH on the new cell but the MS still signaled Handover
5290 * Failure to the old BSS? */
5291
5292 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
5293 var BssmapCause cause := enum2int(cause_val);
5294 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5295
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005296 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005297 f_sleep(1.0);
5298}
5299testcase TC_ho_in_fail_msc_clears_after_ho_detect() runs on test_CT {
5300 var MSC_ConnHdlr vc_conn;
5301 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5302
5303 f_init(1, true);
5304 f_sleep(1.0);
5305
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005306 f_ctrs_bsc_and_bts_init();
5307
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005308 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5309 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005310
5311 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_msc_clears_after_ho_detect), pars);
5312 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005313
5314 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5315 f_ctrs_bsc_and_bts_add(0, "handover:stopped");
5316 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
5317 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:stopped");
5318 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005319 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005320}
5321
5322/* The new BSS's lchan times out before the MSC decides that handover failed. */
5323private function f_tc_ho_in_fail_no_detect(charstring id) runs on MSC_ConnHdlr {
5324 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
5325 f_rslem_register(0, new_chan_nr);
5326 g_chan_nr := new_chan_nr;
5327 f_sleep(1.0);
5328
5329 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
5330 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5331 activate(as_Media());
5332
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005333 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005334 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02005335 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005336
5337 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
5338
5339 var PDU_BSSAP rx_bssap;
5340 var octetstring ho_command_str;
5341
5342 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
5343
5344 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
5345 log("Received L3 Info in HO Request Ack: ", ho_command_str);
5346 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
5347 log("L3 Info in HO Request Ack is ", ho_command);
5348
5349 var GsmArfcn arfcn;
5350 var RslChannelNr actual_new_chan_nr;
5351 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
5352 actual_new_chan_nr, arfcn);
5353
5354 if (actual_new_chan_nr != new_chan_nr) {
5355 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
5356 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
5357 setverdict(fail);
5358 return;
5359 }
5360 log("Handover Command chan_nr is", actual_new_chan_nr);
5361
5362 /* Now the MSC forwards the RR Handover Command to the other BSC, which
5363 * tells the MS to handover to the new lchan. But the MS never shows up
5364 * on the new lchan. */
5365
5366 BSSAP.receive(tr_BSSMAP_HandoverFailure);
5367
5368 /* Did osmo-bsc also send a Clear Request? */
5369 timer T := 0.5;
5370 T.start;
5371 alt {
5372 [] BSSAP.receive(tr_BSSMAP_ClearRequest);
5373 [] T.timeout { }
5374 }
5375
5376 /* MSC plays along with a Clear Command (no matter whether osmo-bsc
5377 * asked for it, this is a Handover Failure after all). */
5378
5379 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
5380 var BssmapCause cause := enum2int(cause_val);
5381 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5382
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005383 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005384 f_sleep(1.0);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005385}
5386testcase TC_ho_in_fail_no_detect() runs on test_CT {
5387 var MSC_ConnHdlr vc_conn;
5388 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5389
5390 f_init(1, true);
5391 f_sleep(1.0);
5392
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005393 f_ctrs_bsc_and_bts_init();
5394
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005395 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5396 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005397
5398 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_no_detect), pars);
5399 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005400
5401 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5402 f_ctrs_bsc_and_bts_add(0, "handover:error");
5403 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
5404 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:error");
5405 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005406 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005407}
5408
5409/* Same as f_tc_ho_in_fail_no_detect, but MSC fails to send a Clear Command */
5410private function f_tc_ho_in_fail_no_detect2(charstring id) runs on MSC_ConnHdlr {
5411 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
5412 f_rslem_register(0, new_chan_nr);
5413 g_chan_nr := new_chan_nr;
5414 f_sleep(1.0);
5415
5416 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
5417 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5418 activate(as_Media());
5419
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005420 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005421 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02005422 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005423
5424 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
5425
5426 var PDU_BSSAP rx_bssap;
5427 var octetstring ho_command_str;
5428
5429 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
5430
5431 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
5432 log("Received L3 Info in HO Request Ack: ", ho_command_str);
5433 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
5434 log("L3 Info in HO Request Ack is ", ho_command);
5435
5436 var GsmArfcn arfcn;
5437 var RslChannelNr actual_new_chan_nr;
5438 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
5439 actual_new_chan_nr, arfcn);
5440
5441 if (actual_new_chan_nr != new_chan_nr) {
5442 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
5443 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
5444 setverdict(fail);
5445 return;
5446 }
5447 log("Handover Command chan_nr is", actual_new_chan_nr);
5448
5449 /* Now the MSC forwards the RR Handover Command to the other BSC, which
5450 * tells the MS to handover to the new lchan. But the MS never shows up
5451 * on the new lchan. */
5452
5453 BSSAP.receive(tr_BSSMAP_HandoverFailure);
5454
5455 /* MSC plays dumb and sends no Clear Command */
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005456 var PDU_BSSAP rx_clear_request;
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02005457
5458 BSSAP.receive(tr_BSSMAP_ClearRequest) -> value rx_clear_request {
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005459 var BssmapCause cause := bit2int(rx_clear_request.pdu.bssmap.clearRequest.cause.causeValue);
5460 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5461 };
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005462 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005463 f_sleep(1.0);
5464}
5465testcase TC_ho_in_fail_no_detect2() runs on test_CT {
5466 var MSC_ConnHdlr vc_conn;
5467 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5468
5469 f_init(1, true);
5470 f_sleep(1.0);
5471
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005472 f_ctrs_bsc_and_bts_init();
5473
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005474 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5475 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005476
5477 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_no_detect2), pars);
5478 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005479
5480 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5481 f_ctrs_bsc_and_bts_add(0, "handover:error");
5482 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
5483 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:error");
5484 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005485 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005486}
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005487
Neels Hofmeyr91401012019-07-11 00:42:35 +02005488type record of charstring Commands;
5489
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005490private function f_bts_0_cfg(TELNETasp_PT pt, Commands cmds := {})
Neels Hofmeyr91401012019-07-11 00:42:35 +02005491{
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005492 f_vty_enter_cfg_bts(pt, 0);
Neels Hofmeyr91401012019-07-11 00:42:35 +02005493 for (var integer i := 0; i < sizeof(cmds); i := i+1) {
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005494 f_vty_transceive(pt, cmds[i]);
Neels Hofmeyr91401012019-07-11 00:42:35 +02005495 }
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005496 f_vty_transceive(pt, "end");
Neels Hofmeyr91401012019-07-11 00:42:35 +02005497}
5498
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01005499private function f_cs7_inst_0_cfg(TELNETasp_PT pt, Commands cmds := {})
5500{
5501 f_vty_enter_cfg_cs7_inst(pt, 0);
5502 for (var integer i := 0; i < sizeof(cmds); i := i+1) {
5503 f_vty_transceive(pt, cmds[i]);
5504 }
5505 f_vty_transceive(pt, "end");
5506}
5507
Neels Hofmeyr91401012019-07-11 00:42:35 +02005508private function f_probe_for_handover(charstring log_label,
5509 charstring log_descr,
5510 charstring handover_vty_cmd,
5511 boolean expect_handover,
5512 boolean is_inter_bsc_handover := false)
5513runs on MSC_ConnHdlr
5514{
Neels Hofmeyrb3fc8982020-05-11 00:16:42 +02005515 /* We're going to thwart any and all handover attempts, just be ready to handle (and ignore) handover target
5516 * lchans to be established on bts 1 or bts 2. */
5517 f_rslem_suspend(RSL1_PROC);
5518 f_rslem_suspend(RSL2_PROC);
5519
Neels Hofmeyr91401012019-07-11 00:42:35 +02005520 var RSL_Message rsl;
5521
5522 var charstring log_msg := " (expecting handover)"
5523 if (not expect_handover) {
5524 log_msg := " (expecting NO handover)";
5525 }
5526 log("f_probe_for_handover starting: " & log_label & ": " & log_descr & log_msg);
5527 f_vty_transceive(BSCVTY, handover_vty_cmd);
5528
Neels Hofmeyr91401012019-07-11 00:42:35 +02005529 timer T := 2.0;
5530 T.start;
5531
5532 alt {
5533 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr)) -> value rsl {
5534 var PDU_ML3_NW_MS l3 := dec_PDU_ML3_NW_MS(rsl.ies[2].body.l3_info.payload);
5535 log("Rx L3 from net: ", l3);
5536 if (ischosen(l3.msgs.rrm.handoverCommand)) {
5537 var RslChannelNr new_chan_nr;
5538 var GsmArfcn arfcn;
5539 f_ChDesc2RslChanNr(l3.msgs.rrm.handoverCommand.channelDescription2,
5540 new_chan_nr, arfcn);
5541 log("Handover to new chan ", new_chan_nr, " on ARFCN ", arfcn);
5542 log(l3.msgs.rrm.handoverCommand);
5543
5544 /* Need to register for new lchan on new BTS -- it's either bts 1 or bts 2. It doesn't really
5545 * matter on which BTS it really is, we're not going to follow through an entire handover
5546 * anyway. */
5547 f_rslem_register(0, new_chan_nr, RSL1_PROC);
5548 f_rslem_resume(RSL1_PROC);
5549 f_rslem_register(0, new_chan_nr, RSL2_PROC);
5550 f_rslem_resume(RSL2_PROC);
5551
5552 if (expect_handover and not is_inter_bsc_handover) {
5553 setverdict(pass);
5554 log("f_probe_for_handover(" & log_label & "): Got RSL Handover Command as expected.");
5555 } else {
5556 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected none, but got RSL Handover Command. "
5557 & log_label & ": " & log_descr);
5558 }
5559
5560 log("f_probe_for_handover(" & log_label & "): Ending the test: Handover Failure stops the procedure.");
5561 /* osmo-bsc has triggered Handover. That's all we need to know for this test, reply with
5562 * Handover Failure. */
5563 f_rsl_send_l3(ts_RRM_HandoverFailure('00'O));
5564
5565 /* target BTS is told to release lchan again; don't care which BTS nor what messages. */
5566 f_sleep(0.5);
5567 RSL1.clear;
5568 RSL2.clear;
5569 log("f_probe_for_handover(" & log_label & "): done (got RSL Handover Command)");
5570 break;
5571 } else {
5572 repeat;
5573 }
5574 }
5575 [] BSSAP.receive(tr_BSSMAP_HandoverRequired) {
5576 if (expect_handover and is_inter_bsc_handover) {
5577 setverdict(pass);
5578 log("f_probe_for_handover(" & log_label & "): Got BSSMAP Handover Required as expected.");
5579 } else {
5580 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected none, but got BSSMAP Handover Required. "
5581 & log_label & ": " & log_descr);
5582 }
5583
5584 log("f_probe_for_handover(" & log_label & "): done (got BSSMAP Handover Required)");
5585
5586 /* Note: f_tc_ho_neighbor_config_start() sets T7, the timeout for BSSMAP Handover Required, to
5587 * 1 second. There is no legal way to quickly abort a handover after a BSSMAP Handover Required,
5588 * setting a short timeout and waiting is the only way. */
5589 log("f_probe_for_handover(" & log_label & "): waiting for inter-BSC HO to time out...");
5590 f_sleep(1.5);
5591 log("f_probe_for_handover(" & log_label & "): ...done");
5592
5593 break;
5594 }
5595 [] T.timeout {
5596 if (expect_handover) {
5597 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected Handover, but got none. "
5598 & log_label & ": " & log_descr);
5599 } else {
5600 setverdict(pass);
5601 log("f_probe_for_handover(" & log_label & "): Got no Handover, as expected.");
5602 }
5603 log("f_probe_for_handover(" & log_label & "): done (got no Handover)");
5604 break;
5605 }
5606 }
5607
5608 f_rslem_resume(RSL1_PROC);
5609 f_rslem_resume(RSL2_PROC);
5610 f_sleep(3.0);
5611 RSL.clear;
5612
5613 log("f_probe_for_handover(" & log_label & "): done clearing");
5614}
5615
5616/* Test the effect of various neighbor configuration scenarios:
5617 *
5618 * To avoid complexity, block off any actual handover operation, and always remain on the lchan at bts 0.
5619 * Reconfigure the neighbors for bts 0, trigger a Handover, and probe whether osmo-bsc does or doesn't start HO.
5620 */
5621private function f_tc_ho_neighbor_config_start() runs on MSC_ConnHdlr {
5622 g_pars := f_gen_test_hdlr_pars();
5623 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
5624 var PDU_BSSAP ass_cmd := f_gen_ass_req();
5625 const OCT8 kc := '0001020304050607'O;
5626
5627 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
5628 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
5629
5630 /* Establish lchan at bts 0 */
5631 f_establish_fully(ass_cmd, exp_compl);
5632
5633 /* Shorten the inter-BSC Handover timeout, to not wait so long for inter-BSC Handovers */
5634 f_vty_enter_cfg_network(BSCVTY);
5635 f_vty_transceive(BSCVTY, "timer T7 1");
5636 f_vty_transceive(BSCVTY, "end");
5637}
5638
5639private function f_tc_ho_neighbor_config_1(charstring id) runs on MSC_ConnHdlr {
5640 f_tc_ho_neighbor_config_start();
5641
5642 /*
5643 * bts 0 ARFCN 871 BSIC 10
5644 * bts 1 ARFCN 871 BSIC 11
5645 * bts 2 ARFCN 871 BSIC 12
5646 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5647 */
5648
5649 log("f_tc_ho_neighbor_config: 1. No 'neighbor' config");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005650 f_bts_0_cfg(BSCVTY, {"no neighbors"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005651 f_probe_for_handover("1.a", "HO to bts 1 works, implicitly listed as neighbor (legacy behavior when none are configured)",
5652 "handover any to arfcn 871 bsic 11",
5653 true);
5654
5655 f_probe_for_handover("1.b", "HO to unknown cell does not start",
5656 "handover any to arfcn 13 bsic 39",
5657 false);
5658
5659 f_probe_for_handover("1.c", "HO to 871-12 is ambiguous = error",
5660 "handover any to arfcn 871 bsic 12",
5661 false);
5662
5663 f_probe_for_handover("1.d", "HO to 871-11 still works (verify that this test properly cleans up)",
5664 "handover any to arfcn 871 bsic 11",
5665 true);
5666}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005667testcase TC_ho_neighbor_config_1() runs on test_CT {
5668 var MSC_ConnHdlr vc_conn;
5669 f_init(3, true, guard_timeout := 60.0);
5670 f_sleep(1.0);
5671 f_ctrs_bsc_and_bts_init();
5672 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_1));
5673 vc_conn.done;
5674
5675 /* f_tc_ho_neighbor_config_start() */
5676 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5677 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5678
5679 /* 1.a */
5680 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
5681 * handover quickly by sending a Handover Failure message. */
5682 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5683 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5684 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5685 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
5686
5687 /* 1.b */
5688 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5689 f_ctrs_bsc_and_bts_add(0, "handover:error");
5690
5691 /* 1.c */
5692 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5693 f_ctrs_bsc_and_bts_add(0, "handover:error");
5694
5695 /* 1.d */
5696 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5697 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5698 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5699 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
5700
5701 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005702 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005703}
5704
Neels Hofmeyr91401012019-07-11 00:42:35 +02005705private function f_tc_ho_neighbor_config_2(charstring id) runs on MSC_ConnHdlr {
5706 f_tc_ho_neighbor_config_start();
5707
5708 /*
5709 * bts 0 ARFCN 871 BSIC 10
5710 * bts 1 ARFCN 871 BSIC 11
5711 * bts 2 ARFCN 871 BSIC 12
5712 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5713 */
5714
5715 log("f_tc_ho_neighbor_config: 2. explicit local neighbor: 'neighbor bts 1'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005716 f_bts_0_cfg(BSCVTY, {"neighbor bts 1"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005717 f_sleep(0.5);
5718
5719 f_probe_for_handover("2.a", "HO to bts 1 works, explicitly listed as neighbor",
5720 "handover any to arfcn 871 bsic 11",
5721 true);
5722
5723 f_probe_for_handover("2.b", "HO to bts 2 doesn't work, not listed as neighbor",
5724 "handover any to arfcn 871 bsic 12",
5725 false);
5726}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005727testcase TC_ho_neighbor_config_2() runs on test_CT {
5728 var MSC_ConnHdlr vc_conn;
5729 f_init(3, true, guard_timeout := 50.0);
5730 f_sleep(1.0);
5731 f_ctrs_bsc_and_bts_init();
5732 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_2));
5733 vc_conn.done;
5734
5735 /* f_tc_ho_neighbor_config_start() */
5736 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5737 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5738
5739 /* 2.a */
5740 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
5741 * handover quickly by sending a Handover Failure message. */
5742 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5743 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5744 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5745 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
5746
5747 /* 2.b */
5748 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5749 f_ctrs_bsc_and_bts_add(0, "handover:error");
5750
5751 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005752 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005753}
5754
Neels Hofmeyr91401012019-07-11 00:42:35 +02005755private function f_tc_ho_neighbor_config_3(charstring id) runs on MSC_ConnHdlr {
5756 f_tc_ho_neighbor_config_start();
5757
5758 /*
5759 * bts 0 ARFCN 871 BSIC 10
5760 * bts 1 ARFCN 871 BSIC 11
5761 * bts 2 ARFCN 871 BSIC 12
5762 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5763 */
5764
5765 log("f_tc_ho_neighbor_config: 3. explicit local neighbor: 'neighbor bts 2'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005766 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor bts 2"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005767 f_sleep(0.5);
5768
5769 f_probe_for_handover("3.a", "HO to bts 1 doesn't work, not listed as neighbor",
5770 "handover any to arfcn 871 bsic 11",
5771 false);
5772 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",
5773 "handover any to arfcn 871 bsic 12",
5774 true);
5775}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005776testcase TC_ho_neighbor_config_3() runs on test_CT {
5777 var MSC_ConnHdlr vc_conn;
5778 f_init(3, true, guard_timeout := 50.0);
5779 f_sleep(1.0);
5780 f_ctrs_bsc_and_bts_init();
5781 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_3));
5782 vc_conn.done;
5783
5784 /* f_tc_ho_neighbor_config_start() */
5785 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5786 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5787
5788 /* 3.a */
5789 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5790 f_ctrs_bsc_and_bts_add(0, "handover:error");
5791
5792 /* 3.b */
5793 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
5794 * handover quickly by sending a Handover Failure message. */
5795 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5796 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5797 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5798 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
5799
5800 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005801 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005802}
5803
Neels Hofmeyr91401012019-07-11 00:42:35 +02005804private function f_tc_ho_neighbor_config_4(charstring id) runs on MSC_ConnHdlr {
5805 f_tc_ho_neighbor_config_start();
5806
5807 /*
5808 * bts 0 ARFCN 871 BSIC 10
5809 * bts 1 ARFCN 871 BSIC 11
5810 * bts 2 ARFCN 871 BSIC 12
5811 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5812 */
5813
5814 log("f_tc_ho_neighbor_config: 4. explicit remote neighbor: 'neighbor lac 99 arfcn 123 bsic 45'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005815 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor lac 99 arfcn 123 bsic 45"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005816 f_sleep(0.5);
5817
5818 f_probe_for_handover("4.a", "HO to bts 1 doesn't work, not listed as neighbor",
5819 "handover any to arfcn 871 bsic 11",
5820 false);
5821 f_probe_for_handover("4.b", "HO to bts 2 doesn't work, not listed as neighbor",
5822 "handover any to arfcn 871 bsic 12",
5823 false);
5824 f_probe_for_handover("4.c", "HO to 123-45 triggers inter-BSC HO",
5825 "handover any to arfcn 123 bsic 45",
5826 true, true);
5827}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005828testcase TC_ho_neighbor_config_4() runs on test_CT {
5829 var MSC_ConnHdlr vc_conn;
5830 f_init(3, true, guard_timeout := 50.0);
5831 f_sleep(1.0);
5832 f_ctrs_bsc_and_bts_init();
5833 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_4));
5834 vc_conn.done;
5835
5836 /* f_tc_ho_neighbor_config_start() */
5837 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5838 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5839
5840 /* 4.a */
5841 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5842 f_ctrs_bsc_and_bts_add(0, "handover:error");
5843
5844 /* 4.b */
5845 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5846 f_ctrs_bsc_and_bts_add(0, "handover:error");
5847
5848 /* 4.c */
5849 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
5850 * handover quickly by timing out after the Handover Required message */
5851 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5852 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
5853 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
5854 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
5855
5856 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005857 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005858}
5859
Neels Hofmeyr91401012019-07-11 00:42:35 +02005860private function f_tc_ho_neighbor_config_5(charstring id) runs on MSC_ConnHdlr {
5861 f_tc_ho_neighbor_config_start();
5862
5863 /*
5864 * bts 0 ARFCN 871 BSIC 10
5865 * bts 1 ARFCN 871 BSIC 11
5866 * bts 2 ARFCN 871 BSIC 12
5867 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5868 */
5869
5870 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 +02005871 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor lac 99 arfcn 871 bsic 12"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005872 f_sleep(0.5);
5873
5874 f_probe_for_handover("5.a", "HO to 871-12 triggers inter-BSC HO (ignoring local cells with same ARFCN+BSIC)",
5875 "handover any to arfcn 871 bsic 12",
5876 true, true);
5877}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005878testcase TC_ho_neighbor_config_5() runs on test_CT {
5879 var MSC_ConnHdlr vc_conn;
5880 f_init(3, true);
5881 f_sleep(1.0);
5882 f_ctrs_bsc_and_bts_init();
5883 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_5));
5884 vc_conn.done;
5885
5886 /* f_tc_ho_neighbor_config_start() */
5887 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5888 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5889
5890 /* 5 */
5891 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
5892 * handover quickly by timing out after the Handover Required message */
5893 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5894 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
5895 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
5896 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
5897
5898 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005899 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005900}
5901
Neels Hofmeyr91401012019-07-11 00:42:35 +02005902private function f_tc_ho_neighbor_config_6(charstring id) runs on MSC_ConnHdlr {
5903 f_tc_ho_neighbor_config_start();
5904
5905 /*
5906 * bts 0 ARFCN 871 BSIC 10
5907 * bts 1 ARFCN 871 BSIC 11
5908 * bts 2 ARFCN 871 BSIC 12
5909 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5910 */
5911
5912 log("f_tc_ho_neighbor_config: 6. config error: explicit local and remote neighbors with ambiguous ARFCN+BSIC:"
5913 & " 'neighbor bts 2; neighbor lac 99 arfcn 871 bsic 12'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005914 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor bts 2", "neighbor lac 99 arfcn 871 bsic 12"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005915 f_sleep(0.5);
5916
5917 f_probe_for_handover("6.a", "HO to 871-12 is ambiguous = error",
5918 "handover any to arfcn 871 bsic 12",
5919 false);
5920}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005921testcase TC_ho_neighbor_config_6() runs on test_CT {
5922 var MSC_ConnHdlr vc_conn;
5923 f_init(3, true);
5924 f_sleep(1.0);
5925 f_ctrs_bsc_and_bts_init();
5926 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_6));
5927 vc_conn.done;
5928
5929 /* f_tc_ho_neighbor_config_start() */
5930 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5931 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5932
5933 /* 6.a */
5934 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
5935 * handover quickly by timing out after the Handover Required message */
5936 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5937 f_ctrs_bsc_and_bts_add(0, "handover:error");
5938
5939 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005940 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005941}
5942
Neels Hofmeyr91401012019-07-11 00:42:35 +02005943private function f_tc_ho_neighbor_config_7(charstring id) runs on MSC_ConnHdlr {
5944 f_tc_ho_neighbor_config_start();
5945
5946 /*
5947 * bts 0 ARFCN 871 BSIC 10
5948 * bts 1 ARFCN 871 BSIC 11
5949 * bts 2 ARFCN 871 BSIC 12
5950 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5951 */
5952
5953 log("f_tc_ho_neighbor_config: 7. explicit local and remote neighbors:"
5954 & " 'neighbor bts 2; neighbor lac 99 arfcn 123 bsic 45'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005955 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor bts 2", "neighbor lac 99 arfcn 123 bsic 45"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005956 f_sleep(0.5);
5957
5958 f_probe_for_handover("7.a", "HO to 871-12 does HO to bts 2",
5959 "handover any to arfcn 871 bsic 12",
5960 true);
5961 f_probe_for_handover("7.b", "HO to 123-45 triggers inter-BSC HO",
5962 "handover any to arfcn 123 bsic 45",
5963 true, true);
5964}
Neels Hofmeyr91401012019-07-11 00:42:35 +02005965testcase TC_ho_neighbor_config_7() runs on test_CT {
5966 var MSC_ConnHdlr vc_conn;
Neels Hofmeyrf2b88032020-06-16 00:35:04 +02005967 f_init(3, true, guard_timeout := 50.0);
Neels Hofmeyr91401012019-07-11 00:42:35 +02005968 f_sleep(1.0);
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005969 f_ctrs_bsc_and_bts_init();
Neels Hofmeyr91401012019-07-11 00:42:35 +02005970 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_7));
5971 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005972
5973 /* f_tc_ho_neighbor_config_start() */
5974 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5975 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5976
5977 /* 7.a */
5978 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
5979 * handover quickly by sending a Handover Failure message. */
5980 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5981 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5982 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5983 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
5984
5985 /* 7.b */
5986 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
5987 * handover quickly by timing out after the Handover Required message */
5988 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5989 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
5990 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
5991 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
5992
5993 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005994 f_shutdown_helper();
Neels Hofmeyr91401012019-07-11 00:42:35 +02005995}
5996
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01005997/* OS#3041: Open and close N connections in a normal fashion, and expect no
5998 * BSSMAP Reset just because of that. */
5999testcase TC_bssap_rlsd_does_not_cause_bssmap_reset() runs on test_CT {
6000 var default d;
6001 var integer i;
6002 var DchanTuple dt;
6003
6004 f_init();
6005
6006 /* Wait for initial BSSMAP Reset to pass */
6007 f_sleep(4.0);
6008
6009 d := activate(no_bssmap_reset());
6010
6011 /* Setup up a number of connections and RLSD them again from the MSC
6012 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
6013 * Let's do it some more times for good measure. */
Harald Weltec3260d92018-06-11 17:48:16 +02006014 for (i := 0; i < 4; i := i+1) {
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01006015 /* Since we're doing a lot of runs, give each one a fresh
6016 * T_guard from the top. */
6017 T_guard.start;
6018
6019 /* Setup a BSSAP connection and clear it right away. This is
6020 * the MSC telling the BSC about a planned release, it's not an
6021 * erratic loss of a connection. */
Harald Weltea1897182018-06-11 13:53:09 +02006022 dt := f_est_dchan(int2oct(i,1), 23+i, '00010203040506'O);
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01006023
6024 /* MSC disconnects (RLSD). */
6025 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
6026 }
6027
6028 /* In the buggy behavior, a timeout of 2 seconds happens between above
6029 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
6030 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
6031 f_sleep(4.0);
6032
6033 deactivate(d);
6034 f_shutdown_helper();
6035}
Harald Welte552620d2017-12-16 23:21:36 +01006036
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01006037/* OS#3041: Open and close N connections in a normal fashion, and expect no
6038 * BSSMAP Reset just because of that. Invoke the release by a BSSMAP Clear from
6039 * the MSC. */
6040testcase TC_bssmap_clear_does_not_cause_bssmap_reset() runs on test_CT {
6041 var default d;
6042 var integer i;
6043 var DchanTuple dt;
6044 var BSSAP_N_DATA_ind rx_di;
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01006045 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_CALL_CONTROL;
6046 var BssmapCause cause := enum2int(cause_val);
6047
6048 f_init();
6049
6050 /* Wait for initial BSSMAP Reset to pass */
6051 f_sleep(4.0);
6052
6053 d := activate(no_bssmap_reset());
6054
6055 /* Setup up a number of connections and RLSD them again from the MSC
6056 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
6057 * Let's do it some more times for good measure. */
6058 for (i := 0; i < 8; i := i+1) {
6059 /* Since we're doing a lot of runs, give each one a fresh
6060 * T_guard from the top. */
6061 T_guard.start;
6062
6063 /* Setup a BSSAP connection and clear it right away. This is
6064 * the MSC telling the BSC about a planned release, it's not an
6065 * erratic loss of a connection. */
Harald Weltea1897182018-06-11 13:53:09 +02006066 dt := f_est_dchan(int2oct(i,1), 23+i, '00010203040506'O);
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01006067
6068 /* Instruct BSC to clear channel */
6069 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
6070
6071 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02006072 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01006073 }
6074
6075 /* In the buggy behavior, a timeout of 2 seconds happens between above
6076 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
6077 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
6078 f_sleep(4.0);
6079
6080 deactivate(d);
6081 f_shutdown_helper();
6082}
6083
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01006084/* OS#3041: Open and close N connections in a normal fashion, and expect no
6085 * BSSMAP Reset just because of that. Close connections from the MS side with a
6086 * Release Ind on RSL. */
6087testcase TC_ms_rel_ind_does_not_cause_bssmap_reset() runs on test_CT {
6088 var default d;
6089 var integer i;
6090 var DchanTuple dt;
6091 var BSSAP_N_DATA_ind rx_di;
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01006092 var integer j;
6093
6094 f_init();
6095
6096 /* Wait for initial BSSMAP Reset to pass */
6097 f_sleep(4.0);
6098
6099 d := activate(no_bssmap_reset());
6100
6101 /* Setup up a number of connections and RLSD them again from the MSC
6102 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
6103 * Let's do it some more times for good measure. */
6104 for (i := 0; i < 8; i := i+1) {
6105 /* Since we're doing a lot of runs, give each one a fresh
6106 * T_guard from the top. */
6107 T_guard.start;
6108
6109 /* Setup a BSSAP connection and clear it right away. This is
6110 * the MSC telling the BSC about a planned release, it's not an
6111 * erratic loss of a connection. */
6112 dt := f_est_dchan('23'O, 23, '00010203040506'O);
6113
6114 /* simulate RLL REL IND */
6115 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0))));
6116
6117 /* expect Clear Request on MSC side */
6118 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
6119
6120 /* Instruct BSC to clear channel */
6121 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
6122 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
6123
6124 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02006125 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01006126 }
6127
6128 /* In the buggy behavior, a timeout of 2 seconds happens between above
6129 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
6130 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
6131 f_sleep(4.0);
6132
6133 deactivate(d);
6134 f_shutdown_helper();
6135}
6136
Harald Welte94e0c342018-04-07 11:33:23 +02006137/***********************************************************************
6138 * IPA style dynamic PDCH
6139 ***********************************************************************/
6140
6141private function f_dyn_ipa_pdch_act(integer bts_nr, integer trx_nr, integer ts_nr,
6142 template (omit) RSL_Cause nack := omit)
6143runs on test_CT {
6144 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(ts_nr));
6145 var RSL_Message rsl_unused;
6146 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
6147 f_vty_ts_action("pdch activate", bts_nr, trx_nr, ts_nr);
6148 /* expect the BSC to issue the related RSL command */
6149 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
6150 if (istemplatekind(nack, "omit")) {
6151 /* respond with a related acknowledgement */
6152 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
6153 } else {
6154 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_NACK(chan_nr, valueof(nack)));
6155 }
6156}
6157
6158private function f_dyn_ipa_pdch_deact(integer bts_nr, integer trx_nr, integer ts_nr,
6159 template (omit) RSL_Cause nack := omit)
6160runs on test_CT {
6161 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(ts_nr));
6162 var RSL_Message rsl_unused;
6163 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
6164 f_vty_ts_action("pdch deactivate", bts_nr, trx_nr, ts_nr);
6165 /* expect the BSC to issue the related RSL command */
6166 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_DEACT(chan_nr));
6167 if (istemplatekind(nack, "omit")) {
6168 /* respond with a related acknowledgement */
6169 f_ipa_tx(0, ts_RSL_IPA_PDCH_DEACT_ACK(chan_nr));
6170 } else {
6171 f_ipa_tx(0, ts_RSL_IPA_PDCH_DEACT_NACK(chan_nr, valueof(nack)));
6172 }
6173}
6174
6175private function f_ts_dyn_mode_get(integer bts_nr, integer trx_nr, integer ts_nr)
6176runs on test_CT return charstring {
6177 var charstring cmd, resp;
6178 cmd := "show timeslot "&int2str(bts_nr)&" "&int2str(trx_nr)&" "&int2str(ts_nr);
Stefan Sperlingcff13562018-11-13 15:24:06 +01006179 return f_vty_transceive_match_regexp_retry(BSCVTY, cmd, "*\((*)\)*", 0, 4, 1.0);
Harald Welte94e0c342018-04-07 11:33:23 +02006180}
6181
6182private function f_ts_dyn_mode_assert(integer bts_nr, integer trx_nr, integer ts_nr,
6183 template charstring exp)
6184runs on test_CT {
6185 var charstring mode := f_ts_dyn_mode_get(bts_nr, trx_nr, ts_nr);
6186 if (not match(mode, exp)) {
6187 setverdict(fail, "Unexpected TS Mode: ", mode);
Daniel Willmannafce8662018-07-06 23:11:32 +02006188 mtc.stop;
Harald Welte94e0c342018-04-07 11:33:23 +02006189 }
6190}
6191
6192private function f_ts_set_chcomb(integer bts_nr, integer trx_nr, integer ts_nr, charstring chcomb)
6193runs on test_CT {
6194 f_vty_enter_cfg_ts(BSCVTY, bts_nr, trx_nr, ts_nr);
6195 f_vty_transceive(BSCVTY, "phys_chan_config " & chcomb);
6196 f_vty_transceive(BSCVTY, "end");
6197}
6198
6199private const charstring TCHF_MODE := "TCH/F mode";
6200private const charstring TCHH_MODE := "TCH/H mode";
6201private const charstring PDCH_MODE := "PDCH mode";
6202private const charstring NONE_MODE := "NONE mode";
6203
6204/* Test IPA PDCH activation / deactivation triggered by VTY */
6205testcase TC_dyn_pdch_ipa_act_deact() runs on test_CT {
6206 var RSL_Message rsl_unused;
6207
6208 /* change Timeslot 6 before f_init() starts RSL */
6209 f_init_vty();
6210 f_ts_set_chcomb(0, 0, 6, "TCH/F_PDCH");
6211 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
6212
6213 f_init(1, false);
6214 f_sleep(1.0);
6215
6216 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
6217
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006218 log("TCH/F_PDCH pchan starts out in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02006219 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6220 /* The BSC will activate the dynamic PDCH by default, so confirm that */
6221 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
6222 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
6223 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006224 log("TCH/F_PDCH pchan, PDCH ACT was ACKed, so now in PDCH mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02006225 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
6226
6227 /* De-activate it via VTY */
6228 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
6229 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006230 log("TCH/F_PDCH pchan, PDCH DEACT via VTY, so now back in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02006231 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6232
6233 /* re-activate it via VTY */
6234 f_dyn_ipa_pdch_act(0, 0, chan_nr.tn);
6235 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006236 log("TCH/F_PDCH pchan, PDCH ACT via VTY, so now in PDCH mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02006237 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
6238
6239 /* and finally de-activate it again */
6240 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
6241 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006242 log("TCH/F_PDCH pchan, PDCH DEACT via VTY, so now back in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02006243 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6244
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02006245 /* clean up config */
6246 f_ts_set_chcomb(0, 0, 6, "PDCH");
6247
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006248 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02006249}
6250
6251/* Test IPA PDCH activation NACK */
6252testcase TC_dyn_pdch_ipa_act_nack() runs on test_CT {
6253 var RSL_Message rsl_unused;
6254
6255 /* change Timeslot 6 before f_init() starts RSL */
6256 f_init_vty();
6257 f_ts_set_chcomb(0, 0, 6, "TCH/F_PDCH");
6258 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
6259
6260 f_init(1, false);
6261 f_sleep(1.0);
6262
6263 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
6264
6265 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6266 /* The BSC will activate the dynamic PDCH by default, so confirm that */
6267 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
6268 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
6269 f_sleep(1.0);
6270 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
6271
6272 /* De-activate it via VTY */
6273 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
6274 f_sleep(1.0);
6275 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6276
6277 /* re-activate it via VTY, but fail that; check BSC still assumes TCH/F mode */
6278 f_dyn_ipa_pdch_act(0, 0, chan_nr.tn, RSL_ERR_EQUIPMENT_FAIL);
6279 f_sleep(1.0);
6280 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6281
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02006282 /* clean up config */
6283 f_ts_set_chcomb(0, 0, 6, "PDCH");
6284
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006285 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02006286}
6287
6288
6289/***********************************************************************
6290 * Osmocom style dynamic PDCH
6291 ***********************************************************************/
6292
6293private function f_dyn_osmo_pdch_act(integer bts_nr, integer trx_nr, integer ts_nr,
6294 template (omit) RSL_Cause nack := omit)
6295runs on test_CT {
6296 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(ts_nr));
6297 var RSL_Message rsl_unused;
6298 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
6299 /* FIXME: no VTY command to activate Osmocom PDCH !! */
6300 /* expect the BSC to issue the related RSL command */
6301 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT(chan_nr, ?));
6302 if (istemplatekind(nack, "omit")) {
6303 /* respond with a related acknowledgement */
6304 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342));
6305 } else {
6306 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, valueof(nack)));
6307 }
6308}
6309
6310private function f_dyn_osmo_pdch_deact(integer bts_nr, integer trx_nr, integer ts_nr,
6311 template (omit) RSL_Cause nack := omit)
6312runs on test_CT {
6313 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(ts_nr));
6314 var RSL_Message rsl_unused;
6315 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
6316 /* FIXME: no VTY command to activate Osmocom PDCH !! */
6317 /* expect the BSC to issue the related RSL command */
6318 rsl_unused := f_exp_ipa_rx(0, tr_RSL_RF_CHAN_REL(chan_nr));
6319 if (istemplatekind(nack, "omit")) {
6320 /* respond with a related acknowledgement */
6321 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(chan_nr));
6322 } else {
6323 //f_ipa_tx(0, ts_RSL_RF_CHAN_REL_NACK(chan_nr, valueof(nack)));
6324 }
6325}
6326
6327/* Test Osmocom dyn PDCH activation / deactivation triggered by VTY */
6328testcase TC_dyn_pdch_osmo_act_deact() runs on test_CT {
6329 var RSL_Message rsl_unused;
6330
6331 /* change Timeslot 6 before f_init() starts RSL */
6332 f_init_vty();
6333 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_PDCH");
6334 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
6335
6336 f_init(1, false);
6337 f_sleep(1.0);
6338
6339 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(6));
6340
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006341 log("TCH/F_TCH/H_PDCH pchan starts out in disabled mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02006342 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
6343 /* The BSC will activate the dynamic PDCH by default, so confirm that */
6344 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
6345
6346 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342));
6347 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006348 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 +02006349 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
6350
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02006351 /* clean up config */
6352 f_ts_set_chcomb(0, 0, 6, "PDCH");
6353
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006354 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02006355}
6356
6357/* Test Osmocom dyn PDCH activation NACK behavior */
6358testcase TC_dyn_pdch_osmo_act_nack() runs on test_CT {
6359 var RSL_Message rsl_unused;
6360
6361 /* change Timeslot 6 before f_init() starts RSL */
6362 f_init_vty();
6363 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_PDCH");
6364 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
6365
6366 f_init(1, false);
6367 f_sleep(1.0);
6368
6369 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(6));
6370
6371 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
6372 /* The BSC will activate the dynamic PDCH by default, so confirm that */
6373 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
6374
6375 /* NACK this activation and expect the "show timeslot" mode still to be NONE */
6376 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, RSL_ERR_EQUIPMENT_FAIL));
6377 f_sleep(1.0);
6378 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
6379
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02006380 /* clean up config */
6381 f_ts_set_chcomb(0, 0, 6, "PDCH");
6382
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006383 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02006384}
6385
Stefan Sperling0796a822018-10-05 13:01:39 +02006386testcase TC_chopped_ipa_ping() runs on test_CT {
Stefan Sperling554123f2018-10-09 14:12:30 +02006387 const Integers bsc_ipa_ports := {mp_bsc_rsl_port, mp_bsc_oml_port, mp_bsc_ctrl_port};
Stefan Sperling0796a822018-10-05 13:01:39 +02006388 for (var integer i := 0; i < lengthof(bsc_ipa_ports); i := i + 1) {
6389 IPA_Testing.f_run_TC_chopped_ipa_ping(mp_bsc_ip, bsc_ipa_ports[i], CONNECT_TO_SERVER);
6390 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006391 f_shutdown_helper();
Stefan Sperling0796a822018-10-05 13:01:39 +02006392}
6393
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02006394testcase TC_chopped_ipa_payload() runs on test_CT {
6395 const Integers bsc_ipa_ports := {mp_bsc_rsl_port, mp_bsc_oml_port
6396 /* TODO: mp_bsc_ctrl_port does not work yet */};
6397 for (var integer i := 0; i < lengthof(bsc_ipa_ports); i := i + 1) {
6398 IPA_Testing.f_run_TC_chopped_ipa_payload(mp_bsc_ip, bsc_ipa_ports[i], CONNECT_TO_SERVER);
6399 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006400 f_shutdown_helper();
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02006401}
6402
Pau Espin Pedrol8f773632019-11-05 11:46:53 +01006403/* Verify the BSC sends the MS Power Parameters IE during CHAN ACT to make sure
6404 the BTS does autonomous MS power control loop */
6405testcase TC_assignment_verify_ms_power_params_ie() runs on test_CT {
6406 var MSC_ConnHdlr vc_conn;
6407 var TestHdlrParams pars := f_gen_test_hdlr_pars();
6408 //pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
6409 pars.exp_ms_power_params := true;
6410
6411 f_init(1, true);
6412 f_sleep(1.0);
6413 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
6414 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006415 f_shutdown_helper();
Pau Espin Pedrol8f773632019-11-05 11:46:53 +01006416}
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02006417
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006418/***********************************************************************
6419 * MSC Pooling
6420 ***********************************************************************/
6421
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006422template MobileIdentityLV ts_MI_TMSI_NRI_LV(integer nri_v, integer nri_bitlen := 10) :=
Harald Weltebf397612021-01-14 20:39:46 +01006423 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 +02006424
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02006425private function f_expect_lchan_rel(RSL_DCHAN_PT rsl) runs on MSC_ConnHdlr {
6426 interleave {
6427 [] rsl.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
6428 f_logp(BSCVTY, "Got RSL RR Release");
6429 }
6430 [] rsl.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
6431 f_logp(BSCVTY, "Got RSL Deact SACCH");
6432 }
6433 [] rsl.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
6434 f_logp(BSCVTY, "Got RSL RF Chan Rel, sending Rel Ack");
6435 rsl.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
6436 break;
6437 }
6438 }
6439}
6440
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006441private function f_perform_clear(RSL_DCHAN_PT rsl) runs on MSC_ConnHdlr {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006442 f_logp(BSCVTY, "MSC instructs BSC to clear channel");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006443 BSSAP.send(ts_BSSMAP_ClearCommand(0));
6444 interleave {
6445 [] rsl.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006446 f_logp(BSCVTY, "Got RSL RR Release");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006447 }
6448 [] rsl.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006449 f_logp(BSCVTY, "Got RSL Deact SACCH");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006450 }
6451 [] BSSAP.receive(tr_BSSMAP_ClearComplete) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006452 f_logp(BSCVTY, "Got BSSMAP Clear Complete");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006453 /* Also drop the SCCP connection */
6454 BSSAP.send(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_REQ);
6455 }
6456 [] rsl.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006457 f_logp(BSCVTY, "Got RSL RF Chan Rel, sending Rel Ack");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006458 rsl.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
6459 }
6460 }
6461}
6462
Neels Hofmeyr66e15092020-10-12 18:44:41 +00006463private 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 +02006464runs on MSC_ConnHdlr {
6465 timer T := 10.0;
6466 var octetstring l3_enc := enc_PDU_ML3_MS_NW(valueof(l3_info));
6467
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006468 f_logp(BSCVTY, "establish channel, send Complete Layer 3 Info");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006469 f_create_bssmap_exp(l3_enc);
6470
6471 /* RSL_Emulation.f_chan_est() on rsl:
6472 * This is basically code dup with s/RSL/rsl from:
6473 * RSL_Emulation.f_chan_est(g_pars.ra, l3_enc, g_pars.link_id, g_pars.fn);
6474 */
6475 var RSL_Message rx_rsl;
6476 var GsmRrMessage rr;
6477
6478 /* request a channel to be established */
6479 rsl.send(ts_RSLDC_ChanRqd(g_pars.ra, g_pars.fn));
6480 /* expect immediate assignment.
6481 * Code dup with s/RSL/rsl from:
6482 * rx_rsl := f_rx_or_fail(tr_RSL_IMM_ASSIGN);
6483 */
6484 timer Tt := 10.0;
6485
6486 /* request a channel to be established */
6487 Tt.start;
6488 alt {
6489 [] rsl.receive(tr_RSL_IMM_ASSIGN) -> value rx_rsl {
6490 Tt.stop;
6491 }
6492 [] rsl.receive {
6493 setverdict(fail, "Unexpected RSL message on DCHAN");
6494 mtc.stop;
6495 }
6496 [] Tt.timeout {
6497 setverdict(fail, "Timeout waiting for RSL on DCHAN");
6498 mtc.stop;
6499 }
6500 }
6501 rr := dec_GsmRrMessage(rx_rsl.ies[1].body.full_imm_ass_info.payload);
6502 g_chan_nr := rr.payload.imm_ass.chan_desc.chan_nr;
6503 rsl.send(ts_RSL_EST_IND(g_chan_nr, valueof(g_pars.link_id), l3_enc));
6504
6505
Neels Hofmeyr66e15092020-10-12 18:44:41 +00006506 if (expect_bssmap_l3) {
6507 f_logp(BSCVTY, "expect BSSAP Complete Layer 3 Info at MSC");
6508 var template PDU_BSSAP exp_l3_compl;
6509 exp_l3_compl := tr_BSSMAP_ComplL3()
6510 if (g_pars.aoip == false) {
6511 exp_l3_compl.pdu.bssmap.completeLayer3Information.codecList := omit;
6512 } else {
6513 exp_l3_compl.pdu.bssmap.completeLayer3Information.codecList := ?;
6514 }
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006515
Neels Hofmeyr66e15092020-10-12 18:44:41 +00006516 var PDU_BSSAP bssap;
6517 T.start;
6518 alt {
6519 [] BSSAP.receive(exp_l3_compl) -> value bssap {
6520 f_logp(BSCVTY, "received expected Complete Layer 3 Info at MSC");
6521 log("rx exp_l3_compl = ", bssap);
6522 }
6523 [] BSSAP.receive(tr_BSSMAP_ComplL3) {
6524 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received non-matching COMPLETE LAYER 3 INFORMATION");
6525 }
6526 [] T.timeout {
6527 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for COMPLETE LAYER 3 INFORMATION");
6528 }
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006529 }
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006530
Neels Hofmeyr66e15092020-10-12 18:44:41 +00006531 /* start ciphering, if requested */
6532 if (ispresent(g_pars.encr)) {
6533 f_logp(BSCVTY, "start ciphering");
6534 f_cipher_mode(g_pars.encr.enc_alg, g_pars.encr.enc_key);
6535 }
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006536 }
6537
6538 if (do_clear) {
6539 f_perform_clear(rsl);
6540 }
6541 setverdict(pass);
6542 f_sleep(1.0);
6543}
6544
6545private function f_tc_mscpool_compl_l3(charstring id) runs on MSC_ConnHdlr {
6546 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
6547 if (g_pars.mscpool.rsl_idx == 0) {
6548 f_perform_compl_l3(RSL, g_pars.mscpool.l3_info);
6549 } else if (g_pars.mscpool.rsl_idx == 1) {
6550 f_perform_compl_l3(RSL1, g_pars.mscpool.l3_info);
6551 } else if (g_pars.mscpool.rsl_idx == 2) {
6552 f_perform_compl_l3(RSL2, g_pars.mscpool.l3_info);
6553 }
6554}
6555
6556/* Various Complete Layer 3 by IMSI all end up with the first MSC, because the other MSCs are not connected. */
6557private function f_tc_mscpool_L3Compl_on_1_msc(charstring id) runs on MSC_ConnHdlr {
6558 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
6559 f_perform_compl_l3(RSL, ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000001'H)), '00F110'O) );
6560 f_perform_compl_l3(RSL, ts_CM_SERV_REQ(CM_TYPE_MO_SMS, valueof(ts_MI_IMSI_LV('001010000000002'H))) );
6561 f_perform_compl_l3(RSL, ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010000000003'H))) );
6562 f_perform_compl_l3(RSL, ts_ML3_MO_MM_IMSI_DET_Ind(valueof(ts_MI_IMSI_LV('001010000000004'H))) );
6563}
6564testcase TC_mscpool_L3Compl_on_1_msc() runs on test_CT {
6565
6566 f_init(1, true);
6567 f_sleep(1.0);
6568 var MSC_ConnHdlr vc_conn;
6569 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006570
6571 f_ctrs_msc_init();
6572
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006573 vc_conn := f_start_handler(refers(f_tc_mscpool_L3Compl_on_1_msc), pars);
6574 vc_conn.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006575
6576 f_ctrs_msc_expect(0, "mscpool:subscr:new", 4);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006577 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006578}
6579
6580/* Three Layer 3 Complete by IMSI are round-robin'ed across two connected MSCs */
6581/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6582 * just as well using only RSL. */
6583testcase TC_mscpool_L3Complete_by_imsi_round_robin() runs on test_CT {
6584
6585 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6586 f_sleep(1.0);
6587
6588 /* Control which MSC gets chosen next by the round-robin, otherwise
6589 * would be randomly affected by which other tests ran before this. */
6590 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6591
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006592 f_ctrs_msc_init();
6593
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006594 var MSC_ConnHdlr vc_conn1;
6595 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6596 pars1.mscpool.rsl_idx := 0;
6597 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000001'H)), '00F110'O));
6598 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6599 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006600 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006601
6602 var MSC_ConnHdlr vc_conn2;
6603 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6604 pars2.mscpool.rsl_idx := 1;
6605 pars2.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000002'H))));
6606 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6607 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006608 f_ctrs_msc_expect(1, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006609
6610 /* Test round-robin wrap to the first MSC */
6611 var MSC_ConnHdlr vc_conn3;
6612 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6613 pars3.mscpool.rsl_idx := 2;
6614 pars3.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010000000003'H))));
6615 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6616 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006617 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006618 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006619}
6620
6621/* Three LU by TMSI are round-robin'ed across two connected MSCs, because they contain the NULL-NRI 0
6622 * (configured in osmo-bsc.cfg). */
6623/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6624 * just as well using only RSL. */
6625testcase TC_mscpool_LU_by_tmsi_null_nri_0_round_robin() runs on test_CT {
6626
6627 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6628 f_sleep(1.0);
6629
6630 /* Control which MSC gets chosen next by the round-robin, otherwise
6631 * would be randomly affected by which other tests ran before this. */
6632 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6633
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006634 f_ctrs_msc_init();
6635
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006636 var MSC_ConnHdlr vc_conn1;
6637 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6638 pars1.mscpool.rsl_idx := 0;
6639 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(0)), '00F110'O));
6640 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6641 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006642 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006643
6644 var MSC_ConnHdlr vc_conn2;
6645 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6646 pars2.mscpool.rsl_idx := 1;
6647 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(0)), '00F110'O));
6648 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6649 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006650 f_ctrs_msc_expect(1, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006651
6652 /* Test round-robin wrap to the first MSC */
6653 var MSC_ConnHdlr vc_conn3;
6654 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6655 pars3.mscpool.rsl_idx := 2;
6656 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(0)), '00F110'O));
6657 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6658 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006659 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006660 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006661}
6662
6663/* Three LU by TMSI are round-robin'ed across two connected MSCs, because they contain the NULL-NRI 1
6664 * (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
6665 * NULL-NRI setting is stronger than that. */
6666/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6667 * just as well using only RSL. */
6668testcase TC_mscpool_LU_by_tmsi_null_nri_1_round_robin() runs on test_CT {
6669
6670 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6671 f_sleep(1.0);
6672
6673 /* Control which MSC gets chosen next by the round-robin, otherwise
6674 * would be randomly affected by which other tests ran before this. */
6675 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6676
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006677 f_ctrs_msc_init();
6678
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006679 var MSC_ConnHdlr vc_conn1;
6680 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6681 pars1.mscpool.rsl_idx := 0;
6682 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(1)), '00F110'O));
6683 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6684 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006685 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006686
6687 var MSC_ConnHdlr vc_conn2;
6688 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6689 pars2.mscpool.rsl_idx := 1;
6690 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(1)), '00F110'O));
6691 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6692 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006693 f_ctrs_msc_expect(1, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006694
6695 /* Test round-robin wrap to the first MSC */
6696 var MSC_ConnHdlr vc_conn3;
6697 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6698 pars3.mscpool.rsl_idx := 2;
6699 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(1)), '00F110'O));
6700 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6701 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006702 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006703 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006704}
6705
6706/* Three Layer 3 Complete by TMSI are round-robin'ed across two connected MSCs, because they contain an NRI not
6707 * assigned to any MSC (configured in osmo-bsc.cfg). */
6708/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6709 * just as well using only RSL. */
6710testcase TC_mscpool_L3Complete_by_tmsi_unassigned_nri_round_robin() runs on test_CT {
6711
6712 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6713 f_sleep(1.0);
6714
6715 /* Control which MSC gets chosen next by the round-robin, otherwise
6716 * would be randomly affected by which other tests ran before this. */
6717 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6718
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006719 f_ctrs_msc_init();
6720
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006721 var MSC_ConnHdlr vc_conn1;
6722 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6723 pars1.mscpool.rsl_idx := 0;
6724 /* An NRI that is not assigned to any MSC */
6725 pars1.mscpool.l3_info := valueof(ts_ML3_MO_MM_IMSI_DET_Ind(valueof(ts_MI_TMSI_NRI_LV(1023))));
6726 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6727 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006728 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006729
6730 var MSC_ConnHdlr vc_conn2;
6731 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6732 pars2.mscpool.rsl_idx := 1;
6733 /* An NRI that is not assigned to any MSC */
6734 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(768)), '00F110'O));
6735 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6736 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006737 f_ctrs_msc_expect(1, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006738
6739 /* Test round-robin wrap to the first MSC */
6740 var MSC_ConnHdlr vc_conn3;
6741 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6742 pars3.mscpool.rsl_idx := 2;
6743 /* An NRI that is not assigned to any MSC */
6744 pars3.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_SS_ACT, valueof(ts_MI_TMSI_NRI_LV(819))));
6745 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6746 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006747 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006748 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006749}
6750
6751/* Three Layer 3 Complete by TMSI are round-robin'ed across two connected MSCs, because they contain an NRI
6752 * assigned to an MSC that is currently not connected (configured in osmo-bsc.cfg). */
6753/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6754 * just as well using only RSL. */
6755testcase TC_mscpool_L3Complete_by_tmsi_valid_nri_msc_not_connected_round_robin() runs on test_CT {
6756
6757 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6758 f_sleep(1.0);
6759
6760 /* Control which MSC gets chosen next by the round-robin, otherwise
6761 * would be randomly affected by which other tests ran before this. */
6762 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6763
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006764 f_ctrs_msc_init();
6765
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006766 var MSC_ConnHdlr vc_conn1;
6767 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6768 pars1.mscpool.rsl_idx := 0;
6769 /* An NRI that is assigned to an unconnected MSC */
6770 pars1.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(512))));
6771 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6772 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006773 f_ctrs_msc_add(2, "mscpool:subscr:attach_lost");
6774 f_ctrs_msc_add(0, "mscpool:subscr:new");
6775 f_ctrs_msc_verify();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006776
6777 var MSC_ConnHdlr vc_conn2;
6778 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6779 pars2.mscpool.rsl_idx := 1;
6780 /* An NRI that is assigned to an unconnected MSC */
6781 pars2.mscpool.l3_info := valueof(ts_ML3_MO_MM_IMSI_DET_Ind(valueof(ts_MI_TMSI_NRI_LV(767))));
6782 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6783 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006784 f_ctrs_msc_add(2, "mscpool:subscr:attach_lost");
6785 f_ctrs_msc_add(1, "mscpool:subscr:new");
6786 f_ctrs_msc_verify();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006787
6788 /* Test round-robin wrap to the first MSC */
6789 var MSC_ConnHdlr vc_conn3;
6790 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6791 pars3.mscpool.rsl_idx := 2;
6792 /* An NRI that is assigned to an unconnected MSC */
6793 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(750)), '00F110'O));
6794 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6795 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006796 f_ctrs_msc_add(2, "mscpool:subscr:attach_lost");
6797 f_ctrs_msc_add(0, "mscpool:subscr:new");
6798 f_ctrs_msc_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006799 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006800}
6801
6802/* Three Layer 3 Complete by TMSI with valid NRI for the second MSC are all directed to the second MSC (configured in
6803 * osmo-bsc.cfg). */
6804/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6805 * just as well using only RSL. */
6806testcase TC_mscpool_L3Complete_by_tmsi_valid_nri_1() runs on test_CT {
6807
6808 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6809 f_sleep(1.0);
6810
6811 /* All TMSIs in this test point at the second MSC, set the round robin to point at the first MSC to make sure
6812 * this is not using round-robin. */
6813 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6814
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006815 f_ctrs_msc_init();
6816
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006817 var MSC_ConnHdlr vc_conn1;
6818 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 1);
6819 pars1.mscpool.rsl_idx := 0;
6820 /* An NRI of the second MSC's range (256-511) */
6821 pars1.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_SMS, valueof(ts_MI_TMSI_NRI_LV(256))));
6822 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6823 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006824 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006825
6826 var MSC_ConnHdlr vc_conn2;
6827 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6828 pars2.mscpool.rsl_idx := 1;
6829 /* An NRI of the second MSC's range (256-511) */
6830 pars2.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(260))));
6831 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6832 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006833 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006834
6835 var MSC_ConnHdlr vc_conn3;
6836 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 1);
6837 pars3.mscpool.rsl_idx := 2;
6838 /* An NRI of the second MSC's range (256-511) */
6839 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(511)), '00F110'O));
6840 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6841 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006842 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006843 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006844}
6845
6846/* Layer 3 Complete by TMSI with valid NRI for the third MSC are directed to the third MSC (configured in osmo-bsc.cfg),
6847 * while a round-robin remains unaffected by that. */
6848/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6849 * just as well using only RSL. */
6850testcase TC_mscpool_L3Complete_by_tmsi_valid_nri_2() runs on test_CT {
6851
6852 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
6853 f_sleep(1.0);
6854
6855 /* All TMSIs in this test point at the third MSC, set the round robin to point at the second MSC to make sure
6856 * this is not using round-robin. */
6857 f_vty_transceive(BSCVTY, "mscpool roundrobin next 1");
6858
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006859 f_ctrs_msc_init();
6860
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006861 var MSC_ConnHdlr vc_conn1;
6862 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 2);
6863 pars1.mscpool.rsl_idx := 0;
6864 /* An NRI of the third MSC's range (512-767) */
6865 pars1.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_SMS, valueof(ts_MI_TMSI_NRI_LV(512))));
6866 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6867 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006868 f_ctrs_msc_expect(2, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006869
6870 var MSC_ConnHdlr vc_conn2;
6871 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 2);
6872 pars2.mscpool.rsl_idx := 1;
6873 /* An NRI of the third MSC's range (512-767) */
6874 pars2.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(678))));
6875 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6876 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006877 f_ctrs_msc_expect(2, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006878
6879 /* The above forwardings to third MSC have not affected the round robin, which still points at the second MSC */
6880 var MSC_ConnHdlr vc_conn3;
6881 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 1);
6882 pars3.mscpool.rsl_idx := 2;
6883 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000013'H)), '00F110'O));
6884 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6885 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006886 f_ctrs_msc_expect(1, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006887 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006888}
6889
6890/* LU with a TMSI but indicating a different PLMN in its previous LAI: ignore the NRI. */
6891/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6892 * just as well using only RSL. */
6893testcase TC_mscpool_LU_by_tmsi_from_other_PLMN() runs on test_CT {
6894
6895 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
6896 f_sleep(1.0);
6897
6898 /* The TMSIs in this test points at the second MSC, but since it is from a different PLMN, round-robin is used
6899 * instead, and hits msc 0. */
6900 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6901
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006902 f_ctrs_msc_init();
6903
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006904 /* An NRI of the second MSC's range (256-511), but a PLMN that doesn't match with osmo-bsc.cfg */
6905 var MSC_ConnHdlr vc_conn1;
6906 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6907 pars1.mscpool.rsl_idx := 0;
6908 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(260)), '99F999'O));
6909 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6910 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006911 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006912
6913 /* An NRI of the third MSC's range (512-767) and a matching PLMN gets directed by NRI. */
6914 var MSC_ConnHdlr vc_conn2;
6915 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 2);
6916 pars2.mscpool.rsl_idx := 1;
6917 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(555)), '00F110'O));
6918 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6919 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006920 f_ctrs_msc_expect(2, "mscpool:subscr:known");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006921 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006922}
6923
6924/* Make sure that whichever MSC paged a subscriber will also get the Paging Response. Page by IMSI, which would be
6925 * round-robined to another MSC, to make sure the Paging->Response relation is stronger than the NRI->MSC mapping. */
6926private function f_tc_mscpool_paging_imsi(charstring id) runs on MSC_ConnHdlr {
6927 var template BSSMAP_FIELD_CellIdentificationList cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(0) } };
6928 //cid_list := { cIl_allInBSS := ''O };
6929 var RSL_ChanNeeded rsl_chneed := RSL_CHANNEED_SDCCH;
6930 var template BSSMAP_IE_ChannelNeeded bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
6931 var BSSAP_N_UNITDATA_req paging;
6932 var hexstring imsi := '001010000000123'H;
6933
6934 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
6935
Neels Hofmeyr90f80962020-06-12 16:16:55 +02006936 paging := valueof(ts_BSSAP_UNITDATA_req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006937 valueof(ts_BSSMAP_Paging(imsi, cid_list, omit, bssmap_chneed))));
6938 BSSAP.send(paging);
6939
6940 /* Register any RSL conn so that the Paging Command gets received here. With the current RSL_Emulation's main()
6941 * handling of '[bts_role] IPA_PT.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD()))' it doesn't matter at all which
6942 * channel number is picked here. */
6943 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(0, RSL_CHAN_NR_INVALID));
6944 f_rslem_register(0, new_chan_nr);
6945 RSL.receive(tr_RSL_PAGING_CMD(tr_MI_IMSI(imsi)));
6946 f_rslem_unregister(0, new_chan_nr);
6947
6948 /* Despite the round robin pointing at the second MSC ('roundrobin next 1'), the earlier Paging for the same IMSI
6949 * causes this Paging Response to go to the first MSC (bssap_idx := 0). */
6950 f_perform_compl_l3(RSL, ts_PAG_RESP(valueof(ts_MI_IMSI_LV(imsi))) );
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006951 f_sleep(1.0);
6952}
6953testcase TC_mscpool_paging_and_response_imsi() runs on test_CT {
6954 f_init(nr_bts := 1, handler_mode := true, nr_msc := 3);
6955 f_sleep(1.0);
6956
6957 /* Testing a Paging on the first MSC to get a Paging Response back to the first MSC. Set round robin to the
6958 * second MSC to make sure we're getting the Paging logic, not a coincidental round robin match. */
6959 f_vty_transceive(BSCVTY, "mscpool roundrobin next 1");
6960
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006961 f_ctrs_msc_init();
6962
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006963 var MSC_ConnHdlr vc_conn1;
6964 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6965 pars1.mscpool.rsl_idx := 0;
Neels Hofmeyr90f80962020-06-12 16:16:55 +02006966 pars1.sccp_addr_bsc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_peer;
6967 pars1.sccp_addr_msc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_own;
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006968 vc_conn1 := f_start_handler(refers(f_tc_mscpool_paging_imsi), pars1);
6969 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006970 f_ctrs_msc_expect(0, "mscpool:subscr:paged");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006971 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006972}
6973
6974/* Make sure that whichever MSC paged a subscriber will also get the Paging Response. Page by TMSI with an NRI value
6975 * that matches a different MSC, to make sure the Paging->Response relation is stronger than the NRI->MSC mapping. */
6976private function f_tc_mscpool_paging_tmsi(charstring id) runs on MSC_ConnHdlr {
6977 var template BSSMAP_FIELD_CellIdentificationList cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(0) } };
6978 //cid_list := { cIl_allInBSS := ''O };
6979 var RSL_ChanNeeded rsl_chneed := RSL_CHANNEED_SDCCH;
6980 var template BSSMAP_IE_ChannelNeeded bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
6981 var integer nri_v := 300; /* <-- second MSC's NRI */
Harald Weltebf397612021-01-14 20:39:46 +01006982 var octetstring tmsi := f_gen_tmsi(suffix := 0, nri_v := nri_v);
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006983 var BSSAP_N_UNITDATA_req paging;
6984
6985 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
6986
Neels Hofmeyr90f80962020-06-12 16:16:55 +02006987 paging := valueof(ts_BSSAP_UNITDATA_req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006988 valueof(ts_BSSMAP_Paging('001010000000011'H, cid_list, tmsi, bssmap_chneed))));
6989 BSSAP.send(paging);
6990
6991 /* Register any RSL conn so that the Paging Command gets received here. With the current RSL_Emulation's main()
6992 * handling of '[bts_role] IPA_PT.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD()))' it doesn't matter at all which
6993 * channel number is picked here. */
6994 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(0, RSL_CHAN_NR_INVALID));
6995 f_rslem_register(0, new_chan_nr);
6996 RSL.receive(tr_RSL_PAGING_CMD(t_MI_TMSI(tmsi)));
6997 f_rslem_unregister(0, new_chan_nr);
6998
6999 /* Despite the NRI matching the second MSC (NRI from 'msc 1' in osmo-bsc.cfg) and round robin pointing at the
7000 * third MSC ('roundrobin next 2'), the earlier Paging for the same TMSI causes this Paging Response to go to
7001 * the first MSC (bssap_idx := 0). */
7002 f_perform_compl_l3(RSL, ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(nri_v))) );
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007003 f_sleep(1.0);
7004}
7005testcase TC_mscpool_paging_and_response_tmsi() runs on test_CT {
7006 f_init(nr_bts := 1, handler_mode := true, nr_msc := 3);
7007 f_sleep(1.0);
7008
7009 /* Testing a Paging on the first MSC to get a Paging Response back to the first MSC. Set round robin to the
7010 * third MSC to make sure we're getting the Paging logic, not a coincidental round robin match. */
7011 f_vty_transceive(BSCVTY, "mscpool roundrobin next 2");
7012
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007013 f_ctrs_msc_init();
7014
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007015 var MSC_ConnHdlr vc_conn1;
7016 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
7017 pars1.mscpool.rsl_idx := 0;
Neels Hofmeyr90f80962020-06-12 16:16:55 +02007018 pars1.sccp_addr_bsc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_peer;
7019 pars1.sccp_addr_msc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_own;
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007020 vc_conn1 := f_start_handler(refers(f_tc_mscpool_paging_tmsi), pars1);
7021 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007022 f_ctrs_msc_expect(0, "mscpool:subscr:paged");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007023 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007024}
7025
7026/* For round-robin, skip an MSC that has 'no allow-attach' set. */
7027/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
7028 * just as well using only RSL. */
7029testcase TC_mscpool_no_allow_attach_round_robin() runs on test_CT {
7030
7031 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
7032 f_sleep(1.0);
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00007033 /* Mark the second MSC as offloading, round-robin should skip this MSC now. */
7034 f_vty_msc_allow_attach(BSCVTY, {true, false, true});
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007035
7036 /* Control which MSC gets chosen next by the round-robin, otherwise
7037 * would be randomly affected by which other tests ran before this. */
7038 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
7039
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007040 f_ctrs_msc_init();
7041
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007042 var MSC_ConnHdlr vc_conn1;
7043 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
7044 pars1.mscpool.rsl_idx := 0;
7045 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000001'H)), '00F110'O));
7046 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
7047 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007048 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007049
7050 var MSC_ConnHdlr vc_conn2;
7051 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 2);
7052 pars2.mscpool.rsl_idx := 1;
7053 pars2.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000002'H))));
7054 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
7055 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007056 f_ctrs_msc_expect(2, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007057
7058 var MSC_ConnHdlr vc_conn3;
7059 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
7060 pars3.mscpool.rsl_idx := 2;
7061 pars3.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010000000003'H))));
7062 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
7063 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007064 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007065 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007066}
7067
7068/* An MSC that has 'no allow-attach' set should still serve subscribers that are already attached according to their
7069 * TMSI NRI. */
7070testcase TC_mscpool_no_allow_attach_valid_nri() runs on test_CT {
7071
7072 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
7073 f_sleep(1.0);
7074
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00007075 /* Mark the second MSC as offloading, round-robin should skip this MSC now. */
7076 f_vty_msc_allow_attach(BSCVTY, {true, false, true});
7077
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007078 /* Control which MSC gets chosen next by the round-robin, otherwise
7079 * would be randomly affected by which other tests ran before this. */
7080 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
7081
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007082 f_ctrs_msc_init();
7083
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007084 /* Round robin points at msc 0, but the valid NRI directs to msc 1, even though msc 1 has 'no allow-attach'. */
7085 var MSC_ConnHdlr vc_conn1;
7086 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 1);
7087 pars1.mscpool.rsl_idx := 0;
7088 /* An NRI of the second MSC's range (256-511) */
7089 pars1.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_TMSI_NRI_LV(260))));
7090 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
7091 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007092 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007093
7094 var MSC_ConnHdlr vc_conn2;
7095 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 0);
7096 pars2.mscpool.rsl_idx := 1;
7097 pars2.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000002'H))));
7098 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
7099 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007100 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007101
7102 var MSC_ConnHdlr vc_conn3;
7103 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 2);
7104 pars3.mscpool.rsl_idx := 2;
7105 pars3.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000003'H))));
7106 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
7107 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007108 f_ctrs_msc_expect(2, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007109 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007110}
7111
Philipp Maier783681c2020-07-16 16:47:06 +02007112/* Allow/Deny emergency calls globally via VTY */
7113private function f_vty_allow_emerg_msc(boolean allow) runs on test_CT {
7114 f_vty_enter_cfg_msc(BSCVTY, 0);
7115 if (allow) {
7116 f_vty_transceive(BSCVTY, "allow-emergency allow");
7117 } else {
7118 f_vty_transceive(BSCVTY, "allow-emergency deny");
7119 }
7120 f_vty_transceive(BSCVTY, "exit");
7121 f_vty_transceive(BSCVTY, "exit");
7122}
7123
7124/* Allow/Deny emergency calls per BTS via VTY */
7125private function f_vty_allow_emerg_bts(boolean allow, integer bts_nr) runs on test_CT {
7126 f_vty_enter_cfg_bts(BSCVTY, bts_nr);
7127 if (allow) {
7128 f_vty_transceive(BSCVTY, "rach emergency call allowed 1");
7129 } else {
7130 f_vty_transceive(BSCVTY, "rach emergency call allowed 0");
7131 }
7132 f_vty_transceive(BSCVTY, "exit");
7133 f_vty_transceive(BSCVTY, "exit");
Neels Hofmeyrb6ed80c2020-10-12 22:52:39 +00007134 f_vty_transceive(BSCVTY, "exit");
Philipp Maier783681c2020-07-16 16:47:06 +02007135}
7136
7137/* Begin assignmet procedure and send an EMERGENCY SETUP (RR) */
7138private function f_assignment_emerg_setup() runs on MSC_ConnHdlr {
7139 var PDU_ML3_MS_NW emerg_setup;
7140 var octetstring emerg_setup_enc;
7141 var RSL_Message emerg_setup_data_ind;
7142
7143 f_establish_fully(omit, omit);
7144
7145 emerg_setup := valueof(ts_ML3_MO_CC_EMERG_SETUP(1, valueof(ts_Bcap_voice)));
7146 emerg_setup_enc := enc_PDU_ML3_MS_NW(emerg_setup);
7147 emerg_setup_data_ind := valueof(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), emerg_setup_enc));
7148
7149 RSL.send(emerg_setup_data_ind);
7150}
7151
7152/* Test if the EMERGENCY SETUP gets passed on to the MSC via A when EMERGENCY
7153 * CALLS are permitted by the BSC config. */
7154private function f_TC_assignment_emerg_setup_allow(charstring id) runs on MSC_ConnHdlr {
7155 var PDU_BSSAP emerg_setup_data_ind_bssap;
7156 var PDU_ML3_MS_NW emerg_setup;
7157 timer T := 3.0;
7158
7159 f_assignment_emerg_setup()
7160
7161 T.start;
7162 alt {
7163 [] BSSAP.receive(tr_BSSAP_DTAP) -> value emerg_setup_data_ind_bssap {
7164 emerg_setup := dec_PDU_ML3_MS_NW(emerg_setup_data_ind_bssap.pdu.dtap);
7165 if (not isbound(emerg_setup.msgs.cc.emergencySetup)) {
7166 setverdict(fail, "no emergency setup");
7167 }
7168 }
7169 [] BSSAP.receive {
7170 setverdict(fail, "unexpected BSSAP message!");
7171 }
7172 [] T.timeout {
7173 setverdict(fail, "timout waiting for EMERGENCY SETUP!");
7174 }
7175 }
7176
7177 setverdict(pass);
7178}
7179
7180/* Test if the EMERGENCY SETUP gets blocked by the BSC if EMERGENCY CALLS are
7181 * forbidden by the BSC config. */
7182private function f_TC_assignment_emerg_setup_deny(charstring id) runs on MSC_ConnHdlr {
7183 var PDU_BSSAP emerg_setup_data_ind_bssap;
7184 timer T := 3.0;
7185
7186 f_assignment_emerg_setup()
7187
7188 T.start;
7189 alt {
7190 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
7191 setverdict(pass);
7192 }
7193 [] RSL.receive {
7194 setverdict(fail, "unexpected RSL message!");
7195 }
7196 [] T.timeout {
7197 setverdict(fail, "timout waiting for RR CHANNEL RELEASE!");
7198 }
7199 }
7200}
7201
7202/* EMERGENCY CALL situation #1, allowed globally and by BTS */
7203testcase TC_assignment_emerg_setup_allow() runs on test_CT {
7204 var TestHdlrParams pars := f_gen_test_hdlr_pars();
7205 var MSC_ConnHdlr vc_conn;
7206
7207 f_init(1, true);
7208 f_sleep(1.0);
7209
7210 f_vty_allow_emerg_msc(true);
7211 f_vty_allow_emerg_bts(true, 0);
7212 vc_conn := f_start_handler(refers(f_TC_assignment_emerg_setup_allow), pars);
7213 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007214 f_shutdown_helper();
Philipp Maier783681c2020-07-16 16:47:06 +02007215}
7216
7217/* EMERGENCY CALL situation #2, forbidden globally but allowed by BTS */
7218testcase TC_assignment_emerg_setup_deny_msc() runs on test_CT {
7219 var TestHdlrParams pars := f_gen_test_hdlr_pars();
7220 var MSC_ConnHdlr vc_conn;
7221
7222 f_init(1, true);
7223 f_sleep(1.0);
7224
7225 f_vty_allow_emerg_msc(false);
7226 f_vty_allow_emerg_bts(true, 0);
7227 vc_conn := f_start_handler(refers(f_TC_assignment_emerg_setup_deny), pars);
7228 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007229 f_shutdown_helper();
Philipp Maier783681c2020-07-16 16:47:06 +02007230}
7231
7232/* EMERGENCY CALL situation #3, allowed globally but forbidden by BTS */
7233testcase TC_assignment_emerg_setup_deny_bts() runs on test_CT {
7234 var TestHdlrParams pars := f_gen_test_hdlr_pars();
7235 var MSC_ConnHdlr vc_conn;
7236
7237 /* Note: This simulates a spec violation by the MS, correct MS
7238 * implementations would not try to establish an emergency call because
7239 * the system information tells in advance that emergency calls are
7240 * not forbidden */
7241
7242 f_init(1, true);
7243 f_sleep(1.0);
7244
7245 f_vty_allow_emerg_msc(true);
7246 f_vty_allow_emerg_bts(false, 0);
7247 vc_conn := f_start_handler(refers(f_TC_assignment_emerg_setup_deny), pars);
7248 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007249 f_shutdown_helper();
Philipp Maier783681c2020-07-16 16:47:06 +02007250}
7251
Philipp Maier82812002020-08-13 18:48:27 +02007252/* Test what happens when an emergency call arrives while all TCH channels are
7253 * busy, the BSC is expected to terminate one call in favor of the incoming
7254 * emergency call */
7255testcase TC_emerg_premption() runs on test_CT {
7256 var ASP_RSL_Unitdata rsl_ud;
7257 var integer i;
7258 var integer chreq_total, chreq_nochan;
7259 var RSL_Message rx_rsl;
7260 var RslChannelNr chan_nr;
7261
7262 f_init(1);
7263 f_sleep(1.0);
7264
7265 f_vty_allow_emerg_msc(true);
7266 f_vty_allow_emerg_bts(true, 0);
7267
7268 /* Fill up all channels on the BTS */
7269 chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total");
7270 chreq_nochan := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel");
7271 for (i := 0; i < NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS; i := i+1) {
7272 chan_nr := f_chreq_act_ack('33'O, i);
7273 }
7274 IPA_RSL[0].clear;
7275 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total",
7276 chreq_total + NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS);
7277
7278 /* Send Channel request for emegergency call */
7279 f_ipa_tx(0, ts_RSL_CHAN_RQD('A5'O, 23));
7280
7281 /* Expect the BSC to release one (the first) TCH/F on the BTS */
7282 chan_nr := valueof(t_RslChanNr_Bm(1));
7283 f_expect_chan_rel(0, chan_nr, expect_rr_chan_rel := false, expect_rll_rel_req := false);
7284
7285 /* Expect the BSC to send activate/assign the a channel for the emergency call */
7286 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7287 chan_nr := rx_rsl.ies[0].body.chan_nr;
7288 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 33));
7289 rx_rsl := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
Philipp Maier104f4c02020-09-11 18:12:18 +02007290
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007291 f_shutdown_helper();
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007292}
7293
7294/* Hopping parameters per a timeslot */
Vadim Yanitskiybc6654a2020-09-13 01:27:40 +07007295private type record length(0..64) of GsmArfcn ArfcnList;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007296private type record FHParamsTs {
7297 boolean enabled,
7298 uint6_t hsn,
7299 uint6_t maio,
7300 ArfcnList ma
7301};
7302
7303/* Hopping parameters per a transceiver */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007304private type record FHParamsTrx {
7305 GsmArfcn arfcn,
7306 FHParamsTs ts[8]
7307};
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007308
7309/* Randomly generate the hopping parameters for the given timeslot numbers */
7310private function f_TC_fh_params_gen(template integer tr_tn := (1, 3, 5))
7311runs on test_CT return FHParamsTrx {
7312 var FHParamsTrx fhp;
7313
Vadim Yanitskiy3e997362020-09-05 21:08:34 +07007314 /* Generate a random ARFCN, including ARFCN 0 */
7315 fhp.arfcn := f_rnd_int(3);
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007316
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007317 for (var integer tn := 0; tn < 8; tn := tn + 1) {
7318 if (not match(tn, tr_tn)) {
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007319 fhp.ts[tn].enabled := false;
7320 fhp.ts[tn].ma := { };
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007321 continue;
7322 }
7323
7324 /* Random HSN / MAIO values: 0..63 */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007325 fhp.ts[tn].hsn := f_rnd_int(64);
7326 fhp.ts[tn].maio := f_rnd_int(64);
7327 fhp.ts[tn].ma := { };
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007328
7329 /* Random Mobile Allocation (hopping channels) */
7330 var integer ma_len := 2 + f_rnd_int(9); /* 2..10 channels */
7331 var integer step := 3 + f_rnd_int(4); /* 3..6 stepping */
7332 for (var integer i := 1; i <= ma_len; i := i + 1) {
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007333 fhp.ts[tn].ma := fhp.ts[tn].ma & { i * step };
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007334 }
7335
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007336 fhp.ts[tn].enabled := true;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007337 }
7338
7339 log("f_TC_fh_params_gen(): ", fhp);
7340 return fhp;
7341}
7342
7343/* Make sure that the given Channel Description IE matches the hopping configuration */
7344private function f_TC_fh_params_match_chan_desc(in FHParamsTrx fhp, in ChannelDescription cd)
7345{
7346 var template (present) ChannelDescription tr_cd;
7347 var template (present) MaioHsn tr_maio_hsn;
7348 var uint3_t tn := cd.chan_nr.tn;
7349
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007350 if (fhp.ts[tn].enabled) {
7351 tr_maio_hsn := tr_HsnMaio(fhp.ts[tn].hsn, fhp.ts[tn].maio);
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007352 tr_cd := tr_ChanDescH1(cd.chan_nr, tr_maio_hsn);
7353 } else {
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007354 tr_cd := tr_ChanDescH0(cd.chan_nr, fhp.arfcn);
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007355 }
7356
7357 if (not match(cd, tr_cd)) {
7358 setverdict(fail, "Channel Description IE does not match: ",
7359 cd, " vs expected ", tr_cd);
7360 }
7361}
7362
7363/* Make sure that the given Mobile Allocation IE matches the hopping configuration */
7364private function f_TC_fh_params_match_ma(in FHParamsTrx fhp, uint3_t tn,
7365 in MobileAllocationLV ma)
7366{
7367 var template MobileAllocationLV tr_ma := f_TC_fh_params_gen_tr_ma(fhp, tn, ma);
7368
7369 if (not match(ma, tr_ma)) {
7370 setverdict(fail, "Mobile Allocation IE does not match (tn := ",
7371 tn, "): ", ma, " vs expected: ", tr_ma);
7372 } else {
7373 setverdict(pass);
7374 }
7375}
7376
7377private function f_TC_fh_params_gen_tr_ma(in FHParamsTrx fhp, uint3_t tn,
7378 in MobileAllocationLV ma)
7379return template MobileAllocationLV {
7380 /* Mobile Allocation IE is expected to be empty if hopping is not enabled */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007381 if (not fhp.ts[tn].enabled) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007382 return { len := 0, ma := ''B };
7383 }
7384
7385 var bitstring full_mask := f_pad_bit(''B, 1024, '0'B);
7386 var bitstring slot_mask := f_pad_bit(''B, 1024, '0'B);
7387 var bitstring ma_mask := ''B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007388
7389 /* Compose the full bit-mask (all channels, up to 1024 entries) */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007390 for (var integer i := 0; i < lengthof(fhp.ts); i := i + 1) {
7391 for (var integer j := 0; j < lengthof(fhp.ts[i].ma); j := j + 1) {
7392 if (full_mask[fhp.ts[i].ma[j]] == '1'B)
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007393 { continue; }
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007394 full_mask[fhp.ts[i].ma[j]] := '1'B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007395 }
7396 }
7397
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007398 /* Take ARFCN of the TRX itself into account */
7399 full_mask[fhp.arfcn] := '1'B;
7400
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007401 /* Compose a bit-mask for the given timeslot number */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007402 for (var integer i := 0; i < lengthof(fhp.ts[tn].ma); i := i + 1) {
7403 slot_mask[fhp.ts[tn].ma[i]] := '1'B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007404 }
7405
7406 /* Finally, compose the Mobile Allocation bit-mask */
Vadim Yanitskiy3e997362020-09-05 21:08:34 +07007407 for (var integer i := 1; i < lengthof(full_mask); i := i + 1) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007408 if (full_mask[i] != '1'B)
7409 { continue; }
7410
7411 /* FIXME: ma_mask := ma_mask & slot_mask[i]; // triggers a bug in TITAN */
7412 if (slot_mask[i] == '1'B) {
7413 ma_mask := ma_mask & '1'B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007414 } else {
7415 ma_mask := ma_mask & '0'B;
7416 }
7417 }
7418
Vadim Yanitskiy3e997362020-09-05 21:08:34 +07007419 /* ARFCN 0 (if present) goes to the last position of the bit-mask */
7420 if (full_mask[0] == '1'B) {
7421 /* FIXME: ma_mask := ma_mask & slot_mask[0]; // triggers a bug in TITAN */
7422 if (slot_mask[0] == '1'B) {
7423 ma_mask := ma_mask & '1'B;
7424 } else {
7425 ma_mask := ma_mask & '0'B;
7426 }
7427 }
7428
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007429 /* Ensure that ma_mask is octet-aligned */
Vadim Yanitskiy2aa02522020-09-06 14:05:23 +07007430 var integer ma_mask_len := (lengthof(ma_mask) + 8 - 1) / 8;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007431 ma_mask := f_pad_bit(ma_mask, ma_mask_len * 8, '0'B);
7432
7433 return { len := ma_mask_len, ma := ma_mask };
7434}
7435
7436/* Configure the hopping parameters in accordance with the given record */
7437private function f_TC_fh_params_set(in FHParamsTrx fhp,
7438 uint8_t bts_nr := 0,
7439 uint8_t trx_nr := 0)
7440runs on test_CT {
7441 /* Enter the configuration node for the given BTS/TRX numbers */
7442 f_vty_enter_cfg_trx(BSCVTY, bts_nr, trx_nr);
7443
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007444 f_vty_transceive(BSCVTY, "arfcn " & int2str(fhp.arfcn));
7445
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007446 for (var integer tn := 0; tn < lengthof(fhp.ts); tn := tn + 1) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007447 f_vty_transceive(BSCVTY, "timeslot " & int2str(tn));
7448
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007449 if (not fhp.ts[tn].enabled) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007450 f_vty_transceive(BSCVTY, "hopping enabled 0");
7451 f_vty_transceive(BSCVTY, "exit"); /* go back */
7452 continue;
7453 }
7454
7455 /* Configure HSN / MAIO values */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007456 f_vty_transceive(BSCVTY, "hopping sequence-number " & int2str(fhp.ts[tn].hsn));
7457 f_vty_transceive(BSCVTY, "hopping maio " & int2str(fhp.ts[tn].maio));
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007458
7459 /* Configure the Mobile Allocation (hopping channels) */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007460 for (var integer i := 0; i < lengthof(fhp.ts[tn].ma); i := i + 1) {
7461 f_vty_transceive(BSCVTY, "hopping arfcn add " & int2str(fhp.ts[tn].ma[i]));
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007462 }
7463
7464 f_vty_transceive(BSCVTY, "hopping enabled 1");
7465 f_vty_transceive(BSCVTY, "exit"); /* go back */
7466 }
7467
7468 f_vty_transceive(BSCVTY, "end");
7469}
7470
7471/* Disable frequency hopping on all timeslots */
7472private function f_TC_fh_params_unset(in FHParamsTrx fhp,
7473 uint8_t bts_nr := 0,
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007474 uint8_t trx_nr := 0,
7475 GsmArfcn arfcn := 871)
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007476runs on test_CT {
7477 /* Enter the configuration node for the given BTS/TRX numbers */
7478 f_vty_enter_cfg_trx(BSCVTY, bts_nr, trx_nr);
7479
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007480 f_vty_transceive(BSCVTY, "arfcn " & int2str(arfcn));
7481
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007482 for (var integer tn := 0; tn < lengthof(fhp.ts); tn := tn + 1) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007483 f_vty_transceive(BSCVTY, "timeslot " & int2str(tn));
7484
7485 /* Delete all ARFCNs from the Mobile Allocation (if any) */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007486 for (var integer i := 0; i < lengthof(fhp.ts[tn].ma); i := i + 1) {
7487 f_vty_transceive(BSCVTY, "hopping arfcn del " & int2str(fhp.ts[tn].ma[i]));
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007488 }
7489
7490 f_vty_transceive(BSCVTY, "hopping enabled 0");
7491 f_vty_transceive(BSCVTY, "exit"); /* go back */
7492 }
7493
7494 f_vty_transceive(BSCVTY, "end");
7495 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7496}
7497
7498/* Verify presence and correctness of the hopping parameters (HSN, MAIO)
7499 * in the Channel Identification IE of the RSL CHANnel ACTIVation message. */
7500testcase TC_fh_params_chan_activ() runs on test_CT {
7501 var FHParamsTrx fhp := f_TC_fh_params_gen();
7502 var RSL_Message rsl_msg;
7503 var RSL_IE_Body ie;
7504
7505 f_init_vty();
7506
7507 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
7508 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7509
7510 f_init(1);
7511
7512 /* CS domain: 3 (SDCCH/4+CBCH) + 4 (TCH/F) + 2 (TCH/H) channels available */
7513 for (var integer i := 0; i < 9; i := i + 1) {
7514 f_ipa_tx(0, ts_RSL_CHAN_RQD(f_rnd_ra_cs(), 23));
7515 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7516
7517 /* Make sure that Channel Identification IE is present */
7518 if (not f_rsl_find_ie(rsl_msg, RSL_IE_CHAN_IDENT, ie)) {
7519 setverdict(fail, "RSL Channel Identification IE is absent");
7520 continue;
7521 }
7522
7523 /* Make sure that hopping parameters (HSN/MAIO) match */
7524 f_TC_fh_params_match_chan_desc(fhp, ie.chan_ident.ch_desc.v);
7525
7526 /* "Mobile Allocation shall be included but empty" - let's check this */
7527 if (ie.chan_ident.ma.v.len != 0) {
7528 setverdict(fail, "Mobile Allocation IE is not empty: ",
7529 ie.chan_ident.ma, ", despite it shall be");
7530 continue;
7531 }
7532 }
7533
7534 /* Disable frequency hopping */
7535 f_TC_fh_params_unset(fhp);
7536
Vadim Yanitskiy21726312020-09-04 01:45:36 +07007537 f_shutdown_helper();
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007538}
7539
7540/* Verify the hopping parameters (HSN, MAIO, MA) in (RR) Immediate Assignment */
7541testcase TC_fh_params_imm_ass() runs on test_CT {
7542 var FHParamsTrx fhp := f_TC_fh_params_gen();
7543 var RSL_Message rsl_msg;
7544 var RSL_IE_Body ie;
7545
7546 f_init_vty();
7547
7548 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
7549 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7550
7551 f_init(1);
7552
7553 /* CS domain: 3 (SDCCH/4+CBCH) + 4 (TCH/F) + 2 (TCH/H) channels available */
7554 for (var integer i := 0; i < 9; i := i + 1) {
7555 f_ipa_tx(0, ts_RSL_CHAN_RQD(f_rnd_ra_cs(), 23));
7556 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7557
7558 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(rsl_msg.ies[0].body.chan_nr, 33));
7559 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeC(RSL_MT_IMMEDIATE_ASSIGN_CMD));
7560
7561 /* Make sure that Full Immediate Assign Info IE is present */
7562 if (not f_rsl_find_ie(rsl_msg, RSL_IE_FULL_IMM_ASS_INFO, ie)) {
7563 setverdict(fail, "RSL Full Immediate Assign Info IE is absent");
7564 continue;
7565 }
7566
7567 /* Decode the actual Immediate Assignment message */
7568 var GsmRrMessage rr_msg := dec_GsmRrMessage(ie.full_imm_ass_info.payload);
7569 if (not match(rr_msg.header, t_RrHeader(IMMEDIATE_ASSIGNMENT, ?))) {
7570 setverdict(fail, "Failed to match Immediate Assignment: ", rr_msg);
7571 continue;
7572 }
7573
7574 /* Make sure that hopping parameters (HSN/MAIO) match */
7575 f_TC_fh_params_match_chan_desc(fhp, rr_msg.payload.imm_ass.chan_desc);
7576
7577 /* Make sure that the Mobile Allocation IE matches */
7578 f_TC_fh_params_match_ma(fhp, rr_msg.payload.imm_ass.chan_desc.chan_nr.tn,
7579 rr_msg.payload.imm_ass.mobile_allocation);
7580 }
7581
7582 /* Disable frequency hopping */
7583 f_TC_fh_params_unset(fhp);
Philipp Maier82812002020-08-13 18:48:27 +02007584
Vadim Yanitskiy21726312020-09-04 01:45:36 +07007585 f_shutdown_helper();
Philipp Maier82812002020-08-13 18:48:27 +02007586}
7587
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07007588/* Verify the hopping parameters (HSN, MAIO, MA) in (RR) Assignment Command */
7589testcase TC_fh_params_assignment_cmd() runs on test_CT {
7590 var FHParamsTrx fhp := f_TC_fh_params_gen();
7591 var RSL_Message rsl_msg;
7592 var RSL_IE_Body ie;
7593
7594 f_init_vty();
7595
7596 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
7597 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7598
7599 f_init(1);
7600
7601 /* HACK: work around "Couldn't find Expect for CRCX" */
7602 vc_MGCP.stop;
7603
7604 var template PDU_BSSAP ass_cmd := f_gen_ass_req();
7605 ass_cmd.pdu.bssmap.assignmentRequest.codecList := ts_BSSMAP_IE_CodecList({ts_CodecFR});
7606
7607 /* CS domain (TCH): 4 (TCH/F) + 2 (TCH/H) channels available
7608 * NOTE: only 3 SDCCH/4 channels are available on CCCH+SDCCH4+CBCH */
7609 for (var integer i := 0; i < 3; i := i + 1) {
7610 /* Establish a dedicated channel, so we can trigger (late) TCH assignment */
7611 var DchanTuple dt := f_est_dchan(f_rnd_ra_cs(), 23, f_rnd_octstring(16));
7612
7613 /* Send a BSSMAP Assignment Command, expect CHANnel ACTIVation */
7614 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ass_cmd));
7615 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7616
7617 /* ACKnowledge CHANnel ACTIVation, expect RSL DATA REQuest */
7618 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(rsl_msg.ies[0].body.chan_nr, 33));
7619 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeR(RSL_MT_DATA_REQ));
7620
7621 /* Make sure that L3 Information IE is present */
7622 if (not f_rsl_find_ie(rsl_msg, RSL_IE_L3_INFO, ie)) {
7623 setverdict(fail, "RSL L3 Information IE is absent");
7624 continue;
7625 }
7626
7627 /* Decode the L3 message and make sure it is (RR) Assignment Command */
7628 var GsmRrL3Message l3_msg := dec_GsmRrL3Message(ie.l3_info.payload);
7629 if (not match(l3_msg.header, t_RrL3Header(ASSIGNMENT_COMMAND))) {
7630 setverdict(fail, "Failed to match Assignment Command: ", l3_msg);
7631 continue;
7632 }
7633
7634 /* Make sure that hopping parameters (HSN/MAIO) match */
7635 var ChannelDescription chan_desc := l3_msg.payload.ass_cmd.chan_desc;
7636 f_TC_fh_params_match_chan_desc(fhp, chan_desc);
7637
7638 /* Make sure that Cell Channel Description IE is present if FH is enabled */
7639 if (chan_desc.h and not ispresent(l3_msg.payload.ass_cmd.cell_chan_desc)) {
Vadim Yanitskiy38d069d2020-09-02 17:18:57 +07007640 setverdict(fail, "FH enabled, but Cell Channel Description IE is absent");
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07007641 continue;
7642 }
7643
7644 /* Make sure that the Mobile Allocation IE matches (if present) */
7645 var boolean ma_present := ispresent(l3_msg.payload.ass_cmd.mobile_allocation);
7646 if (chan_desc.h and ma_present) {
7647 f_TC_fh_params_match_ma(fhp, chan_desc.chan_nr.tn,
7648 l3_msg.payload.ass_cmd.mobile_allocation.v);
7649 } else if (chan_desc.h and not ma_present) {
7650 setverdict(fail, "FH enabled, but Mobile Allocation IE is absent");
7651 continue;
7652 } else if (not chan_desc.h and ma_present) {
7653 setverdict(fail, "FH disabled, but Mobile Allocation IE is present");
7654 continue;
7655 }
7656 }
7657
7658 /* Give the IUT some time to release all channels */
7659 f_sleep(3.0);
7660
7661 /* Disable frequency hopping */
7662 f_TC_fh_params_unset(fhp);
7663
Vadim Yanitskiy21726312020-09-04 01:45:36 +07007664 f_shutdown_helper();
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07007665}
7666
Vadim Yanitskiy8f5430d2020-09-02 18:51:38 +07007667/* Verify the hopping parameters (HSN, MAIO, MA) in (RR) Handover Command */
7668private function f_TC_fh_params_handover_cmd(in FHParamsTrx fhp)
7669runs on test_CT {
7670 var RSL_Message rsl_msg;
7671 var RSL_IE_Body ie;
7672 var DchanTuple dt;
7673
7674 /* Establish a dedicated channel, so we can trigger handover */
7675 dt := f_est_dchan(f_rnd_ra_cs(), 23, f_rnd_octstring(16));
7676
7677 /* Trigger handover from BTS0 to BTS1 */
7678 f_bts_0_cfg(BSCVTY, { "neighbor bts 1" });
7679 f_vty_handover(BSCVTY, 0, 0, dt.rsl_chan_nr, 1);
7680
7681 /* Expect RSL CHANnel ACTIVation on BTS1/TRX0/TS1 */
7682 rsl_msg := f_exp_ipa_rx(1, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7683
7684 /* ACKnowledge channel activation and expect (RR) Handover Command */
7685 f_ipa_tx(1, ts_RSL_CHAN_ACT_ACK(rsl_msg.ies[0].body.chan_nr, 33));
7686 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeR(RSL_MT_DATA_REQ));
7687
7688 /* Make sure that L3 Information IE is present */
7689 if (not f_rsl_find_ie(rsl_msg, RSL_IE_L3_INFO, ie)) {
7690 setverdict(fail, "RSL L3 Information IE is absent");
7691 return;
7692 }
7693
7694 /* Decode the L3 message and make sure it is (RR) Handover Command */
7695 var GsmRrL3Message l3_msg := dec_GsmRrL3Message(ie.l3_info.payload);
7696 if (not match(l3_msg.header, t_RrL3Header(HANDOVER_COMMAND))) {
7697 setverdict(fail, "Failed to match Handover Command: ", l3_msg);
7698 return;
7699 }
7700
7701 /* Make sure that we've got SDCCH/8 on TS1 (expected to be hopping) */
7702 var ChannelDescription chan_desc := l3_msg.payload.ho_cmd.chan_desc;
7703 if (not match(chan_desc.chan_nr, t_RslChanNr_SDCCH8(1, ?))) {
7704 setverdict(fail, "Unexpected channel number: ", chan_desc.chan_nr);
7705 return;
7706 }
7707
7708 /* Make sure that hopping parameters (HSN/MAIO) match */
7709 f_TC_fh_params_match_chan_desc(fhp, chan_desc);
7710
7711 /* Make sure that Cell Channel Description IE is present */
7712 if (not ispresent(l3_msg.payload.ho_cmd.cell_chan_desc)) {
7713 setverdict(fail, "FH enabled, but Cell Channel Description IE is absent");
7714 return;
7715 }
7716
7717 /* Make sure that the Mobile Allocation (after time) IE is present and matches */
7718 var boolean ma_present := ispresent(l3_msg.payload.ho_cmd.mobile_allocation);
7719 if (ma_present) {
7720 f_TC_fh_params_match_ma(fhp, chan_desc.chan_nr.tn,
7721 l3_msg.payload.ho_cmd.mobile_allocation.v);
7722 } else {
7723 setverdict(fail, "FH enabled, but Mobile Allocation IE is absent");
7724 return;
7725 }
7726}
7727testcase TC_fh_params_handover_cmd() runs on test_CT {
7728 var FHParamsTrx fhp := f_TC_fh_params_gen();
7729
7730 f_init_vty();
7731
7732 /* (Re)configure TS0 as BCCH and TS1 as SDCCH8 on BTS1/TRX0 */
7733 f_vty_enter_cfg_trx(BSCVTY, bts := 1, trx := 0);
7734
7735 f_vty_transceive(BSCVTY, "timeslot 0");
7736 f_vty_transceive(BSCVTY, "phys_chan_config ccch");
7737 f_vty_transceive(BSCVTY, "exit"); /* go back */
7738
7739 f_vty_transceive(BSCVTY, "timeslot 1");
7740 f_vty_transceive(BSCVTY, "phys_chan_config sdcch8");
7741 f_vty_transceive(BSCVTY, "end"); /* we're done */
7742
7743 f_TC_fh_params_set(fhp, 1); /* Enable frequency hopping on BTS1 */
7744 f_vty_transceive(BSCVTY, "drop bts connection 1 oml");
7745
7746 f_init(2);
7747
7748 f_TC_fh_params_handover_cmd(fhp);
7749
7750 /* Disable frequency hopping on BTS1 */
7751 f_TC_fh_params_unset(fhp, 1);
7752
7753 /* (Re)configure TS0 as CCCH+SDCCH4+CBCH and TS1 as TCH/F */
7754 f_vty_enter_cfg_trx(BSCVTY, bts := 1, trx := 0);
7755
7756 f_vty_transceive(BSCVTY, "timeslot 0");
7757 f_vty_transceive(BSCVTY, "phys_chan_config ccch+sdcch4+cbch");
7758 f_vty_transceive(BSCVTY, "exit"); /* go back */
7759
7760 f_vty_transceive(BSCVTY, "timeslot 1");
7761 f_vty_transceive(BSCVTY, "phys_chan_config tch/f");
7762 f_vty_transceive(BSCVTY, "end"); /* we're done */
7763
7764 f_shutdown_helper();
7765}
7766
Vadim Yanitskiyca974032020-09-01 07:20:39 +07007767/* Verify the hopping parameters in System Information Type 4 */
7768testcase TC_fh_params_si4_cbch() runs on test_CT {
7769 var FHParamsTrx fhp := f_TC_fh_params_gen(tr_tn := 1);
7770 var ASP_RSL_Unitdata rx_rsl_ud;
7771 timer T := 5.0;
7772
7773 f_init_vty();
7774
7775 /* (Re)configure TS0 as BCCH and TS1 as SDCCH8+CBCH */
7776 f_vty_enter_cfg_trx(BSCVTY, trx := 0);
7777
7778 f_vty_transceive(BSCVTY, "timeslot 0");
7779 f_vty_transceive(BSCVTY, "phys_chan_config ccch");
7780 f_vty_transceive(BSCVTY, "exit"); /* go back */
7781
7782 f_vty_transceive(BSCVTY, "timeslot 1");
7783 f_vty_transceive(BSCVTY, "phys_chan_config sdcch8+cbch");
7784 f_vty_transceive(BSCVTY, "end"); /* we're done */
7785
7786 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
7787 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7788
7789 f_init(1);
7790
7791 T.start;
7792 alt {
7793 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_BCCH_INFO(RSL_SYSTEM_INFO_4))) -> value rx_rsl_ud {
7794 var RSL_IE_Body ie := rx_rsl_ud.rsl.ies[2].body; /* FULL BCCH Information IE */
7795 var SystemInformation si := dec_SystemInformation(ie.other.payload);
7796
7797 /* Make sure that what we decoded is System Information Type 4 */
7798 if (si.header.message_type != SYSTEM_INFORMATION_TYPE_4) {
7799 setverdict(fail, "RSL FULL BCCH Information IE contains: ", si);
7800 repeat;
7801 }
7802
7803 /* Make sure that CBCH Channel Description IE is present */
7804 if (not ispresent(si.payload.si4.cbch_chan_desc)) {
7805 setverdict(fail, "CBCH Channel Description IE is absent");
7806 break;
7807 }
7808
7809 /* Finally, check the hopping parameters (HSN, MAIO) */
7810 var ChannelDescription chan_desc := si.payload.si4.cbch_chan_desc.v;
7811 f_TC_fh_params_match_chan_desc(fhp, chan_desc);
7812
7813 /* 3GPP TS 44.018, section 9.1.36.2 "CBCH Mobile Allocation":
7814 * The CBCH Mobile Allocation IE *shall* be present if FH is enabled. */
7815 if (chan_desc.h and not ispresent(si.payload.si4.cbch_mobile_alloc)) {
7816 setverdict(fail, "FH enabled, but Mobile Allocation IE is absent");
7817 break;
7818 } else if (chan_desc.h and ispresent(si.payload.si4.cbch_mobile_alloc)) {
7819 f_TC_fh_params_match_ma(fhp, chan_desc.chan_nr.tn,
7820 si.payload.si4.cbch_mobile_alloc.v);
7821 }
7822 }
7823 [] IPA_RSL[0].receive { repeat; }
7824 [] T.timeout {
7825 setverdict(fail, "Timeout waiting for RSL BCCH INFOrmation (SI4)");
7826 }
7827 }
7828
7829 /* Disable frequency hopping */
7830 f_TC_fh_params_unset(fhp);
7831
Vadim Yanitskiy8bc46012020-09-06 12:38:01 +07007832 /* (Re)configure TS0 as CCCH+SDCCH4+CBCH and TS1 as TCH/F */
Vadim Yanitskiyca974032020-09-01 07:20:39 +07007833 f_vty_enter_cfg_trx(BSCVTY, trx := 0);
7834
7835 f_vty_transceive(BSCVTY, "timeslot 0");
Vadim Yanitskiy8bc46012020-09-06 12:38:01 +07007836 f_vty_transceive(BSCVTY, "phys_chan_config ccch+sdcch4+cbch");
Vadim Yanitskiyca974032020-09-01 07:20:39 +07007837 f_vty_transceive(BSCVTY, "exit"); /* go back */
7838
7839 f_vty_transceive(BSCVTY, "timeslot 1");
7840 f_vty_transceive(BSCVTY, "phys_chan_config tch/f");
7841 f_vty_transceive(BSCVTY, "end"); /* we're done */
7842
Vadim Yanitskiy21726312020-09-04 01:45:36 +07007843 f_shutdown_helper();
Vadim Yanitskiyca974032020-09-01 07:20:39 +07007844}
7845
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02007846template (value) PDU_BSSAP_LE ts_BSSMAP_LE_BSSLAP(template (value) BSSLAP_PDU bsslap)
7847 := ts_BSSMAP_LE_ConnInfo(BSSMAP_LE_PROT_BSSLAP, data := enc_BSSLAP_PDU(valueof(bsslap)));
7848
7849private function f_match_bsslap(PDU_BSSAP_LE got_bsslap_msg,
7850 template (present) BSSLAP_PDU expect_bsslap)
7851{
7852 var BSSLAP_PDU bsslap := dec_BSSLAP_PDU(got_bsslap_msg.pdu.bssmap.co_info.bsslap_apdu.data);
7853 if (not match(bsslap, expect_bsslap)) {
7854 log("EXPECTING BSSLAP: ", expect_bsslap);
7855 log("GOT BSSLAP: ", bsslap);
7856 setverdict(fail, "BSSLAP is not as expected");
7857 mtc.stop;
7858 }
7859 setverdict(pass);
7860}
7861
7862/* GAD: this is an Ellipsoid point with uncertainty circle, encoded as in 3GPP TS 23.032 §7.3.2. */
7863const octetstring gad_ell_point_unc_circle := '10b0646d0d5f6627'O;
7864
7865private function f_expect_bsslap(template (present) BSSLAP_PDU expect_rx_bsslap) runs on MSC_ConnHdlr {
7866 var PDU_BSSAP_LE rx_bsslap;
7867 BSSAP_LE.receive(tr_BSSMAP_LE_ConnInfo(BSSMAP_LE_PROT_BSSLAP, ?)) -> value(rx_bsslap);
7868 f_match_bsslap(rx_bsslap, expect_rx_bsslap);
7869}
7870
7871/* With an active lchan, start BSSMAP Perform Location Request on A interface, starting BSSMAP-LE Perform Location
7872 * Request on Lb interface. Either with or without the SMLC doing a BSSLAP TA Request. */
7873private function f_lcs_loc_req_for_active_ms(boolean do_ta_request := false) runs on MSC_ConnHdlr {
7874 f_sleep(1.0);
7875
7876 f_establish_fully(omit, omit);
7877 f_bssap_le_register_imsi(g_pars.imsi, omit);
7878
7879 BSSAP.send(valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
7880 ts_CellId_CGI('262'H, '42'H, 23, 42))));
7881
7882 var PDU_BSSAP_LE plr;
7883 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
7884
7885 if (not do_ta_request) {
7886 /* verify TA Layer 3 in APDU. First the APDU type (BSSLAP), then the BSSLAP data contents. */
7887 var template BSSMAP_LE_IE_APDU expect_apdu := tr_BSSMAP_LE_APDU(BSSMAP_LE_PROT_BSSLAP, ?);
7888 if (not match(plr.pdu.bssmap.perf_loc_req.bsslap_apdu, expect_apdu)) {
7889 log("EXPECTING BSSMAP-LE APDU IE ", expect_apdu);
7890 log("GOT BSSMAP-LE APDU IE ", plr.pdu.bssmap.perf_loc_req.bsslap_apdu);
7891 setverdict(fail, "BSSMAP-LE APDU IE is not as expected");
7892 mtc.stop;
7893 }
7894 var template BSSLAP_PDU expect_ta_layer3 := tr_BSSLAP_TA_Layer3(tr_BSSLAP_IE_TA(0));
7895 var BSSLAP_PDU bsslap := dec_BSSLAP_PDU(plr.pdu.bssmap.perf_loc_req.bsslap_apdu.data);
7896 if (not match(bsslap, expect_ta_layer3)) {
7897 log("EXPECTING BSSLAP TA Layer 3: ", expect_ta_layer3);
7898 log("GOT BSSLAP: ", bsslap);
7899 setverdict(fail, "BSSLAP is not as expected");
7900 mtc.stop;
7901 }
7902 /* OsmoBSC directly sent the TA as BSSLAP APDU in the BSSMAP-LE Perform Location Request to the SMLC. The SMLC
7903 * has no need to request the TA from the BSC and directly responds. */
7904 } else {
7905 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
7906 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
7907 f_expect_bsslap(tr_BSSLAP_TA_Resp(?, ?));
7908 }
7909
7910 /* SMLC got the TA from the BSC, now responds with geo information data. */
7911 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(gad_ell_point_unc_circle, omit));
7912 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
7913 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(tr_BSSMAP_IE_LocationEstimate(gad_ell_point_unc_circle)));
7914
7915 /* The LCS was using an active A-interface conn. It should still remain active after this. */
7916 f_mo_l3_transceive();
7917
7918 f_perform_clear(RSL);
7919
7920 f_sleep(2.0);
7921 setverdict(pass);
7922}
7923
7924/* With an active lchan, start BSSMAP Perform Location Request on A interface, starting BSSMAP-LE Perform Location
7925 * Request on Lb interface. Without the SMLC doing a BSSLAP TA Request. */
7926private function f_tc_lcs_loc_req_for_active_ms(charstring id) runs on MSC_ConnHdlr {
7927 f_lcs_loc_req_for_active_ms(false);
7928}
7929testcase TC_lcs_loc_req_for_active_ms() runs on test_CT {
7930 var MSC_ConnHdlr vc_conn;
7931 var TestHdlrParams pars := f_gen_test_hdlr_pars();
7932
7933 f_init(1, true);
7934 f_sleep(1.0);
7935 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_active_ms), pars);
7936 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01007937 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02007938}
7939
7940/* With an active lchan, start BSSMAP Perform Location Request on A interface, starting BSSMAP-LE Perform Location
7941 * Request on Lb interface. With the SMLC doing a BSSLAP TA Request. */
7942private function f_tc_lcs_loc_req_for_active_ms_ta_req(charstring id) runs on MSC_ConnHdlr {
7943 f_lcs_loc_req_for_active_ms(true);
7944}
7945testcase TC_lcs_loc_req_for_active_ms_ta_req() runs on test_CT {
7946 var MSC_ConnHdlr vc_conn;
7947 var TestHdlrParams pars := f_gen_test_hdlr_pars();
7948
7949 f_init(1, true);
7950 f_sleep(1.0);
7951 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_active_ms_ta_req), pars);
7952 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01007953 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02007954}
7955
7956/* Clear the A-interface conn only, without doing anything on Abis. Useful for LCS, for cases where there is only an A
7957 * conn without an active lchan. */
7958private function f_clear_A_conn() runs on MSC_ConnHdlr
7959{
7960 var BssmapCause cause := 0;
7961 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
7962 BSSAP.receive(tr_BSSMAP_ClearComplete);
7963 BSSAP.send(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_REQ);
7964
7965 timer no_more_bssap := 5.0;
7966 no_more_bssap.start;
7967 alt {
7968 [] no_more_bssap.timeout { break; }
7969 [] BSSAP.receive(tr_BSSAP_BSSMAP) {
7970 setverdict(fail, "Expected no more BSSAP after Clear Complete");
7971 mtc.stop;
7972 }
7973 }
7974 setverdict(pass);
7975}
7976
7977/* Verify that the A-interface connection is still working, and then clear it, without doing anything on Abis. Useful
7978 * for LCS, for cases where there is only an A conn without an active lchan. */
7979private function f_verify_active_A_conn_and_clear() runs on MSC_ConnHdlr
7980{
7981 f_logp(BSCVTY, "f_verify_active_A_conn_and_clear: test A link, then clear");
7982
7983 /* When an lchan is active, we can send some L3 data from the BTS side and verify that it shows up on the other
7984 * side towards the MSC. When there is no lchan, this is not possible. To probe whether the A-interface
7985 * connection is still up, we need something that echos back on the A-interface. Another LCS request! */
7986 BSSAP.send(valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
7987 ts_CellId_CGI('262'H, '42'H, 23, 42))));
7988 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?));
7989
7990 /* Right, the Perform Location Request showed up on Lb, now we can clear the A conn. */
7991 f_clear_A_conn();
7992 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocAbort(BSSMAP_LE_LCS_CAUSE_REQUEST_ABORTED));
7993 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
7994}
7995
7996/* With *no* active lchan, start BSSMAP Perform Location Request on A interface, starting BSSMAP-LE Perform Location
7997 * Request on Lb interface. BSC will Page for the subscriber as soon as we (virtual SMLC) request the TA via BSSLAP.
7998 */
7999private function f_tc_lcs_loc_req_for_idle_ms(charstring id) runs on MSC_ConnHdlr {
8000 f_sleep(1.0);
8001
8002 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
8003 f_bssap_le_register_imsi(g_pars.imsi, omit);
8004
8005 /* Register to receive the Paging Command */
8006 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
8007 g_chan_nr := new_chan_nr;
8008 f_rslem_register(0, g_chan_nr);
8009
8010 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
8011 valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
8012 ts_CellId_CGI('001'H, '01'H, 1, 0)))));
8013 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
8014
8015 var PDU_BSSAP_LE plr;
8016 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
8017
8018 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
8019 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
8020
8021 /* OsmoBSC needs to Page */
8022 RSL.receive(tr_RSL_PAGING_CMD(tr_MI_IMSI(g_pars.imsi)));
8023 f_logp(BSCVTY, "got Paging Command");
8024
8025 /* MS requests channel. Since the Paging was for LCS, the Paging Response does not trigger a Complete Layer 3 to
8026 * the MSC, and releases the lchan directly. */
8027 f_perform_compl_l3(RSL, ts_PAG_RESP(valueof(ts_MI_IMSI_LV(g_pars.imsi))), do_clear := false, expect_bssmap_l3 := false);
8028 f_expect_lchan_rel(RSL);
8029
8030 /* From the Paging Response, the TA is now known to the BSC, and it responds to the SMLC. */
8031
8032 f_expect_bsslap(tr_BSSLAP_TA_Resp(?, ?));
8033
8034 /* SMLC got the TA from the BSC, now responds with geo information data. */
8035 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(gad_ell_point_unc_circle, omit));
8036 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
8037
8038 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(tr_BSSMAP_IE_LocationEstimate(gad_ell_point_unc_circle)));
8039
8040 /* The lchan is gone, the A-interface conn was created for the LCS only.
8041 * Still it is clearly the MSC's job to decide whether to tear down the conn or not. */
8042 f_verify_active_A_conn_and_clear();
8043
8044 f_sleep(2.0);
8045 setverdict(pass);
8046}
8047testcase TC_lcs_loc_req_for_idle_ms() runs on test_CT {
8048 var MSC_ConnHdlr vc_conn;
8049 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8050
8051 f_init(1, true);
8052 f_sleep(1.0);
8053
8054 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
8055 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
8056
8057 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_idle_ms), pars);
8058 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008059 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008060}
8061
8062/* With no active lchan, start BSSMAP Perform Location Request on A interface, but omit IMSI; expect failure response.
8063 */
8064private function f_tc_lcs_loc_req_no_subscriber(charstring id) runs on MSC_ConnHdlr {
8065 f_sleep(1.0);
8066
8067 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
8068 f_bssap_le_register_imsi(g_pars.imsi, omit);
8069
8070 /* provoke an abort by omitting both IMSI and IMEI */
8071 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
8072 valueof(ts_BSSMAP_Perform_Location_Request(omit,
8073 ts_CellId_CGI('262'H, '42'H, 23, 42)))));
8074 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
8075
8076 /* BSC tells MSC about failure */
8077 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(
8078 locationEstimate := omit, positioningData := omit,
8079 lCS_Cause := tr_BSSMAP_LcsCause(BSSMAP_LCS_CAUSE_DATA_MISSING_IN_REQ)));
8080
8081 /* There is no lchan. Still the MSC's job to decide whether to tear down the conn or not. */
8082 f_verify_active_A_conn_and_clear();
8083
8084 f_sleep(2.0);
8085 setverdict(pass);
8086}
8087testcase TC_lcs_loc_req_no_subscriber() runs on test_CT {
8088 var MSC_ConnHdlr vc_conn;
8089 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8090
8091 f_init(1, true);
8092 f_sleep(1.0);
8093
8094 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
8095 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
8096
8097 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_no_subscriber), 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 a Perform Location Request on the A-interface, but virtual SMLC does not answer with
8103 * BSSMAP-LE Perform Location Response (before or after sending a BSSLAP TA Request) */
8104private function f_lcs_loc_req_for_active_ms_le_timeout(boolean do_ta) runs on MSC_ConnHdlr {
8105 f_sleep(1.0);
8106
8107 f_establish_fully(omit, omit);
8108 f_bssap_le_register_imsi(g_pars.imsi, omit);
8109
8110 BSSAP.send(valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
8111 ts_CellId_CGI('262'H, '42'H, 23, 42))));
8112
8113 var PDU_BSSAP_LE plr;
8114 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
8115
8116 if (do_ta) {
8117 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
8118 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
8119 f_expect_bsslap(tr_BSSLAP_TA_Resp(?, ?));
8120 }
8121
8122 /* SMLC fails to respond, BSC runs into timeout */
8123 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocAbort(BSSMAP_LE_LCS_CAUSE_SYSTEM_FAILURE));
8124 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
8125
8126 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(
8127 locationEstimate := omit, positioningData := omit,
8128 lCS_Cause := tr_BSSMAP_LcsCause(BSSMAP_LCS_CAUSE_SYSTEM_FAILURE)));
8129
8130 /* There is no lchan. Still the MSC's job to decide whether to tear down the conn or not. */
8131 f_verify_active_A_conn_and_clear();
8132
8133 f_sleep(2.0);
8134 setverdict(pass);
8135}
8136
8137/* With an active lchan, start a Perform Location Request on the A-interface, but virtual SMLC does not answer with
8138 * BSSMAP-LE Perform Location Response, without sending a BSSLAP TA Request. */
8139private function f_tc_lcs_loc_req_for_active_ms_le_timeout(charstring id) runs on MSC_ConnHdlr {
8140 f_lcs_loc_req_for_active_ms_le_timeout(false);
8141}
8142
8143testcase TC_lcs_loc_req_for_active_ms_le_timeout() runs on test_CT {
8144 var MSC_ConnHdlr vc_conn;
8145 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8146
8147 f_init(1, true);
8148 f_sleep(1.0);
8149 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_active_ms_le_timeout), pars);
8150 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008151 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008152}
8153
8154/* With an active lchan, start a Perform Location Request on the A-interface, but virtual SMLC does not answer with
8155 * BSSMAP-LE Perform Location Response, after sending a BSSLAP TA Request. */
8156private function f_tc_lcs_loc_req_for_active_ms_le_timeout2(charstring id) runs on MSC_ConnHdlr {
8157 f_lcs_loc_req_for_active_ms_le_timeout(true);
8158}
8159
8160testcase TC_lcs_loc_req_for_active_ms_le_timeout2() runs on test_CT {
8161 var MSC_ConnHdlr vc_conn;
8162 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8163
8164 f_init(1, true);
8165 f_sleep(1.0);
8166 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_active_ms_le_timeout2), pars);
8167 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008168 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008169}
8170
8171/* With *no* active lchan, start a Perform Location Request, expecting that the MS will be Paged. */
8172private function f_tc_lcs_loc_req_for_idle_ms_no_pag_resp(charstring id) runs on MSC_ConnHdlr {
8173 f_sleep(1.0);
8174
8175 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
8176 f_bssap_le_register_imsi(g_pars.imsi, omit);
8177
8178 /* Register to receive the Paging Command */
8179 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
8180 g_chan_nr := new_chan_nr;
8181 f_rslem_register(0, g_chan_nr);
8182
8183 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
8184 valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
8185 ts_CellId_CGI('001'H, '01'H, 1, 0)))));
8186 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
8187
8188 var PDU_BSSAP_LE plr;
8189 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
8190
8191 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
8192 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
8193
8194 /* OsmoBSC needs to Page */
8195 var PDU_BSSAP_LE rx_bsslap;
8196 alt {
8197 [] RSL.receive(tr_RSL_PAGING_CMD(tr_MI_IMSI(g_pars.imsi))) {
8198 f_logp(BSCVTY, "got Paging Command");
8199 repeat;
8200 }
8201 [] BSSAP_LE.receive(tr_BSSMAP_LE_ConnInfo(BSSMAP_LE_PROT_BSSLAP, ?)) -> value(rx_bsslap) {
8202 /* MS does not respond to Paging, TA Req runs into timeout. */
8203 f_match_bsslap(rx_bsslap, tr_BSSLAP_Abort(?));
8204 }
8205 }
8206
8207 /* SMLC responds with failure */
8208 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(omit, BSSMAP_LE_LCS_CAUSE_REQUEST_ABORTED));
8209 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
8210
8211 /* BSC tells MSC about failure */
8212 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(
8213 locationEstimate := omit, positioningData := omit,
8214 lCS_Cause := tr_BSSMAP_LcsCause(BSSMAP_LCS_CAUSE_REQUEST_ABORTED)));
8215
8216 /* There is no lchan. Still the MSC's job to decide whether to tear down the conn or not. */
8217 f_verify_active_A_conn_and_clear();
8218
8219 f_sleep(2.0);
8220 setverdict(pass);
8221}
8222testcase TC_lcs_loc_req_for_idle_ms_no_pag_resp() runs on test_CT {
8223 var MSC_ConnHdlr vc_conn;
8224 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8225
8226 f_init(1, true);
8227 f_sleep(1.0);
8228
8229 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
8230 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
8231
8232 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_idle_ms_no_pag_resp), pars);
8233 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008234 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008235}
8236
8237/* During an ongoing Location Request, the MS sends a CM Service Request. Expect the same A-conn to be re-used / taken
8238 * over. */
8239private function f_tc_cm_service_during_lcs_loc_req(charstring id) runs on MSC_ConnHdlr {
8240 f_sleep(1.0);
8241
8242 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
8243 f_bssap_le_register_imsi(g_pars.imsi, omit);
8244
8245 /* Register to receive the Paging Command */
8246 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
8247 g_chan_nr := new_chan_nr;
8248 f_rslem_register(0, g_chan_nr);
8249
8250 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
8251 valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
8252 ts_CellId_CGI('001'H, '01'H, 1, 0)))));
8253 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
8254
8255 var PDU_BSSAP_LE plr;
8256 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
8257
8258 /* As the A-interface conn was established for LCS, the MS coincidentally decides to issue a CM Service Request
8259 * and establish Layer 3. It should use the existing A-interface conn. */
8260 f_perform_compl_l3(RSL, valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV(g_pars.imsi)))),
8261 do_clear := false, expect_bssmap_l3 := true);
8262
8263 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
8264 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
8265
8266 /* OsmoBSC already has an lchan, no need to Page, just returns the TA */
8267 f_expect_bsslap(tr_BSSLAP_TA_Resp(?, ?));
8268
8269 /* SMLC got the TA from the BSC, now responds with geo information data. */
8270 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(gad_ell_point_unc_circle, omit));
8271 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
8272 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(tr_BSSMAP_IE_LocationEstimate(gad_ell_point_unc_circle)));
8273
8274 /* The lchan should still exist, it was from a CM Service Request. */
8275 f_mo_l3_transceive();
8276
8277 f_perform_clear(RSL);
8278
8279 f_sleep(2.0);
8280 setverdict(pass);
8281}
8282testcase TC_cm_service_during_lcs_loc_req() runs on test_CT {
8283 var MSC_ConnHdlr vc_conn;
8284 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8285
8286 f_init(1, true);
8287 f_sleep(1.0);
8288
8289 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
8290 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
8291
8292 vc_conn := f_start_handler(refers(f_tc_cm_service_during_lcs_loc_req), pars);
8293 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008294 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008295}
8296
8297/* During an ongoing Perform Location Request, do a Handover, an expect a BSSLAP Reset message from the BSC to indicate
8298 * the new lchan after handover. */
8299private function f_tc_ho_during_lcs_loc_req(charstring id) runs on MSC_ConnHdlr {
8300 f_sleep(1.0);
8301
8302 f_establish_fully(omit, omit);
8303 f_bssap_le_register_imsi(g_pars.imsi, omit);
8304
8305 BSSAP.send(valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
8306 ts_CellId_CGI('262'H, '42'H, 23, 42))));
8307
8308 var PDU_BSSAP_LE plr;
8309 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
8310
8311 /* SMLC ponders the Location Request, in the meantime the BSC decides to handover */
8312 f_bts_0_cfg(BSCVTY, {"neighbor bts 1"});
8313
8314 var HandoverState hs := {
8315 rr_ho_cmpl_seen := false,
8316 handover_done := false,
8317 old_chan_nr := -
8318 };
8319 /* issue hand-over command on VTY */
8320 f_vty_handover(BSCVTY, 0, 0, g_chan_nr, 1);
8321 /* temporarily suspend DChan processing on BTS1 to avoid race with RSLEM_register */
8322 f_rslem_suspend(RSL1_PROC);
8323
8324 /* From the MGW perspective, a handover is is characterized by
8325 * performing one MDCX operation with the MGW. So we expect to see
8326 * one more MDCX during handover. */
8327 g_media.mgcp_conn[0].mdcx_seen_exp := g_media.mgcp_conn[0].crcx_seen_exp + 1;
8328
8329 alt {
8330 [] as_handover(hs);
8331 }
8332
8333 var PDU_BSSAP_LE rx_bsslap;
8334
8335 interleave {
8336 /* Expect the BSC to inform the MSC about the handover */
8337 [] BSSAP.receive(tr_BSSMAP_HandoverPerformed);
8338
8339 /* Expect the BSC to inform the SMLC about the handover */
8340 [] BSSAP_LE.receive(tr_BSSMAP_LE_ConnInfo(BSSMAP_LE_PROT_BSSLAP, ?)) -> value(rx_bsslap) {
8341 f_match_bsslap(rx_bsslap, tr_BSSLAP_Reset(BSSLAP_CAUSE_INTRA_BSS_HO));
8342 }
8343 }
8344
8345 /* SMLC now responds with geo information data. */
8346 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(gad_ell_point_unc_circle, omit));
8347 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
8348 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(tr_BSSMAP_IE_LocationEstimate(gad_ell_point_unc_circle)));
8349
8350 /* lchan still active */
8351 f_mo_l3_transceive(RSL1);
8352
8353 /* MSC decides it is done now. */
8354 f_perform_clear(RSL1);
8355
8356 f_sleep(2.0);
8357 setverdict(pass);
8358}
8359testcase TC_ho_during_lcs_loc_req() runs on test_CT {
8360 var MSC_ConnHdlr vc_conn;
8361 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8362
8363 f_init(2, true);
8364 f_sleep(1.0);
8365 vc_conn := f_start_handler(refers(f_tc_ho_during_lcs_loc_req), pars);
8366 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008367 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008368}
8369
Neels Hofmeyrbf037052020-10-28 22:52:02 +00008370/* Attempt Complete Layer 3 without any MSC available (OS#4832) */
8371private function f_tc_no_msc(charstring id) runs on MSC_ConnHdlr {
8372 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
8373
8374 /* Also disable attach for the single connected MSC */
8375 f_vty_msc_allow_attach(BSCVTY, { false });
8376
8377 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) ));
8378 f_chan_est(g_pars.ra, l3_enc, g_pars.link_id, g_pars.fn);
8379
8380 /* No MSC is found, expecting a proper release on RSL */
8381 interleave {
8382 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
8383 f_logp(BSCVTY, "Got RSL RR Release");
8384 }
8385 [] RSL.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
8386 f_logp(BSCVTY, "Got RSL Deact SACCH");
8387 }
8388 [] RSL.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
8389 f_logp(BSCVTY, "Got RSL RF Chan Rel, sending Rel Ack");
8390 RSL.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
8391 }
8392 }
8393 setverdict(pass);
8394}
8395testcase TC_no_msc() runs on test_CT {
8396
8397 f_init(1, true);
8398 f_sleep(1.0);
8399 var MSC_ConnHdlr vc_conn;
8400 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8401
8402 f_ctrs_bsc_init(counternames_bsc_mscpool);
8403
8404 vc_conn := f_start_handler(refers(f_tc_no_msc), pars);
8405 vc_conn.done;
8406
8407 f_ctrs_bsc_add("mscpool:subscr:no_msc");
8408 f_ctrs_bsc_verify();
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008409 f_shutdown_helper();
Neels Hofmeyrbf037052020-10-28 22:52:02 +00008410}
8411
Harald Welte0ea2d5e2018-04-07 21:40:29 +02008412/* Dyn PDCH todo:
8413 * activate OSMO as TCH/F
8414 * activate OSMO as TCH/H
8415 * does the BSC-located PCU socket get the updated INFO?
8416 * what if no PCU is connected at the time?
8417 * is the info correct on delayed PCU (re)connect?
8418 */
Harald Welte94e0c342018-04-07 11:33:23 +02008419
Harald Welte28d943e2017-11-25 15:00:50 +01008420control {
Harald Welte898113b2018-01-31 18:32:21 +01008421 /* CTRL interface testing */
Harald Welte4003d112017-12-09 22:35:39 +01008422 execute( TC_ctrl_msc_connection_status() );
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01008423 execute( TC_ctrl_msc0_connection_status() );
Harald Welte96c94412017-12-09 03:12:45 +01008424 execute( TC_ctrl() );
Neels Hofmeyrf246a922020-05-13 02:27:10 +02008425 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_SCCPlite_SERVER) {
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +02008426 execute( TC_ctrl_location() );
8427 }
Harald Welte898113b2018-01-31 18:32:21 +01008428
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02008429 execute( TC_si_default() );
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02008430 execute( TC_si2quater_2_earfcns() );
8431 execute( TC_si2quater_3_earfcns() );
8432 execute( TC_si2quater_4_earfcns() );
8433 execute( TC_si2quater_5_earfcns() );
8434 execute( TC_si2quater_6_earfcns() );
Neels Hofmeyrad132f22020-07-08 02:20:16 +02008435 execute( TC_si2quater_12_earfcns() );
8436 execute( TC_si2quater_23_earfcns() );
8437 execute( TC_si2quater_32_earfcns() );
8438 execute( TC_si2quater_33_earfcns() );
8439 execute( TC_si2quater_42_earfcns() );
8440 execute( TC_si2quater_48_earfcns() );
8441 execute( TC_si2quater_49_earfcns() );
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02008442 execute( TC_si_acc_rotate() );
Alexander Couzens4ad3a352020-09-10 22:29:12 +02008443 execute( TC_si_acc_ramp_rotate() );
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02008444
Harald Welte898113b2018-01-31 18:32:21 +01008445 /* RSL DCHAN Channel ACtivation / Deactivation */
Harald Welteae026692017-12-09 01:03:01 +01008446 execute( TC_chan_act_noreply() );
Harald Welte4003d112017-12-09 22:35:39 +01008447 execute( TC_chan_act_counter() );
Harald Welteae026692017-12-09 01:03:01 +01008448 execute( TC_chan_act_ack_noest() );
Philipp Maier9c60a622020-07-09 15:08:46 +02008449 execute( TC_chan_act_ack_noest_emerg() );
Philipp Maier606f07d2020-08-12 17:21:58 +02008450 execute( TC_chan_rqd_emerg_deny() );
Harald Welteae026692017-12-09 01:03:01 +01008451 execute( TC_chan_act_ack_est_ind_noreply() );
8452 execute( TC_chan_act_ack_est_ind_refused() );
Harald Welte618ef642017-12-14 14:58:20 +01008453 execute( TC_chan_act_nack() );
Harald Welte799c97b2017-12-14 17:50:30 +01008454 execute( TC_chan_exhaustion() );
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07008455 execute( TC_chan_deact_silence() );
Harald Welte4003d112017-12-09 22:35:39 +01008456 execute( TC_chan_rel_rll_rel_ind() );
8457 execute( TC_chan_rel_conn_fail() );
8458 execute( TC_chan_rel_hard_clear() );
Harald Welte99787102019-02-04 10:41:36 +01008459 execute( TC_chan_rel_hard_clear_csfb() );
Harald Welted8c36cd2017-12-09 23:05:31 +01008460 execute( TC_chan_rel_hard_rlsd() );
Harald Welte550daf92018-06-11 19:22:13 +02008461 execute( TC_chan_rel_hard_rlsd_ms_dead() );
Harald Welte85804d42017-12-10 14:11:58 +01008462 execute( TC_chan_rel_a_reset() );
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01008463 execute( TC_chan_rel_sccp_tiar_timeout() );
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02008464 execute( TC_chan_rel_rr_cause() );
Harald Welte6f521d82017-12-11 19:52:02 +01008465
Harald Weltecfe2c962017-12-15 12:09:32 +01008466 execute( TC_outbound_connect() );
Harald Welte898113b2018-01-31 18:32:21 +01008467
8468 /* Assignment related */
Harald Welte16a4adf2017-12-14 18:54:01 +01008469 execute( TC_assignment_cic_only() );
Harald Welte235ebf12017-12-15 14:18:16 +01008470 execute( TC_assignment_csd() );
8471 execute( TC_assignment_ctm() );
8472 execute( TC_assignment_sign() );
Pau Espin Pedrol07866632020-09-03 19:10:55 +02008473 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
8474 execute( TC_assignment_aoip_tla_v6() );
8475 }
Harald Welte235ebf12017-12-15 14:18:16 +01008476 execute( TC_assignment_fr_a5_0() );
8477 execute( TC_assignment_fr_a5_1() );
Neels Hofmeyrf246a922020-05-13 02:27:10 +02008478 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welte8f67d1d2018-05-25 20:38:42 +02008479 execute( TC_assignment_fr_a5_1_codec_missing() );
8480 }
Harald Welte235ebf12017-12-15 14:18:16 +01008481 execute( TC_assignment_fr_a5_3() );
8482 execute( TC_assignment_fr_a5_4() );
Harald Welte3c86ea02018-05-10 22:28:05 +02008483 execute( TC_ciph_mode_a5_0() );
8484 execute( TC_ciph_mode_a5_1() );
8485 execute( TC_ciph_mode_a5_3() );
Harald Welte16a4adf2017-12-14 18:54:01 +01008486
Harald Welte60aa5762018-03-21 19:33:13 +01008487 execute( TC_assignment_codec_fr() );
8488 execute( TC_assignment_codec_hr() );
8489 execute( TC_assignment_codec_efr() );
8490 execute( TC_assignment_codec_amr_f() );
8491 execute( TC_assignment_codec_amr_h() );
Philipp Maier8a581d22019-03-26 18:32:48 +01008492
Neels Hofmeyrf246a922020-05-13 02:27:10 +02008493 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Philipp Maier8a581d22019-03-26 18:32:48 +01008494 execute( TC_assignment_codec_amr_f_S1() );
8495 execute( TC_assignment_codec_amr_h_S1() );
8496 execute( TC_assignment_codec_amr_f_S124() );
8497 execute( TC_assignment_codec_amr_h_S124() );
8498 execute( TC_assignment_codec_amr_f_S0() );
8499 execute( TC_assignment_codec_amr_f_S02() );
8500 execute( TC_assignment_codec_amr_f_S024() );
8501 execute( TC_assignment_codec_amr_f_S0247() );
8502 execute( TC_assignment_codec_amr_h_S0() );
8503 execute( TC_assignment_codec_amr_h_S02() );
8504 execute( TC_assignment_codec_amr_h_S024() );
8505 execute( TC_assignment_codec_amr_h_S0247() );
8506 execute( TC_assignment_codec_amr_f_S01234567() );
8507 execute( TC_assignment_codec_amr_f_S0234567() );
8508 execute( TC_assignment_codec_amr_f_zero() );
8509 execute( TC_assignment_codec_amr_f_unsupp() );
8510 execute( TC_assignment_codec_amr_h_S7() );
Neels Hofmeyr21863562020-11-26 00:34:33 +00008511 execute( TC_assignment_codec_amr_f_start_mode_auto() );
8512 execute( TC_assignment_codec_amr_h_start_mode_auto() );
Neels Hofmeyr3eb94562020-11-26 02:40:26 +00008513 execute( TC_assignment_codec_amr_f_start_mode_4() );
8514 execute( TC_assignment_codec_amr_h_start_mode_4() );
Neels Hofmeyr454d7922020-11-26 02:24:57 +00008515 execute( TC_assignment_codec_amr_startmode_cruft() );
Philipp Maier8a581d22019-03-26 18:32:48 +01008516 }
Harald Welte60aa5762018-03-21 19:33:13 +01008517
Philipp Maierac09bfc2019-01-08 13:41:39 +01008518 execute( TC_assignment_codec_fr_exhausted_req_hr() );
8519 execute( TC_assignment_codec_fr_exhausted_req_fr() );
8520 execute( TC_assignment_codec_fr_exhausted_req_fr_hr() );
8521 execute( TC_assignment_codec_fr_exhausted_req_hr_fr() );
8522 execute( TC_assignment_codec_hr_exhausted_req_fr() );
8523 execute( TC_assignment_codec_hr_exhausted_req_hr() );
8524 execute( TC_assignment_codec_hr_exhausted_req_hr_fr() );
8525 execute( TC_assignment_codec_hr_exhausted_req_fr_hr() );
8526 execute( TC_assignment_codec_req_hr_fr() );
8527 execute( TC_assignment_codec_req_fr_hr() );
8528
Pau Espin Pedrol58cf6822019-05-28 18:11:33 +02008529 if (mp_enable_osmux_test) {
8530 execute( TC_assignment_osmux() );
8531 }
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02008532
Harald Welte898113b2018-01-31 18:32:21 +01008533 /* RLL Establish Indication on inactive DCHAN / SAPI */
Harald Welte5cd20ed2017-12-13 21:03:20 +01008534 execute( TC_rll_est_ind_inact_lchan() );
8535 execute( TC_rll_est_ind_inval_sapi1() );
8536 execute( TC_rll_est_ind_inval_sapi3() );
8537 execute( TC_rll_est_ind_inval_sacch() );
8538
Vadim Yanitskiy61f784a2020-10-01 21:12:19 +07008539 /* DLCI / RSL Link ID conversion for MO/MT messages on SAPI0/SAPI3 */
8540 execute( TC_tch_dlci_link_id_sapi() );
8541
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07008542 /* SAPI N Reject triggered by RLL establishment failures */
8543 execute( TC_rll_rel_ind_sapi_n_reject() );
8544 execute( TC_rll_err_ind_sapi_n_reject() );
8545 execute( TC_rll_timeout_sapi_n_reject() );
8546
Harald Welte898113b2018-01-31 18:32:21 +01008547 /* Paging related tests */
Harald Welte6f521d82017-12-11 19:52:02 +01008548 execute( TC_paging_imsi_nochan() );
8549 execute( TC_paging_tmsi_nochan() );
8550 execute( TC_paging_tmsi_any() );
8551 execute( TC_paging_tmsi_sdcch() );
8552 execute( TC_paging_tmsi_tch_f() );
8553 execute( TC_paging_tmsi_tch_hf() );
8554 execute( TC_paging_imsi_nochan_cgi() );
8555 execute( TC_paging_imsi_nochan_lac_ci() );
8556 execute( TC_paging_imsi_nochan_ci() );
8557 execute( TC_paging_imsi_nochan_lai() );
8558 execute( TC_paging_imsi_nochan_lac() );
8559 execute( TC_paging_imsi_nochan_all() );
Harald Welte751d3eb2018-01-31 15:51:06 +01008560 execute( TC_paging_imsi_nochan_plmn_lac_rnc() );
8561 execute( TC_paging_imsi_nochan_rnc() );
8562 execute( TC_paging_imsi_nochan_lac_rnc() );
8563 execute( TC_paging_imsi_nochan_lacs() );
8564 execute( TC_paging_imsi_nochan_lacs_empty() );
Stefan Sperling049a86e2018-03-20 15:51:00 +01008565 execute( TC_paging_imsi_nochan_cgi_unknown_cid() );
Harald Welte10985002017-12-12 09:29:15 +01008566 execute( TC_paging_imsi_a_reset() );
Harald Weltee65d40e2017-12-13 00:09:06 +01008567 execute( TC_paging_imsi_load() );
Philipp Maier779a7922018-02-16 11:00:37 +01008568 execute( TC_paging_counter() );
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01008569 execute( TC_paging_resp_unsol() );
Harald Welte4e9b9cc2017-12-14 18:31:02 +01008570
8571 execute( TC_rsl_drop_counter() );
Stefan Sperling830dc9d2018-02-12 21:08:28 +01008572 execute( TC_rsl_unknown_unit_id() );
8573
8574 execute( TC_oml_unknown_unit_id() );
Harald Welte898113b2018-01-31 18:32:21 +01008575
8576 execute( TC_classmark() );
Harald Welteeddf0e92020-06-21 19:42:15 +02008577 execute( TC_common_id() );
Harald Welte898113b2018-01-31 18:32:21 +01008578 execute( TC_unsol_ass_fail() );
Harald Welteea99a002018-01-31 20:46:43 +01008579 execute( TC_unsol_ass_compl() );
Harald Weltefbf9b5e2018-01-31 20:41:23 +01008580 execute( TC_unsol_ho_fail() );
Harald Weltee3bd6582018-01-31 22:51:25 +01008581 execute( TC_err_82_short_msg() );
Harald Weltee9e02e42018-01-31 23:36:25 +01008582 execute( TC_err_84_unknown_msg() );
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01008583
Harald Welte261af4b2018-02-12 21:20:39 +01008584 execute( TC_ho_int() );
Neels Hofmeyr5f144212020-11-03 15:41:58 +00008585 execute( TC_ho_int_radio_link_failure() );
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01008586
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01008587 execute( TC_ho_out_of_this_bsc() );
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02008588 execute( TC_ho_out_fail_no_msc_response() );
8589 execute( TC_ho_out_fail_rr_ho_failure() );
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02008590 execute( TC_ho_out_fail_no_result_after_ho_cmd() );
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01008591
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01008592 execute( TC_ho_into_this_bsc() );
Pau Espin Pedrol07866632020-09-03 19:10:55 +02008593 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
8594 execute( TC_ho_into_this_bsc_tla_v6() );
8595 }
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01008596 execute( TC_ho_in_fail_msc_clears() );
8597 execute( TC_ho_in_fail_msc_clears_after_ho_detect() );
8598 execute( TC_ho_in_fail_no_detect() );
8599 execute( TC_ho_in_fail_no_detect2() );
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01008600
Neels Hofmeyr91401012019-07-11 00:42:35 +02008601 execute( TC_ho_neighbor_config_1() );
8602 execute( TC_ho_neighbor_config_2() );
8603 execute( TC_ho_neighbor_config_3() );
8604 execute( TC_ho_neighbor_config_4() );
8605 execute( TC_ho_neighbor_config_5() );
8606 execute( TC_ho_neighbor_config_6() );
8607 execute( TC_ho_neighbor_config_7() );
8608
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01008609 execute( TC_bssap_rlsd_does_not_cause_bssmap_reset() );
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01008610 execute( TC_bssmap_clear_does_not_cause_bssmap_reset() );
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01008611 execute( TC_ms_rel_ind_does_not_cause_bssmap_reset() );
Harald Welte94e0c342018-04-07 11:33:23 +02008612
8613 execute( TC_dyn_pdch_ipa_act_deact() );
8614 execute( TC_dyn_pdch_ipa_act_nack() );
8615 execute( TC_dyn_pdch_osmo_act_deact() );
8616 execute( TC_dyn_pdch_osmo_act_nack() );
Harald Welte99f3ca02018-06-14 13:40:29 +02008617
Stefan Sperling0796a822018-10-05 13:01:39 +02008618 execute( TC_chopped_ipa_ping() );
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02008619 execute( TC_chopped_ipa_payload() );
Stefan Sperling0796a822018-10-05 13:01:39 +02008620
Pau Espin Pedrol8f773632019-11-05 11:46:53 +01008621 /* Power control related */
8622 execute( TC_assignment_verify_ms_power_params_ie() );
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008623
8624 /* MSC pooling */
8625 /* FIXME: in SCCPlite, indicating how many MSCs should be connected does currently not work. Since
8626 * RESET->RESET-ACK is unconditionally negotiated for all configured MSCs, they always all appear as connected
8627 * to osmo-bsc. The MSC pooling tests however require disconnecting selected MSCs, and hence don't work out as
8628 * intended on SCCPlite. So for now, run these only for SCCP/M3UA. */
8629 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
8630 execute( TC_mscpool_L3Compl_on_1_msc() );
8631 execute( TC_mscpool_L3Complete_by_imsi_round_robin() );
8632 execute( TC_mscpool_LU_by_tmsi_null_nri_0_round_robin() );
8633 execute( TC_mscpool_LU_by_tmsi_null_nri_1_round_robin() );
8634 execute( TC_mscpool_L3Complete_by_tmsi_unassigned_nri_round_robin() );
8635 execute( TC_mscpool_L3Complete_by_tmsi_valid_nri_msc_not_connected_round_robin() );
8636 execute( TC_mscpool_L3Complete_by_tmsi_valid_nri_1() );
8637 execute( TC_mscpool_L3Complete_by_tmsi_valid_nri_2() );
8638 execute( TC_mscpool_LU_by_tmsi_from_other_PLMN() );
8639 execute( TC_mscpool_paging_and_response_imsi() );
8640 execute( TC_mscpool_paging_and_response_tmsi() );
8641 execute( TC_mscpool_no_allow_attach_round_robin() );
8642 execute( TC_mscpool_no_allow_attach_valid_nri() );
8643 }
8644
Harald Welte99f3ca02018-06-14 13:40:29 +02008645 /* at bottom as they might crash OsmoBSC before OS#3182 is fixed */
8646 execute( TC_early_conn_fail() );
8647 execute( TC_late_conn_fail() );
8648
Philipp Maier783681c2020-07-16 16:47:06 +02008649 /* Emergency call handling (deny / allow) */
8650 execute( TC_assignment_emerg_setup_allow() );
8651 execute( TC_assignment_emerg_setup_deny_msc() );
8652 execute( TC_assignment_emerg_setup_deny_bts() );
Philipp Maier82812002020-08-13 18:48:27 +02008653 execute( TC_emerg_premption() );
8654
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008655 /* Frequency hopping parameters handling */
8656 execute( TC_fh_params_chan_activ() );
8657 execute( TC_fh_params_imm_ass() );
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07008658 execute( TC_fh_params_assignment_cmd() );
Vadim Yanitskiy8f5430d2020-09-02 18:51:38 +07008659 execute( TC_fh_params_handover_cmd() );
Vadim Yanitskiyca974032020-09-01 07:20:39 +07008660 execute( TC_fh_params_si4_cbch() );
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008661
8662 if (mp_enable_lcs_tests) {
8663 execute( TC_lcs_loc_req_for_active_ms() );
8664 execute( TC_lcs_loc_req_for_active_ms_ta_req() );
8665 execute( TC_lcs_loc_req_for_idle_ms() );
8666 execute( TC_lcs_loc_req_no_subscriber() );
8667 execute( TC_lcs_loc_req_for_active_ms_le_timeout() );
8668 execute( TC_lcs_loc_req_for_active_ms_le_timeout2() );
8669 execute( TC_lcs_loc_req_for_idle_ms_no_pag_resp() );
8670 execute( TC_cm_service_during_lcs_loc_req() );
8671 execute( TC_ho_during_lcs_loc_req() );
8672 }
Neels Hofmeyrbf037052020-10-28 22:52:02 +00008673
8674 execute( TC_no_msc() );
Harald Welte28d943e2017-11-25 15:00:50 +01008675}
8676
8677}