blob: 1f8f95179a3fa157abd62fe3d3c5428c57ab37b7 [file] [log] [blame]
Harald Welte28d943e2017-11-25 15:00:50 +01001module BSC_Tests {
2
Harald Welte21b46bd2017-12-17 19:46:32 +01003/* Integration Tests for OsmoBSC
Harald Weltea0630032018-03-20 21:09:55 +01004 * (C) 2017-2018 by Harald Welte <laforge@gnumonks.org>
Harald Welte21b46bd2017-12-17 19:46:32 +01005 * All rights reserved.
6 *
7 * Released under the terms of GNU General Public License, Version 2 or
8 * (at your option) any later version.
9 *
Harald Welte34b5a952019-05-27 11:54:11 +020010 * SPDX-License-Identifier: GPL-2.0-or-later
11 *
Harald Welte21b46bd2017-12-17 19:46:32 +010012 * This test suite tests OsmoBSC while emulating both multiple BTS + MS as
13 * well as the MSC. See README for more details.
14 *
15 * There are test cases that run in so-called 'handler mode' and test cases
16 * that run directly on top of the BSSAP and RSL CodecPorts. The "handler mode"
17 * tests abstract the multiplexing/demultiplexing of multiple SCCP connections
18 * and/or RSL channels and are hence suitable for higher-level test cases, while
19 * the "raw" tests directly on top of the CodecPorts are more suitable for lower-
20 * level testing.
21 */
22
Neels Hofmeyr4f118412020-06-04 15:25:10 +020023import from Misc_Helpers all;
Harald Welte4003d112017-12-09 22:35:39 +010024import from General_Types all;
Harald Welte28d943e2017-11-25 15:00:50 +010025import from Osmocom_Types all;
Harald Welteae026692017-12-09 01:03:01 +010026import from GSM_Types all;
Harald Welte28d943e2017-11-25 15:00:50 +010027import from IPL4asp_Types all;
28
Harald Welte6f521d82017-12-11 19:52:02 +010029import from BSSAP_Types all;
Harald Welte6811d102019-04-14 22:23:14 +020030import from RAN_Adapter all;
Harald Welte47cd0e32020-08-21 12:39:11 +020031import from BSSAP_LE_Adapter all;
32import from BSSAP_LE_CodecPort all;
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +020033import from BSSAP_LE_Types all;
34import from BSSLAP_Types all;
Harald Welteae026692017-12-09 01:03:01 +010035import from BSSAP_CodecPort all;
36import from BSSMAP_Templates all;
Harald Welte28d943e2017-11-25 15:00:50 +010037import from IPA_Emulation all;
Stefan Sperling830dc9d2018-02-12 21:08:28 +010038import from IPA_CodecPort all;
Harald Welteae026692017-12-09 01:03:01 +010039import from IPA_Types all;
Stefan Sperling0796a822018-10-05 13:01:39 +020040import from IPA_Testing all;
Harald Welteae026692017-12-09 01:03:01 +010041import from RSL_Types all;
Harald Welte624f9632017-12-16 19:26:04 +010042import from RSL_Emulation all;
Daniel Willmann191e0d92018-01-17 12:44:35 +010043import from MGCP_Emulation all;
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +010044import from MGCP_Templates all;
45import from MGCP_Types all;
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +020046import from MGCP_CodecPort all;
Harald Welte28d943e2017-11-25 15:00:50 +010047
Harald Welte96c94412017-12-09 03:12:45 +010048import from Osmocom_CTRL_Functions all;
Harald Weltea5d2ab22017-12-09 14:21:42 +010049import from Osmocom_CTRL_Types all;
Harald Welteffe55fc2018-01-17 22:39:54 +010050import from Osmocom_CTRL_Adapter all;
Harald Welte96c94412017-12-09 03:12:45 +010051
Daniel Willmannebdecc02020-08-12 15:30:17 +020052import from StatsD_Types all;
53import from StatsD_CodecPort all;
54import from StatsD_CodecPort_CtrlFunct all;
55import from StatsD_Checker all;
56
Harald Weltebc03c762018-02-12 18:09:38 +010057import from Osmocom_VTY_Functions all;
58import from TELNETasp_PortType all;
59
Harald Welte6f521d82017-12-11 19:52:02 +010060import from MobileL3_CommonIE_Types all;
Harald Weltee3bd6582018-01-31 22:51:25 +010061import from MobileL3_Types all;
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +010062import from MobileL3_RRM_Types all;
Harald Welte6f521d82017-12-11 19:52:02 +010063import from L3_Templates all;
64import from GSM_RR_Types all;
65
Stefan Sperlingc307e682018-06-14 15:15:46 +020066import from SCCP_Templates all;
Neels Hofmeyr4ff93282018-03-12 04:25:35 +010067import from BSSMAP_Templates all;
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +020068import from BSSMAP_LE_Templates all;
Neels Hofmeyr4ff93282018-03-12 04:25:35 +010069
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +010070import from SCCPasp_Types all;
71
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +020072import from GSM_SystemInformation all;
73import from GSM_RestOctets all;
Neels Hofmeyrad132f22020-07-08 02:20:16 +020074import from TCCConversion_Functions all;
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +020075
Harald Welte5d1a2202017-12-13 19:51:29 +010076const integer NUM_BTS := 3;
Neels Hofmeyrf246a922020-05-13 02:27:10 +020077const integer NUM_MSC := 3;
Harald Welteae026692017-12-09 01:03:01 +010078const float T3101_MAX := 12.0;
Harald Welte28d943e2017-11-25 15:00:50 +010079
Harald Welte799c97b2017-12-14 17:50:30 +010080/* make sure to sync this with the osmo-bts.cfg you're using */
Philipp Maiercb6cc482018-03-26 13:08:00 +020081const integer NUM_TCHH_PER_BTS := 2;
82const integer NUM_TCHF_PER_BTS := 4;
Neels Hofmeyr74083c22020-07-29 00:43:01 +020083const integer NUM_SDCCH_PER_BTS := 3;
Harald Welte799c97b2017-12-14 17:50:30 +010084
Harald Welte4003d112017-12-09 22:35:39 +010085
Harald Welte21b46bd2017-12-17 19:46:32 +010086/* per-BTS state which we keep */
Harald Welte96c94412017-12-09 03:12:45 +010087type record BTS_State {
Harald Welte21b46bd2017-12-17 19:46:32 +010088 /* component reference to the IPA_Client component used for RSL */
Harald Weltea5d2ab22017-12-09 14:21:42 +010089 IPA_Client rsl
Harald Welte96c94412017-12-09 03:12:45 +010090}
91
Neels Hofmeyr22c3f792020-06-17 02:49:28 +020092/* Default list of counters for an 'msc' entity. */
93const CounterNameVals counternames_msc_mscpool := {
94 { "mscpool:subscr:new", 0 },
95 { "mscpool:subscr:known", 0 },
96 { "mscpool:subscr:reattach", 0 },
97 { "mscpool:subscr:attach_lost", 0 },
98 { "mscpool:subscr:paged", 0 }
99};
100
Neels Hofmeyrbf037052020-10-28 22:52:02 +0000101/* List of global mscpool counters, not related to a specific 'msc' entity. */
102const CounterNameVals counternames_bsc_mscpool := {
103 { "mscpool:subscr:no_msc", 0 }
104};
105
Neels Hofmeyr12941bd2020-08-29 03:21:26 +0000106/* Default list of counters for 'bsc' and 'bts' entities. */
107const CounterNameVals counternames_bsc_bts_handover := {
108 { "assignment:attempted", 0 },
109 { "assignment:completed", 0 },
110 { "assignment:stopped", 0 },
111 { "assignment:no_channel", 0 },
112 { "assignment:timeout", 0 },
113 { "assignment:failed", 0 },
114 { "assignment:error", 0 },
115
116 { "handover:attempted", 0 },
117 { "handover:completed", 0 },
118 { "handover:stopped", 0 },
119 { "handover:no_channel", 0 },
120 { "handover:timeout", 0 },
121 { "handover:failed", 0 },
122 { "handover:error", 0 },
123
124 { "intra_cell_ho:attempted", 0 },
125 { "intra_cell_ho:completed", 0 },
126 { "intra_cell_ho:stopped", 0 },
127 { "intra_cell_ho:no_channel", 0 },
128 { "intra_cell_ho:timeout", 0 },
129 { "intra_cell_ho:failed", 0 },
130 { "intra_cell_ho:error", 0 },
131
132 { "intra_bsc_ho:attempted", 0 },
133 { "intra_bsc_ho:completed", 0 },
134 { "intra_bsc_ho:stopped", 0 },
135 { "intra_bsc_ho:no_channel", 0 },
136 { "intra_bsc_ho:timeout", 0 },
137 { "intra_bsc_ho:failed", 0 },
138 { "intra_bsc_ho:error", 0 },
139
140 { "interbsc_ho_out:attempted", 0 },
141 { "interbsc_ho_out:completed", 0 },
142 { "interbsc_ho_out:stopped", 0 },
143 { "interbsc_ho_out:timeout", 0 },
144 { "interbsc_ho_out:failed", 0 },
145 { "interbsc_ho_out:error", 0 },
146
147 { "interbsc_ho_in:attempted", 0 },
148 { "interbsc_ho_in:completed", 0 },
149 { "interbsc_ho_in:stopped", 0 },
150 { "interbsc_ho_in:no_channel", 0 },
151 { "interbsc_ho_in:timeout", 0 },
152 { "interbsc_ho_in:failed", 0 },
153 { "interbsc_ho_in:error", 0 }
154};
155
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200156/* Set of all System Information received during one RSL port's startup.
157 * Note that some System Information may be sent on RSL, but lacking actual SI data, to indicate that the BTS should not
158 * broadcast that SI type. That will be reflected as 'omit' here.
159 */
160type record SystemInformationConfig {
161 SystemInformationType1 si1 optional,
162 SystemInformationType2 si2 optional,
163 SystemInformationType2bis si2bis optional,
164 SystemInformationType2ter si2ter optional,
Neels Hofmeyrad132f22020-07-08 02:20:16 +0200165 SI2quaterRestOctetsList si2quater optional,
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200166 SystemInformationType3 si3 optional,
167 SystemInformationType4 si4 optional,
Pau Espin Pedrol28652d82021-02-09 20:20:17 +0100168 SystemInformationType13 si13 optional,
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200169 SystemInformationType5 si5 optional,
170 SystemInformationType5bis si5bis optional,
171 SystemInformationType5ter si5ter optional,
172 SystemInformationType6 si6 optional
173};
174
175const SystemInformationConfig SystemInformationConfig_omit := {
176 si1 := omit,
177 si2 := omit,
178 si2bis := omit,
179 si2ter := omit,
180 si2quater := omit,
181 si3 := omit,
182 si4 := omit,
183 si13 := omit,
184 si5 := omit,
185 si5bis := omit,
186 si5ter := omit,
187 si6 := omit
188};
189
190/* tr_EUTRAN_CellDesc with defaults used in BSC_Tests.ttcn */
191template EUTRAN_CellDesc tr_EUTRAN_CellDesc_default(template (present) uint16_t e_arfcn := ?,
192 template uint3_t meas_bw := 3)
193:= tr_EUTRAN_CellDesc(e_arfcn := e_arfcn,
194 meas_bw_presence := '1'B,
195 meas_bw := meas_bw);
196
197/* tr_EUTRAN_NeighbourCells with defaults used in BSC_Tests.ttcn */
Harald Welte65e419a2020-08-21 12:38:33 +0200198template EUTRAN_NeighbourCells tr_EUTRAN_NeighbourCells_default(template (present) EUTRAN_CellDescs cell_desc_list := { tr_EUTRAN_CellDesc_default },
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200199 template uint3_t prio := 3,
200 template (present) uint5_t thresh_high := 20,
201 template uint5_t thresh_low := 10,
202 template uint5_t qrxlevmin := 22)
203:= tr_EUTRAN_NeighbourCells(
204 cell_desc_list := cell_desc_list,
205 prio_presence := '1'B,
206 prio := prio,
207 thresh_high := thresh_high,
208 thresh_low_presence := '1'B,
209 thresh_low := thresh_low,
210 qrxlevmin_presence := '1'B,
211 qrxlevmin := qrxlevmin);
212
213template SystemInformationConfig SystemInformationConfig_default := {
214 si1 := {
215 cell_chan_desc := '8FB38000000000000000000000000000'O,
216 rach_control := {
217 max_retrans := RACH_MAX_RETRANS_7,
218 tx_integer := '1001'B,
219 cell_barr_access := false,
220 re_not_allowed := true,
221 acc := '0000010000000000'B
222 },
223 rest_octets := ?
224 },
225 si2 := {
226 bcch_freq_list := '00000000000000000000000000000000'O,
227 ncc_permitted := '11111111'B,
228 rach_control := {
229 max_retrans := RACH_MAX_RETRANS_7,
230 tx_integer := '1001'B,
231 cell_barr_access := false,
232 re_not_allowed := true,
233 acc := '0000010000000000'B
234 }
235 },
236 si2bis := omit,
237 si2ter := {
238 extd_bcch_freq_list := '8E320000000000000000000000000800'O,
239 rest_octets := ?
240 },
241 si2quater := {
242 tr_SI2quaterRestOctets_EUTRAN( repeated_neigh_cells := { tr_EUTRAN_NeighbourCells_default } )
243 },
244 si3 := {
245 cell_id := 0,
246 lai := {
247 mcc_mnc := '001F01'H,
248 lac := 1
249 },
250 ctrl_chan_desc := {
251 msc_r99 := true,
252 att := true,
253 bs_ag_blks_res := 1,
254 ccch_conf := CCHAN_DESC_1CCCH_COMBINED,
255 si22ind := false,
256 cbq3 := CBQ3_IU_MODE_NOT_SUPPORTED,
257 spare := '00'B,
258 bs_pa_mfrms := 3,
259 t3212 := 30
260 },
261 cell_options := {
262 dn_ind := false,
263 pwrc := false,
264 dtx := MS_SHALL_USE_UL_DTX,
265 radio_link_tout_div4 := 7
266 },
267 cell_sel_par := {
268 cell_resel_hyst_2dB := 2,
269 ms_txpwr_max_cch := 7,
270 acs := '0'B,
271 neci := true,
272 rxlev_access_min := 0
273 },
274 rach_control := {
275 max_retrans := RACH_MAX_RETRANS_7,
276 tx_integer := '1001'B,
277 cell_barr_access := false,
278 re_not_allowed := true,
279 acc := '0000010000000000'B
280 },
281 rest_octets := {
282 sel_params := {
283 presence := '0'B,
284 params := omit
285 },
286 pwr_offset := {
287 presence := '0'B,
288 offset := omit
289 },
290 si_2ter_ind := '1'B,
291 early_cm_ind := '0'B,
292 sched_where := {
293 presence := '0'B,
294 where := omit
295 },
296 gprs_ind := {
297 presence := '1'B,
298 ind := {
299 ra_colour := 0,
300 si13_pos := '0'B
301 }
302 },
303 umts_early_cm_ind := '1'B,
304 si2_quater_ind := {
305 presence := '1'B,
306 ind := '0'B
307 },
308 iu_mode_ind := omit,
309 si21_ind := {
310 presence := '0'B,
311 pos := omit
312 }
313 }
314 },
315 si4 := {
316 lai := {
317 mcc_mnc := '001F01'H,
318 lac := 1
319 },
320 cell_sel_par := {
321 cell_resel_hyst_2dB := 2,
322 ms_txpwr_max_cch := 7,
323 acs := '0'B,
324 neci := true,
325 rxlev_access_min := 0
326 },
327 rach_control := {
328 max_retrans := RACH_MAX_RETRANS_7,
329 tx_integer := '1001'B,
330 cell_barr_access := false,
331 re_not_allowed := true,
332 acc := '0000010000000000'B
333 },
Neels Hofmeyr74083c22020-07-29 00:43:01 +0200334 cbch_chan_desc := {
335 iei := '64'O,
336 v := {
337 chan_nr := {
338 u := {
339 sdcch4 := {
340 tag := '001'B,
341 sub_chan := 2
342 }
343 },
344 tn := 0
345 },
346 tsc := 2,
347 h := false,
348 arfcn := 871,
349 maio_hsn := omit
350 }
351 },
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200352 cbch_mobile_alloc := omit,
353 rest_octets := {
354 sel_params := {
355 presence := '0'B,
356 params := omit
357 },
358 pwr_offset := {
359 presence := '0'B,
360 offset := omit
361 },
362 gprs_ind := {
363 presence := '1'B,
364 ind := {
365 ra_colour := 0,
366 si13_pos := '0'B
367 }
368 },
369 s_presence := '0'B,
370 s := omit
371 }
372 },
Pau Espin Pedrol28652d82021-02-09 20:20:17 +0100373 si13 := {
374 rest_octets := {
375 presence := '1'B,
376 bcch_change_mark := ?,
377 si_change_field := '0000'B,
378 presence2 := '0'B,
379 si13_change_mark := omit,
380 gprs_ma := omit,
381 zero := '0'B, /* PBCCH not present in cell */
382 rac := 0,
383 spgc_ccch_sup := '0'B,
384 priority_access_thr := '110'B,
385 network_control_order := '00'B,
386 gprs_cell_opts := {
387 nmo := '01'B,
388 t3168 := '011'B,
389 t3192 := '010'B,
390 drx_timer_max := '011'B,
391 access_burst_type := '0'B,
392 control_ack_type := '1'B,
393 bs_cv_max := 15,
394 pan_presence := '1'B,
395 pan_dec := 1,
396 pan_inc := 1,
397 pan_max := '111'B,
398 ext_info_presence := ?,
399 ext_info_length := *,
400 ext_info := *
401 },
402 gprs_pwr_ctrl_params := {
403 alpha := 0,
404 t_avg_w := '10000'B,
405 t_avg_t := '10000'B,
406 pc_meas_chan := '0'B,
407 n_avg_i := '1000'B
408 }
409 }
410 },
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200411 si5 := {
412 bcch_freq_list := '10000000000000000000000000000000'O
413 },
414 si5bis := omit,
415 si5ter := {
416 extd_bcch_freq_list := '9E050020000000000000000000000000'O
417 },
418 si6 := {
419 cell_id := 0,
420 lai := {
421 mcc_mnc := '001F01'H,
422 lac := 1
423 },
424 cell_options := {
425 dtx_ext := '1'B,
426 pwrc := false,
427 dtx := '01'B,
428 radio_link_timeout := '0111'B
429 },
430 ncc_permitted := '11111111'B,
431 rest_octets := ?
432 }
433 };
434
435
436/* List of all the System Information received on all RSL ports */
437type record of SystemInformationConfig SystemInformationConfig_list;
438
439function f_sysinfo_dec_raw(inout SystemInformationConfig si, RSL_Message rsl)
440{
441 var RSL_IE_Body sysinfo_type_ie;
442 var RSL_IE_SysinfoType si_type;
443 var octetstring data;
444
445 if (f_rsl_find_ie(rsl, RSL_IE_SYSINFO_TYPE, sysinfo_type_ie) == false) {
446 setverdict(fail, "Cannot find RSL_IE_SYSINFO_TYPE");
447 mtc.stop;
448 }
449 si_type := sysinfo_type_ie.sysinfo_type;
450
451 if (rsl.msg_type == RSL_MT_BCCH_INFO) {
452 var RSL_IE_Body bcch_ie;
453 if (f_rsl_find_ie(rsl, RSL_IE_FULL_BCCH_INFO, bcch_ie)) {
454 data := bcch_ie.other.payload;
455 }
456 } else if (rsl.msg_type == RSL_MT_SACCH_FILL) {
457 var RSL_IE_Body l3_ie;
458 if (f_rsl_find_ie(rsl, RSL_IE_L3_INFO, l3_ie)) {
459 data := l3_ie.l3_info.payload;
460 }
461 } else {
462 setverdict(fail, "Don't understand this System Information message");
463 mtc.stop;
464 }
465
466 var boolean handled := false;
467
468 if (rsl.msg_type == RSL_MT_BCCH_INFO) {
469 handled := true;
470
471 if (si_type == RSL_SYSTEM_INFO_1) {
472 if (not isbound(data)) {
473 si.si1 := omit;
474 } else {
475 si.si1 := dec_SystemInformation(data).payload.si1;
476 }
477 } else if (si_type == RSL_SYSTEM_INFO_2) {
478 if (not isbound(data)) {
479 si.si2 := omit;
480 } else {
481 si.si2 := dec_SystemInformation(data).payload.si2;
482 }
483 } else if (si_type == RSL_SYSTEM_INFO_2bis) {
484 if (not isbound(data)) {
485 si.si2bis := omit;
486 } else {
487 si.si2bis := dec_SystemInformation(data).payload.si2bis;
488 }
489 } else if (si_type == RSL_SYSTEM_INFO_2ter) {
490 if (not isbound(data)) {
491 si.si2ter := omit;
492 } else {
493 si.si2ter := dec_SystemInformation(data).payload.si2ter;
494 }
495 } else if (si_type == RSL_SYSTEM_INFO_2quater) {
496 if (not isbound(data)) {
497 si.si2quater := {};
498 } else {
499 var SystemInformationType2quater decoded := dec_SystemInformation(data).payload.si2quater;
500 /* this is a *record* of SI2quaterRestOctets! (multiplexed) */
501 si.si2quater[decoded.rest_octets.si2quater_index] := decoded.rest_octets;
502 }
503 } else if (si_type == RSL_SYSTEM_INFO_3) {
504 if (not isbound(data)) {
505 si.si3 := omit;
506 } else {
507 si.si3 := dec_SystemInformation(data).payload.si3;
508 }
509 } else if (si_type == RSL_SYSTEM_INFO_4) {
510 if (not isbound(data)) {
511 si.si4 := omit;
512 } else {
513 si.si4 := dec_SystemInformation(data).payload.si4;
514 }
515 } else if (si_type == RSL_SYSTEM_INFO_13) {
516 if (not isbound(data)) {
517 si.si13 := omit;
518 } else {
Pau Espin Pedrol28652d82021-02-09 20:20:17 +0100519 si.si13 := dec_SystemInformation(data).payload.si13;
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200520 }
521 } else {
522 handled := false;
523 }
524 } else if (rsl.msg_type == RSL_MT_SACCH_FILL) {
525 handled := true;
526
527 if (si_type == RSL_SYSTEM_INFO_5) {
528 if (not isbound(data)) {
529 si.si5 := omit;
530 } else {
531 si.si5 := dec_SystemInformation(data).payload.si5;
532 }
533 } else if (si_type == RSL_SYSTEM_INFO_5bis) {
534 if (not isbound(data)) {
535 si.si5bis := omit;
536 } else {
537 si.si5bis := dec_SystemInformation(data).payload.si5bis;
538 }
539 } else if (si_type == RSL_SYSTEM_INFO_5ter) {
540 if (not isbound(data)) {
541 si.si5ter := omit;
542 } else {
543 si.si5ter := dec_SystemInformation(data).payload.si5ter;
544 }
545 } else if (si_type == RSL_SYSTEM_INFO_6) {
546 if (not isbound(data)) {
547 si.si6 := omit;
548 } else {
549 si.si6 := dec_SystemInformation(data).payload.si6;
550 }
551 } else {
552 handled := false;
553 }
554 }
555
556 if (not handled) {
557 setverdict(fail, "Unexpected SI type in ", rsl.msg_type, " message: ", si_type);
558 }
559}
560
Harald Weltea4ca4462018-02-09 00:17:14 +0100561type component test_CT extends CTRL_Adapter_CT {
Harald Welte21b46bd2017-12-17 19:46:32 +0100562 /* Array of per-BTS state */
Harald Welte96c94412017-12-09 03:12:45 +0100563 var BTS_State bts[NUM_BTS];
Harald Welte89ab1912018-02-23 18:56:29 +0100564 /* RSL common Channel Port (for RSL_Emulation) */
565 port RSL_CCHAN_PT RSL_CCHAN[NUM_BTS];
Harald Welte21b46bd2017-12-17 19:46:32 +0100566 /* array of per-BTS RSL test ports */
Harald Welteae026692017-12-09 01:03:01 +0100567 port IPA_RSL_PT IPA_RSL[NUM_BTS];
Stefan Sperling830dc9d2018-02-12 21:08:28 +0100568 port IPA_CODEC_PT IPA; /* Required for compilation of TC_rsl_unknown_unit_id() */
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +0200569 /* CTRL muxed over IPA in SCCPlite conn BSC<->MSC (or BSC-NAT) */
570 port IPA_CTRL_PT SCCPLITE_IPA_CTRL;
Harald Weltea5d2ab22017-12-09 14:21:42 +0100571
Daniel Willmann191e0d92018-01-17 12:44:35 +0100572 var MGCP_Emulation_CT vc_MGCP;
Harald Weltebc03c762018-02-12 18:09:38 +0100573 port TELNETasp_PT BSCVTY;
Daniel Willmann191e0d92018-01-17 12:44:35 +0100574
Daniel Willmannebdecc02020-08-12 15:30:17 +0200575 /* StatsD */
576 var StatsD_Checker_CT vc_STATSD;
577
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200578 var RAN_Adapter g_bssap[NUM_MSC];
Harald Welte47cd0e32020-08-21 12:39:11 +0200579 var BSSAP_LE_Adapter g_bssap_le;
Harald Weltea4ca4462018-02-09 00:17:14 +0100580 /* for old legacy-tests only */
581 port BSSAP_CODEC_PT BSSAP;
Harald Welte47cd0e32020-08-21 12:39:11 +0200582 port BSSAP_LE_CODEC_PT BSSAP_LE;
Harald Weltea4ca4462018-02-09 00:17:14 +0100583
Harald Welte21b46bd2017-12-17 19:46:32 +0100584 /* are we initialized yet */
Harald Welte28d943e2017-11-25 15:00:50 +0100585 var boolean g_initialized := false;
Harald Welte21b46bd2017-12-17 19:46:32 +0100586
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200587 /* Osmux is enabled through VTY */
588 var boolean g_osmux_enabled := false;
589
Pau Espin Pedrolc675b612020-01-09 19:55:40 +0100590 /*Configure T(tias) over VTY, seconds */
591 var integer g_bsc_sccp_timer_ias := 7 * 60;
592 /*Configure T(tiar) over VTY, seconds */
593 var integer g_bsc_sccp_timer_iar := 15 * 60;
594
Neels Hofmeyr4fbad7f2020-06-16 00:30:47 +0200595 /* global test case guard timer (actual timeout value is set in f_init()) */
Harald Welteae026692017-12-09 01:03:01 +0100596 timer T_guard := 30.0;
597
Neels Hofmeyr22c3f792020-06-17 02:49:28 +0200598 var CounterNameValsList g_ctr_msc;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +0000599 var CounterNameValsList g_ctr_bsc;
600 var CounterNameValsList g_ctr_bts;
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200601
602 /* System Information bytes as received during RSL startup, for each RSL[idx]. */
603 var SystemInformationConfig_list g_system_information := {};
Harald Welte28d943e2017-11-25 15:00:50 +0100604}
605
606modulepar {
Harald Welte21b46bd2017-12-17 19:46:32 +0100607 /* IP address at which the BSC can be reached */
Harald Welte696ddb62017-12-08 14:01:43 +0100608 charstring mp_bsc_ip := "127.0.0.1";
Stefan Sperling830dc9d2018-02-12 21:08:28 +0100609 /* port number to which to establish the IPA OML connections */
610 integer mp_bsc_oml_port := 3002;
Harald Welte21b46bd2017-12-17 19:46:32 +0100611 /* port number to which to establish the IPA RSL connections */
Harald Welte696ddb62017-12-08 14:01:43 +0100612 integer mp_bsc_rsl_port := 3003;
Harald Welte21b46bd2017-12-17 19:46:32 +0100613 /* port number to which to establish the IPA CTRL connection */
Harald Welte96c94412017-12-09 03:12:45 +0100614 integer mp_bsc_ctrl_port := 4249;
Daniel Willmannebdecc02020-08-12 15:30:17 +0200615 /* port number to which to listen for STATSD metrics */
616 integer mp_bsc_statsd_port := 8125;
Daniel Willmann191e0d92018-01-17 12:44:35 +0100617 /* IP address at which the test binds */
618 charstring mp_test_ip := "127.0.0.1";
Harald Weltea4ca4462018-02-09 00:17:14 +0100619
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200620 RAN_Configurations mp_bssap_cfg := {
621 {
622 transport := BSSAP_TRANSPORT_AoIP,
623 sccp_service_type := "mtp3_itu",
624 sctp_addr := { 23905, "127.0.0.1", 2905, "127.0.0.1" },
625 own_pc := 185, /* 0.23.1 first MSC emulation */
626 own_ssn := 254,
627 peer_pc := 187, /* 0.23.3 osmo-bsc */
628 peer_ssn := 254,
629 sio := '83'O,
Harald Weltecb0cc432020-06-21 19:42:31 +0200630 rctx := 1
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200631 },
632 {
633 transport := BSSAP_TRANSPORT_AoIP,
634 sccp_service_type := "mtp3_itu",
635 sctp_addr := { 23906, "127.0.0.1", 2905, "127.0.0.1" },
636 own_pc := 2, /* 0.0.2 second MSC emulation */
637 own_ssn := 254,
638 peer_pc := 187, /* 0.23.3 osmo-bsc */
639 peer_ssn := 254,
640 sio := '83'O,
641 rctx := 2
642 },
643 {
644 transport := BSSAP_TRANSPORT_AoIP,
645 sccp_service_type := "mtp3_itu",
646 sctp_addr := { 23907, "127.0.0.1", 2905, "127.0.0.1" },
647 own_pc := 3, /* 0.0.3 third MSC emulation */
648 own_ssn := 254,
649 peer_pc := 187, /* 0.23.3 osmo-bsc */
650 peer_ssn := 254,
651 sio := '83'O,
652 rctx := 3
653 }
Harald Weltea4ca4462018-02-09 00:17:14 +0100654 };
Pau Espin Pedrol58cf6822019-05-28 18:11:33 +0200655
Harald Welte47cd0e32020-08-21 12:39:11 +0200656 BSSAP_LE_Configuration mp_bssap_le_cfg := {
657 sccp_service_type := "mtp3_itu",
658 sctp_addr := { 23908, "127.0.0.1", 2905, "127.0.0.1" },
Neels Hofmeyrac086c12020-09-18 23:46:42 +0200659 own_pc := 190, /* 0.23.6 SMLC emulation */
Harald Welte47cd0e32020-08-21 12:39:11 +0200660 own_ssn := 252, /* SMLC side SSN */
661 peer_pc := 187, /* 0.23.3 osmo-bsc */
662 peer_ssn := 250, /* BSC side SSN */
663 sio := '83'O,
664 rctx := 6
665 };
Neels Hofmeyrcfe44062020-10-15 02:28:08 +0200666 boolean mp_enable_lcs_tests := true;
Harald Welte47cd0e32020-08-21 12:39:11 +0200667
Pau Espin Pedrol58cf6822019-05-28 18:11:33 +0200668 /* Whether to enable osmux tests. Can be dropped completely and enable
669 unconditionally once new version of osmo-bsc is released (current
670 version: 1.4.1) */
671 boolean mp_enable_osmux_test := true;
Pau Espin Pedrol8f30ccd2019-11-01 17:30:57 +0100672 /* Value set in osmo-bsc.cfg "ms max power" */
673 uint8_t mp_exp_ms_power_level := 7;
Harald Weltea4ca4462018-02-09 00:17:14 +0100674}
675
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200676private function f_gen_test_hdlr_pars(integer bssap_idx := 0) return TestHdlrParams {
Philipp Maier48604732018-10-09 15:00:37 +0200677
678 var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200679 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Philipp Maier48604732018-10-09 15:00:37 +0200680 pars.aoip := true;
681 } else {
682 pars.aoip := false;
683 }
Pau Espin Pedrol8f30ccd2019-11-01 17:30:57 +0100684 pars.exp_ms_power_level := mp_exp_ms_power_level;
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200685 pars.mscpool.bssap_idx := bssap_idx;
Philipp Maier48604732018-10-09 15:00:37 +0200686
687 return pars;
688}
689
Neels Hofmeyr22c3f792020-06-17 02:49:28 +0200690/* Convenience functions for rate counters using g_ctr_msc. */
691
692private function f_ctrs_msc_init(integer mscs_count := NUM_MSC, CounterNameVals counternames := counternames_msc_mscpool) runs on test_CT {
693 g_ctr_msc := f_counter_name_vals_get_n(IPA_CTRL, "msc", mscs_count, counternames);
694 log("initial msc rate counters: ", g_ctr_msc);
695}
696
697private function f_ctrs_msc_add(integer msc_nr, charstring countername, integer val := 1) runs on test_CT {
Neels Hofmeyr9656e922020-06-30 01:27:01 +0200698 f_counter_name_vals_list_add(g_ctr_msc, msc_nr, countername, val);
Neels Hofmeyr22c3f792020-06-17 02:49:28 +0200699}
700
701/* f_ctrs_msc_init();
702 * f_do_thing(on_msc := 0);
703 * f_do_thing(on_msc := 0);
704 * f_do_other(on_msc := 1);
705 * f_ctrs_msc_add(0, "thing", 2);
706 * f_ctrs_msc_add(1, "other");
707 * f_ctrs_msc_verify();
708 */
709private function f_ctrs_msc_verify() runs on test_CT {
710 log("verifying msc rate counters: ", g_ctr_msc);
711 f_counter_name_vals_expect_n(IPA_CTRL, "msc", g_ctr_msc);
712}
713
714/* convenience: f_ctrs_msc_add() and f_ctrs_msc_verify() in one call.
715 * f_ctrs_msc_init();
716 * f_do_thing(on_msc := 0);
717 * f_do_thing(on_msc := 0);
718 * f_do_thing(on_msc := 0);
719 * f_ctrs_msc_expect(0, "thing", 3);
720 */
721private function f_ctrs_msc_expect(integer msc_nr, charstring countername, integer val := 1) runs on test_CT {
722 f_ctrs_msc_add(msc_nr, countername, val);
723 f_ctrs_msc_verify();
724}
725
Neels Hofmeyr12941bd2020-08-29 03:21:26 +0000726/* Convenience functions for rate counters using g_ctr_bts, always also including g_ctr_bsc. */
727
728private function f_ctrs_bsc_and_bts_init(integer bts_count := NUM_BTS, CounterNameVals counternames := counternames_bsc_bts_handover) runs on test_CT {
729 g_ctr_bts := f_counter_name_vals_get_n(IPA_CTRL, "bts", bts_count, counternames);
730 log("initial bts rate counters: ", g_ctr_bts);
731 f_ctrs_bsc_init(counternames);
732}
733
734private function f_ctrs_bsc_and_bts_add(integer bts_nr, charstring countername, integer val := 1) runs on test_CT {
735 f_counter_name_vals_list_add(g_ctr_bts, bts_nr, countername, val);
736 f_ctrs_bsc_add(countername, val);
737}
738
739/* f_ctrs_bsc_and_bts_init();
740 * f_do_thing(on_bts := 0);
741 * f_do_thing(on_bts := 0);
742 * f_do_other(on_bts := 1);
743 * f_ctrs_bsc_and_bts_add(0, "thing", 2);
744 * f_ctrs_bsc_and_bts_add(1, "other");
745 * f_ctrs_bsc_and_bts_verify();
746 */
747private function f_ctrs_bsc_and_bts_verify() runs on test_CT {
748 f_counter_name_vals_expect_n(IPA_CTRL, "bts", g_ctr_bts);
749 f_ctrs_bsc_verify();
750}
751
752/* convenience: f_ctrs_bsc_and_bts_add() and f_ctrs_bsc_and_bts_verify() in one call.
753 * f_ctrs_bsc_and_bts_init();
754 * f_do_thing(on_bts := 0);
755 * f_do_thing(on_bts := 0);
756 * f_do_thing(on_bts := 0);
757 * f_ctrs_bsc_and_bts_expect(0, "thing", 3);
758 */
759private function f_ctrs_bsc_and_bts_expect(integer bts_nr, charstring countername, integer val := 1) runs on test_CT {
760 f_ctrs_bsc_and_bts_add(bts_nr, countername, val);
761 f_ctrs_bsc_and_bts_verify();
762}
763
764
765/* Convenience functions for rate counters using g_ctr_bsc. */
766
767private function f_ctrs_bsc_init(CounterNameVals counternames := counternames_bsc_bts_handover) runs on test_CT {
768 g_ctr_bsc := f_counter_name_vals_get_n(IPA_CTRL, "bsc", 1, counternames);
769 log("initial bsc rate counters: ", g_ctr_bsc);
770}
771
772private function f_ctrs_bsc_add(charstring countername, integer val := 1) runs on test_CT {
773 f_counter_name_vals_list_add(g_ctr_bsc, 0, countername, val);
774}
775
776/* f_ctrs_bsc_init();
777 * f_do_thing();
778 * f_do_thing();
779 * f_do_other();
780 * f_ctrs_bsc_add("thing", 2);
781 * f_ctrs_bsc_add("other");
782 * f_ctrs_bsc_verify();
783 */
784private function f_ctrs_bsc_verify() runs on test_CT {
785 f_counter_name_vals_expect_n(IPA_CTRL, "bsc", g_ctr_bsc);
786}
787
788/* convenience: f_ctrs_bsc_add() and f_ctrs_bsc_verify() in one call.
789 * f_ctrs_bsc_init();
790 * f_do_thing();
791 * f_ctrs_bsc_expect("thing", 1);
792 */
793private function f_ctrs_bsc_expect(charstring countername, integer val := 1) runs on test_CT {
794 f_ctrs_bsc_add(countername, val);
795 f_ctrs_bsc_verify();
796}
797
Neels Hofmeyr22c3f792020-06-17 02:49:28 +0200798
Philipp Maier282ca4b2018-02-27 17:17:00 +0100799private function f_shutdown_helper() runs on test_CT {
Daniel Willmann637ef6c2018-07-25 10:49:09 +0200800 all component.stop;
Philipp Maier282ca4b2018-02-27 17:17:00 +0100801 setverdict(pass);
Daniel Willmannafce8662018-07-06 23:11:32 +0200802 mtc.stop;
Philipp Maier282ca4b2018-02-27 17:17:00 +0100803}
804
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200805private function f_legacy_bssap_reset(integer bssap_idx := 0) runs on test_CT {
Harald Weltea4ca4462018-02-09 00:17:14 +0100806 var BSSAP_N_UNITDATA_ind ud_ind;
Pau Espin Pedrol24c05992020-09-01 12:54:12 +0200807 var boolean reset_received := false;
Harald Weltea4ca4462018-02-09 00:17:14 +0100808 timer T := 5.0;
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200809 BSSAP.send(ts_BSSAP_UNITDATA_req(g_bssap[bssap_idx].sccp_addr_peer, g_bssap[bssap_idx].sccp_addr_own,
810 ts_BSSMAP_Reset(0, g_osmux_enabled)));
Harald Weltea4ca4462018-02-09 00:17:14 +0100811 T.start;
812 alt {
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200813 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(g_bssap[bssap_idx].sccp_addr_own, g_bssap[bssap_idx].sccp_addr_peer,
814 tr_BSSMAP_ResetAck(g_osmux_enabled))) {
Neels Hofmeyr4f5d7be2020-10-16 16:28:16 +0200815 log("BSSMAP: Received RESET-ACK in response to RESET, we're ready to go!");
Harald Weltea4ca4462018-02-09 00:17:14 +0100816 }
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200817 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset(g_osmux_enabled))) -> value ud_ind {
Neels Hofmeyr4f5d7be2020-10-16 16:28:16 +0200818 log("BSSMAP: Respoding to inbound RESET with RESET-ACK");
Harald Weltea4ca4462018-02-09 00:17:14 +0100819 BSSAP.send(ts_BSSAP_UNITDATA_req(ud_ind.callingAddress, ud_ind.calledAddress,
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200820 ts_BSSMAP_ResetAck(g_osmux_enabled)));
Pau Espin Pedrol24c05992020-09-01 12:54:12 +0200821 reset_received := true;
Harald Weltea4ca4462018-02-09 00:17:14 +0100822 repeat;
823 }
824 [] BSSAP.receive { repeat; }
Pau Espin Pedrol24c05992020-09-01 12:54:12 +0200825 [] T.timeout {
Neels Hofmeyr4f5d7be2020-10-16 16:28:16 +0200826 log("BSSMAP: Timeout waiting for RESET-ACK after sending RESET");
Pau Espin Pedrol24c05992020-09-01 12:54:12 +0200827 /* If we received a RESET after ours was sent, it
828 may be a race condition where the other peer beacame
829 available after we sent it, but we are in a desired
830 state anyway, so go forward. */
831 if (not reset_received) {
832 setverdict(fail);
833 }
834 }
Harald Weltea4ca4462018-02-09 00:17:14 +0100835 }
Harald Welte28d943e2017-11-25 15:00:50 +0100836}
837
Harald Welteae026692017-12-09 01:03:01 +0100838type record IPA_Client {
Harald Welte21b46bd2017-12-17 19:46:32 +0100839 /* IPA Emulation component reference */
Harald Welteae026692017-12-09 01:03:01 +0100840 IPA_Emulation_CT vc_IPA,
Harald Welte21b46bd2017-12-17 19:46:32 +0100841 /* Unit-ID and other CCM parameters to use for IPA client emulation */
Harald Welteae026692017-12-09 01:03:01 +0100842 IPA_CCM_Parameters ccm_pars,
Harald Welte21b46bd2017-12-17 19:46:32 +0100843 /* String identifier for this IPA Client */
Harald Welte624f9632017-12-16 19:26:04 +0100844 charstring id,
Harald Welte21b46bd2017-12-17 19:46:32 +0100845 /* Associated RSL Emulation Component (if any). Only used in "Handler mode" */
Harald Welte624f9632017-12-16 19:26:04 +0100846 RSL_Emulation_CT vc_RSL optional
Harald Welte28d943e2017-11-25 15:00:50 +0100847}
848
Harald Welte21b46bd2017-12-17 19:46:32 +0100849/*! Start the IPA/RSL related bits for one IPA_Client.
850 * \param clnt IPA_Client for which to establish
851 * \param bsc_host IP address / hostname of the BSC
852 * \param bsc_port TCP port number of the BSC
853 * \param i number identifying this BTS
854 * \param handler_mode Start an RSL_Emulation_CT component (true) or not (false) */
Harald Welte624f9632017-12-16 19:26:04 +0100855function f_ipa_rsl_start(inout IPA_Client clnt, charstring bsc_host, PortNumber bsc_port, integer i,
856 boolean handler_mode := false)
Harald Welte28d943e2017-11-25 15:00:50 +0100857runs on test_CT {
Harald Welteae026692017-12-09 01:03:01 +0100858 timer T := 10.0;
859
Harald Welte96c94412017-12-09 03:12:45 +0100860 clnt.id := "IPA" & int2str(i) & "-RSL";
Harald Welteae026692017-12-09 01:03:01 +0100861 clnt.vc_IPA := IPA_Emulation_CT.create(clnt.id & "-IPA");
862 clnt.ccm_pars := c_IPA_default_ccm_pars;
863 clnt.ccm_pars.name := "Osmocom TTCN-3 BTS Simulator";
864 clnt.ccm_pars.unit_id := int2str(1234+i) & "/0/0";
Harald Welte624f9632017-12-16 19:26:04 +0100865 if (handler_mode) {
866 clnt.vc_RSL := RSL_Emulation_CT.create(clnt.id & "-RSL");
Harald Welte89ab1912018-02-23 18:56:29 +0100867 connect(clnt.vc_RSL:CCHAN_PT, self:RSL_CCHAN[i]);
Harald Welte624f9632017-12-16 19:26:04 +0100868 }
Harald Welteae026692017-12-09 01:03:01 +0100869
870 map(clnt.vc_IPA:IPA_PORT, system:IPA_CODEC_PT);
Harald Welte624f9632017-12-16 19:26:04 +0100871 if (handler_mode) {
872 connect(clnt.vc_IPA:IPA_RSL_PORT, clnt.vc_RSL:IPA_PT);
873 } else {
874 connect(clnt.vc_IPA:IPA_RSL_PORT, self:IPA_RSL[i]);
875 }
Harald Welteae026692017-12-09 01:03:01 +0100876
Harald Welte5d1a2202017-12-13 19:51:29 +0100877 clnt.vc_IPA.start(IPA_Emulation.main_client(bsc_host, bsc_port, "", 10000+i, clnt.ccm_pars));
Harald Welte624f9632017-12-16 19:26:04 +0100878 if (handler_mode) {
879 clnt.vc_RSL.start(RSL_Emulation.main());
880 return;
881 }
Harald Welteae026692017-12-09 01:03:01 +0100882
883 /* wait for IPA RSL link to connect and send ID ACK */
884 T.start;
885 alt {
Vadim Yanitskiya2afacc2020-05-18 21:16:19 +0700886 [] IPA_RSL[i].receive(tr_ASP_IPA_EV(ASP_IPA_EVENT_ID_ACK)) {
Harald Welteae026692017-12-09 01:03:01 +0100887 T.stop;
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +0700888 IPA_RSL[i].send(ts_ASP_RSL_UD(ts_RSL_PAGING_LOAD_IND(23)));
Harald Welteae026692017-12-09 01:03:01 +0100889 }
Harald Welte60e823a2017-12-10 14:10:59 +0100890 [] IPA_RSL[i].receive(ASP_IPA_Event:?) { repeat }
Harald Welteae026692017-12-09 01:03:01 +0100891 [] IPA_RSL[i].receive { repeat }
892 [] T.timeout {
Harald Welte96c94412017-12-09 03:12:45 +0100893 setverdict(fail, "Timeout RSL waiting for ASP_IPA_EVENT_ID_ACK");
Daniel Willmannafce8662018-07-06 23:11:32 +0200894 mtc.stop;
Harald Welteae026692017-12-09 01:03:01 +0100895 }
896 }
897}
898
Harald Welte12055472018-03-17 20:10:08 +0100899function f_ipa_rsl_stop(inout IPA_Client clnt) runs on test_CT {
900 if (not isbound(clnt) or not isbound(clnt.vc_IPA)) {
901 return;
902 }
903 clnt.vc_IPA.stop;
904 if (isbound(clnt.vc_RSL)) {
905 clnt.vc_RSL.stop;
906 }
907}
908
Harald Welte21b46bd2017-12-17 19:46:32 +0100909/* Wait for the OML connection to be brought up by the external osmo-bts-omldummy */
Harald Weltea5d2ab22017-12-09 14:21:42 +0100910function f_wait_oml(integer bts_nr, charstring status, float secs_max) runs on test_CT {
911 timer T := secs_max;
912 T.start;
913 while (true) {
914 if (f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-connection-state") == status) {
915 T.stop;
Harald Weltebd868bd2017-12-10 18:28:40 +0100916 /* the 'degraded' state exists from OML connection time, and we have to wait
917 * until all MO's are initialized */
918 T.start(1.0);
919 T.timeout;
Harald Weltea5d2ab22017-12-09 14:21:42 +0100920 return;
921 }
Harald Weltef0d6ac62017-12-17 17:02:21 +0100922 f_sleep(0.1);
Harald Weltea5d2ab22017-12-09 14:21:42 +0100923 if (not T.running) {
Max99253902018-11-16 17:57:39 +0100924 setverdict(fail, "Timeout waiting for BTS" & int2str(bts_nr) & " oml-connection-state ", status);
Daniel Willmannafce8662018-07-06 23:11:32 +0200925 mtc.stop;
Harald Weltea5d2ab22017-12-09 14:21:42 +0100926 }
927 }
928}
929
Harald Welte21b46bd2017-12-17 19:46:32 +0100930/* global altstep for global guard timer; also takes care of responding RESET witH RESET-ACK */
Harald Welteae026692017-12-09 01:03:01 +0100931altstep as_Tguard() runs on test_CT {
Harald Welte60e823a2017-12-10 14:10:59 +0100932 var BSSAP_N_UNITDATA_ind ud_ind;
Neels Hofmeyrcc3f76a2018-03-12 01:43:25 +0100933 [] T_guard.timeout {
934 setverdict(fail, "Timeout of T_guard");
Daniel Willmannafce8662018-07-06 23:11:32 +0200935 mtc.stop;
Neels Hofmeyrcc3f76a2018-03-12 01:43:25 +0100936 }
Harald Welte60e823a2017-12-10 14:10:59 +0100937 /* always respond with RESET ACK to RESET */
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200938 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset(g_osmux_enabled))) -> value ud_ind {
Harald Welte60e823a2017-12-10 14:10:59 +0100939 BSSAP.send(ts_BSSAP_UNITDATA_req(ud_ind.callingAddress, ud_ind.calledAddress,
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200940 ts_BSSMAP_ResetAck(g_osmux_enabled)));
Harald Welte69c1c262017-12-13 21:02:08 +0100941 repeat;
Harald Welte60e823a2017-12-10 14:10:59 +0100942 }
Harald Welte28d943e2017-11-25 15:00:50 +0100943}
944
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +0100945altstep no_bssmap_reset() runs on test_CT {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200946 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset(g_osmux_enabled))) {
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +0100947 setverdict(fail, "unexpected BSSMAP Reset");
Daniel Willmannafce8662018-07-06 23:11:32 +0200948 mtc.stop;
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +0100949 }
950}
951
Daniel Willmann191e0d92018-01-17 12:44:35 +0100952function f_init_mgcp(charstring id) runs on test_CT {
953 id := id & "-MGCP";
954
955 var MGCPOps ops := {
956 create_cb := refers(MGCP_Emulation.ExpectedCreateCallback),
957 unitdata_cb := refers(MGCP_Emulation.DummyUnitdataCallback)
958 };
959 var MGCP_conn_parameters mgcp_pars := {
960 callagent_ip := mp_bsc_ip,
Harald Welte9e4273e2018-01-29 22:01:22 +0100961 callagent_udp_port := -1,
Daniel Willmann191e0d92018-01-17 12:44:35 +0100962 mgw_ip := mp_test_ip,
Pau Espin Pedrol1a026a52019-06-18 17:21:52 +0200963 mgw_udp_port := 2427,
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +0200964 /* Enable it for SCCPlite, since we have 2 MGCP sockets towards MGW (UDP one +
965 the on with MGCP over IPA forwarded from MSC one) */
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200966 multi_conn_mode := (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_SCCPlite_SERVER)
Daniel Willmann191e0d92018-01-17 12:44:35 +0100967 };
968
969 vc_MGCP := MGCP_Emulation_CT.create(id);
970 vc_MGCP.start(MGCP_Emulation.main(ops, mgcp_pars, id));
971}
972
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200973/* Enable or disable (current default) Osmux. When enabling, BSSMAP Reset
974 * contains extra IE (OsmuxSupport) and osmo-bsc will handle AssignReq with
975 * OsmuxCID IE.
976 */
977private function f_vty_allow_osmux(boolean allow) runs on test_CT {
978 f_vty_enter_cfg_msc(BSCVTY, 0);
979 if (allow) {
980 f_vty_transceive(BSCVTY, "osmux on");
981 } else {
982 f_vty_transceive(BSCVTY, "osmux off");
983 }
984 f_vty_transceive(BSCVTY, "exit");
985 f_vty_transceive(BSCVTY, "exit");
986 g_osmux_enabled := allow;
987}
988
Max2253c0b2018-11-06 19:28:05 +0100989function f_init_vty(charstring id := "foo") runs on test_CT {
Harald Welte94e0c342018-04-07 11:33:23 +0200990 if (BSCVTY.checkstate("Mapped")) {
991 /* skip initialization if already executed once */
992 return;
993 }
Harald Weltebc03c762018-02-12 18:09:38 +0100994 map(self:BSCVTY, system:BSCVTY);
995 f_vty_set_prompts(BSCVTY);
996 f_vty_transceive(BSCVTY, "enable");
Pau Espin Pedrolc675b612020-01-09 19:55:40 +0100997 f_cs7_inst_0_cfg(BSCVTY, {"sccp-timer ias " & int2str(g_bsc_sccp_timer_ias),
998 "sccp-timer iar " & int2str(g_bsc_sccp_timer_iar)});
Harald Weltebc03c762018-02-12 18:09:38 +0100999}
1000
Neels Hofmeyr767548a2020-08-09 20:26:07 +00001001private function f_logp(TELNETasp_PT pt, charstring log_msg)
Neels Hofmeyr4f118412020-06-04 15:25:10 +02001002{
1003 // log on TTCN3 log output
1004 log(log_msg);
1005 // log in stderr log
Neels Hofmeyr767548a2020-08-09 20:26:07 +00001006 f_vty_transceive(pt, "logp lglobal notice TTCN3 f_logp(): " & log_msg);
Neels Hofmeyr4f118412020-06-04 15:25:10 +02001007}
1008
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02001009private function f_sysinfo_seen(integer rsl_idx, RSL_Message rsl) runs on test_CT
1010{
1011 if (rsl_idx >= lengthof(g_system_information)) {
1012 g_system_information[rsl_idx] := SystemInformationConfig_omit
1013 }
1014 f_sysinfo_dec_raw(g_system_information[rsl_idx], rsl);
1015}
1016
1017altstep as_catch_RSL_sysinfo(integer rsl_idx) runs on test_CT {
1018 var ASP_RSL_Unitdata rx_rsl_ud;
1019
1020 /* For handler_mode := false, receiving the RSL bootstrap messages directly on IPA_RSL */
1021 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_NO_BCCH_INFO)) -> value rx_rsl_ud {
1022 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1023 repeat;
1024 }
1025 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_BCCH_INFO)) -> value rx_rsl_ud {
1026 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1027 repeat;
1028 }
1029 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_NO_SACCH_FILL)) -> value rx_rsl_ud {
1030 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1031 repeat;
1032 }
1033 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_SACCH_FILL)) -> value rx_rsl_ud {
1034 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1035 repeat;
1036 }
1037
1038 /* For handler_mode := true, receiving the RSL bootstrap messages via RSL_Emulation */
1039 [] RSL_CCHAN[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_NO_BCCH_INFO)) -> value rx_rsl_ud {
1040 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1041 repeat;
1042 }
1043 [] RSL_CCHAN[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_BCCH_INFO)) -> value rx_rsl_ud {
1044 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1045 repeat;
1046 }
1047 [] RSL_CCHAN[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_NO_SACCH_FILL)) -> value rx_rsl_ud {
1048 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1049 repeat;
1050 }
1051 [] RSL_CCHAN[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_SACCH_FILL)) -> value rx_rsl_ud {
1052 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1053 repeat;
1054 }
1055}
1056
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001057/* TODO: use BooleanList from COMMON/src/General_Types.ttcn */
1058private type record of boolean my_BooleanList;
1059
1060private function f_vty_msc_allow_attach(TELNETasp_PT pt, my_BooleanList allow_attach_list)
1061{
Neels Hofmeyr8f576712020-08-12 22:49:53 +00001062 var charstring config := f_vty_transceive_ret(pt, "show running-config");
1063
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001064 for (var integer msc_nr := 0; msc_nr < sizeof(allow_attach_list); msc_nr := msc_nr+1) {
Neels Hofmeyr8f576712020-08-12 22:49:53 +00001065 if (f_strstr(config, "\nmsc " & int2str(msc_nr) & "\n") < 0) {
1066 /* There is no 'msc N' for this msc_nr in the running config, so don't create an empty msc by
1067 * stepping into that config node. */
1068 log("msc ", msc_nr, " is not configured, skipping");
1069 continue;
1070 }
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001071 f_vty_enter_cfg_msc(pt, msc_nr);
1072 if (allow_attach_list[msc_nr]) {
1073 /* strict := false: ignore if osmo-bsc does not support this config option (latest build) */
1074 f_vty_transceive(pt, "allow-attach", strict := false);
1075 } else {
1076 f_vty_transceive(pt, "no allow-attach", strict := false);
1077 }
1078 f_vty_transceive(pt, "exit");
1079 f_vty_transceive(pt, "exit");
1080 }
1081}
1082
Harald Welte21b46bd2017-12-17 19:46:32 +01001083/* global initialization function
1084 * \param nr_bts Number of BTSs we should start/bring up
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001085 * \param handler_mode Start an RSL_Emulation_CT component (true) or not (false).
1086 * \param nr_msc Number of virtual MSCs to bring up to connect to osmo-bsc.
1087 */
1088function f_init(integer nr_bts := NUM_BTS, boolean handler_mode := false, boolean allow_osmux := false,
Neels Hofmeyr4fbad7f2020-06-16 00:30:47 +02001089 integer nr_msc := 1, float guard_timeout := 30.0) runs on test_CT {
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001090 var integer bssap_idx;
Harald Welte28d943e2017-11-25 15:00:50 +01001091
Harald Welteae026692017-12-09 01:03:01 +01001092 if (g_initialized) {
1093 return;
Harald Welte28d943e2017-11-25 15:00:50 +01001094 }
Harald Welteae026692017-12-09 01:03:01 +01001095 g_initialized := true;
1096
Neels Hofmeyr4fbad7f2020-06-16 00:30:47 +02001097 T_guard.start(guard_timeout);
Daniel Willmanne68f9272018-11-27 15:15:28 +01001098 activate(as_Tguard());
1099
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001100 f_init_vty("VirtMSC");
Pau Espin Pedrol58cf6822019-05-28 18:11:33 +02001101 if (mp_enable_osmux_test) {
1102 f_vty_allow_osmux(allow_osmux);
1103 }
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001104
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001105 var my_BooleanList allow_attach := { false, false, false };
Daniel Willmannebdecc02020-08-12 15:30:17 +02001106 f_init_statsd("VirtMSC", vc_STATSD, mp_test_ip, mp_bsc_statsd_port);
1107
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001108 for (bssap_idx := 0; bssap_idx < nr_msc; bssap_idx := bssap_idx+1) {
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001109 allow_attach[bssap_idx] := true;
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001110 /* Call a function of our 'parent component' RAN_Adapter_CT to start the
1111 * MSC-side BSSAP emulation */
1112 if (handler_mode) {
1113 var RanOps ranops := MSC_RanOps;
1114 ranops.use_osmux := g_osmux_enabled;
1115 f_ran_adapter_init(g_bssap[bssap_idx], mp_bssap_cfg[bssap_idx], "VirtMSC", ranops);
1116 connect(self:SCCPLITE_IPA_CTRL, g_bssap[bssap_idx].vc_RAN:CTRL_CLIENT);
1117 f_ran_adapter_start(g_bssap[bssap_idx]);
1118 } else {
1119 f_ran_adapter_init(g_bssap[bssap_idx], mp_bssap_cfg[bssap_idx], "VirtMSC", omit);
1120 connect(self:BSSAP, g_bssap[bssap_idx].vc_SCCP:SCCP_SP_PORT);
1121 f_ran_adapter_start(g_bssap[bssap_idx]);
1122 f_legacy_bssap_reset();
1123 }
Harald Welte67089ee2018-01-17 22:19:03 +01001124 }
Harald Welted5833a82018-05-27 16:52:56 +02001125
Neels Hofmeyrcfe44062020-10-15 02:28:08 +02001126 if (mp_enable_lcs_tests) {
1127 if (handler_mode) {
1128 f_bssap_le_adapter_init(g_bssap_le, mp_bssap_le_cfg, "VirtSMLC", SMLC_BssapLeOps);
1129 } else {
1130 f_bssap_le_adapter_init(g_bssap_le, mp_bssap_le_cfg, "VirtSMLC", omit);
1131 connect(self:BSSAP_LE, g_bssap_le.vc_SCCP:SCCP_SP_PORT);
1132 }
1133 f_bssap_le_adapter_start(g_bssap_le);
Harald Welte47cd0e32020-08-21 12:39:11 +02001134 }
Harald Welte47cd0e32020-08-21 12:39:11 +02001135
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001136 /* start the test with exactly all enabled MSCs allowed to attach */
1137 f_vty_msc_allow_attach(BSCVTY, allow_attach);
1138
Pau Espin Pedrol9a5b8ff2021-01-04 19:01:31 +01001139 f_ipa_ctrl_start_client(mp_bsc_ip, mp_bsc_ctrl_port);
Harald Welte28d943e2017-11-25 15:00:50 +01001140
Daniel Willmann191e0d92018-01-17 12:44:35 +01001141 f_init_mgcp("VirtMSC");
1142
Neels Hofmeyr0b7365b2020-07-04 00:52:34 +02001143 for (var integer i := 0; i < nr_bts; i := i+1) {
1144 f_init_bts(i, handler_mode);
Harald Welte696ddb62017-12-08 14:01:43 +01001145 }
Neels Hofmeyr0b7365b2020-07-04 00:52:34 +02001146}
Harald Welte696ddb62017-12-08 14:01:43 +01001147
Neels Hofmeyr0b7365b2020-07-04 00:52:34 +02001148function f_init_bts(integer bts_idx := 0, boolean handler_mode := false)
1149runs on test_CT {
1150 /* wait until osmo-bts-omldummy has respawned */
1151 f_wait_oml(bts_idx, "degraded", 5.0);
1152
1153 /* start RSL connection */
1154 f_ipa_rsl_start(bts[bts_idx].rsl, mp_bsc_ip, mp_bsc_rsl_port, bts_idx, handler_mode);
1155 /* wait until BSC tells us "connected" */
1156 f_wait_oml(bts_idx, "connected", 5.0);
Harald Welte28d943e2017-11-25 15:00:50 +01001157}
1158
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02001159function f_init_bts_and_check_sysinfo(integer bts_idx := 0, boolean handler_mode := false,
1160 template SystemInformationConfig expect_si)
1161runs on test_CT {
1162 var default sysinfo := activate(as_catch_RSL_sysinfo(bts_idx));
1163
1164 f_init_bts(bts_idx, handler_mode);
1165
1166 /* Give some time to (hopefully/most likely) collect all system informations from RSL startup.
1167 * We could stop as soon as all expected SI are received, but then we might miss SI that we don't expect and
1168 * that might be sent afterwards. So rather give a generous timeout and be quite sure to catch all SI.
1169 */
1170 f_sleep(5.0);
1171 log("RSL ", bts_idx, " SYSTEM INFORMATION: ", g_system_information[bts_idx]);
1172
1173 deactivate(sysinfo);
1174
1175 if (match(g_system_information[bts_idx], expect_si)) {
1176 setverdict(pass);
1177 } else {
1178 log("RSL ", bts_idx, ": EXPECTED SI: ", expect_si);
1179 log("RSL ", bts_idx, ": GOT SI: ", g_system_information[bts_idx]);
1180 setverdict(fail, "received SI does not match expectations");
1181 return;
1182 }
1183}
1184
Maxd4e56962018-10-31 19:08:25 +01001185/* expect to receive a RSL message matching a specified template on a given BTS / stream */
Harald Welte65e419a2020-08-21 12:38:33 +02001186function f_exp_ipa_rx(integer bts_nr, template (present) RSL_Message t_rx, float t_secs := 2.0, IpaStreamId sid := IPAC_PROTO_RSL_TRX0)
Harald Welteae026692017-12-09 01:03:01 +01001187runs on test_CT return RSL_Message {
1188 var ASP_RSL_Unitdata rx_rsl_ud;
1189 timer T := t_secs;
1190
1191 T.start;
1192 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001193 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(t_rx, sid)) -> value rx_rsl_ud {
Harald Welteae026692017-12-09 01:03:01 +01001194 T.stop;
1195 }
1196 [] IPA_RSL[bts_nr].receive { repeat; }
Harald Welteb2917702017-12-10 15:48:52 +01001197 [] T.timeout {
1198 setverdict(fail, "Timeout expecting ", t_rx);
Daniel Willmannafce8662018-07-06 23:11:32 +02001199 mtc.stop;
Harald Welteb2917702017-12-10 15:48:52 +01001200 }
Harald Welteae026692017-12-09 01:03:01 +01001201 }
1202 return rx_rsl_ud.rsl;
1203}
1204
Harald Welte21b46bd2017-12-17 19:46:32 +01001205/* helper function to transmit RSL on a given BTS/stream */
Harald Welte65e419a2020-08-21 12:38:33 +02001206function f_ipa_tx(integer bts_nr, template (value) RSL_Message t_tx, IpaStreamId sid := IPAC_PROTO_RSL_TRX0)
Harald Welteae026692017-12-09 01:03:01 +01001207runs on test_CT {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001208 IPA_RSL[bts_nr].send(ts_ASP_RSL_UD(t_tx, sid));
Harald Welteae026692017-12-09 01:03:01 +01001209}
1210
1211
Harald Welte4003d112017-12-09 22:35:39 +01001212/* verify we get a CHAN_ACT after CHAN RQD */
Harald Welteae026692017-12-09 01:03:01 +01001213testcase TC_chan_act_noreply() runs on test_CT {
1214 var BSSAP_N_UNITDATA_ind ud_ind;
Harald Welte930d0a72018-03-22 22:08:40 +01001215 var RSL_Message rsl_unused;
Harald Welte28d943e2017-11-25 15:00:50 +01001216
Harald Welte89d42e82017-12-17 16:42:41 +01001217 f_init(1);
Harald Welte28d943e2017-11-25 15:00:50 +01001218
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001219 IPA_RSL[0].send(ts_ASP_RSL_UD(ts_RSL_CHAN_RQD('23'O, 23)));
Harald Welte930d0a72018-03-22 22:08:40 +01001220 rsl_unused := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001221 f_shutdown_helper();
Harald Welte28d943e2017-11-25 15:00:50 +01001222}
1223
Harald Welte4003d112017-12-09 22:35:39 +01001224/* verify if the "chreq:total" counter increments as expected */
1225testcase TC_chan_act_counter() runs on test_CT {
1226 var BSSAP_N_UNITDATA_ind ud_ind;
1227 var integer chreq_total;
Harald Welte930d0a72018-03-22 22:08:40 +01001228 var RSL_Message rsl_unused;
Harald Welte4003d112017-12-09 22:35:39 +01001229
Harald Welte89d42e82017-12-17 16:42:41 +01001230 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01001231
1232 chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total");
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001233 IPA_RSL[0].send(ts_ASP_RSL_UD(ts_RSL_CHAN_RQD('23'O, 23)));
Harald Welte930d0a72018-03-22 22:08:40 +01001234 rsl_unused := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
Harald Welte4003d112017-12-09 22:35:39 +01001235 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total", chreq_total+1);
1236
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001237 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01001238}
1239
Harald Welteae026692017-12-09 01:03:01 +01001240/* CHAN RQD -> CHAN ACT -> CHAN ACT ACK -> RF CHAN REL */
Philipp Maier9c60a622020-07-09 15:08:46 +02001241private function f_TC_chan_act_ack_noest(OCT1 ra := '23'O) runs on test_CT {
Harald Welteae026692017-12-09 01:03:01 +01001242 var RSL_Message rx_rsl;
1243
Harald Welteae026692017-12-09 01:03:01 +01001244 /* Send CHAN RQD and wait for allocation; acknowledge it */
Philipp Maier9c60a622020-07-09 15:08:46 +02001245 var RslChannelNr chan_nr := f_chreq_act_ack(ra);
Harald Welteae026692017-12-09 01:03:01 +01001246
1247 /* expect BSC to disable the channel again if there's no RLL EST IND */
1248 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX);
1249
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001250 f_shutdown_helper();
Harald Welteae026692017-12-09 01:03:01 +01001251}
1252
Philipp Maier9c60a622020-07-09 15:08:46 +02001253/* Normal variant */
1254testcase TC_chan_act_ack_noest() runs on test_CT {
Philipp Maieraf58db22020-08-12 17:24:40 +02001255 f_init(1);
Philipp Maier9c60a622020-07-09 15:08:46 +02001256 f_TC_chan_act_ack_noest();
1257}
1258
1259/* Emergency call variant */
1260testcase TC_chan_act_ack_noest_emerg() runs on test_CT {
1261 /* See also: 3GPP TS 04.08, Table 9.9, ra=101xxxxx */
Philipp Maieraf58db22020-08-12 17:24:40 +02001262 f_init(1);
1263 f_vty_allow_emerg_bts(true, 0);
Philipp Maier9c60a622020-07-09 15:08:46 +02001264 f_TC_chan_act_ack_noest(ra := 'A5'O);
1265}
1266
Philipp Maier606f07d2020-08-12 17:21:58 +02001267/* Emergency call variant, but emergency calls are not allowed */
1268testcase TC_chan_rqd_emerg_deny() runs on test_CT {
1269 /* See also: 3GPP TS 04.08, Table 9.9, ra=101xxxxx */
1270
1271 var RSL_Message rx_rsl;
1272 var GsmRrMessage rr;
1273
1274 f_init(1);
1275 f_vty_allow_emerg_bts(false, 0);
1276
1277 IPA_RSL[0].clear;
1278 f_ipa_tx(0, ts_RSL_CHAN_RQD('A5'O, 23));
1279
1280 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeC(RSL_MT_IMMEDIATE_ASSIGN_CMD));
1281 rr := dec_GsmRrMessage(rx_rsl.ies[1].body.full_imm_ass_info.payload);
1282 if (rr.header.message_type == IMMEDIATE_ASSIGNMENT_REJECT) {
1283 setverdict(pass);
1284 } else {
1285 setverdict(fail, "immediate assignment not rejected");
1286 }
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01001287
1288 f_shutdown_helper();
Philipp Maier606f07d2020-08-12 17:21:58 +02001289}
1290
Harald Welteae026692017-12-09 01:03:01 +01001291/* Test behavior if MSC never answers to CR */
1292testcase TC_chan_act_ack_est_ind_noreply() runs on test_CT {
Harald Weltef77aef62018-01-28 15:35:42 +01001293 var RslLinkId main_dcch := valueof(ts_RslLinkID_DCCH(0));
1294 var IpaStreamId sid := IPAC_PROTO_RSL_TRX0;
Harald Welteae026692017-12-09 01:03:01 +01001295 var RSL_Message rx_rsl;
Harald Weltef77aef62018-01-28 15:35:42 +01001296 var ASP_RSL_Unitdata rx_rsl_ud;
Harald Welteae026692017-12-09 01:03:01 +01001297
Harald Welte89d42e82017-12-17 16:42:41 +01001298 f_init(1);
Harald Welteae026692017-12-09 01:03:01 +01001299
1300 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +01001301 var RslChannelNr chan_nr := f_chreq_act_ack();
Harald Welteae026692017-12-09 01:03:01 +01001302
1303 var octetstring l3 := '00010203040506'O
1304 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
1305
1306 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3)));
1307
1308 /* expect BSC to disable the channel again if there's no response from MSC */
Harald Weltef77aef62018-01-28 15:35:42 +01001309 /* MS waits 20s (T3210) at LU; 10s (T3230) at CM SERV REQ and 5s (T3220) AT detach */
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001310 f_expect_chan_rel(0, chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001311 f_shutdown_helper();
Harald Welteae026692017-12-09 01:03:01 +01001312}
1313
1314/* Test behavior if MSC answers with CREF to CR */
1315testcase TC_chan_act_ack_est_ind_refused() runs on test_CT {
1316 var BSSAP_N_CONNECT_ind rx_c_ind;
1317 var RSL_Message rx_rsl;
1318
Harald Welte89d42e82017-12-17 16:42:41 +01001319 f_init(1);
Harald Welteae026692017-12-09 01:03:01 +01001320
1321 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +01001322 var RslChannelNr chan_nr := f_chreq_act_ack();
Harald Welteae026692017-12-09 01:03:01 +01001323
1324 var octetstring l3 := '00010203040506'O
1325 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
1326
1327 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
1328 BSSAP.send(ts_BSSAP_DISC_req(rx_c_ind.connectionId, 0));
1329
1330 /* expect BSC to disable the channel */
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001331 f_expect_chan_rel(0, chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001332 f_shutdown_helper();
Harald Welteae026692017-12-09 01:03:01 +01001333}
1334
Harald Welte618ef642017-12-14 14:58:20 +01001335/* CHAN RQD -> CHAN ACT -> CHAN ACT NACK -> RF CHAN REL */
1336testcase TC_chan_act_nack() runs on test_CT {
1337 var RSL_Message rx_rsl;
1338 var integer chact_nack;
1339
Harald Welte89d42e82017-12-17 16:42:41 +01001340 f_init(1);
Harald Welte618ef642017-12-14 14:58:20 +01001341
1342 chact_nack := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chan_act:nack");
1343
1344 f_ipa_tx(0, ts_RSL_CHAN_RQD('33'O, 33));
1345 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
1346 var RslChannelNr chan_nr := rx_rsl.ies[0].body.chan_nr;
1347
1348 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, RSL_ERR_EQUIPMENT_FAIL));
1349
1350 /* wait for some time to hope the NACK arrives before the CTRL GET below */
1351 f_sleep(0.5);
1352
1353 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chan_act:nack", chact_nack+1);
1354
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001355 f_shutdown_helper();
Harald Welte618ef642017-12-14 14:58:20 +01001356}
1357
Harald Welte799c97b2017-12-14 17:50:30 +01001358/* Test for channel exhaustion due to RACH overload */
1359testcase TC_chan_exhaustion() runs on test_CT {
1360 var ASP_RSL_Unitdata rsl_ud;
1361 var integer i;
1362 var integer chreq_total, chreq_nochan;
1363
Harald Welte89d42e82017-12-17 16:42:41 +01001364 f_init(1);
Harald Welte799c97b2017-12-14 17:50:30 +01001365
1366 chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total");
1367 chreq_nochan := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel");
1368
Pau Espin Pedrolfe200d72018-12-10 12:41:04 +01001369 /* GSM 04.08 Table 9.9a:
1370 * RA = '33'O -> Establishment cause = 0011xxxx (MS dual rate capable and asks for "TCH/H or TCH/F").
1371 * With current setup, expect 4xSDCCH + 4xTCH/F + 1xTCH/H to succeed */
Philipp Maiercb6cc482018-03-26 13:08:00 +02001372 for (i := 0; i < NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS; i := i+1) {
Pau Espin Pedrolfe200d72018-12-10 12:41:04 +01001373 var RslChannelNr chan_nr := f_chreq_act_ack('33'O, i);
Harald Welte799c97b2017-12-14 17:50:30 +01001374 }
1375
1376 IPA_RSL[0].clear;
1377
Harald Weltedd8cbf32018-01-28 12:07:52 +01001378 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total",
Philipp Maiercb6cc482018-03-26 13:08:00 +02001379 chreq_total + NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS);
Harald Welte799c97b2017-12-14 17:50:30 +01001380
1381 /* now expect additional channel activations to fail */
1382 f_ipa_tx(0, ts_RSL_CHAN_RQD('42'O, 42));
1383
1384 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001385 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV))) {
Harald Welte799c97b2017-12-14 17:50:30 +01001386 setverdict(fail, "Received CHAN ACT ACK without resources?!?");
1387 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001388 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_IMM_ASSIGN(?))) -> value rsl_ud {
Harald Welte799c97b2017-12-14 17:50:30 +01001389 var GsmRrMessage rr;
1390 /* match on IMM ASS REJ */
1391 rr := dec_GsmRrMessage(rsl_ud.rsl.ies[1].body.full_imm_ass_info.payload);
1392 if (rr.header.message_type == IMMEDIATE_ASSIGNMENT_REJECT) {
1393 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total",
Philipp Maiercb6cc482018-03-26 13:08:00 +02001394 chreq_total + NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS+1);
Harald Welte799c97b2017-12-14 17:50:30 +01001395 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel",
1396 chreq_nochan+1);
1397 setverdict(pass);
1398 } else {
1399 repeat;
1400 }
1401 }
1402 [] IPA_RSL[0].receive { repeat; }
1403 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001404 f_shutdown_helper();
Harald Welte799c97b2017-12-14 17:50:30 +01001405}
1406
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07001407/* Test channel deactivation due to silence from MS */
1408testcase TC_chan_deact_silence() runs on test_CT {
1409 var RslChannelNr chan_nr;
1410
1411 f_init(1);
1412
1413 /* Request for a dedicated channel */
1414 chan_nr := f_chreq_act_ack('23'O);
1415
1416 /* Wait some time until the channel is released */
1417 f_sleep(2.0);
1418
1419 /* Expect CHANnel RELease */
1420 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001421 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL))) {
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07001422 log("Received CHANnel RELease");
1423 setverdict(pass);
1424 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001425 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_IMM_ASSIGN(?))) {
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07001426 /* See OS#3709, OsmoBSC should not send Immediate
1427 * Assignment Reject since a dedicated channel was
1428 * already allocated, and Immediate Assignment was
1429 * already sent. */
1430 setverdict(fail, "Unexpected Immediate Assignment!");
1431 }
1432 [] IPA_RSL[0].receive {
1433 setverdict(fail, "Unexpected RSL message!");
1434 }
1435 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001436 f_shutdown_helper();
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07001437}
1438
Harald Weltecfe2c962017-12-15 12:09:32 +01001439/***********************************************************************
1440 * Assignment Testing
1441 ***********************************************************************/
1442
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02001443/* Verify that the BSC refuses any BSSAP connection from the MSC (They are all BSC->MSC direction,
1444 * except for the inter-BSC handover, MT side) */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001445testcase TC_outbound_connect(integer bssap_idx := 0) runs on test_CT {
Harald Welte89d42e82017-12-17 16:42:41 +01001446 f_init(1);
Harald Weltecfe2c962017-12-15 12:09:32 +01001447
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001448 BSSAP.send(ts_BSSAP_CONNECT_req(g_bssap[bssap_idx].sccp_addr_peer, g_bssap[bssap_idx].sccp_addr_own,
1449 2342, ts_BSSMAP_AssignmentReq));
Harald Weltecfe2c962017-12-15 12:09:32 +01001450 BSSAP.receive(tr_BSSAP_DISC_ind(2342, ?, ?));
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001451 f_shutdown_helper();
Harald Weltecfe2c962017-12-15 12:09:32 +01001452}
1453
Harald Welte16a4adf2017-12-14 18:54:01 +01001454/* Test behavior if MSC answers with CREF to CR */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001455testcase TC_assignment_cic_only(integer bssap_idx := 0) runs on test_CT {
Harald Welte16a4adf2017-12-14 18:54:01 +01001456 var BSSAP_N_CONNECT_ind rx_c_ind;
1457 var RSL_Message rx_rsl;
1458 var DchanTuple dt;
1459
Harald Welte89d42e82017-12-17 16:42:41 +01001460 f_init(1);
Harald Welte16a4adf2017-12-14 18:54:01 +01001461
1462 dt := f_est_dchan('23'O, 23, '00000000'O);
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001463 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welte17b27da2018-05-25 20:33:53 +02001464 /* send assignment without AoIP IEs */
1465 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_AssignmentReq(ts_BSSMAP_IE_CIC(0, 1))));
1466 } else {
1467 /* Send assignmetn without CIC in IPA case */
1468 var BSSMAP_IE_AoIP_TransportLayerAddress tla :=
1469 valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342));
1470 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_AssignmentReq(omit, tla)));
1471 }
Harald Welte16a4adf2017-12-14 18:54:01 +01001472 alt {
1473 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentComplete)) {
1474 setverdict(fail, "AoIP BSC cannot accept ASSIGNMENT without AoIP Transport IE");
1475 }
Harald Welte235ebf12017-12-15 14:18:16 +01001476 /* TODO: Actually expect GSM0808_CAUSE_REQ_A_IF_TYPE_NOT_SUPP */
Harald Welte16a4adf2017-12-14 18:54:01 +01001477 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentFail)) {
1478 setverdict(pass);
1479 }
1480 [] BSSAP.receive { repeat; }
1481 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001482 f_shutdown_helper();
Harald Welte16a4adf2017-12-14 18:54:01 +01001483}
1484
Harald Welteed848512018-05-24 22:27:58 +02001485/* generate an assignment request for either AoIP or SCCPlite */
Pau Espin Pedrol07866632020-09-03 19:10:55 +02001486function f_gen_ass_req(boolean osmux_enabled := false, integer bssap_idx := 0, charstring aoip_tla := "1.2.3.4") return PDU_BSSAP {
Harald Welteed848512018-05-24 22:27:58 +02001487 var PDU_BSSAP ass_cmd;
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001488 var BSSMAP_IE_Osmo_OsmuxCID osmux_cid := valueof(ts_OsmuxCID(0));
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001489 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welteed848512018-05-24 22:27:58 +02001490 var BSSMAP_IE_AoIP_TransportLayerAddress tla :=
Pau Espin Pedrol07866632020-09-03 19:10:55 +02001491 valueof(f_ts_BSSMAP_IE_AoIP_TLA(aoip_tla, 2342));
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001492 if (osmux_enabled) {
1493 ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla, osmux_cid));
1494 } else {
1495 ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla));
1496 }
Harald Welteed848512018-05-24 22:27:58 +02001497 } else {
1498 var BSSMAP_IE_CircuitIdentityCode cic := valueof(ts_BSSMAP_IE_CIC(0,1));
Pau Espin Pedrol096d73d2019-06-06 12:49:17 +02001499 ass_cmd := valueof(ts_BSSMAP_AssignmentReq(cic, omit));
Harald Welteed848512018-05-24 22:27:58 +02001500 }
1501 return ass_cmd;
1502}
1503
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02001504function f_gen_handover_req(integer bssap_idx := 0, charstring aoip_tla := "1.2.3.4",
1505 template (omit) BSSMAP_oldToNewBSSIEs oldToNewBSSIEs := omit) return PDU_BSSAP {
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01001506 var PDU_BSSAP ho_req;
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001507 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01001508 var BSSMAP_IE_AoIP_TransportLayerAddress tla :=
Pau Espin Pedrol07866632020-09-03 19:10:55 +02001509 valueof(f_ts_BSSMAP_IE_AoIP_TLA(aoip_tla, 2342));
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02001510 ho_req := valueof(ts_BSSMAP_HandoverRequest(omit, tla, oldToNewBSSIEs := oldToNewBSSIEs));
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01001511 } else {
1512 var BSSMAP_IE_CircuitIdentityCode cic := valueof(ts_BSSMAP_IE_CIC(0,1));
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02001513 ho_req := valueof(ts_BSSMAP_HandoverRequest(cic, omit, oldToNewBSSIEs := oldToNewBSSIEs));
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01001514 }
1515 return ho_req;
1516}
1517
Harald Welteed848512018-05-24 22:27:58 +02001518/* generate an assignment complete template for either AoIP or SCCPlite */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001519function f_gen_exp_compl(boolean expect_osmux := false, integer bssap_idx := 0) return template PDU_BSSAP {
Harald Welteed848512018-05-24 22:27:58 +02001520 var template PDU_BSSAP exp_compl;
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001521 var BSSMAP_IE_Osmo_OsmuxCID osmux_cid := valueof(ts_OsmuxCID(0));
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001522 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001523 if (expect_osmux) {
1524 exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?, osmux_cid);
1525 } else {
1526 exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?, omit);
1527 }
Harald Welteed848512018-05-24 22:27:58 +02001528 } else {
1529 /* CIC is optional "*" as the MSC allocated it */
Pau Espin Pedrol096d73d2019-06-06 12:49:17 +02001530 exp_compl := tr_BSSMAP_AssignmentComplete(*, omit);
Harald Welteed848512018-05-24 22:27:58 +02001531 }
1532 return exp_compl;
1533}
1534
Harald Welte235ebf12017-12-15 14:18:16 +01001535/* Run everything required up to sending a caller-specified assignment command and expect response */
1536function f_assignment_exp(PDU_BSSAP ass_cmd, template PDU_BSSAP exp, charstring fail_text)
1537runs on test_CT {
1538 var BSSAP_N_CONNECT_ind rx_c_ind;
1539 var RSL_Message rx_rsl;
1540 var DchanTuple dt;
1541
Harald Welte89d42e82017-12-17 16:42:41 +01001542 f_init(1);
Harald Welte235ebf12017-12-15 14:18:16 +01001543
1544 dt := f_est_dchan('23'O, 23, '00000000'O);
1545 /* send assignment without AoIP IEs */
1546 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ass_cmd));
1547 alt {
1548 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentComplete)) {
1549 if (ischosen(exp.pdu.bssmap.assignmentComplete)) {
1550 setverdict(pass);
1551 } else {
1552 setverdict(fail, fail_text);
1553 }
1554 }
1555 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentFail)) {
1556 if (ischosen(exp.pdu.bssmap.assignmentFailure)) {
1557 setverdict(pass);
1558 } else {
1559 setverdict(fail, fail_text);
1560 }
1561 }
1562 [] BSSAP.receive { repeat; }
1563 }
1564}
1565testcase TC_assignment_csd() runs on test_CT {
1566 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +02001567 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte235ebf12017-12-15 14:18:16 +01001568 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeCSD);
1569 //exp_fail.pdu.bssmap.assignmentFailure.cause.causeValue := int2bit(enum2int(GSM0808_CAUSE_REQ_CODEC_TYPE_OR_CONFIG_UNAVAIL), 7);
1570 f_assignment_exp(ass_cmd, exp_fail, "BSC accepted Assignment for CSD");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001571 f_shutdown_helper();
Harald Welte235ebf12017-12-15 14:18:16 +01001572}
1573
1574testcase TC_assignment_ctm() runs on test_CT {
1575 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +02001576 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte235ebf12017-12-15 14:18:16 +01001577 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeCTM);
1578 //exp_fail.pdu.bssmap.assignmentFailure.cause.causeValue := int2bit(enum2int(GSM0808_CAUSE_REQ_CODEC_TYPE_OR_CONFIG_UNAVAIL), 7);
1579 f_assignment_exp(ass_cmd, exp_fail, "BSC accepted Assignment for Speech+CTM");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001580 f_shutdown_helper();
Harald Welte235ebf12017-12-15 14:18:16 +01001581}
1582
Harald Welte4003d112017-12-09 22:35:39 +01001583type record DchanTuple {
1584 integer sccp_conn_id,
1585 RslChannelNr rsl_chan_nr
Harald Weltea5d2ab22017-12-09 14:21:42 +01001586}
1587
Harald Welted6939652017-12-13 21:02:46 +01001588/* Send CHAN RQD and wait for allocation; acknowledge it */
1589private function f_chreq_act_ack(OCT1 ra := '23'O, GsmFrameNumber fn := 23)
1590runs on test_CT return RslChannelNr {
1591 var RSL_Message rx_rsl;
1592 f_ipa_tx(0, ts_RSL_CHAN_RQD(ra, fn));
1593 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
1594 var RslChannelNr chan_nr := rx_rsl.ies[0].body.chan_nr;
1595 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, fn+10));
Daniel Willmannf4ac4ce2018-08-02 14:06:30 +02001596 rx_rsl := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
Harald Welted6939652017-12-13 21:02:46 +01001597 return chan_nr;
1598}
1599
Harald Welte4003d112017-12-09 22:35:39 +01001600/* helper function to establish a dedicated channel via BTS and MSC */
1601function f_est_dchan(OCT1 ra, GsmFrameNumber fn, octetstring l3)
1602runs on test_CT return DchanTuple {
1603 var BSSAP_N_CONNECT_ind rx_c_ind;
Harald Welte4003d112017-12-09 22:35:39 +01001604 var DchanTuple dt;
Harald Weltea5d2ab22017-12-09 14:21:42 +01001605
Harald Welte4003d112017-12-09 22:35:39 +01001606 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +01001607 dt.rsl_chan_nr := f_chreq_act_ack(ra, fn);
Harald Welte4003d112017-12-09 22:35:39 +01001608
1609 f_ipa_tx(0, ts_RSL_EST_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
1610
1611 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
1612 dt.sccp_conn_id := rx_c_ind.connectionId;
1613 BSSAP.send(ts_BSSAP_CONNECT_res(dt.sccp_conn_id));
1614
1615 return dt;
Harald Weltea5d2ab22017-12-09 14:21:42 +01001616}
1617
Harald Welte641fcbe2018-06-14 10:58:35 +02001618/* expect RF CAN REL from BTS, acknowledge it and clear the MSC side */
1619private function f_exp_chan_rel_and_clear(DchanTuple dt, integer bts_nr := 0) runs on test_CT {
1620 var RSL_Message rx_rsl;
1621 /* expect BSC to disable the channel */
1622 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX);
1623 /* respond with CHAN REL ACK */
1624 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
1625
1626 /* expect Clear Complete from BSC */
1627 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete));
1628
1629 /* MSC disconnects as instructed. */
1630 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1631}
1632
Harald Welte4003d112017-12-09 22:35:39 +01001633/* Test behavior of channel release after unilateral RLL REL IND (DISC from MS) */
1634testcase TC_chan_rel_rll_rel_ind() runs on test_CT {
Neels Hofmeyr27f64362018-03-12 01:44:00 +01001635 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +01001636 var DchanTuple dt;
Harald Welte96c94412017-12-09 03:12:45 +01001637
Harald Welte89d42e82017-12-17 16:42:41 +01001638 f_init(1);
Harald Welte96c94412017-12-09 03:12:45 +01001639
Harald Welte4003d112017-12-09 22:35:39 +01001640 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1641
1642 /* simulate RLL REL IND */
1643 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0))));
1644
Neels Hofmeyr27f64362018-03-12 01:44:00 +01001645 /* expect Clear Request on MSC side */
1646 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
1647
1648 /* Instruct BSC to clear channel */
1649 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
1650 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
1651
Harald Welte4003d112017-12-09 22:35:39 +01001652 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02001653 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyr27f64362018-03-12 01:44:00 +01001654
1655 /* wait for SCCP emulation to do its job */
1656 f_sleep(1.0);
Harald Welte4003d112017-12-09 22:35:39 +01001657
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001658 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01001659}
1660
1661/* Test behavior of channel release after CONN FAIL IND from BTS */
1662testcase TC_chan_rel_conn_fail() runs on test_CT {
1663 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +01001664 var DchanTuple dt;
1665
Harald Welte89d42e82017-12-17 16:42:41 +01001666 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01001667
1668 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1669
1670 /* simulate CONN FAIL IND */
Harald Weltea8ed9062017-12-14 09:46:01 +01001671 f_ipa_tx(0, ts_RSL_CONN_FAIL_IND(dt.rsl_chan_nr, RSL_ERR_RADIO_LINK_FAIL));
Harald Welte4003d112017-12-09 22:35:39 +01001672 /* TODO: different cause values? */
1673
Harald Welte4003d112017-12-09 22:35:39 +01001674 /* expect Clear Request from BSC */
1675 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
1676
1677 /* Instruct BSC to clear channel */
1678 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
1679 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
1680
Harald Welte6ff76ea2018-01-28 13:08:01 +01001681 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02001682 f_exp_chan_rel_and_clear(dt, 0);
Harald Welte4003d112017-12-09 22:35:39 +01001683
1684 /* wait for SCCP emulation to do its job */
1685 f_sleep(1.0);
1686
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001687 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01001688}
1689
Harald Welte99f3ca02018-06-14 13:40:29 +02001690/* Test behavior of early CONN FAIL IND from BTS (before EST IND!) */
1691/* See also https://www.osmocom.org/issues/3182 */
1692testcase TC_early_conn_fail() runs on test_CT {
1693 var RSL_Message rx_rsl;
1694 var DchanTuple dt;
1695
1696 f_init(1);
1697
1698 /* BTS->BSC: Send CHAN RQD and wait for allocation; acknowledge it */
Harald Weltec46ea3c2020-10-10 18:46:12 +02001699 dt.rsl_chan_nr := f_chreq_act_ack(f_rnd_ra_cs(), 23);
Harald Welte99f3ca02018-06-14 13:40:29 +02001700
1701 /* BTS->BSC: simulate CONN FAIL IND */
1702 f_ipa_tx(0, ts_RSL_CONN_FAIL_IND(dt.rsl_chan_nr, RSL_ERR_RADIO_LINK_FAIL));
1703
1704 /* BTS->BSC: Expect RF channel release from BSC on Abis */
1705 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), 10.0);
1706
1707 /* BTS<-BSC: respond with CHAN REL ACK */
1708 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
1709
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001710 f_shutdown_helper();
Harald Welte99f3ca02018-06-14 13:40:29 +02001711}
1712
1713/* Test behavior of late CONN FAIL IND from BTS (ater REL IND!) */
1714/* See also https://www.osmocom.org/issues/3182 */
1715testcase TC_late_conn_fail() runs on test_CT {
1716 var RSL_Message rx_rsl;
1717 var DchanTuple dt;
1718
1719 f_init(1);
1720
1721 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1722
1723 /* BSC<-MSC: Instruct BSC to clear connection */
1724 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(0)));
1725
1726 /* BTS->BSC: expect BSC to deactivate SACCH */
1727 rx_rsl := f_exp_ipa_rx(0, tr_RSL_DEACT_SACCH(dt.rsl_chan_nr));
1728
1729 /* BTS->BSC: simulate a late CONN FAIL IND from BTS */
1730 f_ipa_tx(0, ts_RSL_CONN_FAIL_IND(dt.rsl_chan_nr, RSL_ERR_RADIO_LINK_FAIL));
1731
1732 /* BTS<-BSC: Expect RF channel release from BSC on Abis */
1733 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), 10.0);
1734 /* BTS->BSC: respond with CHAN REL ACK */
1735 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
1736
1737 /* BSC->MSC: expect Clear Complete from BSC */
1738 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete));
1739
1740 /* BSC<-MSC: MSC disconnects as requested. */
1741 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1742
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001743 f_shutdown_helper();
Harald Welte99f3ca02018-06-14 13:40:29 +02001744}
1745
Neels Hofmeyrf44ccd12018-11-05 19:15:23 +01001746function f_expect_chan_rel(integer bts_nr, RslChannelNr rsl_chan_nr,
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001747 boolean expect_deact_sacch := true,
1748 boolean expect_rr_chan_rel := true,
1749 boolean expect_rll_rel_req := true,
Harald Welte99787102019-02-04 10:41:36 +01001750 boolean handle_rll_rel := true,
Pau Espin Pedrol36bd4fa2021-04-15 13:00:24 +02001751 template CellSelIndValue expect_cells := omit,
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001752 template RR_Cause expect_rr_cause := ?
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001753 ) runs on test_CT {
Harald Welte91d54a52018-01-28 15:35:07 +01001754
1755 var RslLinkId main_dcch := valueof(ts_RslLinkID_DCCH(0));
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001756 var boolean got_deact_sacch := false;
1757 var boolean got_rr_chan_rel := false;
1758 var boolean got_rll_rel_req := false;
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001759 var ASP_RSL_Unitdata ud;
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001760 var RSL_IE_Body l3_ie;
1761 var PDU_ML3_NW_MS l3;
1762 var RR_Cause got_cause;
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001763 log("f_expect_chan_rel() expecting: expect_deact_sacch=", expect_deact_sacch, " expect_rr_chan_rel=", expect_rr_chan_rel,
1764 " expect_rll_rel_req=", expect_rll_rel_req);
Harald Welte91d54a52018-01-28 15:35:07 +01001765 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001766 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_DEACT_SACCH(rsl_chan_nr))) {
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001767 got_deact_sacch := true;
Harald Welte91d54a52018-01-28 15:35:07 +01001768 repeat;
1769 }
Pau Espin Pedrol841b90d2021-04-15 16:42:52 +02001770 [not istemplatekind(expect_cells, "omit")] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_DATA_REQ(rsl_chan_nr, ?, decmatch tr_RRM_RR_RELEASE_CellSelectInd))) -> value ud {
Harald Welte99787102019-02-04 10:41:36 +01001771 got_rr_chan_rel := true;
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001772
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001773 if (f_rsl_find_ie(ud.rsl, RSL_IE_L3_INFO, l3_ie) == false) {
1774 setverdict(fail, "cannot find L3");
1775 mtc.stop;
1776 }
1777 l3 := dec_PDU_ML3_NW_MS(l3_ie.l3_info.payload);
1778
Pau Espin Pedrol36bd4fa2021-04-15 13:00:24 +02001779 if (not istemplatekind(expect_cells, "omit")) {
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001780 var CellSelIndValue cells := dec_CellSelIndValue(
1781 l3.msgs.rrm.channelRelease.cellSelectionIndicator.cellSelectionIndicatorValue);
1782
Pau Espin Pedrol36bd4fa2021-04-15 13:00:24 +02001783 log("GOT RR CHANNEL RELEASE WITH CELLS: ", cells);
1784 if (match(cells, expect_cells)) {
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001785 setverdict(pass);
1786 } else {
Pau Espin Pedrol36bd4fa2021-04-15 13:00:24 +02001787 log("EXPECTED CELLS: ", expect_cells);
1788 setverdict(fail, "Received cells list on RR Channel Release does not match expectations");
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001789 }
1790 }
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001791
1792 if (not istemplatekind(expect_rr_cause, "omit")) {
1793 int2enum(oct2int(l3.msgs.rrm.channelRelease.rRCause.valuePart), got_cause);
1794 log("GOT CAUSE CODE: ", l3.msgs.rrm.channelRelease.rRCause.valuePart, " = ", got_cause);
1795 if (match(got_cause, expect_rr_cause)) {
1796 setverdict(pass);
1797 } else {
1798 log("EXPECTED CAUSE CODE: ", expect_rr_cause);
1799 setverdict(fail, "Received RR Channel Release Cause code does not match expectations");
1800 }
1801 }
Harald Welte99787102019-02-04 10:41:36 +01001802 repeat;
1803 }
Pau Espin Pedrol841b90d2021-04-15 16:42:52 +02001804 [istemplatekind(expect_cells, "omit")] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_DATA_REQ(rsl_chan_nr, ?, decmatch tr_RRM_RR_RELEASE))) -> value ud {
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001805 got_rr_chan_rel := true;
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001806
1807 if (not istemplatekind(expect_rr_cause, "omit")) {
1808 if (f_rsl_find_ie(ud.rsl, RSL_IE_L3_INFO, l3_ie) == false) {
1809 setverdict(fail, "cannot find L3");
1810 mtc.stop;
1811 }
1812 l3 := dec_PDU_ML3_NW_MS(l3_ie.l3_info.payload);
1813
1814 int2enum(oct2int(l3.msgs.rrm.channelRelease.rRCause.valuePart), got_cause);
1815 log("GOT CAUSE CODE: ", l3.msgs.rrm.channelRelease.rRCause.valuePart, " = ", got_cause);
1816 if (match(got_cause, expect_rr_cause)) {
1817 setverdict(pass);
1818 } else {
1819 log("EXPECTED CAUSE CODE: ", expect_rr_cause);
1820 setverdict(fail, "Received RR Channel Release Cause code does not match expectations");
1821 }
1822 }
Neels Hofmeyr211169d2018-11-07 00:37:29 +01001823 repeat;
1824 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001825 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_REL_REQ(rsl_chan_nr, ?))) {
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001826 got_rll_rel_req := true;
Harald Welte91d54a52018-01-28 15:35:07 +01001827 /* FIXME: Why are we getting this for LinkID SACCH? */
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001828 if (handle_rll_rel) {
1829 f_ipa_tx(0, ts_RSL_REL_CONF(rsl_chan_nr, main_dcch));
1830 }
Harald Welte91d54a52018-01-28 15:35:07 +01001831 repeat;
1832 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001833 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL))) {
Harald Welte91d54a52018-01-28 15:35:07 +01001834 /* respond with CHAN REL ACK */
1835 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(rsl_chan_nr));
1836 }
1837 /* ignore any user data */
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001838 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeR(?))) {
Harald Welte91d54a52018-01-28 15:35:07 +01001839 repeat;
1840 }
1841 }
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001842
1843 log("f_expect_chan_rel() summary: got_deact_sacch=", got_deact_sacch, " got_rr_chan_rel=", got_rr_chan_rel,
1844 " got_rll_rel_req=", got_rll_rel_req);
1845
1846 if (expect_deact_sacch != got_deact_sacch) {
1847 setverdict(fail, "f_expect_chan_rel(): expect_deact_sacch=", expect_deact_sacch, " got_deact_sacch=", got_deact_sacch);
1848 }
1849 if (expect_rr_chan_rel != got_rr_chan_rel) {
1850 setverdict(fail, "f_expect_chan_rel(): expect_rr_chan_rel=", expect_rr_chan_rel, " got_rr_chan_rel=", got_rr_chan_rel);
1851 }
1852 if (expect_rll_rel_req != got_rll_rel_req) {
1853 setverdict(fail, "f_expect_chan_rel(): expect_rll_rel_req=", expect_rll_rel_req, " got_rll_rel_req=", got_rll_rel_req);
1854 }
Harald Welte91d54a52018-01-28 15:35:07 +01001855}
1856
Harald Welte4003d112017-12-09 22:35:39 +01001857/* Test behavior of channel release after hard Clear Command from MSC */
1858testcase TC_chan_rel_hard_clear() runs on test_CT {
1859 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +01001860 var DchanTuple dt;
Harald Welte4003d112017-12-09 22:35:39 +01001861
Harald Welte89d42e82017-12-17 16:42:41 +01001862 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01001863
1864 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1865
1866 /* Instruct BSC to clear channel */
1867 var BssmapCause cause := 0;
1868 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
1869
1870 /* expect Clear Complete from BSC on A */
1871 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
1872 /* release the SCCP connection */
1873 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1874 }
1875
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001876 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001877 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01001878}
1879
Pau Espin Pedrol841b90d2021-04-15 16:42:52 +02001880function f_TC_chan_rel_last_eutran_plmn_hard_clear(boolean tx_csfb_ind) runs on test_CT {
1881 var BSSAP_N_DATA_ind rx_di;
1882 var DchanTuple dt;
1883
1884 f_init(1);
1885
1886 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1887 /* Send CommonID with some random PLMN (BSC doesn't take it into account
1888 /* yet when generating the EUTRAN neigh list in RR CHannel Release) */
1889 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_CommonId('001019876543210'H, '323454'O)));
1890
1891 /* Instruct BSC to clear channel */
1892 var BssmapCause cause := 0;
1893 if (tx_csfb_ind) {
1894 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommandCSFB(cause)));
1895 } else {
1896 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
1897 }
1898
1899 /* expect Clear Complete from BSC on A */
1900 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
1901 /* release the SCCP connection */
1902 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1903 }
1904
1905 /* 1 neighbor is added by default in osmo-bts.cfg and
1906 SystemInformationConfig_default, use that: */
1907 var template CellSelIndValue exp_cells := f_tr_rr_chan_rel_earfcns(1);
1908
1909 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false, expect_cells := exp_cells);
1910 f_shutdown_helper();
1911}
1912
1913/* Test behavior of RR Channel rRelease after Clear Command without CSFB indicator
1914 from MSC, previously receiving any CommonID containing the "Last Used E-UTRAN
1915 PLMN Id". According to spec (3GPP TS 48.008 sec 3.1.30) that's the bit requesting
1916 EUTRAN neighbor list sent later on by BSC in RR Channel, so receiving CSFB
1917 Indicator or not shouldn't matter at all. */
1918testcase TC_chan_rel_last_eutran_plmn_hard_clear_no_csfb() runs on test_CT {
1919 f_TC_chan_rel_last_eutran_plmn_hard_clear(false);
1920}
1921
1922/* Test behavior of RR Channel rRelease after Clear Command with CSFB indicator from
1923 MSC, previously receiving any CommonID containing the "Last Used E-UTRAN PLMN
1924 Id". According to spec (3GPP TS 48.008 sec 3.1.30) that's the bit requesting
1925 EUTRAN neighbor list sent later on by BSC in RR Channel. */
1926testcase TC_chan_rel_last_eutran_plmn_hard_clear_csfb() runs on test_CT {
1927 f_TC_chan_rel_last_eutran_plmn_hard_clear(true);
1928}
1929
1930/* Test behavior of RR Channel Release after Clear Command with CSFB indicator from
1931 MSC, without receiving any CommonID containing the "Last Used E-UTRAN PLMN
1932 Id". According to spec (TS 48.008 version 16.0.0 Release 16 "3.2.1.21") the
1933 CSFB Indicator should not be used anymore, and hence, there should be no
1934 EUTRAN neighbor list sent by BSC in RR Channel release since no CommonId with
1935 Last Used E-UTRAN PLMN Id" IE was sent for this conn. */
Harald Welte99787102019-02-04 10:41:36 +01001936testcase TC_chan_rel_hard_clear_csfb() runs on test_CT {
1937 var BSSAP_N_DATA_ind rx_di;
1938 var DchanTuple dt;
1939
1940 f_init(1);
1941
1942 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1943
1944 /* Instruct BSC to clear channel */
1945 var BssmapCause cause := 0;
1946 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommandCSFB(cause)));
1947
1948 /* expect Clear Complete from BSC on A */
1949 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
1950 /* release the SCCP connection */
1951 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1952 }
1953
Pau Espin Pedrol841b90d2021-04-15 16:42:52 +02001954 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001955 f_shutdown_helper();
Harald Welte99787102019-02-04 10:41:36 +01001956}
1957
Harald Welted8c36cd2017-12-09 23:05:31 +01001958/* Test behavior of channel release after hard RLSD from MSC */
1959testcase TC_chan_rel_hard_rlsd() runs on test_CT {
Harald Welted8c36cd2017-12-09 23:05:31 +01001960 var DchanTuple dt;
Harald Welted8c36cd2017-12-09 23:05:31 +01001961
Harald Welte89d42e82017-12-17 16:42:41 +01001962 f_init(1);
Harald Welted8c36cd2017-12-09 23:05:31 +01001963
1964 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1965
1966 /* release the SCCP connection */
1967 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1968
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001969 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001970 f_shutdown_helper();
Harald Welted8c36cd2017-12-09 23:05:31 +01001971}
1972
Harald Welte550daf92018-06-11 19:22:13 +02001973/* Test behavior of channel release after hard RLSD from MSC and MS is not responding to RLL REL REQ */
1974testcase TC_chan_rel_hard_rlsd_ms_dead() runs on test_CT {
1975 var DchanTuple dt;
1976
1977 f_init(1);
1978
1979 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1980
1981 /* release the SCCP connection */
1982 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1983
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001984 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001985 f_shutdown_helper();
Harald Welte550daf92018-06-11 19:22:13 +02001986}
1987
Harald Welte85804d42017-12-10 14:11:58 +01001988/* Test behavior of channel release after BSSMAP RESET from MSC */
1989testcase TC_chan_rel_a_reset() runs on test_CT {
Harald Welte85804d42017-12-10 14:11:58 +01001990 var DchanTuple dt;
Harald Welte85804d42017-12-10 14:11:58 +01001991
Harald Welte89d42e82017-12-17 16:42:41 +01001992 f_init(1);
Harald Welte85804d42017-12-10 14:11:58 +01001993
1994 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1995
1996 /* Clear the queue, it might still contain stuff like IMMEDIATE ASSIGN */
1997 IPA_RSL[0].clear;
1998
1999 /* perform BSSAP RESET, expect RESET ACK and DISC.ind on connection */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02002000 BSSAP.send(ts_BSSAP_UNITDATA_req(g_bssap[0].sccp_addr_peer, g_bssap[0].sccp_addr_own, ts_BSSMAP_Reset(0, g_osmux_enabled)));
Harald Welte85804d42017-12-10 14:11:58 +01002001 interleave {
Neels Hofmeyrf246a922020-05-13 02:27:10 +02002002 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(g_bssap[0].sccp_addr_own, g_bssap[0].sccp_addr_peer, tr_BSSMAP_ResetAck(g_osmux_enabled))) { }
Harald Welte85804d42017-12-10 14:11:58 +01002003 [] BSSAP.receive(tr_BSSAP_DISC_ind(dt.sccp_conn_id, ?, ?)) { }
2004 }
2005
Neels Hofmeyra5302c82018-11-04 23:09:58 +01002006 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002007 f_shutdown_helper();
Harald Welte85804d42017-12-10 14:11:58 +01002008}
2009
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01002010/* Verify T(iar) triggers and releases the channel */
2011testcase TC_chan_rel_sccp_tiar_timeout() runs on test_CT {
2012 var DchanTuple dt;
2013
2014 /* Set T(iar) in BSC low enough that it will trigger before other side
2015 has time to keep alive with a T(ias). Keep recommended ratio of
2016 T(iar) >= T(ias)*2 */
2017 g_bsc_sccp_timer_ias := 2;
2018 g_bsc_sccp_timer_iar := 5;
2019
2020 f_init(1);
2021
2022 dt := f_est_dchan('23'O, 23, '00010203040506'O);
2023 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002024 f_shutdown_helper();
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01002025}
2026
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02002027private function f_tc_chan_rel_rr_cause(myBSSMAP_Cause clear_cmd_cause, template RR_Cause expect_rr_cause)
2028runs on test_CT
2029{
2030 var DchanTuple dt;
2031
2032 dt := f_est_dchan('23'O, 23, '00010203040506'O);
2033 var BssmapCause cause := 0;
2034 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(enum2int(clear_cmd_cause))));
2035 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
2036 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2037 }
2038
2039 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false, expect_rr_cause := expect_rr_cause);
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02002040}
2041
2042/* Test that Clear Command cause codes affect the RR Channel Release cause code */
2043testcase TC_chan_rel_rr_cause() runs on test_CT {
2044 f_init(1);
2045
2046 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_CALL_CONTROL, GSM48_RR_CAUSE_NORMAL);
2047 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_HANDOVER_SUCCESSFUL, GSM48_RR_CAUSE_NORMAL);
2048 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_PREEMPTION, GSM48_RR_CAUSE_PREMPTIVE_REL);
2049 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_RADIO_INTERFACE_MESSAGE_FAILURE, GSM48_RR_CAUSE_PROT_ERROR_UNSPC);
2050 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_RADIO_INTERFACE_FAILURE, GSM48_RR_CAUSE_ABNORMAL_UNSPEC);
2051 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_EQUIPMENT_FAILURE, GSM48_RR_CAUSE_ABNORMAL_UNSPEC);
Vadim Yanitskiye18aebb2021-01-03 13:10:43 +01002052
2053 f_shutdown_helper();
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02002054}
2055
Harald Welte5cd20ed2017-12-13 21:03:20 +01002056/* Test behavior if RSL EST IND for non-active channel */
2057testcase TC_rll_est_ind_inact_lchan() runs on test_CT {
2058 timer T := 2.0;
2059
Harald Welte89d42e82017-12-17 16:42:41 +01002060 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01002061
2062 var octetstring l3 := '00010203040506'O;
2063 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
2064 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
2065
2066 T.start;
2067 alt {
2068 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
2069 setverdict(fail, "MSC received COMPL L3 for non-active lchan");
2070 }
2071 [] BSSAP.receive {}
2072 [] IPA_RSL[0].receive {}
2073 [] T.timeout {}
2074 }
2075
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002076 f_shutdown_helper();
Harald Welte5cd20ed2017-12-13 21:03:20 +01002077}
2078
2079/* Test behavior if RSL EST IND for invalid SAPI */
2080testcase TC_rll_est_ind_inval_sapi1() runs on test_CT {
2081 var RslChannelNr chan_nr;
2082
Harald Welte89d42e82017-12-17 16:42:41 +01002083 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01002084
2085 chan_nr := f_chreq_act_ack()
2086
2087 var octetstring l3 := '00010203040506'O;
2088 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(1)), l3));
2089
2090 timer T := 2.0;
2091 T.start;
2092 alt {
2093 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
2094 setverdict(fail, "MSC received COMPL L3 for invalid SAPI 1");
2095 }
2096 [] BSSAP.receive { repeat; }
2097 [] IPA_RSL[0].receive { repeat; }
2098 [] T.timeout {}
2099 }
2100
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002101 f_shutdown_helper();
Harald Welte5cd20ed2017-12-13 21:03:20 +01002102}
2103
2104/* Test behavior if RSL EST IND for invalid SAPI */
2105testcase TC_rll_est_ind_inval_sapi3() runs on test_CT {
2106 timer T := 2.0;
2107
Harald Welte89d42e82017-12-17 16:42:41 +01002108 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01002109
2110 var RslChannelNr chan_nr := f_chreq_act_ack();
2111
2112 var octetstring l3 := '00010203040506'O;
2113 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(3)), l3));
2114
2115 T.start;
2116 alt {
2117 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
2118 setverdict(fail, "MSC received COMPL L3 for invalid SAPI 3");
2119 }
2120 [] BSSAP.receive { repeat; }
2121 [] IPA_RSL[0].receive { repeat; }
2122 [] T.timeout {}
2123 }
2124
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002125 f_shutdown_helper();
Harald Welte5cd20ed2017-12-13 21:03:20 +01002126}
2127
2128/* Test behavior if RSL EST IND for invalid SACCH */
2129testcase TC_rll_est_ind_inval_sacch() runs on test_CT {
2130 timer T := 2.0;
2131
Harald Welte89d42e82017-12-17 16:42:41 +01002132 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01002133
2134 var RslChannelNr chan_nr := f_chreq_act_ack();
2135
2136 var octetstring l3 := '00010203040506'O;
2137 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_SACCH(0)), l3));
2138
2139 T.start;
2140 alt {
2141 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
2142 setverdict(fail, "MSC received COMPL L3 for invalid Link SACCH");
2143 }
2144 [] BSSAP.receive { repeat; }
2145 [] IPA_RSL[0].receive { repeat; }
2146 [] T.timeout {}
2147 }
2148
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002149 f_shutdown_helper();
Harald Welte5cd20ed2017-12-13 21:03:20 +01002150}
2151
Vadim Yanitskiy61f784a2020-10-01 21:12:19 +07002152/* Verify DLCI / RSL Link ID conversion for MO/MT messages on SAPI0/SAPI3 */
2153private function f_TC_tch_dlci_link_id_sapi(charstring id) runs on MSC_ConnHdlr {
2154 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2155 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2156
2157 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2158 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
2159
2160 f_establish_fully(ass_cmd, exp_compl);
2161
2162 /* SAPI0 has already been established by f_establish_fully(), establish SAPI3 */
2163 RSL.send(ts_RSL_EST_IND(g_chan_nr, ts_RslLinkID_SACCH(3), '0904'O));
2164 /* Expect BSSAP/DTAP on SAPI3 (DLCI IE) */
2165 BSSAP.receive(PDU_BSSAP:{
2166 discriminator := '1'B,
2167 spare := '0000000'B,
2168 dlci := 'C3'O,
2169 lengthIndicator := ?,
2170 pdu := { dtap := '0904'O }
2171 });
2172
2173 /* Send messages on DCCH/SAPI0 and ACCH/SAPI3 */
2174 for (var integer i := 0; i < 32; i := i + 1) {
2175 var octetstring l3 := '09'O & f_rnd_octstring(14);
2176 var template (value) RslLinkId link_id;
2177 var template (value) OCT1 dlci;
2178
2179 if (i mod 2 == 0) {
2180 /* SAPI0 on FACCH or SDCCH */
2181 link_id := ts_RslLinkID_DCCH(0);
2182 dlci := '80'O;
2183 } else {
2184 /* SAPI3 on SACCH */
2185 link_id := ts_RslLinkID_SACCH(3);
2186 dlci := 'C3'O;
2187 }
2188
2189 /* Send MO message: RSL -> BSSAP */
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00002190 f_mo_l3_transceive(RSL, link_id, dlci, l3);
Vadim Yanitskiy61f784a2020-10-01 21:12:19 +07002191 /* Send MT message: BSSAP -> RSL */
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00002192 f_mt_l3_transceive(RSL, link_id, dlci, l3);
Vadim Yanitskiy61f784a2020-10-01 21:12:19 +07002193 }
2194}
2195testcase TC_tch_dlci_link_id_sapi() runs on test_CT {
2196 var TestHdlrParams pars := f_gen_test_hdlr_pars();
2197 var MSC_ConnHdlr vc_conn;
2198
2199 f_init(1, true);
2200 f_sleep(1.0);
2201
2202 vc_conn := f_start_handler(refers(f_TC_tch_dlci_link_id_sapi), pars);
2203 vc_conn.done;
2204
2205 f_shutdown_helper();
2206}
2207
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07002208private function f_exp_sapi_n_reject(template (present) GsmSapi sapi := ?,
2209 template myBSSMAP_Cause cause := ?,
2210 float T_val := 2.0)
2211runs on test_CT {
2212 var BSSAP_N_DATA_ind rx_di;
2213 timer T;
2214
2215 var template BSSMAP_IE_Cause tr_cause := tr_BSSMAP_IE_Cause(cause);
2216 var template PDU_BSSAP tr_pdu := tr_BSSMAP_SAPInReject(sapi);
2217
2218 T.start(T_val);
2219 alt {
2220 [] BSSAP.receive(tr_BSSAP_DATA_ind(?, tr_pdu)) -> value rx_di {
2221 var BSSMAP_IE_Cause rx_cause := rx_di.userData.pdu.bssmap.sAPInReject.cause;
2222 if (not match(rx_cause, tr_cause)) {
2223 setverdict(fail, "Rx unexpected Cause IE: ",
2224 rx_cause, " vs expected ", tr_cause);
2225 }
2226 setverdict(pass);
2227 }
2228 [] BSSAP.receive(BSSAP_N_DATA_ind:?) -> value rx_di {
2229 setverdict(fail, "Rx unexpected BSSAP PDU: ", rx_di);
2230 }
2231 [] T.timeout {
2232 setverdict(fail, "Timeout waiting for BSSMAP SAPI N Reject");
2233 }
2234 }
2235}
2236
2237/* Check if we get SAPI N Reject on receipt of unexpected RLL RELease INDication */
2238testcase TC_rll_rel_ind_sapi_n_reject() runs on test_CT {
2239 var octetstring rnd_data := f_rnd_octstring(16);
2240 var RSL_Message rx_rsl;
2241 var DchanTuple dt;
2242
2243 f_init(1);
2244
2245 /* MS establishes a SAPI=0 link on DCCH */
2246 dt := f_est_dchan(f_rnd_ra_cs(), 23, rnd_data);
2247
2248 /* MSC sends some data on (not yet established) SAPI=3 link */
2249 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSAP_DTAP(rnd_data, '03'O)));
2250 /* BSC attempts to establish a SAPI=3 link on DCCH */
2251 rx_rsl := f_exp_ipa_rx(0, tr_RSL_EST_REQ(dt.rsl_chan_nr, tr_RslLinkID_DCCH(3)));
2252
2253 /* MS sends unexpected RELease INDication on SAPI=3 */
2254 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, ts_RslLinkID_DCCH(3)));
2255 /* We expect to receive BSSMAP SAPI N Reject message from the BSC */
2256 f_exp_sapi_n_reject(3, GSM0808_CAUSE_MS_NOT_EQUIPPED);
2257
2258 /* Clean up the connection */
2259 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2260 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
2261
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002262 f_shutdown_helper();
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07002263}
2264
2265/* Check if we get SAPI N Reject on receipt of unexpected RLL ERROR INDication */
2266testcase TC_rll_err_ind_sapi_n_reject() runs on test_CT {
2267 var octetstring rnd_data := f_rnd_octstring(16);
2268 var RSL_Message rx_rsl;
2269 var DchanTuple dt;
2270
2271 f_init(1);
2272
2273 /* MS establishes a SAPI=0 link on DCCH */
2274 dt := f_est_dchan(f_rnd_ra_cs(), 23, rnd_data);
2275
2276 /* MSC sends some data on (not yet established) SAPI=3 link */
2277 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSAP_DTAP(rnd_data, '03'O)));
2278 /* BSC attempts to establish a SAPI=3 link on DCCH */
2279 rx_rsl := f_exp_ipa_rx(0, tr_RSL_EST_REQ(dt.rsl_chan_nr, tr_RslLinkID_DCCH(3)));
2280
2281 /* BTS sends unexpected ERROR INDication on SAPI=3 */
2282 f_ipa_tx(0, ts_RSL_ERROR_IND(dt.rsl_chan_nr, ts_RslLinkID_DCCH(3), ''O));
2283 /* We expect to receive BSSMAP SAPI N Reject message from the BSC */
2284 f_exp_sapi_n_reject(3, GSM0808_CAUSE_BSS_NOT_EQUIPPED);
2285
2286 /* Clean up the connection */
2287 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2288 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
2289
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002290 f_shutdown_helper();
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07002291}
2292
2293/* Check if we get SAPI N Reject due to a SAPI=3 link establishment timeout */
2294testcase TC_rll_timeout_sapi_n_reject() runs on test_CT {
2295 var octetstring rnd_data := f_rnd_octstring(16);
2296 var RSL_Message rx_rsl;
2297 var DchanTuple dt;
2298
2299 f_init(1);
2300
2301 /* MS establishes a SAPI=0 link on DCCH */
2302 dt := f_est_dchan(f_rnd_ra_cs(), 23, rnd_data);
2303
2304 /* MSC sends some data on (not yet established) SAPI=3 link */
2305 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSAP_DTAP(rnd_data, '03'O)));
2306 /* BSC attempts to establish a SAPI=3 link on DCCH */
2307 rx_rsl := f_exp_ipa_rx(0, tr_RSL_EST_REQ(dt.rsl_chan_nr, tr_RslLinkID_DCCH(3)));
2308
2309 /* MS does not respond, so the link establishment timeout triggers SAPI N Reject */
2310 f_exp_sapi_n_reject(3, GSM0808_CAUSE_BSS_NOT_EQUIPPED, T_val := 8.0);
2311
2312 /* Clean up the connection */
2313 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2314 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
2315
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002316 f_shutdown_helper();
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07002317}
2318
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02002319testcase TC_si_default() runs on test_CT {
2320 f_init(0);
2321 f_init_bts_and_check_sysinfo(0, expect_si := SystemInformationConfig_default);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002322 f_shutdown_helper();
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02002323}
Harald Welte4003d112017-12-09 22:35:39 +01002324
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002325/* We're testing SI2quater with lists of EARFCNs. Instead of just incrementing EARFCNs, also pick some from the edges of
2326 * the entire value range. This function provides the same EARFCN numbers for the same earfcn_index */
2327private function f_test_si2quater_earfcn_by_idx(integer earfcn_index) return uint16_t
2328{
2329 select (earfcn_index) {
2330 case (0) {
2331 /* E-ARFCN 111 is already added in the osmo-bsc.cfg */
2332 return 111;
2333 }
2334 case (1) {
2335 return 1;
2336 }
2337 case (2) {
2338 return 0;
2339 }
2340 case (3) {
2341 return 65535;
2342 }
2343 case else {
2344 return 23 * (earfcn_index - 3);
2345 }
2346 }
2347}
2348
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002349function f_test_si2quater(integer total_earfcns, template SystemInformationConfig expect_si,
2350 template CellSelIndValue expect_cells := omit) runs on test_CT {
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002351
2352 f_init(0);
2353
2354 /* E-ARFCN 111 is already added in the osmo-bsc.cfg, so only add more arfcns if total_earfcns > 1 */
2355 for (var integer i := 1; i < total_earfcns; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002356 f_bts_0_cfg(BSCVTY, {"si2quater neighbor-list add earfcn " & int2str(f_test_si2quater_earfcn_by_idx(i))
2357 & " thresh-hi 20 thresh-lo 10 prio 3 qrxlv 22 meas 3"});
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002358 }
2359
2360 f_init_bts_and_check_sysinfo(0, expect_si := expect_si);
2361
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002362 if (not istemplatekind(expect_cells, "omit")) {
2363 /* Also check that RR Channel Release contains these EARFCNs.
2364 * (copied code from TC_chan_rel_hard_clear_csfb) */
2365 var BSSAP_N_DATA_ind rx_di;
2366 var DchanTuple dt;
2367
2368 dt := f_est_dchan('23'O, 23, '00010203040506'O);
2369
2370 /* Instruct BSC to clear channel */
2371 var BssmapCause cause := 0;
2372 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommandCSFB(cause)));
2373
2374 /* expect Clear Complete from BSC on A */
2375 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
2376 /* release the SCCP connection */
2377 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2378 }
2379
Pau Espin Pedrol841b90d2021-04-15 16:42:52 +02002380 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false, expect_cells := expect_cells);
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002381 }
2382
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002383 for (var integer i := 1; i < total_earfcns; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002384 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 +02002385 }
2386}
2387
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002388private function f_tr_si2quater_earfcns(integer count) return template SI2quaterRestOctetsList
2389{
2390 var template SI2quaterRestOctetsList si2quater := {};
2391 var integer si2quater_count := (count + 2) / 3;
2392
2393 for (var integer i := 0; i < count; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002394 var integer earfcn := f_test_si2quater_earfcn_by_idx(i);
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002395 var integer index := i / 3;
2396 var integer earfcn_index := i mod 3;
2397 if (index >= lengthof(si2quater)) {
2398 si2quater[index] := tr_SI2quaterRestOctets_EUTRAN(index := index, count := si2quater_count - 1);
2399 }
2400 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);
2401 }
2402
2403 return si2quater;
2404}
2405
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002406private function f_tr_rr_chan_rel_earfcns(integer count) return template CellSelIndValue
2407{
2408 var template CellSelIndValue_EUTRAN_Descrs cells := {};
2409
Alexander Couzensf74b5cb2020-09-10 22:28:40 +02002410 /* the lte neighbors must match the config & vty to pass this test */
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002411 for (var integer i := 0; i < count; i := i + 1) {
2412 var integer earfcn := f_test_si2quater_earfcn_by_idx(i);
Alexander Couzensf74b5cb2020-09-10 22:28:40 +02002413 cells[i] := tr_CellSelIndValue_EUTRAN_Descr(earfcn, '1'B, 3);
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002414 }
2415
2416 return tr_CellSelIndValue_EUTRAN(cells);
2417}
2418
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002419private function f_tc_si2quater_n_earfcns(integer n) runs on test_CT
2420{
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002421 var template SystemInformationConfig sic := SystemInformationConfig_default;
Pau Espin Pedrol8ab62e42020-12-18 16:19:11 +01002422 sic.si2quater := f_tr_si2quater_earfcns(n);
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002423 var template CellSelIndValue cells := f_tr_rr_chan_rel_earfcns(n);
2424 f_test_si2quater(n, sic, cells);
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002425}
2426
2427testcase TC_si2quater_2_earfcns() runs on test_CT {
2428 f_tc_si2quater_n_earfcns(2);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002429 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002430}
2431
2432testcase TC_si2quater_3_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002433 f_tc_si2quater_n_earfcns(3);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002434 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002435}
2436
2437testcase TC_si2quater_4_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002438 f_tc_si2quater_n_earfcns(4);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002439 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002440}
2441
2442testcase TC_si2quater_5_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002443 f_tc_si2quater_n_earfcns(5);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002444 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002445}
2446
2447testcase TC_si2quater_6_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002448 f_tc_si2quater_n_earfcns(6);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002449 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002450}
2451
2452testcase TC_si2quater_12_earfcns() runs on test_CT {
2453 f_tc_si2quater_n_earfcns(12);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002454 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002455}
2456
2457testcase TC_si2quater_23_earfcns() runs on test_CT {
2458 f_tc_si2quater_n_earfcns(23);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002459 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002460}
2461
2462testcase TC_si2quater_32_earfcns() runs on test_CT {
2463 f_tc_si2quater_n_earfcns(32);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002464 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002465}
2466
2467testcase TC_si2quater_33_earfcns() runs on test_CT {
2468 f_tc_si2quater_n_earfcns(33);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002469 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002470}
2471
2472testcase TC_si2quater_42_earfcns() runs on test_CT {
2473 f_tc_si2quater_n_earfcns(42);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002474 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002475}
2476
2477testcase TC_si2quater_48_earfcns() runs on test_CT {
2478 f_tc_si2quater_n_earfcns(48);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002479 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002480}
2481
2482/* verify the VTY error response when adding too many EARFCNs, and showing that osmo-bsc still sends 16 SI2quater with
2483 * 48 EARFCNs. */
2484testcase TC_si2quater_49_earfcns() runs on test_CT {
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002485 var template SystemInformationConfig sic := SystemInformationConfig_default;
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002486 sic.si2quater := f_tr_si2quater_earfcns(48); /* 48, not 49! */
2487 f_init(0);
2488
2489 for (var integer i := 1; i < 48; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002490 f_bts_0_cfg(BSCVTY, {"si2quater neighbor-list add earfcn " & int2str(f_test_si2quater_earfcn_by_idx(i))
2491 & " thresh-hi 20 thresh-lo 10 prio 3 qrxlv 22 meas 3"});
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002492 }
2493
2494 /* The 49th EARFCN no longer fits, expect VTY error */
2495 f_vty_enter_cfg_bts(BSCVTY, 0);
2496 var charstring vty_error;
2497 vty_error := f_vty_transceive_ret(BSCVTY,
2498 "si2quater neighbor-list add earfcn 70 thresh-hi 20 thresh-lo 10 prio 3 qrxlv 22 meas 3")
2499 f_vty_transceive(BSCVTY, "end");
2500
2501 if (f_strstr(vty_error, "Unable to add ARFCN 70") >= 0) {
2502 log("Got expected VTY error: ", vty_error);
2503 setverdict(pass);
2504 } else {
2505 setverdict(fail, "Expected the 49th EUTRAN ARFCN to be rejected by vty config, got: ", vty_error);
2506 }
2507
2508 f_init_bts_and_check_sysinfo(0, expect_si := sic);
2509
2510 for (var integer i := 1; i < 48; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002511 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 +02002512 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002513 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002514}
2515
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002516private function f_acc09_count_allowed(AccessControlClass acc) return uint8_t
2517{
2518 var uint8_t count := 0;
2519 for (var integer i := 5; i < 16; i := i + 1) {
2520 if (acc[i] == '0'B) { /* the list marks barred, we count allowed */
2521 count := count + 1;
2522 }
2523 }
2524 return count;
2525}
2526
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002527private function f_recv_next_si1(integer rsl_idx := 0) runs on test_CT return SystemInformationType1
2528{
2529 var ASP_RSL_Unitdata rx_rsl_ud;
2530 var SystemInformationType1 last_si1;
2531
2532 timer T := 30.0;
2533 T.start;
2534 alt {
2535 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD((tr_RSL_NO_BCCH_INFO,
2536 tr_RSL_BCCH_INFO,
2537 tr_RSL_NO_SACCH_FILL,
2538 tr_RSL_SACCH_FILL))
2539 ) -> value rx_rsl_ud {
2540 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
2541 if (g_system_information[rsl_idx].si1 == omit) {
2542 repeat;
2543 }
2544 last_si1 := g_system_information[rsl_idx].si1;
2545 g_system_information[rsl_idx].si1 := omit;
2546 T.stop;
2547 }
Vadim Yanitskiy79ebd5e2021-01-04 00:12:55 +01002548 [] IPA_RSL[rsl_idx].receive { repeat; }
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002549 [] T.timeout { setverdict(fail, "Timeout receiving next SI1"); }
2550 }
2551 return last_si1;
2552}
2553
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002554/* verify ACC rotate feature */
2555testcase TC_si_acc_rotate() runs on test_CT {
2556 var template SystemInformationConfig sic := SystemInformationConfig_default;
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002557 var SystemInformationType1 last_si1;
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002558 var AccessControlClass acc;
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002559 var uint8_t count;
2560 var integer times_allowed[10] := { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
2561
2562 f_init(0, guard_timeout := 60.0);
2563
2564 f_bts_0_cfg(BSCVTY, {"rach access-control-class 5 barred",
2565 "access-control-class-rotate 3",
2566 "access-control-class-rotate-quantum 1"});
2567
2568 /* Init and get first sysinfo */
2569 f_init_bts_and_check_sysinfo(0, expect_si := ?);
2570
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002571 for (var integer i:= 0; i < 20; i := i + 1) {
2572 last_si1 := f_recv_next_si1(0);
2573 acc := last_si1.rach_control.acc;
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002574 count := f_acc09_count_allowed(acc);
2575 log("RSL: GOT SI1 ACC len=", count, ": ", acc);
2576
2577 if (count != 3) {
2578 log("RSL: EXPECTED SI ACC len=3");
2579 setverdict(fail, "received SI does not match expectations");
2580 break;
2581 }
2582
2583 for (var integer j := 0; j < 10; j := j + 1) {
2584 if (acc[16 - 1 - j] == '0'B) { /* the list marks barred, we count allowed */
2585 times_allowed[j] := times_allowed[j] + 1;
2586 }
2587 }
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002588 }
2589
2590 for (var integer j := 0; j < 10; j := j + 1) {
2591 log("ACC", j, " allowed ", times_allowed[j], " times" );
2592 if (j != 5 and times_allowed[j] < 3) {
2593 setverdict(fail, "ACC", j, " ERROR: allowed ", times_allowed[j], " < 1 times");
2594 } else if (j == 5 and times_allowed[j] > 0) {
2595 setverdict(fail, "ACC", j, " ERROR: allowed ", times_allowed[j], " > 0 times");
2596 }
2597 }
2598
2599 f_bts_0_cfg(BSCVTY, {"access-control-class-rotate 10",
2600 "rach access-control-class 5 allowed"});
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002601 f_shutdown_helper();
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002602}
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002603
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002604/* verify ACC startup ramp+rotate feature */
2605testcase TC_si_acc_ramp_rotate() runs on test_CT {
2606 var template SystemInformationConfig sic := SystemInformationConfig_default;
2607 var SystemInformationType1 last_si1;
2608 var AccessControlClass acc;
2609 var ASP_RSL_Unitdata rx_rsl_ud;
2610 var uint8_t count;
2611 var uint8_t prev_count;
2612 var integer times_allowed[10] := { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
2613
2614 f_init(0, guard_timeout := 80.0);
2615
2616 f_bts_0_cfg(BSCVTY, {"rach access-control-class 4 barred",
2617 "access-control-class-rotate 0",
2618 "access-control-class-rotate-quantum 1",
2619 "access-control-class-ramping",
2620 "access-control-class-ramping-step-interval 5",
2621 "access-control-class-ramping-step-size 5"});
2622
2623 /* Init and get first sysinfo */
2624 f_init_bts_and_check_sysinfo(0, expect_si := ?);
2625 last_si1 := g_system_information[0].si1;
2626 acc := last_si1.rach_control.acc;
2627 count := f_acc09_count_allowed(acc);
2628 /* Adm subset size was set to 0 above, so wait until all ACC are barred */
2629 while (count > 0) {
2630 last_si1 := f_recv_next_si1(0);
2631 acc := last_si1.rach_control.acc;
2632 count := f_acc09_count_allowed(acc);
2633 log("RSL: wait len()=0: GOT SI1 ACC len=", count, ": ", acc);
2634 }
2635
2636 /* Increase adm subset size, we should see ramping start up */
2637 f_bts_0_cfg(BSCVTY, {"access-control-class-rotate 10"});
2638 prev_count := 0;
2639 while (true) {
2640 last_si1 := f_recv_next_si1(0);
2641 acc := last_si1.rach_control.acc;
2642 count := f_acc09_count_allowed(acc);
2643 log("RSL: GOT SI1 ACC len=", count, ": ", acc);
2644
2645 if (prev_count > count) {
2646 setverdict(fail, "ACC allowed count dropped while expecting grow: ", prev_count, " -> ", count);
2647 break;
2648 }
2649
2650 if (count == 9) {
2651 break; /* Maximum reached (10 - 1 perm barred), done here */
2652 }
2653
2654 prev_count := count;
2655 }
2656
2657 setverdict(pass);
2658
2659 f_bts_0_cfg(BSCVTY, {"access-control-class-rotate 10",
2660 "rach access-control-class 4 allowed",
2661 "no access-control-class-ramping"});
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002662 f_shutdown_helper();
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002663}
2664
Harald Welte4003d112017-12-09 22:35:39 +01002665testcase TC_ctrl_msc_connection_status() runs on test_CT {
2666 var charstring ctrl_resp;
2667
Harald Welte89d42e82017-12-17 16:42:41 +01002668 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01002669
2670 /* See https://osmocom.org/issues/2729 */
2671 f_ctrl_get_exp(IPA_CTRL, "msc_connection_status", "connected");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002672 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01002673}
2674
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01002675testcase TC_ctrl_msc0_connection_status() runs on test_CT {
2676 var charstring ctrl_resp;
2677
2678 f_init(1);
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01002679
2680 f_ctrl_get_exp(IPA_CTRL, "msc.0.connection_status", "connected");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002681 f_shutdown_helper();
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01002682}
2683
Harald Welte4003d112017-12-09 22:35:39 +01002684testcase TC_ctrl() runs on test_CT {
2685 var charstring ctrl_resp;
2686
Harald Welte89d42e82017-12-17 16:42:41 +01002687 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01002688
2689 /* all below values must match the osmo-bsc.cfg config file used */
2690
Harald Welte6a129692018-03-17 17:30:14 +01002691 f_ctrl_get_exp(IPA_CTRL, "mcc", "001");
2692 f_ctrl_get_exp(IPA_CTRL, "mnc", "01");
Oliver Smith75aa0202019-08-19 14:17:50 +02002693 f_ctrl_get_exp(IPA_CTRL, "number-of-bts", "4");
Harald Welte4003d112017-12-09 22:35:39 +01002694
2695 var integer bts_nr := 0;
2696 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "location-area-code", "1");
2697 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "cell-identity", "0");
2698 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "oml-connection-state", "connected");
2699 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "gprs-mode", "gprs");
2700 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "rf_state", "operational,unlocked,on");
2701 f_ctrl_get_exp_trx(IPA_CTRL, bts_nr, 0, "arfcn", "871");
2702 f_ctrl_get_exp_trx(IPA_CTRL, bts_nr, 0, "max-power-reduction", "20");
2703
2704 var integer uptime := str2int(f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-uptime"));
2705 f_sleep(2.0);
2706 if (str2int(f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-uptime")) < uptime+1) {
2707 setverdict(fail, "oml-uptime not incrementing as expected");
2708 }
2709 /* TODO: Disconnect RSL, imply that OML is disconnected and check for uptime zero? */
2710
2711 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted", 0);
2712
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002713 f_shutdown_helper();
Harald Welte96c94412017-12-09 03:12:45 +01002714}
2715
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +02002716/* Verify that Upon receival of SET "location", BSC forwards a TRAP
2717 "location-state" over the SCCPlite IPA conn */
2718testcase TC_ctrl_location() runs on test_CT {
2719 var MSC_ConnHdlr vc_conn;
2720 var integer bts_nr := 0;
2721
2722 f_init(1, true);
2723 f_sleep(1.0);
2724
2725 f_ctrl_set_bts(IPA_CTRL, bts_nr, "location", "1234567,fix3d,0.340000,0.560000,0.780000");
2726 f_ctrl_exp_trap(SCCPLITE_IPA_CTRL, "bts." & int2str(bts_nr) & ".location-state",
2727 "1234567,fix3d,0.340000,0.560000,0.780000,operational,unlocked,on,001,01");
2728
2729 f_ctrl_set(SCCPLITE_IPA_CTRL, "rf_locked", "1");
2730 f_sleep(2.0);
2731
2732 f_ctrl_set_bts(IPA_CTRL, bts_nr, "location", "1234888,fix3d,0.350000,0.570000,0.790000");
2733 f_ctrl_exp_trap(SCCPLITE_IPA_CTRL, "bts." & int2str(bts_nr) & ".location-state",
2734 "1234888,fix3d,0.350000,0.570000,0.790000,operational,locked,off,001,01");
2735
2736 /* should match the one from config */
2737 f_ctrl_set(SCCPLITE_IPA_CTRL, "rf_locked", "0");
2738
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002739 f_shutdown_helper();
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +02002740}
2741
Harald Welte6f521d82017-12-11 19:52:02 +01002742
2743/***********************************************************************
2744 * Paging Testing
2745 ***********************************************************************/
2746
2747type record Cell_Identity {
2748 GsmMcc mcc,
2749 GsmMnc mnc,
2750 GsmLac lac,
2751 GsmCellId ci
2752};
Harald Welte24135bd2018-03-17 19:27:53 +01002753private const Cell_Identity cid := { '001'H, '01'H, 1, 0 };
Stefan Sperling049a86e2018-03-20 15:51:00 +01002754private const Cell_Identity unknown_cid := { '678'H, 'f90'H, 1, 0 };
Harald Welte6f521d82017-12-11 19:52:02 +01002755
Harald Welte5d1a2202017-12-13 19:51:29 +01002756type set of integer BtsIdList;
2757
2758private function f_bts_in_list(integer bts_id, BtsIdList bts_ids) return boolean {
2759 for (var integer j := 0; j < sizeof(bts_ids); j := j + 1) {
2760 if (bts_id == bts_ids[j]) {
2761 return true;
2762 }
2763 }
2764 return false;
2765}
Harald Welte6f521d82017-12-11 19:52:02 +01002766
2767/* core paging test helper function; used by most paging test cases */
2768private function f_pageing_helper(hexstring imsi,
2769 template BSSMAP_FIELD_CellIdentificationList cid_list,
Harald Welte5d1a2202017-12-13 19:51:29 +01002770 BtsIdList bts_ids := { 0 },
Harald Welte6f521d82017-12-11 19:52:02 +01002771 template RSL_ChanNeeded rsl_chneed := omit,
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002772 template (omit) OCT4 tmsi := omit) runs on test_CT
Harald Welte6f521d82017-12-11 19:52:02 +01002773{
2774 var template BSSMAP_IE_ChannelNeeded bssmap_chneed;
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002775 var template MobileIdentityV mi;
Harald Welte6f521d82017-12-11 19:52:02 +01002776 var RSL_Message rx_rsl;
2777 var integer paging_group := hex2int(imsi[lengthof(imsi)-1]);
Harald Welte5d1a2202017-12-13 19:51:29 +01002778 var integer i;
Harald Welte6f521d82017-12-11 19:52:02 +01002779
2780 f_init();
Harald Welte6f521d82017-12-11 19:52:02 +01002781
2782 /* Clear the queue, it might still contain stuff like BCCH FILLING */
Harald Weltec3068592018-03-17 19:55:31 +01002783 for (i := 0; i < NUM_BTS; i := i + 1) {
2784 IPA_RSL[i].clear;
Harald Welte5d1a2202017-12-13 19:51:29 +01002785 }
Harald Welte6f521d82017-12-11 19:52:02 +01002786
2787 if (isvalue(rsl_chneed)) {
2788 /* The values of 08.08 3.2.2.36 and 08.58 9.3.40 are luckily identical */
2789 bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
2790 } else {
2791 bssmap_chneed := omit;
2792 }
2793
Neels Hofmeyrf246a922020-05-13 02:27:10 +02002794 BSSAP.send(ts_BSSAP_UNITDATA_req(g_bssap[0].sccp_addr_peer, g_bssap[0].sccp_addr_own,
2795 ts_BSSMAP_Paging(imsi, cid_list, tmsi, bssmap_chneed)));
Harald Welte6f521d82017-12-11 19:52:02 +01002796
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002797 if (not istemplatekind(tmsi, "omit")) {
2798 mi := t_MI_TMSI(tmsi);
Harald Welte6f521d82017-12-11 19:52:02 +01002799 } else {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002800 mi := tr_MI_IMSI(imsi);
Harald Welte6f521d82017-12-11 19:52:02 +01002801 }
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002802
Harald Welte5d1a2202017-12-13 19:51:29 +01002803 for (i := 0; i < sizeof(bts_ids); i := i + 1) {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002804 rx_rsl := f_exp_ipa_rx(bts_ids[i], tr_RSL_PAGING_CMD(mi));
Harald Welte5d1a2202017-12-13 19:51:29 +01002805 /* check channel type, paging group */
2806 if (rx_rsl.ies[1].body.paging_group != paging_group) {
2807 setverdict(fail, "Paging for wrong paging group");
2808 }
2809 if (ispresent(rsl_chneed) and
2810 rx_rsl.ies[3].body.chan_needed.chan_needed != valueof(rsl_chneed)) {
2811 setverdict(fail, "RSL Channel Needed != BSSMAP Channel Needed");
2812 }
Harald Welte6f521d82017-12-11 19:52:02 +01002813 }
Harald Welte2fccd982018-01-31 15:48:19 +01002814 f_sleep(2.0);
Harald Welte5d1a2202017-12-13 19:51:29 +01002815 /* do a quick check on all not-included BTSs if they received paging */
2816 for (i := 0; i < NUM_BTS; i := i + 1) {
2817 timer T := 0.1;
2818 if (f_bts_in_list(i, bts_ids)) {
2819 continue;
2820 }
2821 T.start;
2822 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07002823 [] IPA_RSL[i].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(mi))) {
Harald Welte5d1a2202017-12-13 19:51:29 +01002824 setverdict(fail, "Paging on BTS ", i, " which is not part of ", bts_ids);
2825 }
2826 [] IPA_RSL[i].receive { repeat; }
2827 [] T.timeout { }
2828 }
Harald Welte6f521d82017-12-11 19:52:02 +01002829 }
2830
2831 setverdict(pass);
2832}
2833
Harald Welte5d1a2202017-12-13 19:51:29 +01002834const BtsIdList c_BtsId_all := { 0, 1, 2 };
Harald Welte751d3eb2018-01-31 15:51:06 +01002835const BtsIdList c_BtsId_none := { };
Harald Welte5d1a2202017-12-13 19:51:29 +01002836const BtsIdList c_BtsId_LAC1 := { 0, 1 };
2837const BtsIdList c_BtsId_LAC2 := { 2 };
2838
Harald Welte6f521d82017-12-11 19:52:02 +01002839/* PAGING by IMSI + TMSI */
2840testcase TC_paging_imsi_nochan() runs on test_CT {
2841 var BSSMAP_FIELD_CellIdentificationList cid_list;
2842 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Philipp Maier8c04b0a2018-02-23 13:48:48 +01002843 f_pageing_helper('001010100000001'H, cid_list, c_BtsId_all, omit, omit);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002844 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002845}
2846
2847/* PAGING by IMSI + TMSI */
2848testcase TC_paging_tmsi_nochan() runs on test_CT {
2849 var BSSMAP_FIELD_CellIdentificationList cid_list;
2850 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002851 f_pageing_helper('001010100000001'H, cid_list, c_BtsId_all, omit, 'A1B2C301'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002852 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002853}
2854
2855/* Paging with different "channel needed' values */
2856testcase TC_paging_tmsi_any() runs on test_CT {
2857 var BSSMAP_FIELD_CellIdentificationList cid_list;
2858 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002859 f_pageing_helper('001010100000002'H, cid_list, c_BtsId_all, RSL_CHANNEED_ANY, 'A1B2C302'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002860 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002861}
2862testcase TC_paging_tmsi_sdcch() runs on test_CT {
2863 var BSSMAP_FIELD_CellIdentificationList cid_list;
2864 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002865 f_pageing_helper('001010100000003'H, cid_list, c_BtsId_all, RSL_CHANNEED_SDCCH, 'A1B2C303'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002866 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002867}
2868testcase TC_paging_tmsi_tch_f() runs on test_CT {
2869 var BSSMAP_FIELD_CellIdentificationList cid_list;
2870 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002871 f_pageing_helper('001010000000004'H, cid_list, c_BtsId_all, RSL_CHANNEED_TCH_F, 'A1B2C304'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002872 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002873}
2874testcase TC_paging_tmsi_tch_hf() runs on test_CT {
2875 var BSSMAP_FIELD_CellIdentificationList cid_list;
2876 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002877 f_pageing_helper('001010000000005'H, cid_list, c_BtsId_all, RSL_CHANNEED_TCH_ForH, 'A1B2C305'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002878 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002879}
2880
2881/* Paging by CGI */
2882testcase TC_paging_imsi_nochan_cgi() runs on test_CT {
2883 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2884 cid_list := { cIl_CGI := { ts_BSSMAP_CI_CGI(cid.mcc, cid.mnc, cid.lac, cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002885 f_pageing_helper('001010000000006'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01002886 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002887}
2888
2889/* Paging by LAC+CI */
2890testcase TC_paging_imsi_nochan_lac_ci() runs on test_CT {
2891 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2892 cid_list := { cIl_LAC_CI := { ts_BSSMAP_CI_LAC_CI(cid.lac, cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002893 f_pageing_helper('001010000000007'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01002894 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002895}
2896
2897/* Paging by CI */
2898testcase TC_paging_imsi_nochan_ci() runs on test_CT {
2899 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2900 cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002901 f_pageing_helper('001010000000008'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01002902 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002903}
2904
2905/* Paging by LAI */
2906testcase TC_paging_imsi_nochan_lai() runs on test_CT {
2907 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2908 cid_list := { cIl_LAI := { ts_BSSMAP_CI_LAI(cid.mcc, cid.mnc, cid.lac) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002909 f_pageing_helper('001010000000009'H, cid_list, c_BtsId_LAC1);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002910 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002911}
2912
2913/* Paging by LAC */
2914testcase TC_paging_imsi_nochan_lac() runs on test_CT {
2915 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2916 cid_list := { cIl_LAC := { ts_BSSMAP_CI_LAC(cid.lac) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002917 f_pageing_helper('001010000000010'H, cid_list, c_BtsId_LAC1);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002918 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002919}
2920
2921/* Paging by "all in BSS" */
2922testcase TC_paging_imsi_nochan_all() runs on test_CT {
2923 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2924 cid_list := { cIl_allInBSS := ''O };
Harald Welte5d1a2202017-12-13 19:51:29 +01002925 f_pageing_helper('001010000000011'H, cid_list, c_BtsId_all);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002926 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002927}
2928
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002929/* Paging by PLMN+LAC+RNC; We do not implement this; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01002930testcase TC_paging_imsi_nochan_plmn_lac_rnc() runs on test_CT {
2931 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2932 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 +01002933 f_pageing_helper('001010000000012'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002934 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002935}
Harald Welte6f521d82017-12-11 19:52:02 +01002936
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002937/* Paging by RNC; We do not implement this; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01002938testcase TC_paging_imsi_nochan_rnc() runs on test_CT {
2939 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2940 cid_list := { cIl_RNC := { int2oct(13, 2) } };
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002941 f_pageing_helper('001010000000013'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002942 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002943}
2944
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002945/* Paging by LAC+RNC; We do not implement; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01002946testcase TC_paging_imsi_nochan_lac_rnc() runs on test_CT {
2947 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2948 cid_list := { cIl_LAC_RNC := { ts_BSSMAP_CI_LAC_RNC(cid.lac, 14) } };
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002949 f_pageing_helper('001010000000014'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002950 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002951}
2952
Harald Welte6f521d82017-12-11 19:52:02 +01002953/* Paging on multiple cells (multiple entries in list): Verify all of them page */
Harald Welte751d3eb2018-01-31 15:51:06 +01002954testcase TC_paging_imsi_nochan_lacs() runs on test_CT {
2955 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2956 cid_list := { cIl_LAC := { ts_BSSMAP_CI_LAC(1), ts_BSSMAP_CI_LAC(2) } };
2957 f_pageing_helper('001010000000015'H, cid_list, c_BtsId_all);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002958 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002959}
2960
2961/* Paging on empty list: Verify none of them page */
2962testcase TC_paging_imsi_nochan_lacs_empty() runs on test_CT {
2963 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2964 cid_list := { cIl_LAC := { } };
2965 f_pageing_helper('001010000000016'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002966 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002967}
2968
Stefan Sperling049a86e2018-03-20 15:51:00 +01002969/* Paging by CGI with unknown MCC/MNC: Verify nothing is paged. */
2970testcase TC_paging_imsi_nochan_cgi_unknown_cid() runs on test_CT {
2971 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2972 cid_list := { cIl_CGI := { ts_BSSMAP_CI_CGI(unknown_cid.mcc, unknown_cid.mnc, unknown_cid.lac, unknown_cid.ci) } };
2973 f_pageing_helper('001010000000006'H, cid_list, c_BtsId_none);
2974 f_shutdown_helper();
2975}
2976
Harald Welte6f521d82017-12-11 19:52:02 +01002977/* Verify paging retransmission interval + count */
2978/* Verify paging stops after channel establishment */
Harald Welte6f521d82017-12-11 19:52:02 +01002979/* Test behavior under paging overload */
Harald Welteae026692017-12-09 01:03:01 +01002980
Harald Weltee65d40e2017-12-13 00:09:06 +01002981/* Verify PCH load */
2982testcase TC_paging_imsi_load() runs on test_CT {
2983 var BSSMAP_FIELD_CellIdentificationList cid_list;
2984 timer T := 4.0;
Harald Welte2caa1062018-03-17 18:19:05 +01002985 timer T_retrans := 1.0;
Harald Weltee65d40e2017-12-13 00:09:06 +01002986 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002987 f_pageing_helper('001010123456789'H, cid_list, c_BtsId_all);
Harald Weltee65d40e2017-12-13 00:09:06 +01002988
2989 /* tell BSC there is no paging space anymore */
2990 f_ipa_tx(0, ts_RSL_PAGING_LOAD_IND(0));
Harald Welte3b57ab52018-03-17 18:01:10 +01002991 f_sleep(0.2);
2992 IPA_RSL[0].clear;
Harald Weltee65d40e2017-12-13 00:09:06 +01002993
2994 /* Wait for 4 seconds if any more PAGING CMD are received on RSL. Normally,
2995 * there would be 8 retransmissions during 4 seconds */
2996 T.start;
Harald Welte2caa1062018-03-17 18:19:05 +01002997 T_retrans.start;
Harald Weltee65d40e2017-12-13 00:09:06 +01002998 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07002999 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Weltee65d40e2017-12-13 00:09:06 +01003000 setverdict(fail, "Received PAGING after LOAD_IND(0)");
Daniel Willmannafce8662018-07-06 23:11:32 +02003001 mtc.stop;
Harald Weltee65d40e2017-12-13 00:09:06 +01003002 }
Harald Welte2caa1062018-03-17 18:19:05 +01003003 [] T_retrans.timeout {
3004 /* re-trnsmit the zero-space LOAD IND to avoid BSC 'auto credit' */
3005 f_ipa_tx(0, ts_RSL_PAGING_LOAD_IND(0));
3006 T_retrans.start;
3007 repeat;
3008 }
Harald Weltee65d40e2017-12-13 00:09:06 +01003009 [] T.timeout {
3010 setverdict(pass);
3011 }
3012 }
Philipp Maier282ca4b2018-02-27 17:17:00 +01003013
3014 f_shutdown_helper();
Harald Weltee65d40e2017-12-13 00:09:06 +01003015}
3016
Harald Welte235ebf12017-12-15 14:18:16 +01003017/* Verify Paging Counter */
Harald Welte1ff69992017-12-14 12:31:17 +01003018testcase TC_paging_counter() runs on test_CT {
3019 var BSSMAP_FIELD_CellIdentificationList cid_list;
3020 timer T := 4.0;
3021 var integer i;
3022 var integer paging_attempted_bsc;
3023 var integer paging_attempted_bts[NUM_BTS];
3024 var integer paging_expired_bts[NUM_BTS];
3025 cid_list := valueof(ts_BSSMAP_CIL_noCell);
3026
3027 f_init();
3028
3029 /* read counters before paging */
3030 paging_attempted_bsc := f_ctrl_get_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted");
3031 for (i := 0; i < NUM_BTS; i := i+1) {
3032 paging_attempted_bts[i] := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", i, "paging:attempted");
3033 paging_expired_bts[i] := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", i, "paging:expired");
3034 }
3035
3036 f_pageing_helper('001230000000001'H, cid_list, c_BtsId_all);
3037
3038 /* expect the attempted pages on BSC and each BTSs to have incremented by one */
3039 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted", paging_attempted_bsc+1);
3040 for (i := 0; i < NUM_BTS; i := i+1) {
3041 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", i, "paging:attempted",
3042 paging_attempted_bts[i]+1);
3043 }
3044
3045 /* assume that 12s later the paging on all BTSs have expired and hence incremented by 1 */
3046 f_sleep(12.0);
3047 for (i := 0; i < NUM_BTS; i := i+1) {
3048 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", i, "paging:expired",
3049 paging_expired_bts[i]+1);
3050 }
Harald Welte1ff69992017-12-14 12:31:17 +01003051
Philipp Maier282ca4b2018-02-27 17:17:00 +01003052 f_shutdown_helper();
Harald Welte1ff69992017-12-14 12:31:17 +01003053}
3054
3055
Harald Welte10985002017-12-12 09:29:15 +01003056/* Verify paging stops after A-RESET */
3057testcase TC_paging_imsi_a_reset() runs on test_CT {
3058 var BSSMAP_FIELD_CellIdentificationList cid_list;
3059 timer T := 3.0;
3060 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01003061 f_pageing_helper('001010123456789'H, cid_list, c_BtsId_all);
Harald Welte10985002017-12-12 09:29:15 +01003062
3063 /* Perform a BSSMAP Reset and wait for ACK */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003064 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 +01003065 alt {
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003066 [] 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 +01003067 [] BSSAP.receive { repeat; }
3068 }
3069
Daniel Willmanncbef3982018-07-30 09:22:40 +02003070 /* Wait to avoid a possible race condition if a paging message is
3071 * received right before the reset ACK. */
3072 f_sleep(0.2);
3073
Harald Welte10985002017-12-12 09:29:15 +01003074 /* Clear the queue, it might still contain stuff like BCCH FILLING */
Philipp Maier1e6b4422018-02-23 14:02:13 +01003075 for (var integer i := 0; i < sizeof(IPA_RSL); i := i+1) {
3076 IPA_RSL[i].clear;
3077 }
Harald Welte10985002017-12-12 09:29:15 +01003078
3079 /* Wait for 3 seconds if any more PAGING CMD are received on RSL */
3080 T.start;
3081 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07003082 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Welte10985002017-12-12 09:29:15 +01003083 setverdict(fail, "Received PAGING after A-RESET");
Daniel Willmannafce8662018-07-06 23:11:32 +02003084 mtc.stop;
Harald Welte10985002017-12-12 09:29:15 +01003085 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07003086 [] IPA_RSL[1].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Welte5d1a2202017-12-13 19:51:29 +01003087 setverdict(fail, "Received PAGING after A-RESET");
Daniel Willmannafce8662018-07-06 23:11:32 +02003088 mtc.stop;
Harald Welte5d1a2202017-12-13 19:51:29 +01003089 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07003090 [] IPA_RSL[2].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Welte5d1a2202017-12-13 19:51:29 +01003091 setverdict(fail, "Received PAGING after A-RESET");
Daniel Willmannafce8662018-07-06 23:11:32 +02003092 mtc.stop;
Harald Welte5d1a2202017-12-13 19:51:29 +01003093 }
Harald Welte10985002017-12-12 09:29:15 +01003094 [] T.timeout {
3095 setverdict(pass);
3096 }
3097 }
Philipp Maier282ca4b2018-02-27 17:17:00 +01003098
3099 f_shutdown_helper();
Harald Welte10985002017-12-12 09:29:15 +01003100}
Harald Welteae026692017-12-09 01:03:01 +01003101
Philipp Maierf45824a2019-08-14 14:44:10 +02003102/* Verify how we handle unsolicited Paging Response. In case of an unsolicit
3103 * paging response we can not know which MSC is in charge, so we will blindly
3104 * pick the first configured MSC. This behavior is required in order to make
3105 * MT-CSFB calls working because in those cases the BSC can not know that the
3106 * MSC has already paged the subscriver via SGs. So any MT-CSFB call will look
3107 * like an unsolicited Paging Response to the MSC.
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003108 */
3109testcase TC_paging_resp_unsol() runs on test_CT {
3110
3111 f_init(1);
Philipp Maierf45824a2019-08-14 14:44:10 +02003112 timer T := 5.0;
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003113
3114 var BSSAP_N_CONNECT_ind rx_c_ind;
3115 var DchanTuple dt;
3116 var PDU_ML3_MS_NW l3 := valueof(ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010008880018'H))));
Philipp Maierf45824a2019-08-14 14:44:10 +02003117 var octetstring rr_pag_resp := enc_PDU_ML3_MS_NW(l3);
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003118
3119 /* Send CHAN RQD and wait for allocation; acknowledge it */
3120 dt.rsl_chan_nr := f_chreq_act_ack();
3121
3122 /* Send unsolicited Paging response (no matching Paging CMD stored in BSC) */
3123 f_ipa_tx(0, ts_RSL_EST_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)), enc_PDU_ML3_MS_NW(l3)));
3124
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003125
Philipp Maierf45824a2019-08-14 14:44:10 +02003126 /* Expevct a CR with a matching Paging response on the A-Interface */
3127 T.start;
3128 alt {
3129 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(rr_pag_resp))) {
3130 setverdict(pass);
3131 }
3132 [] BSSAP.receive {
3133 setverdict(fail, "Received unexpected message on A-Interface!");
3134 }
3135 [] T.timeout {
3136 setverdict(fail, "Received nothing on A-Interface!");
3137 }
3138 }
3139
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003140 f_shutdown_helper();
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003141}
3142
Harald Welte4e9b9cc2017-12-14 18:31:02 +01003143/* Test RSL link drop causes counter increment */
3144testcase TC_rsl_drop_counter() runs on test_CT {
3145 var integer rsl_fail;
3146
Harald Welte89d42e82017-12-17 16:42:41 +01003147 f_init(1);
Harald Welte4e9b9cc2017-12-14 18:31:02 +01003148
3149 rsl_fail := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "rsl_fail");
3150
3151 bts[0].rsl.vc_IPA.stop;
3152
3153 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "rsl_fail", rsl_fail+1);
3154
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003155 f_shutdown_helper();
Harald Welte4e9b9cc2017-12-14 18:31:02 +01003156}
3157
3158/* TODO: Test OML link drop causes counter increment */
3159
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003160/* The body of TC_rsl_unknown_unit_id() and TC_oml_unknown_unit_id() tests. */
3161function f_ipa_unknown_unit_id(integer mp_bsc_ipa_port) runs on test_CT return boolean {
3162 timer T := 10.0;
3163
3164 bts[0].rsl.id := "IPA-0-RSL";
3165 bts[0].rsl.vc_IPA := IPA_Emulation_CT.create(bts[0].rsl.id & "-IPA");
3166 bts[0].rsl.ccm_pars := c_IPA_default_ccm_pars;
3167 bts[0].rsl.ccm_pars.name := "Osmocom TTCN-3 BTS Simulator";
Oliver Smith92c2bdb2019-08-20 15:11:24 +02003168 bts[0].rsl.ccm_pars.unit_id := "99/0/0"; /* value which is unknown at BTS */
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003169
Pau Espin Pedrol9a5b8ff2021-01-04 19:01:31 +01003170 f_ipa_ctrl_start_client(mp_bsc_ip, mp_bsc_ctrl_port);
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003171
3172 f_init_mgcp("VirtMSC");
3173
3174 /* start RSL/OML connection (XXX re-uses RSL port/protocol definitions for OML) */
3175 map(bts[0].rsl.vc_IPA:IPA_PORT, system:IPA);
3176 connect(bts[0].rsl.vc_IPA:IPA_RSL_PORT, self:IPA_RSL[0]);
3177 bts[0].rsl.vc_IPA.start(IPA_Emulation.main_client(mp_bsc_ip, mp_bsc_ipa_port, "", 10000, bts[0].rsl.ccm_pars));
3178
3179 /* wait for IPA OML link to connect and then disconnect */
3180 T.start;
3181 alt {
Vadim Yanitskiya2afacc2020-05-18 21:16:19 +07003182 [] IPA_RSL[0].receive(tr_ASP_IPA_EV(ASP_IPA_EVENT_DOWN)) {
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003183 T.stop;
3184 return true;
3185 }
3186 [] IPA_RSL[0].receive { repeat }
3187 [] T.timeout {
Daniel Willmannafce8662018-07-06 23:11:32 +02003188 return false;
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003189 }
3190 }
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003191 return false;
3192}
3193
3194/* BSC should close an RSL connection from a BTS with unknown unit ID (OS#2714). */
3195testcase TC_rsl_unknown_unit_id() runs on test_CT {
3196 if (f_ipa_unknown_unit_id(mp_bsc_rsl_port)) {
3197 setverdict(pass);
3198 } else {
3199 setverdict(fail, "Timeout RSL waiting for connection to close");
3200 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003201 f_shutdown_helper();
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003202}
3203
3204
3205/* BSC should close an RSL connection from a BTS with unknown unit ID (OS#2714). */
3206testcase TC_oml_unknown_unit_id() runs on test_CT {
3207 if (f_ipa_unknown_unit_id(mp_bsc_oml_port)) {
3208 setverdict(pass);
3209 } else {
3210 setverdict(fail, "Timeout OML waiting for connection to close");
3211 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003212 f_shutdown_helper();
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003213}
3214
3215
Harald Weltec1a2fff2017-12-17 11:06:19 +01003216/***********************************************************************
Harald Welte6811d102019-04-14 22:23:14 +02003217 * "New world" test cases using RSL_Emulation + RAN_Emulation
Harald Weltec1a2fff2017-12-17 11:06:19 +01003218 ***********************************************************************/
3219
Harald Welte6811d102019-04-14 22:23:14 +02003220import from RAN_Emulation all;
Harald Welte47cd0e32020-08-21 12:39:11 +02003221import from BSSAP_LE_Emulation all;
Harald Weltec1a2fff2017-12-17 11:06:19 +01003222import from RSL_Emulation all;
3223import from MSC_ConnectionHandler all;
3224
3225type function void_fn(charstring id) runs on MSC_ConnHdlr;
3226
Harald Welte336820c2018-05-31 20:34:52 +02003227/* helper function to create and connect a MSC_ConnHdlr component */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003228private function f_connect_handler(inout MSC_ConnHdlr vc_conn, integer bssap_idx := 0) runs on test_CT {
3229 connect(vc_conn:RAN, g_bssap[bssap_idx].vc_RAN:PROC);
Daniel Willmann191e0d92018-01-17 12:44:35 +01003230 connect(vc_conn:MGCP_PROC, vc_MGCP:MGCP_PROC);
Harald Weltec1a2fff2017-12-17 11:06:19 +01003231 connect(vc_conn:RSL, bts[0].rsl.vc_RSL:CLIENT_PT);
Harald Weltef70df652018-01-29 22:00:23 +01003232 connect(vc_conn:RSL_PROC, bts[0].rsl.vc_RSL:RSL_PROC);
Philipp Maier88f4ae82018-03-01 14:00:58 +01003233 if (isvalue(bts[1])) {
Philipp Maier956a92f2018-02-16 10:58:07 +01003234 connect(vc_conn:RSL1, bts[1].rsl.vc_RSL:CLIENT_PT);
3235 connect(vc_conn:RSL1_PROC, bts[1].rsl.vc_RSL:RSL_PROC);
3236 }
Neels Hofmeyr91401012019-07-11 00:42:35 +02003237 if (isvalue(bts[2])) {
3238 connect(vc_conn:RSL2, bts[2].rsl.vc_RSL:CLIENT_PT);
3239 connect(vc_conn:RSL2_PROC, bts[2].rsl.vc_RSL:RSL_PROC);
3240 }
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003241 connect(vc_conn:BSSAP, g_bssap[bssap_idx].vc_RAN:CLIENT);
Neels Hofmeyrcfe44062020-10-15 02:28:08 +02003242 if (mp_enable_lcs_tests) {
3243 connect(vc_conn:BSSAP_LE, g_bssap_le.vc_BSSAP_LE:CLIENT);
3244 connect(vc_conn:BSSAP_LE_PROC, g_bssap_le.vc_BSSAP_LE:PROC);
3245 }
Daniel Willmann191e0d92018-01-17 12:44:35 +01003246 connect(vc_conn:MGCP, vc_MGCP:MGCP_CLIENT);
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02003247 connect(vc_conn:MGCP_MULTI, vc_MGCP:MGCP_CLIENT_MULTI);
Daniel Willmannebdecc02020-08-12 15:30:17 +02003248 connect(vc_conn:STATSD_PROC, vc_STATSD:STATSD_PROC);
Harald Welte336820c2018-05-31 20:34:52 +02003249}
3250
3251function f_start_handler(void_fn fn, template (omit) TestHdlrParams pars := omit)
3252runs on test_CT return MSC_ConnHdlr {
3253 var charstring id := testcasename();
3254 var MSC_ConnHdlr vc_conn;
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003255 var integer bssap_idx := 0;
3256 if (isvalue(pars)) {
3257 bssap_idx := valueof(pars).mscpool.bssap_idx;
3258 }
Harald Welte336820c2018-05-31 20:34:52 +02003259 vc_conn := MSC_ConnHdlr.create(id);
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003260 f_connect_handler(vc_conn, bssap_idx);
Neels Hofmeyr1708d1b2020-10-10 16:56:48 +02003261 /* Emit a marker to appear in the SUT's own logging output */
3262 f_logp(BSCVTY, testcasename() & "() start");
Harald Weltea0630032018-03-20 21:09:55 +01003263 vc_conn.start(f_handler_init(fn, id, pars));
Harald Weltec1a2fff2017-12-17 11:06:19 +01003264 return vc_conn;
3265}
3266
Harald Weltea0630032018-03-20 21:09:55 +01003267/* first function inside ConnHdlr component; sets g_pars + starts function */
3268private function f_handler_init(void_fn fn, charstring id, template (omit) TestHdlrParams pars := omit)
3269runs on MSC_ConnHdlr {
3270 if (isvalue(pars)) {
3271 g_pars := valueof(pars);
3272 }
3273 fn.apply(id);
3274}
3275
Harald Welte3c86ea02018-05-10 22:28:05 +02003276/* Establish signalling channel (non-assignment case) followed by cipher mode */
3277private function f_tc_ciph_mode_a5(charstring id) runs on MSC_ConnHdlr {
Harald Welteed848512018-05-24 22:27:58 +02003278 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3279 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte3c86ea02018-05-10 22:28:05 +02003280 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeSIGNAL);
Philipp Maier23000732018-05-18 11:25:37 +02003281 ass_cmd.pdu.bssmap.assignmentRequest.circuitIdentityCode := omit;
3282 ass_cmd.pdu.bssmap.assignmentRequest.aoIPTransportLayer := omit;
3283 exp_compl.pdu.bssmap.assignmentComplete.circuitIdentityCode := omit;
3284 exp_compl.pdu.bssmap.assignmentComplete.aoIPTransportLayer := omit;
Harald Welte3c86ea02018-05-10 22:28:05 +02003285
Philipp Maier23000732018-05-18 11:25:37 +02003286 f_establish_fully(ass_cmd, exp_compl);
Harald Welte3c86ea02018-05-10 22:28:05 +02003287}
3288testcase TC_ciph_mode_a5_0() runs on test_CT {
3289 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003290 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02003291 pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
3292
3293 f_init(1, true);
3294 f_sleep(1.0);
3295 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
3296 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003297 f_shutdown_helper();
Harald Welte3c86ea02018-05-10 22:28:05 +02003298}
3299testcase TC_ciph_mode_a5_1() runs on test_CT {
3300 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003301 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02003302 pars.encr := valueof(t_EncrParams('02'O, f_rnd_octstring(8)));
3303
3304 f_init(1, true);
3305 f_sleep(1.0);
3306 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
3307 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003308 f_shutdown_helper();
Harald Welte3c86ea02018-05-10 22:28:05 +02003309}
3310testcase TC_ciph_mode_a5_3() runs on test_CT {
3311 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003312 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02003313 pars.encr := valueof(t_EncrParams('08'O, f_rnd_octstring(8)));
3314
3315 f_init(1, true);
3316 f_sleep(1.0);
3317 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
3318 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003319 f_shutdown_helper();
Harald Welte3c86ea02018-05-10 22:28:05 +02003320}
3321
Pau Espin Pedrol07866632020-09-03 19:10:55 +02003322/* establish initial channel, enable ciphering followed by assignment to ciphered channel */
3323private function f_tc_assignment_aoip_tla_v6(charstring id) runs on MSC_ConnHdlr {
3324 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3325 var PDU_BSSAP ass_cmd := f_gen_ass_req(aoip_tla := "::3");
3326 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3327 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
3328
3329 f_establish_fully(ass_cmd, exp_compl);
3330}
3331testcase TC_assignment_aoip_tla_v6() runs on test_CT {
3332 var MSC_ConnHdlr vc_conn;
3333 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3334
3335 f_init(1, true);
3336 f_sleep(1.0);
3337 vc_conn := f_start_handler(refers(f_tc_assignment_aoip_tla_v6), pars);
3338 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003339 f_shutdown_helper();
Pau Espin Pedrol07866632020-09-03 19:10:55 +02003340}
3341
Harald Welte3c86ea02018-05-10 22:28:05 +02003342
3343/* establish initial channel, enable ciphering followed by assignment to ciphered channel */
Harald Welte651fcdc2018-05-10 20:23:16 +02003344private function f_tc_assignment_fr_a5(charstring id) runs on MSC_ConnHdlr {
Harald Welteed848512018-05-24 22:27:58 +02003345 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3346 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Weltec1a2fff2017-12-17 11:06:19 +01003347
Harald Welte552620d2017-12-16 23:21:36 +01003348 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3349 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Welte73cd2712017-12-17 00:44:52 +01003350
Harald Weltea0630032018-03-20 21:09:55 +01003351 f_establish_fully(ass_cmd, exp_compl);
Harald Welte552620d2017-12-16 23:21:36 +01003352}
Harald Welte552620d2017-12-16 23:21:36 +01003353testcase TC_assignment_fr_a5_0() runs on test_CT {
3354 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003355 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02003356 pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
Harald Welte552620d2017-12-16 23:21:36 +01003357
Harald Welte89d42e82017-12-17 16:42:41 +01003358 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01003359 f_sleep(1.0);
Harald Welte651fcdc2018-05-10 20:23:16 +02003360 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
Harald Welte552620d2017-12-16 23:21:36 +01003361 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003362 f_shutdown_helper();
Harald Welte552620d2017-12-16 23:21:36 +01003363}
Harald Welte552620d2017-12-16 23:21:36 +01003364testcase TC_assignment_fr_a5_1() runs on test_CT {
Harald Weltec1a2fff2017-12-17 11:06:19 +01003365 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003366 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02003367 pars.encr := valueof(t_EncrParams('02'O, f_rnd_octstring(8)));
Harald Weltec1a2fff2017-12-17 11:06:19 +01003368
Harald Welte89d42e82017-12-17 16:42:41 +01003369 f_init(1, true);
Harald Weltec1a2fff2017-12-17 11:06:19 +01003370 f_sleep(1.0);
Harald Welte651fcdc2018-05-10 20:23:16 +02003371 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
3372 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003373 f_shutdown_helper();
Harald Welte651fcdc2018-05-10 20:23:16 +02003374}
3375testcase TC_assignment_fr_a5_3() runs on test_CT {
3376 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003377 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02003378 pars.encr := valueof(t_EncrParams('08'O, f_rnd_octstring(8)));
Harald Weltec1a2fff2017-12-17 11:06:19 +01003379
Harald Welte651fcdc2018-05-10 20:23:16 +02003380 f_init(1, true);
3381 f_sleep(1.0);
3382 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
Harald Weltec1a2fff2017-12-17 11:06:19 +01003383 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003384 f_shutdown_helper();
Harald Weltec1a2fff2017-12-17 11:06:19 +01003385}
3386
Harald Welte552620d2017-12-16 23:21:36 +01003387/* Expect ASSIGNMENT FAIL if mandatory IE is missing */
3388private function f_tc_assignment_fr_a5_1_codec_missing(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02003389 g_pars := f_gen_test_hdlr_pars();
Harald Welte552620d2017-12-16 23:21:36 +01003390 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +02003391 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte552620d2017-12-16 23:21:36 +01003392 const OCT8 kc := '0001020304050607'O;
3393
3394 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02003395 /* Omit: ass_cmd.pdu.bssmap.assignmentRequest.codecList */
3396
Harald Weltea0630032018-03-20 21:09:55 +01003397 f_establish_fully(ass_cmd, exp_fail);
Harald Welte552620d2017-12-16 23:21:36 +01003398}
Harald Welte552620d2017-12-16 23:21:36 +01003399testcase TC_assignment_fr_a5_1_codec_missing() runs on test_CT {
3400 var MSC_ConnHdlr vc_conn;
3401
Harald Welte89d42e82017-12-17 16:42:41 +01003402 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01003403 f_sleep(1.0);
3404
Harald Welte8863fa12018-05-10 20:15:27 +02003405 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5_1_codec_missing));
Harald Welte552620d2017-12-16 23:21:36 +01003406 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003407 f_shutdown_helper();
Harald Welte552620d2017-12-16 23:21:36 +01003408}
3409
Harald Welte552620d2017-12-16 23:21:36 +01003410private function f_tc_assignment_fr_a5_4(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02003411 g_pars := f_gen_test_hdlr_pars();
Harald Welteed848512018-05-24 22:27:58 +02003412 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3413 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte552620d2017-12-16 23:21:36 +01003414 const OCT8 kc := '0001020304050607'O;
3415 const OCT16 kc128 := kc & kc;
3416
3417 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3418 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Weltea0630032018-03-20 21:09:55 +01003419 f_establish_fully(ass_cmd, exp_compl);
Harald Welte38b2a102017-12-23 02:42:58 +01003420 f_cipher_mode('10'O, kc, kc128, true);
Harald Welte552620d2017-12-16 23:21:36 +01003421 /* TODO: expect GSM0808_CAUSE_CIPHERING_ALGORITHM_NOT_SUPPORTED cause value */
Harald Welte552620d2017-12-16 23:21:36 +01003422}
Harald Welte552620d2017-12-16 23:21:36 +01003423testcase TC_assignment_fr_a5_4() runs on test_CT {
3424 var MSC_ConnHdlr vc_conn;
3425
Harald Welte89d42e82017-12-17 16:42:41 +01003426 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01003427 f_sleep(1.0);
3428
Harald Welte8863fa12018-05-10 20:15:27 +02003429 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5_4));
Harald Welte552620d2017-12-16 23:21:36 +01003430 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003431 f_shutdown_helper();
Harald Welte552620d2017-12-16 23:21:36 +01003432}
3433
3434
Harald Welte4532e0a2017-12-23 02:05:44 +01003435private function f_tc_assignment_sign(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02003436 g_pars := f_gen_test_hdlr_pars();
Harald Welte4532e0a2017-12-23 02:05:44 +01003437 var template PDU_BSSAP exp_compl := tr_BSSMAP_AssignmentComplete(omit, omit);
Philipp Maier48604732018-10-09 15:00:37 +02003438 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte4532e0a2017-12-23 02:05:44 +01003439 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeSIGNAL);
Daniel Willmannebdecc02020-08-12 15:30:17 +02003440
3441 f_statsd_reset();
Harald Weltea0630032018-03-20 21:09:55 +01003442 f_establish_fully(ass_cmd, exp_compl);
Daniel Willmannebdecc02020-08-12 15:30:17 +02003443
3444 var StatsDExpects expect := {
Daniel Willmannc5398f72020-09-21 10:41:35 +02003445 { name := "TTCN3.bts.0.chreq.total", mtype := "c", min := 1, max := 1},
3446 { name := "TTCN3.bts.0.chreq.successful", mtype := "c", min := 1, max := 1},
Daniel Willmannebdecc02020-08-12 15:30:17 +02003447 { name := "TTCN3.bsc.0.assignment.attempted", mtype := "c", min := 1, max := 1},
3448 { name := "TTCN3.bsc.0.assignment.completed", mtype := "c", min := 1, max := 1}
3449 };
3450 f_statsd_expect(expect);
Harald Welte4532e0a2017-12-23 02:05:44 +01003451}
3452
3453testcase TC_assignment_sign() runs on test_CT {
3454 var MSC_ConnHdlr vc_conn;
3455
3456 f_init(1, true);
3457 f_sleep(1.0);
3458
Harald Welte8863fa12018-05-10 20:15:27 +02003459 vc_conn := f_start_handler(refers(f_tc_assignment_sign));
Harald Welte4532e0a2017-12-23 02:05:44 +01003460 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003461 f_shutdown_helper();
Harald Welte4532e0a2017-12-23 02:05:44 +01003462}
3463
Harald Welte60aa5762018-03-21 19:33:13 +01003464/***********************************************************************
3465 * Codec (list) testing
3466 ***********************************************************************/
3467
3468/* check if the given rsl_mode is compatible with the a_elem */
3469private function f_match_codec(BSSMAP_FIELD_CodecElement a_elem, RSL_IE_ChannelMode rsl_mode)
3470return boolean {
3471 select (a_elem.codecType) {
3472 case (GSM_FR) {
3473 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM1))) {
3474 return true;
3475 }
3476 }
3477 case (GSM_HR) {
3478 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1))) {
3479 return true;
3480 }
3481 }
3482 case (GSM_EFR) {
3483 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM2))) {
3484 return true;
3485 }
3486 }
3487 case (FR_AMR) {
3488 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM3))) {
3489 return true;
3490 }
3491 }
3492 case (HR_AMR) {
3493 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM3))) {
3494 return true;
3495 }
3496 }
3497 case else { }
3498 }
3499 return false;
3500}
3501
3502/* check if the given rsl_mode is compatible with the a_list */
3503private function f_match_codecs(BSSMAP_IE_SpeechCodecList a_list, RSL_IE_ChannelMode rsl_mode)
3504return boolean {
3505 for (var integer i := 0; i < sizeof(a_list); i := i+1) {
3506 if (f_match_codec(a_list.codecElements[i], rsl_mode)) {
3507 return true;
3508 }
3509 }
3510 return false;
3511}
3512
3513/* determine BSSMAP_IE_ChannelType from *first* element of BSSMAP_FIELD_CodecElement */
Philipp Maier61f6b572018-07-06 14:03:38 +02003514function f_BSSMAP_chtype_from_codec(BSSMAP_FIELD_CodecElement a_elem)
Harald Welte60aa5762018-03-21 19:33:13 +01003515return BSSMAP_IE_ChannelType {
3516 /* FIXME: actually look at all elements of BSSMAP_IE_SpeechCodecList */
3517 var BSSMAP_IE_ChannelType ret := valueof(ts_BSSMAP_IE_ChannelType);
3518 select (a_elem.codecType) {
3519 case (GSM_FR) {
3520 ret.channelRateAndType := ChRate_TCHF;
3521 ret.speechId_DataIndicator := Spdi_TCHF_FR;
3522 }
3523 case (GSM_HR) {
3524 ret.channelRateAndType := ChRate_TCHH;
3525 ret.speechId_DataIndicator := Spdi_TCHH_HR;
3526 }
3527 case (GSM_EFR) {
3528 ret.channelRateAndType := ChRate_TCHF;
3529 ret.speechId_DataIndicator := Spdi_TCHF_EFR;
3530 }
3531 case (FR_AMR) {
3532 ret.channelRateAndType := ChRate_TCHF;
3533 ret.speechId_DataIndicator := Spdi_TCHF_AMR;
3534 }
3535 case (HR_AMR) {
3536 ret.channelRateAndType := ChRate_TCHH;
3537 ret.speechId_DataIndicator := Spdi_TCHH_AMR;
3538 }
3539 case else {
3540 setverdict(fail, "Unsupported codec ", a_elem);
Daniel Willmannafce8662018-07-06 23:11:32 +02003541 mtc.stop;
Harald Welte60aa5762018-03-21 19:33:13 +01003542 }
3543 }
3544 return ret;
3545}
3546
Harald Weltea63b9102018-03-22 20:36:16 +01003547private function f_rsl_chmod_tmpl_from_codec(BSSMAP_FIELD_CodecElement a_elem)
3548return template RSL_IE_Body {
3549 var template RSL_IE_Body mode_ie := {
3550 chan_mode := {
3551 len := ?,
3552 reserved := ?,
3553 dtx_d := ?,
3554 dtx_u := ?,
3555 spd_ind := RSL_SPDI_SPEECH,
3556 ch_rate_type := -,
3557 coding_alg_rate := -
3558 }
3559 }
3560
3561 select (a_elem.codecType) {
3562 case (GSM_FR) {
3563 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
3564 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM1;
3565 }
3566 case (GSM_HR) {
3567 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_H;
3568 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM1;
3569 }
3570 case (GSM_EFR) {
3571 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
3572 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM2;
3573 }
3574 case (FR_AMR) {
3575 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
3576 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM3;
3577 }
3578 case (HR_AMR) {
3579 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_H;
3580 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM3;
3581 }
3582 }
3583 return mode_ie;
3584}
3585
Harald Welte60aa5762018-03-21 19:33:13 +01003586type record CodecListTest {
3587 BSSMAP_IE_SpeechCodecList codec_list,
3588 charstring id
3589}
3590type record of CodecListTest CodecListTests
3591
3592private function f_TC_assignment_codec(charstring id) runs on MSC_ConnHdlr {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02003593 var PDU_BSSAP ass_cmd := f_gen_ass_req(g_pars.use_osmux);
3594 var template PDU_BSSAP exp_compl := f_gen_exp_compl(g_pars.use_osmux);
Harald Welte60aa5762018-03-21 19:33:13 +01003595
3596 /* puzzle together the ASSIGNMENT REQ for given codec[s] */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003597 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welte79f3f542018-05-25 20:02:37 +02003598 ass_cmd.pdu.bssmap.assignmentRequest.codecList := g_pars.ass_codec_list;
3599 exp_compl.pdu.bssmap.assignmentComplete.speechCodec.codecElements[0] :=
3600 g_pars.ass_codec_list.codecElements[0];
Philipp Maierd0e64b02019-03-13 14:15:23 +01003601 if (isvalue(g_pars.expect_mr_s0_s7)) {
3602 exp_compl.pdu.bssmap.assignmentComplete.speechCodec.codecElements[0].s0_7 :=
3603 g_pars.expect_mr_s0_s7;
3604 }
Harald Welte79f3f542018-05-25 20:02:37 +02003605 }
Harald Welte60aa5762018-03-21 19:33:13 +01003606 ass_cmd.pdu.bssmap.assignmentRequest.channelType :=
3607 f_BSSMAP_chtype_from_codec(g_pars.ass_codec_list.codecElements[0]);
Harald Welte60aa5762018-03-21 19:33:13 +01003608 log("expecting ASS COMPL like this: ", exp_compl);
3609
3610 f_establish_fully(ass_cmd, exp_compl);
Harald Weltea63b9102018-03-22 20:36:16 +01003611
3612 /* Verify that the RSL-side activation actually matches our expectations */
3613 var RSL_Message rsl := f_rslem_get_last_act(RSL_PROC, 0, g_chan_nr);
3614
3615 var RSL_IE_Body mode_ie;
3616 if (f_rsl_find_ie(rsl, RSL_IE_CHAN_MODE, mode_ie) == false) {
3617 setverdict(fail, "Couldn't find CHAN_MODE IE");
Daniel Willmannafce8662018-07-06 23:11:32 +02003618 mtc.stop;
Harald Weltea63b9102018-03-22 20:36:16 +01003619 }
3620 var template RSL_IE_Body t_mode_ie := f_rsl_chmod_tmpl_from_codec(g_pars.ass_codec_list.codecElements[0]);
3621 if (not match(mode_ie, t_mode_ie)) {
3622 setverdict(fail, "RSL Channel Mode IE doesn't match expectation");
3623 }
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003624
3625 var RSL_IE_Body mr_conf;
3626 if (g_pars.expect_mr_conf_ie != omit) {
3627 if (f_rsl_find_ie(rsl, RSL_IE_MR_CONFIG, mr_conf) == false) {
3628 setverdict(fail, "Missing MR CONFIG IE in RSL Chan Activ");
Daniel Willmannafce8662018-07-06 23:11:32 +02003629 mtc.stop;
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003630 }
3631 log("found RSL MR CONFIG IE: ", mr_conf);
3632
3633 if (not match(mr_conf, g_pars.expect_mr_conf_ie)) {
3634 setverdict(fail, "RSL MR CONFIG IE does not match expectation. Expected: ",
3635 g_pars.expect_mr_conf_ie);
3636 }
3637 } else {
3638 if (f_rsl_find_ie(rsl, RSL_IE_MR_CONFIG, mr_conf) == true) {
3639 log("found RSL MR CONFIG IE: ", mr_conf);
3640 setverdict(fail, "Found MR CONFIG IE in RSL Chan Activ, expecting omit");
Daniel Willmannafce8662018-07-06 23:11:32 +02003641 mtc.stop;
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003642 }
3643 }
Harald Welte60aa5762018-03-21 19:33:13 +01003644}
3645
Philipp Maierd0e64b02019-03-13 14:15:23 +01003646private function f_TC_assignment_codec_fail(charstring id) runs on MSC_ConnHdlr {
3647
3648 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3649 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
3650
3651 /* puzzle together the ASSIGNMENT REQ for given codec[s] */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003652 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Philipp Maierd0e64b02019-03-13 14:15:23 +01003653 ass_cmd.pdu.bssmap.assignmentRequest.codecList := g_pars.ass_codec_list;
3654 }
3655 ass_cmd.pdu.bssmap.assignmentRequest.channelType :=
3656 f_BSSMAP_chtype_from_codec(g_pars.ass_codec_list.codecElements[0]);
3657 log("expecting ASS FAIL like this: ", exp_fail);
3658
3659 f_establish_fully(ass_cmd, exp_fail);
3660}
3661
Harald Welte60aa5762018-03-21 19:33:13 +01003662testcase TC_assignment_codec_fr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003663 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003664 var MSC_ConnHdlr vc_conn;
3665
3666 f_init(1, true);
3667 f_sleep(1.0);
3668
3669 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Welte8863fa12018-05-10 20:15:27 +02003670 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003671 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003672 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01003673}
3674
3675testcase TC_assignment_codec_hr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003676 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003677 var MSC_ConnHdlr vc_conn;
3678
3679 f_init(1, true);
3680 f_sleep(1.0);
3681
3682 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
Harald Welte8863fa12018-05-10 20:15:27 +02003683 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003684 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003685 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01003686}
3687
3688testcase TC_assignment_codec_efr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003689 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003690 var MSC_ConnHdlr vc_conn;
3691
3692 f_init(1, true);
3693 f_sleep(1.0);
3694
3695 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecEFR}));
Harald Welte8863fa12018-05-10 20:15:27 +02003696 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003697 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003698 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01003699}
3700
Philipp Maierd0e64b02019-03-13 14:15:23 +01003701/* Allow 5,90k only (current default config) */
3702private function f_allow_amr_rate_5_90k() runs on test_CT {
Neels Hofmeyr2a5670b2020-11-25 23:39:57 +00003703 f_vty_cfg_msc(BSCVTY, 0, {
3704 "amr-config 12_2k forbidden",
3705 "amr-config 10_2k forbidden",
3706 "amr-config 7_95k forbidden",
3707 "amr-config 7_40k forbidden",
3708 "amr-config 6_70k forbidden",
3709 "amr-config 5_90k allowed",
3710 "amr-config 5_15k forbidden",
3711 "amr-config 4_75k forbidden"
3712 });
Philipp Maierd0e64b02019-03-13 14:15:23 +01003713}
3714
3715/* Allow 4,75k, 5,90k, 4,70k and 12,2k, which are the most common rates
3716 * ("Config-NB-Code = 1") */
3717private function f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k() runs on test_CT {
Neels Hofmeyr2a5670b2020-11-25 23:39:57 +00003718 f_vty_cfg_msc(BSCVTY, 0, {
3719 "amr-config 12_2k allowed",
3720 "amr-config 10_2k forbidden",
3721 "amr-config 7_95k forbidden",
3722 "amr-config 7_40k allowed",
3723 "amr-config 6_70k forbidden",
3724 "amr-config 5_90k allowed",
3725 "amr-config 5_15k forbidden",
3726 "amr-config 4_75k allowed"
3727 });
Philipp Maierd0e64b02019-03-13 14:15:23 +01003728}
3729
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003730private function f_vty_amr_start_mode_set(boolean fr, charstring startmode) runs on test_CT {
3731 var charstring tch;
3732 if (fr) {
3733 tch := "tch-f";
3734 } else {
3735 tch := "tch-h";
3736 }
3737 f_vty_cfg_bts(BSCVTY, 0, { "amr " & tch & " start-mode " & startmode });
3738}
3739
3740/* Set the AMR start-mode for this TCH back to the default configuration. */
3741private function f_vty_amr_start_mode_restore(boolean fr) runs on test_CT {
3742 f_vty_amr_start_mode_set(fr, "auto");
3743}
3744
Harald Welte60aa5762018-03-21 19:33:13 +01003745testcase TC_assignment_codec_amr_f() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003746 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003747 var MSC_ConnHdlr vc_conn;
Philipp Maier7695a0d2018-09-27 17:52:14 +02003748
3749 /* Note: This setups the codec configuration. The parameter payload in
3750 * mr_conf must be consistant with the parameter codecElements in pars
3751 * and also must match the amr-config in osmo-bsc.cfg! */
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003752 var RSL_IE_Body mr_conf := {
3753 other := {
3754 len := 2,
3755 payload := '2804'O
3756 }
3757 };
Harald Welte60aa5762018-03-21 19:33:13 +01003758
Philipp Maier7695a0d2018-09-27 17:52:14 +02003759 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
Philipp Maier806f8f12019-03-12 12:13:41 +01003760 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
Philipp Maier7695a0d2018-09-27 17:52:14 +02003761 pars.ass_codec_list.codecElements[0].s8_15 := '01010111'B;
3762 pars.expect_mr_conf_ie := mr_conf;
3763
Harald Welte60aa5762018-03-21 19:33:13 +01003764 f_init(1, true);
3765 f_sleep(1.0);
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003766 f_vty_amr_start_mode_set(true, "1");
Harald Welte60aa5762018-03-21 19:33:13 +01003767
Harald Welte8863fa12018-05-10 20:15:27 +02003768 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003769 vc_conn.done;
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003770
3771 f_vty_amr_start_mode_restore(true);
Vadim Yanitskiy292e5962021-01-03 14:18:47 +01003772 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01003773}
3774
3775testcase TC_assignment_codec_amr_h() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003776 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003777 var MSC_ConnHdlr vc_conn;
Philipp Maier7695a0d2018-09-27 17:52:14 +02003778
3779 /* See note above */
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003780 var RSL_IE_Body mr_conf := {
3781 other := {
3782 len := 2,
3783 payload := '2804'O
3784 }
3785 };
Harald Welte60aa5762018-03-21 19:33:13 +01003786
Philipp Maier7695a0d2018-09-27 17:52:14 +02003787 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
Philipp Maier806f8f12019-03-12 12:13:41 +01003788 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
Philipp Maier7695a0d2018-09-27 17:52:14 +02003789 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
3790 pars.expect_mr_conf_ie := mr_conf;
3791
Harald Welte60aa5762018-03-21 19:33:13 +01003792 f_init(1, true);
3793 f_sleep(1.0);
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003794 f_vty_amr_start_mode_set(false, "1");
Harald Welte60aa5762018-03-21 19:33:13 +01003795
Harald Welte8863fa12018-05-10 20:15:27 +02003796 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003797 vc_conn.done;
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003798
3799 f_vty_amr_start_mode_restore(false);
Vadim Yanitskiy292e5962021-01-03 14:18:47 +01003800 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01003801}
3802
Neels Hofmeyr454d7922020-11-26 02:24:57 +00003803/* 'amr start-mode auto' should not keep the (unused) 'smod' bits from previous configuration */
3804testcase TC_assignment_codec_amr_startmode_cruft() runs on test_CT {
3805 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3806 var MSC_ConnHdlr vc_conn;
3807
3808 var RSL_IE_Body mr_conf := {
3809 other := {
3810 len := 2,
3811 payload := '2004'O /* <- expect ICMI=0, smod=00 */
3812 }
3813 };
3814
3815 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
3816 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
3817 pars.ass_codec_list.codecElements[0].s8_15 := '01010111'B;
3818 pars.expect_mr_conf_ie := mr_conf;
3819
3820 f_init(1, true);
3821 f_sleep(1.0);
3822
3823 /* First set nonzero start mode bits */
3824 f_vty_amr_start_mode_set(true, "4");
3825 /* Now set to auto, and expect the startmode bits to be zero in the message, i.e. ensure that osmo-bsc does not
3826 * let the startmode bits stick around and has deterministic MultiRate config for 'start-mode auto'; that is
3827 * ensured by above '2004'O, where 'x0xx'O indicates ICMI = 0, spare = 0, smod = 00. */
3828 f_vty_amr_start_mode_set(true, "auto");
3829
3830 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
3831 vc_conn.done;
Neels Hofmeyr454d7922020-11-26 02:24:57 +00003832
3833 /* Clear the startmode bits to not affect subsequent tests, in case the bits should indeed stick around. */
3834 f_vty_amr_start_mode_set(true, "1");
3835 f_vty_amr_start_mode_restore(true);
Vadim Yanitskiy292e5962021-01-03 14:18:47 +01003836 f_shutdown_helper();
Neels Hofmeyr454d7922020-11-26 02:24:57 +00003837}
3838
Neels Hofmeyr21863562020-11-26 00:34:33 +00003839function f_TC_assignment_codec_amr(boolean fr, octetstring mrconf, bitstring s8_s0, bitstring exp_s8_s0,
3840 charstring start_mode := "1")
Philipp Maierd0e64b02019-03-13 14:15:23 +01003841runs on test_CT {
3842
3843 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3844 var MSC_ConnHdlr vc_conn;
3845
3846 /* See note above */
3847 var RSL_IE_Body mr_conf := {
3848 other := {
3849 len := lengthof(mrconf),
3850 payload := mrconf
3851 }
3852 };
3853
3854 if (fr) {
3855 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
3856 } else {
3857 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
3858 }
3859 pars.ass_codec_list.codecElements[0].s0_7 := s8_s0;
3860 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
3861 pars.expect_mr_conf_ie := mr_conf;
3862 pars.expect_mr_s0_s7 := exp_s8_s0;
3863
3864 f_init(1, true);
3865 f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k();
Neels Hofmeyr21863562020-11-26 00:34:33 +00003866 f_vty_amr_start_mode_set(fr, start_mode);
Philipp Maierd0e64b02019-03-13 14:15:23 +01003867 f_sleep(1.0);
3868
3869 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
3870 vc_conn.done;
3871 f_allow_amr_rate_5_90k();
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003872 f_vty_amr_start_mode_restore(fr);
Philipp Maierd0e64b02019-03-13 14:15:23 +01003873}
3874
3875function f_TC_assignment_codec_amr_fail(boolean fr, bitstring s8_s0)
3876runs on test_CT {
3877
3878 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3879 var MSC_ConnHdlr vc_conn;
3880
3881 if (fr) {
3882 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
3883 } else {
3884 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
3885 }
3886 pars.ass_codec_list.codecElements[0].s0_7 := s8_s0;
3887 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
3888
3889 f_init(1, true);
3890 f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k();
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003891 f_vty_amr_start_mode_set(fr, "1");
Philipp Maierd0e64b02019-03-13 14:15:23 +01003892 f_sleep(1.0);
3893
3894 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fail), pars);
3895 vc_conn.done;
3896 f_allow_amr_rate_5_90k();
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003897 f_vty_amr_start_mode_restore(fr);
Philipp Maierd0e64b02019-03-13 14:15:23 +01003898}
3899
3900
3901/* Set S1, we expect an AMR multirate configuration IE with all four rates
3902 * set. */
3903testcase TC_assignment_codec_amr_f_S1() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003904 f_TC_assignment_codec_amr(true, '289520882208'O, '00000010'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003905 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003906}
3907
3908/* Set S1, we expect an AMR multirate configuration IE with the lower three
3909 * rates set. */
3910testcase TC_assignment_codec_amr_h_S1() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003911 f_TC_assignment_codec_amr(false, '2815208820'O, '00000010'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003912 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003913}
3914
3915/* Set S1 and two other rates, we expect an AMR MULTIRATE CONFIGURATION IE with
3916 * all four rates (and only S1 set in the ASSIGNMENT COMPLETE) */
3917testcase TC_assignment_codec_amr_f_S124() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003918 f_TC_assignment_codec_amr(true, '289520882208'O, '00010110'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003919 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003920}
3921
3922/* Set S1 and two other rates, we expect an AMR MULTIRATE CONFIGURATION IE with
3923 * all four rates (and only S1 set in the ASSIGNMENT COMPLETE) */
3924testcase TC_assignment_codec_amr_h_S124() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003925 f_TC_assignment_codec_amr(false, '2815208820'O, '00010110'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003926 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003927}
3928
3929/* The following block of tests selects more and more rates until all four
3930 * possible rates are in the active set (full rate) */
3931testcase TC_assignment_codec_amr_f_S0() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003932 f_TC_assignment_codec_amr(true, '2801'O, '00000001'B, '00000001'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003933 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003934}
3935
3936testcase TC_assignment_codec_amr_f_S02() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003937 f_TC_assignment_codec_amr(true, '28052080'O, '00000101'B, '00000101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003938 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003939}
3940
3941testcase TC_assignment_codec_amr_f_S024() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003942 f_TC_assignment_codec_amr(true, '2815208820'O, '00010101'B, '00010101'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_S0247() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003947 f_TC_assignment_codec_amr(true, '289520882208'O, '10010101'B, '10010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003948 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003949}
3950
3951/* The following block of tests selects more and more rates until all three
3952 * possible rates are in the active set (half rate) */
3953testcase TC_assignment_codec_amr_h_S0() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003954 f_TC_assignment_codec_amr(false, '2801'O, '00000001'B, '00000001'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_S02() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003959 f_TC_assignment_codec_amr(false, '28052080'O, '00000101'B, '00000101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003960 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003961}
3962
3963testcase TC_assignment_codec_amr_h_S024() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003964 f_TC_assignment_codec_amr(false, '2815208820'O, '00010101'B, '00010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003965 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003966}
3967
3968/* The following block tests what happens when the MSC does offer rate
3969 * configurations that are not supported by the BSC. Normally such situations
3970 * should not happen because the MSC gets informed by the BSC in advance via
3971 * the L3 COMPLETE message which rates are applicable. The MSC should not try
3972 * to offer rates that are not applicable anyway. */
3973
3974testcase TC_assignment_codec_amr_h_S0247() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003975 /* Try to include 12,2k in into the active set even though the channel
3976 * is half rate only. The BSC is expected to remove the 12,0k */
3977 f_TC_assignment_codec_amr(false, '2815208820'O, '10010101'B, '00010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003978 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003979}
3980
3981testcase TC_assignment_codec_amr_f_S01234567() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003982 /* See what happens when all rates are selected at once. Since then
3983 * Also S1 is selected, this setting will be prefered and we should
3984 * get 12.2k, 7,40k, 5,90k, and 4,75k in the active set. */
3985 f_TC_assignment_codec_amr(true, '289520882208'O, '11111111'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003986 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003987}
3988
3989testcase TC_assignment_codec_amr_f_S0234567() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003990 /* Same as above, but with S1 missing, the MSC is then expected to
3991 * select the currently supported rates, which are also 12.2k, 7,40k,
3992 * 5,90k, and 4,75k, into the active set. */
3993 f_TC_assignment_codec_amr(true, '289520882208'O, '11111101'B, '10010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003994 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003995}
3996
3997testcase TC_assignment_codec_amr_f_zero() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003998 /* Try to select no rates at all */
3999 f_TC_assignment_codec_amr_fail(true, '00000000'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004000 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004001}
4002
4003testcase TC_assignment_codec_amr_f_unsupp() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004004 /* Try to select only unsupported rates */
4005 f_TC_assignment_codec_amr_fail(true, '01101000'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004006 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004007}
4008
4009testcase TC_assignment_codec_amr_h_S7() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004010 /* Try to select 12,2k for half rate */
4011 f_TC_assignment_codec_amr_fail(false, '10000000'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004012 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004013}
4014
Neels Hofmeyr21863562020-11-26 00:34:33 +00004015testcase TC_assignment_codec_amr_f_start_mode_auto() runs on test_CT {
4016 f_TC_assignment_codec_amr(true, '209520882208'O, '11111111'B, '00000010'B,
4017 start_mode := "auto");
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01004018 f_shutdown_helper();
Neels Hofmeyr21863562020-11-26 00:34:33 +00004019}
4020
4021testcase TC_assignment_codec_amr_h_start_mode_auto() runs on test_CT {
4022 f_TC_assignment_codec_amr(false, '2015208820'O, '10010101'B, '00010101'B,
4023 start_mode := "auto");
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01004024 f_shutdown_helper();
Neels Hofmeyr21863562020-11-26 00:34:33 +00004025}
4026
Neels Hofmeyr3eb94562020-11-26 02:40:26 +00004027testcase TC_assignment_codec_amr_f_start_mode_4() runs on test_CT {
Vadim Yanitskiy7815f482021-01-03 17:07:37 +01004028 /* "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 +00004029 f_TC_assignment_codec_amr(true, '2b9520882208'O, '11111111'B, '00000010'B,
4030 start_mode := "4");
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01004031 f_shutdown_helper();
Neels Hofmeyr3eb94562020-11-26 02:40:26 +00004032}
4033
4034testcase TC_assignment_codec_amr_h_start_mode_4() runs on test_CT {
Vadim Yanitskiy7815f482021-01-03 17:07:37 +01004035 /* "amr tch-h modes 0 2 4" => total 3 modes and start mode 4 => '10'B on the wire */
4036 f_TC_assignment_codec_amr(false, '2a15208820'O, '10010101'B, '00010101'B,
Neels Hofmeyr3eb94562020-11-26 02:40:26 +00004037 start_mode := "4");
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01004038 f_shutdown_helper();
Neels Hofmeyr3eb94562020-11-26 02:40:26 +00004039}
4040
Philipp Maierac09bfc2019-01-08 13:41:39 +01004041private function f_disable_all_tch_f() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01004042 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 1 sub-slot 0 borken");
4043 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 2 sub-slot 0 borken");
4044 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 3 sub-slot 0 borken");
4045 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 4 sub-slot 0 borken");
Philipp Maierac09bfc2019-01-08 13:41:39 +01004046}
4047
4048private function f_disable_all_tch_h() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01004049 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 0 borken");
4050 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 1 borken");
Philipp Maierac09bfc2019-01-08 13:41:39 +01004051}
4052
4053private function f_enable_all_tch() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01004054 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 1 sub-slot 0 unused");
4055 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 2 sub-slot 0 unused");
4056 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 3 sub-slot 0 unused");
4057 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 4 sub-slot 0 unused");
4058 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 0 unused");
4059 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 1 unused");
Philipp Maierac09bfc2019-01-08 13:41:39 +01004060}
4061
4062/* Allow HR only */
4063private function f_TC_assignment_codec_xr_exhausted_req_hr(charstring id) runs on MSC_ConnHdlr {
4064 g_pars := f_gen_test_hdlr_pars();
4065 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4066 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4067 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4068 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '09'O;
4069 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '05'O;
4070 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
4071 f_establish_fully(ass_cmd, exp_compl);
4072}
4073
4074/* Allow FR only */
4075private function f_TC_assignment_codec_xr_exhausted_req_fr(charstring id) runs on MSC_ConnHdlr {
4076 g_pars := f_gen_test_hdlr_pars();
4077 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4078 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4079 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4080 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '08'O;
4081 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '01'O;
4082 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4083 f_establish_fully(ass_cmd, exp_compl);
4084}
4085
4086/* Allow HR only (expect assignment failure) */
4087private function f_TC_assignment_codec_xr_exhausted_req_hr_fail(charstring id) runs on MSC_ConnHdlr {
4088 g_pars := f_gen_test_hdlr_pars();
4089 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4090 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
4091 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4092 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '09'O;
4093 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '05'O;
4094 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
4095 f_establish_fully(ass_cmd, exp_fail);
4096}
4097
4098/* Allow FR only (expect assignment failure) */
4099private function f_TC_assignment_codec_xr_exhausted_req_fr_fail(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_fail := tr_BSSMAP_AssignmentFail;
4103 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4104 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '08'O;
4105 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '01'O;
4106 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4107 f_establish_fully(ass_cmd, exp_fail);
4108}
4109
4110/* Allow FR and HR, but prefer FR */
4111private function f_TC_assignment_codec_fr_exhausted_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
4112 g_pars := f_gen_test_hdlr_pars();
4113 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4114 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4115 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4116 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
4117 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
4118 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
4119 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
4120 f_establish_fully(ass_cmd, exp_compl);
4121}
4122
4123/* Allow FR and HR, but prefer HR */
4124private function f_TC_assignment_codec_fr_exhausted_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
4125 g_pars := f_gen_test_hdlr_pars();
4126 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4127 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4128 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4129 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
4130 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
4131 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
4132 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
4133 f_establish_fully(ass_cmd, exp_compl);
4134}
4135
4136/* Allow FR and HR, but prefer FR */
4137private function f_TC_assignment_codec_hr_exhausted_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
4138 g_pars := f_gen_test_hdlr_pars();
4139 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4140 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4141 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4142 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
4143 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
4144 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
4145 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
4146 f_establish_fully(ass_cmd, exp_compl);
4147}
4148
4149/* Allow FR and HR, but prefer HR */
4150private function f_TC_assignment_codec_hr_exhausted_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
4151 g_pars := f_gen_test_hdlr_pars();
4152 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4153 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4154 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4155 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
4156 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
4157 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
4158 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
4159 f_establish_fully(ass_cmd, exp_compl);
4160}
4161
4162/* Request a HR channel while all FR channels are exhausted, this is expected
4163 * to work without conflicts */
4164testcase TC_assignment_codec_fr_exhausted_req_hr() runs on test_CT {
4165 var MSC_ConnHdlr vc_conn;
4166 f_init(1, true);
4167 f_sleep(1.0);
4168 f_enable_all_tch();
4169 f_disable_all_tch_f();
4170 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_hr));
4171 vc_conn.done;
4172 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004173 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004174}
4175
4176/* Request a FR channel while all FR channels are exhausted, this is expected
4177 * to fail. */
4178testcase TC_assignment_codec_fr_exhausted_req_fr() runs on test_CT {
4179 var MSC_ConnHdlr vc_conn;
4180 f_init(1, true);
4181 f_sleep(1.0);
4182 f_enable_all_tch();
4183 f_disable_all_tch_f();
4184 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_fr_fail));
4185 vc_conn.done;
4186 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004187 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004188}
4189
4190/* Request a FR (prefered) or alternatively a HR channel while all FR channels
4191 * are exhausted, this is expected to be resolved by selecting a HR channel. */
4192testcase TC_assignment_codec_fr_exhausted_req_fr_hr() runs on test_CT {
4193 var MSC_ConnHdlr vc_conn;
4194 f_init(1, true);
4195 f_sleep(1.0);
4196 f_enable_all_tch();
4197 f_disable_all_tch_f();
4198 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fr_exhausted_req_fr_hr));
4199 vc_conn.done;
4200 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004201 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004202}
4203
4204/* Request a HR (prefered) or alternatively a FR channel while all FR channels
4205 * are exhausted, this is expected to work without conflicts. */
4206testcase TC_assignment_codec_fr_exhausted_req_hr_fr() runs on test_CT {
4207 var MSC_ConnHdlr vc_conn;
4208 f_init(1, true);
4209 f_sleep(1.0);
4210 f_enable_all_tch();
4211 f_disable_all_tch_f();
4212 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fr_exhausted_req_hr_fr));
4213 vc_conn.done;
4214 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004215 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004216}
4217
4218/* Request a FR channel while all HR channels are exhausted, this is expected
4219 * to work without conflicts */
4220testcase TC_assignment_codec_hr_exhausted_req_fr() runs on test_CT {
4221 var MSC_ConnHdlr vc_conn;
4222 f_init(1, true);
4223 f_sleep(1.0);
4224 f_enable_all_tch();
4225 f_disable_all_tch_h();
4226 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_fr));
4227 vc_conn.done;
4228 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004229 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004230}
4231
4232/* Request a HR channel while all HR channels are exhausted, this is expected
4233 * to fail. */
4234testcase TC_assignment_codec_hr_exhausted_req_hr() runs on test_CT {
4235 var MSC_ConnHdlr vc_conn;
4236 f_init(1, true);
4237 f_sleep(1.0);
4238 f_enable_all_tch();
4239 f_disable_all_tch_h();
4240 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_hr_fail));
4241 vc_conn.done;
4242 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004243 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004244}
4245
4246/* Request a HR (prefered) or alternatively a FR channel while all HR channels
4247 * are exhausted, this is expected to be resolved by selecting a FR channel. */
4248testcase TC_assignment_codec_hr_exhausted_req_hr_fr() runs on test_CT {
4249 var MSC_ConnHdlr vc_conn;
4250 f_init(1, true);
4251 f_sleep(1.0);
4252 f_enable_all_tch();
4253 f_disable_all_tch_h();
4254 vc_conn := f_start_handler(refers(f_TC_assignment_codec_hr_exhausted_req_hr_fr));
4255 vc_conn.done;
4256 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004257 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004258}
4259
4260/* Request a FR (prefered) or alternatively a HR channel while all HR channels
4261 * are exhausted, this is expected to work without conflicts. */
4262testcase TC_assignment_codec_hr_exhausted_req_fr_hr() runs on test_CT {
4263 var MSC_ConnHdlr vc_conn;
4264 f_init(1, true);
4265 f_sleep(1.0);
4266 f_enable_all_tch();
4267 f_disable_all_tch_h();
4268 vc_conn := f_start_handler(refers(f_TC_assignment_codec_hr_exhausted_req_fr_hr));
4269 vc_conn.done;
4270 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004271 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004272}
4273
4274/* Allow FR and HR, but prefer HR */
4275private function f_TC_assignment_codec_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
4276 g_pars := f_gen_test_hdlr_pars();
4277 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4278 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4279 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4280 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
4281 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
4282 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
4283 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
4284 f_establish_fully(ass_cmd, exp_compl);
4285}
4286
4287/* Allow FR and HR, but prefer FR */
4288private function f_TC_assignment_codec_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
4289 g_pars := f_gen_test_hdlr_pars();
4290 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4291 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4292 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4293 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
4294 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
4295 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
4296 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
4297 f_establish_fully(ass_cmd, exp_compl);
4298}
4299
4300/* Request a HR (prefered) or alternatively a FR channel, it is expected that
4301 * HR, which is the prefered type, is selected. */
4302testcase TC_assignment_codec_req_hr_fr() runs on test_CT {
4303 var MSC_ConnHdlr vc_conn;
4304 f_init(1, true);
4305 f_sleep(1.0);
4306 f_enable_all_tch();
4307 vc_conn := f_start_handler(refers(f_TC_assignment_codec_req_hr_fr));
4308 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004309 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004310}
4311
4312/* Request a FR (prefered) or alternatively a HR channel, it is expected that
4313 * FR, which is the prefered type, is selected. */
4314testcase TC_assignment_codec_req_fr_hr() runs on test_CT {
4315 var MSC_ConnHdlr vc_conn;
4316 f_init(1, true);
4317 f_sleep(1.0);
4318 f_enable_all_tch();
4319 vc_conn := f_start_handler(refers(f_TC_assignment_codec_req_fr_hr));
4320 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004321 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004322}
4323
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02004324testcase TC_assignment_osmux() runs on test_CT {
4325 var TestHdlrParams pars := f_gen_test_hdlr_pars();
4326 var MSC_ConnHdlr vc_conn;
4327
4328 /* See note above */
4329 var RSL_IE_Body mr_conf := {
4330 other := {
4331 len := 2,
4332 payload := '2804'O
4333 }
4334 };
4335
4336 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
4337 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
4338 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
4339 pars.expect_mr_conf_ie := mr_conf;
4340 pars.use_osmux := true;
4341
4342 f_init(1, true, true);
4343 f_sleep(1.0);
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00004344 f_vty_amr_start_mode_set(false, "1");
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02004345
4346 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
4347 vc_conn.done;
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00004348
4349 f_vty_amr_start_mode_restore(false);
Vadim Yanitskiy292e5962021-01-03 14:18:47 +01004350 f_shutdown_helper();
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02004351}
4352
Neels Hofmeyr92b12b72018-09-18 14:30:23 +02004353/* test the procedure of the MSC requesting a Classmark Update:
4354 * a) BSSMAP Classmark Request should result in RR CLASSMARK ENQUIRY,
4355 * b) L3 RR CLASSMARK CHANGE should result in BSSMAP CLASSMARK UPDATE */
Harald Welte898113b2018-01-31 18:32:21 +01004356private function f_tc_classmark(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004357 g_pars := f_gen_test_hdlr_pars();
4358
Harald Weltea0630032018-03-20 21:09:55 +01004359 f_create_chan_and_exp();
Harald Welte898113b2018-01-31 18:32:21 +01004360 /* we should now have a COMPL_L3 at the MSC */
4361 BSSAP.receive(tr_BSSMAP_ComplL3);
4362
Neels Hofmeyr92b12b72018-09-18 14:30:23 +02004363 BSSAP.send(ts_BSSMAP_ClassmarkRequest);
4364 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_CM_ENQUIRY));
4365
Harald Welte898113b2018-01-31 18:32:21 +01004366 f_rsl_send_l3(ts_RRM_CM_CHG(valueof(ts_CM2)));
4367 BSSAP.receive(tr_BSSMAP_ClassmarkUpd(?, omit));
4368 setverdict(pass);
4369}
4370testcase TC_classmark() runs on test_CT {
4371 var MSC_ConnHdlr vc_conn;
4372 f_init(1, true);
4373 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004374 vc_conn := f_start_handler(refers(f_tc_classmark));
Harald Welte898113b2018-01-31 18:32:21 +01004375 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004376 f_shutdown_helper();
Harald Welte898113b2018-01-31 18:32:21 +01004377}
4378
Harald Welteeddf0e92020-06-21 19:42:15 +02004379/* Send a CommonID from the simulated MSC and verify that the information is used to
4380 * fill BSC-internal data structures (specifically, bsc_subscr associated with subscr_conn) */
4381private function f_tc_common_id(charstring id) runs on MSC_ConnHdlr {
4382 g_pars := f_gen_test_hdlr_pars();
4383 f_MscConnHdlr_init_vty();
4384
4385 f_create_chan_and_exp();
4386 /* we should now have a COMPL_L3 at the MSC */
4387 BSSAP.receive(tr_BSSMAP_ComplL3);
4388
4389 /* Send CommonID */
4390 BSSAP.send(ts_BSSMAP_CommonId(g_pars.imsi));
4391
4392 /* Use VTY to verify that the IMSI of the subscr_conn is set */
4393 var charstring regex := "*(IMSI: " & hex2str(g_pars.imsi) & ")*";
4394 f_vty_transceive_match_regexp_retry(BSCVTY, "show conns", regex, 0, 4, 1.0);
4395
4396 setverdict(pass);
4397}
4398testcase TC_common_id() runs on test_CT {
4399 var MSC_ConnHdlr vc_conn;
4400 f_init(1, true);
4401 f_sleep(1.0);
4402 vc_conn := f_start_handler(refers(f_tc_common_id));
4403 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004404 f_shutdown_helper();
Harald Welteeddf0e92020-06-21 19:42:15 +02004405}
4406
Harald Weltee3bd6582018-01-31 22:51:25 +01004407private function f_est_single_l3(template PDU_ML3_MS_NW l3) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004408 g_pars := f_gen_test_hdlr_pars();
Harald Weltea0630032018-03-20 21:09:55 +01004409 f_create_chan_and_exp();
Harald Welte898113b2018-01-31 18:32:21 +01004410 /* we should now have a COMPL_L3 at the MSC */
4411 BSSAP.receive(tr_BSSMAP_ComplL3);
4412
Harald Weltee3bd6582018-01-31 22:51:25 +01004413 /* send the single message we want to send */
4414 f_rsl_send_l3(l3);
4415}
4416
4417private function f_bssap_expect_nothing(float sec := 5.00) runs on MSC_ConnHdlr {
4418 timer T := sec;
4419 var PDU_BSSAP bssap;
Harald Welte898113b2018-01-31 18:32:21 +01004420 T.start;
4421 alt {
Harald Weltee3bd6582018-01-31 22:51:25 +01004422 [] BSSAP.receive(PDU_BSSAP:?) -> value bssap {
4423 setverdict(fail, "Unexpected BSSMAP ", bssap);
Daniel Willmannafce8662018-07-06 23:11:32 +02004424 mtc.stop;
Harald Welte898113b2018-01-31 18:32:21 +01004425 }
4426 [] T.timeout {
4427 setverdict(pass);
4428 }
4429 }
4430}
4431
Harald Weltee3bd6582018-01-31 22:51:25 +01004432/* unsolicited ASSIGNMENT FAIL (without ASSIGN) from MS shouldn't bring BSC down */
4433private function f_tc_unsol_ass_fail(charstring id) runs on MSC_ConnHdlr {
4434 f_est_single_l3(ts_RRM_AssignmentFailure('00'O));
4435 f_bssap_expect_nothing();
4436}
Harald Welte898113b2018-01-31 18:32:21 +01004437testcase TC_unsol_ass_fail() 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_unsol_ass_fail));
Harald Welte898113b2018-01-31 18:32:21 +01004442 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004443 f_shutdown_helper();
Harald Welte898113b2018-01-31 18:32:21 +01004444}
Harald Welte552620d2017-12-16 23:21:36 +01004445
Harald Welteea99a002018-01-31 20:46:43 +01004446
4447/* unsolicited ASSIGNMENT COMPLETE (without ASSIGN) from MS shouldn't bring BSC down */
4448private function f_tc_unsol_ass_compl(charstring id) runs on MSC_ConnHdlr {
Harald Weltee3bd6582018-01-31 22:51:25 +01004449 f_est_single_l3(ts_RRM_AssignmentComplete('00'O));
4450 f_bssap_expect_nothing();
Harald Welteea99a002018-01-31 20:46:43 +01004451}
4452testcase TC_unsol_ass_compl() runs on test_CT {
4453 var MSC_ConnHdlr vc_conn;
4454 f_init(1, true);
4455 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004456 vc_conn := f_start_handler(refers(f_tc_unsol_ass_compl));
Harald Welteea99a002018-01-31 20:46:43 +01004457 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004458 f_shutdown_helper();
Harald Welteea99a002018-01-31 20:46:43 +01004459}
4460
4461
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004462/* unsolicited HANDOVER FAIL (without ASSIGN) from MS shouldn't bring BSC down */
4463private function f_tc_unsol_ho_fail(charstring id) runs on MSC_ConnHdlr {
Harald Weltee3bd6582018-01-31 22:51:25 +01004464 f_est_single_l3(ts_RRM_HandoverFailure('00'O));
4465 f_bssap_expect_nothing();
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004466}
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004467testcase TC_unsol_ho_fail() runs on test_CT {
4468 var MSC_ConnHdlr vc_conn;
4469 f_init(1, true);
4470 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004471 vc_conn := f_start_handler(refers(f_tc_unsol_ho_fail));
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004472 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004473 f_shutdown_helper();
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004474}
4475
4476
Harald Weltee3bd6582018-01-31 22:51:25 +01004477/* short message from MS should be ignored */
4478private function f_tc_err_82_short_msg(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004479 g_pars := f_gen_test_hdlr_pars();
Harald Weltea0630032018-03-20 21:09:55 +01004480 f_create_chan_and_exp();
Harald Weltee3bd6582018-01-31 22:51:25 +01004481 /* we should now have a COMPL_L3 at the MSC */
4482 BSSAP.receive(tr_BSSMAP_ComplL3);
4483
4484 /* send short message */
4485 RSL.send(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), ''O));
4486 f_bssap_expect_nothing();
4487}
4488testcase TC_err_82_short_msg() runs on test_CT {
4489 var MSC_ConnHdlr vc_conn;
4490 f_init(1, true);
4491 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004492 vc_conn := f_start_handler(refers(f_tc_err_82_short_msg));
Harald Weltee3bd6582018-01-31 22:51:25 +01004493 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004494 f_shutdown_helper();
Harald Weltee3bd6582018-01-31 22:51:25 +01004495}
4496
4497
Harald Weltee9e02e42018-01-31 23:36:25 +01004498/* 24.008 8.4 Unknown message must trigger RR STATUS */
4499private function f_tc_err_84_unknown_msg(charstring id) runs on MSC_ConnHdlr {
4500 f_est_single_l3(ts_RRM_UL_REL('00'O));
4501 timer T := 3.0
4502 alt {
4503 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_STATUS)) {
4504 setverdict(pass);
4505 }
4506 [] BSSAP.receive { setverdict(fail, "unexpected BSSAP"); }
Harald Welte458fd372018-03-21 11:26:23 +01004507 [] T.timeout { setverdict(fail, "Timeout waiting for RR STATUS"); }
Harald Weltee9e02e42018-01-31 23:36:25 +01004508 }
4509}
4510testcase TC_err_84_unknown_msg() runs on test_CT {
4511 var MSC_ConnHdlr vc_conn;
4512 f_init(1, true);
4513 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004514 vc_conn := f_start_handler(refers(f_tc_err_84_unknown_msg));
Harald Weltee9e02e42018-01-31 23:36:25 +01004515 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004516 f_shutdown_helper();
Harald Weltee9e02e42018-01-31 23:36:25 +01004517}
4518
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004519/***********************************************************************
4520 * Handover
4521 ***********************************************************************/
4522
Harald Welte94e0c342018-04-07 11:33:23 +02004523/* execute a "bts <0-255> trx <0-255> timeslot <0-7> " command on given Dchan */
4524private function f_vty_ts_action(charstring suffix, integer bts_nr, integer trx_nr, integer ts_nr)
4525runs on test_CT {
4526 var charstring cmd := "bts "&int2str(bts_nr)&" trx "&int2str(trx_nr)&
4527 " timeslot "&int2str(ts_nr)&" ";
4528 f_vty_transceive(BSCVTY, cmd & suffix);
4529}
4530
Harald Welte261af4b2018-02-12 21:20:39 +01004531/* 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 +07004532private function f_vty_ss_action(TELNETasp_PT pt, charstring suffix,
4533 uint8_t bts_nr, uint8_t trx_nr,
4534 in RslChannelNr chan_nr)
4535{
Harald Welte261af4b2018-02-12 21:20:39 +01004536 /* FIXME: resolve those from component-global state */
4537 var integer ts_nr := chan_nr.tn;
4538 var integer ss_nr;
4539 if (ischosen(chan_nr.u.ch0)) {
4540 ss_nr := 0;
4541 } else if (ischosen(chan_nr.u.lm)) {
4542 ss_nr := chan_nr.u.lm.sub_chan;
4543 } else if (ischosen(chan_nr.u.sdcch4)) {
4544 ss_nr := chan_nr.u.sdcch4.sub_chan;
4545 } else if (ischosen(chan_nr.u.sdcch8)) {
4546 ss_nr := chan_nr.u.sdcch8.sub_chan;
4547 } else {
4548 setverdict(fail, "Invalid ChanNr ", chan_nr);
Daniel Willmannafce8662018-07-06 23:11:32 +02004549 mtc.stop;
Harald Welte261af4b2018-02-12 21:20:39 +01004550 }
4551
4552 var charstring cmd := "bts "&int2str(bts_nr)&" trx "&int2str(trx_nr)&
4553 " timeslot "&int2str(ts_nr)&" sub-slot "&int2str(ss_nr)&" ";
Vadim Yanitskiy00070722020-09-02 17:27:57 +07004554 f_vty_transceive(pt, cmd & suffix);
Harald Welte261af4b2018-02-12 21:20:39 +01004555}
4556
Neels Hofmeyr91401012019-07-11 00:42:35 +02004557/* Even though the VTY command to trigger handover takes a new BTS number as argument, behind the scenes osmo-bsc always
4558 * translates that to a target ARFCN+BSIC first. See bsc_vty.c trigger_ho_or_as(), which puts the selected BTS' neighbor
4559 * ident key (ARFCN + BSIC) in the struct passed on to handover_request(). handover_start() then resolves that to a
4560 * viable actual neighbor cell. So from the internal osmo-bsc perspective, we always request handover to an ARFCN + BSIC
4561 * pair, not really to a specific BTS number. */
Vadim Yanitskiy00070722020-09-02 17:27:57 +07004562private function f_vty_handover(TELNETasp_PT pt, uint8_t bts_nr, uint8_t trx_nr,
4563 in RslChannelNr chan_nr, uint8_t new_bts_nr)
4564{
4565 f_vty_ss_action(pt, "handover " & int2str(new_bts_nr), bts_nr, trx_nr, chan_nr);
Harald Welte261af4b2018-02-12 21:20:39 +01004566}
4567
4568/* intra-BSC hand-over between BTS0 and BTS1 */
4569private function f_tc_ho_int(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004570 g_pars := f_gen_test_hdlr_pars();
Harald Welteed848512018-05-24 22:27:58 +02004571 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4572 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte261af4b2018-02-12 21:20:39 +01004573 const OCT8 kc := '0001020304050607'O;
4574
4575 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4576 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4577
Harald Weltea0630032018-03-20 21:09:55 +01004578 f_establish_fully(ass_cmd, exp_compl);
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004579 f_bts_0_cfg(BSCVTY, {"neighbor bts 1"});
Harald Welte261af4b2018-02-12 21:20:39 +01004580
4581 var HandoverState hs := {
4582 rr_ho_cmpl_seen := false,
4583 handover_done := false,
4584 old_chan_nr := -
4585 };
4586 /* issue hand-over command on VTY */
Vadim Yanitskiy00070722020-09-02 17:27:57 +07004587 f_vty_handover(BSCVTY, 0, 0, g_chan_nr, 1);
Harald Welte261af4b2018-02-12 21:20:39 +01004588 /* temporarily suspend DChan processing on BTS1 to avoid race with RSLEM_register */
4589 f_rslem_suspend(RSL1_PROC);
Philipp Maier3e2af5d2018-07-11 17:01:05 +02004590
4591 /* From the MGW perspective, a handover is is characterized by
4592 * performing one MDCX operation with the MGW. So we expect to see
4593 * one more MDCX during handover. */
4594 g_media.mgcp_conn[0].mdcx_seen_exp := g_media.mgcp_conn[0].crcx_seen_exp + 1;
4595
Harald Welte261af4b2018-02-12 21:20:39 +01004596 alt {
4597 [] as_handover(hs);
Harald Welte261af4b2018-02-12 21:20:39 +01004598 }
Philipp Maier3e2af5d2018-07-11 17:01:05 +02004599
Philipp Maier4dae0652018-11-12 12:03:26 +01004600 /* Since this is an internal handover we expect the BSC to inform the
4601 * MSC about the event */
4602 BSSAP.receive(tr_BSSMAP_HandoverPerformed);
4603
Philipp Maier3e2af5d2018-07-11 17:01:05 +02004604 /* Check the amount of MGCP transactions is still consistant with the
4605 * test expectation */
4606 f_check_mgcp_expectations()
Neels Hofmeyr861a4c12018-11-07 01:23:17 +01004607 f_sleep(0.5);
Harald Welte261af4b2018-02-12 21:20:39 +01004608}
4609
4610testcase TC_ho_int() runs on test_CT {
4611 var MSC_ConnHdlr vc_conn;
4612 f_init(2, true);
4613 f_sleep(1.0);
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004614
4615 f_ctrs_bsc_and_bts_init();
4616
Harald Welte8863fa12018-05-10 20:15:27 +02004617 vc_conn := f_start_handler(refers(f_tc_ho_int));
Harald Welte261af4b2018-02-12 21:20:39 +01004618 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004619
4620 /* from f_establish_fully() */
4621 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4622 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4623 /* from handover */
4624 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4625 f_ctrs_bsc_and_bts_add(0, "handover:completed");
4626 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
4627 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:completed");
4628 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004629 f_shutdown_helper();
Harald Welte261af4b2018-02-12 21:20:39 +01004630}
Harald Weltee9e02e42018-01-31 23:36:25 +01004631
Neels Hofmeyr5f144212020-11-03 15:41:58 +00004632/* intra-BSC hand-over with CONNection FAILure and cause Radio Link Failure: check RR release cause */
4633private function f_tc_ho_int_radio_link_failure(charstring id) runs on MSC_ConnHdlr {
4634 g_pars := f_gen_test_hdlr_pars();
4635 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4636 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4637 const OCT8 kc := '0001020304050607'O;
4638
4639 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4640 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4641
4642 f_establish_fully(ass_cmd, exp_compl);
4643 f_bts_0_cfg(BSCVTY, {"neighbor bts 1"});
4644
4645 var HandoverState hs := {
4646 rr_ho_cmpl_seen := false,
4647 handover_done := false,
4648 old_chan_nr := -
4649 };
4650 /* issue hand-over command on VTY */
4651 f_vty_handover(BSCVTY, 0, 0, g_chan_nr, 1);
4652 /* temporarily suspend DChan processing on BTS1 to avoid race with RSLEM_register */
4653 f_rslem_suspend(RSL1_PROC);
4654
4655 /* From the MGW perspective, a handover is is characterized by
4656 * performing one MDCX operation with the MGW. So we expect to see
4657 * one more MDCX during handover. */
4658 g_media.mgcp_conn[0].mdcx_seen_exp := g_media.mgcp_conn[0].crcx_seen_exp + 1;
4659
4660 var RSL_Message rsl;
4661 var PDU_ML3_NW_MS l3;
4662 var RslChannelNr new_chan_nr;
4663 var GsmArfcn arfcn;
4664 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr)) -> value rsl {
4665 l3 := dec_PDU_ML3_NW_MS(rsl.ies[2].body.l3_info.payload);
4666 if (not ischosen(l3.msgs.rrm.handoverCommand)) {
4667 setverdict(fail, "Expected handoverCommand");
4668 mtc.stop;
4669 }
4670 }
4671 f_ChDesc2RslChanNr(l3.msgs.rrm.handoverCommand.channelDescription2,
4672 new_chan_nr, arfcn);
4673
4674 f_rslem_register(0, new_chan_nr, RSL1_PROC);
4675
4676 /* resume processing of RSL DChan messages, which was temporarily suspended
4677 * before performing a hand-over */
4678 f_rslem_resume(RSL1_PROC);
4679 RSL1.receive(tr_RSL_IPA_CRCX(new_chan_nr));
4680
4681 f_sleep(1.0);
4682
4683 /* Handover fails because no HANDO DET appears on the new lchan,
4684 * and the old lchan reports a Radio Link Failure. */
4685 RSL.send(ts_RSL_CONN_FAIL_IND(g_chan_nr, RSL_ERR_RADIO_LINK_FAIL));
4686
4687 var PDU_BSSAP rx_clear_request;
4688 BSSAP.receive(tr_BSSMAP_ClearRequest) -> value rx_clear_request;
4689 var BssmapCause cause := bit2int(rx_clear_request.pdu.bssmap.clearRequest.cause.causeValue);
4690 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
4691
4692 var RR_Cause rr_cause := GSM48_RR_CAUSE_ABNORMAL_UNSPEC;
4693
4694 var MgcpCommand mgcp;
4695 interleave {
4696 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE(int2oct(enum2int(rr_cause), 1)))) {}
4697 [] RSL.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {}
4698 [] RSL.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
4699 RSL.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
4700 }
4701 [] RSL1.receive(tr_RSL_DEACT_SACCH(new_chan_nr)) {}
4702 [] RSL1.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
4703 RSL1.send(ts_RSL_RF_CHAN_REL_ACK(new_chan_nr));
4704 }
4705 [] BSSAP.receive(tr_BSSMAP_ClearComplete) {}
4706 }
4707
4708 f_sleep(0.5);
4709 setverdict(pass);
4710}
4711testcase TC_ho_int_radio_link_failure() runs on test_CT {
4712 var MSC_ConnHdlr vc_conn;
4713 f_init(2, true);
4714 f_sleep(1.0);
4715
4716 f_ctrs_bsc_and_bts_init();
4717
4718 vc_conn := f_start_handler(refers(f_tc_ho_int_radio_link_failure));
4719 vc_conn.done;
4720
4721 /* from f_establish_fully() */
4722 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4723 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4724 /* from handover */
4725 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4726 f_ctrs_bsc_and_bts_add(0, "handover:stopped");
4727 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
4728 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:stopped");
4729 f_ctrs_bsc_and_bts_verify();
4730 f_shutdown_helper();
4731}
4732
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004733/* Expecting MGCP to DLCX the endpoint's two connections: towards BTS and towards MSC */
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004734private function f_expect_dlcx_conns() runs on MSC_ConnHdlr {
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004735 var MgcpCommand mgcp;
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02004736 var template MgcpResponse mgcp_resp;
4737 var MGCP_RecvFrom mrf;
4738 var template MgcpMessage msg_resp;
4739 var template MgcpMessage msg_dlcx := {
4740 command := tr_DLCX()
4741 }
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004742
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02004743 if (g_pars.aoip) {
4744 MGCP.receive(tr_DLCX()) -> value mgcp {
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004745 log("Got first DLCX: ", mgcp);
4746 MGCP.send(ts_DLCX_ACK2(mgcp.line.trans_id));
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02004747 };
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004748
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004749 MGCP.receive(tr_DLCX()) -> value mgcp {
4750 log("Got second DLCX: ", mgcp);
4751 MGCP.send(ts_DLCX_ACK2(mgcp.line.trans_id));
4752 };
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02004753 } else {
4754 /* For SCCPLite, BSC doesn't handle the MSC-side */
4755 MGCP_MULTI.receive(tr_MGCP_RecvFrom_any(msg_dlcx)) -> value mrf {
4756 log("Got first DLCX: ", mrf.msg.command);
4757 msg_resp := {
4758 response := ts_DLCX_ACK2(mrf.msg.command.line.trans_id)
4759 }
4760 MGCP_MULTI.send(t_MGCP_SendToMrf(mrf, msg_resp));
4761 };
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004762 }
4763
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004764 BSSAP.receive(tr_BSSMAP_ClearComplete);
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004765}
4766
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004767private function f_tc_ho_out_of_this_bsc(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004768 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004769
4770 var PDU_BSSAP ass_req := f_gen_ass_req();
4771 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4772 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4773 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4774 f_establish_fully(ass_req, exp_compl);
4775
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004776 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004777 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
4778
4779 BSSAP.receive(tr_BSSMAP_HandoverRequired);
4780
4781 f_sleep(0.5);
4782 /* The MSC negotiates Handover Request and Handover Request Ack with
4783 * the other BSS and comes back with a BSSMAP Handover Command
4784 * containing an RR Handover Command coming from the target BSS... */
4785
4786 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
4787 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
4788 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
4789 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
4790 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
4791
4792 /* expect the Handover Command to go out on RR */
4793 var RSL_Message rsl_ho_cmd
4794 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
4795 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
4796 var RSL_IE_Body rsl_ho_cmd_l3;
4797 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
4798 log("RSL message contains no L3 Info IE, expected RR Handover Command");
4799 setverdict(fail);
4800 } else {
4801 log("Found L3 Info: ", rsl_ho_cmd_l3);
4802 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
4803 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
4804 setverdict(fail);
4805 } else {
4806 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
4807 setverdict(pass);
4808 }
4809 }
4810
4811 /* When the other BSS has reported a completed handover, this side is
4812 * torn down. */
4813
4814 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_HANDOVER_SUCCESSFUL;
4815 var BssmapCause cause := enum2int(cause_val);
4816 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
4817
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004818 f_expect_dlcx_conns();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004819 setverdict(pass);
4820 f_sleep(1.0);
4821}
4822testcase TC_ho_out_of_this_bsc() runs on test_CT {
4823 var MSC_ConnHdlr vc_conn;
4824
4825 f_init(1, true);
4826 f_sleep(1.0);
4827
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004828 f_ctrs_bsc_and_bts_init();
4829
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004830 vc_conn := f_start_handler(refers(f_tc_ho_out_of_this_bsc));
4831 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004832
4833 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4834 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4835 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4836 f_ctrs_bsc_and_bts_add(0, "handover:completed");
4837 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
4838 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:completed");
4839 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004840 f_shutdown_helper();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004841}
4842
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00004843private function f_mo_l3_transceive(RSL_DCHAN_PT rsl := RSL,
4844 template (value) RslLinkId link_id := ts_RslLinkID_DCCH(0),
Vadim Yanitskiy2ef6a2f2020-10-08 23:17:32 +07004845 template (present) OCT1 dlci := ?,
Vadim Yanitskiyb93aa432020-10-01 14:23:11 +07004846 octetstring l3 := '0123456789'O)
4847runs on MSC_ConnHdlr {
Neels Hofmeyr43654812020-09-25 01:35:35 +02004848 /* The old lchan and conn should still be active. See that arbitrary L3
4849 * is still going through. */
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00004850 rsl.send(ts_RSL_DATA_IND(g_chan_nr, link_id, l3));
Neels Hofmeyr43654812020-09-25 01:35:35 +02004851 var template PDU_BSSAP exp_data := {
4852 discriminator := '1'B,
4853 spare := '0000000'B,
Vadim Yanitskiyb93aa432020-10-01 14:23:11 +07004854 dlci := dlci,
4855 lengthIndicator := lengthof(l3),
Neels Hofmeyr43654812020-09-25 01:35:35 +02004856 pdu := {
4857 dtap := l3
4858 }
4859 };
4860 BSSAP.receive(exp_data);
4861 setverdict(pass);
4862}
4863
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00004864private function f_mt_l3_transceive(RSL_DCHAN_PT rsl := RSL,
4865 template (present) RslLinkId link_id := tr_RslLinkID_DCCH(0),
Vadim Yanitskiy0033a3b2020-10-01 22:21:16 +07004866 template (value) OCT1 dlci := '00'O,
4867 octetstring l3 := '0123456789'O)
4868runs on MSC_ConnHdlr {
4869 BSSAP.send(PDU_BSSAP:{
4870 discriminator := '1'B,
4871 spare := '0000000'B,
4872 dlci := dlci,
4873 lengthIndicator := lengthof(l3),
4874 pdu := {
4875 dtap := l3
4876 }
4877 });
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00004878 rsl.receive(tr_RSL_DATA_REQ(g_chan_nr, link_id, l3));
Vadim Yanitskiy0033a3b2020-10-01 22:21:16 +07004879 setverdict(pass);
4880}
4881
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004882/* BSC asks for inter-BSC HO, but the MSC decides that it won't happen and
4883 * simply never sends a BSSMAP Handover Command. */
4884private function f_tc_ho_out_fail_no_msc_response(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01004885 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004886
4887 var PDU_BSSAP ass_req := f_gen_ass_req();
4888 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4889 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4890 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4891 f_establish_fully(ass_req, exp_compl);
4892
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004893 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004894 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
4895
4896 BSSAP.receive(tr_BSSMAP_HandoverRequired);
4897
4898 /* osmo-bsc should time out 10 seconds after the handover started.
4899 * Let's give it a bit extra. */
4900 f_sleep(15.0);
4901
Vadim Yanitskiy74ae5eb2020-10-01 22:13:29 +07004902 f_mo_l3_transceive();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004903 f_sleep(1.0);
4904}
4905testcase TC_ho_out_fail_no_msc_response() runs on test_CT {
4906 var MSC_ConnHdlr vc_conn;
4907
4908 f_init(1, true);
4909 f_sleep(1.0);
4910
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004911 f_ctrs_bsc_and_bts_init();
4912
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004913 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_no_msc_response));
4914 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004915
4916 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4917 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4918 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4919 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
4920 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
4921 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
4922 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004923 f_shutdown_helper();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004924}
4925
4926/* BSC asks for inter-BSC HO, receives BSSMAP Handover Command, but MS reports
4927 * RR Handover Failure. */
4928private function f_tc_ho_out_fail_rr_ho_failure(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01004929 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004930
4931 var PDU_BSSAP ass_req := f_gen_ass_req();
4932 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4933 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4934 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4935 f_establish_fully(ass_req, exp_compl);
4936
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004937 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004938 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
4939
4940 BSSAP.receive(tr_BSSMAP_HandoverRequired);
4941
4942 f_sleep(0.5);
4943 /* The MSC negotiates Handover Request and Handover Request Ack with
4944 * the other BSS and comes back with a BSSMAP Handover Command
4945 * containing an RR Handover Command coming from the target BSS... */
4946
4947 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
4948 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
4949 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
4950 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
4951 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
4952
4953 /* expect the Handover Command to go out on RR */
4954 var RSL_Message rsl_ho_cmd
4955 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
4956 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
4957 var RSL_IE_Body rsl_ho_cmd_l3;
4958 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
4959 log("RSL message contains no L3 Info IE, expected RR Handover Command");
4960 setverdict(fail);
4961 } else {
4962 log("Found L3 Info: ", rsl_ho_cmd_l3);
4963 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
4964 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
4965 setverdict(fail);
4966 } else {
4967 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
4968 setverdict(pass);
4969 }
4970 }
4971
4972 f_sleep(0.2);
4973 f_rsl_send_l3(ts_RRM_HandoverFailure('00'O));
4974
4975 /* Should tell the MSC about the failure */
4976 BSSAP.receive(tr_BSSMAP_HandoverFailure);
4977
4978 f_sleep(1.0);
4979
Vadim Yanitskiy74ae5eb2020-10-01 22:13:29 +07004980 f_mo_l3_transceive();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004981 f_sleep(1.0);
4982
4983 setverdict(pass);
4984 f_sleep(1.0);
4985}
4986testcase TC_ho_out_fail_rr_ho_failure() runs on test_CT {
4987 var MSC_ConnHdlr vc_conn;
4988
4989 f_init(1, true);
4990 f_sleep(1.0);
4991
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004992 f_ctrs_bsc_and_bts_init();
4993
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004994 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_rr_ho_failure));
4995 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004996
4997 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4998 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4999 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5000 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5001 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
5002 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:failed");
5003 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005004 f_shutdown_helper();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005005}
5006
Neels Hofmeyr10f2bfa2019-07-09 19:33:29 +02005007/* BSC asks for inter-BSC-out HO, receives BSSMAP Handover Command, but then no reply is received about HO outcome
5008 * (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 +02005009 * and the lchan is released. */
5010private function f_tc_ho_out_fail_no_result_after_ho_cmd(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01005011 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005012
5013 var PDU_BSSAP ass_req := f_gen_ass_req();
5014 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
5015 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
5016 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
5017 f_establish_fully(ass_req, exp_compl);
5018
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005019 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005020 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
5021
5022 BSSAP.receive(tr_BSSMAP_HandoverRequired);
5023
5024 f_sleep(0.5);
5025 /* The MSC negotiates Handover Request and Handover Request Ack with
5026 * the other BSS and comes back with a BSSMAP Handover Command
5027 * containing an RR Handover Command coming from the target BSS... */
5028
5029 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
5030 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
5031 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
5032 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
5033 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
5034
5035 /* expect the Handover Command to go out on RR */
5036 var RSL_Message rsl_ho_cmd
5037 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
5038 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
5039 var RSL_IE_Body rsl_ho_cmd_l3;
5040 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
5041 log("RSL message contains no L3 Info IE, expected RR Handover Command");
5042 setverdict(fail);
5043 } else {
5044 log("Found L3 Info: ", rsl_ho_cmd_l3);
5045 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
5046 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
5047 setverdict(fail);
5048 } else {
5049 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
5050 setverdict(pass);
5051 }
5052 }
5053
Neels Hofmeyr10f2bfa2019-07-09 19:33:29 +02005054 /* We get neither success nor failure report from the remote BSS. Eventually T8 times out and we run into 3GPP
5055 * TS 48.008 3.1.5.3.3 "Abnormal Conditions": Clear Request should go to the MSC, and RR should be released
5056 * after Clear Command */
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005057
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005058 var PDU_BSSAP rx_clear_request;
Neels Hofmeyre1797aa2019-07-09 19:34:04 +02005059 BSSAP.receive(tr_BSSMAP_ClearRequest) -> value rx_clear_request;
5060 log("Got BSSMAP Clear Request");
5061 /* Instruct BSC to clear channel */
5062 var BssmapCause cause := bit2int(rx_clear_request.pdu.bssmap.clearRequest.cause.causeValue);
5063 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5064
5065 var MgcpCommand mgcp;
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005066 interleave {
Neels Hofmeyr861a4c12018-11-07 01:23:17 +01005067 [] RSL.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
5068 log("Got Deact SACCH");
5069 }
Harald Welte924b6ea2019-02-04 01:05:34 +01005070 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
Neels Hofmeyr211169d2018-11-07 00:37:29 +01005071 log("Got RR Release");
5072 }
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005073 [] RSL.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
5074 log("Got RF Chan Rel");
5075 RSL.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
5076 }
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005077 }
5078
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005079 f_expect_dlcx_conns();
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02005080
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005081 setverdict(pass);
5082 f_sleep(1.0);
5083}
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02005084testcase TC_ho_out_fail_no_result_after_ho_cmd() runs on test_CT {
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005085 var MSC_ConnHdlr vc_conn;
5086
5087 f_init(1, true);
5088 f_sleep(1.0);
5089
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005090 f_ctrs_bsc_and_bts_init();
5091
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02005092 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_no_result_after_ho_cmd));
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005093 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005094
5095 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5096 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5097 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5098 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
5099 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
5100 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
5101 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005102 f_shutdown_helper();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005103}
5104
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005105private function f_tc_ho_into_this_bsc(charstring id) runs on MSC_ConnHdlr {
5106 /* Hack: the proper way would be to wait for the BSSMAP Handover Request ACK and extract the
5107 * actual assigned chan_nr from its L3 (RR Handover Command) message. But osmo-bsc starts acting
5108 * on the lchan even before we get a chance to evaluate the BSSMAP Handover Request ACK. So we
5109 * need to assume that osmo-bsc will activate TS 1 and already set up this lchan's RSL emulation
5110 * before we get started. */
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02005111 var template (omit) BSSMAP_oldToNewBSSIEs oldToNewBSSIEs := omit;
5112 var template PDU_ML3_NW_MS exp_rr_rel_tmpl := tr_RRM_RR_RELEASE;
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005113 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
5114 f_rslem_register(0, new_chan_nr);
5115 g_chan_nr := new_chan_nr;
5116 f_sleep(1.0);
5117
5118 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
5119 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5120 activate(as_Media());
5121
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02005122 if (not istemplatekind(g_pars.last_used_eutran_plmn, "omit")) {
5123 oldToNewBSSIEs := f_ts_BSSMAP_oldToNewBSSIEs(ts_BSSMAP_LastUsedEUTRANPLMNId(g_pars.last_used_eutran_plmn));
5124 exp_rr_rel_tmpl := tr_RRM_RR_RELEASE_CellSelectInd;
5125 }
5126
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005127 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02005128 f_gen_handover_req(aoip_tla := g_pars.host_aoip_tla,
5129 oldToNewBSSIEs := oldToNewBSSIEs)));
Harald Welte6811d102019-04-14 22:23:14 +02005130 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005131
5132 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
5133
5134 var PDU_BSSAP rx_bssap;
5135 var octetstring ho_command_str;
5136
5137 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
Pau Espin Pedrol76ba5412019-06-10 11:00:33 +02005138
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005139 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
5140 log("Received L3 Info in HO Request Ack: ", ho_command_str);
5141 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
5142 log("L3 Info in HO Request Ack is ", ho_command);
5143
5144 var GsmArfcn arfcn;
5145 var RslChannelNr actual_new_chan_nr;
5146 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
5147 actual_new_chan_nr, arfcn);
5148
5149 if (actual_new_chan_nr != new_chan_nr) {
5150 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
5151 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
5152 setverdict(fail);
5153 return;
5154 }
5155 log("Handover Command chan_nr is", actual_new_chan_nr);
5156
5157 /* Now the MSC forwards the RR Handover Command to the other BSC, which
5158 * tells the MS to handover to the new lchan. Here comes the new MS on
5159 * the new lchan with a Handover RACH: */
5160
5161 /* send handover detect */
5162
5163 RSL.send(ts_RSL_HANDO_DET(new_chan_nr));
5164
5165 BSSAP.receive(tr_BSSMAP_HandoverDetect);
5166
5167 /* send handover complete over the new channel */
5168
5169 var PDU_ML3_MS_NW l3_tx := valueof(ts_RRM_HandoverComplete('00'O));
5170 RSL.send(ts_RSL_EST_IND(new_chan_nr, valueof(ts_RslLinkID_DCCH(0)),
5171 enc_PDU_ML3_MS_NW(l3_tx)));
5172
5173 BSSAP.receive(tr_BSSMAP_HandoverComplete);
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02005174
5175 f_perform_clear(RSL, exp_rr_rel_tmpl);
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005176 setverdict(pass);
5177}
Pau Espin Pedrol07866632020-09-03 19:10:55 +02005178function f_tc_ho_into_this_bsc_main(TestHdlrParams pars) runs on test_CT {
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005179 var MSC_ConnHdlr vc_conn;
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005180
5181 f_init(1, true);
5182 f_sleep(1.0);
5183
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005184 f_ctrs_bsc_and_bts_init();
5185
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005186 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5187 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005188
5189 vc_conn := f_start_handler(refers(f_tc_ho_into_this_bsc), pars);
5190 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005191
5192 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5193 f_ctrs_bsc_and_bts_add(0, "handover:completed");
5194 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
5195 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:completed");
5196 f_ctrs_bsc_and_bts_verify();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005197}
5198
Pau Espin Pedrol07866632020-09-03 19:10:55 +02005199testcase TC_ho_into_this_bsc() runs on test_CT {
5200 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5201 f_tc_ho_into_this_bsc_main(pars);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005202 f_shutdown_helper();
Pau Espin Pedrol07866632020-09-03 19:10:55 +02005203}
5204
5205testcase TC_ho_into_this_bsc_tla_v6() runs on test_CT {
5206 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5207 pars.host_aoip_tla := "::6";
5208 f_tc_ho_into_this_bsc_main(pars);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005209 f_shutdown_helper();
Pau Espin Pedrol07866632020-09-03 19:10:55 +02005210}
5211
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02005212/* Similar to TC_ho_into_this_bsc, but when in SRVCC, HO Req contains "Old BSS
5213 to New BSS Information" IE with "Last Used E-UTRAN PLMN Id", whihch, when the
5214 channel is later released (RR CHannel Release), should trigger inclusion of
5215 IE "Cell Selection Indicator after Release of all TCH and SDCCH" with E-UTRAN
5216 neighbors. */
5217testcase TC_srvcc_eutran_to_geran() runs on test_CT {
5218 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5219 pars.last_used_eutran_plmn := '323454'O;
5220 f_tc_ho_into_this_bsc_main(pars);
5221 f_shutdown_helper();
5222}
5223
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005224private function f_tc_ho_in_fail_msc_clears(charstring id) runs on MSC_ConnHdlr {
5225 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
5226 f_rslem_register(0, new_chan_nr);
5227 g_chan_nr := new_chan_nr;
5228 f_sleep(1.0);
5229
5230 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
5231 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5232 activate(as_Media());
5233
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005234 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005235 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02005236 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005237
5238 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
5239
5240 var PDU_BSSAP rx_bssap;
5241 var octetstring ho_command_str;
5242
5243 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
5244
5245 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
5246 log("Received L3 Info in HO Request Ack: ", ho_command_str);
5247 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
5248 log("L3 Info in HO Request Ack is ", ho_command);
5249
5250 var GsmArfcn arfcn;
5251 var RslChannelNr actual_new_chan_nr;
5252 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
5253 actual_new_chan_nr, arfcn);
5254
5255 if (actual_new_chan_nr != new_chan_nr) {
5256 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
5257 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
5258 setverdict(fail);
5259 return;
5260 }
5261 log("Handover Command chan_nr is", actual_new_chan_nr);
5262
Neels Hofmeyr61ca08d2019-05-06 23:52:22 +02005263 /* For deterministic test results, give some time for the MGW endpoint to be configured */
5264 f_sleep(1.0);
5265
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005266 /* Now the MSC forwards the RR Handover Command to the other BSC, which
5267 * tells the MS to handover to the new lchan. In this case, the MS
5268 * reports a Handover Failure to the old BSS, which forwards a BSSMAP
5269 * Handover Failure to the MSC. The procedure according to 3GPP TS
5270 * 48.008 3.1.5.3.2 "Handover Failure" is then that the MSC sends a
5271 * BSSMAP Clear Command: */
5272
5273 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
5274 var BssmapCause cause := enum2int(cause_val);
5275 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5276
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005277 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005278 setverdict(pass);
5279 f_sleep(1.0);
5280
5281 setverdict(pass);
5282}
5283testcase TC_ho_in_fail_msc_clears() runs on test_CT {
5284 var MSC_ConnHdlr vc_conn;
5285 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5286
5287 f_init(1, true);
5288 f_sleep(1.0);
5289
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005290 f_ctrs_bsc_and_bts_init();
5291
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005292 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5293 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005294
5295 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_msc_clears), pars);
5296 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005297
5298 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5299 f_ctrs_bsc_and_bts_add(0, "handover:stopped");
5300 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
5301 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:stopped");
5302 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005303 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005304}
5305
5306private function f_tc_ho_in_fail_msc_clears_after_ho_detect(charstring id) runs on MSC_ConnHdlr {
5307 /* Hack: the proper way would be to wait for the BSSMAP Handover Request ACK and extract the
5308 * actual assigned chan_nr from its L3 (RR Handover Command) message. But osmo-bsc starts acting
5309 * on the lchan even before we get a chance to evaluate the BSSMAP Handover Request ACK. So we
5310 * need to assume that osmo-bsc will activate TS 1 and already set up this lchan's RSL emulation
5311 * before we get started. */
5312 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
5313 f_rslem_register(0, new_chan_nr);
5314 g_chan_nr := new_chan_nr;
5315 f_sleep(1.0);
5316
5317 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
5318 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5319 activate(as_Media());
5320
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005321 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005322 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02005323 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005324
5325 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
5326
5327 var PDU_BSSAP rx_bssap;
5328 var octetstring ho_command_str;
5329
5330 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
5331
5332 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
5333 log("Received L3 Info in HO Request Ack: ", ho_command_str);
5334 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
5335 log("L3 Info in HO Request Ack is ", ho_command);
5336
5337 var GsmArfcn arfcn;
5338 var RslChannelNr actual_new_chan_nr;
5339 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
5340 actual_new_chan_nr, arfcn);
5341
5342 if (actual_new_chan_nr != new_chan_nr) {
5343 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
5344 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
5345 setverdict(fail);
5346 return;
5347 }
5348 log("Handover Command chan_nr is", actual_new_chan_nr);
5349
5350 /* Now the MSC forwards the RR Handover Command to the other BSC, which
5351 * tells the MS to handover to the new lchan. Here comes the new MS on
5352 * the new lchan with a Handover RACH: */
5353
5354 /* send handover detect */
5355
5356 RSL.send(ts_RSL_HANDO_DET(new_chan_nr));
5357
5358 BSSAP.receive(tr_BSSMAP_HandoverDetect);
5359
5360 /* The MSC chooses to clear the connection now, maybe we got the
5361 * Handover RACH on the new cell but the MS still signaled Handover
5362 * Failure to the old BSS? */
5363
5364 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
5365 var BssmapCause cause := enum2int(cause_val);
5366 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5367
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005368 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005369 f_sleep(1.0);
5370}
5371testcase TC_ho_in_fail_msc_clears_after_ho_detect() runs on test_CT {
5372 var MSC_ConnHdlr vc_conn;
5373 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5374
5375 f_init(1, true);
5376 f_sleep(1.0);
5377
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005378 f_ctrs_bsc_and_bts_init();
5379
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005380 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5381 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005382
5383 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_msc_clears_after_ho_detect), pars);
5384 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005385
5386 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5387 f_ctrs_bsc_and_bts_add(0, "handover:stopped");
5388 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
5389 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:stopped");
5390 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005391 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005392}
5393
5394/* The new BSS's lchan times out before the MSC decides that handover failed. */
5395private function f_tc_ho_in_fail_no_detect(charstring id) runs on MSC_ConnHdlr {
5396 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
5397 f_rslem_register(0, new_chan_nr);
5398 g_chan_nr := new_chan_nr;
5399 f_sleep(1.0);
5400
5401 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
5402 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5403 activate(as_Media());
5404
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005405 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005406 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02005407 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005408
5409 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
5410
5411 var PDU_BSSAP rx_bssap;
5412 var octetstring ho_command_str;
5413
5414 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
5415
5416 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
5417 log("Received L3 Info in HO Request Ack: ", ho_command_str);
5418 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
5419 log("L3 Info in HO Request Ack is ", ho_command);
5420
5421 var GsmArfcn arfcn;
5422 var RslChannelNr actual_new_chan_nr;
5423 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
5424 actual_new_chan_nr, arfcn);
5425
5426 if (actual_new_chan_nr != new_chan_nr) {
5427 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
5428 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
5429 setverdict(fail);
5430 return;
5431 }
5432 log("Handover Command chan_nr is", actual_new_chan_nr);
5433
5434 /* Now the MSC forwards the RR Handover Command to the other BSC, which
5435 * tells the MS to handover to the new lchan. But the MS never shows up
5436 * on the new lchan. */
5437
5438 BSSAP.receive(tr_BSSMAP_HandoverFailure);
5439
5440 /* Did osmo-bsc also send a Clear Request? */
5441 timer T := 0.5;
5442 T.start;
5443 alt {
5444 [] BSSAP.receive(tr_BSSMAP_ClearRequest);
5445 [] T.timeout { }
5446 }
5447
5448 /* MSC plays along with a Clear Command (no matter whether osmo-bsc
5449 * asked for it, this is a Handover Failure after all). */
5450
5451 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
5452 var BssmapCause cause := enum2int(cause_val);
5453 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5454
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005455 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005456 f_sleep(1.0);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005457}
5458testcase TC_ho_in_fail_no_detect() runs on test_CT {
5459 var MSC_ConnHdlr vc_conn;
5460 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5461
5462 f_init(1, true);
5463 f_sleep(1.0);
5464
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005465 f_ctrs_bsc_and_bts_init();
5466
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005467 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5468 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005469
5470 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_no_detect), pars);
5471 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005472
5473 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5474 f_ctrs_bsc_and_bts_add(0, "handover:error");
5475 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
5476 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:error");
5477 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005478 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005479}
5480
5481/* Same as f_tc_ho_in_fail_no_detect, but MSC fails to send a Clear Command */
5482private function f_tc_ho_in_fail_no_detect2(charstring id) runs on MSC_ConnHdlr {
5483 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
5484 f_rslem_register(0, new_chan_nr);
5485 g_chan_nr := new_chan_nr;
5486 f_sleep(1.0);
5487
5488 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
5489 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5490 activate(as_Media());
5491
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005492 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005493 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02005494 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005495
5496 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
5497
5498 var PDU_BSSAP rx_bssap;
5499 var octetstring ho_command_str;
5500
5501 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
5502
5503 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
5504 log("Received L3 Info in HO Request Ack: ", ho_command_str);
5505 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
5506 log("L3 Info in HO Request Ack is ", ho_command);
5507
5508 var GsmArfcn arfcn;
5509 var RslChannelNr actual_new_chan_nr;
5510 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
5511 actual_new_chan_nr, arfcn);
5512
5513 if (actual_new_chan_nr != new_chan_nr) {
5514 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
5515 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
5516 setverdict(fail);
5517 return;
5518 }
5519 log("Handover Command chan_nr is", actual_new_chan_nr);
5520
5521 /* Now the MSC forwards the RR Handover Command to the other BSC, which
5522 * tells the MS to handover to the new lchan. But the MS never shows up
5523 * on the new lchan. */
5524
5525 BSSAP.receive(tr_BSSMAP_HandoverFailure);
5526
5527 /* MSC plays dumb and sends no Clear Command */
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005528 var PDU_BSSAP rx_clear_request;
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02005529
5530 BSSAP.receive(tr_BSSMAP_ClearRequest) -> value rx_clear_request {
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005531 var BssmapCause cause := bit2int(rx_clear_request.pdu.bssmap.clearRequest.cause.causeValue);
5532 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5533 };
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005534 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005535 f_sleep(1.0);
5536}
5537testcase TC_ho_in_fail_no_detect2() runs on test_CT {
5538 var MSC_ConnHdlr vc_conn;
5539 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5540
5541 f_init(1, true);
5542 f_sleep(1.0);
5543
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005544 f_ctrs_bsc_and_bts_init();
5545
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005546 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5547 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005548
5549 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_no_detect2), pars);
5550 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005551
5552 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5553 f_ctrs_bsc_and_bts_add(0, "handover:error");
5554 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
5555 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:error");
5556 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005557 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005558}
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005559
Neels Hofmeyr91401012019-07-11 00:42:35 +02005560type record of charstring Commands;
5561
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005562private function f_bts_0_cfg(TELNETasp_PT pt, Commands cmds := {})
Neels Hofmeyr91401012019-07-11 00:42:35 +02005563{
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005564 f_vty_enter_cfg_bts(pt, 0);
Neels Hofmeyr91401012019-07-11 00:42:35 +02005565 for (var integer i := 0; i < sizeof(cmds); i := i+1) {
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005566 f_vty_transceive(pt, cmds[i]);
Neels Hofmeyr91401012019-07-11 00:42:35 +02005567 }
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005568 f_vty_transceive(pt, "end");
Neels Hofmeyr91401012019-07-11 00:42:35 +02005569}
5570
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01005571private function f_cs7_inst_0_cfg(TELNETasp_PT pt, Commands cmds := {})
5572{
5573 f_vty_enter_cfg_cs7_inst(pt, 0);
5574 for (var integer i := 0; i < sizeof(cmds); i := i+1) {
5575 f_vty_transceive(pt, cmds[i]);
5576 }
5577 f_vty_transceive(pt, "end");
5578}
5579
Neels Hofmeyr91401012019-07-11 00:42:35 +02005580private function f_probe_for_handover(charstring log_label,
5581 charstring log_descr,
5582 charstring handover_vty_cmd,
5583 boolean expect_handover,
5584 boolean is_inter_bsc_handover := false)
5585runs on MSC_ConnHdlr
5586{
Neels Hofmeyrb3fc8982020-05-11 00:16:42 +02005587 /* We're going to thwart any and all handover attempts, just be ready to handle (and ignore) handover target
5588 * lchans to be established on bts 1 or bts 2. */
5589 f_rslem_suspend(RSL1_PROC);
5590 f_rslem_suspend(RSL2_PROC);
5591
Neels Hofmeyr91401012019-07-11 00:42:35 +02005592 var RSL_Message rsl;
5593
5594 var charstring log_msg := " (expecting handover)"
5595 if (not expect_handover) {
5596 log_msg := " (expecting NO handover)";
5597 }
5598 log("f_probe_for_handover starting: " & log_label & ": " & log_descr & log_msg);
5599 f_vty_transceive(BSCVTY, handover_vty_cmd);
5600
Neels Hofmeyr91401012019-07-11 00:42:35 +02005601 timer T := 2.0;
5602 T.start;
5603
5604 alt {
5605 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr)) -> value rsl {
5606 var PDU_ML3_NW_MS l3 := dec_PDU_ML3_NW_MS(rsl.ies[2].body.l3_info.payload);
5607 log("Rx L3 from net: ", l3);
5608 if (ischosen(l3.msgs.rrm.handoverCommand)) {
5609 var RslChannelNr new_chan_nr;
5610 var GsmArfcn arfcn;
5611 f_ChDesc2RslChanNr(l3.msgs.rrm.handoverCommand.channelDescription2,
5612 new_chan_nr, arfcn);
5613 log("Handover to new chan ", new_chan_nr, " on ARFCN ", arfcn);
5614 log(l3.msgs.rrm.handoverCommand);
5615
5616 /* Need to register for new lchan on new BTS -- it's either bts 1 or bts 2. It doesn't really
5617 * matter on which BTS it really is, we're not going to follow through an entire handover
5618 * anyway. */
5619 f_rslem_register(0, new_chan_nr, RSL1_PROC);
5620 f_rslem_resume(RSL1_PROC);
5621 f_rslem_register(0, new_chan_nr, RSL2_PROC);
5622 f_rslem_resume(RSL2_PROC);
5623
5624 if (expect_handover and not is_inter_bsc_handover) {
5625 setverdict(pass);
5626 log("f_probe_for_handover(" & log_label & "): Got RSL Handover Command as expected.");
5627 } else {
5628 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected none, but got RSL Handover Command. "
5629 & log_label & ": " & log_descr);
5630 }
5631
5632 log("f_probe_for_handover(" & log_label & "): Ending the test: Handover Failure stops the procedure.");
5633 /* osmo-bsc has triggered Handover. That's all we need to know for this test, reply with
5634 * Handover Failure. */
5635 f_rsl_send_l3(ts_RRM_HandoverFailure('00'O));
5636
5637 /* target BTS is told to release lchan again; don't care which BTS nor what messages. */
5638 f_sleep(0.5);
5639 RSL1.clear;
5640 RSL2.clear;
5641 log("f_probe_for_handover(" & log_label & "): done (got RSL Handover Command)");
5642 break;
5643 } else {
5644 repeat;
5645 }
5646 }
5647 [] BSSAP.receive(tr_BSSMAP_HandoverRequired) {
5648 if (expect_handover and is_inter_bsc_handover) {
5649 setverdict(pass);
5650 log("f_probe_for_handover(" & log_label & "): Got BSSMAP Handover Required as expected.");
5651 } else {
5652 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected none, but got BSSMAP Handover Required. "
5653 & log_label & ": " & log_descr);
5654 }
5655
5656 log("f_probe_for_handover(" & log_label & "): done (got BSSMAP Handover Required)");
5657
5658 /* Note: f_tc_ho_neighbor_config_start() sets T7, the timeout for BSSMAP Handover Required, to
5659 * 1 second. There is no legal way to quickly abort a handover after a BSSMAP Handover Required,
5660 * setting a short timeout and waiting is the only way. */
5661 log("f_probe_for_handover(" & log_label & "): waiting for inter-BSC HO to time out...");
5662 f_sleep(1.5);
5663 log("f_probe_for_handover(" & log_label & "): ...done");
5664
5665 break;
5666 }
5667 [] T.timeout {
5668 if (expect_handover) {
5669 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected Handover, but got none. "
5670 & log_label & ": " & log_descr);
5671 } else {
5672 setverdict(pass);
5673 log("f_probe_for_handover(" & log_label & "): Got no Handover, as expected.");
5674 }
5675 log("f_probe_for_handover(" & log_label & "): done (got no Handover)");
5676 break;
5677 }
5678 }
5679
5680 f_rslem_resume(RSL1_PROC);
5681 f_rslem_resume(RSL2_PROC);
5682 f_sleep(3.0);
5683 RSL.clear;
5684
5685 log("f_probe_for_handover(" & log_label & "): done clearing");
5686}
5687
5688/* Test the effect of various neighbor configuration scenarios:
5689 *
5690 * To avoid complexity, block off any actual handover operation, and always remain on the lchan at bts 0.
5691 * Reconfigure the neighbors for bts 0, trigger a Handover, and probe whether osmo-bsc does or doesn't start HO.
5692 */
5693private function f_tc_ho_neighbor_config_start() runs on MSC_ConnHdlr {
5694 g_pars := f_gen_test_hdlr_pars();
5695 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
5696 var PDU_BSSAP ass_cmd := f_gen_ass_req();
5697 const OCT8 kc := '0001020304050607'O;
5698
5699 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
5700 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
5701
5702 /* Establish lchan at bts 0 */
5703 f_establish_fully(ass_cmd, exp_compl);
5704
5705 /* Shorten the inter-BSC Handover timeout, to not wait so long for inter-BSC Handovers */
5706 f_vty_enter_cfg_network(BSCVTY);
5707 f_vty_transceive(BSCVTY, "timer T7 1");
5708 f_vty_transceive(BSCVTY, "end");
5709}
5710
5711private function f_tc_ho_neighbor_config_1(charstring id) runs on MSC_ConnHdlr {
5712 f_tc_ho_neighbor_config_start();
5713
5714 /*
5715 * bts 0 ARFCN 871 BSIC 10
5716 * bts 1 ARFCN 871 BSIC 11
5717 * bts 2 ARFCN 871 BSIC 12
5718 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5719 */
5720
5721 log("f_tc_ho_neighbor_config: 1. No 'neighbor' config");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005722 f_bts_0_cfg(BSCVTY, {"no neighbors"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005723 f_probe_for_handover("1.a", "HO to bts 1 works, implicitly listed as neighbor (legacy behavior when none are configured)",
5724 "handover any to arfcn 871 bsic 11",
5725 true);
5726
5727 f_probe_for_handover("1.b", "HO to unknown cell does not start",
5728 "handover any to arfcn 13 bsic 39",
5729 false);
5730
5731 f_probe_for_handover("1.c", "HO to 871-12 is ambiguous = error",
5732 "handover any to arfcn 871 bsic 12",
5733 false);
5734
5735 f_probe_for_handover("1.d", "HO to 871-11 still works (verify that this test properly cleans up)",
5736 "handover any to arfcn 871 bsic 11",
5737 true);
5738}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005739testcase TC_ho_neighbor_config_1() runs on test_CT {
5740 var MSC_ConnHdlr vc_conn;
5741 f_init(3, true, guard_timeout := 60.0);
5742 f_sleep(1.0);
5743 f_ctrs_bsc_and_bts_init();
5744 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_1));
5745 vc_conn.done;
5746
5747 /* f_tc_ho_neighbor_config_start() */
5748 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5749 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5750
5751 /* 1.a */
5752 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
5753 * handover quickly by sending a Handover Failure message. */
5754 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5755 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5756 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5757 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
5758
5759 /* 1.b */
5760 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5761 f_ctrs_bsc_and_bts_add(0, "handover:error");
5762
5763 /* 1.c */
5764 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5765 f_ctrs_bsc_and_bts_add(0, "handover:error");
5766
5767 /* 1.d */
5768 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5769 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5770 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5771 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
5772
5773 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005774 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005775}
5776
Neels Hofmeyr91401012019-07-11 00:42:35 +02005777private function f_tc_ho_neighbor_config_2(charstring id) runs on MSC_ConnHdlr {
5778 f_tc_ho_neighbor_config_start();
5779
5780 /*
5781 * bts 0 ARFCN 871 BSIC 10
5782 * bts 1 ARFCN 871 BSIC 11
5783 * bts 2 ARFCN 871 BSIC 12
5784 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5785 */
5786
5787 log("f_tc_ho_neighbor_config: 2. explicit local neighbor: 'neighbor bts 1'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005788 f_bts_0_cfg(BSCVTY, {"neighbor bts 1"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005789 f_sleep(0.5);
5790
5791 f_probe_for_handover("2.a", "HO to bts 1 works, explicitly listed as neighbor",
5792 "handover any to arfcn 871 bsic 11",
5793 true);
5794
5795 f_probe_for_handover("2.b", "HO to bts 2 doesn't work, not listed as neighbor",
5796 "handover any to arfcn 871 bsic 12",
5797 false);
5798}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005799testcase TC_ho_neighbor_config_2() runs on test_CT {
5800 var MSC_ConnHdlr vc_conn;
5801 f_init(3, true, guard_timeout := 50.0);
5802 f_sleep(1.0);
5803 f_ctrs_bsc_and_bts_init();
5804 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_2));
5805 vc_conn.done;
5806
5807 /* f_tc_ho_neighbor_config_start() */
5808 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5809 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5810
5811 /* 2.a */
5812 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
5813 * handover quickly by sending a Handover Failure message. */
5814 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5815 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5816 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5817 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
5818
5819 /* 2.b */
5820 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5821 f_ctrs_bsc_and_bts_add(0, "handover:error");
5822
5823 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005824 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005825}
5826
Neels Hofmeyr91401012019-07-11 00:42:35 +02005827private function f_tc_ho_neighbor_config_3(charstring id) runs on MSC_ConnHdlr {
5828 f_tc_ho_neighbor_config_start();
5829
5830 /*
5831 * bts 0 ARFCN 871 BSIC 10
5832 * bts 1 ARFCN 871 BSIC 11
5833 * bts 2 ARFCN 871 BSIC 12
5834 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5835 */
5836
5837 log("f_tc_ho_neighbor_config: 3. explicit local neighbor: 'neighbor bts 2'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005838 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor bts 2"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005839 f_sleep(0.5);
5840
5841 f_probe_for_handover("3.a", "HO to bts 1 doesn't work, not listed as neighbor",
5842 "handover any to arfcn 871 bsic 11",
5843 false);
5844 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",
5845 "handover any to arfcn 871 bsic 12",
5846 true);
5847}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005848testcase TC_ho_neighbor_config_3() runs on test_CT {
5849 var MSC_ConnHdlr vc_conn;
5850 f_init(3, true, guard_timeout := 50.0);
5851 f_sleep(1.0);
5852 f_ctrs_bsc_and_bts_init();
5853 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_3));
5854 vc_conn.done;
5855
5856 /* f_tc_ho_neighbor_config_start() */
5857 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5858 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5859
5860 /* 3.a */
5861 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5862 f_ctrs_bsc_and_bts_add(0, "handover:error");
5863
5864 /* 3.b */
5865 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
5866 * handover quickly by sending a Handover Failure message. */
5867 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5868 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5869 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5870 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
5871
5872 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005873 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005874}
5875
Neels Hofmeyr91401012019-07-11 00:42:35 +02005876private function f_tc_ho_neighbor_config_4(charstring id) runs on MSC_ConnHdlr {
5877 f_tc_ho_neighbor_config_start();
5878
5879 /*
5880 * bts 0 ARFCN 871 BSIC 10
5881 * bts 1 ARFCN 871 BSIC 11
5882 * bts 2 ARFCN 871 BSIC 12
5883 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5884 */
5885
5886 log("f_tc_ho_neighbor_config: 4. explicit remote neighbor: 'neighbor lac 99 arfcn 123 bsic 45'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005887 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor lac 99 arfcn 123 bsic 45"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005888 f_sleep(0.5);
5889
5890 f_probe_for_handover("4.a", "HO to bts 1 doesn't work, not listed as neighbor",
5891 "handover any to arfcn 871 bsic 11",
5892 false);
5893 f_probe_for_handover("4.b", "HO to bts 2 doesn't work, not listed as neighbor",
5894 "handover any to arfcn 871 bsic 12",
5895 false);
5896 f_probe_for_handover("4.c", "HO to 123-45 triggers inter-BSC HO",
5897 "handover any to arfcn 123 bsic 45",
5898 true, true);
5899}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005900testcase TC_ho_neighbor_config_4() runs on test_CT {
5901 var MSC_ConnHdlr vc_conn;
5902 f_init(3, true, guard_timeout := 50.0);
5903 f_sleep(1.0);
5904 f_ctrs_bsc_and_bts_init();
5905 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_4));
5906 vc_conn.done;
5907
5908 /* f_tc_ho_neighbor_config_start() */
5909 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5910 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5911
5912 /* 4.a */
5913 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5914 f_ctrs_bsc_and_bts_add(0, "handover:error");
5915
5916 /* 4.b */
5917 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5918 f_ctrs_bsc_and_bts_add(0, "handover:error");
5919
5920 /* 4.c */
5921 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
5922 * handover quickly by timing out after the Handover Required message */
5923 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5924 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
5925 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
5926 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
5927
5928 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005929 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005930}
5931
Neels Hofmeyr91401012019-07-11 00:42:35 +02005932private function f_tc_ho_neighbor_config_5(charstring id) runs on MSC_ConnHdlr {
5933 f_tc_ho_neighbor_config_start();
5934
5935 /*
5936 * bts 0 ARFCN 871 BSIC 10
5937 * bts 1 ARFCN 871 BSIC 11
5938 * bts 2 ARFCN 871 BSIC 12
5939 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5940 */
5941
5942 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 +02005943 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor lac 99 arfcn 871 bsic 12"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005944 f_sleep(0.5);
5945
5946 f_probe_for_handover("5.a", "HO to 871-12 triggers inter-BSC HO (ignoring local cells with same ARFCN+BSIC)",
5947 "handover any to arfcn 871 bsic 12",
5948 true, true);
5949}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005950testcase TC_ho_neighbor_config_5() runs on test_CT {
5951 var MSC_ConnHdlr vc_conn;
5952 f_init(3, true);
5953 f_sleep(1.0);
5954 f_ctrs_bsc_and_bts_init();
5955 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_5));
5956 vc_conn.done;
5957
5958 /* f_tc_ho_neighbor_config_start() */
5959 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5960 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5961
5962 /* 5 */
5963 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
5964 * handover quickly by timing out after the Handover Required message */
5965 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5966 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
5967 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
5968 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
5969
5970 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005971 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005972}
5973
Neels Hofmeyr91401012019-07-11 00:42:35 +02005974private function f_tc_ho_neighbor_config_6(charstring id) runs on MSC_ConnHdlr {
5975 f_tc_ho_neighbor_config_start();
5976
5977 /*
5978 * bts 0 ARFCN 871 BSIC 10
5979 * bts 1 ARFCN 871 BSIC 11
5980 * bts 2 ARFCN 871 BSIC 12
5981 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5982 */
5983
5984 log("f_tc_ho_neighbor_config: 6. config error: explicit local and remote neighbors with ambiguous ARFCN+BSIC:"
5985 & " 'neighbor bts 2; neighbor lac 99 arfcn 871 bsic 12'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005986 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor bts 2", "neighbor lac 99 arfcn 871 bsic 12"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005987 f_sleep(0.5);
5988
5989 f_probe_for_handover("6.a", "HO to 871-12 is ambiguous = error",
5990 "handover any to arfcn 871 bsic 12",
5991 false);
5992}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005993testcase TC_ho_neighbor_config_6() runs on test_CT {
5994 var MSC_ConnHdlr vc_conn;
5995 f_init(3, true);
5996 f_sleep(1.0);
5997 f_ctrs_bsc_and_bts_init();
5998 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_6));
5999 vc_conn.done;
6000
6001 /* f_tc_ho_neighbor_config_start() */
6002 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
6003 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
6004
6005 /* 6.a */
6006 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
6007 * handover quickly by timing out after the Handover Required message */
6008 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6009 f_ctrs_bsc_and_bts_add(0, "handover:error");
6010
6011 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006012 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006013}
6014
Neels Hofmeyr91401012019-07-11 00:42:35 +02006015private function f_tc_ho_neighbor_config_7(charstring id) runs on MSC_ConnHdlr {
6016 f_tc_ho_neighbor_config_start();
6017
6018 /*
6019 * bts 0 ARFCN 871 BSIC 10
6020 * bts 1 ARFCN 871 BSIC 11
6021 * bts 2 ARFCN 871 BSIC 12
6022 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
6023 */
6024
6025 log("f_tc_ho_neighbor_config: 7. explicit local and remote neighbors:"
6026 & " 'neighbor bts 2; neighbor lac 99 arfcn 123 bsic 45'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02006027 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor bts 2", "neighbor lac 99 arfcn 123 bsic 45"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02006028 f_sleep(0.5);
6029
6030 f_probe_for_handover("7.a", "HO to 871-12 does HO to bts 2",
6031 "handover any to arfcn 871 bsic 12",
6032 true);
6033 f_probe_for_handover("7.b", "HO to 123-45 triggers inter-BSC HO",
6034 "handover any to arfcn 123 bsic 45",
6035 true, true);
6036}
Neels Hofmeyr91401012019-07-11 00:42:35 +02006037testcase TC_ho_neighbor_config_7() runs on test_CT {
6038 var MSC_ConnHdlr vc_conn;
Neels Hofmeyrf2b88032020-06-16 00:35:04 +02006039 f_init(3, true, guard_timeout := 50.0);
Neels Hofmeyr91401012019-07-11 00:42:35 +02006040 f_sleep(1.0);
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006041 f_ctrs_bsc_and_bts_init();
Neels Hofmeyr91401012019-07-11 00:42:35 +02006042 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_7));
6043 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006044
6045 /* f_tc_ho_neighbor_config_start() */
6046 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
6047 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
6048
6049 /* 7.a */
6050 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
6051 * handover quickly by sending a Handover Failure message. */
6052 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6053 f_ctrs_bsc_and_bts_add(0, "handover:failed");
6054 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
6055 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
6056
6057 /* 7.b */
6058 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
6059 * handover quickly by timing out after the Handover Required message */
6060 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6061 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
6062 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
6063 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
6064
6065 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006066 f_shutdown_helper();
Neels Hofmeyr91401012019-07-11 00:42:35 +02006067}
6068
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01006069/* OS#3041: Open and close N connections in a normal fashion, and expect no
6070 * BSSMAP Reset just because of that. */
6071testcase TC_bssap_rlsd_does_not_cause_bssmap_reset() runs on test_CT {
6072 var default d;
6073 var integer i;
6074 var DchanTuple dt;
6075
6076 f_init();
6077
6078 /* Wait for initial BSSMAP Reset to pass */
6079 f_sleep(4.0);
6080
6081 d := activate(no_bssmap_reset());
6082
6083 /* Setup up a number of connections and RLSD them again from the MSC
6084 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
6085 * Let's do it some more times for good measure. */
Harald Weltec3260d92018-06-11 17:48:16 +02006086 for (i := 0; i < 4; i := i+1) {
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01006087 /* Since we're doing a lot of runs, give each one a fresh
6088 * T_guard from the top. */
6089 T_guard.start;
6090
6091 /* Setup a BSSAP connection and clear it right away. This is
6092 * the MSC telling the BSC about a planned release, it's not an
6093 * erratic loss of a connection. */
Harald Weltea1897182018-06-11 13:53:09 +02006094 dt := f_est_dchan(int2oct(i,1), 23+i, '00010203040506'O);
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01006095
6096 /* MSC disconnects (RLSD). */
6097 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
6098 }
6099
6100 /* In the buggy behavior, a timeout of 2 seconds happens between above
6101 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
6102 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
6103 f_sleep(4.0);
6104
6105 deactivate(d);
6106 f_shutdown_helper();
6107}
Harald Welte552620d2017-12-16 23:21:36 +01006108
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01006109/* OS#3041: Open and close N connections in a normal fashion, and expect no
6110 * BSSMAP Reset just because of that. Invoke the release by a BSSMAP Clear from
6111 * the MSC. */
6112testcase TC_bssmap_clear_does_not_cause_bssmap_reset() runs on test_CT {
6113 var default d;
6114 var integer i;
6115 var DchanTuple dt;
6116 var BSSAP_N_DATA_ind rx_di;
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01006117 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_CALL_CONTROL;
6118 var BssmapCause cause := enum2int(cause_val);
6119
6120 f_init();
6121
6122 /* Wait for initial BSSMAP Reset to pass */
6123 f_sleep(4.0);
6124
6125 d := activate(no_bssmap_reset());
6126
6127 /* Setup up a number of connections and RLSD them again from the MSC
6128 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
6129 * Let's do it some more times for good measure. */
6130 for (i := 0; i < 8; i := i+1) {
6131 /* Since we're doing a lot of runs, give each one a fresh
6132 * T_guard from the top. */
6133 T_guard.start;
6134
6135 /* Setup a BSSAP connection and clear it right away. This is
6136 * the MSC telling the BSC about a planned release, it's not an
6137 * erratic loss of a connection. */
Harald Weltea1897182018-06-11 13:53:09 +02006138 dt := f_est_dchan(int2oct(i,1), 23+i, '00010203040506'O);
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01006139
6140 /* Instruct BSC to clear channel */
6141 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
6142
6143 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02006144 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01006145 }
6146
6147 /* In the buggy behavior, a timeout of 2 seconds happens between above
6148 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
6149 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
6150 f_sleep(4.0);
6151
6152 deactivate(d);
6153 f_shutdown_helper();
6154}
6155
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01006156/* OS#3041: Open and close N connections in a normal fashion, and expect no
6157 * BSSMAP Reset just because of that. Close connections from the MS side with a
6158 * Release Ind on RSL. */
6159testcase TC_ms_rel_ind_does_not_cause_bssmap_reset() runs on test_CT {
6160 var default d;
6161 var integer i;
6162 var DchanTuple dt;
6163 var BSSAP_N_DATA_ind rx_di;
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01006164 var integer j;
6165
6166 f_init();
6167
6168 /* Wait for initial BSSMAP Reset to pass */
6169 f_sleep(4.0);
6170
6171 d := activate(no_bssmap_reset());
6172
6173 /* Setup up a number of connections and RLSD them again from the MSC
6174 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
6175 * Let's do it some more times for good measure. */
6176 for (i := 0; i < 8; i := i+1) {
6177 /* Since we're doing a lot of runs, give each one a fresh
6178 * T_guard from the top. */
6179 T_guard.start;
6180
6181 /* Setup a BSSAP connection and clear it right away. This is
6182 * the MSC telling the BSC about a planned release, it's not an
6183 * erratic loss of a connection. */
6184 dt := f_est_dchan('23'O, 23, '00010203040506'O);
6185
6186 /* simulate RLL REL IND */
6187 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0))));
6188
6189 /* expect Clear Request on MSC side */
6190 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
6191
6192 /* Instruct BSC to clear channel */
6193 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
6194 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
6195
6196 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02006197 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01006198 }
6199
6200 /* In the buggy behavior, a timeout of 2 seconds happens between above
6201 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
6202 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
6203 f_sleep(4.0);
6204
6205 deactivate(d);
6206 f_shutdown_helper();
6207}
6208
Harald Welte94e0c342018-04-07 11:33:23 +02006209/***********************************************************************
6210 * IPA style dynamic PDCH
6211 ***********************************************************************/
6212
6213private function f_dyn_ipa_pdch_act(integer bts_nr, integer trx_nr, integer ts_nr,
6214 template (omit) RSL_Cause nack := omit)
6215runs on test_CT {
6216 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(ts_nr));
6217 var RSL_Message rsl_unused;
6218 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
6219 f_vty_ts_action("pdch activate", bts_nr, trx_nr, ts_nr);
6220 /* expect the BSC to issue the related RSL command */
6221 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
6222 if (istemplatekind(nack, "omit")) {
6223 /* respond with a related acknowledgement */
6224 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
6225 } else {
6226 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_NACK(chan_nr, valueof(nack)));
6227 }
6228}
6229
6230private function f_dyn_ipa_pdch_deact(integer bts_nr, integer trx_nr, integer ts_nr,
6231 template (omit) RSL_Cause nack := omit)
6232runs on test_CT {
6233 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(ts_nr));
6234 var RSL_Message rsl_unused;
6235 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
6236 f_vty_ts_action("pdch deactivate", bts_nr, trx_nr, ts_nr);
6237 /* expect the BSC to issue the related RSL command */
6238 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_DEACT(chan_nr));
6239 if (istemplatekind(nack, "omit")) {
6240 /* respond with a related acknowledgement */
6241 f_ipa_tx(0, ts_RSL_IPA_PDCH_DEACT_ACK(chan_nr));
6242 } else {
6243 f_ipa_tx(0, ts_RSL_IPA_PDCH_DEACT_NACK(chan_nr, valueof(nack)));
6244 }
6245}
6246
6247private function f_ts_dyn_mode_get(integer bts_nr, integer trx_nr, integer ts_nr)
6248runs on test_CT return charstring {
6249 var charstring cmd, resp;
6250 cmd := "show timeslot "&int2str(bts_nr)&" "&int2str(trx_nr)&" "&int2str(ts_nr);
Stefan Sperlingcff13562018-11-13 15:24:06 +01006251 return f_vty_transceive_match_regexp_retry(BSCVTY, cmd, "*\((*)\)*", 0, 4, 1.0);
Harald Welte94e0c342018-04-07 11:33:23 +02006252}
6253
6254private function f_ts_dyn_mode_assert(integer bts_nr, integer trx_nr, integer ts_nr,
6255 template charstring exp)
6256runs on test_CT {
6257 var charstring mode := f_ts_dyn_mode_get(bts_nr, trx_nr, ts_nr);
6258 if (not match(mode, exp)) {
6259 setverdict(fail, "Unexpected TS Mode: ", mode);
Daniel Willmannafce8662018-07-06 23:11:32 +02006260 mtc.stop;
Harald Welte94e0c342018-04-07 11:33:23 +02006261 }
6262}
6263
6264private function f_ts_set_chcomb(integer bts_nr, integer trx_nr, integer ts_nr, charstring chcomb)
6265runs on test_CT {
6266 f_vty_enter_cfg_ts(BSCVTY, bts_nr, trx_nr, ts_nr);
6267 f_vty_transceive(BSCVTY, "phys_chan_config " & chcomb);
6268 f_vty_transceive(BSCVTY, "end");
6269}
6270
6271private const charstring TCHF_MODE := "TCH/F mode";
6272private const charstring TCHH_MODE := "TCH/H mode";
6273private const charstring PDCH_MODE := "PDCH mode";
6274private const charstring NONE_MODE := "NONE mode";
6275
6276/* Test IPA PDCH activation / deactivation triggered by VTY */
6277testcase TC_dyn_pdch_ipa_act_deact() runs on test_CT {
6278 var RSL_Message rsl_unused;
6279
6280 /* change Timeslot 6 before f_init() starts RSL */
6281 f_init_vty();
6282 f_ts_set_chcomb(0, 0, 6, "TCH/F_PDCH");
6283 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
6284
6285 f_init(1, false);
6286 f_sleep(1.0);
6287
6288 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
6289
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006290 log("TCH/F_PDCH pchan starts out in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02006291 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6292 /* The BSC will activate the dynamic PDCH by default, so confirm that */
6293 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
6294 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
6295 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006296 log("TCH/F_PDCH pchan, PDCH ACT was ACKed, so now in PDCH mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02006297 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
6298
6299 /* De-activate it via VTY */
6300 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
6301 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006302 log("TCH/F_PDCH pchan, PDCH DEACT via VTY, so now back in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02006303 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6304
6305 /* re-activate it via VTY */
6306 f_dyn_ipa_pdch_act(0, 0, chan_nr.tn);
6307 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006308 log("TCH/F_PDCH pchan, PDCH ACT via VTY, so now in PDCH mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02006309 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
6310
6311 /* and finally de-activate it again */
6312 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
6313 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006314 log("TCH/F_PDCH pchan, PDCH DEACT via VTY, so now back in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02006315 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6316
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02006317 /* clean up config */
6318 f_ts_set_chcomb(0, 0, 6, "PDCH");
6319
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006320 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02006321}
6322
6323/* Test IPA PDCH activation NACK */
6324testcase TC_dyn_pdch_ipa_act_nack() runs on test_CT {
6325 var RSL_Message rsl_unused;
6326
6327 /* change Timeslot 6 before f_init() starts RSL */
6328 f_init_vty();
6329 f_ts_set_chcomb(0, 0, 6, "TCH/F_PDCH");
6330 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
6331
6332 f_init(1, false);
6333 f_sleep(1.0);
6334
6335 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
6336
6337 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6338 /* The BSC will activate the dynamic PDCH by default, so confirm that */
6339 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
6340 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
6341 f_sleep(1.0);
6342 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
6343
6344 /* De-activate it via VTY */
6345 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
6346 f_sleep(1.0);
6347 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6348
6349 /* re-activate it via VTY, but fail that; check BSC still assumes TCH/F mode */
6350 f_dyn_ipa_pdch_act(0, 0, chan_nr.tn, RSL_ERR_EQUIPMENT_FAIL);
6351 f_sleep(1.0);
6352 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6353
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02006354 /* clean up config */
6355 f_ts_set_chcomb(0, 0, 6, "PDCH");
6356
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006357 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02006358}
6359
6360
6361/***********************************************************************
6362 * Osmocom style dynamic PDCH
6363 ***********************************************************************/
6364
6365private function f_dyn_osmo_pdch_act(integer bts_nr, integer trx_nr, integer ts_nr,
6366 template (omit) RSL_Cause nack := omit)
6367runs on test_CT {
6368 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(ts_nr));
6369 var RSL_Message rsl_unused;
6370 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
6371 /* FIXME: no VTY command to activate Osmocom PDCH !! */
6372 /* expect the BSC to issue the related RSL command */
6373 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT(chan_nr, ?));
6374 if (istemplatekind(nack, "omit")) {
6375 /* respond with a related acknowledgement */
6376 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342));
6377 } else {
6378 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, valueof(nack)));
6379 }
6380}
6381
6382private function f_dyn_osmo_pdch_deact(integer bts_nr, integer trx_nr, integer ts_nr,
6383 template (omit) RSL_Cause nack := omit)
6384runs on test_CT {
6385 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(ts_nr));
6386 var RSL_Message rsl_unused;
6387 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
6388 /* FIXME: no VTY command to activate Osmocom PDCH !! */
6389 /* expect the BSC to issue the related RSL command */
6390 rsl_unused := f_exp_ipa_rx(0, tr_RSL_RF_CHAN_REL(chan_nr));
6391 if (istemplatekind(nack, "omit")) {
6392 /* respond with a related acknowledgement */
6393 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(chan_nr));
6394 } else {
6395 //f_ipa_tx(0, ts_RSL_RF_CHAN_REL_NACK(chan_nr, valueof(nack)));
6396 }
6397}
6398
6399/* Test Osmocom dyn PDCH activation / deactivation triggered by VTY */
6400testcase TC_dyn_pdch_osmo_act_deact() runs on test_CT {
6401 var RSL_Message rsl_unused;
6402
6403 /* change Timeslot 6 before f_init() starts RSL */
6404 f_init_vty();
6405 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_PDCH");
6406 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
6407
6408 f_init(1, false);
6409 f_sleep(1.0);
6410
6411 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(6));
6412
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006413 log("TCH/F_TCH/H_PDCH pchan starts out in disabled mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02006414 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
6415 /* The BSC will activate the dynamic PDCH by default, so confirm that */
6416 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
6417
6418 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342));
6419 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006420 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 +02006421 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
6422
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02006423 /* clean up config */
6424 f_ts_set_chcomb(0, 0, 6, "PDCH");
6425
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006426 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02006427}
6428
6429/* Test Osmocom dyn PDCH activation NACK behavior */
6430testcase TC_dyn_pdch_osmo_act_nack() runs on test_CT {
6431 var RSL_Message rsl_unused;
6432
6433 /* change Timeslot 6 before f_init() starts RSL */
6434 f_init_vty();
6435 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_PDCH");
6436 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
6437
6438 f_init(1, false);
6439 f_sleep(1.0);
6440
6441 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(6));
6442
6443 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
6444 /* The BSC will activate the dynamic PDCH by default, so confirm that */
6445 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
6446
6447 /* NACK this activation and expect the "show timeslot" mode still to be NONE */
6448 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, RSL_ERR_EQUIPMENT_FAIL));
6449 f_sleep(1.0);
6450 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
6451
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02006452 /* clean up config */
6453 f_ts_set_chcomb(0, 0, 6, "PDCH");
6454
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006455 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02006456}
6457
Stefan Sperling0796a822018-10-05 13:01:39 +02006458testcase TC_chopped_ipa_ping() runs on test_CT {
Stefan Sperling554123f2018-10-09 14:12:30 +02006459 const Integers bsc_ipa_ports := {mp_bsc_rsl_port, mp_bsc_oml_port, mp_bsc_ctrl_port};
Stefan Sperling0796a822018-10-05 13:01:39 +02006460 for (var integer i := 0; i < lengthof(bsc_ipa_ports); i := i + 1) {
6461 IPA_Testing.f_run_TC_chopped_ipa_ping(mp_bsc_ip, bsc_ipa_ports[i], CONNECT_TO_SERVER);
6462 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006463 f_shutdown_helper();
Stefan Sperling0796a822018-10-05 13:01:39 +02006464}
6465
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02006466testcase TC_chopped_ipa_payload() runs on test_CT {
6467 const Integers bsc_ipa_ports := {mp_bsc_rsl_port, mp_bsc_oml_port
6468 /* TODO: mp_bsc_ctrl_port does not work yet */};
6469 for (var integer i := 0; i < lengthof(bsc_ipa_ports); i := i + 1) {
6470 IPA_Testing.f_run_TC_chopped_ipa_payload(mp_bsc_ip, bsc_ipa_ports[i], CONNECT_TO_SERVER);
6471 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006472 f_shutdown_helper();
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02006473}
6474
Pau Espin Pedrol8f773632019-11-05 11:46:53 +01006475/* Verify the BSC sends the MS Power Parameters IE during CHAN ACT to make sure
6476 the BTS does autonomous MS power control loop */
6477testcase TC_assignment_verify_ms_power_params_ie() runs on test_CT {
6478 var MSC_ConnHdlr vc_conn;
6479 var TestHdlrParams pars := f_gen_test_hdlr_pars();
6480 //pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
6481 pars.exp_ms_power_params := true;
6482
6483 f_init(1, true);
6484 f_sleep(1.0);
6485 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
6486 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006487 f_shutdown_helper();
Pau Espin Pedrol8f773632019-11-05 11:46:53 +01006488}
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02006489
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006490/***********************************************************************
6491 * MSC Pooling
6492 ***********************************************************************/
6493
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006494template MobileIdentityLV ts_MI_TMSI_NRI_LV(integer nri_v, integer nri_bitlen := 10) :=
Harald Weltebf397612021-01-14 20:39:46 +01006495 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 +02006496
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02006497private function f_expect_lchan_rel(RSL_DCHAN_PT rsl, template PDU_ML3_NW_MS exp_rr_rel_tmpl := tr_RRM_RR_RELEASE)
6498runs on MSC_ConnHdlr {
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02006499 interleave {
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02006500 [] rsl.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch exp_rr_rel_tmpl)) {
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02006501 f_logp(BSCVTY, "Got RSL RR Release");
6502 }
6503 [] rsl.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
6504 f_logp(BSCVTY, "Got RSL Deact SACCH");
6505 }
6506 [] rsl.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
6507 f_logp(BSCVTY, "Got RSL RF Chan Rel, sending Rel Ack");
6508 rsl.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
6509 break;
6510 }
6511 }
6512}
6513
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02006514private function f_perform_clear(RSL_DCHAN_PT rsl, template PDU_ML3_NW_MS exp_rr_rel_tmpl := tr_RRM_RR_RELEASE)
6515runs on MSC_ConnHdlr {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006516 f_logp(BSCVTY, "MSC instructs BSC to clear channel");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006517 BSSAP.send(ts_BSSMAP_ClearCommand(0));
6518 interleave {
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02006519 [] rsl.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch exp_rr_rel_tmpl)) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006520 f_logp(BSCVTY, "Got RSL RR Release");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006521 }
6522 [] rsl.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006523 f_logp(BSCVTY, "Got RSL Deact SACCH");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006524 }
6525 [] BSSAP.receive(tr_BSSMAP_ClearComplete) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006526 f_logp(BSCVTY, "Got BSSMAP Clear Complete");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006527 /* Also drop the SCCP connection */
6528 BSSAP.send(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_REQ);
6529 }
6530 [] rsl.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006531 f_logp(BSCVTY, "Got RSL RF Chan Rel, sending Rel Ack");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006532 rsl.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
6533 }
6534 }
6535}
6536
Neels Hofmeyr66e15092020-10-12 18:44:41 +00006537private 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 +02006538runs on MSC_ConnHdlr {
6539 timer T := 10.0;
6540 var octetstring l3_enc := enc_PDU_ML3_MS_NW(valueof(l3_info));
6541
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006542 f_logp(BSCVTY, "establish channel, send Complete Layer 3 Info");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006543 f_create_bssmap_exp(l3_enc);
6544
6545 /* RSL_Emulation.f_chan_est() on rsl:
6546 * This is basically code dup with s/RSL/rsl from:
6547 * RSL_Emulation.f_chan_est(g_pars.ra, l3_enc, g_pars.link_id, g_pars.fn);
6548 */
6549 var RSL_Message rx_rsl;
6550 var GsmRrMessage rr;
6551
6552 /* request a channel to be established */
6553 rsl.send(ts_RSLDC_ChanRqd(g_pars.ra, g_pars.fn));
6554 /* expect immediate assignment.
6555 * Code dup with s/RSL/rsl from:
6556 * rx_rsl := f_rx_or_fail(tr_RSL_IMM_ASSIGN);
6557 */
6558 timer Tt := 10.0;
6559
6560 /* request a channel to be established */
6561 Tt.start;
6562 alt {
6563 [] rsl.receive(tr_RSL_IMM_ASSIGN) -> value rx_rsl {
6564 Tt.stop;
6565 }
6566 [] rsl.receive {
6567 setverdict(fail, "Unexpected RSL message on DCHAN");
6568 mtc.stop;
6569 }
6570 [] Tt.timeout {
6571 setverdict(fail, "Timeout waiting for RSL on DCHAN");
6572 mtc.stop;
6573 }
6574 }
6575 rr := dec_GsmRrMessage(rx_rsl.ies[1].body.full_imm_ass_info.payload);
6576 g_chan_nr := rr.payload.imm_ass.chan_desc.chan_nr;
6577 rsl.send(ts_RSL_EST_IND(g_chan_nr, valueof(g_pars.link_id), l3_enc));
6578
6579
Neels Hofmeyr66e15092020-10-12 18:44:41 +00006580 if (expect_bssmap_l3) {
6581 f_logp(BSCVTY, "expect BSSAP Complete Layer 3 Info at MSC");
6582 var template PDU_BSSAP exp_l3_compl;
6583 exp_l3_compl := tr_BSSMAP_ComplL3()
6584 if (g_pars.aoip == false) {
6585 exp_l3_compl.pdu.bssmap.completeLayer3Information.codecList := omit;
6586 } else {
6587 exp_l3_compl.pdu.bssmap.completeLayer3Information.codecList := ?;
6588 }
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006589
Neels Hofmeyr66e15092020-10-12 18:44:41 +00006590 var PDU_BSSAP bssap;
6591 T.start;
6592 alt {
6593 [] BSSAP.receive(exp_l3_compl) -> value bssap {
6594 f_logp(BSCVTY, "received expected Complete Layer 3 Info at MSC");
6595 log("rx exp_l3_compl = ", bssap);
6596 }
6597 [] BSSAP.receive(tr_BSSMAP_ComplL3) {
6598 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received non-matching COMPLETE LAYER 3 INFORMATION");
6599 }
6600 [] T.timeout {
6601 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for COMPLETE LAYER 3 INFORMATION");
6602 }
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006603 }
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006604
Neels Hofmeyr66e15092020-10-12 18:44:41 +00006605 /* start ciphering, if requested */
6606 if (ispresent(g_pars.encr)) {
6607 f_logp(BSCVTY, "start ciphering");
6608 f_cipher_mode(g_pars.encr.enc_alg, g_pars.encr.enc_key);
6609 }
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006610 }
6611
6612 if (do_clear) {
6613 f_perform_clear(rsl);
6614 }
6615 setverdict(pass);
6616 f_sleep(1.0);
6617}
6618
6619private function f_tc_mscpool_compl_l3(charstring id) runs on MSC_ConnHdlr {
6620 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
6621 if (g_pars.mscpool.rsl_idx == 0) {
6622 f_perform_compl_l3(RSL, g_pars.mscpool.l3_info);
6623 } else if (g_pars.mscpool.rsl_idx == 1) {
6624 f_perform_compl_l3(RSL1, g_pars.mscpool.l3_info);
6625 } else if (g_pars.mscpool.rsl_idx == 2) {
6626 f_perform_compl_l3(RSL2, g_pars.mscpool.l3_info);
6627 }
6628}
6629
6630/* Various Complete Layer 3 by IMSI all end up with the first MSC, because the other MSCs are not connected. */
6631private function f_tc_mscpool_L3Compl_on_1_msc(charstring id) runs on MSC_ConnHdlr {
6632 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
6633 f_perform_compl_l3(RSL, ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000001'H)), '00F110'O) );
6634 f_perform_compl_l3(RSL, ts_CM_SERV_REQ(CM_TYPE_MO_SMS, valueof(ts_MI_IMSI_LV('001010000000002'H))) );
6635 f_perform_compl_l3(RSL, ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010000000003'H))) );
6636 f_perform_compl_l3(RSL, ts_ML3_MO_MM_IMSI_DET_Ind(valueof(ts_MI_IMSI_LV('001010000000004'H))) );
6637}
6638testcase TC_mscpool_L3Compl_on_1_msc() runs on test_CT {
6639
6640 f_init(1, true);
6641 f_sleep(1.0);
6642 var MSC_ConnHdlr vc_conn;
6643 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006644
6645 f_ctrs_msc_init();
6646
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006647 vc_conn := f_start_handler(refers(f_tc_mscpool_L3Compl_on_1_msc), pars);
6648 vc_conn.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006649
6650 f_ctrs_msc_expect(0, "mscpool:subscr:new", 4);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006651 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006652}
6653
6654/* Three Layer 3 Complete by IMSI are round-robin'ed across two connected MSCs */
6655/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6656 * just as well using only RSL. */
6657testcase TC_mscpool_L3Complete_by_imsi_round_robin() runs on test_CT {
6658
6659 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6660 f_sleep(1.0);
6661
6662 /* Control which MSC gets chosen next by the round-robin, otherwise
6663 * would be randomly affected by which other tests ran before this. */
6664 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6665
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006666 f_ctrs_msc_init();
6667
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006668 var MSC_ConnHdlr vc_conn1;
6669 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6670 pars1.mscpool.rsl_idx := 0;
6671 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000001'H)), '00F110'O));
6672 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6673 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006674 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006675
6676 var MSC_ConnHdlr vc_conn2;
6677 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6678 pars2.mscpool.rsl_idx := 1;
6679 pars2.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000002'H))));
6680 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6681 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006682 f_ctrs_msc_expect(1, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006683
6684 /* Test round-robin wrap to the first MSC */
6685 var MSC_ConnHdlr vc_conn3;
6686 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6687 pars3.mscpool.rsl_idx := 2;
6688 pars3.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010000000003'H))));
6689 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6690 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006691 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006692 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006693}
6694
6695/* Three LU by TMSI are round-robin'ed across two connected MSCs, because they contain the NULL-NRI 0
6696 * (configured in osmo-bsc.cfg). */
6697/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6698 * just as well using only RSL. */
6699testcase TC_mscpool_LU_by_tmsi_null_nri_0_round_robin() runs on test_CT {
6700
6701 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6702 f_sleep(1.0);
6703
6704 /* Control which MSC gets chosen next by the round-robin, otherwise
6705 * would be randomly affected by which other tests ran before this. */
6706 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6707
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006708 f_ctrs_msc_init();
6709
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006710 var MSC_ConnHdlr vc_conn1;
6711 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6712 pars1.mscpool.rsl_idx := 0;
6713 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(0)), '00F110'O));
6714 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6715 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006716 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006717
6718 var MSC_ConnHdlr vc_conn2;
6719 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6720 pars2.mscpool.rsl_idx := 1;
6721 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(0)), '00F110'O));
6722 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6723 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006724 f_ctrs_msc_expect(1, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006725
6726 /* Test round-robin wrap to the first MSC */
6727 var MSC_ConnHdlr vc_conn3;
6728 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6729 pars3.mscpool.rsl_idx := 2;
6730 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(0)), '00F110'O));
6731 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6732 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006733 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006734 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006735}
6736
6737/* Three LU by TMSI are round-robin'ed across two connected MSCs, because they contain the NULL-NRI 1
6738 * (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
6739 * NULL-NRI setting is stronger than that. */
6740/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6741 * just as well using only RSL. */
6742testcase TC_mscpool_LU_by_tmsi_null_nri_1_round_robin() runs on test_CT {
6743
6744 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6745 f_sleep(1.0);
6746
6747 /* Control which MSC gets chosen next by the round-robin, otherwise
6748 * would be randomly affected by which other tests ran before this. */
6749 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6750
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006751 f_ctrs_msc_init();
6752
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006753 var MSC_ConnHdlr vc_conn1;
6754 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6755 pars1.mscpool.rsl_idx := 0;
6756 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(1)), '00F110'O));
6757 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6758 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006759 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006760
6761 var MSC_ConnHdlr vc_conn2;
6762 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6763 pars2.mscpool.rsl_idx := 1;
6764 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(1)), '00F110'O));
6765 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6766 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006767 f_ctrs_msc_expect(1, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006768
6769 /* Test round-robin wrap to the first MSC */
6770 var MSC_ConnHdlr vc_conn3;
6771 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6772 pars3.mscpool.rsl_idx := 2;
6773 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(1)), '00F110'O));
6774 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6775 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006776 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006777 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006778}
6779
6780/* Three Layer 3 Complete by TMSI are round-robin'ed across two connected MSCs, because they contain an NRI not
6781 * assigned to any MSC (configured in osmo-bsc.cfg). */
6782/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6783 * just as well using only RSL. */
6784testcase TC_mscpool_L3Complete_by_tmsi_unassigned_nri_round_robin() runs on test_CT {
6785
6786 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6787 f_sleep(1.0);
6788
6789 /* Control which MSC gets chosen next by the round-robin, otherwise
6790 * would be randomly affected by which other tests ran before this. */
6791 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6792
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006793 f_ctrs_msc_init();
6794
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006795 var MSC_ConnHdlr vc_conn1;
6796 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6797 pars1.mscpool.rsl_idx := 0;
6798 /* An NRI that is not assigned to any MSC */
6799 pars1.mscpool.l3_info := valueof(ts_ML3_MO_MM_IMSI_DET_Ind(valueof(ts_MI_TMSI_NRI_LV(1023))));
6800 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6801 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006802 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006803
6804 var MSC_ConnHdlr vc_conn2;
6805 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6806 pars2.mscpool.rsl_idx := 1;
6807 /* An NRI that is not assigned to any MSC */
6808 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(768)), '00F110'O));
6809 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6810 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006811 f_ctrs_msc_expect(1, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006812
6813 /* Test round-robin wrap to the first MSC */
6814 var MSC_ConnHdlr vc_conn3;
6815 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6816 pars3.mscpool.rsl_idx := 2;
6817 /* An NRI that is not assigned to any MSC */
6818 pars3.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_SS_ACT, valueof(ts_MI_TMSI_NRI_LV(819))));
6819 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6820 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006821 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006822 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006823}
6824
6825/* Three Layer 3 Complete by TMSI are round-robin'ed across two connected MSCs, because they contain an NRI
6826 * assigned to an MSC that is currently not connected (configured in osmo-bsc.cfg). */
6827/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6828 * just as well using only RSL. */
6829testcase TC_mscpool_L3Complete_by_tmsi_valid_nri_msc_not_connected_round_robin() runs on test_CT {
6830
6831 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6832 f_sleep(1.0);
6833
6834 /* Control which MSC gets chosen next by the round-robin, otherwise
6835 * would be randomly affected by which other tests ran before this. */
6836 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6837
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006838 f_ctrs_msc_init();
6839
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006840 var MSC_ConnHdlr vc_conn1;
6841 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6842 pars1.mscpool.rsl_idx := 0;
6843 /* An NRI that is assigned to an unconnected MSC */
6844 pars1.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(512))));
6845 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6846 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006847 f_ctrs_msc_add(2, "mscpool:subscr:attach_lost");
6848 f_ctrs_msc_add(0, "mscpool:subscr:new");
6849 f_ctrs_msc_verify();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006850
6851 var MSC_ConnHdlr vc_conn2;
6852 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6853 pars2.mscpool.rsl_idx := 1;
6854 /* An NRI that is assigned to an unconnected MSC */
6855 pars2.mscpool.l3_info := valueof(ts_ML3_MO_MM_IMSI_DET_Ind(valueof(ts_MI_TMSI_NRI_LV(767))));
6856 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6857 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006858 f_ctrs_msc_add(2, "mscpool:subscr:attach_lost");
6859 f_ctrs_msc_add(1, "mscpool:subscr:new");
6860 f_ctrs_msc_verify();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006861
6862 /* Test round-robin wrap to the first MSC */
6863 var MSC_ConnHdlr vc_conn3;
6864 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6865 pars3.mscpool.rsl_idx := 2;
6866 /* An NRI that is assigned to an unconnected MSC */
6867 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(750)), '00F110'O));
6868 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6869 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006870 f_ctrs_msc_add(2, "mscpool:subscr:attach_lost");
6871 f_ctrs_msc_add(0, "mscpool:subscr:new");
6872 f_ctrs_msc_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006873 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006874}
6875
6876/* Three Layer 3 Complete by TMSI with valid NRI for the second MSC are all directed to the second MSC (configured in
6877 * osmo-bsc.cfg). */
6878/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6879 * just as well using only RSL. */
6880testcase TC_mscpool_L3Complete_by_tmsi_valid_nri_1() runs on test_CT {
6881
6882 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6883 f_sleep(1.0);
6884
6885 /* All TMSIs in this test point at the second MSC, set the round robin to point at the first MSC to make sure
6886 * this is not using round-robin. */
6887 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6888
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006889 f_ctrs_msc_init();
6890
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006891 var MSC_ConnHdlr vc_conn1;
6892 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 1);
6893 pars1.mscpool.rsl_idx := 0;
6894 /* An NRI of the second MSC's range (256-511) */
6895 pars1.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_SMS, valueof(ts_MI_TMSI_NRI_LV(256))));
6896 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6897 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006898 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006899
6900 var MSC_ConnHdlr vc_conn2;
6901 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6902 pars2.mscpool.rsl_idx := 1;
6903 /* An NRI of the second MSC's range (256-511) */
6904 pars2.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(260))));
6905 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6906 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006907 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006908
6909 var MSC_ConnHdlr vc_conn3;
6910 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 1);
6911 pars3.mscpool.rsl_idx := 2;
6912 /* An NRI of the second MSC's range (256-511) */
6913 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(511)), '00F110'O));
6914 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6915 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006916 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006917 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006918}
6919
6920/* Layer 3 Complete by TMSI with valid NRI for the third MSC are directed to the third MSC (configured in osmo-bsc.cfg),
6921 * while a round-robin remains unaffected by that. */
6922/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6923 * just as well using only RSL. */
6924testcase TC_mscpool_L3Complete_by_tmsi_valid_nri_2() runs on test_CT {
6925
6926 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
6927 f_sleep(1.0);
6928
6929 /* All TMSIs in this test point at the third MSC, set the round robin to point at the second MSC to make sure
6930 * this is not using round-robin. */
6931 f_vty_transceive(BSCVTY, "mscpool roundrobin next 1");
6932
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006933 f_ctrs_msc_init();
6934
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006935 var MSC_ConnHdlr vc_conn1;
6936 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 2);
6937 pars1.mscpool.rsl_idx := 0;
6938 /* An NRI of the third MSC's range (512-767) */
6939 pars1.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_SMS, valueof(ts_MI_TMSI_NRI_LV(512))));
6940 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6941 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006942 f_ctrs_msc_expect(2, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006943
6944 var MSC_ConnHdlr vc_conn2;
6945 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 2);
6946 pars2.mscpool.rsl_idx := 1;
6947 /* An NRI of the third MSC's range (512-767) */
6948 pars2.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(678))));
6949 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6950 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006951 f_ctrs_msc_expect(2, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006952
6953 /* The above forwardings to third MSC have not affected the round robin, which still points at the second MSC */
6954 var MSC_ConnHdlr vc_conn3;
6955 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 1);
6956 pars3.mscpool.rsl_idx := 2;
6957 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000013'H)), '00F110'O));
6958 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6959 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006960 f_ctrs_msc_expect(1, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006961 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006962}
6963
6964/* LU with a TMSI but indicating a different PLMN in its previous LAI: ignore the NRI. */
6965/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6966 * just as well using only RSL. */
6967testcase TC_mscpool_LU_by_tmsi_from_other_PLMN() runs on test_CT {
6968
6969 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
6970 f_sleep(1.0);
6971
6972 /* The TMSIs in this test points at the second MSC, but since it is from a different PLMN, round-robin is used
6973 * instead, and hits msc 0. */
6974 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6975
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006976 f_ctrs_msc_init();
6977
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006978 /* An NRI of the second MSC's range (256-511), but a PLMN that doesn't match with osmo-bsc.cfg */
6979 var MSC_ConnHdlr vc_conn1;
6980 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6981 pars1.mscpool.rsl_idx := 0;
6982 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(260)), '99F999'O));
6983 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6984 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006985 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006986
6987 /* An NRI of the third MSC's range (512-767) and a matching PLMN gets directed by NRI. */
6988 var MSC_ConnHdlr vc_conn2;
6989 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 2);
6990 pars2.mscpool.rsl_idx := 1;
6991 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(555)), '00F110'O));
6992 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6993 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006994 f_ctrs_msc_expect(2, "mscpool:subscr:known");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006995 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006996}
6997
6998/* Make sure that whichever MSC paged a subscriber will also get the Paging Response. Page by IMSI, which would be
6999 * round-robined to another MSC, to make sure the Paging->Response relation is stronger than the NRI->MSC mapping. */
7000private function f_tc_mscpool_paging_imsi(charstring id) runs on MSC_ConnHdlr {
7001 var template BSSMAP_FIELD_CellIdentificationList cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(0) } };
7002 //cid_list := { cIl_allInBSS := ''O };
7003 var RSL_ChanNeeded rsl_chneed := RSL_CHANNEED_SDCCH;
7004 var template BSSMAP_IE_ChannelNeeded bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
7005 var BSSAP_N_UNITDATA_req paging;
7006 var hexstring imsi := '001010000000123'H;
7007
7008 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
7009
Neels Hofmeyr90f80962020-06-12 16:16:55 +02007010 paging := valueof(ts_BSSAP_UNITDATA_req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007011 valueof(ts_BSSMAP_Paging(imsi, cid_list, omit, bssmap_chneed))));
7012 BSSAP.send(paging);
7013
7014 /* Register any RSL conn so that the Paging Command gets received here. With the current RSL_Emulation's main()
7015 * handling of '[bts_role] IPA_PT.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD()))' it doesn't matter at all which
7016 * channel number is picked here. */
7017 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(0, RSL_CHAN_NR_INVALID));
7018 f_rslem_register(0, new_chan_nr);
7019 RSL.receive(tr_RSL_PAGING_CMD(tr_MI_IMSI(imsi)));
7020 f_rslem_unregister(0, new_chan_nr);
7021
7022 /* Despite the round robin pointing at the second MSC ('roundrobin next 1'), the earlier Paging for the same IMSI
7023 * causes this Paging Response to go to the first MSC (bssap_idx := 0). */
7024 f_perform_compl_l3(RSL, ts_PAG_RESP(valueof(ts_MI_IMSI_LV(imsi))) );
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007025 f_sleep(1.0);
7026}
7027testcase TC_mscpool_paging_and_response_imsi() runs on test_CT {
7028 f_init(nr_bts := 1, handler_mode := true, nr_msc := 3);
7029 f_sleep(1.0);
7030
7031 /* Testing a Paging on the first MSC to get a Paging Response back to the first MSC. Set round robin to the
7032 * second MSC to make sure we're getting the Paging logic, not a coincidental round robin match. */
7033 f_vty_transceive(BSCVTY, "mscpool roundrobin next 1");
7034
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007035 f_ctrs_msc_init();
7036
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007037 var MSC_ConnHdlr vc_conn1;
7038 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
7039 pars1.mscpool.rsl_idx := 0;
Neels Hofmeyr90f80962020-06-12 16:16:55 +02007040 pars1.sccp_addr_bsc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_peer;
7041 pars1.sccp_addr_msc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_own;
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007042 vc_conn1 := f_start_handler(refers(f_tc_mscpool_paging_imsi), pars1);
7043 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007044 f_ctrs_msc_expect(0, "mscpool:subscr:paged");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007045 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007046}
7047
7048/* Make sure that whichever MSC paged a subscriber will also get the Paging Response. Page by TMSI with an NRI value
7049 * that matches a different MSC, to make sure the Paging->Response relation is stronger than the NRI->MSC mapping. */
7050private function f_tc_mscpool_paging_tmsi(charstring id) runs on MSC_ConnHdlr {
7051 var template BSSMAP_FIELD_CellIdentificationList cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(0) } };
7052 //cid_list := { cIl_allInBSS := ''O };
7053 var RSL_ChanNeeded rsl_chneed := RSL_CHANNEED_SDCCH;
7054 var template BSSMAP_IE_ChannelNeeded bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
7055 var integer nri_v := 300; /* <-- second MSC's NRI */
Harald Weltebf397612021-01-14 20:39:46 +01007056 var octetstring tmsi := f_gen_tmsi(suffix := 0, nri_v := nri_v);
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007057 var BSSAP_N_UNITDATA_req paging;
7058
7059 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
7060
Neels Hofmeyr90f80962020-06-12 16:16:55 +02007061 paging := valueof(ts_BSSAP_UNITDATA_req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007062 valueof(ts_BSSMAP_Paging('001010000000011'H, cid_list, tmsi, bssmap_chneed))));
7063 BSSAP.send(paging);
7064
7065 /* Register any RSL conn so that the Paging Command gets received here. With the current RSL_Emulation's main()
7066 * handling of '[bts_role] IPA_PT.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD()))' it doesn't matter at all which
7067 * channel number is picked here. */
7068 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(0, RSL_CHAN_NR_INVALID));
7069 f_rslem_register(0, new_chan_nr);
7070 RSL.receive(tr_RSL_PAGING_CMD(t_MI_TMSI(tmsi)));
7071 f_rslem_unregister(0, new_chan_nr);
7072
7073 /* Despite the NRI matching the second MSC (NRI from 'msc 1' in osmo-bsc.cfg) and round robin pointing at the
7074 * third MSC ('roundrobin next 2'), the earlier Paging for the same TMSI causes this Paging Response to go to
7075 * the first MSC (bssap_idx := 0). */
7076 f_perform_compl_l3(RSL, ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(nri_v))) );
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007077 f_sleep(1.0);
7078}
7079testcase TC_mscpool_paging_and_response_tmsi() runs on test_CT {
7080 f_init(nr_bts := 1, handler_mode := true, nr_msc := 3);
7081 f_sleep(1.0);
7082
7083 /* Testing a Paging on the first MSC to get a Paging Response back to the first MSC. Set round robin to the
7084 * third MSC to make sure we're getting the Paging logic, not a coincidental round robin match. */
7085 f_vty_transceive(BSCVTY, "mscpool roundrobin next 2");
7086
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007087 f_ctrs_msc_init();
7088
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007089 var MSC_ConnHdlr vc_conn1;
7090 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
7091 pars1.mscpool.rsl_idx := 0;
Neels Hofmeyr90f80962020-06-12 16:16:55 +02007092 pars1.sccp_addr_bsc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_peer;
7093 pars1.sccp_addr_msc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_own;
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007094 vc_conn1 := f_start_handler(refers(f_tc_mscpool_paging_tmsi), pars1);
7095 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007096 f_ctrs_msc_expect(0, "mscpool:subscr:paged");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007097 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007098}
7099
7100/* For round-robin, skip an MSC that has 'no allow-attach' set. */
7101/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
7102 * just as well using only RSL. */
7103testcase TC_mscpool_no_allow_attach_round_robin() runs on test_CT {
7104
7105 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
7106 f_sleep(1.0);
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00007107 /* Mark the second MSC as offloading, round-robin should skip this MSC now. */
7108 f_vty_msc_allow_attach(BSCVTY, {true, false, true});
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007109
7110 /* Control which MSC gets chosen next by the round-robin, otherwise
7111 * would be randomly affected by which other tests ran before this. */
7112 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
7113
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007114 f_ctrs_msc_init();
7115
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007116 var MSC_ConnHdlr vc_conn1;
7117 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
7118 pars1.mscpool.rsl_idx := 0;
7119 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000001'H)), '00F110'O));
7120 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
7121 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007122 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007123
7124 var MSC_ConnHdlr vc_conn2;
7125 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 2);
7126 pars2.mscpool.rsl_idx := 1;
7127 pars2.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000002'H))));
7128 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
7129 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007130 f_ctrs_msc_expect(2, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007131
7132 var MSC_ConnHdlr vc_conn3;
7133 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
7134 pars3.mscpool.rsl_idx := 2;
7135 pars3.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010000000003'H))));
7136 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
7137 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007138 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007139 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007140}
7141
7142/* An MSC that has 'no allow-attach' set should still serve subscribers that are already attached according to their
7143 * TMSI NRI. */
7144testcase TC_mscpool_no_allow_attach_valid_nri() runs on test_CT {
7145
7146 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
7147 f_sleep(1.0);
7148
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00007149 /* Mark the second MSC as offloading, round-robin should skip this MSC now. */
7150 f_vty_msc_allow_attach(BSCVTY, {true, false, true});
7151
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007152 /* Control which MSC gets chosen next by the round-robin, otherwise
7153 * would be randomly affected by which other tests ran before this. */
7154 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
7155
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007156 f_ctrs_msc_init();
7157
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007158 /* Round robin points at msc 0, but the valid NRI directs to msc 1, even though msc 1 has 'no allow-attach'. */
7159 var MSC_ConnHdlr vc_conn1;
7160 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 1);
7161 pars1.mscpool.rsl_idx := 0;
7162 /* An NRI of the second MSC's range (256-511) */
7163 pars1.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_TMSI_NRI_LV(260))));
7164 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
7165 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007166 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007167
7168 var MSC_ConnHdlr vc_conn2;
7169 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 0);
7170 pars2.mscpool.rsl_idx := 1;
7171 pars2.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000002'H))));
7172 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
7173 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007174 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007175
7176 var MSC_ConnHdlr vc_conn3;
7177 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 2);
7178 pars3.mscpool.rsl_idx := 2;
7179 pars3.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000003'H))));
7180 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
7181 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007182 f_ctrs_msc_expect(2, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007183 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007184}
7185
Philipp Maier783681c2020-07-16 16:47:06 +02007186/* Allow/Deny emergency calls globally via VTY */
7187private function f_vty_allow_emerg_msc(boolean allow) runs on test_CT {
7188 f_vty_enter_cfg_msc(BSCVTY, 0);
7189 if (allow) {
7190 f_vty_transceive(BSCVTY, "allow-emergency allow");
7191 } else {
7192 f_vty_transceive(BSCVTY, "allow-emergency deny");
7193 }
7194 f_vty_transceive(BSCVTY, "exit");
7195 f_vty_transceive(BSCVTY, "exit");
7196}
7197
7198/* Allow/Deny emergency calls per BTS via VTY */
7199private function f_vty_allow_emerg_bts(boolean allow, integer bts_nr) runs on test_CT {
7200 f_vty_enter_cfg_bts(BSCVTY, bts_nr);
7201 if (allow) {
7202 f_vty_transceive(BSCVTY, "rach emergency call allowed 1");
7203 } else {
7204 f_vty_transceive(BSCVTY, "rach emergency call allowed 0");
7205 }
7206 f_vty_transceive(BSCVTY, "exit");
7207 f_vty_transceive(BSCVTY, "exit");
Neels Hofmeyrb6ed80c2020-10-12 22:52:39 +00007208 f_vty_transceive(BSCVTY, "exit");
Philipp Maier783681c2020-07-16 16:47:06 +02007209}
7210
7211/* Begin assignmet procedure and send an EMERGENCY SETUP (RR) */
7212private function f_assignment_emerg_setup() runs on MSC_ConnHdlr {
7213 var PDU_ML3_MS_NW emerg_setup;
7214 var octetstring emerg_setup_enc;
7215 var RSL_Message emerg_setup_data_ind;
7216
7217 f_establish_fully(omit, omit);
7218
7219 emerg_setup := valueof(ts_ML3_MO_CC_EMERG_SETUP(1, valueof(ts_Bcap_voice)));
7220 emerg_setup_enc := enc_PDU_ML3_MS_NW(emerg_setup);
7221 emerg_setup_data_ind := valueof(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), emerg_setup_enc));
7222
7223 RSL.send(emerg_setup_data_ind);
7224}
7225
7226/* Test if the EMERGENCY SETUP gets passed on to the MSC via A when EMERGENCY
7227 * CALLS are permitted by the BSC config. */
7228private function f_TC_assignment_emerg_setup_allow(charstring id) runs on MSC_ConnHdlr {
7229 var PDU_BSSAP emerg_setup_data_ind_bssap;
7230 var PDU_ML3_MS_NW emerg_setup;
7231 timer T := 3.0;
7232
7233 f_assignment_emerg_setup()
7234
7235 T.start;
7236 alt {
7237 [] BSSAP.receive(tr_BSSAP_DTAP) -> value emerg_setup_data_ind_bssap {
7238 emerg_setup := dec_PDU_ML3_MS_NW(emerg_setup_data_ind_bssap.pdu.dtap);
7239 if (not isbound(emerg_setup.msgs.cc.emergencySetup)) {
7240 setverdict(fail, "no emergency setup");
7241 }
7242 }
7243 [] BSSAP.receive {
7244 setverdict(fail, "unexpected BSSAP message!");
7245 }
7246 [] T.timeout {
7247 setverdict(fail, "timout waiting for EMERGENCY SETUP!");
7248 }
7249 }
7250
7251 setverdict(pass);
7252}
7253
7254/* Test if the EMERGENCY SETUP gets blocked by the BSC if EMERGENCY CALLS are
7255 * forbidden by the BSC config. */
7256private function f_TC_assignment_emerg_setup_deny(charstring id) runs on MSC_ConnHdlr {
7257 var PDU_BSSAP emerg_setup_data_ind_bssap;
7258 timer T := 3.0;
7259
7260 f_assignment_emerg_setup()
7261
7262 T.start;
7263 alt {
7264 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
7265 setverdict(pass);
7266 }
7267 [] RSL.receive {
7268 setverdict(fail, "unexpected RSL message!");
7269 }
7270 [] T.timeout {
7271 setverdict(fail, "timout waiting for RR CHANNEL RELEASE!");
7272 }
7273 }
7274}
7275
7276/* EMERGENCY CALL situation #1, allowed globally and by BTS */
7277testcase TC_assignment_emerg_setup_allow() runs on test_CT {
7278 var TestHdlrParams pars := f_gen_test_hdlr_pars();
7279 var MSC_ConnHdlr vc_conn;
7280
7281 f_init(1, true);
7282 f_sleep(1.0);
7283
7284 f_vty_allow_emerg_msc(true);
7285 f_vty_allow_emerg_bts(true, 0);
7286 vc_conn := f_start_handler(refers(f_TC_assignment_emerg_setup_allow), pars);
7287 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007288 f_shutdown_helper();
Philipp Maier783681c2020-07-16 16:47:06 +02007289}
7290
7291/* EMERGENCY CALL situation #2, forbidden globally but allowed by BTS */
7292testcase TC_assignment_emerg_setup_deny_msc() runs on test_CT {
7293 var TestHdlrParams pars := f_gen_test_hdlr_pars();
7294 var MSC_ConnHdlr vc_conn;
7295
7296 f_init(1, true);
7297 f_sleep(1.0);
7298
7299 f_vty_allow_emerg_msc(false);
7300 f_vty_allow_emerg_bts(true, 0);
7301 vc_conn := f_start_handler(refers(f_TC_assignment_emerg_setup_deny), pars);
7302 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007303 f_shutdown_helper();
Philipp Maier783681c2020-07-16 16:47:06 +02007304}
7305
7306/* EMERGENCY CALL situation #3, allowed globally but forbidden by BTS */
7307testcase TC_assignment_emerg_setup_deny_bts() runs on test_CT {
7308 var TestHdlrParams pars := f_gen_test_hdlr_pars();
7309 var MSC_ConnHdlr vc_conn;
7310
7311 /* Note: This simulates a spec violation by the MS, correct MS
7312 * implementations would not try to establish an emergency call because
7313 * the system information tells in advance that emergency calls are
7314 * not forbidden */
7315
7316 f_init(1, true);
7317 f_sleep(1.0);
7318
7319 f_vty_allow_emerg_msc(true);
7320 f_vty_allow_emerg_bts(false, 0);
7321 vc_conn := f_start_handler(refers(f_TC_assignment_emerg_setup_deny), pars);
7322 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007323 f_shutdown_helper();
Philipp Maier783681c2020-07-16 16:47:06 +02007324}
7325
Philipp Maier82812002020-08-13 18:48:27 +02007326/* Test what happens when an emergency call arrives while all TCH channels are
7327 * busy, the BSC is expected to terminate one call in favor of the incoming
7328 * emergency call */
7329testcase TC_emerg_premption() runs on test_CT {
7330 var ASP_RSL_Unitdata rsl_ud;
7331 var integer i;
7332 var integer chreq_total, chreq_nochan;
7333 var RSL_Message rx_rsl;
7334 var RslChannelNr chan_nr;
7335
7336 f_init(1);
7337 f_sleep(1.0);
7338
7339 f_vty_allow_emerg_msc(true);
7340 f_vty_allow_emerg_bts(true, 0);
7341
7342 /* Fill up all channels on the BTS */
7343 chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total");
7344 chreq_nochan := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel");
7345 for (i := 0; i < NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS; i := i+1) {
7346 chan_nr := f_chreq_act_ack('33'O, i);
7347 }
7348 IPA_RSL[0].clear;
7349 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total",
7350 chreq_total + NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS);
7351
7352 /* Send Channel request for emegergency call */
7353 f_ipa_tx(0, ts_RSL_CHAN_RQD('A5'O, 23));
7354
7355 /* Expect the BSC to release one (the first) TCH/F on the BTS */
7356 chan_nr := valueof(t_RslChanNr_Bm(1));
7357 f_expect_chan_rel(0, chan_nr, expect_rr_chan_rel := false, expect_rll_rel_req := false);
7358
7359 /* Expect the BSC to send activate/assign the a channel for the emergency call */
7360 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7361 chan_nr := rx_rsl.ies[0].body.chan_nr;
7362 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 33));
7363 rx_rsl := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
Philipp Maier104f4c02020-09-11 18:12:18 +02007364
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007365 f_shutdown_helper();
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007366}
7367
7368/* Hopping parameters per a timeslot */
Vadim Yanitskiybc6654a2020-09-13 01:27:40 +07007369private type record length(0..64) of GsmArfcn ArfcnList;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007370private type record FHParamsTs {
7371 boolean enabled,
7372 uint6_t hsn,
7373 uint6_t maio,
7374 ArfcnList ma
7375};
7376
7377/* Hopping parameters per a transceiver */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007378private type record FHParamsTrx {
7379 GsmArfcn arfcn,
7380 FHParamsTs ts[8]
7381};
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007382
7383/* Randomly generate the hopping parameters for the given timeslot numbers */
7384private function f_TC_fh_params_gen(template integer tr_tn := (1, 3, 5))
7385runs on test_CT return FHParamsTrx {
7386 var FHParamsTrx fhp;
7387
Vadim Yanitskiy3e997362020-09-05 21:08:34 +07007388 /* Generate a random ARFCN, including ARFCN 0 */
7389 fhp.arfcn := f_rnd_int(3);
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007390
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007391 for (var integer tn := 0; tn < 8; tn := tn + 1) {
7392 if (not match(tn, tr_tn)) {
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007393 fhp.ts[tn].enabled := false;
7394 fhp.ts[tn].ma := { };
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007395 continue;
7396 }
7397
7398 /* Random HSN / MAIO values: 0..63 */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007399 fhp.ts[tn].hsn := f_rnd_int(64);
7400 fhp.ts[tn].maio := f_rnd_int(64);
7401 fhp.ts[tn].ma := { };
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007402
7403 /* Random Mobile Allocation (hopping channels) */
7404 var integer ma_len := 2 + f_rnd_int(9); /* 2..10 channels */
7405 var integer step := 3 + f_rnd_int(4); /* 3..6 stepping */
7406 for (var integer i := 1; i <= ma_len; i := i + 1) {
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007407 fhp.ts[tn].ma := fhp.ts[tn].ma & { i * step };
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007408 }
7409
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007410 fhp.ts[tn].enabled := true;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007411 }
7412
7413 log("f_TC_fh_params_gen(): ", fhp);
7414 return fhp;
7415}
7416
7417/* Make sure that the given Channel Description IE matches the hopping configuration */
7418private function f_TC_fh_params_match_chan_desc(in FHParamsTrx fhp, in ChannelDescription cd)
7419{
7420 var template (present) ChannelDescription tr_cd;
7421 var template (present) MaioHsn tr_maio_hsn;
7422 var uint3_t tn := cd.chan_nr.tn;
7423
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007424 if (fhp.ts[tn].enabled) {
7425 tr_maio_hsn := tr_HsnMaio(fhp.ts[tn].hsn, fhp.ts[tn].maio);
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007426 tr_cd := tr_ChanDescH1(cd.chan_nr, tr_maio_hsn);
7427 } else {
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007428 tr_cd := tr_ChanDescH0(cd.chan_nr, fhp.arfcn);
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007429 }
7430
7431 if (not match(cd, tr_cd)) {
7432 setverdict(fail, "Channel Description IE does not match: ",
7433 cd, " vs expected ", tr_cd);
7434 }
7435}
7436
7437/* Make sure that the given Mobile Allocation IE matches the hopping configuration */
7438private function f_TC_fh_params_match_ma(in FHParamsTrx fhp, uint3_t tn,
7439 in MobileAllocationLV ma)
7440{
7441 var template MobileAllocationLV tr_ma := f_TC_fh_params_gen_tr_ma(fhp, tn, ma);
7442
7443 if (not match(ma, tr_ma)) {
7444 setverdict(fail, "Mobile Allocation IE does not match (tn := ",
7445 tn, "): ", ma, " vs expected: ", tr_ma);
7446 } else {
7447 setverdict(pass);
7448 }
7449}
7450
7451private function f_TC_fh_params_gen_tr_ma(in FHParamsTrx fhp, uint3_t tn,
7452 in MobileAllocationLV ma)
7453return template MobileAllocationLV {
7454 /* Mobile Allocation IE is expected to be empty if hopping is not enabled */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007455 if (not fhp.ts[tn].enabled) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007456 return { len := 0, ma := ''B };
7457 }
7458
7459 var bitstring full_mask := f_pad_bit(''B, 1024, '0'B);
7460 var bitstring slot_mask := f_pad_bit(''B, 1024, '0'B);
7461 var bitstring ma_mask := ''B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007462
7463 /* Compose the full bit-mask (all channels, up to 1024 entries) */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007464 for (var integer i := 0; i < lengthof(fhp.ts); i := i + 1) {
7465 for (var integer j := 0; j < lengthof(fhp.ts[i].ma); j := j + 1) {
7466 if (full_mask[fhp.ts[i].ma[j]] == '1'B)
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007467 { continue; }
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007468 full_mask[fhp.ts[i].ma[j]] := '1'B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007469 }
7470 }
7471
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007472 /* Take ARFCN of the TRX itself into account */
7473 full_mask[fhp.arfcn] := '1'B;
7474
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007475 /* Compose a bit-mask for the given timeslot number */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007476 for (var integer i := 0; i < lengthof(fhp.ts[tn].ma); i := i + 1) {
7477 slot_mask[fhp.ts[tn].ma[i]] := '1'B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007478 }
7479
7480 /* Finally, compose the Mobile Allocation bit-mask */
Vadim Yanitskiy3e997362020-09-05 21:08:34 +07007481 for (var integer i := 1; i < lengthof(full_mask); i := i + 1) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007482 if (full_mask[i] != '1'B)
7483 { continue; }
7484
7485 /* FIXME: ma_mask := ma_mask & slot_mask[i]; // triggers a bug in TITAN */
7486 if (slot_mask[i] == '1'B) {
7487 ma_mask := ma_mask & '1'B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007488 } else {
7489 ma_mask := ma_mask & '0'B;
7490 }
7491 }
7492
Vadim Yanitskiy3e997362020-09-05 21:08:34 +07007493 /* ARFCN 0 (if present) goes to the last position of the bit-mask */
7494 if (full_mask[0] == '1'B) {
7495 /* FIXME: ma_mask := ma_mask & slot_mask[0]; // triggers a bug in TITAN */
7496 if (slot_mask[0] == '1'B) {
7497 ma_mask := ma_mask & '1'B;
7498 } else {
7499 ma_mask := ma_mask & '0'B;
7500 }
7501 }
7502
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007503 /* Ensure that ma_mask is octet-aligned */
Vadim Yanitskiy2aa02522020-09-06 14:05:23 +07007504 var integer ma_mask_len := (lengthof(ma_mask) + 8 - 1) / 8;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007505 ma_mask := f_pad_bit(ma_mask, ma_mask_len * 8, '0'B);
7506
7507 return { len := ma_mask_len, ma := ma_mask };
7508}
7509
7510/* Configure the hopping parameters in accordance with the given record */
7511private function f_TC_fh_params_set(in FHParamsTrx fhp,
7512 uint8_t bts_nr := 0,
7513 uint8_t trx_nr := 0)
7514runs on test_CT {
7515 /* Enter the configuration node for the given BTS/TRX numbers */
7516 f_vty_enter_cfg_trx(BSCVTY, bts_nr, trx_nr);
7517
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007518 f_vty_transceive(BSCVTY, "arfcn " & int2str(fhp.arfcn));
7519
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007520 for (var integer tn := 0; tn < lengthof(fhp.ts); tn := tn + 1) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007521 f_vty_transceive(BSCVTY, "timeslot " & int2str(tn));
7522
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007523 if (not fhp.ts[tn].enabled) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007524 f_vty_transceive(BSCVTY, "hopping enabled 0");
7525 f_vty_transceive(BSCVTY, "exit"); /* go back */
7526 continue;
7527 }
7528
7529 /* Configure HSN / MAIO values */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007530 f_vty_transceive(BSCVTY, "hopping sequence-number " & int2str(fhp.ts[tn].hsn));
7531 f_vty_transceive(BSCVTY, "hopping maio " & int2str(fhp.ts[tn].maio));
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007532
7533 /* Configure the Mobile Allocation (hopping channels) */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007534 for (var integer i := 0; i < lengthof(fhp.ts[tn].ma); i := i + 1) {
7535 f_vty_transceive(BSCVTY, "hopping arfcn add " & int2str(fhp.ts[tn].ma[i]));
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007536 }
7537
7538 f_vty_transceive(BSCVTY, "hopping enabled 1");
7539 f_vty_transceive(BSCVTY, "exit"); /* go back */
7540 }
7541
7542 f_vty_transceive(BSCVTY, "end");
7543}
7544
7545/* Disable frequency hopping on all timeslots */
7546private function f_TC_fh_params_unset(in FHParamsTrx fhp,
7547 uint8_t bts_nr := 0,
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007548 uint8_t trx_nr := 0,
7549 GsmArfcn arfcn := 871)
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007550runs on test_CT {
7551 /* Enter the configuration node for the given BTS/TRX numbers */
7552 f_vty_enter_cfg_trx(BSCVTY, bts_nr, trx_nr);
7553
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007554 f_vty_transceive(BSCVTY, "arfcn " & int2str(arfcn));
7555
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007556 for (var integer tn := 0; tn < lengthof(fhp.ts); tn := tn + 1) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007557 f_vty_transceive(BSCVTY, "timeslot " & int2str(tn));
7558
7559 /* Delete all ARFCNs from the Mobile Allocation (if any) */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007560 for (var integer i := 0; i < lengthof(fhp.ts[tn].ma); i := i + 1) {
7561 f_vty_transceive(BSCVTY, "hopping arfcn del " & int2str(fhp.ts[tn].ma[i]));
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007562 }
7563
7564 f_vty_transceive(BSCVTY, "hopping enabled 0");
7565 f_vty_transceive(BSCVTY, "exit"); /* go back */
7566 }
7567
7568 f_vty_transceive(BSCVTY, "end");
7569 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7570}
7571
7572/* Verify presence and correctness of the hopping parameters (HSN, MAIO)
7573 * in the Channel Identification IE of the RSL CHANnel ACTIVation message. */
7574testcase TC_fh_params_chan_activ() runs on test_CT {
7575 var FHParamsTrx fhp := f_TC_fh_params_gen();
7576 var RSL_Message rsl_msg;
7577 var RSL_IE_Body ie;
7578
7579 f_init_vty();
7580
7581 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
7582 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7583
7584 f_init(1);
7585
7586 /* CS domain: 3 (SDCCH/4+CBCH) + 4 (TCH/F) + 2 (TCH/H) channels available */
7587 for (var integer i := 0; i < 9; i := i + 1) {
7588 f_ipa_tx(0, ts_RSL_CHAN_RQD(f_rnd_ra_cs(), 23));
7589 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7590
7591 /* Make sure that Channel Identification IE is present */
7592 if (not f_rsl_find_ie(rsl_msg, RSL_IE_CHAN_IDENT, ie)) {
7593 setverdict(fail, "RSL Channel Identification IE is absent");
7594 continue;
7595 }
7596
7597 /* Make sure that hopping parameters (HSN/MAIO) match */
7598 f_TC_fh_params_match_chan_desc(fhp, ie.chan_ident.ch_desc.v);
7599
7600 /* "Mobile Allocation shall be included but empty" - let's check this */
7601 if (ie.chan_ident.ma.v.len != 0) {
7602 setverdict(fail, "Mobile Allocation IE is not empty: ",
7603 ie.chan_ident.ma, ", despite it shall be");
7604 continue;
7605 }
7606 }
7607
7608 /* Disable frequency hopping */
7609 f_TC_fh_params_unset(fhp);
7610
Vadim Yanitskiy21726312020-09-04 01:45:36 +07007611 f_shutdown_helper();
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007612}
7613
7614/* Verify the hopping parameters (HSN, MAIO, MA) in (RR) Immediate Assignment */
7615testcase TC_fh_params_imm_ass() runs on test_CT {
7616 var FHParamsTrx fhp := f_TC_fh_params_gen();
7617 var RSL_Message rsl_msg;
7618 var RSL_IE_Body ie;
7619
7620 f_init_vty();
7621
7622 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
7623 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7624
7625 f_init(1);
7626
7627 /* CS domain: 3 (SDCCH/4+CBCH) + 4 (TCH/F) + 2 (TCH/H) channels available */
7628 for (var integer i := 0; i < 9; i := i + 1) {
7629 f_ipa_tx(0, ts_RSL_CHAN_RQD(f_rnd_ra_cs(), 23));
7630 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7631
7632 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(rsl_msg.ies[0].body.chan_nr, 33));
7633 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeC(RSL_MT_IMMEDIATE_ASSIGN_CMD));
7634
7635 /* Make sure that Full Immediate Assign Info IE is present */
7636 if (not f_rsl_find_ie(rsl_msg, RSL_IE_FULL_IMM_ASS_INFO, ie)) {
7637 setverdict(fail, "RSL Full Immediate Assign Info IE is absent");
7638 continue;
7639 }
7640
7641 /* Decode the actual Immediate Assignment message */
7642 var GsmRrMessage rr_msg := dec_GsmRrMessage(ie.full_imm_ass_info.payload);
7643 if (not match(rr_msg.header, t_RrHeader(IMMEDIATE_ASSIGNMENT, ?))) {
7644 setverdict(fail, "Failed to match Immediate Assignment: ", rr_msg);
7645 continue;
7646 }
7647
7648 /* Make sure that hopping parameters (HSN/MAIO) match */
7649 f_TC_fh_params_match_chan_desc(fhp, rr_msg.payload.imm_ass.chan_desc);
7650
7651 /* Make sure that the Mobile Allocation IE matches */
7652 f_TC_fh_params_match_ma(fhp, rr_msg.payload.imm_ass.chan_desc.chan_nr.tn,
7653 rr_msg.payload.imm_ass.mobile_allocation);
7654 }
7655
7656 /* Disable frequency hopping */
7657 f_TC_fh_params_unset(fhp);
Philipp Maier82812002020-08-13 18:48:27 +02007658
Vadim Yanitskiy21726312020-09-04 01:45:36 +07007659 f_shutdown_helper();
Philipp Maier82812002020-08-13 18:48:27 +02007660}
7661
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07007662/* Verify the hopping parameters (HSN, MAIO, MA) in (RR) Assignment Command */
7663testcase TC_fh_params_assignment_cmd() runs on test_CT {
7664 var FHParamsTrx fhp := f_TC_fh_params_gen();
7665 var RSL_Message rsl_msg;
7666 var RSL_IE_Body ie;
7667
7668 f_init_vty();
7669
7670 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
7671 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7672
7673 f_init(1);
7674
7675 /* HACK: work around "Couldn't find Expect for CRCX" */
7676 vc_MGCP.stop;
7677
7678 var template PDU_BSSAP ass_cmd := f_gen_ass_req();
7679 ass_cmd.pdu.bssmap.assignmentRequest.codecList := ts_BSSMAP_IE_CodecList({ts_CodecFR});
7680
7681 /* CS domain (TCH): 4 (TCH/F) + 2 (TCH/H) channels available
7682 * NOTE: only 3 SDCCH/4 channels are available on CCCH+SDCCH4+CBCH */
7683 for (var integer i := 0; i < 3; i := i + 1) {
7684 /* Establish a dedicated channel, so we can trigger (late) TCH assignment */
7685 var DchanTuple dt := f_est_dchan(f_rnd_ra_cs(), 23, f_rnd_octstring(16));
7686
7687 /* Send a BSSMAP Assignment Command, expect CHANnel ACTIVation */
7688 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ass_cmd));
7689 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7690
7691 /* ACKnowledge CHANnel ACTIVation, expect RSL DATA REQuest */
7692 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(rsl_msg.ies[0].body.chan_nr, 33));
7693 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeR(RSL_MT_DATA_REQ));
7694
7695 /* Make sure that L3 Information IE is present */
7696 if (not f_rsl_find_ie(rsl_msg, RSL_IE_L3_INFO, ie)) {
7697 setverdict(fail, "RSL L3 Information IE is absent");
7698 continue;
7699 }
7700
7701 /* Decode the L3 message and make sure it is (RR) Assignment Command */
7702 var GsmRrL3Message l3_msg := dec_GsmRrL3Message(ie.l3_info.payload);
7703 if (not match(l3_msg.header, t_RrL3Header(ASSIGNMENT_COMMAND))) {
7704 setverdict(fail, "Failed to match Assignment Command: ", l3_msg);
7705 continue;
7706 }
7707
7708 /* Make sure that hopping parameters (HSN/MAIO) match */
7709 var ChannelDescription chan_desc := l3_msg.payload.ass_cmd.chan_desc;
7710 f_TC_fh_params_match_chan_desc(fhp, chan_desc);
7711
7712 /* Make sure that Cell Channel Description IE is present if FH is enabled */
7713 if (chan_desc.h and not ispresent(l3_msg.payload.ass_cmd.cell_chan_desc)) {
Vadim Yanitskiy38d069d2020-09-02 17:18:57 +07007714 setverdict(fail, "FH enabled, but Cell Channel Description IE is absent");
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07007715 continue;
7716 }
7717
7718 /* Make sure that the Mobile Allocation IE matches (if present) */
7719 var boolean ma_present := ispresent(l3_msg.payload.ass_cmd.mobile_allocation);
7720 if (chan_desc.h and ma_present) {
7721 f_TC_fh_params_match_ma(fhp, chan_desc.chan_nr.tn,
7722 l3_msg.payload.ass_cmd.mobile_allocation.v);
7723 } else if (chan_desc.h and not ma_present) {
7724 setverdict(fail, "FH enabled, but Mobile Allocation IE is absent");
7725 continue;
7726 } else if (not chan_desc.h and ma_present) {
7727 setverdict(fail, "FH disabled, but Mobile Allocation IE is present");
7728 continue;
7729 }
7730 }
7731
7732 /* Give the IUT some time to release all channels */
7733 f_sleep(3.0);
7734
7735 /* Disable frequency hopping */
7736 f_TC_fh_params_unset(fhp);
7737
Vadim Yanitskiy21726312020-09-04 01:45:36 +07007738 f_shutdown_helper();
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07007739}
7740
Vadim Yanitskiy8f5430d2020-09-02 18:51:38 +07007741/* Verify the hopping parameters (HSN, MAIO, MA) in (RR) Handover Command */
7742private function f_TC_fh_params_handover_cmd(in FHParamsTrx fhp)
7743runs on test_CT {
7744 var RSL_Message rsl_msg;
7745 var RSL_IE_Body ie;
7746 var DchanTuple dt;
7747
7748 /* Establish a dedicated channel, so we can trigger handover */
7749 dt := f_est_dchan(f_rnd_ra_cs(), 23, f_rnd_octstring(16));
7750
7751 /* Trigger handover from BTS0 to BTS1 */
7752 f_bts_0_cfg(BSCVTY, { "neighbor bts 1" });
7753 f_vty_handover(BSCVTY, 0, 0, dt.rsl_chan_nr, 1);
7754
7755 /* Expect RSL CHANnel ACTIVation on BTS1/TRX0/TS1 */
7756 rsl_msg := f_exp_ipa_rx(1, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7757
7758 /* ACKnowledge channel activation and expect (RR) Handover Command */
7759 f_ipa_tx(1, ts_RSL_CHAN_ACT_ACK(rsl_msg.ies[0].body.chan_nr, 33));
7760 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeR(RSL_MT_DATA_REQ));
7761
7762 /* Make sure that L3 Information IE is present */
7763 if (not f_rsl_find_ie(rsl_msg, RSL_IE_L3_INFO, ie)) {
7764 setverdict(fail, "RSL L3 Information IE is absent");
7765 return;
7766 }
7767
7768 /* Decode the L3 message and make sure it is (RR) Handover Command */
7769 var GsmRrL3Message l3_msg := dec_GsmRrL3Message(ie.l3_info.payload);
7770 if (not match(l3_msg.header, t_RrL3Header(HANDOVER_COMMAND))) {
7771 setverdict(fail, "Failed to match Handover Command: ", l3_msg);
7772 return;
7773 }
7774
7775 /* Make sure that we've got SDCCH/8 on TS1 (expected to be hopping) */
7776 var ChannelDescription chan_desc := l3_msg.payload.ho_cmd.chan_desc;
7777 if (not match(chan_desc.chan_nr, t_RslChanNr_SDCCH8(1, ?))) {
7778 setverdict(fail, "Unexpected channel number: ", chan_desc.chan_nr);
7779 return;
7780 }
7781
7782 /* Make sure that hopping parameters (HSN/MAIO) match */
7783 f_TC_fh_params_match_chan_desc(fhp, chan_desc);
7784
7785 /* Make sure that Cell Channel Description IE is present */
7786 if (not ispresent(l3_msg.payload.ho_cmd.cell_chan_desc)) {
7787 setverdict(fail, "FH enabled, but Cell Channel Description IE is absent");
7788 return;
7789 }
7790
7791 /* Make sure that the Mobile Allocation (after time) IE is present and matches */
7792 var boolean ma_present := ispresent(l3_msg.payload.ho_cmd.mobile_allocation);
7793 if (ma_present) {
7794 f_TC_fh_params_match_ma(fhp, chan_desc.chan_nr.tn,
7795 l3_msg.payload.ho_cmd.mobile_allocation.v);
7796 } else {
7797 setverdict(fail, "FH enabled, but Mobile Allocation IE is absent");
7798 return;
7799 }
7800}
7801testcase TC_fh_params_handover_cmd() runs on test_CT {
7802 var FHParamsTrx fhp := f_TC_fh_params_gen();
7803
7804 f_init_vty();
7805
7806 /* (Re)configure TS0 as BCCH and TS1 as SDCCH8 on BTS1/TRX0 */
7807 f_vty_enter_cfg_trx(BSCVTY, bts := 1, trx := 0);
7808
7809 f_vty_transceive(BSCVTY, "timeslot 0");
7810 f_vty_transceive(BSCVTY, "phys_chan_config ccch");
7811 f_vty_transceive(BSCVTY, "exit"); /* go back */
7812
7813 f_vty_transceive(BSCVTY, "timeslot 1");
7814 f_vty_transceive(BSCVTY, "phys_chan_config sdcch8");
7815 f_vty_transceive(BSCVTY, "end"); /* we're done */
7816
7817 f_TC_fh_params_set(fhp, 1); /* Enable frequency hopping on BTS1 */
7818 f_vty_transceive(BSCVTY, "drop bts connection 1 oml");
7819
7820 f_init(2);
7821
7822 f_TC_fh_params_handover_cmd(fhp);
7823
7824 /* Disable frequency hopping on BTS1 */
7825 f_TC_fh_params_unset(fhp, 1);
7826
7827 /* (Re)configure TS0 as CCCH+SDCCH4+CBCH and TS1 as TCH/F */
7828 f_vty_enter_cfg_trx(BSCVTY, bts := 1, trx := 0);
7829
7830 f_vty_transceive(BSCVTY, "timeslot 0");
7831 f_vty_transceive(BSCVTY, "phys_chan_config ccch+sdcch4+cbch");
7832 f_vty_transceive(BSCVTY, "exit"); /* go back */
7833
7834 f_vty_transceive(BSCVTY, "timeslot 1");
7835 f_vty_transceive(BSCVTY, "phys_chan_config tch/f");
7836 f_vty_transceive(BSCVTY, "end"); /* we're done */
7837
7838 f_shutdown_helper();
7839}
7840
Vadim Yanitskiyca974032020-09-01 07:20:39 +07007841/* Verify the hopping parameters in System Information Type 4 */
7842testcase TC_fh_params_si4_cbch() runs on test_CT {
7843 var FHParamsTrx fhp := f_TC_fh_params_gen(tr_tn := 1);
7844 var ASP_RSL_Unitdata rx_rsl_ud;
7845 timer T := 5.0;
7846
7847 f_init_vty();
7848
7849 /* (Re)configure TS0 as BCCH and TS1 as SDCCH8+CBCH */
7850 f_vty_enter_cfg_trx(BSCVTY, trx := 0);
7851
7852 f_vty_transceive(BSCVTY, "timeslot 0");
7853 f_vty_transceive(BSCVTY, "phys_chan_config ccch");
7854 f_vty_transceive(BSCVTY, "exit"); /* go back */
7855
7856 f_vty_transceive(BSCVTY, "timeslot 1");
7857 f_vty_transceive(BSCVTY, "phys_chan_config sdcch8+cbch");
7858 f_vty_transceive(BSCVTY, "end"); /* we're done */
7859
7860 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
7861 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7862
7863 f_init(1);
7864
7865 T.start;
7866 alt {
7867 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_BCCH_INFO(RSL_SYSTEM_INFO_4))) -> value rx_rsl_ud {
7868 var RSL_IE_Body ie := rx_rsl_ud.rsl.ies[2].body; /* FULL BCCH Information IE */
7869 var SystemInformation si := dec_SystemInformation(ie.other.payload);
7870
7871 /* Make sure that what we decoded is System Information Type 4 */
7872 if (si.header.message_type != SYSTEM_INFORMATION_TYPE_4) {
7873 setverdict(fail, "RSL FULL BCCH Information IE contains: ", si);
7874 repeat;
7875 }
7876
7877 /* Make sure that CBCH Channel Description IE is present */
7878 if (not ispresent(si.payload.si4.cbch_chan_desc)) {
7879 setverdict(fail, "CBCH Channel Description IE is absent");
7880 break;
7881 }
7882
7883 /* Finally, check the hopping parameters (HSN, MAIO) */
7884 var ChannelDescription chan_desc := si.payload.si4.cbch_chan_desc.v;
7885 f_TC_fh_params_match_chan_desc(fhp, chan_desc);
7886
7887 /* 3GPP TS 44.018, section 9.1.36.2 "CBCH Mobile Allocation":
7888 * The CBCH Mobile Allocation IE *shall* be present if FH is enabled. */
7889 if (chan_desc.h and not ispresent(si.payload.si4.cbch_mobile_alloc)) {
7890 setverdict(fail, "FH enabled, but Mobile Allocation IE is absent");
7891 break;
7892 } else if (chan_desc.h and ispresent(si.payload.si4.cbch_mobile_alloc)) {
7893 f_TC_fh_params_match_ma(fhp, chan_desc.chan_nr.tn,
7894 si.payload.si4.cbch_mobile_alloc.v);
7895 }
7896 }
7897 [] IPA_RSL[0].receive { repeat; }
7898 [] T.timeout {
7899 setverdict(fail, "Timeout waiting for RSL BCCH INFOrmation (SI4)");
7900 }
7901 }
7902
7903 /* Disable frequency hopping */
7904 f_TC_fh_params_unset(fhp);
7905
Vadim Yanitskiy8bc46012020-09-06 12:38:01 +07007906 /* (Re)configure TS0 as CCCH+SDCCH4+CBCH and TS1 as TCH/F */
Vadim Yanitskiyca974032020-09-01 07:20:39 +07007907 f_vty_enter_cfg_trx(BSCVTY, trx := 0);
7908
7909 f_vty_transceive(BSCVTY, "timeslot 0");
Vadim Yanitskiy8bc46012020-09-06 12:38:01 +07007910 f_vty_transceive(BSCVTY, "phys_chan_config ccch+sdcch4+cbch");
Vadim Yanitskiyca974032020-09-01 07:20:39 +07007911 f_vty_transceive(BSCVTY, "exit"); /* go back */
7912
7913 f_vty_transceive(BSCVTY, "timeslot 1");
7914 f_vty_transceive(BSCVTY, "phys_chan_config tch/f");
7915 f_vty_transceive(BSCVTY, "end"); /* we're done */
7916
Vadim Yanitskiy21726312020-09-04 01:45:36 +07007917 f_shutdown_helper();
Vadim Yanitskiyca974032020-09-01 07:20:39 +07007918}
7919
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02007920template (value) PDU_BSSAP_LE ts_BSSMAP_LE_BSSLAP(template (value) BSSLAP_PDU bsslap)
7921 := ts_BSSMAP_LE_ConnInfo(BSSMAP_LE_PROT_BSSLAP, data := enc_BSSLAP_PDU(valueof(bsslap)));
7922
7923private function f_match_bsslap(PDU_BSSAP_LE got_bsslap_msg,
7924 template (present) BSSLAP_PDU expect_bsslap)
7925{
7926 var BSSLAP_PDU bsslap := dec_BSSLAP_PDU(got_bsslap_msg.pdu.bssmap.co_info.bsslap_apdu.data);
7927 if (not match(bsslap, expect_bsslap)) {
7928 log("EXPECTING BSSLAP: ", expect_bsslap);
7929 log("GOT BSSLAP: ", bsslap);
7930 setverdict(fail, "BSSLAP is not as expected");
7931 mtc.stop;
7932 }
7933 setverdict(pass);
7934}
7935
7936/* GAD: this is an Ellipsoid point with uncertainty circle, encoded as in 3GPP TS 23.032 §7.3.2. */
7937const octetstring gad_ell_point_unc_circle := '10b0646d0d5f6627'O;
7938
7939private function f_expect_bsslap(template (present) BSSLAP_PDU expect_rx_bsslap) runs on MSC_ConnHdlr {
7940 var PDU_BSSAP_LE rx_bsslap;
7941 BSSAP_LE.receive(tr_BSSMAP_LE_ConnInfo(BSSMAP_LE_PROT_BSSLAP, ?)) -> value(rx_bsslap);
7942 f_match_bsslap(rx_bsslap, expect_rx_bsslap);
7943}
7944
7945/* With an active lchan, start BSSMAP Perform Location Request on A interface, starting BSSMAP-LE Perform Location
7946 * Request on Lb interface. Either with or without the SMLC doing a BSSLAP TA Request. */
7947private function f_lcs_loc_req_for_active_ms(boolean do_ta_request := false) runs on MSC_ConnHdlr {
7948 f_sleep(1.0);
7949
7950 f_establish_fully(omit, omit);
7951 f_bssap_le_register_imsi(g_pars.imsi, omit);
7952
7953 BSSAP.send(valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
7954 ts_CellId_CGI('262'H, '42'H, 23, 42))));
7955
7956 var PDU_BSSAP_LE plr;
7957 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
7958
7959 if (not do_ta_request) {
7960 /* verify TA Layer 3 in APDU. First the APDU type (BSSLAP), then the BSSLAP data contents. */
7961 var template BSSMAP_LE_IE_APDU expect_apdu := tr_BSSMAP_LE_APDU(BSSMAP_LE_PROT_BSSLAP, ?);
7962 if (not match(plr.pdu.bssmap.perf_loc_req.bsslap_apdu, expect_apdu)) {
7963 log("EXPECTING BSSMAP-LE APDU IE ", expect_apdu);
7964 log("GOT BSSMAP-LE APDU IE ", plr.pdu.bssmap.perf_loc_req.bsslap_apdu);
7965 setverdict(fail, "BSSMAP-LE APDU IE is not as expected");
7966 mtc.stop;
7967 }
7968 var template BSSLAP_PDU expect_ta_layer3 := tr_BSSLAP_TA_Layer3(tr_BSSLAP_IE_TA(0));
7969 var BSSLAP_PDU bsslap := dec_BSSLAP_PDU(plr.pdu.bssmap.perf_loc_req.bsslap_apdu.data);
7970 if (not match(bsslap, expect_ta_layer3)) {
7971 log("EXPECTING BSSLAP TA Layer 3: ", expect_ta_layer3);
7972 log("GOT BSSLAP: ", bsslap);
7973 setverdict(fail, "BSSLAP is not as expected");
7974 mtc.stop;
7975 }
7976 /* OsmoBSC directly sent the TA as BSSLAP APDU in the BSSMAP-LE Perform Location Request to the SMLC. The SMLC
7977 * has no need to request the TA from the BSC and directly responds. */
7978 } else {
7979 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
7980 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
7981 f_expect_bsslap(tr_BSSLAP_TA_Resp(?, ?));
7982 }
7983
7984 /* SMLC got the TA from the BSC, now responds with geo information data. */
7985 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(gad_ell_point_unc_circle, omit));
7986 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
7987 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(tr_BSSMAP_IE_LocationEstimate(gad_ell_point_unc_circle)));
7988
7989 /* The LCS was using an active A-interface conn. It should still remain active after this. */
7990 f_mo_l3_transceive();
7991
7992 f_perform_clear(RSL);
7993
7994 f_sleep(2.0);
7995 setverdict(pass);
7996}
7997
7998/* With an active lchan, start BSSMAP Perform Location Request on A interface, starting BSSMAP-LE Perform Location
7999 * Request on Lb interface. Without the SMLC doing a BSSLAP TA Request. */
8000private function f_tc_lcs_loc_req_for_active_ms(charstring id) runs on MSC_ConnHdlr {
8001 f_lcs_loc_req_for_active_ms(false);
8002}
8003testcase TC_lcs_loc_req_for_active_ms() runs on test_CT {
8004 var MSC_ConnHdlr vc_conn;
8005 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8006
8007 f_init(1, true);
8008 f_sleep(1.0);
8009 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_active_ms), pars);
8010 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008011 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008012}
8013
8014/* With an active lchan, start BSSMAP Perform Location Request on A interface, starting BSSMAP-LE Perform Location
8015 * Request on Lb interface. With the SMLC doing a BSSLAP TA Request. */
8016private function f_tc_lcs_loc_req_for_active_ms_ta_req(charstring id) runs on MSC_ConnHdlr {
8017 f_lcs_loc_req_for_active_ms(true);
8018}
8019testcase TC_lcs_loc_req_for_active_ms_ta_req() runs on test_CT {
8020 var MSC_ConnHdlr vc_conn;
8021 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8022
8023 f_init(1, true);
8024 f_sleep(1.0);
8025 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_active_ms_ta_req), pars);
8026 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008027 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008028}
8029
8030/* Clear the A-interface conn only, without doing anything on Abis. Useful for LCS, for cases where there is only an A
8031 * conn without an active lchan. */
8032private function f_clear_A_conn() runs on MSC_ConnHdlr
8033{
8034 var BssmapCause cause := 0;
8035 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
8036 BSSAP.receive(tr_BSSMAP_ClearComplete);
8037 BSSAP.send(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_REQ);
8038
8039 timer no_more_bssap := 5.0;
8040 no_more_bssap.start;
8041 alt {
8042 [] no_more_bssap.timeout { break; }
8043 [] BSSAP.receive(tr_BSSAP_BSSMAP) {
8044 setverdict(fail, "Expected no more BSSAP after Clear Complete");
8045 mtc.stop;
8046 }
8047 }
8048 setverdict(pass);
8049}
8050
8051/* Verify that the A-interface connection is still working, and then clear it, without doing anything on Abis. Useful
8052 * for LCS, for cases where there is only an A conn without an active lchan. */
8053private function f_verify_active_A_conn_and_clear() runs on MSC_ConnHdlr
8054{
8055 f_logp(BSCVTY, "f_verify_active_A_conn_and_clear: test A link, then clear");
8056
8057 /* When an lchan is active, we can send some L3 data from the BTS side and verify that it shows up on the other
8058 * side towards the MSC. When there is no lchan, this is not possible. To probe whether the A-interface
8059 * connection is still up, we need something that echos back on the A-interface. Another LCS request! */
8060 BSSAP.send(valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
8061 ts_CellId_CGI('262'H, '42'H, 23, 42))));
8062 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?));
8063
8064 /* Right, the Perform Location Request showed up on Lb, now we can clear the A conn. */
8065 f_clear_A_conn();
8066 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocAbort(BSSMAP_LE_LCS_CAUSE_REQUEST_ABORTED));
8067 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
8068}
8069
8070/* With *no* active lchan, start BSSMAP Perform Location Request on A interface, starting BSSMAP-LE Perform Location
8071 * Request on Lb interface. BSC will Page for the subscriber as soon as we (virtual SMLC) request the TA via BSSLAP.
8072 */
8073private function f_tc_lcs_loc_req_for_idle_ms(charstring id) runs on MSC_ConnHdlr {
8074 f_sleep(1.0);
8075
8076 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
8077 f_bssap_le_register_imsi(g_pars.imsi, omit);
8078
8079 /* Register to receive the Paging Command */
8080 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
8081 g_chan_nr := new_chan_nr;
8082 f_rslem_register(0, g_chan_nr);
8083
8084 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
8085 valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
8086 ts_CellId_CGI('001'H, '01'H, 1, 0)))));
8087 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
8088
8089 var PDU_BSSAP_LE plr;
8090 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
8091
8092 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
8093 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
8094
8095 /* OsmoBSC needs to Page */
8096 RSL.receive(tr_RSL_PAGING_CMD(tr_MI_IMSI(g_pars.imsi)));
8097 f_logp(BSCVTY, "got Paging Command");
8098
8099 /* MS requests channel. Since the Paging was for LCS, the Paging Response does not trigger a Complete Layer 3 to
8100 * the MSC, and releases the lchan directly. */
8101 f_perform_compl_l3(RSL, ts_PAG_RESP(valueof(ts_MI_IMSI_LV(g_pars.imsi))), do_clear := false, expect_bssmap_l3 := false);
8102 f_expect_lchan_rel(RSL);
8103
8104 /* From the Paging Response, the TA is now known to the BSC, and it responds to the SMLC. */
8105
8106 f_expect_bsslap(tr_BSSLAP_TA_Resp(?, ?));
8107
8108 /* SMLC got the TA from the BSC, now responds with geo information data. */
8109 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(gad_ell_point_unc_circle, omit));
8110 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
8111
8112 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(tr_BSSMAP_IE_LocationEstimate(gad_ell_point_unc_circle)));
8113
8114 /* The lchan is gone, the A-interface conn was created for the LCS only.
8115 * Still it is clearly the MSC's job to decide whether to tear down the conn or not. */
8116 f_verify_active_A_conn_and_clear();
8117
8118 f_sleep(2.0);
8119 setverdict(pass);
8120}
8121testcase TC_lcs_loc_req_for_idle_ms() runs on test_CT {
8122 var MSC_ConnHdlr vc_conn;
8123 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8124
8125 f_init(1, true);
8126 f_sleep(1.0);
8127
8128 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
8129 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
8130
8131 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_idle_ms), pars);
8132 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008133 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008134}
8135
8136/* With no active lchan, start BSSMAP Perform Location Request on A interface, but omit IMSI; expect failure response.
8137 */
8138private function f_tc_lcs_loc_req_no_subscriber(charstring id) runs on MSC_ConnHdlr {
8139 f_sleep(1.0);
8140
8141 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
8142 f_bssap_le_register_imsi(g_pars.imsi, omit);
8143
8144 /* provoke an abort by omitting both IMSI and IMEI */
8145 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
8146 valueof(ts_BSSMAP_Perform_Location_Request(omit,
8147 ts_CellId_CGI('262'H, '42'H, 23, 42)))));
8148 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
8149
8150 /* BSC tells MSC about failure */
8151 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(
8152 locationEstimate := omit, positioningData := omit,
8153 lCS_Cause := tr_BSSMAP_LcsCause(BSSMAP_LCS_CAUSE_DATA_MISSING_IN_REQ)));
8154
8155 /* There is no lchan. Still the MSC's job to decide whether to tear down the conn or not. */
8156 f_verify_active_A_conn_and_clear();
8157
8158 f_sleep(2.0);
8159 setverdict(pass);
8160}
8161testcase TC_lcs_loc_req_no_subscriber() runs on test_CT {
8162 var MSC_ConnHdlr vc_conn;
8163 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8164
8165 f_init(1, true);
8166 f_sleep(1.0);
8167
8168 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
8169 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
8170
8171 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_no_subscriber), pars);
8172 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008173 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008174}
8175
8176/* With an active lchan, start a Perform Location Request on the A-interface, but virtual SMLC does not answer with
8177 * BSSMAP-LE Perform Location Response (before or after sending a BSSLAP TA Request) */
8178private function f_lcs_loc_req_for_active_ms_le_timeout(boolean do_ta) runs on MSC_ConnHdlr {
8179 f_sleep(1.0);
8180
8181 f_establish_fully(omit, omit);
8182 f_bssap_le_register_imsi(g_pars.imsi, omit);
8183
8184 BSSAP.send(valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
8185 ts_CellId_CGI('262'H, '42'H, 23, 42))));
8186
8187 var PDU_BSSAP_LE plr;
8188 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
8189
8190 if (do_ta) {
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 f_expect_bsslap(tr_BSSLAP_TA_Resp(?, ?));
8194 }
8195
8196 /* SMLC fails to respond, BSC runs into timeout */
8197 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocAbort(BSSMAP_LE_LCS_CAUSE_SYSTEM_FAILURE));
8198 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
8199
8200 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(
8201 locationEstimate := omit, positioningData := omit,
8202 lCS_Cause := tr_BSSMAP_LcsCause(BSSMAP_LCS_CAUSE_SYSTEM_FAILURE)));
8203
8204 /* There is no lchan. Still the MSC's job to decide whether to tear down the conn or not. */
8205 f_verify_active_A_conn_and_clear();
8206
8207 f_sleep(2.0);
8208 setverdict(pass);
8209}
8210
8211/* With an active lchan, start a Perform Location Request on the A-interface, but virtual SMLC does not answer with
8212 * BSSMAP-LE Perform Location Response, without sending a BSSLAP TA Request. */
8213private function f_tc_lcs_loc_req_for_active_ms_le_timeout(charstring id) runs on MSC_ConnHdlr {
8214 f_lcs_loc_req_for_active_ms_le_timeout(false);
8215}
8216
8217testcase TC_lcs_loc_req_for_active_ms_le_timeout() runs on test_CT {
8218 var MSC_ConnHdlr vc_conn;
8219 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8220
8221 f_init(1, true);
8222 f_sleep(1.0);
8223 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_active_ms_le_timeout), pars);
8224 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008225 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008226}
8227
8228/* With an active lchan, start a Perform Location Request on the A-interface, but virtual SMLC does not answer with
8229 * BSSMAP-LE Perform Location Response, after sending a BSSLAP TA Request. */
8230private function f_tc_lcs_loc_req_for_active_ms_le_timeout2(charstring id) runs on MSC_ConnHdlr {
8231 f_lcs_loc_req_for_active_ms_le_timeout(true);
8232}
8233
8234testcase TC_lcs_loc_req_for_active_ms_le_timeout2() runs on test_CT {
8235 var MSC_ConnHdlr vc_conn;
8236 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8237
8238 f_init(1, true);
8239 f_sleep(1.0);
8240 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_active_ms_le_timeout2), pars);
8241 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008242 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008243}
8244
8245/* With *no* active lchan, start a Perform Location Request, expecting that the MS will be Paged. */
8246private function f_tc_lcs_loc_req_for_idle_ms_no_pag_resp(charstring id) runs on MSC_ConnHdlr {
8247 f_sleep(1.0);
8248
8249 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
8250 f_bssap_le_register_imsi(g_pars.imsi, omit);
8251
8252 /* Register to receive the Paging Command */
8253 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
8254 g_chan_nr := new_chan_nr;
8255 f_rslem_register(0, g_chan_nr);
8256
8257 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
8258 valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
8259 ts_CellId_CGI('001'H, '01'H, 1, 0)))));
8260 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
8261
8262 var PDU_BSSAP_LE plr;
8263 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
8264
8265 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
8266 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
8267
8268 /* OsmoBSC needs to Page */
8269 var PDU_BSSAP_LE rx_bsslap;
8270 alt {
8271 [] RSL.receive(tr_RSL_PAGING_CMD(tr_MI_IMSI(g_pars.imsi))) {
8272 f_logp(BSCVTY, "got Paging Command");
8273 repeat;
8274 }
8275 [] BSSAP_LE.receive(tr_BSSMAP_LE_ConnInfo(BSSMAP_LE_PROT_BSSLAP, ?)) -> value(rx_bsslap) {
8276 /* MS does not respond to Paging, TA Req runs into timeout. */
8277 f_match_bsslap(rx_bsslap, tr_BSSLAP_Abort(?));
8278 }
8279 }
8280
8281 /* SMLC responds with failure */
8282 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(omit, BSSMAP_LE_LCS_CAUSE_REQUEST_ABORTED));
8283 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
8284
8285 /* BSC tells MSC about failure */
8286 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(
8287 locationEstimate := omit, positioningData := omit,
8288 lCS_Cause := tr_BSSMAP_LcsCause(BSSMAP_LCS_CAUSE_REQUEST_ABORTED)));
8289
8290 /* There is no lchan. Still the MSC's job to decide whether to tear down the conn or not. */
8291 f_verify_active_A_conn_and_clear();
8292
8293 f_sleep(2.0);
8294 setverdict(pass);
8295}
8296testcase TC_lcs_loc_req_for_idle_ms_no_pag_resp() runs on test_CT {
8297 var MSC_ConnHdlr vc_conn;
8298 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8299
8300 f_init(1, true);
8301 f_sleep(1.0);
8302
8303 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
8304 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
8305
8306 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_idle_ms_no_pag_resp), pars);
8307 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008308 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008309}
8310
8311/* During an ongoing Location Request, the MS sends a CM Service Request. Expect the same A-conn to be re-used / taken
8312 * over. */
8313private function f_tc_cm_service_during_lcs_loc_req(charstring id) runs on MSC_ConnHdlr {
8314 f_sleep(1.0);
8315
8316 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
8317 f_bssap_le_register_imsi(g_pars.imsi, omit);
8318
8319 /* Register to receive the Paging Command */
8320 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
8321 g_chan_nr := new_chan_nr;
8322 f_rslem_register(0, g_chan_nr);
8323
8324 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
8325 valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
8326 ts_CellId_CGI('001'H, '01'H, 1, 0)))));
8327 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
8328
8329 var PDU_BSSAP_LE plr;
8330 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
8331
8332 /* As the A-interface conn was established for LCS, the MS coincidentally decides to issue a CM Service Request
8333 * and establish Layer 3. It should use the existing A-interface conn. */
8334 f_perform_compl_l3(RSL, valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV(g_pars.imsi)))),
8335 do_clear := false, expect_bssmap_l3 := true);
8336
8337 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
8338 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
8339
8340 /* OsmoBSC already has an lchan, no need to Page, just returns the TA */
8341 f_expect_bsslap(tr_BSSLAP_TA_Resp(?, ?));
8342
8343 /* SMLC got the TA from the BSC, now responds with geo information data. */
8344 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(gad_ell_point_unc_circle, omit));
8345 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
8346 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(tr_BSSMAP_IE_LocationEstimate(gad_ell_point_unc_circle)));
8347
8348 /* The lchan should still exist, it was from a CM Service Request. */
8349 f_mo_l3_transceive();
8350
8351 f_perform_clear(RSL);
8352
8353 f_sleep(2.0);
8354 setverdict(pass);
8355}
8356testcase TC_cm_service_during_lcs_loc_req() runs on test_CT {
8357 var MSC_ConnHdlr vc_conn;
8358 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8359
8360 f_init(1, true);
8361 f_sleep(1.0);
8362
8363 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
8364 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
8365
8366 vc_conn := f_start_handler(refers(f_tc_cm_service_during_lcs_loc_req), pars);
8367 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008368 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008369}
8370
8371/* During an ongoing Perform Location Request, do a Handover, an expect a BSSLAP Reset message from the BSC to indicate
8372 * the new lchan after handover. */
8373private function f_tc_ho_during_lcs_loc_req(charstring id) runs on MSC_ConnHdlr {
8374 f_sleep(1.0);
8375
8376 f_establish_fully(omit, omit);
8377 f_bssap_le_register_imsi(g_pars.imsi, omit);
8378
8379 BSSAP.send(valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
8380 ts_CellId_CGI('262'H, '42'H, 23, 42))));
8381
8382 var PDU_BSSAP_LE plr;
8383 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
8384
8385 /* SMLC ponders the Location Request, in the meantime the BSC decides to handover */
8386 f_bts_0_cfg(BSCVTY, {"neighbor bts 1"});
8387
8388 var HandoverState hs := {
8389 rr_ho_cmpl_seen := false,
8390 handover_done := false,
8391 old_chan_nr := -
8392 };
8393 /* issue hand-over command on VTY */
8394 f_vty_handover(BSCVTY, 0, 0, g_chan_nr, 1);
8395 /* temporarily suspend DChan processing on BTS1 to avoid race with RSLEM_register */
8396 f_rslem_suspend(RSL1_PROC);
8397
8398 /* From the MGW perspective, a handover is is characterized by
8399 * performing one MDCX operation with the MGW. So we expect to see
8400 * one more MDCX during handover. */
8401 g_media.mgcp_conn[0].mdcx_seen_exp := g_media.mgcp_conn[0].crcx_seen_exp + 1;
8402
8403 alt {
8404 [] as_handover(hs);
8405 }
8406
8407 var PDU_BSSAP_LE rx_bsslap;
8408
8409 interleave {
8410 /* Expect the BSC to inform the MSC about the handover */
8411 [] BSSAP.receive(tr_BSSMAP_HandoverPerformed);
8412
8413 /* Expect the BSC to inform the SMLC about the handover */
8414 [] BSSAP_LE.receive(tr_BSSMAP_LE_ConnInfo(BSSMAP_LE_PROT_BSSLAP, ?)) -> value(rx_bsslap) {
8415 f_match_bsslap(rx_bsslap, tr_BSSLAP_Reset(BSSLAP_CAUSE_INTRA_BSS_HO));
8416 }
8417 }
8418
8419 /* SMLC now responds with geo information data. */
8420 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(gad_ell_point_unc_circle, omit));
8421 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
8422 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(tr_BSSMAP_IE_LocationEstimate(gad_ell_point_unc_circle)));
8423
8424 /* lchan still active */
8425 f_mo_l3_transceive(RSL1);
8426
8427 /* MSC decides it is done now. */
8428 f_perform_clear(RSL1);
8429
8430 f_sleep(2.0);
8431 setverdict(pass);
8432}
8433testcase TC_ho_during_lcs_loc_req() runs on test_CT {
8434 var MSC_ConnHdlr vc_conn;
8435 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8436
8437 f_init(2, true);
8438 f_sleep(1.0);
8439 vc_conn := f_start_handler(refers(f_tc_ho_during_lcs_loc_req), pars);
8440 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008441 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008442}
8443
Neels Hofmeyrbf037052020-10-28 22:52:02 +00008444/* Attempt Complete Layer 3 without any MSC available (OS#4832) */
8445private function f_tc_no_msc(charstring id) runs on MSC_ConnHdlr {
8446 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
8447
8448 /* Also disable attach for the single connected MSC */
8449 f_vty_msc_allow_attach(BSCVTY, { false });
8450
8451 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) ));
8452 f_chan_est(g_pars.ra, l3_enc, g_pars.link_id, g_pars.fn);
8453
8454 /* No MSC is found, expecting a proper release on RSL */
8455 interleave {
8456 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
8457 f_logp(BSCVTY, "Got RSL RR Release");
8458 }
8459 [] RSL.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
8460 f_logp(BSCVTY, "Got RSL Deact SACCH");
8461 }
8462 [] RSL.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
8463 f_logp(BSCVTY, "Got RSL RF Chan Rel, sending Rel Ack");
8464 RSL.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
8465 }
8466 }
8467 setverdict(pass);
8468}
8469testcase TC_no_msc() runs on test_CT {
8470
8471 f_init(1, true);
8472 f_sleep(1.0);
8473 var MSC_ConnHdlr vc_conn;
8474 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8475
8476 f_ctrs_bsc_init(counternames_bsc_mscpool);
8477
8478 vc_conn := f_start_handler(refers(f_tc_no_msc), pars);
8479 vc_conn.done;
8480
8481 f_ctrs_bsc_add("mscpool:subscr:no_msc");
8482 f_ctrs_bsc_verify();
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008483 f_shutdown_helper();
Neels Hofmeyrbf037052020-10-28 22:52:02 +00008484}
8485
Harald Welte0ea2d5e2018-04-07 21:40:29 +02008486/* Dyn PDCH todo:
8487 * activate OSMO as TCH/F
8488 * activate OSMO as TCH/H
8489 * does the BSC-located PCU socket get the updated INFO?
8490 * what if no PCU is connected at the time?
8491 * is the info correct on delayed PCU (re)connect?
8492 */
Harald Welte94e0c342018-04-07 11:33:23 +02008493
Harald Welte28d943e2017-11-25 15:00:50 +01008494control {
Harald Welte898113b2018-01-31 18:32:21 +01008495 /* CTRL interface testing */
Harald Welte4003d112017-12-09 22:35:39 +01008496 execute( TC_ctrl_msc_connection_status() );
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01008497 execute( TC_ctrl_msc0_connection_status() );
Harald Welte96c94412017-12-09 03:12:45 +01008498 execute( TC_ctrl() );
Neels Hofmeyrf246a922020-05-13 02:27:10 +02008499 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_SCCPlite_SERVER) {
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +02008500 execute( TC_ctrl_location() );
8501 }
Harald Welte898113b2018-01-31 18:32:21 +01008502
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02008503 execute( TC_si_default() );
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02008504 execute( TC_si2quater_2_earfcns() );
8505 execute( TC_si2quater_3_earfcns() );
8506 execute( TC_si2quater_4_earfcns() );
8507 execute( TC_si2quater_5_earfcns() );
8508 execute( TC_si2quater_6_earfcns() );
Neels Hofmeyrad132f22020-07-08 02:20:16 +02008509 execute( TC_si2quater_12_earfcns() );
8510 execute( TC_si2quater_23_earfcns() );
8511 execute( TC_si2quater_32_earfcns() );
8512 execute( TC_si2quater_33_earfcns() );
8513 execute( TC_si2quater_42_earfcns() );
8514 execute( TC_si2quater_48_earfcns() );
8515 execute( TC_si2quater_49_earfcns() );
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02008516 execute( TC_si_acc_rotate() );
Alexander Couzens4ad3a352020-09-10 22:29:12 +02008517 execute( TC_si_acc_ramp_rotate() );
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02008518
Harald Welte898113b2018-01-31 18:32:21 +01008519 /* RSL DCHAN Channel ACtivation / Deactivation */
Harald Welteae026692017-12-09 01:03:01 +01008520 execute( TC_chan_act_noreply() );
Harald Welte4003d112017-12-09 22:35:39 +01008521 execute( TC_chan_act_counter() );
Harald Welteae026692017-12-09 01:03:01 +01008522 execute( TC_chan_act_ack_noest() );
Philipp Maier9c60a622020-07-09 15:08:46 +02008523 execute( TC_chan_act_ack_noest_emerg() );
Philipp Maier606f07d2020-08-12 17:21:58 +02008524 execute( TC_chan_rqd_emerg_deny() );
Harald Welteae026692017-12-09 01:03:01 +01008525 execute( TC_chan_act_ack_est_ind_noreply() );
8526 execute( TC_chan_act_ack_est_ind_refused() );
Harald Welte618ef642017-12-14 14:58:20 +01008527 execute( TC_chan_act_nack() );
Harald Welte799c97b2017-12-14 17:50:30 +01008528 execute( TC_chan_exhaustion() );
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07008529 execute( TC_chan_deact_silence() );
Harald Welte4003d112017-12-09 22:35:39 +01008530 execute( TC_chan_rel_rll_rel_ind() );
8531 execute( TC_chan_rel_conn_fail() );
8532 execute( TC_chan_rel_hard_clear() );
Pau Espin Pedrol841b90d2021-04-15 16:42:52 +02008533 execute( TC_chan_rel_last_eutran_plmn_hard_clear_no_csfb() );
8534 execute( TC_chan_rel_last_eutran_plmn_hard_clear_csfb() );
Harald Welte99787102019-02-04 10:41:36 +01008535 execute( TC_chan_rel_hard_clear_csfb() );
Harald Welted8c36cd2017-12-09 23:05:31 +01008536 execute( TC_chan_rel_hard_rlsd() );
Harald Welte550daf92018-06-11 19:22:13 +02008537 execute( TC_chan_rel_hard_rlsd_ms_dead() );
Harald Welte85804d42017-12-10 14:11:58 +01008538 execute( TC_chan_rel_a_reset() );
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01008539 execute( TC_chan_rel_sccp_tiar_timeout() );
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02008540 execute( TC_chan_rel_rr_cause() );
Harald Welte6f521d82017-12-11 19:52:02 +01008541
Harald Weltecfe2c962017-12-15 12:09:32 +01008542 execute( TC_outbound_connect() );
Harald Welte898113b2018-01-31 18:32:21 +01008543
8544 /* Assignment related */
Harald Welte16a4adf2017-12-14 18:54:01 +01008545 execute( TC_assignment_cic_only() );
Harald Welte235ebf12017-12-15 14:18:16 +01008546 execute( TC_assignment_csd() );
8547 execute( TC_assignment_ctm() );
8548 execute( TC_assignment_sign() );
Pau Espin Pedrol07866632020-09-03 19:10:55 +02008549 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
8550 execute( TC_assignment_aoip_tla_v6() );
8551 }
Harald Welte235ebf12017-12-15 14:18:16 +01008552 execute( TC_assignment_fr_a5_0() );
8553 execute( TC_assignment_fr_a5_1() );
Neels Hofmeyrf246a922020-05-13 02:27:10 +02008554 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welte8f67d1d2018-05-25 20:38:42 +02008555 execute( TC_assignment_fr_a5_1_codec_missing() );
8556 }
Harald Welte235ebf12017-12-15 14:18:16 +01008557 execute( TC_assignment_fr_a5_3() );
8558 execute( TC_assignment_fr_a5_4() );
Harald Welte3c86ea02018-05-10 22:28:05 +02008559 execute( TC_ciph_mode_a5_0() );
8560 execute( TC_ciph_mode_a5_1() );
8561 execute( TC_ciph_mode_a5_3() );
Harald Welte16a4adf2017-12-14 18:54:01 +01008562
Harald Welte60aa5762018-03-21 19:33:13 +01008563 execute( TC_assignment_codec_fr() );
8564 execute( TC_assignment_codec_hr() );
8565 execute( TC_assignment_codec_efr() );
8566 execute( TC_assignment_codec_amr_f() );
8567 execute( TC_assignment_codec_amr_h() );
Philipp Maier8a581d22019-03-26 18:32:48 +01008568
Neels Hofmeyrf246a922020-05-13 02:27:10 +02008569 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Philipp Maier8a581d22019-03-26 18:32:48 +01008570 execute( TC_assignment_codec_amr_f_S1() );
8571 execute( TC_assignment_codec_amr_h_S1() );
8572 execute( TC_assignment_codec_amr_f_S124() );
8573 execute( TC_assignment_codec_amr_h_S124() );
8574 execute( TC_assignment_codec_amr_f_S0() );
8575 execute( TC_assignment_codec_amr_f_S02() );
8576 execute( TC_assignment_codec_amr_f_S024() );
8577 execute( TC_assignment_codec_amr_f_S0247() );
8578 execute( TC_assignment_codec_amr_h_S0() );
8579 execute( TC_assignment_codec_amr_h_S02() );
8580 execute( TC_assignment_codec_amr_h_S024() );
8581 execute( TC_assignment_codec_amr_h_S0247() );
8582 execute( TC_assignment_codec_amr_f_S01234567() );
8583 execute( TC_assignment_codec_amr_f_S0234567() );
8584 execute( TC_assignment_codec_amr_f_zero() );
8585 execute( TC_assignment_codec_amr_f_unsupp() );
8586 execute( TC_assignment_codec_amr_h_S7() );
Neels Hofmeyr21863562020-11-26 00:34:33 +00008587 execute( TC_assignment_codec_amr_f_start_mode_auto() );
8588 execute( TC_assignment_codec_amr_h_start_mode_auto() );
Neels Hofmeyr3eb94562020-11-26 02:40:26 +00008589 execute( TC_assignment_codec_amr_f_start_mode_4() );
8590 execute( TC_assignment_codec_amr_h_start_mode_4() );
Neels Hofmeyr454d7922020-11-26 02:24:57 +00008591 execute( TC_assignment_codec_amr_startmode_cruft() );
Philipp Maier8a581d22019-03-26 18:32:48 +01008592 }
Harald Welte60aa5762018-03-21 19:33:13 +01008593
Philipp Maierac09bfc2019-01-08 13:41:39 +01008594 execute( TC_assignment_codec_fr_exhausted_req_hr() );
8595 execute( TC_assignment_codec_fr_exhausted_req_fr() );
8596 execute( TC_assignment_codec_fr_exhausted_req_fr_hr() );
8597 execute( TC_assignment_codec_fr_exhausted_req_hr_fr() );
8598 execute( TC_assignment_codec_hr_exhausted_req_fr() );
8599 execute( TC_assignment_codec_hr_exhausted_req_hr() );
8600 execute( TC_assignment_codec_hr_exhausted_req_hr_fr() );
8601 execute( TC_assignment_codec_hr_exhausted_req_fr_hr() );
8602 execute( TC_assignment_codec_req_hr_fr() );
8603 execute( TC_assignment_codec_req_fr_hr() );
8604
Pau Espin Pedrol58cf6822019-05-28 18:11:33 +02008605 if (mp_enable_osmux_test) {
8606 execute( TC_assignment_osmux() );
8607 }
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02008608
Harald Welte898113b2018-01-31 18:32:21 +01008609 /* RLL Establish Indication on inactive DCHAN / SAPI */
Harald Welte5cd20ed2017-12-13 21:03:20 +01008610 execute( TC_rll_est_ind_inact_lchan() );
8611 execute( TC_rll_est_ind_inval_sapi1() );
8612 execute( TC_rll_est_ind_inval_sapi3() );
8613 execute( TC_rll_est_ind_inval_sacch() );
8614
Vadim Yanitskiy61f784a2020-10-01 21:12:19 +07008615 /* DLCI / RSL Link ID conversion for MO/MT messages on SAPI0/SAPI3 */
8616 execute( TC_tch_dlci_link_id_sapi() );
8617
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07008618 /* SAPI N Reject triggered by RLL establishment failures */
8619 execute( TC_rll_rel_ind_sapi_n_reject() );
8620 execute( TC_rll_err_ind_sapi_n_reject() );
8621 execute( TC_rll_timeout_sapi_n_reject() );
8622
Harald Welte898113b2018-01-31 18:32:21 +01008623 /* Paging related tests */
Harald Welte6f521d82017-12-11 19:52:02 +01008624 execute( TC_paging_imsi_nochan() );
8625 execute( TC_paging_tmsi_nochan() );
8626 execute( TC_paging_tmsi_any() );
8627 execute( TC_paging_tmsi_sdcch() );
8628 execute( TC_paging_tmsi_tch_f() );
8629 execute( TC_paging_tmsi_tch_hf() );
8630 execute( TC_paging_imsi_nochan_cgi() );
8631 execute( TC_paging_imsi_nochan_lac_ci() );
8632 execute( TC_paging_imsi_nochan_ci() );
8633 execute( TC_paging_imsi_nochan_lai() );
8634 execute( TC_paging_imsi_nochan_lac() );
8635 execute( TC_paging_imsi_nochan_all() );
Harald Welte751d3eb2018-01-31 15:51:06 +01008636 execute( TC_paging_imsi_nochan_plmn_lac_rnc() );
8637 execute( TC_paging_imsi_nochan_rnc() );
8638 execute( TC_paging_imsi_nochan_lac_rnc() );
8639 execute( TC_paging_imsi_nochan_lacs() );
8640 execute( TC_paging_imsi_nochan_lacs_empty() );
Stefan Sperling049a86e2018-03-20 15:51:00 +01008641 execute( TC_paging_imsi_nochan_cgi_unknown_cid() );
Harald Welte10985002017-12-12 09:29:15 +01008642 execute( TC_paging_imsi_a_reset() );
Harald Weltee65d40e2017-12-13 00:09:06 +01008643 execute( TC_paging_imsi_load() );
Philipp Maier779a7922018-02-16 11:00:37 +01008644 execute( TC_paging_counter() );
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01008645 execute( TC_paging_resp_unsol() );
Harald Welte4e9b9cc2017-12-14 18:31:02 +01008646
8647 execute( TC_rsl_drop_counter() );
Stefan Sperling830dc9d2018-02-12 21:08:28 +01008648 execute( TC_rsl_unknown_unit_id() );
8649
8650 execute( TC_oml_unknown_unit_id() );
Harald Welte898113b2018-01-31 18:32:21 +01008651
8652 execute( TC_classmark() );
Harald Welteeddf0e92020-06-21 19:42:15 +02008653 execute( TC_common_id() );
Harald Welte898113b2018-01-31 18:32:21 +01008654 execute( TC_unsol_ass_fail() );
Harald Welteea99a002018-01-31 20:46:43 +01008655 execute( TC_unsol_ass_compl() );
Harald Weltefbf9b5e2018-01-31 20:41:23 +01008656 execute( TC_unsol_ho_fail() );
Harald Weltee3bd6582018-01-31 22:51:25 +01008657 execute( TC_err_82_short_msg() );
Harald Weltee9e02e42018-01-31 23:36:25 +01008658 execute( TC_err_84_unknown_msg() );
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01008659
Harald Welte261af4b2018-02-12 21:20:39 +01008660 execute( TC_ho_int() );
Neels Hofmeyr5f144212020-11-03 15:41:58 +00008661 execute( TC_ho_int_radio_link_failure() );
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01008662
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01008663 execute( TC_ho_out_of_this_bsc() );
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02008664 execute( TC_ho_out_fail_no_msc_response() );
8665 execute( TC_ho_out_fail_rr_ho_failure() );
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02008666 execute( TC_ho_out_fail_no_result_after_ho_cmd() );
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01008667
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01008668 execute( TC_ho_into_this_bsc() );
Pau Espin Pedrol07866632020-09-03 19:10:55 +02008669 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
8670 execute( TC_ho_into_this_bsc_tla_v6() );
8671 }
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02008672 execute( TC_srvcc_eutran_to_geran() );
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01008673 execute( TC_ho_in_fail_msc_clears() );
8674 execute( TC_ho_in_fail_msc_clears_after_ho_detect() );
8675 execute( TC_ho_in_fail_no_detect() );
8676 execute( TC_ho_in_fail_no_detect2() );
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01008677
Neels Hofmeyr91401012019-07-11 00:42:35 +02008678 execute( TC_ho_neighbor_config_1() );
8679 execute( TC_ho_neighbor_config_2() );
8680 execute( TC_ho_neighbor_config_3() );
8681 execute( TC_ho_neighbor_config_4() );
8682 execute( TC_ho_neighbor_config_5() );
8683 execute( TC_ho_neighbor_config_6() );
8684 execute( TC_ho_neighbor_config_7() );
8685
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01008686 execute( TC_bssap_rlsd_does_not_cause_bssmap_reset() );
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01008687 execute( TC_bssmap_clear_does_not_cause_bssmap_reset() );
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01008688 execute( TC_ms_rel_ind_does_not_cause_bssmap_reset() );
Harald Welte94e0c342018-04-07 11:33:23 +02008689
8690 execute( TC_dyn_pdch_ipa_act_deact() );
8691 execute( TC_dyn_pdch_ipa_act_nack() );
8692 execute( TC_dyn_pdch_osmo_act_deact() );
8693 execute( TC_dyn_pdch_osmo_act_nack() );
Harald Welte99f3ca02018-06-14 13:40:29 +02008694
Stefan Sperling0796a822018-10-05 13:01:39 +02008695 execute( TC_chopped_ipa_ping() );
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02008696 execute( TC_chopped_ipa_payload() );
Stefan Sperling0796a822018-10-05 13:01:39 +02008697
Pau Espin Pedrol8f773632019-11-05 11:46:53 +01008698 /* Power control related */
8699 execute( TC_assignment_verify_ms_power_params_ie() );
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008700
8701 /* MSC pooling */
8702 /* FIXME: in SCCPlite, indicating how many MSCs should be connected does currently not work. Since
8703 * RESET->RESET-ACK is unconditionally negotiated for all configured MSCs, they always all appear as connected
8704 * to osmo-bsc. The MSC pooling tests however require disconnecting selected MSCs, and hence don't work out as
8705 * intended on SCCPlite. So for now, run these only for SCCP/M3UA. */
8706 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
8707 execute( TC_mscpool_L3Compl_on_1_msc() );
8708 execute( TC_mscpool_L3Complete_by_imsi_round_robin() );
8709 execute( TC_mscpool_LU_by_tmsi_null_nri_0_round_robin() );
8710 execute( TC_mscpool_LU_by_tmsi_null_nri_1_round_robin() );
8711 execute( TC_mscpool_L3Complete_by_tmsi_unassigned_nri_round_robin() );
8712 execute( TC_mscpool_L3Complete_by_tmsi_valid_nri_msc_not_connected_round_robin() );
8713 execute( TC_mscpool_L3Complete_by_tmsi_valid_nri_1() );
8714 execute( TC_mscpool_L3Complete_by_tmsi_valid_nri_2() );
8715 execute( TC_mscpool_LU_by_tmsi_from_other_PLMN() );
8716 execute( TC_mscpool_paging_and_response_imsi() );
8717 execute( TC_mscpool_paging_and_response_tmsi() );
8718 execute( TC_mscpool_no_allow_attach_round_robin() );
8719 execute( TC_mscpool_no_allow_attach_valid_nri() );
8720 }
8721
Harald Welte99f3ca02018-06-14 13:40:29 +02008722 /* at bottom as they might crash OsmoBSC before OS#3182 is fixed */
8723 execute( TC_early_conn_fail() );
8724 execute( TC_late_conn_fail() );
8725
Philipp Maier783681c2020-07-16 16:47:06 +02008726 /* Emergency call handling (deny / allow) */
8727 execute( TC_assignment_emerg_setup_allow() );
8728 execute( TC_assignment_emerg_setup_deny_msc() );
8729 execute( TC_assignment_emerg_setup_deny_bts() );
Philipp Maier82812002020-08-13 18:48:27 +02008730 execute( TC_emerg_premption() );
8731
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008732 /* Frequency hopping parameters handling */
8733 execute( TC_fh_params_chan_activ() );
8734 execute( TC_fh_params_imm_ass() );
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07008735 execute( TC_fh_params_assignment_cmd() );
Vadim Yanitskiy8f5430d2020-09-02 18:51:38 +07008736 execute( TC_fh_params_handover_cmd() );
Vadim Yanitskiyca974032020-09-01 07:20:39 +07008737 execute( TC_fh_params_si4_cbch() );
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008738
8739 if (mp_enable_lcs_tests) {
8740 execute( TC_lcs_loc_req_for_active_ms() );
8741 execute( TC_lcs_loc_req_for_active_ms_ta_req() );
8742 execute( TC_lcs_loc_req_for_idle_ms() );
8743 execute( TC_lcs_loc_req_no_subscriber() );
8744 execute( TC_lcs_loc_req_for_active_ms_le_timeout() );
8745 execute( TC_lcs_loc_req_for_active_ms_le_timeout2() );
8746 execute( TC_lcs_loc_req_for_idle_ms_no_pag_resp() );
8747 execute( TC_cm_service_during_lcs_loc_req() );
8748 execute( TC_ho_during_lcs_loc_req() );
8749 }
Neels Hofmeyrbf037052020-10-28 22:52:02 +00008750
8751 execute( TC_no_msc() );
Harald Welte28d943e2017-11-25 15:00:50 +01008752}
8753
8754}