blob: 2fde8aeb17c53b9c6f7a9aee96cb12f302421820 [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 Hofmeyr9f3e6ac2021-04-08 23:09:24 +020023friend module BSC_Tests_VAMOS;
24
Neels Hofmeyr4f118412020-06-04 15:25:10 +020025import from Misc_Helpers all;
Harald Welte4003d112017-12-09 22:35:39 +010026import from General_Types all;
Harald Welte28d943e2017-11-25 15:00:50 +010027import from Osmocom_Types all;
Harald Welteae026692017-12-09 01:03:01 +010028import from GSM_Types all;
Harald Welte28d943e2017-11-25 15:00:50 +010029import from IPL4asp_Types all;
30
Harald Welte6f521d82017-12-11 19:52:02 +010031import from BSSAP_Types all;
Harald Welte6811d102019-04-14 22:23:14 +020032import from RAN_Adapter all;
Harald Welte47cd0e32020-08-21 12:39:11 +020033import from BSSAP_LE_Adapter all;
34import from BSSAP_LE_CodecPort all;
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +020035import from BSSAP_LE_Types all;
36import from BSSLAP_Types all;
Harald Welteae026692017-12-09 01:03:01 +010037import from BSSAP_CodecPort all;
38import from BSSMAP_Templates all;
Harald Welte28d943e2017-11-25 15:00:50 +010039import from IPA_Emulation all;
Stefan Sperling830dc9d2018-02-12 21:08:28 +010040import from IPA_CodecPort all;
Harald Welteae026692017-12-09 01:03:01 +010041import from IPA_Types all;
Stefan Sperling0796a822018-10-05 13:01:39 +020042import from IPA_Testing all;
Harald Welteae026692017-12-09 01:03:01 +010043import from RSL_Types all;
Harald Welte624f9632017-12-16 19:26:04 +010044import from RSL_Emulation all;
Daniel Willmann191e0d92018-01-17 12:44:35 +010045import from MGCP_Emulation all;
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +010046import from MGCP_Templates all;
47import from MGCP_Types all;
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +020048import from MGCP_CodecPort all;
Harald Welte28d943e2017-11-25 15:00:50 +010049
Harald Welte96c94412017-12-09 03:12:45 +010050import from Osmocom_CTRL_Functions all;
Harald Weltea5d2ab22017-12-09 14:21:42 +010051import from Osmocom_CTRL_Types all;
Harald Welteffe55fc2018-01-17 22:39:54 +010052import from Osmocom_CTRL_Adapter all;
Harald Welte96c94412017-12-09 03:12:45 +010053
Daniel Willmannebdecc02020-08-12 15:30:17 +020054import from StatsD_Types all;
55import from StatsD_CodecPort all;
56import from StatsD_CodecPort_CtrlFunct all;
57import from StatsD_Checker all;
58
Harald Weltebc03c762018-02-12 18:09:38 +010059import from Osmocom_VTY_Functions all;
60import from TELNETasp_PortType all;
61
Harald Welte6f521d82017-12-11 19:52:02 +010062import from MobileL3_CommonIE_Types all;
Harald Weltee3bd6582018-01-31 22:51:25 +010063import from MobileL3_Types all;
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +010064import from MobileL3_RRM_Types all;
Harald Welte6f521d82017-12-11 19:52:02 +010065import from L3_Templates all;
66import from GSM_RR_Types all;
67
Stefan Sperlingc307e682018-06-14 15:15:46 +020068import from SCCP_Templates all;
Neels Hofmeyr4ff93282018-03-12 04:25:35 +010069import from BSSMAP_Templates all;
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +020070import from BSSMAP_LE_Templates all;
Neels Hofmeyr4ff93282018-03-12 04:25:35 +010071
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +010072import from SCCPasp_Types all;
73
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +020074import from GSM_SystemInformation all;
75import from GSM_RestOctets all;
Neels Hofmeyrad132f22020-07-08 02:20:16 +020076import from TCCConversion_Functions all;
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +020077
Neels Hofmeyrbf720202021-10-02 12:58:24 +020078type record of integer integer_list;
79
Harald Welte5d1a2202017-12-13 19:51:29 +010080const integer NUM_BTS := 3;
Neels Hofmeyr5ce3ae42021-08-29 15:32:00 +020081const integer NUM_BTS_CFG := 4; /* we have 4 BTS in the osmo-bsc.cfg (for inter-BSC HO tests) but use only 3 */
Neels Hofmeyrf246a922020-05-13 02:27:10 +020082const integer NUM_MSC := 3;
Harald Welteae026692017-12-09 01:03:01 +010083const float T3101_MAX := 12.0;
Harald Welte28d943e2017-11-25 15:00:50 +010084
Harald Welte799c97b2017-12-14 17:50:30 +010085/* make sure to sync this with the osmo-bts.cfg you're using */
Philipp Maiercb6cc482018-03-26 13:08:00 +020086const integer NUM_TCHH_PER_BTS := 2;
87const integer NUM_TCHF_PER_BTS := 4;
Neels Hofmeyr74083c22020-07-29 00:43:01 +020088const integer NUM_SDCCH_PER_BTS := 3;
Harald Welte799c97b2017-12-14 17:50:30 +010089
Neels Hofmeyrbf720202021-10-02 12:58:24 +020090/* Default Training Sequence Code expected for bts[i]:
91 * BTS 0 has BSIC 10 (and no explicit timeslot training_sequence_code config), so expecting TSC = (BSIC & 7) = 2.
92 * BTS 1 has BSIC 11, TSC = (BSIC & 7) = 3.
93 * BTS 2 has BSIC 12, TSC = (BSIC & 7) = 4.
94 * BTS 2 has BSIC 12, TSC = (BSIC & 7) = 4.
95 */
96const integer_list BTS_TSC := {
97 2,
98 3,
99 4,
100 4
101}
Harald Welte4003d112017-12-09 22:35:39 +0100102
Harald Welte21b46bd2017-12-17 19:46:32 +0100103/* per-BTS state which we keep */
Harald Welte96c94412017-12-09 03:12:45 +0100104type record BTS_State {
Harald Welte21b46bd2017-12-17 19:46:32 +0100105 /* component reference to the IPA_Client component used for RSL */
Harald Weltea5d2ab22017-12-09 14:21:42 +0100106 IPA_Client rsl
Harald Welte96c94412017-12-09 03:12:45 +0100107}
108
Neels Hofmeyr22c3f792020-06-17 02:49:28 +0200109/* Default list of counters for an 'msc' entity. */
110const CounterNameVals counternames_msc_mscpool := {
111 { "mscpool:subscr:new", 0 },
112 { "mscpool:subscr:known", 0 },
113 { "mscpool:subscr:reattach", 0 },
114 { "mscpool:subscr:attach_lost", 0 },
115 { "mscpool:subscr:paged", 0 }
116};
117
Neels Hofmeyrbf037052020-10-28 22:52:02 +0000118/* List of global mscpool counters, not related to a specific 'msc' entity. */
119const CounterNameVals counternames_bsc_mscpool := {
120 { "mscpool:subscr:no_msc", 0 }
121};
122
Neels Hofmeyr12941bd2020-08-29 03:21:26 +0000123/* Default list of counters for 'bsc' and 'bts' entities. */
124const CounterNameVals counternames_bsc_bts_handover := {
125 { "assignment:attempted", 0 },
126 { "assignment:completed", 0 },
127 { "assignment:stopped", 0 },
128 { "assignment:no_channel", 0 },
129 { "assignment:timeout", 0 },
130 { "assignment:failed", 0 },
131 { "assignment:error", 0 },
132
133 { "handover:attempted", 0 },
134 { "handover:completed", 0 },
135 { "handover:stopped", 0 },
136 { "handover:no_channel", 0 },
137 { "handover:timeout", 0 },
138 { "handover:failed", 0 },
139 { "handover:error", 0 },
140
141 { "intra_cell_ho:attempted", 0 },
142 { "intra_cell_ho:completed", 0 },
143 { "intra_cell_ho:stopped", 0 },
144 { "intra_cell_ho:no_channel", 0 },
145 { "intra_cell_ho:timeout", 0 },
146 { "intra_cell_ho:failed", 0 },
147 { "intra_cell_ho:error", 0 },
148
149 { "intra_bsc_ho:attempted", 0 },
150 { "intra_bsc_ho:completed", 0 },
151 { "intra_bsc_ho:stopped", 0 },
152 { "intra_bsc_ho:no_channel", 0 },
153 { "intra_bsc_ho:timeout", 0 },
154 { "intra_bsc_ho:failed", 0 },
155 { "intra_bsc_ho:error", 0 },
156
157 { "interbsc_ho_out:attempted", 0 },
158 { "interbsc_ho_out:completed", 0 },
159 { "interbsc_ho_out:stopped", 0 },
160 { "interbsc_ho_out:timeout", 0 },
161 { "interbsc_ho_out:failed", 0 },
162 { "interbsc_ho_out:error", 0 },
163
164 { "interbsc_ho_in:attempted", 0 },
165 { "interbsc_ho_in:completed", 0 },
166 { "interbsc_ho_in:stopped", 0 },
167 { "interbsc_ho_in:no_channel", 0 },
168 { "interbsc_ho_in:timeout", 0 },
169 { "interbsc_ho_in:failed", 0 },
170 { "interbsc_ho_in:error", 0 }
171};
172
Neels Hofmeyrac432fa2021-11-02 16:45:56 +0100173const CounterNameVals counternames_bts_handover := {
174 { "incoming_intra_bsc_ho:attempted", 0 },
175 { "incoming_intra_bsc_ho:completed", 0 },
176 { "incoming_intra_bsc_ho:stopped", 0 },
177 { "incoming_intra_bsc_ho:no_channel", 0 },
178 { "incoming_intra_bsc_ho:timeout", 0 },
179 { "incoming_intra_bsc_ho:failed", 0 },
180 { "incoming_intra_bsc_ho:error", 0 }
181};
182
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200183/* Set of all System Information received during one RSL port's startup.
184 * Note that some System Information may be sent on RSL, but lacking actual SI data, to indicate that the BTS should not
185 * broadcast that SI type. That will be reflected as 'omit' here.
186 */
187type record SystemInformationConfig {
188 SystemInformationType1 si1 optional,
189 SystemInformationType2 si2 optional,
190 SystemInformationType2bis si2bis optional,
191 SystemInformationType2ter si2ter optional,
Neels Hofmeyrad132f22020-07-08 02:20:16 +0200192 SI2quaterRestOctetsList si2quater optional,
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200193 SystemInformationType3 si3 optional,
194 SystemInformationType4 si4 optional,
Pau Espin Pedrol28652d82021-02-09 20:20:17 +0100195 SystemInformationType13 si13 optional,
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200196 SystemInformationType5 si5 optional,
197 SystemInformationType5bis si5bis optional,
198 SystemInformationType5ter si5ter optional,
199 SystemInformationType6 si6 optional
200};
201
202const SystemInformationConfig SystemInformationConfig_omit := {
203 si1 := omit,
204 si2 := omit,
205 si2bis := omit,
206 si2ter := omit,
207 si2quater := omit,
208 si3 := omit,
209 si4 := omit,
210 si13 := omit,
211 si5 := omit,
212 si5bis := omit,
213 si5ter := omit,
214 si6 := omit
215};
216
217/* tr_EUTRAN_CellDesc with defaults used in BSC_Tests.ttcn */
218template EUTRAN_CellDesc tr_EUTRAN_CellDesc_default(template (present) uint16_t e_arfcn := ?,
219 template uint3_t meas_bw := 3)
220:= tr_EUTRAN_CellDesc(e_arfcn := e_arfcn,
221 meas_bw_presence := '1'B,
222 meas_bw := meas_bw);
223
224/* tr_EUTRAN_NeighbourCells with defaults used in BSC_Tests.ttcn */
Harald Welte65e419a2020-08-21 12:38:33 +0200225template EUTRAN_NeighbourCells tr_EUTRAN_NeighbourCells_default(template (present) EUTRAN_CellDescs cell_desc_list := { tr_EUTRAN_CellDesc_default },
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200226 template uint3_t prio := 3,
227 template (present) uint5_t thresh_high := 20,
228 template uint5_t thresh_low := 10,
229 template uint5_t qrxlevmin := 22)
230:= tr_EUTRAN_NeighbourCells(
231 cell_desc_list := cell_desc_list,
232 prio_presence := '1'B,
233 prio := prio,
234 thresh_high := thresh_high,
235 thresh_low_presence := '1'B,
236 thresh_low := thresh_low,
237 qrxlevmin_presence := '1'B,
238 qrxlevmin := qrxlevmin);
239
240template SystemInformationConfig SystemInformationConfig_default := {
241 si1 := {
242 cell_chan_desc := '8FB38000000000000000000000000000'O,
243 rach_control := {
244 max_retrans := RACH_MAX_RETRANS_7,
245 tx_integer := '1001'B,
246 cell_barr_access := false,
247 re_not_allowed := true,
248 acc := '0000010000000000'B
249 },
250 rest_octets := ?
251 },
252 si2 := {
253 bcch_freq_list := '00000000000000000000000000000000'O,
254 ncc_permitted := '11111111'B,
255 rach_control := {
256 max_retrans := RACH_MAX_RETRANS_7,
257 tx_integer := '1001'B,
258 cell_barr_access := false,
259 re_not_allowed := true,
260 acc := '0000010000000000'B
261 }
262 },
263 si2bis := omit,
264 si2ter := {
265 extd_bcch_freq_list := '8E320000000000000000000000000800'O,
266 rest_octets := ?
267 },
268 si2quater := {
269 tr_SI2quaterRestOctets_EUTRAN( repeated_neigh_cells := { tr_EUTRAN_NeighbourCells_default } )
270 },
271 si3 := {
272 cell_id := 0,
273 lai := {
274 mcc_mnc := '001F01'H,
275 lac := 1
276 },
277 ctrl_chan_desc := {
278 msc_r99 := true,
279 att := true,
280 bs_ag_blks_res := 1,
281 ccch_conf := CCHAN_DESC_1CCCH_COMBINED,
282 si22ind := false,
283 cbq3 := CBQ3_IU_MODE_NOT_SUPPORTED,
284 spare := '00'B,
285 bs_pa_mfrms := 3,
286 t3212 := 30
287 },
288 cell_options := {
289 dn_ind := false,
290 pwrc := false,
291 dtx := MS_SHALL_USE_UL_DTX,
292 radio_link_tout_div4 := 7
293 },
294 cell_sel_par := {
295 cell_resel_hyst_2dB := 2,
296 ms_txpwr_max_cch := 7,
297 acs := '0'B,
298 neci := true,
299 rxlev_access_min := 0
300 },
301 rach_control := {
302 max_retrans := RACH_MAX_RETRANS_7,
303 tx_integer := '1001'B,
304 cell_barr_access := false,
305 re_not_allowed := true,
306 acc := '0000010000000000'B
307 },
308 rest_octets := {
309 sel_params := {
310 presence := '0'B,
311 params := omit
312 },
313 pwr_offset := {
314 presence := '0'B,
315 offset := omit
316 },
317 si_2ter_ind := '1'B,
318 early_cm_ind := '0'B,
319 sched_where := {
320 presence := '0'B,
321 where := omit
322 },
323 gprs_ind := {
324 presence := '1'B,
325 ind := {
326 ra_colour := 0,
327 si13_pos := '0'B
328 }
329 },
330 umts_early_cm_ind := '1'B,
331 si2_quater_ind := {
332 presence := '1'B,
333 ind := '0'B
334 },
335 iu_mode_ind := omit,
336 si21_ind := {
337 presence := '0'B,
338 pos := omit
339 }
340 }
341 },
342 si4 := {
343 lai := {
344 mcc_mnc := '001F01'H,
345 lac := 1
346 },
347 cell_sel_par := {
348 cell_resel_hyst_2dB := 2,
349 ms_txpwr_max_cch := 7,
350 acs := '0'B,
351 neci := true,
352 rxlev_access_min := 0
353 },
354 rach_control := {
355 max_retrans := RACH_MAX_RETRANS_7,
356 tx_integer := '1001'B,
357 cell_barr_access := false,
358 re_not_allowed := true,
359 acc := '0000010000000000'B
360 },
Neels Hofmeyr74083c22020-07-29 00:43:01 +0200361 cbch_chan_desc := {
362 iei := '64'O,
363 v := {
364 chan_nr := {
365 u := {
366 sdcch4 := {
367 tag := '001'B,
368 sub_chan := 2
369 }
370 },
371 tn := 0
372 },
373 tsc := 2,
374 h := false,
375 arfcn := 871,
376 maio_hsn := omit
377 }
378 },
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200379 cbch_mobile_alloc := omit,
380 rest_octets := {
381 sel_params := {
382 presence := '0'B,
383 params := omit
384 },
385 pwr_offset := {
386 presence := '0'B,
387 offset := omit
388 },
389 gprs_ind := {
390 presence := '1'B,
391 ind := {
392 ra_colour := 0,
393 si13_pos := '0'B
394 }
395 },
396 s_presence := '0'B,
397 s := omit
398 }
399 },
Pau Espin Pedrol28652d82021-02-09 20:20:17 +0100400 si13 := {
401 rest_octets := {
402 presence := '1'B,
403 bcch_change_mark := ?,
404 si_change_field := '0000'B,
405 presence2 := '0'B,
406 si13_change_mark := omit,
407 gprs_ma := omit,
408 zero := '0'B, /* PBCCH not present in cell */
409 rac := 0,
410 spgc_ccch_sup := '0'B,
411 priority_access_thr := '110'B,
412 network_control_order := '00'B,
413 gprs_cell_opts := {
414 nmo := '01'B,
415 t3168 := '011'B,
416 t3192 := '010'B,
417 drx_timer_max := '011'B,
418 access_burst_type := '0'B,
419 control_ack_type := '1'B,
420 bs_cv_max := 15,
421 pan_presence := '1'B,
422 pan_dec := 1,
423 pan_inc := 1,
424 pan_max := '111'B,
425 ext_info_presence := ?,
426 ext_info_length := *,
427 ext_info := *
428 },
429 gprs_pwr_ctrl_params := {
430 alpha := 0,
431 t_avg_w := '10000'B,
432 t_avg_t := '10000'B,
433 pc_meas_chan := '0'B,
434 n_avg_i := '1000'B
435 }
436 }
437 },
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200438 si5 := {
439 bcch_freq_list := '10000000000000000000000000000000'O
440 },
441 si5bis := omit,
442 si5ter := {
443 extd_bcch_freq_list := '9E050020000000000000000000000000'O
444 },
445 si6 := {
446 cell_id := 0,
447 lai := {
448 mcc_mnc := '001F01'H,
449 lac := 1
450 },
451 cell_options := {
452 dtx_ext := '1'B,
453 pwrc := false,
454 dtx := '01'B,
455 radio_link_timeout := '0111'B
456 },
457 ncc_permitted := '11111111'B,
458 rest_octets := ?
459 }
460 };
461
462
463/* List of all the System Information received on all RSL ports */
464type record of SystemInformationConfig SystemInformationConfig_list;
465
466function f_sysinfo_dec_raw(inout SystemInformationConfig si, RSL_Message rsl)
467{
468 var RSL_IE_Body sysinfo_type_ie;
469 var RSL_IE_SysinfoType si_type;
470 var octetstring data;
471
472 if (f_rsl_find_ie(rsl, RSL_IE_SYSINFO_TYPE, sysinfo_type_ie) == false) {
473 setverdict(fail, "Cannot find RSL_IE_SYSINFO_TYPE");
474 mtc.stop;
475 }
476 si_type := sysinfo_type_ie.sysinfo_type;
477
478 if (rsl.msg_type == RSL_MT_BCCH_INFO) {
479 var RSL_IE_Body bcch_ie;
480 if (f_rsl_find_ie(rsl, RSL_IE_FULL_BCCH_INFO, bcch_ie)) {
481 data := bcch_ie.other.payload;
482 }
483 } else if (rsl.msg_type == RSL_MT_SACCH_FILL) {
484 var RSL_IE_Body l3_ie;
485 if (f_rsl_find_ie(rsl, RSL_IE_L3_INFO, l3_ie)) {
486 data := l3_ie.l3_info.payload;
487 }
488 } else {
489 setverdict(fail, "Don't understand this System Information message");
490 mtc.stop;
491 }
492
493 var boolean handled := false;
494
495 if (rsl.msg_type == RSL_MT_BCCH_INFO) {
496 handled := true;
497
498 if (si_type == RSL_SYSTEM_INFO_1) {
499 if (not isbound(data)) {
500 si.si1 := omit;
501 } else {
502 si.si1 := dec_SystemInformation(data).payload.si1;
503 }
504 } else if (si_type == RSL_SYSTEM_INFO_2) {
505 if (not isbound(data)) {
506 si.si2 := omit;
507 } else {
508 si.si2 := dec_SystemInformation(data).payload.si2;
509 }
510 } else if (si_type == RSL_SYSTEM_INFO_2bis) {
511 if (not isbound(data)) {
512 si.si2bis := omit;
513 } else {
514 si.si2bis := dec_SystemInformation(data).payload.si2bis;
515 }
516 } else if (si_type == RSL_SYSTEM_INFO_2ter) {
517 if (not isbound(data)) {
518 si.si2ter := omit;
519 } else {
520 si.si2ter := dec_SystemInformation(data).payload.si2ter;
521 }
522 } else if (si_type == RSL_SYSTEM_INFO_2quater) {
523 if (not isbound(data)) {
524 si.si2quater := {};
525 } else {
526 var SystemInformationType2quater decoded := dec_SystemInformation(data).payload.si2quater;
527 /* this is a *record* of SI2quaterRestOctets! (multiplexed) */
528 si.si2quater[decoded.rest_octets.si2quater_index] := decoded.rest_octets;
529 }
530 } else if (si_type == RSL_SYSTEM_INFO_3) {
531 if (not isbound(data)) {
532 si.si3 := omit;
533 } else {
534 si.si3 := dec_SystemInformation(data).payload.si3;
535 }
536 } else if (si_type == RSL_SYSTEM_INFO_4) {
537 if (not isbound(data)) {
538 si.si4 := omit;
539 } else {
540 si.si4 := dec_SystemInformation(data).payload.si4;
541 }
542 } else if (si_type == RSL_SYSTEM_INFO_13) {
543 if (not isbound(data)) {
544 si.si13 := omit;
545 } else {
Pau Espin Pedrol28652d82021-02-09 20:20:17 +0100546 si.si13 := dec_SystemInformation(data).payload.si13;
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200547 }
548 } else {
549 handled := false;
550 }
551 } else if (rsl.msg_type == RSL_MT_SACCH_FILL) {
552 handled := true;
553
554 if (si_type == RSL_SYSTEM_INFO_5) {
555 if (not isbound(data)) {
556 si.si5 := omit;
557 } else {
558 si.si5 := dec_SystemInformation(data).payload.si5;
559 }
560 } else if (si_type == RSL_SYSTEM_INFO_5bis) {
561 if (not isbound(data)) {
562 si.si5bis := omit;
563 } else {
564 si.si5bis := dec_SystemInformation(data).payload.si5bis;
565 }
566 } else if (si_type == RSL_SYSTEM_INFO_5ter) {
567 if (not isbound(data)) {
568 si.si5ter := omit;
569 } else {
570 si.si5ter := dec_SystemInformation(data).payload.si5ter;
571 }
572 } else if (si_type == RSL_SYSTEM_INFO_6) {
573 if (not isbound(data)) {
574 si.si6 := omit;
575 } else {
576 si.si6 := dec_SystemInformation(data).payload.si6;
577 }
578 } else {
579 handled := false;
580 }
581 }
582
583 if (not handled) {
584 setverdict(fail, "Unexpected SI type in ", rsl.msg_type, " message: ", si_type);
585 }
586}
587
Harald Weltea4ca4462018-02-09 00:17:14 +0100588type component test_CT extends CTRL_Adapter_CT {
Harald Welte21b46bd2017-12-17 19:46:32 +0100589 /* Array of per-BTS state */
Harald Welte96c94412017-12-09 03:12:45 +0100590 var BTS_State bts[NUM_BTS];
Harald Welte89ab1912018-02-23 18:56:29 +0100591 /* RSL common Channel Port (for RSL_Emulation) */
592 port RSL_CCHAN_PT RSL_CCHAN[NUM_BTS];
Harald Welte21b46bd2017-12-17 19:46:32 +0100593 /* array of per-BTS RSL test ports */
Harald Welteae026692017-12-09 01:03:01 +0100594 port IPA_RSL_PT IPA_RSL[NUM_BTS];
Stefan Sperling830dc9d2018-02-12 21:08:28 +0100595 port IPA_CODEC_PT IPA; /* Required for compilation of TC_rsl_unknown_unit_id() */
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +0200596 /* CTRL muxed over IPA in SCCPlite conn BSC<->MSC (or BSC-NAT) */
597 port IPA_CTRL_PT SCCPLITE_IPA_CTRL;
Harald Weltea5d2ab22017-12-09 14:21:42 +0100598
Daniel Willmann191e0d92018-01-17 12:44:35 +0100599 var MGCP_Emulation_CT vc_MGCP;
Harald Weltebc03c762018-02-12 18:09:38 +0100600 port TELNETasp_PT BSCVTY;
Daniel Willmann191e0d92018-01-17 12:44:35 +0100601
Daniel Willmannebdecc02020-08-12 15:30:17 +0200602 /* StatsD */
603 var StatsD_Checker_CT vc_STATSD;
604
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200605 var RAN_Adapter g_bssap[NUM_MSC];
Harald Welte47cd0e32020-08-21 12:39:11 +0200606 var BSSAP_LE_Adapter g_bssap_le;
Harald Weltea4ca4462018-02-09 00:17:14 +0100607 /* for old legacy-tests only */
608 port BSSAP_CODEC_PT BSSAP;
Harald Welte47cd0e32020-08-21 12:39:11 +0200609 port BSSAP_LE_CODEC_PT BSSAP_LE;
Harald Weltea4ca4462018-02-09 00:17:14 +0100610
Harald Welte21b46bd2017-12-17 19:46:32 +0100611 /* are we initialized yet */
Harald Welte28d943e2017-11-25 15:00:50 +0100612 var boolean g_initialized := false;
Harald Welte21b46bd2017-12-17 19:46:32 +0100613
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200614 /* Osmux is enabled through VTY */
615 var boolean g_osmux_enabled := false;
616
Pau Espin Pedrolc675b612020-01-09 19:55:40 +0100617 /*Configure T(tias) over VTY, seconds */
618 var integer g_bsc_sccp_timer_ias := 7 * 60;
619 /*Configure T(tiar) over VTY, seconds */
620 var integer g_bsc_sccp_timer_iar := 15 * 60;
621
Neels Hofmeyr4fbad7f2020-06-16 00:30:47 +0200622 /* global test case guard timer (actual timeout value is set in f_init()) */
Harald Welteae026692017-12-09 01:03:01 +0100623 timer T_guard := 30.0;
624
Neels Hofmeyr22c3f792020-06-17 02:49:28 +0200625 var CounterNameValsList g_ctr_msc;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +0000626 var CounterNameValsList g_ctr_bsc;
627 var CounterNameValsList g_ctr_bts;
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200628
629 /* System Information bytes as received during RSL startup, for each RSL[idx]. */
630 var SystemInformationConfig_list g_system_information := {};
Harald Welte28d943e2017-11-25 15:00:50 +0100631}
632
Pau Espin Pedrol0953bf82021-07-09 13:20:19 +0200633type record of charstring phys_chan_configs;
Harald Welte28d943e2017-11-25 15:00:50 +0100634modulepar {
Harald Welte21b46bd2017-12-17 19:46:32 +0100635 /* IP address at which the BSC can be reached */
Harald Welte696ddb62017-12-08 14:01:43 +0100636 charstring mp_bsc_ip := "127.0.0.1";
Stefan Sperling830dc9d2018-02-12 21:08:28 +0100637 /* port number to which to establish the IPA OML connections */
638 integer mp_bsc_oml_port := 3002;
Harald Welte21b46bd2017-12-17 19:46:32 +0100639 /* port number to which to establish the IPA RSL connections */
Harald Welte696ddb62017-12-08 14:01:43 +0100640 integer mp_bsc_rsl_port := 3003;
Harald Welte21b46bd2017-12-17 19:46:32 +0100641 /* port number to which to establish the IPA CTRL connection */
Harald Welte96c94412017-12-09 03:12:45 +0100642 integer mp_bsc_ctrl_port := 4249;
Daniel Willmannebdecc02020-08-12 15:30:17 +0200643 /* port number to which to listen for STATSD metrics */
644 integer mp_bsc_statsd_port := 8125;
Daniel Willmann191e0d92018-01-17 12:44:35 +0100645 /* IP address at which the test binds */
646 charstring mp_test_ip := "127.0.0.1";
Harald Weltea4ca4462018-02-09 00:17:14 +0100647
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200648 RAN_Configurations mp_bssap_cfg := {
649 {
650 transport := BSSAP_TRANSPORT_AoIP,
651 sccp_service_type := "mtp3_itu",
652 sctp_addr := { 23905, "127.0.0.1", 2905, "127.0.0.1" },
653 own_pc := 185, /* 0.23.1 first MSC emulation */
654 own_ssn := 254,
655 peer_pc := 187, /* 0.23.3 osmo-bsc */
656 peer_ssn := 254,
657 sio := '83'O,
Harald Weltecb0cc432020-06-21 19:42:31 +0200658 rctx := 1
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200659 },
660 {
661 transport := BSSAP_TRANSPORT_AoIP,
662 sccp_service_type := "mtp3_itu",
663 sctp_addr := { 23906, "127.0.0.1", 2905, "127.0.0.1" },
664 own_pc := 2, /* 0.0.2 second MSC emulation */
665 own_ssn := 254,
666 peer_pc := 187, /* 0.23.3 osmo-bsc */
667 peer_ssn := 254,
668 sio := '83'O,
669 rctx := 2
670 },
671 {
672 transport := BSSAP_TRANSPORT_AoIP,
673 sccp_service_type := "mtp3_itu",
674 sctp_addr := { 23907, "127.0.0.1", 2905, "127.0.0.1" },
675 own_pc := 3, /* 0.0.3 third MSC emulation */
676 own_ssn := 254,
677 peer_pc := 187, /* 0.23.3 osmo-bsc */
678 peer_ssn := 254,
679 sio := '83'O,
680 rctx := 3
681 }
Harald Weltea4ca4462018-02-09 00:17:14 +0100682 };
Pau Espin Pedrol58cf6822019-05-28 18:11:33 +0200683
Pau Espin Pedrol0953bf82021-07-09 13:20:19 +0200684 /* Must match per BTS config in osmo-bsc.cfg */
685 phys_chan_configs phys_chan_config := {
686 "CCCH+SDCCH4+CBCH",
687 "TCH/F",
688 "TCH/F",
689 "TCH/F",
690 "TCH/F",
Vadim Yanitskiy343c9eb2021-07-16 18:36:01 +0600691 "TCH/H",
Pau Espin Pedrol0953bf82021-07-09 13:20:19 +0200692 "PDCH",
693 "PDCH"
694 };
695
Harald Welte47cd0e32020-08-21 12:39:11 +0200696 BSSAP_LE_Configuration mp_bssap_le_cfg := {
697 sccp_service_type := "mtp3_itu",
698 sctp_addr := { 23908, "127.0.0.1", 2905, "127.0.0.1" },
Neels Hofmeyrac086c12020-09-18 23:46:42 +0200699 own_pc := 190, /* 0.23.6 SMLC emulation */
Harald Welte47cd0e32020-08-21 12:39:11 +0200700 own_ssn := 252, /* SMLC side SSN */
701 peer_pc := 187, /* 0.23.3 osmo-bsc */
702 peer_ssn := 250, /* BSC side SSN */
703 sio := '83'O,
704 rctx := 6
705 };
Neels Hofmeyrcfe44062020-10-15 02:28:08 +0200706 boolean mp_enable_lcs_tests := true;
Harald Welte47cd0e32020-08-21 12:39:11 +0200707
Pau Espin Pedrole076b3f2021-07-20 16:45:57 +0200708 /* Whether to enable dyn TS SDCCH8 tests. Can be dropped completely and enable
709 unconditionally once new version of osmo-bsc is released (current
710 version: 1.7.0) */
711 boolean mp_enable_dyn_sdcch8_test := true;
Pau Espin Pedrol8f30ccd2019-11-01 17:30:57 +0100712 /* Value set in osmo-bsc.cfg "ms max power" */
713 uint8_t mp_exp_ms_power_level := 7;
Harald Weltea4ca4462018-02-09 00:17:14 +0100714}
715
Neels Hofmeyr9f3e6ac2021-04-08 23:09:24 +0200716friend function f_gen_test_hdlr_pars(integer bssap_idx := 0) return TestHdlrParams {
Philipp Maier48604732018-10-09 15:00:37 +0200717
718 var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200719 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Philipp Maier48604732018-10-09 15:00:37 +0200720 pars.aoip := true;
721 } else {
722 pars.aoip := false;
723 }
Pau Espin Pedrol8f30ccd2019-11-01 17:30:57 +0100724 pars.exp_ms_power_level := mp_exp_ms_power_level;
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200725 pars.mscpool.bssap_idx := bssap_idx;
Neels Hofmeyrbf720202021-10-02 12:58:24 +0200726 pars.expect_tsc := BTS_TSC[0];
Neels Hofmeyrb5b7a6e2021-06-04 19:03:45 +0200727
Philipp Maier48604732018-10-09 15:00:37 +0200728 return pars;
729}
730
Neels Hofmeyr22c3f792020-06-17 02:49:28 +0200731/* Convenience functions for rate counters using g_ctr_msc. */
732
733private function f_ctrs_msc_init(integer mscs_count := NUM_MSC, CounterNameVals counternames := counternames_msc_mscpool) runs on test_CT {
734 g_ctr_msc := f_counter_name_vals_get_n(IPA_CTRL, "msc", mscs_count, counternames);
735 log("initial msc rate counters: ", g_ctr_msc);
736}
737
738private function f_ctrs_msc_add(integer msc_nr, charstring countername, integer val := 1) runs on test_CT {
Neels Hofmeyr9656e922020-06-30 01:27:01 +0200739 f_counter_name_vals_list_add(g_ctr_msc, msc_nr, countername, val);
Neels Hofmeyr22c3f792020-06-17 02:49:28 +0200740}
741
742/* f_ctrs_msc_init();
743 * f_do_thing(on_msc := 0);
744 * f_do_thing(on_msc := 0);
745 * f_do_other(on_msc := 1);
746 * f_ctrs_msc_add(0, "thing", 2);
747 * f_ctrs_msc_add(1, "other");
748 * f_ctrs_msc_verify();
749 */
750private function f_ctrs_msc_verify() runs on test_CT {
751 log("verifying msc rate counters: ", g_ctr_msc);
752 f_counter_name_vals_expect_n(IPA_CTRL, "msc", g_ctr_msc);
753}
754
755/* convenience: f_ctrs_msc_add() and f_ctrs_msc_verify() in one call.
756 * f_ctrs_msc_init();
757 * f_do_thing(on_msc := 0);
758 * f_do_thing(on_msc := 0);
759 * f_do_thing(on_msc := 0);
760 * f_ctrs_msc_expect(0, "thing", 3);
761 */
762private function f_ctrs_msc_expect(integer msc_nr, charstring countername, integer val := 1) runs on test_CT {
763 f_ctrs_msc_add(msc_nr, countername, val);
764 f_ctrs_msc_verify();
765}
766
Neels Hofmeyr12941bd2020-08-29 03:21:26 +0000767/* Convenience functions for rate counters using g_ctr_bts, always also including g_ctr_bsc. */
768
769private function f_ctrs_bsc_and_bts_init(integer bts_count := NUM_BTS, CounterNameVals counternames := counternames_bsc_bts_handover) runs on test_CT {
770 g_ctr_bts := f_counter_name_vals_get_n(IPA_CTRL, "bts", bts_count, counternames);
771 log("initial bts rate counters: ", g_ctr_bts);
772 f_ctrs_bsc_init(counternames);
773}
774
Neels Hofmeyrac432fa2021-11-02 16:45:56 +0100775private function f_ctrs_bsc_and_bts_handover_init(integer bts_count := NUM_BTS) runs on test_CT {
776 var CounterNameVals bts_names := counternames_bsc_bts_handover & counternames_bts_handover;
777 g_ctr_bts := f_counter_name_vals_get_n(IPA_CTRL, "bts", bts_count, bts_names);
778 log("initial bts rate counters: ", g_ctr_bts);
779 f_ctrs_bsc_init(counternames_bsc_bts_handover);
780}
781
782private function f_ctrs_bts_add(integer bts_nr, charstring countername, integer val := 1) runs on test_CT {
Neels Hofmeyr12941bd2020-08-29 03:21:26 +0000783 f_counter_name_vals_list_add(g_ctr_bts, bts_nr, countername, val);
Neels Hofmeyrac432fa2021-11-02 16:45:56 +0100784}
785
786private function f_ctrs_bsc_and_bts_add(integer bts_nr, charstring countername, integer val := 1) runs on test_CT {
787 f_ctrs_bts_add(bts_nr, countername, val);
Neels Hofmeyr12941bd2020-08-29 03:21:26 +0000788 f_ctrs_bsc_add(countername, val);
789}
790
791/* f_ctrs_bsc_and_bts_init();
792 * f_do_thing(on_bts := 0);
793 * f_do_thing(on_bts := 0);
794 * f_do_other(on_bts := 1);
795 * f_ctrs_bsc_and_bts_add(0, "thing", 2);
796 * f_ctrs_bsc_and_bts_add(1, "other");
797 * f_ctrs_bsc_and_bts_verify();
798 */
799private function f_ctrs_bsc_and_bts_verify() runs on test_CT {
800 f_counter_name_vals_expect_n(IPA_CTRL, "bts", g_ctr_bts);
801 f_ctrs_bsc_verify();
802}
803
804/* convenience: f_ctrs_bsc_and_bts_add() and f_ctrs_bsc_and_bts_verify() in one call.
805 * f_ctrs_bsc_and_bts_init();
806 * f_do_thing(on_bts := 0);
807 * f_do_thing(on_bts := 0);
808 * f_do_thing(on_bts := 0);
809 * f_ctrs_bsc_and_bts_expect(0, "thing", 3);
810 */
811private function f_ctrs_bsc_and_bts_expect(integer bts_nr, charstring countername, integer val := 1) runs on test_CT {
812 f_ctrs_bsc_and_bts_add(bts_nr, countername, val);
813 f_ctrs_bsc_and_bts_verify();
814}
815
816
817/* Convenience functions for rate counters using g_ctr_bsc. */
818
819private function f_ctrs_bsc_init(CounterNameVals counternames := counternames_bsc_bts_handover) runs on test_CT {
820 g_ctr_bsc := f_counter_name_vals_get_n(IPA_CTRL, "bsc", 1, counternames);
821 log("initial bsc rate counters: ", g_ctr_bsc);
822}
823
824private function f_ctrs_bsc_add(charstring countername, integer val := 1) runs on test_CT {
825 f_counter_name_vals_list_add(g_ctr_bsc, 0, countername, val);
826}
827
828/* f_ctrs_bsc_init();
829 * f_do_thing();
830 * f_do_thing();
831 * f_do_other();
832 * f_ctrs_bsc_add("thing", 2);
833 * f_ctrs_bsc_add("other");
834 * f_ctrs_bsc_verify();
835 */
836private function f_ctrs_bsc_verify() runs on test_CT {
837 f_counter_name_vals_expect_n(IPA_CTRL, "bsc", g_ctr_bsc);
838}
839
840/* convenience: f_ctrs_bsc_add() and f_ctrs_bsc_verify() in one call.
841 * f_ctrs_bsc_init();
842 * f_do_thing();
843 * f_ctrs_bsc_expect("thing", 1);
844 */
845private function f_ctrs_bsc_expect(charstring countername, integer val := 1) runs on test_CT {
846 f_ctrs_bsc_add(countername, val);
847 f_ctrs_bsc_verify();
848}
849
Neels Hofmeyr22c3f792020-06-17 02:49:28 +0200850
Neels Hofmeyr9f3e6ac2021-04-08 23:09:24 +0200851friend function f_shutdown_helper() runs on test_CT {
Daniel Willmann637ef6c2018-07-25 10:49:09 +0200852 all component.stop;
Philipp Maier282ca4b2018-02-27 17:17:00 +0100853 setverdict(pass);
Daniel Willmannafce8662018-07-06 23:11:32 +0200854 mtc.stop;
Philipp Maier282ca4b2018-02-27 17:17:00 +0100855}
856
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200857private function f_legacy_bssap_reset(integer bssap_idx := 0) runs on test_CT {
Harald Weltea4ca4462018-02-09 00:17:14 +0100858 var BSSAP_N_UNITDATA_ind ud_ind;
Pau Espin Pedrol24c05992020-09-01 12:54:12 +0200859 var boolean reset_received := false;
Harald Weltea4ca4462018-02-09 00:17:14 +0100860 timer T := 5.0;
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200861 BSSAP.send(ts_BSSAP_UNITDATA_req(g_bssap[bssap_idx].sccp_addr_peer, g_bssap[bssap_idx].sccp_addr_own,
862 ts_BSSMAP_Reset(0, g_osmux_enabled)));
Harald Weltea4ca4462018-02-09 00:17:14 +0100863 T.start;
864 alt {
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200865 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(g_bssap[bssap_idx].sccp_addr_own, g_bssap[bssap_idx].sccp_addr_peer,
866 tr_BSSMAP_ResetAck(g_osmux_enabled))) {
Neels Hofmeyr4f5d7be2020-10-16 16:28:16 +0200867 log("BSSMAP: Received RESET-ACK in response to RESET, we're ready to go!");
Harald Weltea4ca4462018-02-09 00:17:14 +0100868 }
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200869 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset(g_osmux_enabled))) -> value ud_ind {
Neels Hofmeyr4f5d7be2020-10-16 16:28:16 +0200870 log("BSSMAP: Respoding to inbound RESET with RESET-ACK");
Harald Weltea4ca4462018-02-09 00:17:14 +0100871 BSSAP.send(ts_BSSAP_UNITDATA_req(ud_ind.callingAddress, ud_ind.calledAddress,
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200872 ts_BSSMAP_ResetAck(g_osmux_enabled)));
Pau Espin Pedrol24c05992020-09-01 12:54:12 +0200873 reset_received := true;
Harald Weltea4ca4462018-02-09 00:17:14 +0100874 repeat;
875 }
876 [] BSSAP.receive { repeat; }
Pau Espin Pedrol24c05992020-09-01 12:54:12 +0200877 [] T.timeout {
Neels Hofmeyr4f5d7be2020-10-16 16:28:16 +0200878 log("BSSMAP: Timeout waiting for RESET-ACK after sending RESET");
Pau Espin Pedrol24c05992020-09-01 12:54:12 +0200879 /* If we received a RESET after ours was sent, it
880 may be a race condition where the other peer beacame
881 available after we sent it, but we are in a desired
882 state anyway, so go forward. */
883 if (not reset_received) {
884 setverdict(fail);
885 }
886 }
Harald Weltea4ca4462018-02-09 00:17:14 +0100887 }
Harald Welte28d943e2017-11-25 15:00:50 +0100888}
889
Harald Welteae026692017-12-09 01:03:01 +0100890type record IPA_Client {
Harald Welte21b46bd2017-12-17 19:46:32 +0100891 /* IPA Emulation component reference */
Harald Welteae026692017-12-09 01:03:01 +0100892 IPA_Emulation_CT vc_IPA,
Harald Welte21b46bd2017-12-17 19:46:32 +0100893 /* Unit-ID and other CCM parameters to use for IPA client emulation */
Harald Welteae026692017-12-09 01:03:01 +0100894 IPA_CCM_Parameters ccm_pars,
Harald Welte21b46bd2017-12-17 19:46:32 +0100895 /* String identifier for this IPA Client */
Harald Welte624f9632017-12-16 19:26:04 +0100896 charstring id,
Harald Welte21b46bd2017-12-17 19:46:32 +0100897 /* Associated RSL Emulation Component (if any). Only used in "Handler mode" */
Harald Welte624f9632017-12-16 19:26:04 +0100898 RSL_Emulation_CT vc_RSL optional
Harald Welte28d943e2017-11-25 15:00:50 +0100899}
900
Harald Welte21b46bd2017-12-17 19:46:32 +0100901/*! Start the IPA/RSL related bits for one IPA_Client.
902 * \param clnt IPA_Client for which to establish
903 * \param bsc_host IP address / hostname of the BSC
904 * \param bsc_port TCP port number of the BSC
905 * \param i number identifying this BTS
906 * \param handler_mode Start an RSL_Emulation_CT component (true) or not (false) */
Harald Welte624f9632017-12-16 19:26:04 +0100907function f_ipa_rsl_start(inout IPA_Client clnt, charstring bsc_host, PortNumber bsc_port, integer i,
908 boolean handler_mode := false)
Harald Welte28d943e2017-11-25 15:00:50 +0100909runs on test_CT {
Harald Welteae026692017-12-09 01:03:01 +0100910 timer T := 10.0;
911
Harald Welte96c94412017-12-09 03:12:45 +0100912 clnt.id := "IPA" & int2str(i) & "-RSL";
Harald Welteae026692017-12-09 01:03:01 +0100913 clnt.vc_IPA := IPA_Emulation_CT.create(clnt.id & "-IPA");
914 clnt.ccm_pars := c_IPA_default_ccm_pars;
915 clnt.ccm_pars.name := "Osmocom TTCN-3 BTS Simulator";
916 clnt.ccm_pars.unit_id := int2str(1234+i) & "/0/0";
Harald Welte624f9632017-12-16 19:26:04 +0100917 if (handler_mode) {
918 clnt.vc_RSL := RSL_Emulation_CT.create(clnt.id & "-RSL");
Harald Welte89ab1912018-02-23 18:56:29 +0100919 connect(clnt.vc_RSL:CCHAN_PT, self:RSL_CCHAN[i]);
Harald Welte624f9632017-12-16 19:26:04 +0100920 }
Harald Welteae026692017-12-09 01:03:01 +0100921
922 map(clnt.vc_IPA:IPA_PORT, system:IPA_CODEC_PT);
Harald Welte624f9632017-12-16 19:26:04 +0100923 if (handler_mode) {
924 connect(clnt.vc_IPA:IPA_RSL_PORT, clnt.vc_RSL:IPA_PT);
925 } else {
926 connect(clnt.vc_IPA:IPA_RSL_PORT, self:IPA_RSL[i]);
927 }
Harald Welteae026692017-12-09 01:03:01 +0100928
Harald Welte5d1a2202017-12-13 19:51:29 +0100929 clnt.vc_IPA.start(IPA_Emulation.main_client(bsc_host, bsc_port, "", 10000+i, clnt.ccm_pars));
Harald Welte624f9632017-12-16 19:26:04 +0100930 if (handler_mode) {
931 clnt.vc_RSL.start(RSL_Emulation.main());
932 return;
933 }
Harald Welteae026692017-12-09 01:03:01 +0100934
935 /* wait for IPA RSL link to connect and send ID ACK */
936 T.start;
937 alt {
Vadim Yanitskiya2afacc2020-05-18 21:16:19 +0700938 [] IPA_RSL[i].receive(tr_ASP_IPA_EV(ASP_IPA_EVENT_ID_ACK)) {
Harald Welteae026692017-12-09 01:03:01 +0100939 T.stop;
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +0700940 IPA_RSL[i].send(ts_ASP_RSL_UD(ts_RSL_PAGING_LOAD_IND(23)));
Harald Welteae026692017-12-09 01:03:01 +0100941 }
Harald Welte60e823a2017-12-10 14:10:59 +0100942 [] IPA_RSL[i].receive(ASP_IPA_Event:?) { repeat }
Harald Welteae026692017-12-09 01:03:01 +0100943 [] IPA_RSL[i].receive { repeat }
944 [] T.timeout {
Harald Welte96c94412017-12-09 03:12:45 +0100945 setverdict(fail, "Timeout RSL waiting for ASP_IPA_EVENT_ID_ACK");
Daniel Willmannafce8662018-07-06 23:11:32 +0200946 mtc.stop;
Harald Welteae026692017-12-09 01:03:01 +0100947 }
948 }
949}
950
Harald Welte12055472018-03-17 20:10:08 +0100951function f_ipa_rsl_stop(inout IPA_Client clnt) runs on test_CT {
952 if (not isbound(clnt) or not isbound(clnt.vc_IPA)) {
953 return;
954 }
955 clnt.vc_IPA.stop;
956 if (isbound(clnt.vc_RSL)) {
957 clnt.vc_RSL.stop;
958 }
959}
960
Harald Welte21b46bd2017-12-17 19:46:32 +0100961/* Wait for the OML connection to be brought up by the external osmo-bts-omldummy */
Harald Weltea5d2ab22017-12-09 14:21:42 +0100962function f_wait_oml(integer bts_nr, charstring status, float secs_max) runs on test_CT {
963 timer T := secs_max;
964 T.start;
965 while (true) {
966 if (f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-connection-state") == status) {
967 T.stop;
Harald Weltebd868bd2017-12-10 18:28:40 +0100968 /* the 'degraded' state exists from OML connection time, and we have to wait
969 * until all MO's are initialized */
970 T.start(1.0);
971 T.timeout;
Harald Weltea5d2ab22017-12-09 14:21:42 +0100972 return;
973 }
Harald Weltef0d6ac62017-12-17 17:02:21 +0100974 f_sleep(0.1);
Harald Weltea5d2ab22017-12-09 14:21:42 +0100975 if (not T.running) {
Max99253902018-11-16 17:57:39 +0100976 setverdict(fail, "Timeout waiting for BTS" & int2str(bts_nr) & " oml-connection-state ", status);
Daniel Willmannafce8662018-07-06 23:11:32 +0200977 mtc.stop;
Harald Weltea5d2ab22017-12-09 14:21:42 +0100978 }
979 }
980}
981
Harald Welte21b46bd2017-12-17 19:46:32 +0100982/* global altstep for global guard timer; also takes care of responding RESET witH RESET-ACK */
Harald Welteae026692017-12-09 01:03:01 +0100983altstep as_Tguard() runs on test_CT {
Harald Welte60e823a2017-12-10 14:10:59 +0100984 var BSSAP_N_UNITDATA_ind ud_ind;
Neels Hofmeyrcc3f76a2018-03-12 01:43:25 +0100985 [] T_guard.timeout {
986 setverdict(fail, "Timeout of T_guard");
Daniel Willmannafce8662018-07-06 23:11:32 +0200987 mtc.stop;
Neels Hofmeyrcc3f76a2018-03-12 01:43:25 +0100988 }
Harald Welte60e823a2017-12-10 14:10:59 +0100989 /* always respond with RESET ACK to RESET */
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200990 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset(g_osmux_enabled))) -> value ud_ind {
Harald Welte60e823a2017-12-10 14:10:59 +0100991 BSSAP.send(ts_BSSAP_UNITDATA_req(ud_ind.callingAddress, ud_ind.calledAddress,
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200992 ts_BSSMAP_ResetAck(g_osmux_enabled)));
Harald Welte69c1c262017-12-13 21:02:08 +0100993 repeat;
Harald Welte60e823a2017-12-10 14:10:59 +0100994 }
Harald Welte28d943e2017-11-25 15:00:50 +0100995}
996
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +0100997altstep no_bssmap_reset() runs on test_CT {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200998 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset(g_osmux_enabled))) {
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +0100999 setverdict(fail, "unexpected BSSMAP Reset");
Daniel Willmannafce8662018-07-06 23:11:32 +02001000 mtc.stop;
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01001001 }
1002}
1003
Daniel Willmann191e0d92018-01-17 12:44:35 +01001004function f_init_mgcp(charstring id) runs on test_CT {
1005 id := id & "-MGCP";
1006
1007 var MGCPOps ops := {
1008 create_cb := refers(MGCP_Emulation.ExpectedCreateCallback),
1009 unitdata_cb := refers(MGCP_Emulation.DummyUnitdataCallback)
1010 };
1011 var MGCP_conn_parameters mgcp_pars := {
1012 callagent_ip := mp_bsc_ip,
Harald Welte9e4273e2018-01-29 22:01:22 +01001013 callagent_udp_port := -1,
Daniel Willmann191e0d92018-01-17 12:44:35 +01001014 mgw_ip := mp_test_ip,
Pau Espin Pedrol1a026a52019-06-18 17:21:52 +02001015 mgw_udp_port := 2427,
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02001016 /* Enable it for SCCPlite, since we have 2 MGCP sockets towards MGW (UDP one +
1017 the on with MGCP over IPA forwarded from MSC one) */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001018 multi_conn_mode := (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_SCCPlite_SERVER)
Daniel Willmann191e0d92018-01-17 12:44:35 +01001019 };
1020
1021 vc_MGCP := MGCP_Emulation_CT.create(id);
1022 vc_MGCP.start(MGCP_Emulation.main(ops, mgcp_pars, id));
1023}
1024
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001025/* Enable or disable (current default) Osmux. When enabling, BSSMAP Reset
1026 * contains extra IE (OsmuxSupport) and osmo-bsc will handle AssignReq with
1027 * OsmuxCID IE.
1028 */
1029private function f_vty_allow_osmux(boolean allow) runs on test_CT {
1030 f_vty_enter_cfg_msc(BSCVTY, 0);
1031 if (allow) {
1032 f_vty_transceive(BSCVTY, "osmux on");
1033 } else {
1034 f_vty_transceive(BSCVTY, "osmux off");
1035 }
1036 f_vty_transceive(BSCVTY, "exit");
1037 f_vty_transceive(BSCVTY, "exit");
1038 g_osmux_enabled := allow;
1039}
1040
Max2253c0b2018-11-06 19:28:05 +01001041function f_init_vty(charstring id := "foo") runs on test_CT {
Harald Welte94e0c342018-04-07 11:33:23 +02001042 if (BSCVTY.checkstate("Mapped")) {
1043 /* skip initialization if already executed once */
1044 return;
1045 }
Harald Weltebc03c762018-02-12 18:09:38 +01001046 map(self:BSCVTY, system:BSCVTY);
1047 f_vty_set_prompts(BSCVTY);
1048 f_vty_transceive(BSCVTY, "enable");
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01001049 f_cs7_inst_0_cfg(BSCVTY, {"sccp-timer ias " & int2str(g_bsc_sccp_timer_ias),
1050 "sccp-timer iar " & int2str(g_bsc_sccp_timer_iar)});
Harald Weltebc03c762018-02-12 18:09:38 +01001051}
1052
Neels Hofmeyr9f3e6ac2021-04-08 23:09:24 +02001053friend function f_logp(TELNETasp_PT pt, charstring log_msg)
Neels Hofmeyr4f118412020-06-04 15:25:10 +02001054{
1055 // log on TTCN3 log output
1056 log(log_msg);
1057 // log in stderr log
Neels Hofmeyr767548a2020-08-09 20:26:07 +00001058 f_vty_transceive(pt, "logp lglobal notice TTCN3 f_logp(): " & log_msg);
Neels Hofmeyr4f118412020-06-04 15:25:10 +02001059}
1060
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02001061private function f_sysinfo_seen(integer rsl_idx, RSL_Message rsl) runs on test_CT
1062{
1063 if (rsl_idx >= lengthof(g_system_information)) {
1064 g_system_information[rsl_idx] := SystemInformationConfig_omit
1065 }
1066 f_sysinfo_dec_raw(g_system_information[rsl_idx], rsl);
1067}
1068
1069altstep as_catch_RSL_sysinfo(integer rsl_idx) runs on test_CT {
1070 var ASP_RSL_Unitdata rx_rsl_ud;
1071
1072 /* For handler_mode := false, receiving the RSL bootstrap messages directly on IPA_RSL */
1073 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_NO_BCCH_INFO)) -> value rx_rsl_ud {
1074 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1075 repeat;
1076 }
1077 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_BCCH_INFO)) -> value rx_rsl_ud {
1078 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1079 repeat;
1080 }
1081 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_NO_SACCH_FILL)) -> value rx_rsl_ud {
1082 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1083 repeat;
1084 }
1085 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_SACCH_FILL)) -> value rx_rsl_ud {
1086 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1087 repeat;
1088 }
1089
1090 /* For handler_mode := true, receiving the RSL bootstrap messages via RSL_Emulation */
1091 [] RSL_CCHAN[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_NO_BCCH_INFO)) -> value rx_rsl_ud {
1092 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1093 repeat;
1094 }
1095 [] RSL_CCHAN[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_BCCH_INFO)) -> value rx_rsl_ud {
1096 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1097 repeat;
1098 }
1099 [] RSL_CCHAN[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_NO_SACCH_FILL)) -> value rx_rsl_ud {
1100 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1101 repeat;
1102 }
1103 [] RSL_CCHAN[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_SACCH_FILL)) -> value rx_rsl_ud {
1104 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1105 repeat;
1106 }
1107}
1108
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001109/* TODO: use BooleanList from COMMON/src/General_Types.ttcn */
1110private type record of boolean my_BooleanList;
1111
1112private function f_vty_msc_allow_attach(TELNETasp_PT pt, my_BooleanList allow_attach_list)
1113{
Neels Hofmeyr8f576712020-08-12 22:49:53 +00001114 var charstring config := f_vty_transceive_ret(pt, "show running-config");
1115
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001116 for (var integer msc_nr := 0; msc_nr < sizeof(allow_attach_list); msc_nr := msc_nr+1) {
Neels Hofmeyr8f576712020-08-12 22:49:53 +00001117 if (f_strstr(config, "\nmsc " & int2str(msc_nr) & "\n") < 0) {
1118 /* There is no 'msc N' for this msc_nr in the running config, so don't create an empty msc by
1119 * stepping into that config node. */
1120 log("msc ", msc_nr, " is not configured, skipping");
1121 continue;
1122 }
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001123 f_vty_enter_cfg_msc(pt, msc_nr);
1124 if (allow_attach_list[msc_nr]) {
1125 /* strict := false: ignore if osmo-bsc does not support this config option (latest build) */
1126 f_vty_transceive(pt, "allow-attach", strict := false);
1127 } else {
1128 f_vty_transceive(pt, "no allow-attach", strict := false);
1129 }
1130 f_vty_transceive(pt, "exit");
1131 f_vty_transceive(pt, "exit");
1132 }
1133}
1134
Harald Welte21b46bd2017-12-17 19:46:32 +01001135/* global initialization function
1136 * \param nr_bts Number of BTSs we should start/bring up
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001137 * \param handler_mode Start an RSL_Emulation_CT component (true) or not (false).
1138 * \param nr_msc Number of virtual MSCs to bring up to connect to osmo-bsc.
1139 */
1140function f_init(integer nr_bts := NUM_BTS, boolean handler_mode := false, boolean allow_osmux := false,
Neels Hofmeyr4fbad7f2020-06-16 00:30:47 +02001141 integer nr_msc := 1, float guard_timeout := 30.0) runs on test_CT {
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001142 var integer bssap_idx;
Harald Welte28d943e2017-11-25 15:00:50 +01001143
Harald Welteae026692017-12-09 01:03:01 +01001144 if (g_initialized) {
1145 return;
Harald Welte28d943e2017-11-25 15:00:50 +01001146 }
Harald Welteae026692017-12-09 01:03:01 +01001147 g_initialized := true;
1148
Neels Hofmeyr4fbad7f2020-06-16 00:30:47 +02001149 T_guard.start(guard_timeout);
Daniel Willmanne68f9272018-11-27 15:15:28 +01001150 activate(as_Tguard());
1151
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001152 f_init_vty("VirtMSC");
Pau Espin Pedrol23510fb2021-07-20 17:00:38 +02001153 f_vty_allow_osmux(allow_osmux);
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001154
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001155 var my_BooleanList allow_attach := { false, false, false };
Daniel Willmannebdecc02020-08-12 15:30:17 +02001156 f_init_statsd("VirtMSC", vc_STATSD, mp_test_ip, mp_bsc_statsd_port);
1157
Neels Hofmeyr9db8e0e2021-08-23 20:45:58 +02001158 /* Make sure each MSC's internal state is "DISCONNECTED" at first */
1159 for (bssap_idx := 0; bssap_idx < NUM_MSC; bssap_idx := bssap_idx+1) {
1160 f_vty_transceive(BSCVTY, "msc " & int2str(bssap_idx) & " bssmap reset", strict := false);
1161 }
1162
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001163 for (bssap_idx := 0; bssap_idx < nr_msc; bssap_idx := bssap_idx+1) {
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001164 allow_attach[bssap_idx] := true;
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001165 /* Call a function of our 'parent component' RAN_Adapter_CT to start the
1166 * MSC-side BSSAP emulation */
1167 if (handler_mode) {
1168 var RanOps ranops := MSC_RanOps;
1169 ranops.use_osmux := g_osmux_enabled;
1170 f_ran_adapter_init(g_bssap[bssap_idx], mp_bssap_cfg[bssap_idx], "VirtMSC", ranops);
1171 connect(self:SCCPLITE_IPA_CTRL, g_bssap[bssap_idx].vc_RAN:CTRL_CLIENT);
1172 f_ran_adapter_start(g_bssap[bssap_idx]);
1173 } else {
1174 f_ran_adapter_init(g_bssap[bssap_idx], mp_bssap_cfg[bssap_idx], "VirtMSC", omit);
1175 connect(self:BSSAP, g_bssap[bssap_idx].vc_SCCP:SCCP_SP_PORT);
1176 f_ran_adapter_start(g_bssap[bssap_idx]);
1177 f_legacy_bssap_reset();
1178 }
Harald Welte67089ee2018-01-17 22:19:03 +01001179 }
Harald Welted5833a82018-05-27 16:52:56 +02001180
Neels Hofmeyrcfe44062020-10-15 02:28:08 +02001181 if (mp_enable_lcs_tests) {
1182 if (handler_mode) {
1183 f_bssap_le_adapter_init(g_bssap_le, mp_bssap_le_cfg, "VirtSMLC", SMLC_BssapLeOps);
1184 } else {
1185 f_bssap_le_adapter_init(g_bssap_le, mp_bssap_le_cfg, "VirtSMLC", omit);
1186 connect(self:BSSAP_LE, g_bssap_le.vc_SCCP:SCCP_SP_PORT);
1187 }
1188 f_bssap_le_adapter_start(g_bssap_le);
Harald Welte47cd0e32020-08-21 12:39:11 +02001189 }
Harald Welte47cd0e32020-08-21 12:39:11 +02001190
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001191 /* start the test with exactly all enabled MSCs allowed to attach */
1192 f_vty_msc_allow_attach(BSCVTY, allow_attach);
1193
Pau Espin Pedrol9a5b8ff2021-01-04 19:01:31 +01001194 f_ipa_ctrl_start_client(mp_bsc_ip, mp_bsc_ctrl_port);
Harald Welte28d943e2017-11-25 15:00:50 +01001195
Daniel Willmann191e0d92018-01-17 12:44:35 +01001196 f_init_mgcp("VirtMSC");
1197
Neels Hofmeyr0b7365b2020-07-04 00:52:34 +02001198 for (var integer i := 0; i < nr_bts; i := i+1) {
1199 f_init_bts(i, handler_mode);
Harald Welte696ddb62017-12-08 14:01:43 +01001200 }
Neels Hofmeyr0b7365b2020-07-04 00:52:34 +02001201}
Harald Welte696ddb62017-12-08 14:01:43 +01001202
Neels Hofmeyr0b7365b2020-07-04 00:52:34 +02001203function f_init_bts(integer bts_idx := 0, boolean handler_mode := false)
1204runs on test_CT {
1205 /* wait until osmo-bts-omldummy has respawned */
1206 f_wait_oml(bts_idx, "degraded", 5.0);
1207
1208 /* start RSL connection */
1209 f_ipa_rsl_start(bts[bts_idx].rsl, mp_bsc_ip, mp_bsc_rsl_port, bts_idx, handler_mode);
1210 /* wait until BSC tells us "connected" */
1211 f_wait_oml(bts_idx, "connected", 5.0);
Harald Welte28d943e2017-11-25 15:00:50 +01001212}
1213
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02001214function f_init_bts_and_check_sysinfo(integer bts_idx := 0, boolean handler_mode := false,
1215 template SystemInformationConfig expect_si)
1216runs on test_CT {
1217 var default sysinfo := activate(as_catch_RSL_sysinfo(bts_idx));
1218
1219 f_init_bts(bts_idx, handler_mode);
1220
1221 /* Give some time to (hopefully/most likely) collect all system informations from RSL startup.
1222 * We could stop as soon as all expected SI are received, but then we might miss SI that we don't expect and
1223 * that might be sent afterwards. So rather give a generous timeout and be quite sure to catch all SI.
1224 */
1225 f_sleep(5.0);
1226 log("RSL ", bts_idx, " SYSTEM INFORMATION: ", g_system_information[bts_idx]);
1227
1228 deactivate(sysinfo);
1229
1230 if (match(g_system_information[bts_idx], expect_si)) {
1231 setverdict(pass);
1232 } else {
1233 log("RSL ", bts_idx, ": EXPECTED SI: ", expect_si);
1234 log("RSL ", bts_idx, ": GOT SI: ", g_system_information[bts_idx]);
1235 setverdict(fail, "received SI does not match expectations");
1236 return;
1237 }
1238}
1239
Maxd4e56962018-10-31 19:08:25 +01001240/* expect to receive a RSL message matching a specified template on a given BTS / stream */
Harald Welte65e419a2020-08-21 12:38:33 +02001241function 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 +01001242runs on test_CT return RSL_Message {
1243 var ASP_RSL_Unitdata rx_rsl_ud;
1244 timer T := t_secs;
1245
1246 T.start;
1247 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001248 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(t_rx, sid)) -> value rx_rsl_ud {
Harald Welteae026692017-12-09 01:03:01 +01001249 T.stop;
1250 }
1251 [] IPA_RSL[bts_nr].receive { repeat; }
Harald Welteb2917702017-12-10 15:48:52 +01001252 [] T.timeout {
1253 setverdict(fail, "Timeout expecting ", t_rx);
Daniel Willmannafce8662018-07-06 23:11:32 +02001254 mtc.stop;
Harald Welteb2917702017-12-10 15:48:52 +01001255 }
Harald Welteae026692017-12-09 01:03:01 +01001256 }
1257 return rx_rsl_ud.rsl;
1258}
1259
Harald Welte21b46bd2017-12-17 19:46:32 +01001260/* helper function to transmit RSL on a given BTS/stream */
Harald Welte65e419a2020-08-21 12:38:33 +02001261function 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 +01001262runs on test_CT {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001263 IPA_RSL[bts_nr].send(ts_ASP_RSL_UD(t_tx, sid));
Harald Welteae026692017-12-09 01:03:01 +01001264}
1265
1266
Harald Welte4003d112017-12-09 22:35:39 +01001267/* verify we get a CHAN_ACT after CHAN RQD */
Harald Welteae026692017-12-09 01:03:01 +01001268testcase TC_chan_act_noreply() runs on test_CT {
1269 var BSSAP_N_UNITDATA_ind ud_ind;
Harald Welte930d0a72018-03-22 22:08:40 +01001270 var RSL_Message rsl_unused;
Harald Welte28d943e2017-11-25 15:00:50 +01001271
Harald Welte89d42e82017-12-17 16:42:41 +01001272 f_init(1);
Harald Welte28d943e2017-11-25 15:00:50 +01001273
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001274 IPA_RSL[0].send(ts_ASP_RSL_UD(ts_RSL_CHAN_RQD('23'O, 23)));
Harald Welte930d0a72018-03-22 22:08:40 +01001275 rsl_unused := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001276 f_shutdown_helper();
Harald Welte28d943e2017-11-25 15:00:50 +01001277}
1278
Harald Welte4003d112017-12-09 22:35:39 +01001279/* verify if the "chreq:total" counter increments as expected */
1280testcase TC_chan_act_counter() runs on test_CT {
1281 var BSSAP_N_UNITDATA_ind ud_ind;
1282 var integer chreq_total;
Harald Welte930d0a72018-03-22 22:08:40 +01001283 var RSL_Message rsl_unused;
Harald Welte4003d112017-12-09 22:35:39 +01001284
Harald Welte89d42e82017-12-17 16:42:41 +01001285 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01001286
1287 chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total");
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001288 IPA_RSL[0].send(ts_ASP_RSL_UD(ts_RSL_CHAN_RQD('23'O, 23)));
Harald Welte930d0a72018-03-22 22:08:40 +01001289 rsl_unused := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
Harald Welte4003d112017-12-09 22:35:39 +01001290 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total", chreq_total+1);
1291
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001292 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01001293}
1294
Harald Welteae026692017-12-09 01:03:01 +01001295/* CHAN RQD -> CHAN ACT -> CHAN ACT ACK -> RF CHAN REL */
Philipp Maier9c60a622020-07-09 15:08:46 +02001296private function f_TC_chan_act_ack_noest(OCT1 ra := '23'O) runs on test_CT {
Harald Welteae026692017-12-09 01:03:01 +01001297 var RSL_Message rx_rsl;
1298
Harald Welteae026692017-12-09 01:03:01 +01001299 /* Send CHAN RQD and wait for allocation; acknowledge it */
Philipp Maier9c60a622020-07-09 15:08:46 +02001300 var RslChannelNr chan_nr := f_chreq_act_ack(ra);
Harald Welteae026692017-12-09 01:03:01 +01001301
1302 /* expect BSC to disable the channel again if there's no RLL EST IND */
1303 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX);
1304
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001305 f_shutdown_helper();
Harald Welteae026692017-12-09 01:03:01 +01001306}
1307
Philipp Maier9c60a622020-07-09 15:08:46 +02001308/* Normal variant */
1309testcase TC_chan_act_ack_noest() runs on test_CT {
Philipp Maieraf58db22020-08-12 17:24:40 +02001310 f_init(1);
Philipp Maier9c60a622020-07-09 15:08:46 +02001311 f_TC_chan_act_ack_noest();
1312}
1313
1314/* Emergency call variant */
1315testcase TC_chan_act_ack_noest_emerg() runs on test_CT {
1316 /* See also: 3GPP TS 04.08, Table 9.9, ra=101xxxxx */
Philipp Maieraf58db22020-08-12 17:24:40 +02001317 f_init(1);
1318 f_vty_allow_emerg_bts(true, 0);
Philipp Maier9c60a622020-07-09 15:08:46 +02001319 f_TC_chan_act_ack_noest(ra := 'A5'O);
1320}
1321
Philipp Maier606f07d2020-08-12 17:21:58 +02001322/* Emergency call variant, but emergency calls are not allowed */
1323testcase TC_chan_rqd_emerg_deny() runs on test_CT {
1324 /* See also: 3GPP TS 04.08, Table 9.9, ra=101xxxxx */
1325
1326 var RSL_Message rx_rsl;
1327 var GsmRrMessage rr;
1328
1329 f_init(1);
1330 f_vty_allow_emerg_bts(false, 0);
1331
1332 IPA_RSL[0].clear;
1333 f_ipa_tx(0, ts_RSL_CHAN_RQD('A5'O, 23));
1334
1335 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeC(RSL_MT_IMMEDIATE_ASSIGN_CMD));
1336 rr := dec_GsmRrMessage(rx_rsl.ies[1].body.full_imm_ass_info.payload);
1337 if (rr.header.message_type == IMMEDIATE_ASSIGNMENT_REJECT) {
1338 setverdict(pass);
1339 } else {
1340 setverdict(fail, "immediate assignment not rejected");
1341 }
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01001342
1343 f_shutdown_helper();
Philipp Maier606f07d2020-08-12 17:21:58 +02001344}
1345
Harald Welteae026692017-12-09 01:03:01 +01001346/* Test behavior if MSC never answers to CR */
1347testcase TC_chan_act_ack_est_ind_noreply() runs on test_CT {
Harald Weltef77aef62018-01-28 15:35:42 +01001348 var RslLinkId main_dcch := valueof(ts_RslLinkID_DCCH(0));
1349 var IpaStreamId sid := IPAC_PROTO_RSL_TRX0;
Harald Welteae026692017-12-09 01:03:01 +01001350 var RSL_Message rx_rsl;
Harald Weltef77aef62018-01-28 15:35:42 +01001351 var ASP_RSL_Unitdata rx_rsl_ud;
Harald Welteae026692017-12-09 01:03:01 +01001352
Harald Welte89d42e82017-12-17 16:42:41 +01001353 f_init(1);
Harald Welteae026692017-12-09 01:03:01 +01001354
1355 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +01001356 var RslChannelNr chan_nr := f_chreq_act_ack();
Harald Welteae026692017-12-09 01:03:01 +01001357
1358 var octetstring l3 := '00010203040506'O
1359 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
1360
1361 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3)));
1362
1363 /* expect BSC to disable the channel again if there's no response from MSC */
Harald Weltef77aef62018-01-28 15:35:42 +01001364 /* MS waits 20s (T3210) at LU; 10s (T3230) at CM SERV REQ and 5s (T3220) AT detach */
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001365 f_expect_chan_rel(0, chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001366 f_shutdown_helper();
Harald Welteae026692017-12-09 01:03:01 +01001367}
1368
1369/* Test behavior if MSC answers with CREF to CR */
1370testcase TC_chan_act_ack_est_ind_refused() runs on test_CT {
1371 var BSSAP_N_CONNECT_ind rx_c_ind;
1372 var RSL_Message rx_rsl;
1373
Harald Welte89d42e82017-12-17 16:42:41 +01001374 f_init(1);
Harald Welteae026692017-12-09 01:03:01 +01001375
1376 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +01001377 var RslChannelNr chan_nr := f_chreq_act_ack();
Harald Welteae026692017-12-09 01:03:01 +01001378
1379 var octetstring l3 := '00010203040506'O
1380 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
1381
1382 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
1383 BSSAP.send(ts_BSSAP_DISC_req(rx_c_ind.connectionId, 0));
1384
1385 /* expect BSC to disable the channel */
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001386 f_expect_chan_rel(0, chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001387 f_shutdown_helper();
Harald Welteae026692017-12-09 01:03:01 +01001388}
1389
Harald Welte618ef642017-12-14 14:58:20 +01001390/* CHAN RQD -> CHAN ACT -> CHAN ACT NACK -> RF CHAN REL */
1391testcase TC_chan_act_nack() runs on test_CT {
1392 var RSL_Message rx_rsl;
1393 var integer chact_nack;
1394
Harald Welte89d42e82017-12-17 16:42:41 +01001395 f_init(1);
Harald Welte618ef642017-12-14 14:58:20 +01001396
1397 chact_nack := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chan_act:nack");
1398
1399 f_ipa_tx(0, ts_RSL_CHAN_RQD('33'O, 33));
1400 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
1401 var RslChannelNr chan_nr := rx_rsl.ies[0].body.chan_nr;
1402
1403 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, RSL_ERR_EQUIPMENT_FAIL));
1404
1405 /* wait for some time to hope the NACK arrives before the CTRL GET below */
1406 f_sleep(0.5);
1407
1408 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chan_act:nack", chact_nack+1);
1409
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001410 f_shutdown_helper();
Harald Welte618ef642017-12-14 14:58:20 +01001411}
1412
Harald Welte799c97b2017-12-14 17:50:30 +01001413/* Test for channel exhaustion due to RACH overload */
1414testcase TC_chan_exhaustion() runs on test_CT {
1415 var ASP_RSL_Unitdata rsl_ud;
1416 var integer i;
1417 var integer chreq_total, chreq_nochan;
1418
Harald Welte89d42e82017-12-17 16:42:41 +01001419 f_init(1);
Harald Welte799c97b2017-12-14 17:50:30 +01001420
1421 chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total");
1422 chreq_nochan := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel");
1423
Neels Hofmeyr85fa37f2021-10-06 13:50:38 +02001424 /* GSM 44.018 Table 9.1.8.2:
Pau Espin Pedrolfe200d72018-12-10 12:41:04 +01001425 * RA = '33'O -> Establishment cause = 0011xxxx (MS dual rate capable and asks for "TCH/H or TCH/F").
1426 * With current setup, expect 4xSDCCH + 4xTCH/F + 1xTCH/H to succeed */
Philipp Maiercb6cc482018-03-26 13:08:00 +02001427 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 +01001428 var RslChannelNr chan_nr := f_chreq_act_ack('33'O, i);
Harald Welte799c97b2017-12-14 17:50:30 +01001429 }
1430
1431 IPA_RSL[0].clear;
1432
Harald Weltedd8cbf32018-01-28 12:07:52 +01001433 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total",
Philipp Maiercb6cc482018-03-26 13:08:00 +02001434 chreq_total + NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS);
Harald Welte799c97b2017-12-14 17:50:30 +01001435
1436 /* now expect additional channel activations to fail */
1437 f_ipa_tx(0, ts_RSL_CHAN_RQD('42'O, 42));
1438
1439 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001440 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV))) {
Harald Welte799c97b2017-12-14 17:50:30 +01001441 setverdict(fail, "Received CHAN ACT ACK without resources?!?");
1442 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001443 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_IMM_ASSIGN(?))) -> value rsl_ud {
Harald Welte799c97b2017-12-14 17:50:30 +01001444 var GsmRrMessage rr;
1445 /* match on IMM ASS REJ */
1446 rr := dec_GsmRrMessage(rsl_ud.rsl.ies[1].body.full_imm_ass_info.payload);
1447 if (rr.header.message_type == IMMEDIATE_ASSIGNMENT_REJECT) {
1448 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total",
Philipp Maiercb6cc482018-03-26 13:08:00 +02001449 chreq_total + NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS+1);
Harald Welte799c97b2017-12-14 17:50:30 +01001450 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel",
1451 chreq_nochan+1);
1452 setverdict(pass);
1453 } else {
1454 repeat;
1455 }
1456 }
1457 [] IPA_RSL[0].receive { repeat; }
1458 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001459 f_shutdown_helper();
Harald Welte799c97b2017-12-14 17:50:30 +01001460}
1461
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07001462/* Test channel deactivation due to silence from MS */
1463testcase TC_chan_deact_silence() runs on test_CT {
1464 var RslChannelNr chan_nr;
1465
1466 f_init(1);
1467
1468 /* Request for a dedicated channel */
1469 chan_nr := f_chreq_act_ack('23'O);
1470
1471 /* Wait some time until the channel is released */
1472 f_sleep(2.0);
1473
1474 /* Expect CHANnel RELease */
1475 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001476 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL))) {
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07001477 log("Received CHANnel RELease");
1478 setverdict(pass);
1479 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001480 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_IMM_ASSIGN(?))) {
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07001481 /* See OS#3709, OsmoBSC should not send Immediate
1482 * Assignment Reject since a dedicated channel was
1483 * already allocated, and Immediate Assignment was
1484 * already sent. */
1485 setverdict(fail, "Unexpected Immediate Assignment!");
1486 }
1487 [] IPA_RSL[0].receive {
1488 setverdict(fail, "Unexpected RSL message!");
1489 }
1490 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001491 f_shutdown_helper();
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07001492}
1493
Harald Weltecfe2c962017-12-15 12:09:32 +01001494/***********************************************************************
1495 * Assignment Testing
1496 ***********************************************************************/
1497
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02001498/* Verify that the BSC refuses any BSSAP connection from the MSC (They are all BSC->MSC direction,
1499 * except for the inter-BSC handover, MT side) */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001500testcase TC_outbound_connect(integer bssap_idx := 0) runs on test_CT {
Harald Welte89d42e82017-12-17 16:42:41 +01001501 f_init(1);
Harald Weltecfe2c962017-12-15 12:09:32 +01001502
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001503 BSSAP.send(ts_BSSAP_CONNECT_req(g_bssap[bssap_idx].sccp_addr_peer, g_bssap[bssap_idx].sccp_addr_own,
1504 2342, ts_BSSMAP_AssignmentReq));
Harald Weltecfe2c962017-12-15 12:09:32 +01001505 BSSAP.receive(tr_BSSAP_DISC_ind(2342, ?, ?));
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001506 f_shutdown_helper();
Harald Weltecfe2c962017-12-15 12:09:32 +01001507}
1508
Harald Welte16a4adf2017-12-14 18:54:01 +01001509/* Test behavior if MSC answers with CREF to CR */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001510testcase TC_assignment_cic_only(integer bssap_idx := 0) runs on test_CT {
Harald Welte16a4adf2017-12-14 18:54:01 +01001511 var BSSAP_N_CONNECT_ind rx_c_ind;
1512 var RSL_Message rx_rsl;
1513 var DchanTuple dt;
1514
Harald Welte89d42e82017-12-17 16:42:41 +01001515 f_init(1);
Harald Welte16a4adf2017-12-14 18:54:01 +01001516
1517 dt := f_est_dchan('23'O, 23, '00000000'O);
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001518 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welte17b27da2018-05-25 20:33:53 +02001519 /* send assignment without AoIP IEs */
1520 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_AssignmentReq(ts_BSSMAP_IE_CIC(0, 1))));
1521 } else {
1522 /* Send assignmetn without CIC in IPA case */
1523 var BSSMAP_IE_AoIP_TransportLayerAddress tla :=
1524 valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342));
1525 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_AssignmentReq(omit, tla)));
1526 }
Harald Welte16a4adf2017-12-14 18:54:01 +01001527 alt {
1528 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentComplete)) {
1529 setverdict(fail, "AoIP BSC cannot accept ASSIGNMENT without AoIP Transport IE");
1530 }
Harald Welte235ebf12017-12-15 14:18:16 +01001531 /* TODO: Actually expect GSM0808_CAUSE_REQ_A_IF_TYPE_NOT_SUPP */
Harald Welte16a4adf2017-12-14 18:54:01 +01001532 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentFail)) {
1533 setverdict(pass);
1534 }
1535 [] BSSAP.receive { repeat; }
1536 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001537 f_shutdown_helper();
Harald Welte16a4adf2017-12-14 18:54:01 +01001538}
1539
Harald Welteed848512018-05-24 22:27:58 +02001540/* generate an assignment request for either AoIP or SCCPlite */
Pau Espin Pedrol07866632020-09-03 19:10:55 +02001541function 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 +02001542 var PDU_BSSAP ass_cmd;
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001543 var BSSMAP_IE_Osmo_OsmuxCID osmux_cid := valueof(ts_OsmuxCID(0));
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001544 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welteed848512018-05-24 22:27:58 +02001545 var BSSMAP_IE_AoIP_TransportLayerAddress tla :=
Pau Espin Pedrol07866632020-09-03 19:10:55 +02001546 valueof(f_ts_BSSMAP_IE_AoIP_TLA(aoip_tla, 2342));
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001547 if (osmux_enabled) {
1548 ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla, osmux_cid));
1549 } else {
1550 ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla));
1551 }
Harald Welteed848512018-05-24 22:27:58 +02001552 } else {
1553 var BSSMAP_IE_CircuitIdentityCode cic := valueof(ts_BSSMAP_IE_CIC(0,1));
Pau Espin Pedrol096d73d2019-06-06 12:49:17 +02001554 ass_cmd := valueof(ts_BSSMAP_AssignmentReq(cic, omit));
Harald Welteed848512018-05-24 22:27:58 +02001555 }
1556 return ass_cmd;
1557}
1558
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02001559function f_gen_handover_req(integer bssap_idx := 0, charstring aoip_tla := "1.2.3.4",
Neels Hofmeyr8ebf19c2021-06-21 05:24:01 +02001560 template (omit) BSSMAP_oldToNewBSSIEs oldToNewBSSIEs := omit,
1561 template (omit) TestHdlrEncrParams enc := omit) return PDU_BSSAP {
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01001562 var PDU_BSSAP ho_req;
Neels Hofmeyr8ebf19c2021-06-21 05:24:01 +02001563
1564 var BSSMAP_IE_EncryptionInformation encryptionInformation :=
1565 valueof(ts_BSSMAP_IE_EncrInfo('0000000000000000'O,'01'O));
1566 var template BSSMAP_IE_ChosenEncryptionAlgorithm chosenEncryptionAlgorithm := omit;
1567 var template BSSMAP_IE_KC128 kc128 := omit;
1568 if (ispresent(enc)) {
1569 var TestHdlrEncrParams v_enc := valueof(enc);
1570 encryptionInformation := valueof(ts_BSSMAP_IE_EncrInfo(v_enc.enc_key, v_enc.enc_alg));
1571 chosenEncryptionAlgorithm := valueof(
1572 ts_BSSMAP_IE_ChosenEncryptionAlgorithm(int2oct(enum2int(
Oliver Smith598e1ed2021-07-09 10:28:40 +02001573 f_cipher_mode_bssmap_to_rsl(v_enc.enc_alg)), 1)));
Neels Hofmeyr8ebf19c2021-06-21 05:24:01 +02001574 if (ispresent(v_enc.enc_kc128)) {
1575 kc128 := ts_BSSMAP_IE_Kc128(v_enc.enc_kc128);
1576 }
1577 }
1578
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001579 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01001580 var BSSMAP_IE_AoIP_TransportLayerAddress tla :=
Pau Espin Pedrol07866632020-09-03 19:10:55 +02001581 valueof(f_ts_BSSMAP_IE_AoIP_TLA(aoip_tla, 2342));
Neels Hofmeyr8ebf19c2021-06-21 05:24:01 +02001582 ho_req := valueof(ts_BSSMAP_HandoverRequest(omit, tla, oldToNewBSSIEs := oldToNewBSSIEs,
1583 encryptionInformation := encryptionInformation,
1584 chosenEncryptionAlgorithm := chosenEncryptionAlgorithm,
1585 kC128 := kc128));
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01001586 } else {
1587 var BSSMAP_IE_CircuitIdentityCode cic := valueof(ts_BSSMAP_IE_CIC(0,1));
Neels Hofmeyr8ebf19c2021-06-21 05:24:01 +02001588 ho_req := valueof(ts_BSSMAP_HandoverRequest(cic, omit, oldToNewBSSIEs := oldToNewBSSIEs,
1589 encryptionInformation := encryptionInformation,
1590 chosenEncryptionAlgorithm := chosenEncryptionAlgorithm,
1591 kC128 := kc128));
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01001592 }
1593 return ho_req;
1594}
1595
Harald Welteed848512018-05-24 22:27:58 +02001596/* generate an assignment complete template for either AoIP or SCCPlite */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001597function f_gen_exp_compl(boolean expect_osmux := false, integer bssap_idx := 0) return template PDU_BSSAP {
Harald Welteed848512018-05-24 22:27:58 +02001598 var template PDU_BSSAP exp_compl;
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001599 var BSSMAP_IE_Osmo_OsmuxCID osmux_cid := valueof(ts_OsmuxCID(0));
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001600 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001601 if (expect_osmux) {
1602 exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?, osmux_cid);
1603 } else {
1604 exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?, omit);
1605 }
Harald Welteed848512018-05-24 22:27:58 +02001606 } else {
1607 /* CIC is optional "*" as the MSC allocated it */
Pau Espin Pedrol096d73d2019-06-06 12:49:17 +02001608 exp_compl := tr_BSSMAP_AssignmentComplete(*, omit);
Harald Welteed848512018-05-24 22:27:58 +02001609 }
1610 return exp_compl;
1611}
1612
Harald Welte235ebf12017-12-15 14:18:16 +01001613/* Run everything required up to sending a caller-specified assignment command and expect response */
1614function f_assignment_exp(PDU_BSSAP ass_cmd, template PDU_BSSAP exp, charstring fail_text)
1615runs on test_CT {
1616 var BSSAP_N_CONNECT_ind rx_c_ind;
1617 var RSL_Message rx_rsl;
1618 var DchanTuple dt;
1619
Harald Welte89d42e82017-12-17 16:42:41 +01001620 f_init(1);
Harald Welte235ebf12017-12-15 14:18:16 +01001621
1622 dt := f_est_dchan('23'O, 23, '00000000'O);
1623 /* send assignment without AoIP IEs */
1624 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ass_cmd));
1625 alt {
1626 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentComplete)) {
1627 if (ischosen(exp.pdu.bssmap.assignmentComplete)) {
1628 setverdict(pass);
1629 } else {
1630 setverdict(fail, fail_text);
1631 }
1632 }
1633 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentFail)) {
1634 if (ischosen(exp.pdu.bssmap.assignmentFailure)) {
1635 setverdict(pass);
1636 } else {
1637 setverdict(fail, fail_text);
1638 }
1639 }
1640 [] BSSAP.receive { repeat; }
1641 }
1642}
1643testcase TC_assignment_csd() runs on test_CT {
1644 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +02001645 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte235ebf12017-12-15 14:18:16 +01001646 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeCSD);
1647 //exp_fail.pdu.bssmap.assignmentFailure.cause.causeValue := int2bit(enum2int(GSM0808_CAUSE_REQ_CODEC_TYPE_OR_CONFIG_UNAVAIL), 7);
1648 f_assignment_exp(ass_cmd, exp_fail, "BSC accepted Assignment for CSD");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001649 f_shutdown_helper();
Harald Welte235ebf12017-12-15 14:18:16 +01001650}
1651
1652testcase TC_assignment_ctm() runs on test_CT {
1653 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +02001654 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte235ebf12017-12-15 14:18:16 +01001655 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeCTM);
1656 //exp_fail.pdu.bssmap.assignmentFailure.cause.causeValue := int2bit(enum2int(GSM0808_CAUSE_REQ_CODEC_TYPE_OR_CONFIG_UNAVAIL), 7);
1657 f_assignment_exp(ass_cmd, exp_fail, "BSC accepted Assignment for Speech+CTM");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001658 f_shutdown_helper();
Harald Welte235ebf12017-12-15 14:18:16 +01001659}
1660
Harald Welte4003d112017-12-09 22:35:39 +01001661type record DchanTuple {
1662 integer sccp_conn_id,
1663 RslChannelNr rsl_chan_nr
Harald Weltea5d2ab22017-12-09 14:21:42 +01001664}
1665
Neels Hofmeyrbd94fe72021-10-26 22:04:53 +02001666type record of DchanTuple DchanTuples;
1667
Harald Welted6939652017-12-13 21:02:46 +01001668/* Send CHAN RQD and wait for allocation; acknowledge it */
1669private function f_chreq_act_ack(OCT1 ra := '23'O, GsmFrameNumber fn := 23)
1670runs on test_CT return RslChannelNr {
1671 var RSL_Message rx_rsl;
1672 f_ipa_tx(0, ts_RSL_CHAN_RQD(ra, fn));
1673 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
1674 var RslChannelNr chan_nr := rx_rsl.ies[0].body.chan_nr;
1675 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, fn+10));
Daniel Willmannf4ac4ce2018-08-02 14:06:30 +02001676 rx_rsl := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
Harald Welted6939652017-12-13 21:02:46 +01001677 return chan_nr;
1678}
1679
Harald Welte4003d112017-12-09 22:35:39 +01001680/* helper function to establish a dedicated channel via BTS and MSC */
1681function f_est_dchan(OCT1 ra, GsmFrameNumber fn, octetstring l3)
1682runs on test_CT return DchanTuple {
1683 var BSSAP_N_CONNECT_ind rx_c_ind;
Harald Welte4003d112017-12-09 22:35:39 +01001684 var DchanTuple dt;
Harald Weltea5d2ab22017-12-09 14:21:42 +01001685
Harald Welte4003d112017-12-09 22:35:39 +01001686 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +01001687 dt.rsl_chan_nr := f_chreq_act_ack(ra, fn);
Harald Welte4003d112017-12-09 22:35:39 +01001688
1689 f_ipa_tx(0, ts_RSL_EST_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
1690
1691 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
1692 dt.sccp_conn_id := rx_c_ind.connectionId;
1693 BSSAP.send(ts_BSSAP_CONNECT_res(dt.sccp_conn_id));
1694
1695 return dt;
Harald Weltea5d2ab22017-12-09 14:21:42 +01001696}
1697
Neels Hofmeyre1a7c4d2021-10-23 23:13:01 +02001698/* Like f_est_dchan(), but for the first lchan of a dynamic timeslot: first ACK the deactivation of PDCH. */
1699function f_est_dchan_dyn(OCT1 ra, GsmFrameNumber fn, octetstring l3)
1700runs on test_CT return DchanTuple {
1701 var BSSAP_N_CONNECT_ind rx_c_ind;
1702 var DchanTuple dt;
1703
1704 /* Send CHAN RQD */
1705 var RSL_Message rx_rsl;
1706 f_ipa_tx(0, ts_RSL_CHAN_RQD(ra, fn));
1707
1708 /* The dyn TS first deactivates PDCH */
1709 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX);
1710 dt.rsl_chan_nr := rx_rsl.ies[0].body.chan_nr;
1711 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
1712
1713 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
1714 dt.rsl_chan_nr := rx_rsl.ies[0].body.chan_nr;
1715
1716 /* Now activates the signalling channel */
1717 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(dt.rsl_chan_nr, fn+10));
1718 rx_rsl := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
1719
1720 f_ipa_tx(0, ts_RSL_EST_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
1721
1722 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
1723 dt.sccp_conn_id := rx_c_ind.connectionId;
1724 BSSAP.send(ts_BSSAP_CONNECT_res(dt.sccp_conn_id));
1725
1726 return dt;
1727}
1728
Harald Welte641fcbe2018-06-14 10:58:35 +02001729/* expect RF CAN REL from BTS, acknowledge it and clear the MSC side */
1730private function f_exp_chan_rel_and_clear(DchanTuple dt, integer bts_nr := 0) runs on test_CT {
1731 var RSL_Message rx_rsl;
1732 /* expect BSC to disable the channel */
1733 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX);
1734 /* respond with CHAN REL ACK */
1735 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
1736
1737 /* expect Clear Complete from BSC */
1738 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete));
1739
1740 /* MSC disconnects as instructed. */
1741 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1742}
1743
Harald Welte4003d112017-12-09 22:35:39 +01001744/* Test behavior of channel release after unilateral RLL REL IND (DISC from MS) */
1745testcase TC_chan_rel_rll_rel_ind() runs on test_CT {
Neels Hofmeyr27f64362018-03-12 01:44:00 +01001746 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +01001747 var DchanTuple dt;
Harald Welte96c94412017-12-09 03:12:45 +01001748
Harald Welte89d42e82017-12-17 16:42:41 +01001749 f_init(1);
Harald Welte96c94412017-12-09 03:12:45 +01001750
Harald Welte4003d112017-12-09 22:35:39 +01001751 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1752
1753 /* simulate RLL REL IND */
1754 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0))));
1755
Neels Hofmeyr27f64362018-03-12 01:44:00 +01001756 /* expect Clear Request on MSC side */
1757 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
1758
1759 /* Instruct BSC to clear channel */
1760 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
1761 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
1762
Harald Welte4003d112017-12-09 22:35:39 +01001763 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02001764 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyr27f64362018-03-12 01:44:00 +01001765
1766 /* wait for SCCP emulation to do its job */
1767 f_sleep(1.0);
Harald Welte4003d112017-12-09 22:35:39 +01001768
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001769 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01001770}
1771
1772/* Test behavior of channel release after CONN FAIL IND from BTS */
1773testcase TC_chan_rel_conn_fail() runs on test_CT {
1774 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +01001775 var DchanTuple dt;
1776
Harald Welte89d42e82017-12-17 16:42:41 +01001777 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01001778
1779 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1780
1781 /* simulate CONN FAIL IND */
Harald Weltea8ed9062017-12-14 09:46:01 +01001782 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 +01001783 /* TODO: different cause values? */
1784
Harald Welte4003d112017-12-09 22:35:39 +01001785 /* expect Clear Request from BSC */
1786 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
1787
1788 /* Instruct BSC to clear channel */
1789 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
1790 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
1791
Harald Welte6ff76ea2018-01-28 13:08:01 +01001792 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02001793 f_exp_chan_rel_and_clear(dt, 0);
Harald Welte4003d112017-12-09 22:35:39 +01001794
1795 /* wait for SCCP emulation to do its job */
1796 f_sleep(1.0);
1797
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001798 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01001799}
1800
Harald Welte99f3ca02018-06-14 13:40:29 +02001801/* Test behavior of early CONN FAIL IND from BTS (before EST IND!) */
1802/* See also https://www.osmocom.org/issues/3182 */
1803testcase TC_early_conn_fail() runs on test_CT {
1804 var RSL_Message rx_rsl;
1805 var DchanTuple dt;
1806
1807 f_init(1);
1808
1809 /* BTS->BSC: Send CHAN RQD and wait for allocation; acknowledge it */
Harald Weltec46ea3c2020-10-10 18:46:12 +02001810 dt.rsl_chan_nr := f_chreq_act_ack(f_rnd_ra_cs(), 23);
Harald Welte99f3ca02018-06-14 13:40:29 +02001811
1812 /* BTS->BSC: simulate CONN FAIL IND */
1813 f_ipa_tx(0, ts_RSL_CONN_FAIL_IND(dt.rsl_chan_nr, RSL_ERR_RADIO_LINK_FAIL));
1814
1815 /* BTS->BSC: Expect RF channel release from BSC on Abis */
1816 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), 10.0);
1817
1818 /* BTS<-BSC: respond with CHAN REL ACK */
1819 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
1820
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001821 f_shutdown_helper();
Harald Welte99f3ca02018-06-14 13:40:29 +02001822}
1823
1824/* Test behavior of late CONN FAIL IND from BTS (ater REL IND!) */
1825/* See also https://www.osmocom.org/issues/3182 */
1826testcase TC_late_conn_fail() runs on test_CT {
1827 var RSL_Message rx_rsl;
1828 var DchanTuple dt;
1829
1830 f_init(1);
1831
1832 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1833
1834 /* BSC<-MSC: Instruct BSC to clear connection */
1835 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(0)));
1836
1837 /* BTS->BSC: expect BSC to deactivate SACCH */
1838 rx_rsl := f_exp_ipa_rx(0, tr_RSL_DEACT_SACCH(dt.rsl_chan_nr));
1839
1840 /* BTS->BSC: simulate a late CONN FAIL IND from BTS */
1841 f_ipa_tx(0, ts_RSL_CONN_FAIL_IND(dt.rsl_chan_nr, RSL_ERR_RADIO_LINK_FAIL));
1842
1843 /* BTS<-BSC: Expect RF channel release from BSC on Abis */
1844 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), 10.0);
1845 /* BTS->BSC: respond with CHAN REL ACK */
1846 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
1847
1848 /* BSC->MSC: expect Clear Complete from BSC */
1849 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete));
1850
1851 /* BSC<-MSC: MSC disconnects as requested. */
1852 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1853
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001854 f_shutdown_helper();
Harald Welte99f3ca02018-06-14 13:40:29 +02001855}
1856
Oliver Smithaf03bef2021-08-24 15:34:51 +02001857private function f_TC_stats_conn_fail(charstring id) runs on MSC_ConnHdlr {
1858 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
1859 var PDU_BSSAP ass_cmd := f_gen_ass_req();
1860
1861 f_statsd_reset();
1862
1863 /* Establish SDCCH */
1864 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeCSD);
1865 f_establish_fully(ass_cmd, exp_fail);
1866
1867 /* Expect stats to be 0 */
1868 var StatsDExpects expect := {
1869 {name := "TTCN3.bts.0.chan.rf_fail", mtype := "c", min := 0, max := 0},
1870 {name := "TTCN3.bts.0.chan.rf_fail_sdcch", mtype := "c", min := 0, max := 0}
1871 };
1872 f_statsd_expect(expect);
1873
1874 /* Simulate CONN FAIL IND on SDCCH */
1875 RSL.send(ts_ASP_RSL_UD(
1876 ts_RSL_CONN_FAIL_IND(g_chan_nr, RSL_ERR_RADIO_LINK_FAIL),
1877 IPAC_PROTO_RSL_TRX0));
1878
Neels Hofmeyr58be48a2021-09-07 18:39:21 +02001879 f_sleep(1.0);
1880
Oliver Smithaf03bef2021-08-24 15:34:51 +02001881 /* Expect stats to be 1 */
1882 expect := {
1883 {name := "TTCN3.bts.0.chan.rf_fail", mtype := "c", min := 1, max := 1},
1884 {name := "TTCN3.bts.0.chan.rf_fail_sdcch", mtype := "c", min := 1, max := 1}
1885 };
1886 f_statsd_expect(expect);
1887}
1888testcase TC_stats_conn_fail() runs on test_CT {
1889 var TestHdlrParams pars := f_gen_test_hdlr_pars();
1890 var MSC_ConnHdlr vc_conn;
1891
1892 f_init(1, true);
1893 f_sleep(1.0);
1894
1895 vc_conn := f_start_handler(refers(f_TC_stats_conn_fail), pars);
1896 vc_conn.done;
1897
1898 f_shutdown_helper();
1899}
1900
Neels Hofmeyrf44ccd12018-11-05 19:15:23 +01001901function f_expect_chan_rel(integer bts_nr, RslChannelNr rsl_chan_nr,
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001902 boolean expect_deact_sacch := true,
1903 boolean expect_rr_chan_rel := true,
1904 boolean expect_rll_rel_req := true,
Harald Welte99787102019-02-04 10:41:36 +01001905 boolean handle_rll_rel := true,
Pau Espin Pedrol36bd4fa2021-04-15 13:00:24 +02001906 template CellSelIndValue expect_cells := omit,
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001907 template RR_Cause expect_rr_cause := ?
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001908 ) runs on test_CT {
Harald Welte91d54a52018-01-28 15:35:07 +01001909
1910 var RslLinkId main_dcch := valueof(ts_RslLinkID_DCCH(0));
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001911 var boolean got_deact_sacch := false;
1912 var boolean got_rr_chan_rel := false;
1913 var boolean got_rll_rel_req := false;
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001914 var ASP_RSL_Unitdata ud;
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001915 var RSL_IE_Body l3_ie;
1916 var PDU_ML3_NW_MS l3;
1917 var RR_Cause got_cause;
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001918 log("f_expect_chan_rel() expecting: expect_deact_sacch=", expect_deact_sacch, " expect_rr_chan_rel=", expect_rr_chan_rel,
1919 " expect_rll_rel_req=", expect_rll_rel_req);
Harald Welte91d54a52018-01-28 15:35:07 +01001920 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001921 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_DEACT_SACCH(rsl_chan_nr))) {
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001922 got_deact_sacch := true;
Harald Welte91d54a52018-01-28 15:35:07 +01001923 repeat;
1924 }
Pau Espin Pedrol841b90d2021-04-15 16:42:52 +02001925 [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 +01001926 got_rr_chan_rel := true;
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001927
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001928 if (f_rsl_find_ie(ud.rsl, RSL_IE_L3_INFO, l3_ie) == false) {
1929 setverdict(fail, "cannot find L3");
1930 mtc.stop;
1931 }
1932 l3 := dec_PDU_ML3_NW_MS(l3_ie.l3_info.payload);
1933
Pau Espin Pedrol36bd4fa2021-04-15 13:00:24 +02001934 if (not istemplatekind(expect_cells, "omit")) {
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001935 var CellSelIndValue cells := dec_CellSelIndValue(
1936 l3.msgs.rrm.channelRelease.cellSelectionIndicator.cellSelectionIndicatorValue);
1937
Pau Espin Pedrol36bd4fa2021-04-15 13:00:24 +02001938 log("GOT RR CHANNEL RELEASE WITH CELLS: ", cells);
1939 if (match(cells, expect_cells)) {
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001940 setverdict(pass);
1941 } else {
Pau Espin Pedrol36bd4fa2021-04-15 13:00:24 +02001942 log("EXPECTED CELLS: ", expect_cells);
1943 setverdict(fail, "Received cells list on RR Channel Release does not match expectations");
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001944 }
1945 }
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001946
1947 if (not istemplatekind(expect_rr_cause, "omit")) {
1948 int2enum(oct2int(l3.msgs.rrm.channelRelease.rRCause.valuePart), got_cause);
1949 log("GOT CAUSE CODE: ", l3.msgs.rrm.channelRelease.rRCause.valuePart, " = ", got_cause);
1950 if (match(got_cause, expect_rr_cause)) {
1951 setverdict(pass);
1952 } else {
1953 log("EXPECTED CAUSE CODE: ", expect_rr_cause);
1954 setverdict(fail, "Received RR Channel Release Cause code does not match expectations");
1955 }
1956 }
Harald Welte99787102019-02-04 10:41:36 +01001957 repeat;
1958 }
Pau Espin Pedrol841b90d2021-04-15 16:42:52 +02001959 [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 +01001960 got_rr_chan_rel := true;
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001961
1962 if (not istemplatekind(expect_rr_cause, "omit")) {
1963 if (f_rsl_find_ie(ud.rsl, RSL_IE_L3_INFO, l3_ie) == false) {
1964 setverdict(fail, "cannot find L3");
1965 mtc.stop;
1966 }
1967 l3 := dec_PDU_ML3_NW_MS(l3_ie.l3_info.payload);
1968
1969 int2enum(oct2int(l3.msgs.rrm.channelRelease.rRCause.valuePart), got_cause);
1970 log("GOT CAUSE CODE: ", l3.msgs.rrm.channelRelease.rRCause.valuePart, " = ", got_cause);
1971 if (match(got_cause, expect_rr_cause)) {
1972 setverdict(pass);
1973 } else {
1974 log("EXPECTED CAUSE CODE: ", expect_rr_cause);
1975 setverdict(fail, "Received RR Channel Release Cause code does not match expectations");
1976 }
1977 }
Neels Hofmeyr211169d2018-11-07 00:37:29 +01001978 repeat;
1979 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001980 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_REL_REQ(rsl_chan_nr, ?))) {
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001981 got_rll_rel_req := true;
Harald Welte91d54a52018-01-28 15:35:07 +01001982 /* FIXME: Why are we getting this for LinkID SACCH? */
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001983 if (handle_rll_rel) {
1984 f_ipa_tx(0, ts_RSL_REL_CONF(rsl_chan_nr, main_dcch));
1985 }
Harald Welte91d54a52018-01-28 15:35:07 +01001986 repeat;
1987 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001988 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL))) {
Harald Welte91d54a52018-01-28 15:35:07 +01001989 /* respond with CHAN REL ACK */
1990 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(rsl_chan_nr));
1991 }
1992 /* ignore any user data */
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001993 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeR(?))) {
Harald Welte91d54a52018-01-28 15:35:07 +01001994 repeat;
1995 }
1996 }
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001997
1998 log("f_expect_chan_rel() summary: got_deact_sacch=", got_deact_sacch, " got_rr_chan_rel=", got_rr_chan_rel,
1999 " got_rll_rel_req=", got_rll_rel_req);
2000
2001 if (expect_deact_sacch != got_deact_sacch) {
2002 setverdict(fail, "f_expect_chan_rel(): expect_deact_sacch=", expect_deact_sacch, " got_deact_sacch=", got_deact_sacch);
2003 }
2004 if (expect_rr_chan_rel != got_rr_chan_rel) {
2005 setverdict(fail, "f_expect_chan_rel(): expect_rr_chan_rel=", expect_rr_chan_rel, " got_rr_chan_rel=", got_rr_chan_rel);
2006 }
2007 if (expect_rll_rel_req != got_rll_rel_req) {
2008 setverdict(fail, "f_expect_chan_rel(): expect_rll_rel_req=", expect_rll_rel_req, " got_rll_rel_req=", got_rll_rel_req);
2009 }
Harald Welte91d54a52018-01-28 15:35:07 +01002010}
2011
Harald Welte4003d112017-12-09 22:35:39 +01002012/* Test behavior of channel release after hard Clear Command from MSC */
2013testcase TC_chan_rel_hard_clear() runs on test_CT {
2014 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +01002015 var DchanTuple dt;
Harald Welte4003d112017-12-09 22:35:39 +01002016
Harald Welte89d42e82017-12-17 16:42:41 +01002017 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01002018
2019 dt := f_est_dchan('23'O, 23, '00010203040506'O);
2020
2021 /* Instruct BSC to clear channel */
2022 var BssmapCause cause := 0;
2023 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
2024
2025 /* expect Clear Complete from BSC on A */
2026 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
2027 /* release the SCCP connection */
2028 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2029 }
2030
Neels Hofmeyra5302c82018-11-04 23:09:58 +01002031 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002032 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01002033}
2034
Pau Espin Pedrol841b90d2021-04-15 16:42:52 +02002035function f_TC_chan_rel_last_eutran_plmn_hard_clear(boolean tx_csfb_ind) runs on test_CT {
2036 var BSSAP_N_DATA_ind rx_di;
2037 var DchanTuple dt;
2038
2039 f_init(1);
2040
2041 dt := f_est_dchan('23'O, 23, '00010203040506'O);
2042 /* Send CommonID with some random PLMN (BSC doesn't take it into account
2043 /* yet when generating the EUTRAN neigh list in RR CHannel Release) */
2044 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_CommonId('001019876543210'H, '323454'O)));
2045
2046 /* Instruct BSC to clear channel */
2047 var BssmapCause cause := 0;
2048 if (tx_csfb_ind) {
2049 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommandCSFB(cause)));
2050 } else {
2051 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
2052 }
2053
2054 /* expect Clear Complete from BSC on A */
2055 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
2056 /* release the SCCP connection */
2057 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2058 }
2059
2060 /* 1 neighbor is added by default in osmo-bts.cfg and
2061 SystemInformationConfig_default, use that: */
2062 var template CellSelIndValue exp_cells := f_tr_rr_chan_rel_earfcns(1);
2063
2064 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false, expect_cells := exp_cells);
2065 f_shutdown_helper();
2066}
2067
2068/* Test behavior of RR Channel rRelease after Clear Command without CSFB indicator
2069 from MSC, previously receiving any CommonID containing the "Last Used E-UTRAN
2070 PLMN Id". According to spec (3GPP TS 48.008 sec 3.1.30) that's the bit requesting
2071 EUTRAN neighbor list sent later on by BSC in RR Channel, so receiving CSFB
2072 Indicator or not shouldn't matter at all. */
2073testcase TC_chan_rel_last_eutran_plmn_hard_clear_no_csfb() runs on test_CT {
2074 f_TC_chan_rel_last_eutran_plmn_hard_clear(false);
2075}
2076
2077/* Test behavior of RR Channel rRelease after Clear Command with CSFB indicator from
2078 MSC, previously receiving any CommonID containing the "Last Used E-UTRAN PLMN
2079 Id". According to spec (3GPP TS 48.008 sec 3.1.30) that's the bit requesting
2080 EUTRAN neighbor list sent later on by BSC in RR Channel. */
2081testcase TC_chan_rel_last_eutran_plmn_hard_clear_csfb() runs on test_CT {
2082 f_TC_chan_rel_last_eutran_plmn_hard_clear(true);
2083}
2084
2085/* Test behavior of RR Channel Release after Clear Command with CSFB indicator from
2086 MSC, without receiving any CommonID containing the "Last Used E-UTRAN PLMN
2087 Id". According to spec (TS 48.008 version 16.0.0 Release 16 "3.2.1.21") the
2088 CSFB Indicator should not be used anymore, and hence, there should be no
2089 EUTRAN neighbor list sent by BSC in RR Channel release since no CommonId with
2090 Last Used E-UTRAN PLMN Id" IE was sent for this conn. */
Harald Welte99787102019-02-04 10:41:36 +01002091testcase TC_chan_rel_hard_clear_csfb() runs on test_CT {
2092 var BSSAP_N_DATA_ind rx_di;
2093 var DchanTuple dt;
2094
2095 f_init(1);
2096
2097 dt := f_est_dchan('23'O, 23, '00010203040506'O);
2098
2099 /* Instruct BSC to clear channel */
2100 var BssmapCause cause := 0;
2101 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommandCSFB(cause)));
2102
2103 /* expect Clear Complete from BSC on A */
2104 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
2105 /* release the SCCP connection */
2106 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2107 }
2108
Pau Espin Pedrol841b90d2021-04-15 16:42:52 +02002109 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002110 f_shutdown_helper();
Harald Welte99787102019-02-04 10:41:36 +01002111}
2112
Harald Welted8c36cd2017-12-09 23:05:31 +01002113/* Test behavior of channel release after hard RLSD from MSC */
2114testcase TC_chan_rel_hard_rlsd() runs on test_CT {
Harald Welted8c36cd2017-12-09 23:05:31 +01002115 var DchanTuple dt;
Harald Welted8c36cd2017-12-09 23:05:31 +01002116
Harald Welte89d42e82017-12-17 16:42:41 +01002117 f_init(1);
Harald Welted8c36cd2017-12-09 23:05:31 +01002118
2119 dt := f_est_dchan('23'O, 23, '00010203040506'O);
2120
2121 /* release the SCCP connection */
2122 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2123
Neels Hofmeyra5302c82018-11-04 23:09:58 +01002124 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002125 f_shutdown_helper();
Harald Welted8c36cd2017-12-09 23:05:31 +01002126}
2127
Harald Welte550daf92018-06-11 19:22:13 +02002128/* Test behavior of channel release after hard RLSD from MSC and MS is not responding to RLL REL REQ */
2129testcase TC_chan_rel_hard_rlsd_ms_dead() runs on test_CT {
2130 var DchanTuple dt;
2131
2132 f_init(1);
2133
2134 dt := f_est_dchan('23'O, 23, '00010203040506'O);
2135
2136 /* release the SCCP connection */
2137 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2138
Neels Hofmeyra5302c82018-11-04 23:09:58 +01002139 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002140 f_shutdown_helper();
Harald Welte550daf92018-06-11 19:22:13 +02002141}
2142
Harald Welte85804d42017-12-10 14:11:58 +01002143/* Test behavior of channel release after BSSMAP RESET from MSC */
2144testcase TC_chan_rel_a_reset() runs on test_CT {
Harald Welte85804d42017-12-10 14:11:58 +01002145 var DchanTuple dt;
Harald Welte85804d42017-12-10 14:11:58 +01002146
Harald Welte89d42e82017-12-17 16:42:41 +01002147 f_init(1);
Harald Welte85804d42017-12-10 14:11:58 +01002148
2149 dt := f_est_dchan('23'O, 23, '00010203040506'O);
2150
2151 /* Clear the queue, it might still contain stuff like IMMEDIATE ASSIGN */
2152 IPA_RSL[0].clear;
2153
2154 /* perform BSSAP RESET, expect RESET ACK and DISC.ind on connection */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02002155 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 +01002156 interleave {
Neels Hofmeyrf246a922020-05-13 02:27:10 +02002157 [] 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 +01002158 [] BSSAP.receive(tr_BSSAP_DISC_ind(dt.sccp_conn_id, ?, ?)) { }
2159 }
2160
Neels Hofmeyra5302c82018-11-04 23:09:58 +01002161 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002162 f_shutdown_helper();
Harald Welte85804d42017-12-10 14:11:58 +01002163}
2164
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01002165/* Verify T(iar) triggers and releases the channel */
2166testcase TC_chan_rel_sccp_tiar_timeout() runs on test_CT {
2167 var DchanTuple dt;
2168
2169 /* Set T(iar) in BSC low enough that it will trigger before other side
2170 has time to keep alive with a T(ias). Keep recommended ratio of
2171 T(iar) >= T(ias)*2 */
2172 g_bsc_sccp_timer_ias := 2;
2173 g_bsc_sccp_timer_iar := 5;
2174
2175 f_init(1);
2176
2177 dt := f_est_dchan('23'O, 23, '00010203040506'O);
2178 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002179 f_shutdown_helper();
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01002180}
2181
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02002182private function f_tc_chan_rel_rr_cause(myBSSMAP_Cause clear_cmd_cause, template RR_Cause expect_rr_cause)
2183runs on test_CT
2184{
2185 var DchanTuple dt;
2186
2187 dt := f_est_dchan('23'O, 23, '00010203040506'O);
2188 var BssmapCause cause := 0;
2189 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(enum2int(clear_cmd_cause))));
2190 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
2191 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2192 }
2193
2194 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 +02002195}
2196
2197/* Test that Clear Command cause codes affect the RR Channel Release cause code */
2198testcase TC_chan_rel_rr_cause() runs on test_CT {
2199 f_init(1);
2200
2201 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_CALL_CONTROL, GSM48_RR_CAUSE_NORMAL);
2202 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_HANDOVER_SUCCESSFUL, GSM48_RR_CAUSE_NORMAL);
2203 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_PREEMPTION, GSM48_RR_CAUSE_PREMPTIVE_REL);
2204 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_RADIO_INTERFACE_MESSAGE_FAILURE, GSM48_RR_CAUSE_PROT_ERROR_UNSPC);
2205 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_RADIO_INTERFACE_FAILURE, GSM48_RR_CAUSE_ABNORMAL_UNSPEC);
2206 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_EQUIPMENT_FAILURE, GSM48_RR_CAUSE_ABNORMAL_UNSPEC);
Vadim Yanitskiye18aebb2021-01-03 13:10:43 +01002207
2208 f_shutdown_helper();
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02002209}
2210
Harald Welte5cd20ed2017-12-13 21:03:20 +01002211/* Test behavior if RSL EST IND for non-active channel */
2212testcase TC_rll_est_ind_inact_lchan() runs on test_CT {
2213 timer T := 2.0;
2214
Harald Welte89d42e82017-12-17 16:42:41 +01002215 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01002216
2217 var octetstring l3 := '00010203040506'O;
2218 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
2219 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
2220
2221 T.start;
2222 alt {
2223 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
2224 setverdict(fail, "MSC received COMPL L3 for non-active lchan");
2225 }
2226 [] BSSAP.receive {}
2227 [] IPA_RSL[0].receive {}
2228 [] T.timeout {}
2229 }
2230
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002231 f_shutdown_helper();
Harald Welte5cd20ed2017-12-13 21:03:20 +01002232}
2233
2234/* Test behavior if RSL EST IND for invalid SAPI */
2235testcase TC_rll_est_ind_inval_sapi1() runs on test_CT {
2236 var RslChannelNr chan_nr;
2237
Harald Welte89d42e82017-12-17 16:42:41 +01002238 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01002239
2240 chan_nr := f_chreq_act_ack()
2241
2242 var octetstring l3 := '00010203040506'O;
2243 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(1)), l3));
2244
2245 timer T := 2.0;
2246 T.start;
2247 alt {
2248 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
2249 setverdict(fail, "MSC received COMPL L3 for invalid SAPI 1");
2250 }
2251 [] BSSAP.receive { repeat; }
2252 [] IPA_RSL[0].receive { repeat; }
2253 [] T.timeout {}
2254 }
2255
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002256 f_shutdown_helper();
Harald Welte5cd20ed2017-12-13 21:03:20 +01002257}
2258
2259/* Test behavior if RSL EST IND for invalid SAPI */
2260testcase TC_rll_est_ind_inval_sapi3() runs on test_CT {
2261 timer T := 2.0;
2262
Harald Welte89d42e82017-12-17 16:42:41 +01002263 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01002264
2265 var RslChannelNr chan_nr := f_chreq_act_ack();
2266
2267 var octetstring l3 := '00010203040506'O;
2268 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(3)), l3));
2269
2270 T.start;
2271 alt {
2272 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
2273 setverdict(fail, "MSC received COMPL L3 for invalid SAPI 3");
2274 }
2275 [] BSSAP.receive { repeat; }
2276 [] IPA_RSL[0].receive { repeat; }
2277 [] T.timeout {}
2278 }
2279
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002280 f_shutdown_helper();
Harald Welte5cd20ed2017-12-13 21:03:20 +01002281}
2282
2283/* Test behavior if RSL EST IND for invalid SACCH */
2284testcase TC_rll_est_ind_inval_sacch() runs on test_CT {
2285 timer T := 2.0;
2286
Harald Welte89d42e82017-12-17 16:42:41 +01002287 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01002288
2289 var RslChannelNr chan_nr := f_chreq_act_ack();
2290
2291 var octetstring l3 := '00010203040506'O;
2292 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_SACCH(0)), l3));
2293
2294 T.start;
2295 alt {
2296 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
2297 setverdict(fail, "MSC received COMPL L3 for invalid Link SACCH");
2298 }
2299 [] BSSAP.receive { repeat; }
2300 [] IPA_RSL[0].receive { repeat; }
2301 [] T.timeout {}
2302 }
2303
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002304 f_shutdown_helper();
Harald Welte5cd20ed2017-12-13 21:03:20 +01002305}
2306
Vadim Yanitskiy61f784a2020-10-01 21:12:19 +07002307/* Verify DLCI / RSL Link ID conversion for MO/MT messages on SAPI0/SAPI3 */
2308private function f_TC_tch_dlci_link_id_sapi(charstring id) runs on MSC_ConnHdlr {
2309 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2310 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2311
2312 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2313 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
2314
2315 f_establish_fully(ass_cmd, exp_compl);
2316
2317 /* SAPI0 has already been established by f_establish_fully(), establish SAPI3 */
2318 RSL.send(ts_RSL_EST_IND(g_chan_nr, ts_RslLinkID_SACCH(3), '0904'O));
2319 /* Expect BSSAP/DTAP on SAPI3 (DLCI IE) */
2320 BSSAP.receive(PDU_BSSAP:{
2321 discriminator := '1'B,
2322 spare := '0000000'B,
2323 dlci := 'C3'O,
2324 lengthIndicator := ?,
2325 pdu := { dtap := '0904'O }
2326 });
2327
2328 /* Send messages on DCCH/SAPI0 and ACCH/SAPI3 */
2329 for (var integer i := 0; i < 32; i := i + 1) {
2330 var octetstring l3 := '09'O & f_rnd_octstring(14);
2331 var template (value) RslLinkId link_id;
2332 var template (value) OCT1 dlci;
2333
2334 if (i mod 2 == 0) {
2335 /* SAPI0 on FACCH or SDCCH */
2336 link_id := ts_RslLinkID_DCCH(0);
2337 dlci := '80'O;
2338 } else {
2339 /* SAPI3 on SACCH */
2340 link_id := ts_RslLinkID_SACCH(3);
2341 dlci := 'C3'O;
2342 }
2343
2344 /* Send MO message: RSL -> BSSAP */
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00002345 f_mo_l3_transceive(RSL, link_id, dlci, l3);
Vadim Yanitskiy61f784a2020-10-01 21:12:19 +07002346 /* Send MT message: BSSAP -> RSL */
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00002347 f_mt_l3_transceive(RSL, link_id, dlci, l3);
Vadim Yanitskiy61f784a2020-10-01 21:12:19 +07002348 }
2349}
2350testcase TC_tch_dlci_link_id_sapi() runs on test_CT {
2351 var TestHdlrParams pars := f_gen_test_hdlr_pars();
2352 var MSC_ConnHdlr vc_conn;
2353
2354 f_init(1, true);
2355 f_sleep(1.0);
2356
2357 vc_conn := f_start_handler(refers(f_TC_tch_dlci_link_id_sapi), pars);
2358 vc_conn.done;
2359
2360 f_shutdown_helper();
2361}
2362
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07002363private function f_exp_sapi_n_reject(template (present) GsmSapi sapi := ?,
2364 template myBSSMAP_Cause cause := ?,
2365 float T_val := 2.0)
2366runs on test_CT {
2367 var BSSAP_N_DATA_ind rx_di;
2368 timer T;
2369
2370 var template BSSMAP_IE_Cause tr_cause := tr_BSSMAP_IE_Cause(cause);
2371 var template PDU_BSSAP tr_pdu := tr_BSSMAP_SAPInReject(sapi);
2372
2373 T.start(T_val);
2374 alt {
2375 [] BSSAP.receive(tr_BSSAP_DATA_ind(?, tr_pdu)) -> value rx_di {
2376 var BSSMAP_IE_Cause rx_cause := rx_di.userData.pdu.bssmap.sAPInReject.cause;
2377 if (not match(rx_cause, tr_cause)) {
2378 setverdict(fail, "Rx unexpected Cause IE: ",
2379 rx_cause, " vs expected ", tr_cause);
2380 }
2381 setverdict(pass);
2382 }
2383 [] BSSAP.receive(BSSAP_N_DATA_ind:?) -> value rx_di {
2384 setverdict(fail, "Rx unexpected BSSAP PDU: ", rx_di);
2385 }
2386 [] T.timeout {
2387 setverdict(fail, "Timeout waiting for BSSMAP SAPI N Reject");
2388 }
2389 }
2390}
2391
2392/* Check if we get SAPI N Reject on receipt of unexpected RLL RELease INDication */
2393testcase TC_rll_rel_ind_sapi_n_reject() runs on test_CT {
2394 var octetstring rnd_data := f_rnd_octstring(16);
2395 var RSL_Message rx_rsl;
2396 var DchanTuple dt;
2397
2398 f_init(1);
2399
2400 /* MS establishes a SAPI=0 link on DCCH */
2401 dt := f_est_dchan(f_rnd_ra_cs(), 23, rnd_data);
2402
2403 /* MSC sends some data on (not yet established) SAPI=3 link */
2404 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSAP_DTAP(rnd_data, '03'O)));
2405 /* BSC attempts to establish a SAPI=3 link on DCCH */
2406 rx_rsl := f_exp_ipa_rx(0, tr_RSL_EST_REQ(dt.rsl_chan_nr, tr_RslLinkID_DCCH(3)));
2407
2408 /* MS sends unexpected RELease INDication on SAPI=3 */
2409 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, ts_RslLinkID_DCCH(3)));
2410 /* We expect to receive BSSMAP SAPI N Reject message from the BSC */
2411 f_exp_sapi_n_reject(3, GSM0808_CAUSE_MS_NOT_EQUIPPED);
2412
2413 /* Clean up the connection */
2414 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2415 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
2416
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002417 f_shutdown_helper();
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07002418}
2419
2420/* Check if we get SAPI N Reject on receipt of unexpected RLL ERROR INDication */
2421testcase TC_rll_err_ind_sapi_n_reject() runs on test_CT {
2422 var octetstring rnd_data := f_rnd_octstring(16);
2423 var RSL_Message rx_rsl;
2424 var DchanTuple dt;
2425
2426 f_init(1);
2427
2428 /* MS establishes a SAPI=0 link on DCCH */
2429 dt := f_est_dchan(f_rnd_ra_cs(), 23, rnd_data);
2430
2431 /* MSC sends some data on (not yet established) SAPI=3 link */
2432 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSAP_DTAP(rnd_data, '03'O)));
2433 /* BSC attempts to establish a SAPI=3 link on DCCH */
2434 rx_rsl := f_exp_ipa_rx(0, tr_RSL_EST_REQ(dt.rsl_chan_nr, tr_RslLinkID_DCCH(3)));
2435
2436 /* BTS sends unexpected ERROR INDication on SAPI=3 */
2437 f_ipa_tx(0, ts_RSL_ERROR_IND(dt.rsl_chan_nr, ts_RslLinkID_DCCH(3), ''O));
2438 /* We expect to receive BSSMAP SAPI N Reject message from the BSC */
2439 f_exp_sapi_n_reject(3, GSM0808_CAUSE_BSS_NOT_EQUIPPED);
2440
2441 /* Clean up the connection */
2442 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2443 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
2444
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002445 f_shutdown_helper();
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07002446}
2447
2448/* Check if we get SAPI N Reject due to a SAPI=3 link establishment timeout */
2449testcase TC_rll_timeout_sapi_n_reject() runs on test_CT {
2450 var octetstring rnd_data := f_rnd_octstring(16);
2451 var RSL_Message rx_rsl;
2452 var DchanTuple dt;
2453
2454 f_init(1);
2455
2456 /* MS establishes a SAPI=0 link on DCCH */
2457 dt := f_est_dchan(f_rnd_ra_cs(), 23, rnd_data);
2458
2459 /* MSC sends some data on (not yet established) SAPI=3 link */
2460 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSAP_DTAP(rnd_data, '03'O)));
2461 /* BSC attempts to establish a SAPI=3 link on DCCH */
2462 rx_rsl := f_exp_ipa_rx(0, tr_RSL_EST_REQ(dt.rsl_chan_nr, tr_RslLinkID_DCCH(3)));
2463
2464 /* MS does not respond, so the link establishment timeout triggers SAPI N Reject */
2465 f_exp_sapi_n_reject(3, GSM0808_CAUSE_BSS_NOT_EQUIPPED, T_val := 8.0);
2466
2467 /* Clean up the connection */
2468 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2469 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
2470
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002471 f_shutdown_helper();
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07002472}
2473
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02002474testcase TC_si_default() runs on test_CT {
2475 f_init(0);
2476 f_init_bts_and_check_sysinfo(0, expect_si := SystemInformationConfig_default);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002477 f_shutdown_helper();
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02002478}
Harald Welte4003d112017-12-09 22:35:39 +01002479
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002480/* We're testing SI2quater with lists of EARFCNs. Instead of just incrementing EARFCNs, also pick some from the edges of
2481 * the entire value range. This function provides the same EARFCN numbers for the same earfcn_index */
2482private function f_test_si2quater_earfcn_by_idx(integer earfcn_index) return uint16_t
2483{
2484 select (earfcn_index) {
2485 case (0) {
2486 /* E-ARFCN 111 is already added in the osmo-bsc.cfg */
2487 return 111;
2488 }
2489 case (1) {
2490 return 1;
2491 }
2492 case (2) {
2493 return 0;
2494 }
2495 case (3) {
2496 return 65535;
2497 }
2498 case else {
2499 return 23 * (earfcn_index - 3);
2500 }
2501 }
2502}
2503
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002504function f_test_si2quater(integer total_earfcns, template SystemInformationConfig expect_si,
2505 template CellSelIndValue expect_cells := omit) runs on test_CT {
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002506
2507 f_init(0);
2508
2509 /* E-ARFCN 111 is already added in the osmo-bsc.cfg, so only add more arfcns if total_earfcns > 1 */
2510 for (var integer i := 1; i < total_earfcns; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002511 f_bts_0_cfg(BSCVTY, {"si2quater neighbor-list add earfcn " & int2str(f_test_si2quater_earfcn_by_idx(i))
2512 & " thresh-hi 20 thresh-lo 10 prio 3 qrxlv 22 meas 3"});
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002513 }
2514
2515 f_init_bts_and_check_sysinfo(0, expect_si := expect_si);
2516
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002517 if (not istemplatekind(expect_cells, "omit")) {
2518 /* Also check that RR Channel Release contains these EARFCNs.
2519 * (copied code from TC_chan_rel_hard_clear_csfb) */
2520 var BSSAP_N_DATA_ind rx_di;
2521 var DchanTuple dt;
2522
2523 dt := f_est_dchan('23'O, 23, '00010203040506'O);
Pau Espin Pedrold0046312021-04-19 16:35:58 +02002524 /* Send CommonID with some random PLMN (BSC doesn't take it into account
2525 * yet when generating the EUTRAN neigh list in RR CHannel Release) */
2526 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_CommonId('001019876543210'H, '323454'O)));
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002527
2528 /* Instruct BSC to clear channel */
2529 var BssmapCause cause := 0;
2530 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommandCSFB(cause)));
2531
2532 /* expect Clear Complete from BSC on A */
2533 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
2534 /* release the SCCP connection */
2535 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2536 }
2537
Pau Espin Pedrol841b90d2021-04-15 16:42:52 +02002538 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 +02002539 }
2540
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002541 for (var integer i := 1; i < total_earfcns; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002542 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 +02002543 }
2544}
2545
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002546private function f_tr_si2quater_earfcns(integer count) return template SI2quaterRestOctetsList
2547{
2548 var template SI2quaterRestOctetsList si2quater := {};
2549 var integer si2quater_count := (count + 2) / 3;
2550
2551 for (var integer i := 0; i < count; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002552 var integer earfcn := f_test_si2quater_earfcn_by_idx(i);
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002553 var integer index := i / 3;
2554 var integer earfcn_index := i mod 3;
2555 if (index >= lengthof(si2quater)) {
2556 si2quater[index] := tr_SI2quaterRestOctets_EUTRAN(index := index, count := si2quater_count - 1);
2557 }
2558 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);
2559 }
2560
2561 return si2quater;
2562}
2563
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002564private function f_tr_rr_chan_rel_earfcns(integer count) return template CellSelIndValue
2565{
2566 var template CellSelIndValue_EUTRAN_Descrs cells := {};
2567
Alexander Couzensf74b5cb2020-09-10 22:28:40 +02002568 /* the lte neighbors must match the config & vty to pass this test */
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002569 for (var integer i := 0; i < count; i := i + 1) {
2570 var integer earfcn := f_test_si2quater_earfcn_by_idx(i);
Alexander Couzensf74b5cb2020-09-10 22:28:40 +02002571 cells[i] := tr_CellSelIndValue_EUTRAN_Descr(earfcn, '1'B, 3);
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002572 }
2573
2574 return tr_CellSelIndValue_EUTRAN(cells);
2575}
2576
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002577private function f_tc_si2quater_n_earfcns(integer n) runs on test_CT
2578{
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002579 var template SystemInformationConfig sic := SystemInformationConfig_default;
Pau Espin Pedrol8ab62e42020-12-18 16:19:11 +01002580 sic.si2quater := f_tr_si2quater_earfcns(n);
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002581 var template CellSelIndValue cells := f_tr_rr_chan_rel_earfcns(n);
2582 f_test_si2quater(n, sic, cells);
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002583}
2584
2585testcase TC_si2quater_2_earfcns() runs on test_CT {
2586 f_tc_si2quater_n_earfcns(2);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002587 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002588}
2589
2590testcase TC_si2quater_3_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002591 f_tc_si2quater_n_earfcns(3);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002592 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002593}
2594
2595testcase TC_si2quater_4_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002596 f_tc_si2quater_n_earfcns(4);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002597 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002598}
2599
2600testcase TC_si2quater_5_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002601 f_tc_si2quater_n_earfcns(5);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002602 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002603}
2604
2605testcase TC_si2quater_6_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002606 f_tc_si2quater_n_earfcns(6);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002607 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002608}
2609
2610testcase TC_si2quater_12_earfcns() runs on test_CT {
2611 f_tc_si2quater_n_earfcns(12);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002612 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002613}
2614
2615testcase TC_si2quater_23_earfcns() runs on test_CT {
2616 f_tc_si2quater_n_earfcns(23);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002617 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002618}
2619
2620testcase TC_si2quater_32_earfcns() runs on test_CT {
2621 f_tc_si2quater_n_earfcns(32);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002622 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002623}
2624
2625testcase TC_si2quater_33_earfcns() runs on test_CT {
2626 f_tc_si2quater_n_earfcns(33);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002627 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002628}
2629
2630testcase TC_si2quater_42_earfcns() runs on test_CT {
2631 f_tc_si2quater_n_earfcns(42);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002632 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002633}
2634
2635testcase TC_si2quater_48_earfcns() runs on test_CT {
2636 f_tc_si2quater_n_earfcns(48);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002637 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002638}
2639
2640/* verify the VTY error response when adding too many EARFCNs, and showing that osmo-bsc still sends 16 SI2quater with
2641 * 48 EARFCNs. */
2642testcase TC_si2quater_49_earfcns() runs on test_CT {
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002643 var template SystemInformationConfig sic := SystemInformationConfig_default;
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002644 sic.si2quater := f_tr_si2quater_earfcns(48); /* 48, not 49! */
2645 f_init(0);
2646
2647 for (var integer i := 1; i < 48; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002648 f_bts_0_cfg(BSCVTY, {"si2quater neighbor-list add earfcn " & int2str(f_test_si2quater_earfcn_by_idx(i))
2649 & " thresh-hi 20 thresh-lo 10 prio 3 qrxlv 22 meas 3"});
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002650 }
2651
2652 /* The 49th EARFCN no longer fits, expect VTY error */
2653 f_vty_enter_cfg_bts(BSCVTY, 0);
2654 var charstring vty_error;
2655 vty_error := f_vty_transceive_ret(BSCVTY,
2656 "si2quater neighbor-list add earfcn 70 thresh-hi 20 thresh-lo 10 prio 3 qrxlv 22 meas 3")
2657 f_vty_transceive(BSCVTY, "end");
2658
2659 if (f_strstr(vty_error, "Unable to add ARFCN 70") >= 0) {
2660 log("Got expected VTY error: ", vty_error);
2661 setverdict(pass);
2662 } else {
2663 setverdict(fail, "Expected the 49th EUTRAN ARFCN to be rejected by vty config, got: ", vty_error);
2664 }
2665
2666 f_init_bts_and_check_sysinfo(0, expect_si := sic);
2667
2668 for (var integer i := 1; i < 48; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002669 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 +02002670 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002671 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002672}
2673
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002674private function f_acc09_count_allowed(AccessControlClass acc) return uint8_t
2675{
2676 var uint8_t count := 0;
2677 for (var integer i := 5; i < 16; i := i + 1) {
2678 if (acc[i] == '0'B) { /* the list marks barred, we count allowed */
2679 count := count + 1;
2680 }
2681 }
2682 return count;
2683}
2684
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002685private function f_recv_next_si1(integer rsl_idx := 0) runs on test_CT return SystemInformationType1
2686{
2687 var ASP_RSL_Unitdata rx_rsl_ud;
2688 var SystemInformationType1 last_si1;
2689
2690 timer T := 30.0;
2691 T.start;
2692 alt {
2693 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD((tr_RSL_NO_BCCH_INFO,
2694 tr_RSL_BCCH_INFO,
2695 tr_RSL_NO_SACCH_FILL,
2696 tr_RSL_SACCH_FILL))
2697 ) -> value rx_rsl_ud {
2698 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
2699 if (g_system_information[rsl_idx].si1 == omit) {
2700 repeat;
2701 }
2702 last_si1 := g_system_information[rsl_idx].si1;
2703 g_system_information[rsl_idx].si1 := omit;
2704 T.stop;
2705 }
Vadim Yanitskiy79ebd5e2021-01-04 00:12:55 +01002706 [] IPA_RSL[rsl_idx].receive { repeat; }
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002707 [] T.timeout { setverdict(fail, "Timeout receiving next SI1"); }
2708 }
2709 return last_si1;
2710}
2711
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002712/* verify ACC rotate feature */
2713testcase TC_si_acc_rotate() runs on test_CT {
2714 var template SystemInformationConfig sic := SystemInformationConfig_default;
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002715 var SystemInformationType1 last_si1;
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002716 var AccessControlClass acc;
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002717 var uint8_t count;
2718 var integer times_allowed[10] := { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
2719
2720 f_init(0, guard_timeout := 60.0);
2721
2722 f_bts_0_cfg(BSCVTY, {"rach access-control-class 5 barred",
2723 "access-control-class-rotate 3",
2724 "access-control-class-rotate-quantum 1"});
2725
2726 /* Init and get first sysinfo */
2727 f_init_bts_and_check_sysinfo(0, expect_si := ?);
2728
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002729 for (var integer i:= 0; i < 20; i := i + 1) {
2730 last_si1 := f_recv_next_si1(0);
2731 acc := last_si1.rach_control.acc;
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002732 count := f_acc09_count_allowed(acc);
2733 log("RSL: GOT SI1 ACC len=", count, ": ", acc);
2734
2735 if (count != 3) {
2736 log("RSL: EXPECTED SI ACC len=3");
2737 setverdict(fail, "received SI does not match expectations");
2738 break;
2739 }
2740
2741 for (var integer j := 0; j < 10; j := j + 1) {
2742 if (acc[16 - 1 - j] == '0'B) { /* the list marks barred, we count allowed */
2743 times_allowed[j] := times_allowed[j] + 1;
2744 }
2745 }
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002746 }
2747
2748 for (var integer j := 0; j < 10; j := j + 1) {
2749 log("ACC", j, " allowed ", times_allowed[j], " times" );
2750 if (j != 5 and times_allowed[j] < 3) {
2751 setverdict(fail, "ACC", j, " ERROR: allowed ", times_allowed[j], " < 1 times");
2752 } else if (j == 5 and times_allowed[j] > 0) {
2753 setverdict(fail, "ACC", j, " ERROR: allowed ", times_allowed[j], " > 0 times");
2754 }
2755 }
2756
2757 f_bts_0_cfg(BSCVTY, {"access-control-class-rotate 10",
2758 "rach access-control-class 5 allowed"});
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002759 f_shutdown_helper();
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002760}
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002761
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002762/* verify ACC startup ramp+rotate feature */
2763testcase TC_si_acc_ramp_rotate() runs on test_CT {
2764 var template SystemInformationConfig sic := SystemInformationConfig_default;
2765 var SystemInformationType1 last_si1;
2766 var AccessControlClass acc;
2767 var ASP_RSL_Unitdata rx_rsl_ud;
2768 var uint8_t count;
2769 var uint8_t prev_count;
2770 var integer times_allowed[10] := { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
2771
2772 f_init(0, guard_timeout := 80.0);
2773
2774 f_bts_0_cfg(BSCVTY, {"rach access-control-class 4 barred",
2775 "access-control-class-rotate 0",
2776 "access-control-class-rotate-quantum 1",
2777 "access-control-class-ramping",
2778 "access-control-class-ramping-step-interval 5",
2779 "access-control-class-ramping-step-size 5"});
2780
2781 /* Init and get first sysinfo */
2782 f_init_bts_and_check_sysinfo(0, expect_si := ?);
2783 last_si1 := g_system_information[0].si1;
2784 acc := last_si1.rach_control.acc;
2785 count := f_acc09_count_allowed(acc);
2786 /* Adm subset size was set to 0 above, so wait until all ACC are barred */
2787 while (count > 0) {
2788 last_si1 := f_recv_next_si1(0);
2789 acc := last_si1.rach_control.acc;
2790 count := f_acc09_count_allowed(acc);
2791 log("RSL: wait len()=0: GOT SI1 ACC len=", count, ": ", acc);
2792 }
2793
2794 /* Increase adm subset size, we should see ramping start up */
2795 f_bts_0_cfg(BSCVTY, {"access-control-class-rotate 10"});
2796 prev_count := 0;
2797 while (true) {
2798 last_si1 := f_recv_next_si1(0);
2799 acc := last_si1.rach_control.acc;
2800 count := f_acc09_count_allowed(acc);
2801 log("RSL: GOT SI1 ACC len=", count, ": ", acc);
2802
2803 if (prev_count > count) {
2804 setverdict(fail, "ACC allowed count dropped while expecting grow: ", prev_count, " -> ", count);
2805 break;
2806 }
2807
2808 if (count == 9) {
2809 break; /* Maximum reached (10 - 1 perm barred), done here */
2810 }
2811
2812 prev_count := count;
2813 }
2814
2815 setverdict(pass);
2816
2817 f_bts_0_cfg(BSCVTY, {"access-control-class-rotate 10",
2818 "rach access-control-class 4 allowed",
2819 "no access-control-class-ramping"});
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002820 f_shutdown_helper();
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002821}
2822
Harald Welte4003d112017-12-09 22:35:39 +01002823testcase TC_ctrl_msc_connection_status() runs on test_CT {
2824 var charstring ctrl_resp;
2825
Harald Welte89d42e82017-12-17 16:42:41 +01002826 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01002827
2828 /* See https://osmocom.org/issues/2729 */
2829 f_ctrl_get_exp(IPA_CTRL, "msc_connection_status", "connected");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002830 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01002831}
2832
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01002833testcase TC_ctrl_msc0_connection_status() runs on test_CT {
2834 var charstring ctrl_resp;
2835
2836 f_init(1);
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01002837
2838 f_ctrl_get_exp(IPA_CTRL, "msc.0.connection_status", "connected");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002839 f_shutdown_helper();
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01002840}
2841
Neels Hofmeyr0bc470d2021-08-21 13:37:13 +02002842/* Verify correct stats on the number of configured and connected MSCs */
2843private function f_tc_stat_num_msc_connected_msc_connhdlr(integer expect_num_msc_connected) runs on MSC_ConnHdlr {
2844 g_pars := f_gen_test_hdlr_pars();
2845 var StatsDExpects expect := {
2846 { name := "TTCN3.bsc.0.num_msc.connected", mtype := "g", min := expect_num_msc_connected, max := expect_num_msc_connected },
2847 { name := "TTCN3.bsc.0.num_msc.total", mtype := "g", min := NUM_MSC, max := NUM_MSC }
2848 };
2849 f_statsd_expect(expect);
2850}
2851
2852private function f_tc_stat_num_msc_connected_test_ct(void_fn tc_fn, integer nr_msc) runs on test_CT
2853{
2854 var MSC_ConnHdlr vc_conn;
2855
2856 f_init(nr_bts := 1, handler_mode := true, nr_msc := nr_msc);
2857 f_sleep(1.0);
2858 vc_conn := f_start_handler(tc_fn);
2859 vc_conn.done;
2860
2861 /* Also verify stat exposed on CTRL interface */
2862 f_ctrl_get_exp(IPA_CTRL, "stat_item.last.bsc.0.num_msc:connected", int2str(nr_msc));
2863 f_ctrl_get_exp(IPA_CTRL, "stat_item.last.bsc.0.num_msc:total", int2str(NUM_MSC));
2864
2865 f_shutdown_helper();
2866}
2867
2868/* Verify that when 1 MSC is active, that num_msc:connected reports 1. */
2869private function f_tc_stat_num_msc_connected_1(charstring id) runs on MSC_ConnHdlr {
2870 f_tc_stat_num_msc_connected_msc_connhdlr(1);
2871}
2872testcase TC_stat_num_msc_connected_1() runs on test_CT {
2873 f_tc_stat_num_msc_connected_test_ct(refers(f_tc_stat_num_msc_connected_1), 1);
2874}
2875
2876/* Verify that when 2 MSCs are active, that num_msc:connected reports 2. */
2877private function f_tc_stat_num_msc_connected_2(charstring id) runs on MSC_ConnHdlr {
2878 f_tc_stat_num_msc_connected_msc_connhdlr(2);
2879}
2880testcase TC_stat_num_msc_connected_2() runs on test_CT {
2881 f_tc_stat_num_msc_connected_test_ct(refers(f_tc_stat_num_msc_connected_2), 2);
2882}
2883
2884/* Verify that when 3 MSCs are active, that num_msc:connected reports 3. */
2885private function f_tc_stat_num_msc_connected_3(charstring id) runs on MSC_ConnHdlr {
2886 f_tc_stat_num_msc_connected_msc_connhdlr(3);
2887}
2888testcase TC_stat_num_msc_connected_3() runs on test_CT {
2889 f_tc_stat_num_msc_connected_test_ct(refers(f_tc_stat_num_msc_connected_3), 3);
2890}
2891
Neels Hofmeyr5ce3ae42021-08-29 15:32:00 +02002892/* Verify correct stats on the number of configured and connected MSCs */
2893private function f_tc_stat_num_bts_connected_msc_connhdlr(integer expect_num_bts_connected) runs on MSC_ConnHdlr {
2894 g_pars := f_gen_test_hdlr_pars();
2895 var StatsDExpects expect := {
2896 { name := "TTCN3.bsc.0.num_bts.oml_connected", mtype := "g", min := expect_num_bts_connected, max := NUM_BTS_CFG },
2897 { name := "TTCN3.bsc.0.num_bts.all_trx_rsl_connected", mtype := "g", min := expect_num_bts_connected, max := expect_num_bts_connected },
2898 { name := "TTCN3.bsc.0.num_bts.total", mtype := "g", min := NUM_BTS_CFG, max := NUM_BTS_CFG },
2899 { name := "TTCN3.bsc.0.num_trx.rsl_connected", mtype := "g", min := expect_num_bts_connected, max := expect_num_bts_connected },
2900 { name := "TTCN3.bsc.0.num_trx.total", mtype := "g", min := NUM_BTS_CFG, max := NUM_BTS_CFG }
2901 };
2902 f_statsd_expect(expect);
2903}
2904
2905private function f_tc_stat_num_bts_connected_test_ct(void_fn tc_fn, integer nr_bts) runs on test_CT {
2906 var MSC_ConnHdlr vc_conn;
2907
2908 f_init(nr_bts := nr_bts, handler_mode := true, nr_msc := 1);
2909 f_sleep(1.0);
2910 vc_conn := f_start_handler(tc_fn);
2911 vc_conn.done;
2912
2913 /* Also verify stat exposed on CTRL interface */
2914 f_ctrl_get_exp(IPA_CTRL, "stat_item.last.bsc.0.num_bts:all_trx_rsl_connected", int2str(nr_bts));
2915 f_ctrl_get_exp(IPA_CTRL, "stat_item.last.bsc.0.num_bts:total", int2str(NUM_BTS_CFG));
2916 f_ctrl_get_exp(IPA_CTRL, "stat_item.last.bsc.0.num_trx:rsl_connected", int2str(nr_bts));
2917 f_ctrl_get_exp(IPA_CTRL, "stat_item.last.bsc.0.num_trx:total", int2str(NUM_BTS_CFG));
2918
Neels Hofmeyra41ae302021-09-06 22:06:02 +02002919 /* Verify rf_states exposed on CTRL interface */
2920 var charstring expect_net_rf_states := "";
2921 for (var integer i := 0; i < NUM_BTS_CFG; i := i + 1) {
2922 var charstring expect_bts_rf_states := int2str(i) & ",0,";
2923 if (i < NUM_BTS) {
2924 /* In these tests, OML for the first NUM_BTS are always connected via osmo-bts-omldummy */
2925 expect_bts_rf_states := expect_bts_rf_states & "operational,unlocked,";
2926 } else {
2927 /* For remaining i < NUM_BTS_CFG, OML is not connected, i.e. inoperational */
2928 expect_bts_rf_states := expect_bts_rf_states & "inoperational,locked,";
2929 }
2930 /* The RF policy is still global in osmo-bsc, i.e. always "on" */
2931 expect_bts_rf_states := expect_bts_rf_states & "on,";
2932 if (i < nr_bts) {
2933 /* For BTS where RSL is connected, the RSL state will be "up" */
2934 expect_bts_rf_states := expect_bts_rf_states & "rsl-up;";
2935 } else {
2936 expect_bts_rf_states := expect_bts_rf_states & "rsl-down;";
2937 }
2938
2939 f_ctrl_get_exp(IPA_CTRL, "bts." & int2str(i) & ".rf_states", expect_bts_rf_states);
2940 expect_net_rf_states := expect_net_rf_states & expect_bts_rf_states;
2941 }
2942 f_ctrl_get_exp(IPA_CTRL, "rf_states", expect_net_rf_states);
2943
Neels Hofmeyr5ce3ae42021-08-29 15:32:00 +02002944 f_shutdown_helper();
2945}
2946
2947/* Verify that when 1 BTS is connected, that num_{bts,trx}:*_connected reports 1. */
2948private function f_tc_stat_num_bts_connected_1(charstring id) runs on MSC_ConnHdlr {
2949 f_tc_stat_num_bts_connected_msc_connhdlr(1);
2950}
2951testcase TC_stat_num_bts_connected_1() runs on test_CT {
2952 f_tc_stat_num_bts_connected_test_ct(refers(f_tc_stat_num_bts_connected_1), 1);
2953}
2954
2955/* Verify that when 2 BTS is connected, that num_{bts,trx}:*_connected reports 2. */
2956private function f_tc_stat_num_bts_connected_2(charstring id) runs on MSC_ConnHdlr {
2957 f_tc_stat_num_bts_connected_msc_connhdlr(2);
2958}
2959testcase TC_stat_num_bts_connected_2() runs on test_CT {
2960 f_tc_stat_num_bts_connected_test_ct(refers(f_tc_stat_num_bts_connected_2), 2);
2961}
2962
2963/* Verify that when 3 BTS is connected, that num_{bts,trx}:*_connected reports 3. */
2964private function f_tc_stat_num_bts_connected_3(charstring id) runs on MSC_ConnHdlr {
2965 f_tc_stat_num_bts_connected_msc_connhdlr(3);
2966}
2967testcase TC_stat_num_bts_connected_3() runs on test_CT {
2968 f_tc_stat_num_bts_connected_test_ct(refers(f_tc_stat_num_bts_connected_3), 3);
2969}
2970
Harald Welte4003d112017-12-09 22:35:39 +01002971testcase TC_ctrl() runs on test_CT {
2972 var charstring ctrl_resp;
2973
Harald Welte89d42e82017-12-17 16:42:41 +01002974 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01002975
2976 /* all below values must match the osmo-bsc.cfg config file used */
2977
Harald Welte6a129692018-03-17 17:30:14 +01002978 f_ctrl_get_exp(IPA_CTRL, "mcc", "001");
2979 f_ctrl_get_exp(IPA_CTRL, "mnc", "01");
Oliver Smith75aa0202019-08-19 14:17:50 +02002980 f_ctrl_get_exp(IPA_CTRL, "number-of-bts", "4");
Harald Welte4003d112017-12-09 22:35:39 +01002981
2982 var integer bts_nr := 0;
2983 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "location-area-code", "1");
2984 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "cell-identity", "0");
2985 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "oml-connection-state", "connected");
2986 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "gprs-mode", "gprs");
2987 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "rf_state", "operational,unlocked,on");
2988 f_ctrl_get_exp_trx(IPA_CTRL, bts_nr, 0, "arfcn", "871");
2989 f_ctrl_get_exp_trx(IPA_CTRL, bts_nr, 0, "max-power-reduction", "20");
2990
2991 var integer uptime := str2int(f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-uptime"));
2992 f_sleep(2.0);
2993 if (str2int(f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-uptime")) < uptime+1) {
2994 setverdict(fail, "oml-uptime not incrementing as expected");
2995 }
2996 /* TODO: Disconnect RSL, imply that OML is disconnected and check for uptime zero? */
2997
2998 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted", 0);
2999
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003000 f_shutdown_helper();
Harald Welte96c94412017-12-09 03:12:45 +01003001}
3002
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +02003003/* Verify that Upon receival of SET "location", BSC forwards a TRAP
3004 "location-state" over the SCCPlite IPA conn */
3005testcase TC_ctrl_location() runs on test_CT {
3006 var MSC_ConnHdlr vc_conn;
3007 var integer bts_nr := 0;
3008
3009 f_init(1, true);
3010 f_sleep(1.0);
3011
3012 f_ctrl_set_bts(IPA_CTRL, bts_nr, "location", "1234567,fix3d,0.340000,0.560000,0.780000");
3013 f_ctrl_exp_trap(SCCPLITE_IPA_CTRL, "bts." & int2str(bts_nr) & ".location-state",
3014 "1234567,fix3d,0.340000,0.560000,0.780000,operational,unlocked,on,001,01");
3015
3016 f_ctrl_set(SCCPLITE_IPA_CTRL, "rf_locked", "1");
3017 f_sleep(2.0);
3018
3019 f_ctrl_set_bts(IPA_CTRL, bts_nr, "location", "1234888,fix3d,0.350000,0.570000,0.790000");
3020 f_ctrl_exp_trap(SCCPLITE_IPA_CTRL, "bts." & int2str(bts_nr) & ".location-state",
3021 "1234888,fix3d,0.350000,0.570000,0.790000,operational,locked,off,001,01");
3022
3023 /* should match the one from config */
3024 f_ctrl_set(SCCPLITE_IPA_CTRL, "rf_locked", "0");
3025
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003026 f_shutdown_helper();
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +02003027}
3028
Harald Welte6f521d82017-12-11 19:52:02 +01003029
3030/***********************************************************************
3031 * Paging Testing
3032 ***********************************************************************/
3033
3034type record Cell_Identity {
3035 GsmMcc mcc,
3036 GsmMnc mnc,
3037 GsmLac lac,
3038 GsmCellId ci
3039};
Harald Welte24135bd2018-03-17 19:27:53 +01003040private const Cell_Identity cid := { '001'H, '01'H, 1, 0 };
Stefan Sperling049a86e2018-03-20 15:51:00 +01003041private const Cell_Identity unknown_cid := { '678'H, 'f90'H, 1, 0 };
Harald Welte6f521d82017-12-11 19:52:02 +01003042
Harald Welte5d1a2202017-12-13 19:51:29 +01003043type set of integer BtsIdList;
3044
3045private function f_bts_in_list(integer bts_id, BtsIdList bts_ids) return boolean {
3046 for (var integer j := 0; j < sizeof(bts_ids); j := j + 1) {
3047 if (bts_id == bts_ids[j]) {
3048 return true;
3049 }
3050 }
3051 return false;
3052}
Harald Welte6f521d82017-12-11 19:52:02 +01003053
3054/* core paging test helper function; used by most paging test cases */
3055private function f_pageing_helper(hexstring imsi,
3056 template BSSMAP_FIELD_CellIdentificationList cid_list,
Harald Welte5d1a2202017-12-13 19:51:29 +01003057 BtsIdList bts_ids := { 0 },
Harald Welte6f521d82017-12-11 19:52:02 +01003058 template RSL_ChanNeeded rsl_chneed := omit,
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07003059 template (omit) OCT4 tmsi := omit) runs on test_CT
Harald Welte6f521d82017-12-11 19:52:02 +01003060{
3061 var template BSSMAP_IE_ChannelNeeded bssmap_chneed;
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07003062 var template MobileIdentityV mi;
Harald Welte6f521d82017-12-11 19:52:02 +01003063 var RSL_Message rx_rsl;
3064 var integer paging_group := hex2int(imsi[lengthof(imsi)-1]);
Harald Welte5d1a2202017-12-13 19:51:29 +01003065 var integer i;
Harald Welte6f521d82017-12-11 19:52:02 +01003066
3067 f_init();
Harald Welte6f521d82017-12-11 19:52:02 +01003068
3069 /* Clear the queue, it might still contain stuff like BCCH FILLING */
Harald Weltec3068592018-03-17 19:55:31 +01003070 for (i := 0; i < NUM_BTS; i := i + 1) {
3071 IPA_RSL[i].clear;
Harald Welte5d1a2202017-12-13 19:51:29 +01003072 }
Harald Welte6f521d82017-12-11 19:52:02 +01003073
3074 if (isvalue(rsl_chneed)) {
3075 /* The values of 08.08 3.2.2.36 and 08.58 9.3.40 are luckily identical */
3076 bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
3077 } else {
3078 bssmap_chneed := omit;
3079 }
3080
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003081 BSSAP.send(ts_BSSAP_UNITDATA_req(g_bssap[0].sccp_addr_peer, g_bssap[0].sccp_addr_own,
3082 ts_BSSMAP_Paging(imsi, cid_list, tmsi, bssmap_chneed)));
Harald Welte6f521d82017-12-11 19:52:02 +01003083
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07003084 if (not istemplatekind(tmsi, "omit")) {
3085 mi := t_MI_TMSI(tmsi);
Harald Welte6f521d82017-12-11 19:52:02 +01003086 } else {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07003087 mi := tr_MI_IMSI(imsi);
Harald Welte6f521d82017-12-11 19:52:02 +01003088 }
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07003089
Harald Welte5d1a2202017-12-13 19:51:29 +01003090 for (i := 0; i < sizeof(bts_ids); i := i + 1) {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07003091 rx_rsl := f_exp_ipa_rx(bts_ids[i], tr_RSL_PAGING_CMD(mi));
Harald Welte5d1a2202017-12-13 19:51:29 +01003092 /* check channel type, paging group */
3093 if (rx_rsl.ies[1].body.paging_group != paging_group) {
3094 setverdict(fail, "Paging for wrong paging group");
3095 }
3096 if (ispresent(rsl_chneed) and
3097 rx_rsl.ies[3].body.chan_needed.chan_needed != valueof(rsl_chneed)) {
3098 setverdict(fail, "RSL Channel Needed != BSSMAP Channel Needed");
3099 }
Harald Welte6f521d82017-12-11 19:52:02 +01003100 }
Harald Welte2fccd982018-01-31 15:48:19 +01003101 f_sleep(2.0);
Harald Welte5d1a2202017-12-13 19:51:29 +01003102 /* do a quick check on all not-included BTSs if they received paging */
3103 for (i := 0; i < NUM_BTS; i := i + 1) {
3104 timer T := 0.1;
3105 if (f_bts_in_list(i, bts_ids)) {
3106 continue;
3107 }
3108 T.start;
3109 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07003110 [] IPA_RSL[i].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(mi))) {
Harald Welte5d1a2202017-12-13 19:51:29 +01003111 setverdict(fail, "Paging on BTS ", i, " which is not part of ", bts_ids);
3112 }
3113 [] IPA_RSL[i].receive { repeat; }
3114 [] T.timeout { }
3115 }
Harald Welte6f521d82017-12-11 19:52:02 +01003116 }
3117
3118 setverdict(pass);
3119}
3120
Harald Welte5d1a2202017-12-13 19:51:29 +01003121const BtsIdList c_BtsId_all := { 0, 1, 2 };
Harald Welte751d3eb2018-01-31 15:51:06 +01003122const BtsIdList c_BtsId_none := { };
Harald Welte5d1a2202017-12-13 19:51:29 +01003123const BtsIdList c_BtsId_LAC1 := { 0, 1 };
3124const BtsIdList c_BtsId_LAC2 := { 2 };
3125
Harald Welte6f521d82017-12-11 19:52:02 +01003126/* PAGING by IMSI + TMSI */
3127testcase TC_paging_imsi_nochan() runs on test_CT {
3128 var BSSMAP_FIELD_CellIdentificationList cid_list;
3129 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Philipp Maier8c04b0a2018-02-23 13:48:48 +01003130 f_pageing_helper('001010100000001'H, cid_list, c_BtsId_all, omit, omit);
Philipp Maier282ca4b2018-02-27 17:17:00 +01003131 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01003132}
3133
3134/* PAGING by IMSI + TMSI */
3135testcase TC_paging_tmsi_nochan() runs on test_CT {
3136 var BSSMAP_FIELD_CellIdentificationList cid_list;
3137 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01003138 f_pageing_helper('001010100000001'H, cid_list, c_BtsId_all, omit, 'A1B2C301'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01003139 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01003140}
3141
3142/* Paging with different "channel needed' values */
3143testcase TC_paging_tmsi_any() runs on test_CT {
3144 var BSSMAP_FIELD_CellIdentificationList cid_list;
3145 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01003146 f_pageing_helper('001010100000002'H, cid_list, c_BtsId_all, RSL_CHANNEED_ANY, 'A1B2C302'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01003147 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01003148}
3149testcase TC_paging_tmsi_sdcch() runs on test_CT {
3150 var BSSMAP_FIELD_CellIdentificationList cid_list;
3151 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01003152 f_pageing_helper('001010100000003'H, cid_list, c_BtsId_all, RSL_CHANNEED_SDCCH, 'A1B2C303'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01003153 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01003154}
3155testcase TC_paging_tmsi_tch_f() runs on test_CT {
3156 var BSSMAP_FIELD_CellIdentificationList cid_list;
3157 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01003158 f_pageing_helper('001010000000004'H, cid_list, c_BtsId_all, RSL_CHANNEED_TCH_F, 'A1B2C304'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01003159 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01003160}
3161testcase TC_paging_tmsi_tch_hf() runs on test_CT {
3162 var BSSMAP_FIELD_CellIdentificationList cid_list;
3163 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01003164 f_pageing_helper('001010000000005'H, cid_list, c_BtsId_all, RSL_CHANNEED_TCH_ForH, 'A1B2C305'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01003165 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01003166}
3167
3168/* Paging by CGI */
3169testcase TC_paging_imsi_nochan_cgi() runs on test_CT {
3170 var template BSSMAP_FIELD_CellIdentificationList cid_list;
3171 cid_list := { cIl_CGI := { ts_BSSMAP_CI_CGI(cid.mcc, cid.mnc, cid.lac, cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01003172 f_pageing_helper('001010000000006'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01003173 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01003174}
3175
3176/* Paging by LAC+CI */
3177testcase TC_paging_imsi_nochan_lac_ci() runs on test_CT {
3178 var template BSSMAP_FIELD_CellIdentificationList cid_list;
3179 cid_list := { cIl_LAC_CI := { ts_BSSMAP_CI_LAC_CI(cid.lac, cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01003180 f_pageing_helper('001010000000007'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01003181 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01003182}
3183
3184/* Paging by CI */
3185testcase TC_paging_imsi_nochan_ci() runs on test_CT {
3186 var template BSSMAP_FIELD_CellIdentificationList cid_list;
3187 cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01003188 f_pageing_helper('001010000000008'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01003189 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01003190}
3191
3192/* Paging by LAI */
3193testcase TC_paging_imsi_nochan_lai() runs on test_CT {
3194 var template BSSMAP_FIELD_CellIdentificationList cid_list;
3195 cid_list := { cIl_LAI := { ts_BSSMAP_CI_LAI(cid.mcc, cid.mnc, cid.lac) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01003196 f_pageing_helper('001010000000009'H, cid_list, c_BtsId_LAC1);
Philipp Maier282ca4b2018-02-27 17:17:00 +01003197 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01003198}
3199
3200/* Paging by LAC */
3201testcase TC_paging_imsi_nochan_lac() runs on test_CT {
3202 var template BSSMAP_FIELD_CellIdentificationList cid_list;
3203 cid_list := { cIl_LAC := { ts_BSSMAP_CI_LAC(cid.lac) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01003204 f_pageing_helper('001010000000010'H, cid_list, c_BtsId_LAC1);
Philipp Maier282ca4b2018-02-27 17:17:00 +01003205 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01003206}
3207
3208/* Paging by "all in BSS" */
3209testcase TC_paging_imsi_nochan_all() runs on test_CT {
3210 var template BSSMAP_FIELD_CellIdentificationList cid_list;
3211 cid_list := { cIl_allInBSS := ''O };
Harald Welte5d1a2202017-12-13 19:51:29 +01003212 f_pageing_helper('001010000000011'H, cid_list, c_BtsId_all);
Philipp Maier282ca4b2018-02-27 17:17:00 +01003213 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01003214}
3215
Stefan Sperling7b5e1782018-03-20 19:32:43 +01003216/* Paging by PLMN+LAC+RNC; We do not implement this; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01003217testcase TC_paging_imsi_nochan_plmn_lac_rnc() runs on test_CT {
3218 var template BSSMAP_FIELD_CellIdentificationList cid_list;
3219 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 +01003220 f_pageing_helper('001010000000012'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01003221 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01003222}
Harald Welte6f521d82017-12-11 19:52:02 +01003223
Stefan Sperling7b5e1782018-03-20 19:32:43 +01003224/* Paging by RNC; We do not implement this; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01003225testcase TC_paging_imsi_nochan_rnc() runs on test_CT {
3226 var template BSSMAP_FIELD_CellIdentificationList cid_list;
3227 cid_list := { cIl_RNC := { int2oct(13, 2) } };
Stefan Sperling7b5e1782018-03-20 19:32:43 +01003228 f_pageing_helper('001010000000013'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01003229 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01003230}
3231
Stefan Sperling7b5e1782018-03-20 19:32:43 +01003232/* Paging by LAC+RNC; We do not implement; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01003233testcase TC_paging_imsi_nochan_lac_rnc() runs on test_CT {
3234 var template BSSMAP_FIELD_CellIdentificationList cid_list;
3235 cid_list := { cIl_LAC_RNC := { ts_BSSMAP_CI_LAC_RNC(cid.lac, 14) } };
Stefan Sperling7b5e1782018-03-20 19:32:43 +01003236 f_pageing_helper('001010000000014'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01003237 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01003238}
3239
Harald Welte6f521d82017-12-11 19:52:02 +01003240/* Paging on multiple cells (multiple entries in list): Verify all of them page */
Harald Welte751d3eb2018-01-31 15:51:06 +01003241testcase TC_paging_imsi_nochan_lacs() runs on test_CT {
3242 var template BSSMAP_FIELD_CellIdentificationList cid_list;
3243 cid_list := { cIl_LAC := { ts_BSSMAP_CI_LAC(1), ts_BSSMAP_CI_LAC(2) } };
3244 f_pageing_helper('001010000000015'H, cid_list, c_BtsId_all);
Philipp Maier282ca4b2018-02-27 17:17:00 +01003245 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01003246}
3247
3248/* Paging on empty list: Verify none of them page */
3249testcase TC_paging_imsi_nochan_lacs_empty() runs on test_CT {
3250 var template BSSMAP_FIELD_CellIdentificationList cid_list;
3251 cid_list := { cIl_LAC := { } };
3252 f_pageing_helper('001010000000016'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01003253 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01003254}
3255
Stefan Sperling049a86e2018-03-20 15:51:00 +01003256/* Paging by CGI with unknown MCC/MNC: Verify nothing is paged. */
3257testcase TC_paging_imsi_nochan_cgi_unknown_cid() runs on test_CT {
3258 var template BSSMAP_FIELD_CellIdentificationList cid_list;
3259 cid_list := { cIl_CGI := { ts_BSSMAP_CI_CGI(unknown_cid.mcc, unknown_cid.mnc, unknown_cid.lac, unknown_cid.ci) } };
3260 f_pageing_helper('001010000000006'H, cid_list, c_BtsId_none);
3261 f_shutdown_helper();
3262}
3263
Harald Welte6f521d82017-12-11 19:52:02 +01003264/* Verify paging retransmission interval + count */
3265/* Verify paging stops after channel establishment */
Harald Welte6f521d82017-12-11 19:52:02 +01003266/* Test behavior under paging overload */
Harald Welteae026692017-12-09 01:03:01 +01003267
Harald Weltee65d40e2017-12-13 00:09:06 +01003268/* Verify PCH load */
3269testcase TC_paging_imsi_load() runs on test_CT {
3270 var BSSMAP_FIELD_CellIdentificationList cid_list;
3271 timer T := 4.0;
Harald Welte2caa1062018-03-17 18:19:05 +01003272 timer T_retrans := 1.0;
Harald Weltee65d40e2017-12-13 00:09:06 +01003273 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01003274 f_pageing_helper('001010123456789'H, cid_list, c_BtsId_all);
Harald Weltee65d40e2017-12-13 00:09:06 +01003275
3276 /* tell BSC there is no paging space anymore */
3277 f_ipa_tx(0, ts_RSL_PAGING_LOAD_IND(0));
Harald Welte3b57ab52018-03-17 18:01:10 +01003278 f_sleep(0.2);
3279 IPA_RSL[0].clear;
Harald Weltee65d40e2017-12-13 00:09:06 +01003280
3281 /* Wait for 4 seconds if any more PAGING CMD are received on RSL. Normally,
3282 * there would be 8 retransmissions during 4 seconds */
3283 T.start;
Harald Welte2caa1062018-03-17 18:19:05 +01003284 T_retrans.start;
Harald Weltee65d40e2017-12-13 00:09:06 +01003285 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07003286 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Weltee65d40e2017-12-13 00:09:06 +01003287 setverdict(fail, "Received PAGING after LOAD_IND(0)");
Daniel Willmannafce8662018-07-06 23:11:32 +02003288 mtc.stop;
Harald Weltee65d40e2017-12-13 00:09:06 +01003289 }
Harald Welte2caa1062018-03-17 18:19:05 +01003290 [] T_retrans.timeout {
3291 /* re-trnsmit the zero-space LOAD IND to avoid BSC 'auto credit' */
3292 f_ipa_tx(0, ts_RSL_PAGING_LOAD_IND(0));
3293 T_retrans.start;
3294 repeat;
3295 }
Harald Weltee65d40e2017-12-13 00:09:06 +01003296 [] T.timeout {
3297 setverdict(pass);
3298 }
3299 }
Philipp Maier282ca4b2018-02-27 17:17:00 +01003300
3301 f_shutdown_helper();
Harald Weltee65d40e2017-12-13 00:09:06 +01003302}
3303
Harald Welte235ebf12017-12-15 14:18:16 +01003304/* Verify Paging Counter */
Harald Welte1ff69992017-12-14 12:31:17 +01003305testcase TC_paging_counter() runs on test_CT {
3306 var BSSMAP_FIELD_CellIdentificationList cid_list;
3307 timer T := 4.0;
3308 var integer i;
3309 var integer paging_attempted_bsc;
3310 var integer paging_attempted_bts[NUM_BTS];
3311 var integer paging_expired_bts[NUM_BTS];
3312 cid_list := valueof(ts_BSSMAP_CIL_noCell);
3313
3314 f_init();
3315
3316 /* read counters before paging */
3317 paging_attempted_bsc := f_ctrl_get_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted");
3318 for (i := 0; i < NUM_BTS; i := i+1) {
3319 paging_attempted_bts[i] := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", i, "paging:attempted");
3320 paging_expired_bts[i] := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", i, "paging:expired");
3321 }
3322
3323 f_pageing_helper('001230000000001'H, cid_list, c_BtsId_all);
3324
3325 /* expect the attempted pages on BSC and each BTSs to have incremented by one */
3326 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted", paging_attempted_bsc+1);
3327 for (i := 0; i < NUM_BTS; i := i+1) {
3328 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", i, "paging:attempted",
3329 paging_attempted_bts[i]+1);
3330 }
3331
3332 /* assume that 12s later the paging on all BTSs have expired and hence incremented by 1 */
3333 f_sleep(12.0);
3334 for (i := 0; i < NUM_BTS; i := i+1) {
3335 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", i, "paging:expired",
3336 paging_expired_bts[i]+1);
3337 }
Harald Welte1ff69992017-12-14 12:31:17 +01003338
Philipp Maier282ca4b2018-02-27 17:17:00 +01003339 f_shutdown_helper();
Harald Welte1ff69992017-12-14 12:31:17 +01003340}
3341
3342
Harald Welte10985002017-12-12 09:29:15 +01003343/* Verify paging stops after A-RESET */
3344testcase TC_paging_imsi_a_reset() runs on test_CT {
3345 var BSSMAP_FIELD_CellIdentificationList cid_list;
3346 timer T := 3.0;
3347 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01003348 f_pageing_helper('001010123456789'H, cid_list, c_BtsId_all);
Harald Welte10985002017-12-12 09:29:15 +01003349
3350 /* Perform a BSSMAP Reset and wait for ACK */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003351 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 +01003352 alt {
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003353 [] 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 +01003354 [] BSSAP.receive { repeat; }
3355 }
3356
Daniel Willmanncbef3982018-07-30 09:22:40 +02003357 /* Wait to avoid a possible race condition if a paging message is
3358 * received right before the reset ACK. */
3359 f_sleep(0.2);
3360
Harald Welte10985002017-12-12 09:29:15 +01003361 /* Clear the queue, it might still contain stuff like BCCH FILLING */
Philipp Maier1e6b4422018-02-23 14:02:13 +01003362 for (var integer i := 0; i < sizeof(IPA_RSL); i := i+1) {
3363 IPA_RSL[i].clear;
3364 }
Harald Welte10985002017-12-12 09:29:15 +01003365
3366 /* Wait for 3 seconds if any more PAGING CMD are received on RSL */
3367 T.start;
3368 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07003369 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Welte10985002017-12-12 09:29:15 +01003370 setverdict(fail, "Received PAGING after A-RESET");
Daniel Willmannafce8662018-07-06 23:11:32 +02003371 mtc.stop;
Harald Welte10985002017-12-12 09:29:15 +01003372 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07003373 [] IPA_RSL[1].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Welte5d1a2202017-12-13 19:51:29 +01003374 setverdict(fail, "Received PAGING after A-RESET");
Daniel Willmannafce8662018-07-06 23:11:32 +02003375 mtc.stop;
Harald Welte5d1a2202017-12-13 19:51:29 +01003376 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07003377 [] IPA_RSL[2].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Welte5d1a2202017-12-13 19:51:29 +01003378 setverdict(fail, "Received PAGING after A-RESET");
Daniel Willmannafce8662018-07-06 23:11:32 +02003379 mtc.stop;
Harald Welte5d1a2202017-12-13 19:51:29 +01003380 }
Harald Welte10985002017-12-12 09:29:15 +01003381 [] T.timeout {
3382 setverdict(pass);
3383 }
3384 }
Philipp Maier282ca4b2018-02-27 17:17:00 +01003385
3386 f_shutdown_helper();
Harald Welte10985002017-12-12 09:29:15 +01003387}
Harald Welteae026692017-12-09 01:03:01 +01003388
Philipp Maierf45824a2019-08-14 14:44:10 +02003389/* Verify how we handle unsolicited Paging Response. In case of an unsolicit
3390 * paging response we can not know which MSC is in charge, so we will blindly
3391 * pick the first configured MSC. This behavior is required in order to make
3392 * MT-CSFB calls working because in those cases the BSC can not know that the
3393 * MSC has already paged the subscriver via SGs. So any MT-CSFB call will look
3394 * like an unsolicited Paging Response to the MSC.
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003395 */
3396testcase TC_paging_resp_unsol() runs on test_CT {
3397
3398 f_init(1);
Philipp Maierf45824a2019-08-14 14:44:10 +02003399 timer T := 5.0;
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003400
3401 var BSSAP_N_CONNECT_ind rx_c_ind;
3402 var DchanTuple dt;
3403 var PDU_ML3_MS_NW l3 := valueof(ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010008880018'H))));
Philipp Maierf45824a2019-08-14 14:44:10 +02003404 var octetstring rr_pag_resp := enc_PDU_ML3_MS_NW(l3);
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003405
3406 /* Send CHAN RQD and wait for allocation; acknowledge it */
3407 dt.rsl_chan_nr := f_chreq_act_ack();
3408
3409 /* Send unsolicited Paging response (no matching Paging CMD stored in BSC) */
3410 f_ipa_tx(0, ts_RSL_EST_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)), enc_PDU_ML3_MS_NW(l3)));
3411
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003412
Philipp Maierf45824a2019-08-14 14:44:10 +02003413 /* Expevct a CR with a matching Paging response on the A-Interface */
3414 T.start;
3415 alt {
3416 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(rr_pag_resp))) {
3417 setverdict(pass);
3418 }
3419 [] BSSAP.receive {
3420 setverdict(fail, "Received unexpected message on A-Interface!");
3421 }
3422 [] T.timeout {
3423 setverdict(fail, "Received nothing on A-Interface!");
3424 }
3425 }
3426
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003427 f_shutdown_helper();
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003428}
3429
Harald Welte4e9b9cc2017-12-14 18:31:02 +01003430/* Test RSL link drop causes counter increment */
3431testcase TC_rsl_drop_counter() runs on test_CT {
3432 var integer rsl_fail;
3433
Harald Welte89d42e82017-12-17 16:42:41 +01003434 f_init(1);
Harald Welte4e9b9cc2017-12-14 18:31:02 +01003435
3436 rsl_fail := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "rsl_fail");
3437
3438 bts[0].rsl.vc_IPA.stop;
3439
3440 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "rsl_fail", rsl_fail+1);
3441
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003442 f_shutdown_helper();
Harald Welte4e9b9cc2017-12-14 18:31:02 +01003443}
3444
3445/* TODO: Test OML link drop causes counter increment */
3446
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003447/* The body of TC_rsl_unknown_unit_id() and TC_oml_unknown_unit_id() tests. */
3448function f_ipa_unknown_unit_id(integer mp_bsc_ipa_port) runs on test_CT return boolean {
3449 timer T := 10.0;
3450
3451 bts[0].rsl.id := "IPA-0-RSL";
3452 bts[0].rsl.vc_IPA := IPA_Emulation_CT.create(bts[0].rsl.id & "-IPA");
3453 bts[0].rsl.ccm_pars := c_IPA_default_ccm_pars;
3454 bts[0].rsl.ccm_pars.name := "Osmocom TTCN-3 BTS Simulator";
Oliver Smith92c2bdb2019-08-20 15:11:24 +02003455 bts[0].rsl.ccm_pars.unit_id := "99/0/0"; /* value which is unknown at BTS */
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003456
Pau Espin Pedrol9a5b8ff2021-01-04 19:01:31 +01003457 f_ipa_ctrl_start_client(mp_bsc_ip, mp_bsc_ctrl_port);
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003458
3459 f_init_mgcp("VirtMSC");
3460
3461 /* start RSL/OML connection (XXX re-uses RSL port/protocol definitions for OML) */
3462 map(bts[0].rsl.vc_IPA:IPA_PORT, system:IPA);
3463 connect(bts[0].rsl.vc_IPA:IPA_RSL_PORT, self:IPA_RSL[0]);
3464 bts[0].rsl.vc_IPA.start(IPA_Emulation.main_client(mp_bsc_ip, mp_bsc_ipa_port, "", 10000, bts[0].rsl.ccm_pars));
3465
3466 /* wait for IPA OML link to connect and then disconnect */
3467 T.start;
3468 alt {
Vadim Yanitskiya2afacc2020-05-18 21:16:19 +07003469 [] IPA_RSL[0].receive(tr_ASP_IPA_EV(ASP_IPA_EVENT_DOWN)) {
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003470 T.stop;
3471 return true;
3472 }
3473 [] IPA_RSL[0].receive { repeat }
3474 [] T.timeout {
Daniel Willmannafce8662018-07-06 23:11:32 +02003475 return false;
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003476 }
3477 }
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003478 return false;
3479}
3480
3481/* BSC should close an RSL connection from a BTS with unknown unit ID (OS#2714). */
3482testcase TC_rsl_unknown_unit_id() runs on test_CT {
3483 if (f_ipa_unknown_unit_id(mp_bsc_rsl_port)) {
3484 setverdict(pass);
3485 } else {
3486 setverdict(fail, "Timeout RSL waiting for connection to close");
3487 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003488 f_shutdown_helper();
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003489}
3490
3491
3492/* BSC should close an RSL connection from a BTS with unknown unit ID (OS#2714). */
3493testcase TC_oml_unknown_unit_id() runs on test_CT {
3494 if (f_ipa_unknown_unit_id(mp_bsc_oml_port)) {
3495 setverdict(pass);
3496 } else {
3497 setverdict(fail, "Timeout OML waiting for connection to close");
3498 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003499 f_shutdown_helper();
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003500}
3501
3502
Harald Weltec1a2fff2017-12-17 11:06:19 +01003503/***********************************************************************
Harald Welte6811d102019-04-14 22:23:14 +02003504 * "New world" test cases using RSL_Emulation + RAN_Emulation
Harald Weltec1a2fff2017-12-17 11:06:19 +01003505 ***********************************************************************/
3506
Harald Welte6811d102019-04-14 22:23:14 +02003507import from RAN_Emulation all;
Harald Welte47cd0e32020-08-21 12:39:11 +02003508import from BSSAP_LE_Emulation all;
Harald Weltec1a2fff2017-12-17 11:06:19 +01003509import from RSL_Emulation all;
3510import from MSC_ConnectionHandler all;
3511
3512type function void_fn(charstring id) runs on MSC_ConnHdlr;
3513
Harald Welte336820c2018-05-31 20:34:52 +02003514/* helper function to create and connect a MSC_ConnHdlr component */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003515private function f_connect_handler(inout MSC_ConnHdlr vc_conn, integer bssap_idx := 0) runs on test_CT {
3516 connect(vc_conn:RAN, g_bssap[bssap_idx].vc_RAN:PROC);
Daniel Willmann191e0d92018-01-17 12:44:35 +01003517 connect(vc_conn:MGCP_PROC, vc_MGCP:MGCP_PROC);
Harald Weltec1a2fff2017-12-17 11:06:19 +01003518 connect(vc_conn:RSL, bts[0].rsl.vc_RSL:CLIENT_PT);
Harald Weltef70df652018-01-29 22:00:23 +01003519 connect(vc_conn:RSL_PROC, bts[0].rsl.vc_RSL:RSL_PROC);
Philipp Maier88f4ae82018-03-01 14:00:58 +01003520 if (isvalue(bts[1])) {
Philipp Maier956a92f2018-02-16 10:58:07 +01003521 connect(vc_conn:RSL1, bts[1].rsl.vc_RSL:CLIENT_PT);
3522 connect(vc_conn:RSL1_PROC, bts[1].rsl.vc_RSL:RSL_PROC);
3523 }
Neels Hofmeyr91401012019-07-11 00:42:35 +02003524 if (isvalue(bts[2])) {
3525 connect(vc_conn:RSL2, bts[2].rsl.vc_RSL:CLIENT_PT);
3526 connect(vc_conn:RSL2_PROC, bts[2].rsl.vc_RSL:RSL_PROC);
3527 }
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003528 connect(vc_conn:BSSAP, g_bssap[bssap_idx].vc_RAN:CLIENT);
Neels Hofmeyrcfe44062020-10-15 02:28:08 +02003529 if (mp_enable_lcs_tests) {
3530 connect(vc_conn:BSSAP_LE, g_bssap_le.vc_BSSAP_LE:CLIENT);
3531 connect(vc_conn:BSSAP_LE_PROC, g_bssap_le.vc_BSSAP_LE:PROC);
3532 }
Daniel Willmann191e0d92018-01-17 12:44:35 +01003533 connect(vc_conn:MGCP, vc_MGCP:MGCP_CLIENT);
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02003534 connect(vc_conn:MGCP_MULTI, vc_MGCP:MGCP_CLIENT_MULTI);
Daniel Willmannebdecc02020-08-12 15:30:17 +02003535 connect(vc_conn:STATSD_PROC, vc_STATSD:STATSD_PROC);
Harald Welte336820c2018-05-31 20:34:52 +02003536}
3537
Neels Hofmeyrda436782021-07-20 22:09:06 +02003538function f_start_handler_create(template (omit) TestHdlrParams pars := omit)
Harald Welte336820c2018-05-31 20:34:52 +02003539runs on test_CT return MSC_ConnHdlr {
3540 var charstring id := testcasename();
3541 var MSC_ConnHdlr vc_conn;
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003542 var integer bssap_idx := 0;
3543 if (isvalue(pars)) {
3544 bssap_idx := valueof(pars).mscpool.bssap_idx;
3545 }
Harald Welte336820c2018-05-31 20:34:52 +02003546 vc_conn := MSC_ConnHdlr.create(id);
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003547 f_connect_handler(vc_conn, bssap_idx);
Neels Hofmeyrda436782021-07-20 22:09:06 +02003548 return vc_conn;
3549}
3550
3551function f_start_handler_run(MSC_ConnHdlr vc_conn, void_fn fn, template (omit) TestHdlrParams pars := omit)
3552runs on test_CT return MSC_ConnHdlr {
3553 var charstring id := testcasename();
Neels Hofmeyr1708d1b2020-10-10 16:56:48 +02003554 /* Emit a marker to appear in the SUT's own logging output */
Neels Hofmeyrda436782021-07-20 22:09:06 +02003555 f_logp(BSCVTY, id & "() start");
Harald Weltea0630032018-03-20 21:09:55 +01003556 vc_conn.start(f_handler_init(fn, id, pars));
Harald Weltec1a2fff2017-12-17 11:06:19 +01003557 return vc_conn;
3558}
3559
Neels Hofmeyrda436782021-07-20 22:09:06 +02003560function f_start_handler(void_fn fn, template (omit) TestHdlrParams pars := omit)
3561runs on test_CT return MSC_ConnHdlr {
3562 return f_start_handler_run(f_start_handler_create(pars), fn, pars);
3563}
3564
Harald Weltea0630032018-03-20 21:09:55 +01003565/* first function inside ConnHdlr component; sets g_pars + starts function */
3566private function f_handler_init(void_fn fn, charstring id, template (omit) TestHdlrParams pars := omit)
3567runs on MSC_ConnHdlr {
3568 if (isvalue(pars)) {
3569 g_pars := valueof(pars);
3570 }
3571 fn.apply(id);
3572}
3573
Oliver Smith26a3db72021-07-09 13:51:29 +02003574private function f_vty_encryption_a5(charstring options) runs on test_CT {
3575 f_vty_transceive(BSCVTY, "configure terminal");
3576 f_vty_transceive(BSCVTY, "network");
3577 f_vty_transceive(BSCVTY, "encryption a5 " & options);
3578 f_vty_transceive(BSCVTY, "exit");
3579 f_vty_transceive(BSCVTY, "exit");
3580}
3581
3582private function f_vty_encryption_a5_reset() runs on test_CT {
3583 /* keep in sync with docker-playground.git ttcn3-bsc-test/osmo-bsc.cfg */
3584 f_vty_encryption_a5("0 1 3");
3585}
3586
Harald Welte3c86ea02018-05-10 22:28:05 +02003587/* Establish signalling channel (non-assignment case) followed by cipher mode */
3588private function f_tc_ciph_mode_a5(charstring id) runs on MSC_ConnHdlr {
Harald Welteed848512018-05-24 22:27:58 +02003589 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3590 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte3c86ea02018-05-10 22:28:05 +02003591 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeSIGNAL);
Philipp Maier23000732018-05-18 11:25:37 +02003592 ass_cmd.pdu.bssmap.assignmentRequest.circuitIdentityCode := omit;
3593 ass_cmd.pdu.bssmap.assignmentRequest.aoIPTransportLayer := omit;
3594 exp_compl.pdu.bssmap.assignmentComplete.circuitIdentityCode := omit;
3595 exp_compl.pdu.bssmap.assignmentComplete.aoIPTransportLayer := omit;
Harald Welte3c86ea02018-05-10 22:28:05 +02003596
Philipp Maier23000732018-05-18 11:25:37 +02003597 f_establish_fully(ass_cmd, exp_compl);
Harald Welte3c86ea02018-05-10 22:28:05 +02003598}
3599testcase TC_ciph_mode_a5_0() runs on test_CT {
3600 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003601 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02003602 pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
3603
3604 f_init(1, true);
3605 f_sleep(1.0);
3606 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
3607 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003608 f_shutdown_helper();
Harald Welte3c86ea02018-05-10 22:28:05 +02003609}
3610testcase TC_ciph_mode_a5_1() runs on test_CT {
3611 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003612 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02003613 pars.encr := valueof(t_EncrParams('02'O, f_rnd_octstring(8)));
3614
3615 f_init(1, true);
3616 f_sleep(1.0);
3617 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
3618 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003619 f_shutdown_helper();
Harald Welte3c86ea02018-05-10 22:28:05 +02003620}
Oliver Smith50b98122021-07-09 15:00:28 +02003621/* OS#4975: verify that A5/2 is preferred over A5/0 */
3622testcase TC_ciph_mode_a5_2_0() runs on test_CT {
3623 var MSC_ConnHdlr vc_conn;
3624 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3625
3626 pars.encr := valueof(t_EncrParams('05'O, f_rnd_octstring(8))); /* A5/0 and A5/2 (0x01|0x04)*/
3627 pars.encr_exp_enc_alg := '04'O; /* A5/2 */
3628
3629 f_init(1, true);
3630 f_vty_encryption_a5("0 1 2 3");
3631 f_sleep(1.0);
3632 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
3633 vc_conn.done;
3634 f_vty_encryption_a5_reset();
3635 f_shutdown_helper();
3636}
Oliver Smith1dff88d2021-07-09 08:45:51 +02003637/* OS#4975: verify that A5/1 is preferred over A5/2 */
3638testcase TC_ciph_mode_a5_2_1() runs on test_CT {
3639 var MSC_ConnHdlr vc_conn;
3640 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3641
3642 pars.encr := valueof(t_EncrParams('06'O, f_rnd_octstring(8))); /* A5/1 and A5/2 (0x02|0x04)*/
3643 pars.encr_exp_enc_alg := '02'O; /* A5/1 */
3644
3645 f_init(1, true);
3646 f_vty_encryption_a5("1 2");
3647 f_sleep(1.0);
3648 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
3649 vc_conn.done;
3650 f_vty_encryption_a5_reset();
3651 f_shutdown_helper();
3652}
Harald Welte3c86ea02018-05-10 22:28:05 +02003653testcase TC_ciph_mode_a5_3() runs on test_CT {
3654 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003655 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02003656 pars.encr := valueof(t_EncrParams('08'O, f_rnd_octstring(8)));
3657
3658 f_init(1, true);
3659 f_sleep(1.0);
3660 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
3661 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003662 f_shutdown_helper();
Harald Welte3c86ea02018-05-10 22:28:05 +02003663}
Neels Hofmeyr81ad27f2021-06-11 00:09:40 +02003664/* Establish a Signalling channel with A5/4 encryption. */
3665testcase TC_ciph_mode_a5_4() runs on test_CT {
3666 var MSC_ConnHdlr vc_conn;
3667 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3668 pars.encr := valueof(t_EncrParams('10'O, f_rnd_octstring(8), f_rnd_octstring(16)));
Harald Welte3c86ea02018-05-10 22:28:05 +02003669
Neels Hofmeyr81ad27f2021-06-11 00:09:40 +02003670 f_init(1, true);
Oliver Smith26a3db72021-07-09 13:51:29 +02003671 f_vty_encryption_a5("0 1 3 4");
Neels Hofmeyr81ad27f2021-06-11 00:09:40 +02003672 f_sleep(1.0);
3673 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
3674 vc_conn.done;
Oliver Smith26a3db72021-07-09 13:51:29 +02003675 f_vty_encryption_a5_reset();
Neels Hofmeyr81ad27f2021-06-11 00:09:40 +02003676 f_shutdown_helper();
3677}
Pau Espin Pedrol07866632020-09-03 19:10:55 +02003678/* establish initial channel, enable ciphering followed by assignment to ciphered channel */
3679private function f_tc_assignment_aoip_tla_v6(charstring id) runs on MSC_ConnHdlr {
3680 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3681 var PDU_BSSAP ass_cmd := f_gen_ass_req(aoip_tla := "::3");
3682 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3683 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
3684
3685 f_establish_fully(ass_cmd, exp_compl);
3686}
3687testcase TC_assignment_aoip_tla_v6() runs on test_CT {
3688 var MSC_ConnHdlr vc_conn;
3689 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3690
3691 f_init(1, true);
3692 f_sleep(1.0);
3693 vc_conn := f_start_handler(refers(f_tc_assignment_aoip_tla_v6), pars);
3694 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003695 f_shutdown_helper();
Pau Espin Pedrol07866632020-09-03 19:10:55 +02003696}
3697
Harald Welte3c86ea02018-05-10 22:28:05 +02003698
3699/* establish initial channel, enable ciphering followed by assignment to ciphered channel */
Harald Welte651fcdc2018-05-10 20:23:16 +02003700private function f_tc_assignment_fr_a5(charstring id) runs on MSC_ConnHdlr {
Harald Welteed848512018-05-24 22:27:58 +02003701 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3702 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Weltec1a2fff2017-12-17 11:06:19 +01003703
Harald Welte552620d2017-12-16 23:21:36 +01003704 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3705 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Welte73cd2712017-12-17 00:44:52 +01003706
Harald Weltea0630032018-03-20 21:09:55 +01003707 f_establish_fully(ass_cmd, exp_compl);
Harald Welte552620d2017-12-16 23:21:36 +01003708}
Harald Welte552620d2017-12-16 23:21:36 +01003709testcase TC_assignment_fr_a5_0() runs on test_CT {
3710 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003711 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02003712 pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
Harald Welte552620d2017-12-16 23:21:36 +01003713
Harald Welte89d42e82017-12-17 16:42:41 +01003714 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01003715 f_sleep(1.0);
Harald Welte651fcdc2018-05-10 20:23:16 +02003716 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
Harald Welte552620d2017-12-16 23:21:36 +01003717 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003718 f_shutdown_helper();
Harald Welte552620d2017-12-16 23:21:36 +01003719}
Harald Welte552620d2017-12-16 23:21:36 +01003720testcase TC_assignment_fr_a5_1() runs on test_CT {
Harald Weltec1a2fff2017-12-17 11:06:19 +01003721 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003722 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02003723 pars.encr := valueof(t_EncrParams('02'O, f_rnd_octstring(8)));
Harald Weltec1a2fff2017-12-17 11:06:19 +01003724
Harald Welte89d42e82017-12-17 16:42:41 +01003725 f_init(1, true);
Harald Weltec1a2fff2017-12-17 11:06:19 +01003726 f_sleep(1.0);
Harald Welte651fcdc2018-05-10 20:23:16 +02003727 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
3728 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003729 f_shutdown_helper();
Harald Welte651fcdc2018-05-10 20:23:16 +02003730}
3731testcase TC_assignment_fr_a5_3() runs on test_CT {
3732 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003733 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02003734 pars.encr := valueof(t_EncrParams('08'O, f_rnd_octstring(8)));
Harald Weltec1a2fff2017-12-17 11:06:19 +01003735
Harald Welte651fcdc2018-05-10 20:23:16 +02003736 f_init(1, true);
3737 f_sleep(1.0);
3738 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
Harald Weltec1a2fff2017-12-17 11:06:19 +01003739 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003740 f_shutdown_helper();
Harald Weltec1a2fff2017-12-17 11:06:19 +01003741}
Neels Hofmeyr0d8ec532021-06-11 00:09:48 +02003742/* Establish a Signalling channel and re-assign to TCH/F with A5/4 encryption. */
3743testcase TC_assignment_fr_a5_4() runs on test_CT {
3744 var MSC_ConnHdlr vc_conn;
3745 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3746 pars.encr := valueof(t_EncrParams('10'O, f_rnd_octstring(8), f_rnd_octstring(16)));
3747
3748 f_init(1, true);
Oliver Smith7eabd312021-07-12 14:18:56 +02003749 f_vty_encryption_a5("0 1 3 4");
Neels Hofmeyr0d8ec532021-06-11 00:09:48 +02003750 f_sleep(1.0);
3751 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
3752 vc_conn.done;
Oliver Smith7eabd312021-07-12 14:18:56 +02003753 f_vty_encryption_a5_reset();
Neels Hofmeyr0d8ec532021-06-11 00:09:48 +02003754 f_shutdown_helper();
3755}
Harald Weltec1a2fff2017-12-17 11:06:19 +01003756
Neels Hofmeyr0faeb7a2021-06-10 23:59:35 +02003757/* Allow only A5/4, but omit the Kc128 IE from MSC's msg. Expect Cipher Mode Reject. */
3758testcase TC_assignment_fr_a5_4_fail() runs on test_CT {
3759 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3760 var MSC_ConnHdlr vc_conn;
3761
3762 f_init(1, true);
3763 f_sleep(1.0);
3764
3765 pars.encr := valueof(t_EncrParams('10'O, f_rnd_octstring(8))); // A5/4 support, but Kc128 missing!
3766 vc_conn := f_start_handler(refers(f_TC_assignment_a5_not_sup), pars);
3767 vc_conn.done;
3768 f_shutdown_helper();
3769}
3770
Harald Welte552620d2017-12-16 23:21:36 +01003771/* Expect ASSIGNMENT FAIL if mandatory IE is missing */
3772private function f_tc_assignment_fr_a5_1_codec_missing(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02003773 g_pars := f_gen_test_hdlr_pars();
Harald Welte552620d2017-12-16 23:21:36 +01003774 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +02003775 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte552620d2017-12-16 23:21:36 +01003776
3777 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02003778 /* Omit: ass_cmd.pdu.bssmap.assignmentRequest.codecList */
3779
Harald Weltea0630032018-03-20 21:09:55 +01003780 f_establish_fully(ass_cmd, exp_fail);
Harald Welte552620d2017-12-16 23:21:36 +01003781}
Harald Welte552620d2017-12-16 23:21:36 +01003782testcase TC_assignment_fr_a5_1_codec_missing() runs on test_CT {
3783 var MSC_ConnHdlr vc_conn;
3784
Harald Welte89d42e82017-12-17 16:42:41 +01003785 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01003786 f_sleep(1.0);
3787
Harald Welte8863fa12018-05-10 20:15:27 +02003788 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5_1_codec_missing));
Harald Welte552620d2017-12-16 23:21:36 +01003789 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003790 f_shutdown_helper();
Harald Welte552620d2017-12-16 23:21:36 +01003791}
3792
Neels Hofmeyr04d6e6a2021-06-11 00:10:02 +02003793private function f_TC_assignment_a5_not_sup(charstring id) runs on MSC_ConnHdlr {
3794 var template PDU_BSSAP exp_ass_cpl := f_gen_exp_compl();
3795 var PDU_BSSAP exp_ass_req := f_gen_ass_req();
Harald Welte552620d2017-12-16 23:21:36 +01003796
Neels Hofmeyr04d6e6a2021-06-11 00:10:02 +02003797 exp_ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3798 exp_ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
3799
3800 /* this is like the beginning of f_establish_fully(), but only up to ciphering reject */
3801
3802 var BSSMAP_FIELD_CodecType codecType;
3803 timer T := 10.0;
3804
3805 codecType := exp_ass_req.pdu.bssmap.assignmentRequest.codecList.codecElements[0].codecType;
3806 f_MscConnHdlr_init(g_pars.media_nr, host_bts, host_mgw_mgcp, codecType);
3807
3808 f_create_chan_and_exp();
3809 /* we should now have a COMPL_L3 at the MSC */
3810
3811 var template PDU_BSSAP exp_l3_compl;
3812 exp_l3_compl := tr_BSSMAP_ComplL3()
3813 if (g_pars.aoip == false) {
3814 exp_l3_compl.pdu.bssmap.completeLayer3Information.codecList := omit;
3815 } else {
3816 exp_l3_compl.pdu.bssmap.completeLayer3Information.codecList := ?;
3817 }
3818 T.start;
3819 alt {
3820 [] BSSAP.receive(exp_l3_compl);
3821 [] BSSAP.receive(tr_BSSMAP_ComplL3) {
3822 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received non-matching COMPLETE LAYER 3 INFORMATION");
3823 }
3824 [] T.timeout {
3825 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for COMPLETE LAYER 3 INFORMATION");
3826 }
3827 }
3828
3829 /* Start ciphering, expect Cipher Mode Reject */
Neels Hofmeyr6c388f22021-06-11 02:36:56 +02003830 f_cipher_mode(g_pars.encr, exp_fail := true);
Harald Welte552620d2017-12-16 23:21:36 +01003831}
Neels Hofmeyr04d6e6a2021-06-11 00:10:02 +02003832testcase TC_assignment_fr_a5_not_sup() runs on test_CT {
3833 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte552620d2017-12-16 23:21:36 +01003834 var MSC_ConnHdlr vc_conn;
3835
Harald Welte89d42e82017-12-17 16:42:41 +01003836 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01003837 f_sleep(1.0);
3838
Neels Hofmeyr0588cad2021-06-11 01:38:18 +02003839 pars.encr := valueof(t_EncrParams('20'O, f_rnd_octstring(8), f_rnd_octstring(16)));
Neels Hofmeyr04d6e6a2021-06-11 00:10:02 +02003840 vc_conn := f_start_handler(refers(f_TC_assignment_a5_not_sup), pars);
Harald Welte552620d2017-12-16 23:21:36 +01003841 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003842 f_shutdown_helper();
Harald Welte552620d2017-12-16 23:21:36 +01003843}
3844
3845
Harald Welte4532e0a2017-12-23 02:05:44 +01003846private function f_tc_assignment_sign(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02003847 g_pars := f_gen_test_hdlr_pars();
Harald Welte4532e0a2017-12-23 02:05:44 +01003848 var template PDU_BSSAP exp_compl := tr_BSSMAP_AssignmentComplete(omit, omit);
Philipp Maier48604732018-10-09 15:00:37 +02003849 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte4532e0a2017-12-23 02:05:44 +01003850 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeSIGNAL);
Daniel Willmannebdecc02020-08-12 15:30:17 +02003851
3852 f_statsd_reset();
Harald Weltea0630032018-03-20 21:09:55 +01003853 f_establish_fully(ass_cmd, exp_compl);
Daniel Willmannebdecc02020-08-12 15:30:17 +02003854
3855 var StatsDExpects expect := {
Daniel Willmannc5398f72020-09-21 10:41:35 +02003856 { name := "TTCN3.bts.0.chreq.total", mtype := "c", min := 1, max := 1},
3857 { name := "TTCN3.bts.0.chreq.successful", mtype := "c", min := 1, max := 1},
Daniel Willmannebdecc02020-08-12 15:30:17 +02003858 { name := "TTCN3.bsc.0.assignment.attempted", mtype := "c", min := 1, max := 1},
3859 { name := "TTCN3.bsc.0.assignment.completed", mtype := "c", min := 1, max := 1}
3860 };
3861 f_statsd_expect(expect);
Harald Welte4532e0a2017-12-23 02:05:44 +01003862}
3863
3864testcase TC_assignment_sign() runs on test_CT {
3865 var MSC_ConnHdlr vc_conn;
3866
3867 f_init(1, true);
3868 f_sleep(1.0);
3869
Harald Welte8863fa12018-05-10 20:15:27 +02003870 vc_conn := f_start_handler(refers(f_tc_assignment_sign));
Harald Welte4532e0a2017-12-23 02:05:44 +01003871 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003872 f_shutdown_helper();
Harald Welte4532e0a2017-12-23 02:05:44 +01003873}
3874
Harald Welte60aa5762018-03-21 19:33:13 +01003875/***********************************************************************
3876 * Codec (list) testing
3877 ***********************************************************************/
3878
3879/* check if the given rsl_mode is compatible with the a_elem */
3880private function f_match_codec(BSSMAP_FIELD_CodecElement a_elem, RSL_IE_ChannelMode rsl_mode)
3881return boolean {
3882 select (a_elem.codecType) {
3883 case (GSM_FR) {
3884 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM1))) {
3885 return true;
3886 }
3887 }
3888 case (GSM_HR) {
3889 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1))) {
3890 return true;
3891 }
3892 }
3893 case (GSM_EFR) {
3894 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM2))) {
3895 return true;
3896 }
3897 }
3898 case (FR_AMR) {
3899 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM3))) {
3900 return true;
3901 }
3902 }
3903 case (HR_AMR) {
3904 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM3))) {
3905 return true;
3906 }
3907 }
3908 case else { }
3909 }
3910 return false;
3911}
3912
3913/* check if the given rsl_mode is compatible with the a_list */
3914private function f_match_codecs(BSSMAP_IE_SpeechCodecList a_list, RSL_IE_ChannelMode rsl_mode)
3915return boolean {
3916 for (var integer i := 0; i < sizeof(a_list); i := i+1) {
3917 if (f_match_codec(a_list.codecElements[i], rsl_mode)) {
3918 return true;
3919 }
3920 }
3921 return false;
3922}
3923
3924/* determine BSSMAP_IE_ChannelType from *first* element of BSSMAP_FIELD_CodecElement */
Philipp Maier61f6b572018-07-06 14:03:38 +02003925function f_BSSMAP_chtype_from_codec(BSSMAP_FIELD_CodecElement a_elem)
Harald Welte60aa5762018-03-21 19:33:13 +01003926return BSSMAP_IE_ChannelType {
3927 /* FIXME: actually look at all elements of BSSMAP_IE_SpeechCodecList */
3928 var BSSMAP_IE_ChannelType ret := valueof(ts_BSSMAP_IE_ChannelType);
3929 select (a_elem.codecType) {
3930 case (GSM_FR) {
3931 ret.channelRateAndType := ChRate_TCHF;
3932 ret.speechId_DataIndicator := Spdi_TCHF_FR;
3933 }
3934 case (GSM_HR) {
3935 ret.channelRateAndType := ChRate_TCHH;
3936 ret.speechId_DataIndicator := Spdi_TCHH_HR;
3937 }
3938 case (GSM_EFR) {
3939 ret.channelRateAndType := ChRate_TCHF;
3940 ret.speechId_DataIndicator := Spdi_TCHF_EFR;
3941 }
3942 case (FR_AMR) {
3943 ret.channelRateAndType := ChRate_TCHF;
3944 ret.speechId_DataIndicator := Spdi_TCHF_AMR;
3945 }
3946 case (HR_AMR) {
3947 ret.channelRateAndType := ChRate_TCHH;
3948 ret.speechId_DataIndicator := Spdi_TCHH_AMR;
3949 }
3950 case else {
3951 setverdict(fail, "Unsupported codec ", a_elem);
Daniel Willmannafce8662018-07-06 23:11:32 +02003952 mtc.stop;
Harald Welte60aa5762018-03-21 19:33:13 +01003953 }
3954 }
3955 return ret;
3956}
3957
Harald Weltea63b9102018-03-22 20:36:16 +01003958private function f_rsl_chmod_tmpl_from_codec(BSSMAP_FIELD_CodecElement a_elem)
3959return template RSL_IE_Body {
3960 var template RSL_IE_Body mode_ie := {
3961 chan_mode := {
3962 len := ?,
3963 reserved := ?,
3964 dtx_d := ?,
3965 dtx_u := ?,
3966 spd_ind := RSL_SPDI_SPEECH,
3967 ch_rate_type := -,
3968 coding_alg_rate := -
3969 }
3970 }
3971
3972 select (a_elem.codecType) {
3973 case (GSM_FR) {
3974 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
3975 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM1;
3976 }
3977 case (GSM_HR) {
3978 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_H;
3979 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM1;
3980 }
3981 case (GSM_EFR) {
3982 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
3983 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM2;
3984 }
3985 case (FR_AMR) {
3986 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
3987 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM3;
3988 }
3989 case (HR_AMR) {
3990 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_H;
3991 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM3;
3992 }
3993 }
3994 return mode_ie;
3995}
3996
Harald Welte60aa5762018-03-21 19:33:13 +01003997type record CodecListTest {
3998 BSSMAP_IE_SpeechCodecList codec_list,
3999 charstring id
4000}
4001type record of CodecListTest CodecListTests
4002
4003private function f_TC_assignment_codec(charstring id) runs on MSC_ConnHdlr {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02004004 var PDU_BSSAP ass_cmd := f_gen_ass_req(g_pars.use_osmux);
4005 var template PDU_BSSAP exp_compl := f_gen_exp_compl(g_pars.use_osmux);
Harald Welte60aa5762018-03-21 19:33:13 +01004006
4007 /* puzzle together the ASSIGNMENT REQ for given codec[s] */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02004008 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welte79f3f542018-05-25 20:02:37 +02004009 ass_cmd.pdu.bssmap.assignmentRequest.codecList := g_pars.ass_codec_list;
4010 exp_compl.pdu.bssmap.assignmentComplete.speechCodec.codecElements[0] :=
4011 g_pars.ass_codec_list.codecElements[0];
Philipp Maierd0e64b02019-03-13 14:15:23 +01004012 if (isvalue(g_pars.expect_mr_s0_s7)) {
4013 exp_compl.pdu.bssmap.assignmentComplete.speechCodec.codecElements[0].s0_7 :=
4014 g_pars.expect_mr_s0_s7;
4015 }
Harald Welte79f3f542018-05-25 20:02:37 +02004016 }
Harald Welte60aa5762018-03-21 19:33:13 +01004017 ass_cmd.pdu.bssmap.assignmentRequest.channelType :=
4018 f_BSSMAP_chtype_from_codec(g_pars.ass_codec_list.codecElements[0]);
Harald Welte60aa5762018-03-21 19:33:13 +01004019 log("expecting ASS COMPL like this: ", exp_compl);
4020
4021 f_establish_fully(ass_cmd, exp_compl);
Harald Weltea63b9102018-03-22 20:36:16 +01004022
Neels Hofmeyr559d5d02021-04-16 16:50:49 +02004023 if (not g_pars.expect_channel_mode_modify) {
4024 /* Verify that the RSL-side activation actually matches our expectations */
4025 var RSL_Message rsl := f_rslem_get_last_act(RSL_PROC, 0, g_chan_nr);
Harald Weltea63b9102018-03-22 20:36:16 +01004026
Neels Hofmeyr559d5d02021-04-16 16:50:49 +02004027 var RSL_IE_Body mode_ie;
4028 if (f_rsl_find_ie(rsl, RSL_IE_CHAN_MODE, mode_ie) == false) {
4029 setverdict(fail, "Couldn't find CHAN_MODE IE");
Daniel Willmannafce8662018-07-06 23:11:32 +02004030 mtc.stop;
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02004031 }
Neels Hofmeyr559d5d02021-04-16 16:50:49 +02004032 var template RSL_IE_Body t_mode_ie := f_rsl_chmod_tmpl_from_codec(g_pars.ass_codec_list.codecElements[0]);
4033 if (not match(mode_ie, t_mode_ie)) {
4034 log("mode_ie ", mode_ie, " != t_mode_ie ", t_mode_ie);
4035 setverdict(fail, "RSL Channel Mode IE doesn't match expectation");
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02004036 }
Neels Hofmeyr559d5d02021-04-16 16:50:49 +02004037
4038 var RSL_IE_Body mr_conf;
4039 if (g_pars.expect_mr_conf_ie != omit) {
4040 if (f_rsl_find_ie(rsl, RSL_IE_MR_CONFIG, mr_conf) == false) {
4041 setverdict(fail, "Missing MR CONFIG IE in RSL Chan Activ");
4042 mtc.stop;
4043 }
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02004044 log("found RSL MR CONFIG IE: ", mr_conf);
Neels Hofmeyr559d5d02021-04-16 16:50:49 +02004045
4046 if (not match(mr_conf, g_pars.expect_mr_conf_ie)) {
4047 setverdict(fail, "RSL MR CONFIG IE does not match expectation. Expected: ",
4048 g_pars.expect_mr_conf_ie);
4049 }
4050 } else {
4051 if (f_rsl_find_ie(rsl, RSL_IE_MR_CONFIG, mr_conf) == true) {
4052 log("found RSL MR CONFIG IE: ", mr_conf);
4053 setverdict(fail, "Found MR CONFIG IE in RSL Chan Activ, expecting omit");
4054 mtc.stop;
4055 }
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02004056 }
4057 }
Harald Welte60aa5762018-03-21 19:33:13 +01004058}
4059
Philipp Maierd0e64b02019-03-13 14:15:23 +01004060private function f_TC_assignment_codec_fail(charstring id) runs on MSC_ConnHdlr {
4061
4062 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4063 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
4064
4065 /* puzzle together the ASSIGNMENT REQ for given codec[s] */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02004066 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Philipp Maierd0e64b02019-03-13 14:15:23 +01004067 ass_cmd.pdu.bssmap.assignmentRequest.codecList := g_pars.ass_codec_list;
4068 }
4069 ass_cmd.pdu.bssmap.assignmentRequest.channelType :=
4070 f_BSSMAP_chtype_from_codec(g_pars.ass_codec_list.codecElements[0]);
4071 log("expecting ASS FAIL like this: ", exp_fail);
4072
4073 f_establish_fully(ass_cmd, exp_fail);
4074}
4075
Harald Welte60aa5762018-03-21 19:33:13 +01004076testcase TC_assignment_codec_fr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02004077 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01004078 var MSC_ConnHdlr vc_conn;
4079
4080 f_init(1, true);
4081 f_sleep(1.0);
4082
4083 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Welte8863fa12018-05-10 20:15:27 +02004084 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01004085 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004086 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01004087}
4088
4089testcase TC_assignment_codec_hr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02004090 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01004091 var MSC_ConnHdlr vc_conn;
4092
4093 f_init(1, true);
4094 f_sleep(1.0);
4095
4096 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
Harald Welte8863fa12018-05-10 20:15:27 +02004097 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01004098 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004099 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01004100}
4101
4102testcase TC_assignment_codec_efr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02004103 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01004104 var MSC_ConnHdlr vc_conn;
4105
4106 f_init(1, true);
4107 f_sleep(1.0);
4108
4109 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecEFR}));
Harald Welte8863fa12018-05-10 20:15:27 +02004110 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01004111 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004112 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01004113}
4114
Philipp Maierd0e64b02019-03-13 14:15:23 +01004115/* Allow 5,90k only (current default config) */
4116private function f_allow_amr_rate_5_90k() runs on test_CT {
Neels Hofmeyr2a5670b2020-11-25 23:39:57 +00004117 f_vty_cfg_msc(BSCVTY, 0, {
4118 "amr-config 12_2k forbidden",
4119 "amr-config 10_2k forbidden",
4120 "amr-config 7_95k forbidden",
4121 "amr-config 7_40k forbidden",
4122 "amr-config 6_70k forbidden",
4123 "amr-config 5_90k allowed",
4124 "amr-config 5_15k forbidden",
4125 "amr-config 4_75k forbidden"
4126 });
Philipp Maierd0e64b02019-03-13 14:15:23 +01004127}
4128
4129/* Allow 4,75k, 5,90k, 4,70k and 12,2k, which are the most common rates
4130 * ("Config-NB-Code = 1") */
4131private function f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k() runs on test_CT {
Neels Hofmeyr2a5670b2020-11-25 23:39:57 +00004132 f_vty_cfg_msc(BSCVTY, 0, {
4133 "amr-config 12_2k allowed",
4134 "amr-config 10_2k forbidden",
4135 "amr-config 7_95k forbidden",
4136 "amr-config 7_40k allowed",
4137 "amr-config 6_70k forbidden",
4138 "amr-config 5_90k allowed",
4139 "amr-config 5_15k forbidden",
4140 "amr-config 4_75k allowed"
4141 });
Philipp Maierd0e64b02019-03-13 14:15:23 +01004142}
4143
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00004144private function f_vty_amr_start_mode_set(boolean fr, charstring startmode) runs on test_CT {
4145 var charstring tch;
4146 if (fr) {
4147 tch := "tch-f";
4148 } else {
4149 tch := "tch-h";
4150 }
4151 f_vty_cfg_bts(BSCVTY, 0, { "amr " & tch & " start-mode " & startmode });
4152}
4153
4154/* Set the AMR start-mode for this TCH back to the default configuration. */
4155private function f_vty_amr_start_mode_restore(boolean fr) runs on test_CT {
4156 f_vty_amr_start_mode_set(fr, "auto");
4157}
4158
Harald Welte60aa5762018-03-21 19:33:13 +01004159testcase TC_assignment_codec_amr_f() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02004160 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01004161 var MSC_ConnHdlr vc_conn;
Philipp Maier7695a0d2018-09-27 17:52:14 +02004162
4163 /* Note: This setups the codec configuration. The parameter payload in
4164 * mr_conf must be consistant with the parameter codecElements in pars
4165 * and also must match the amr-config in osmo-bsc.cfg! */
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02004166 var RSL_IE_Body mr_conf := {
4167 other := {
4168 len := 2,
4169 payload := '2804'O
4170 }
4171 };
Harald Welte60aa5762018-03-21 19:33:13 +01004172
Philipp Maier7695a0d2018-09-27 17:52:14 +02004173 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
Philipp Maier806f8f12019-03-12 12:13:41 +01004174 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
Philipp Maier7695a0d2018-09-27 17:52:14 +02004175 pars.ass_codec_list.codecElements[0].s8_15 := '01010111'B;
4176 pars.expect_mr_conf_ie := mr_conf;
4177
Harald Welte60aa5762018-03-21 19:33:13 +01004178 f_init(1, true);
4179 f_sleep(1.0);
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00004180 f_vty_amr_start_mode_set(true, "1");
Harald Welte60aa5762018-03-21 19:33:13 +01004181
Harald Welte8863fa12018-05-10 20:15:27 +02004182 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01004183 vc_conn.done;
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00004184
4185 f_vty_amr_start_mode_restore(true);
Vadim Yanitskiy292e5962021-01-03 14:18:47 +01004186 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01004187}
4188
4189testcase TC_assignment_codec_amr_h() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02004190 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01004191 var MSC_ConnHdlr vc_conn;
Philipp Maier7695a0d2018-09-27 17:52:14 +02004192
4193 /* See note above */
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02004194 var RSL_IE_Body mr_conf := {
4195 other := {
4196 len := 2,
4197 payload := '2804'O
4198 }
4199 };
Harald Welte60aa5762018-03-21 19:33:13 +01004200
Philipp Maier7695a0d2018-09-27 17:52:14 +02004201 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
Philipp Maier806f8f12019-03-12 12:13:41 +01004202 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
Philipp Maier7695a0d2018-09-27 17:52:14 +02004203 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
4204 pars.expect_mr_conf_ie := mr_conf;
4205
Harald Welte60aa5762018-03-21 19:33:13 +01004206 f_init(1, true);
4207 f_sleep(1.0);
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00004208 f_vty_amr_start_mode_set(false, "1");
Harald Welte60aa5762018-03-21 19:33:13 +01004209
Harald Welte8863fa12018-05-10 20:15:27 +02004210 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01004211 vc_conn.done;
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00004212
4213 f_vty_amr_start_mode_restore(false);
Vadim Yanitskiy292e5962021-01-03 14:18:47 +01004214 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01004215}
4216
Neels Hofmeyr559d5d02021-04-16 16:50:49 +02004217/* Establish signalling on a TCH/F lchan, and then switch to speech mode without a new Assignment. */
4218testcase TC_assignment_codec_fr_by_mode_modify() runs on test_CT {
4219 var TestHdlrParams pars := f_gen_test_hdlr_pars();
4220 var MSC_ConnHdlr vc_conn;
4221
4222 f_init(1, true);
4223 f_sleep(1.0);
4224
4225 /* By disabling all SDCCH, the MS should be given a TCH/F for signalling. Then activating an FR codec should
4226 * merely do a Channel Mode Modify, and not assign to a new lchan. f_establish_fully() already accounts for
4227 * expecting a Channel Mode Modify if the channel type is compatible. */
4228 f_disable_all_sdcch();
4229 f_disable_all_tch_h();
4230
4231 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4232 pars.expect_channel_mode_modify := true;
4233 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
4234 vc_conn.done;
4235
4236 f_enable_all_sdcch();
4237 f_enable_all_tch();
4238 f_shutdown_helper();
4239}
4240
Neels Hofmeyr454d7922020-11-26 02:24:57 +00004241/* 'amr start-mode auto' should not keep the (unused) 'smod' bits from previous configuration */
4242testcase TC_assignment_codec_amr_startmode_cruft() runs on test_CT {
4243 var TestHdlrParams pars := f_gen_test_hdlr_pars();
4244 var MSC_ConnHdlr vc_conn;
4245
4246 var RSL_IE_Body mr_conf := {
4247 other := {
4248 len := 2,
4249 payload := '2004'O /* <- expect ICMI=0, smod=00 */
4250 }
4251 };
4252
4253 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
4254 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
4255 pars.ass_codec_list.codecElements[0].s8_15 := '01010111'B;
4256 pars.expect_mr_conf_ie := mr_conf;
4257
4258 f_init(1, true);
4259 f_sleep(1.0);
4260
4261 /* First set nonzero start mode bits */
4262 f_vty_amr_start_mode_set(true, "4");
4263 /* Now set to auto, and expect the startmode bits to be zero in the message, i.e. ensure that osmo-bsc does not
4264 * let the startmode bits stick around and has deterministic MultiRate config for 'start-mode auto'; that is
4265 * ensured by above '2004'O, where 'x0xx'O indicates ICMI = 0, spare = 0, smod = 00. */
4266 f_vty_amr_start_mode_set(true, "auto");
4267
4268 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
4269 vc_conn.done;
Neels Hofmeyr454d7922020-11-26 02:24:57 +00004270
4271 /* Clear the startmode bits to not affect subsequent tests, in case the bits should indeed stick around. */
4272 f_vty_amr_start_mode_set(true, "1");
4273 f_vty_amr_start_mode_restore(true);
Vadim Yanitskiy292e5962021-01-03 14:18:47 +01004274 f_shutdown_helper();
Neels Hofmeyr454d7922020-11-26 02:24:57 +00004275}
4276
Neels Hofmeyr21863562020-11-26 00:34:33 +00004277function f_TC_assignment_codec_amr(boolean fr, octetstring mrconf, bitstring s8_s0, bitstring exp_s8_s0,
4278 charstring start_mode := "1")
Philipp Maierd0e64b02019-03-13 14:15:23 +01004279runs on test_CT {
4280
4281 var TestHdlrParams pars := f_gen_test_hdlr_pars();
4282 var MSC_ConnHdlr vc_conn;
4283
4284 /* See note above */
4285 var RSL_IE_Body mr_conf := {
4286 other := {
4287 len := lengthof(mrconf),
4288 payload := mrconf
4289 }
4290 };
4291
4292 if (fr) {
4293 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
4294 } else {
4295 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
4296 }
4297 pars.ass_codec_list.codecElements[0].s0_7 := s8_s0;
4298 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
4299 pars.expect_mr_conf_ie := mr_conf;
4300 pars.expect_mr_s0_s7 := exp_s8_s0;
4301
4302 f_init(1, true);
4303 f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k();
Neels Hofmeyr21863562020-11-26 00:34:33 +00004304 f_vty_amr_start_mode_set(fr, start_mode);
Philipp Maierd0e64b02019-03-13 14:15:23 +01004305 f_sleep(1.0);
4306
4307 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
4308 vc_conn.done;
4309 f_allow_amr_rate_5_90k();
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00004310 f_vty_amr_start_mode_restore(fr);
Philipp Maierd0e64b02019-03-13 14:15:23 +01004311}
4312
4313function f_TC_assignment_codec_amr_fail(boolean fr, bitstring s8_s0)
4314runs on test_CT {
4315
4316 var TestHdlrParams pars := f_gen_test_hdlr_pars();
4317 var MSC_ConnHdlr vc_conn;
4318
4319 if (fr) {
4320 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
4321 } else {
4322 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
4323 }
4324 pars.ass_codec_list.codecElements[0].s0_7 := s8_s0;
4325 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
4326
4327 f_init(1, true);
4328 f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k();
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00004329 f_vty_amr_start_mode_set(fr, "1");
Philipp Maierd0e64b02019-03-13 14:15:23 +01004330 f_sleep(1.0);
4331
4332 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fail), pars);
4333 vc_conn.done;
4334 f_allow_amr_rate_5_90k();
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00004335 f_vty_amr_start_mode_restore(fr);
Philipp Maierd0e64b02019-03-13 14:15:23 +01004336}
4337
4338
4339/* Set S1, we expect an AMR multirate configuration IE with all four rates
4340 * set. */
4341testcase TC_assignment_codec_amr_f_S1() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004342 f_TC_assignment_codec_amr(true, '289520882208'O, '00000010'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004343 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004344}
4345
4346/* Set S1, we expect an AMR multirate configuration IE with the lower three
4347 * rates set. */
4348testcase TC_assignment_codec_amr_h_S1() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004349 f_TC_assignment_codec_amr(false, '2815208820'O, '00000010'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004350 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004351}
4352
4353/* Set S1 and two other rates, we expect an AMR MULTIRATE CONFIGURATION IE with
4354 * all four rates (and only S1 set in the ASSIGNMENT COMPLETE) */
4355testcase TC_assignment_codec_amr_f_S124() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004356 f_TC_assignment_codec_amr(true, '289520882208'O, '00010110'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004357 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004358}
4359
4360/* Set S1 and two other rates, we expect an AMR MULTIRATE CONFIGURATION IE with
4361 * all four rates (and only S1 set in the ASSIGNMENT COMPLETE) */
4362testcase TC_assignment_codec_amr_h_S124() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004363 f_TC_assignment_codec_amr(false, '2815208820'O, '00010110'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004364 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004365}
4366
4367/* The following block of tests selects more and more rates until all four
4368 * possible rates are in the active set (full rate) */
4369testcase TC_assignment_codec_amr_f_S0() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004370 f_TC_assignment_codec_amr(true, '2801'O, '00000001'B, '00000001'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004371 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004372}
4373
4374testcase TC_assignment_codec_amr_f_S02() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004375 f_TC_assignment_codec_amr(true, '28052080'O, '00000101'B, '00000101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004376 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004377}
4378
4379testcase TC_assignment_codec_amr_f_S024() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004380 f_TC_assignment_codec_amr(true, '2815208820'O, '00010101'B, '00010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004381 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004382}
4383
4384testcase TC_assignment_codec_amr_f_S0247() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004385 f_TC_assignment_codec_amr(true, '289520882208'O, '10010101'B, '10010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004386 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004387}
4388
4389/* The following block of tests selects more and more rates until all three
4390 * possible rates are in the active set (half rate) */
4391testcase TC_assignment_codec_amr_h_S0() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004392 f_TC_assignment_codec_amr(false, '2801'O, '00000001'B, '00000001'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004393 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004394}
4395
4396testcase TC_assignment_codec_amr_h_S02() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004397 f_TC_assignment_codec_amr(false, '28052080'O, '00000101'B, '00000101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004398 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004399}
4400
4401testcase TC_assignment_codec_amr_h_S024() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004402 f_TC_assignment_codec_amr(false, '2815208820'O, '00010101'B, '00010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004403 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004404}
4405
4406/* The following block tests what happens when the MSC does offer rate
4407 * configurations that are not supported by the BSC. Normally such situations
4408 * should not happen because the MSC gets informed by the BSC in advance via
4409 * the L3 COMPLETE message which rates are applicable. The MSC should not try
4410 * to offer rates that are not applicable anyway. */
4411
4412testcase TC_assignment_codec_amr_h_S0247() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004413 /* Try to include 12,2k in into the active set even though the channel
4414 * is half rate only. The BSC is expected to remove the 12,0k */
4415 f_TC_assignment_codec_amr(false, '2815208820'O, '10010101'B, '00010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004416 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004417}
4418
4419testcase TC_assignment_codec_amr_f_S01234567() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004420 /* See what happens when all rates are selected at once. Since then
4421 * Also S1 is selected, this setting will be prefered and we should
4422 * get 12.2k, 7,40k, 5,90k, and 4,75k in the active set. */
4423 f_TC_assignment_codec_amr(true, '289520882208'O, '11111111'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004424 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004425}
4426
4427testcase TC_assignment_codec_amr_f_S0234567() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004428 /* Same as above, but with S1 missing, the MSC is then expected to
4429 * select the currently supported rates, which are also 12.2k, 7,40k,
4430 * 5,90k, and 4,75k, into the active set. */
4431 f_TC_assignment_codec_amr(true, '289520882208'O, '11111101'B, '10010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004432 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004433}
4434
4435testcase TC_assignment_codec_amr_f_zero() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004436 /* Try to select no rates at all */
4437 f_TC_assignment_codec_amr_fail(true, '00000000'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004438 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004439}
4440
4441testcase TC_assignment_codec_amr_f_unsupp() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004442 /* Try to select only unsupported rates */
4443 f_TC_assignment_codec_amr_fail(true, '01101000'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004444 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004445}
4446
4447testcase TC_assignment_codec_amr_h_S7() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004448 /* Try to select 12,2k for half rate */
4449 f_TC_assignment_codec_amr_fail(false, '10000000'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004450 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004451}
4452
Neels Hofmeyr21863562020-11-26 00:34:33 +00004453testcase TC_assignment_codec_amr_f_start_mode_auto() runs on test_CT {
4454 f_TC_assignment_codec_amr(true, '209520882208'O, '11111111'B, '00000010'B,
4455 start_mode := "auto");
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01004456 f_shutdown_helper();
Neels Hofmeyr21863562020-11-26 00:34:33 +00004457}
4458
4459testcase TC_assignment_codec_amr_h_start_mode_auto() runs on test_CT {
4460 f_TC_assignment_codec_amr(false, '2015208820'O, '10010101'B, '00010101'B,
4461 start_mode := "auto");
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01004462 f_shutdown_helper();
Neels Hofmeyr21863562020-11-26 00:34:33 +00004463}
4464
Neels Hofmeyr3eb94562020-11-26 02:40:26 +00004465testcase TC_assignment_codec_amr_f_start_mode_4() runs on test_CT {
Vadim Yanitskiy7815f482021-01-03 17:07:37 +01004466 /* "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 +00004467 f_TC_assignment_codec_amr(true, '2b9520882208'O, '11111111'B, '00000010'B,
4468 start_mode := "4");
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01004469 f_shutdown_helper();
Neels Hofmeyr3eb94562020-11-26 02:40:26 +00004470}
4471
4472testcase TC_assignment_codec_amr_h_start_mode_4() runs on test_CT {
Vadim Yanitskiy7815f482021-01-03 17:07:37 +01004473 /* "amr tch-h modes 0 2 4" => total 3 modes and start mode 4 => '10'B on the wire */
4474 f_TC_assignment_codec_amr(false, '2a15208820'O, '10010101'B, '00010101'B,
Neels Hofmeyr3eb94562020-11-26 02:40:26 +00004475 start_mode := "4");
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01004476 f_shutdown_helper();
Neels Hofmeyr3eb94562020-11-26 02:40:26 +00004477}
4478
Philipp Maierac09bfc2019-01-08 13:41:39 +01004479private function f_disable_all_tch_f() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01004480 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 1 sub-slot 0 borken");
4481 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 2 sub-slot 0 borken");
4482 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 3 sub-slot 0 borken");
4483 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 4 sub-slot 0 borken");
Philipp Maierac09bfc2019-01-08 13:41:39 +01004484}
4485
4486private function f_disable_all_tch_h() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01004487 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 0 borken");
4488 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 1 borken");
Philipp Maierac09bfc2019-01-08 13:41:39 +01004489}
4490
4491private function f_enable_all_tch() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01004492 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 1 sub-slot 0 unused");
4493 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 2 sub-slot 0 unused");
4494 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 3 sub-slot 0 unused");
4495 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 4 sub-slot 0 unused");
4496 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 0 unused");
4497 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 1 unused");
Philipp Maierac09bfc2019-01-08 13:41:39 +01004498}
4499
Neels Hofmeyr559d5d02021-04-16 16:50:49 +02004500private function f_disable_all_sdcch() runs on test_CT {
4501 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 0 sub-slot 0 borken");
4502 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 0 sub-slot 1 borken");
4503 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 0 sub-slot 2 borken");
4504 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 0 sub-slot 3 borken");
4505}
4506
4507private function f_enable_all_sdcch() runs on test_CT {
4508 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 0 sub-slot 0 unused");
4509 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 0 sub-slot 1 unused");
4510 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 0 sub-slot 2 unused");
4511 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 0 sub-slot 3 unused");
4512}
4513
Philipp Maierac09bfc2019-01-08 13:41:39 +01004514/* Allow HR only */
4515private function f_TC_assignment_codec_xr_exhausted_req_hr(charstring id) runs on MSC_ConnHdlr {
4516 g_pars := f_gen_test_hdlr_pars();
4517 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4518 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4519 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4520 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '09'O;
4521 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '05'O;
4522 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
4523 f_establish_fully(ass_cmd, exp_compl);
4524}
4525
4526/* Allow FR only */
4527private function f_TC_assignment_codec_xr_exhausted_req_fr(charstring id) runs on MSC_ConnHdlr {
4528 g_pars := f_gen_test_hdlr_pars();
4529 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4530 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4531 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4532 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '08'O;
4533 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '01'O;
4534 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4535 f_establish_fully(ass_cmd, exp_compl);
4536}
4537
4538/* Allow HR only (expect assignment failure) */
4539private function f_TC_assignment_codec_xr_exhausted_req_hr_fail(charstring id) runs on MSC_ConnHdlr {
4540 g_pars := f_gen_test_hdlr_pars();
4541 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4542 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
4543 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4544 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '09'O;
4545 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '05'O;
4546 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
4547 f_establish_fully(ass_cmd, exp_fail);
4548}
4549
4550/* Allow FR only (expect assignment failure) */
4551private function f_TC_assignment_codec_xr_exhausted_req_fr_fail(charstring id) runs on MSC_ConnHdlr {
4552 g_pars := f_gen_test_hdlr_pars();
4553 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4554 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
4555 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4556 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '08'O;
4557 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '01'O;
4558 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4559 f_establish_fully(ass_cmd, exp_fail);
4560}
4561
4562/* Allow FR and HR, but prefer FR */
4563private function f_TC_assignment_codec_fr_exhausted_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
4564 g_pars := f_gen_test_hdlr_pars();
4565 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4566 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4567 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4568 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
4569 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
4570 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
4571 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
4572 f_establish_fully(ass_cmd, exp_compl);
4573}
4574
4575/* Allow FR and HR, but prefer HR */
4576private function f_TC_assignment_codec_fr_exhausted_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
4577 g_pars := f_gen_test_hdlr_pars();
4578 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4579 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4580 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4581 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
4582 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
4583 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
4584 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
4585 f_establish_fully(ass_cmd, exp_compl);
4586}
4587
4588/* Allow FR and HR, but prefer FR */
4589private function f_TC_assignment_codec_hr_exhausted_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
4590 g_pars := f_gen_test_hdlr_pars();
4591 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4592 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4593 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4594 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
4595 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
4596 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
4597 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
4598 f_establish_fully(ass_cmd, exp_compl);
4599}
4600
4601/* Allow FR and HR, but prefer HR */
4602private function f_TC_assignment_codec_hr_exhausted_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
4603 g_pars := f_gen_test_hdlr_pars();
4604 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4605 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4606 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4607 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
4608 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
4609 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
4610 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
4611 f_establish_fully(ass_cmd, exp_compl);
4612}
4613
4614/* Request a HR channel while all FR channels are exhausted, this is expected
4615 * to work without conflicts */
4616testcase TC_assignment_codec_fr_exhausted_req_hr() runs on test_CT {
4617 var MSC_ConnHdlr vc_conn;
4618 f_init(1, true);
4619 f_sleep(1.0);
4620 f_enable_all_tch();
4621 f_disable_all_tch_f();
4622 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_hr));
4623 vc_conn.done;
4624 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004625 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004626}
4627
4628/* Request a FR channel while all FR channels are exhausted, this is expected
4629 * to fail. */
4630testcase TC_assignment_codec_fr_exhausted_req_fr() runs on test_CT {
4631 var MSC_ConnHdlr vc_conn;
4632 f_init(1, true);
4633 f_sleep(1.0);
4634 f_enable_all_tch();
4635 f_disable_all_tch_f();
4636 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_fr_fail));
4637 vc_conn.done;
4638 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004639 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004640}
4641
4642/* Request a FR (prefered) or alternatively a HR channel while all FR channels
4643 * are exhausted, this is expected to be resolved by selecting a HR channel. */
4644testcase TC_assignment_codec_fr_exhausted_req_fr_hr() runs on test_CT {
4645 var MSC_ConnHdlr vc_conn;
4646 f_init(1, true);
4647 f_sleep(1.0);
4648 f_enable_all_tch();
4649 f_disable_all_tch_f();
4650 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fr_exhausted_req_fr_hr));
4651 vc_conn.done;
4652 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004653 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004654}
4655
4656/* Request a HR (prefered) or alternatively a FR channel while all FR channels
4657 * are exhausted, this is expected to work without conflicts. */
4658testcase TC_assignment_codec_fr_exhausted_req_hr_fr() runs on test_CT {
4659 var MSC_ConnHdlr vc_conn;
4660 f_init(1, true);
4661 f_sleep(1.0);
4662 f_enable_all_tch();
4663 f_disable_all_tch_f();
4664 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fr_exhausted_req_hr_fr));
4665 vc_conn.done;
4666 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004667 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004668}
4669
4670/* Request a FR channel while all HR channels are exhausted, this is expected
4671 * to work without conflicts */
4672testcase TC_assignment_codec_hr_exhausted_req_fr() runs on test_CT {
4673 var MSC_ConnHdlr vc_conn;
4674 f_init(1, true);
4675 f_sleep(1.0);
4676 f_enable_all_tch();
4677 f_disable_all_tch_h();
4678 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_fr));
4679 vc_conn.done;
4680 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004681 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004682}
4683
4684/* Request a HR channel while all HR channels are exhausted, this is expected
4685 * to fail. */
4686testcase TC_assignment_codec_hr_exhausted_req_hr() runs on test_CT {
4687 var MSC_ConnHdlr vc_conn;
4688 f_init(1, true);
4689 f_sleep(1.0);
4690 f_enable_all_tch();
4691 f_disable_all_tch_h();
4692 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_hr_fail));
4693 vc_conn.done;
4694 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004695 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004696}
4697
4698/* Request a HR (prefered) or alternatively a FR channel while all HR channels
4699 * are exhausted, this is expected to be resolved by selecting a FR channel. */
4700testcase TC_assignment_codec_hr_exhausted_req_hr_fr() runs on test_CT {
4701 var MSC_ConnHdlr vc_conn;
4702 f_init(1, true);
4703 f_sleep(1.0);
4704 f_enable_all_tch();
4705 f_disable_all_tch_h();
4706 vc_conn := f_start_handler(refers(f_TC_assignment_codec_hr_exhausted_req_hr_fr));
4707 vc_conn.done;
4708 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004709 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004710}
4711
4712/* Request a FR (prefered) or alternatively a HR channel while all HR channels
4713 * are exhausted, this is expected to work without conflicts. */
4714testcase TC_assignment_codec_hr_exhausted_req_fr_hr() runs on test_CT {
4715 var MSC_ConnHdlr vc_conn;
4716 f_init(1, true);
4717 f_sleep(1.0);
4718 f_enable_all_tch();
4719 f_disable_all_tch_h();
4720 vc_conn := f_start_handler(refers(f_TC_assignment_codec_hr_exhausted_req_fr_hr));
4721 vc_conn.done;
4722 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004723 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004724}
4725
4726/* Allow FR and HR, but prefer HR */
4727private function f_TC_assignment_codec_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
4728 g_pars := f_gen_test_hdlr_pars();
4729 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4730 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4731 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4732 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
4733 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
4734 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
4735 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
4736 f_establish_fully(ass_cmd, exp_compl);
4737}
4738
4739/* Allow FR and HR, but prefer FR */
4740private function f_TC_assignment_codec_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
4741 g_pars := f_gen_test_hdlr_pars();
4742 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4743 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4744 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4745 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
4746 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
4747 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
4748 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
4749 f_establish_fully(ass_cmd, exp_compl);
4750}
4751
4752/* Request a HR (prefered) or alternatively a FR channel, it is expected that
4753 * HR, which is the prefered type, is selected. */
4754testcase TC_assignment_codec_req_hr_fr() runs on test_CT {
4755 var MSC_ConnHdlr vc_conn;
4756 f_init(1, true);
4757 f_sleep(1.0);
4758 f_enable_all_tch();
4759 vc_conn := f_start_handler(refers(f_TC_assignment_codec_req_hr_fr));
4760 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004761 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004762}
4763
4764/* Request a FR (prefered) or alternatively a HR channel, it is expected that
4765 * FR, which is the prefered type, is selected. */
4766testcase TC_assignment_codec_req_fr_hr() runs on test_CT {
4767 var MSC_ConnHdlr vc_conn;
4768 f_init(1, true);
4769 f_sleep(1.0);
4770 f_enable_all_tch();
4771 vc_conn := f_start_handler(refers(f_TC_assignment_codec_req_fr_hr));
4772 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004773 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004774}
4775
Pau Espin Pedrol14475352021-07-22 15:48:16 +02004776/* request a signalling channel with all SDCCH exhausted, it is expected that a TCH will be selected */
4777private function f_TC_assignment_sdcch_exhausted_req_signalling(charstring id) runs on MSC_ConnHdlr {
4778 g_pars := f_gen_test_hdlr_pars();
4779 g_pars.ra := '02'O; /* RA containing reason=LU */
4780
4781 var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi));
4782 var PDU_ML3_MS_NW l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, mi));
4783 var octetstring l3_enc := enc_PDU_ML3_MS_NW(l3_info);
4784 var template uint3_t tsc := ?;
4785
4786 f_MscConnHdlr_init(g_pars.media_nr, host_bts, host_mgw_mgcp, FR_AMR);
4787 f_create_bssmap_exp(l3_enc);
4788 /* call helper function for CHAN_RQD -> IMM ASS ->EST_IND */
4789 RSL_Emulation.f_chan_est(g_pars.ra, l3_enc, g_pars.link_id, g_pars.fn, tsc);
4790
4791 /* we should now have a COMPL_L3 at the MSC */
4792 timer T := 10.0;
4793 T.start;
4794 alt {
4795 [] BSSAP.receive(tr_BSSMAP_ComplL3);
4796 [] T.timeout {
4797 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for COMPLETE LAYER 3 INFORMATION");
4798 }
4799 }
4800}
4801testcase TC_assignment_sdcch_exhausted_req_signalling() runs on test_CT {
4802 var MSC_ConnHdlr vc_conn;
4803 f_init(1, true);
4804 f_sleep(1.0);
4805 f_disable_all_sdcch();
4806 vc_conn := f_start_handler(refers(f_TC_assignment_sdcch_exhausted_req_signalling));
4807 vc_conn.done;
4808 f_enable_all_sdcch();
4809 f_shutdown_helper();
4810}
4811
4812/* Request a signalling channel with all SDCCH exhausted, it is
4813 expected that no TCH will be selected for signalling and assigment will fail
4814 because it's dictated by VTY config */
4815testcase TC_assignment_sdcch_exhausted_req_signalling_tch_forbidden() runs on test_CT {
4816 var RSL_Message rsl_unused, rsl_msg;
4817 var GsmRrMessage rr;
4818 f_init(1, false);
4819 f_sleep(1.0);
4820 f_vty_allow_tch_for_signalling(false, 0);
4821 f_disable_all_sdcch();
4822
4823 /* RA containing reason=LU */
4824 f_ipa_tx(0, ts_RSL_CHAN_RQD('02'O, 2342));
4825 rsl_msg := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
4826 rr := dec_GsmRrMessage(rsl_msg.ies[1].body.full_imm_ass_info.payload);
4827 if (rr.header.message_type != IMMEDIATE_ASSIGNMENT_REJECT) {
4828 setverdict(fail, "Expected reject");
4829 }
4830
4831 f_vty_allow_tch_for_signalling(true, 0);
4832 f_enable_all_sdcch();
4833 f_shutdown_helper();
4834}
4835
4836/* Request a voice channel with all SDCCH exhausted, it is
4837 * expected that TCH channel will be allocated since the VTY option is only
4838 * aimed at signalling requests */
4839private function f_TC_assignment_sdcch_exhausted_req_voice_tch_forbidden(charstring id) runs on MSC_ConnHdlr {
4840 g_pars := f_gen_test_hdlr_pars();
4841 g_pars.ra := '43'O; /* RA containing reason=originating speech call*/
4842
4843 var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi));
4844 var PDU_ML3_MS_NW l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, mi));
4845 var octetstring l3_enc := enc_PDU_ML3_MS_NW(l3_info);
4846 var template uint3_t tsc := ?;
4847
4848 f_MscConnHdlr_init(g_pars.media_nr, host_bts, host_mgw_mgcp, FR_AMR);
4849 f_create_bssmap_exp(l3_enc);
4850 /* call helper function for CHAN_RQD -> IMM ASS ->EST_IND */
4851 RSL_Emulation.f_chan_est(g_pars.ra, l3_enc, g_pars.link_id, g_pars.fn, tsc);
4852
4853 /* we should now have a COMPL_L3 at the MSC */
4854 timer T := 10.0;
4855 T.start;
4856 alt {
4857 [] BSSAP.receive(tr_BSSMAP_ComplL3);
4858 [] T.timeout {
4859 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for COMPLETE LAYER 3 INFORMATION");
4860 }
4861 }
4862}
4863testcase TC_assignment_sdcch_exhausted_req_voice_tch_forbidden() runs on test_CT {
4864 var MSC_ConnHdlr vc_conn;
4865 f_init(1, true);
4866 f_sleep(1.0);
4867 f_vty_allow_tch_for_signalling(false, 0);
4868 f_disable_all_sdcch();
4869
4870 vc_conn := f_start_handler(refers(f_TC_assignment_sdcch_exhausted_req_voice_tch_forbidden));
4871 vc_conn.done;
4872
4873 f_vty_allow_tch_for_signalling(true, 0);
4874 f_enable_all_sdcch();
4875 f_shutdown_helper();
4876}
4877
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02004878testcase TC_assignment_osmux() runs on test_CT {
4879 var TestHdlrParams pars := f_gen_test_hdlr_pars();
4880 var MSC_ConnHdlr vc_conn;
4881
4882 /* See note above */
4883 var RSL_IE_Body mr_conf := {
4884 other := {
4885 len := 2,
4886 payload := '2804'O
4887 }
4888 };
4889
4890 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
4891 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
4892 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
4893 pars.expect_mr_conf_ie := mr_conf;
4894 pars.use_osmux := true;
4895
4896 f_init(1, true, true);
4897 f_sleep(1.0);
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00004898 f_vty_amr_start_mode_set(false, "1");
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02004899
4900 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
4901 vc_conn.done;
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00004902
4903 f_vty_amr_start_mode_restore(false);
Vadim Yanitskiy292e5962021-01-03 14:18:47 +01004904 f_shutdown_helper();
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02004905}
4906
Neels Hofmeyr92b12b72018-09-18 14:30:23 +02004907/* test the procedure of the MSC requesting a Classmark Update:
4908 * a) BSSMAP Classmark Request should result in RR CLASSMARK ENQUIRY,
4909 * b) L3 RR CLASSMARK CHANGE should result in BSSMAP CLASSMARK UPDATE */
Harald Welte898113b2018-01-31 18:32:21 +01004910private function f_tc_classmark(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004911 g_pars := f_gen_test_hdlr_pars();
4912
Harald Weltea0630032018-03-20 21:09:55 +01004913 f_create_chan_and_exp();
Harald Welte898113b2018-01-31 18:32:21 +01004914 /* we should now have a COMPL_L3 at the MSC */
4915 BSSAP.receive(tr_BSSMAP_ComplL3);
4916
Neels Hofmeyr92b12b72018-09-18 14:30:23 +02004917 BSSAP.send(ts_BSSMAP_ClassmarkRequest);
4918 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_CM_ENQUIRY));
4919
Harald Welte898113b2018-01-31 18:32:21 +01004920 f_rsl_send_l3(ts_RRM_CM_CHG(valueof(ts_CM2)));
4921 BSSAP.receive(tr_BSSMAP_ClassmarkUpd(?, omit));
4922 setverdict(pass);
4923}
4924testcase TC_classmark() runs on test_CT {
4925 var MSC_ConnHdlr vc_conn;
4926 f_init(1, true);
4927 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004928 vc_conn := f_start_handler(refers(f_tc_classmark));
Harald Welte898113b2018-01-31 18:32:21 +01004929 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004930 f_shutdown_helper();
Harald Welte898113b2018-01-31 18:32:21 +01004931}
4932
Harald Welteeddf0e92020-06-21 19:42:15 +02004933/* Send a CommonID from the simulated MSC and verify that the information is used to
4934 * fill BSC-internal data structures (specifically, bsc_subscr associated with subscr_conn) */
4935private function f_tc_common_id(charstring id) runs on MSC_ConnHdlr {
4936 g_pars := f_gen_test_hdlr_pars();
4937 f_MscConnHdlr_init_vty();
4938
4939 f_create_chan_and_exp();
4940 /* we should now have a COMPL_L3 at the MSC */
4941 BSSAP.receive(tr_BSSMAP_ComplL3);
4942
4943 /* Send CommonID */
4944 BSSAP.send(ts_BSSMAP_CommonId(g_pars.imsi));
4945
4946 /* Use VTY to verify that the IMSI of the subscr_conn is set */
4947 var charstring regex := "*(IMSI: " & hex2str(g_pars.imsi) & ")*";
4948 f_vty_transceive_match_regexp_retry(BSCVTY, "show conns", regex, 0, 4, 1.0);
4949
4950 setverdict(pass);
4951}
4952testcase TC_common_id() runs on test_CT {
4953 var MSC_ConnHdlr vc_conn;
4954 f_init(1, true);
4955 f_sleep(1.0);
4956 vc_conn := f_start_handler(refers(f_tc_common_id));
4957 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004958 f_shutdown_helper();
Harald Welteeddf0e92020-06-21 19:42:15 +02004959}
4960
Harald Weltee3bd6582018-01-31 22:51:25 +01004961private function f_est_single_l3(template PDU_ML3_MS_NW l3) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004962 g_pars := f_gen_test_hdlr_pars();
Harald Weltea0630032018-03-20 21:09:55 +01004963 f_create_chan_and_exp();
Harald Welte898113b2018-01-31 18:32:21 +01004964 /* we should now have a COMPL_L3 at the MSC */
4965 BSSAP.receive(tr_BSSMAP_ComplL3);
4966
Harald Weltee3bd6582018-01-31 22:51:25 +01004967 /* send the single message we want to send */
4968 f_rsl_send_l3(l3);
4969}
4970
4971private function f_bssap_expect_nothing(float sec := 5.00) runs on MSC_ConnHdlr {
4972 timer T := sec;
4973 var PDU_BSSAP bssap;
Harald Welte898113b2018-01-31 18:32:21 +01004974 T.start;
4975 alt {
Harald Weltee3bd6582018-01-31 22:51:25 +01004976 [] BSSAP.receive(PDU_BSSAP:?) -> value bssap {
4977 setverdict(fail, "Unexpected BSSMAP ", bssap);
Daniel Willmannafce8662018-07-06 23:11:32 +02004978 mtc.stop;
Harald Welte898113b2018-01-31 18:32:21 +01004979 }
4980 [] T.timeout {
4981 setverdict(pass);
4982 }
4983 }
4984}
4985
Harald Weltee3bd6582018-01-31 22:51:25 +01004986/* unsolicited ASSIGNMENT FAIL (without ASSIGN) from MS shouldn't bring BSC down */
4987private function f_tc_unsol_ass_fail(charstring id) runs on MSC_ConnHdlr {
4988 f_est_single_l3(ts_RRM_AssignmentFailure('00'O));
4989 f_bssap_expect_nothing();
4990}
Harald Welte898113b2018-01-31 18:32:21 +01004991testcase TC_unsol_ass_fail() runs on test_CT {
4992 var MSC_ConnHdlr vc_conn;
4993 f_init(1, true);
4994 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004995 vc_conn := f_start_handler(refers(f_tc_unsol_ass_fail));
Harald Welte898113b2018-01-31 18:32:21 +01004996 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004997 f_shutdown_helper();
Harald Welte898113b2018-01-31 18:32:21 +01004998}
Harald Welte552620d2017-12-16 23:21:36 +01004999
Harald Welteea99a002018-01-31 20:46:43 +01005000
5001/* unsolicited ASSIGNMENT COMPLETE (without ASSIGN) from MS shouldn't bring BSC down */
5002private function f_tc_unsol_ass_compl(charstring id) runs on MSC_ConnHdlr {
Harald Weltee3bd6582018-01-31 22:51:25 +01005003 f_est_single_l3(ts_RRM_AssignmentComplete('00'O));
5004 f_bssap_expect_nothing();
Harald Welteea99a002018-01-31 20:46:43 +01005005}
5006testcase TC_unsol_ass_compl() runs on test_CT {
5007 var MSC_ConnHdlr vc_conn;
5008 f_init(1, true);
5009 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02005010 vc_conn := f_start_handler(refers(f_tc_unsol_ass_compl));
Harald Welteea99a002018-01-31 20:46:43 +01005011 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005012 f_shutdown_helper();
Harald Welteea99a002018-01-31 20:46:43 +01005013}
5014
5015
Harald Weltefbf9b5e2018-01-31 20:41:23 +01005016/* unsolicited HANDOVER FAIL (without ASSIGN) from MS shouldn't bring BSC down */
5017private function f_tc_unsol_ho_fail(charstring id) runs on MSC_ConnHdlr {
Harald Weltee3bd6582018-01-31 22:51:25 +01005018 f_est_single_l3(ts_RRM_HandoverFailure('00'O));
5019 f_bssap_expect_nothing();
Harald Weltefbf9b5e2018-01-31 20:41:23 +01005020}
Harald Weltefbf9b5e2018-01-31 20:41:23 +01005021testcase TC_unsol_ho_fail() runs on test_CT {
5022 var MSC_ConnHdlr vc_conn;
5023 f_init(1, true);
5024 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02005025 vc_conn := f_start_handler(refers(f_tc_unsol_ho_fail));
Harald Weltefbf9b5e2018-01-31 20:41:23 +01005026 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005027 f_shutdown_helper();
Harald Weltefbf9b5e2018-01-31 20:41:23 +01005028}
5029
5030
Harald Weltee3bd6582018-01-31 22:51:25 +01005031/* short message from MS should be ignored */
5032private function f_tc_err_82_short_msg(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02005033 g_pars := f_gen_test_hdlr_pars();
Harald Weltea0630032018-03-20 21:09:55 +01005034 f_create_chan_and_exp();
Harald Weltee3bd6582018-01-31 22:51:25 +01005035 /* we should now have a COMPL_L3 at the MSC */
5036 BSSAP.receive(tr_BSSMAP_ComplL3);
5037
5038 /* send short message */
5039 RSL.send(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), ''O));
5040 f_bssap_expect_nothing();
5041}
5042testcase TC_err_82_short_msg() runs on test_CT {
5043 var MSC_ConnHdlr vc_conn;
5044 f_init(1, true);
5045 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02005046 vc_conn := f_start_handler(refers(f_tc_err_82_short_msg));
Harald Weltee3bd6582018-01-31 22:51:25 +01005047 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005048 f_shutdown_helper();
Harald Weltee3bd6582018-01-31 22:51:25 +01005049}
5050
5051
Harald Weltee9e02e42018-01-31 23:36:25 +01005052/* 24.008 8.4 Unknown message must trigger RR STATUS */
5053private function f_tc_err_84_unknown_msg(charstring id) runs on MSC_ConnHdlr {
5054 f_est_single_l3(ts_RRM_UL_REL('00'O));
5055 timer T := 3.0
5056 alt {
5057 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_STATUS)) {
5058 setverdict(pass);
5059 }
5060 [] BSSAP.receive { setverdict(fail, "unexpected BSSAP"); }
Harald Welte458fd372018-03-21 11:26:23 +01005061 [] T.timeout { setverdict(fail, "Timeout waiting for RR STATUS"); }
Harald Weltee9e02e42018-01-31 23:36:25 +01005062 }
5063}
5064testcase TC_err_84_unknown_msg() runs on test_CT {
5065 var MSC_ConnHdlr vc_conn;
5066 f_init(1, true);
5067 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02005068 vc_conn := f_start_handler(refers(f_tc_err_84_unknown_msg));
Harald Weltee9e02e42018-01-31 23:36:25 +01005069 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005070 f_shutdown_helper();
Harald Weltee9e02e42018-01-31 23:36:25 +01005071}
5072
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005073/***********************************************************************
5074 * Handover
5075 ***********************************************************************/
5076
Harald Welte94e0c342018-04-07 11:33:23 +02005077/* execute a "bts <0-255> trx <0-255> timeslot <0-7> " command on given Dchan */
5078private function f_vty_ts_action(charstring suffix, integer bts_nr, integer trx_nr, integer ts_nr)
5079runs on test_CT {
5080 var charstring cmd := "bts "&int2str(bts_nr)&" trx "&int2str(trx_nr)&
5081 " timeslot "&int2str(ts_nr)&" ";
5082 f_vty_transceive(BSCVTY, cmd & suffix);
5083}
5084
Harald Welte261af4b2018-02-12 21:20:39 +01005085/* 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 +07005086private function f_vty_ss_action(TELNETasp_PT pt, charstring suffix,
5087 uint8_t bts_nr, uint8_t trx_nr,
5088 in RslChannelNr chan_nr)
5089{
Harald Welte261af4b2018-02-12 21:20:39 +01005090 /* FIXME: resolve those from component-global state */
5091 var integer ts_nr := chan_nr.tn;
5092 var integer ss_nr;
5093 if (ischosen(chan_nr.u.ch0)) {
5094 ss_nr := 0;
5095 } else if (ischosen(chan_nr.u.lm)) {
5096 ss_nr := chan_nr.u.lm.sub_chan;
5097 } else if (ischosen(chan_nr.u.sdcch4)) {
5098 ss_nr := chan_nr.u.sdcch4.sub_chan;
5099 } else if (ischosen(chan_nr.u.sdcch8)) {
5100 ss_nr := chan_nr.u.sdcch8.sub_chan;
5101 } else {
5102 setverdict(fail, "Invalid ChanNr ", chan_nr);
Daniel Willmannafce8662018-07-06 23:11:32 +02005103 mtc.stop;
Harald Welte261af4b2018-02-12 21:20:39 +01005104 }
5105
5106 var charstring cmd := "bts "&int2str(bts_nr)&" trx "&int2str(trx_nr)&
5107 " timeslot "&int2str(ts_nr)&" sub-slot "&int2str(ss_nr)&" ";
Vadim Yanitskiy00070722020-09-02 17:27:57 +07005108 f_vty_transceive(pt, cmd & suffix);
Harald Welte261af4b2018-02-12 21:20:39 +01005109}
5110
Neels Hofmeyr91401012019-07-11 00:42:35 +02005111/* Even though the VTY command to trigger handover takes a new BTS number as argument, behind the scenes osmo-bsc always
5112 * translates that to a target ARFCN+BSIC first. See bsc_vty.c trigger_ho_or_as(), which puts the selected BTS' neighbor
5113 * ident key (ARFCN + BSIC) in the struct passed on to handover_request(). handover_start() then resolves that to a
5114 * viable actual neighbor cell. So from the internal osmo-bsc perspective, we always request handover to an ARFCN + BSIC
5115 * pair, not really to a specific BTS number. */
Vadim Yanitskiy00070722020-09-02 17:27:57 +07005116private function f_vty_handover(TELNETasp_PT pt, uint8_t bts_nr, uint8_t trx_nr,
5117 in RslChannelNr chan_nr, uint8_t new_bts_nr)
5118{
5119 f_vty_ss_action(pt, "handover " & int2str(new_bts_nr), bts_nr, trx_nr, chan_nr);
Harald Welte261af4b2018-02-12 21:20:39 +01005120}
5121
5122/* intra-BSC hand-over between BTS0 and BTS1 */
5123private function f_tc_ho_int(charstring id) runs on MSC_ConnHdlr {
Harald Welteed848512018-05-24 22:27:58 +02005124 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
5125 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte261af4b2018-02-12 21:20:39 +01005126
5127 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
5128 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
5129
Harald Weltea0630032018-03-20 21:09:55 +01005130 f_establish_fully(ass_cmd, exp_compl);
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005131 f_bts_0_cfg(BSCVTY, {"neighbor bts 1"});
Harald Welte261af4b2018-02-12 21:20:39 +01005132
5133 var HandoverState hs := {
5134 rr_ho_cmpl_seen := false,
5135 handover_done := false,
Neels Hofmeyrc741fcb2021-10-02 14:52:28 +02005136 old_chan_nr := -,
5137 expect_target_tsc := BTS_TSC[1]
Harald Welte261af4b2018-02-12 21:20:39 +01005138 };
Neels Hofmeyrc2cf4542021-10-02 12:26:38 +02005139 /* issue hand-over command on VTY, from BTS 0 to BTS 1 */
Vadim Yanitskiy00070722020-09-02 17:27:57 +07005140 f_vty_handover(BSCVTY, 0, 0, g_chan_nr, 1);
Harald Welte261af4b2018-02-12 21:20:39 +01005141 /* temporarily suspend DChan processing on BTS1 to avoid race with RSLEM_register */
5142 f_rslem_suspend(RSL1_PROC);
Philipp Maier3e2af5d2018-07-11 17:01:05 +02005143
5144 /* From the MGW perspective, a handover is is characterized by
5145 * performing one MDCX operation with the MGW. So we expect to see
5146 * one more MDCX during handover. */
5147 g_media.mgcp_conn[0].mdcx_seen_exp := g_media.mgcp_conn[0].crcx_seen_exp + 1;
5148
Harald Welte261af4b2018-02-12 21:20:39 +01005149 alt {
5150 [] as_handover(hs);
Harald Welte261af4b2018-02-12 21:20:39 +01005151 }
Philipp Maier3e2af5d2018-07-11 17:01:05 +02005152
Philipp Maier4dae0652018-11-12 12:03:26 +01005153 /* Since this is an internal handover we expect the BSC to inform the
5154 * MSC about the event */
5155 BSSAP.receive(tr_BSSMAP_HandoverPerformed);
5156
Philipp Maier3e2af5d2018-07-11 17:01:05 +02005157 /* Check the amount of MGCP transactions is still consistant with the
5158 * test expectation */
5159 f_check_mgcp_expectations()
Neels Hofmeyraf88d9d2021-06-21 02:14:27 +02005160
Neels Hofmeyrc2cf4542021-10-02 12:26:38 +02005161 var RSL_Message chan_act := f_rslem_get_last_act(RSL1_PROC, 0, g_chan_nr);
5162
Neels Hofmeyraf88d9d2021-06-21 02:14:27 +02005163 /* Ensure the Channel Activation for the new channel contained the right encryption params. as_handover() set
5164 * g_chan_nr to the new lchan that was handed over to. It lives in bts 1, so look it up at RSL1_PROC. */
Neels Hofmeyrc2cf4542021-10-02 12:26:38 +02005165 f_verify_encr_info(chan_act);
5166
5167 f_chan_act_verify_tsc(chan_act, BTS_TSC[1]);
Neels Hofmeyraf88d9d2021-06-21 02:14:27 +02005168
Neels Hofmeyr861a4c12018-11-07 01:23:17 +01005169 f_sleep(0.5);
Harald Welte261af4b2018-02-12 21:20:39 +01005170}
5171
5172testcase TC_ho_int() runs on test_CT {
Neels Hofmeyr5f7a9df2021-06-21 01:30:43 +02005173 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte261af4b2018-02-12 21:20:39 +01005174 var MSC_ConnHdlr vc_conn;
5175 f_init(2, true);
5176 f_sleep(1.0);
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005177
Neels Hofmeyrc2cf4542021-10-02 12:26:38 +02005178 pars.expect_tsc := BTS_TSC[0];
5179
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01005180 f_ctrs_bsc_and_bts_handover_init();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005181
Neels Hofmeyr5f7a9df2021-06-21 01:30:43 +02005182 vc_conn := f_start_handler(refers(f_tc_ho_int), pars);
Harald Welte261af4b2018-02-12 21:20:39 +01005183 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005184
5185 /* from f_establish_fully() */
5186 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5187 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5188 /* from handover */
5189 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5190 f_ctrs_bsc_and_bts_add(0, "handover:completed");
5191 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5192 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:completed");
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01005193 f_ctrs_bts_add(1, "incoming_intra_bsc_ho:attempted");
5194 f_ctrs_bts_add(1, "incoming_intra_bsc_ho:completed");
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005195 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005196 f_shutdown_helper();
Harald Welte261af4b2018-02-12 21:20:39 +01005197}
Harald Weltee9e02e42018-01-31 23:36:25 +01005198
Oliver Smith7eabd312021-07-12 14:18:56 +02005199function f_tc_ho_int_a5(OCT1 encr_alg, charstring enc_a5 := "0 1 3") runs on test_CT {
Neels Hofmeyraf88d9d2021-06-21 02:14:27 +02005200 var MSC_ConnHdlr vc_conn;
5201 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5202 pars.encr := valueof(t_EncrParams(encr_alg, f_rnd_octstring(8), f_rnd_octstring(16)));
5203
5204 f_init(2, true);
Oliver Smith7eabd312021-07-12 14:18:56 +02005205 f_vty_encryption_a5(enc_a5);
Neels Hofmeyraf88d9d2021-06-21 02:14:27 +02005206 f_sleep(1.0);
5207
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01005208 f_ctrs_bsc_and_bts_handover_init();
Neels Hofmeyraf88d9d2021-06-21 02:14:27 +02005209
5210 vc_conn := f_start_handler(refers(f_tc_ho_int), pars);
5211 vc_conn.done;
5212
5213 /* from f_establish_fully() */
5214 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5215 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5216 /* from handover */
5217 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5218 f_ctrs_bsc_and_bts_add(0, "handover:completed");
5219 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5220 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:completed");
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01005221 f_ctrs_bts_add(1, "incoming_intra_bsc_ho:attempted");
5222 f_ctrs_bts_add(1, "incoming_intra_bsc_ho:completed");
Neels Hofmeyraf88d9d2021-06-21 02:14:27 +02005223 f_ctrs_bsc_and_bts_verify();
Oliver Smith7eabd312021-07-12 14:18:56 +02005224 f_vty_encryption_a5_reset();
Neels Hofmeyraf88d9d2021-06-21 02:14:27 +02005225 f_shutdown_helper();
5226}
5227
5228testcase TC_ho_int_a5_0() runs on test_CT {
5229 f_tc_ho_int_a5('01'O);
5230}
5231
5232testcase TC_ho_int_a5_1() runs on test_CT {
5233 f_tc_ho_int_a5('02'O);
5234}
5235
5236testcase TC_ho_int_a5_3() runs on test_CT {
5237 f_tc_ho_int_a5('08'O);
5238}
5239
5240testcase TC_ho_int_a5_4() runs on test_CT {
Oliver Smith7eabd312021-07-12 14:18:56 +02005241 f_tc_ho_int_a5('10'O, "0 1 3 4");
Neels Hofmeyraf88d9d2021-06-21 02:14:27 +02005242}
5243
Neels Hofmeyr5f144212020-11-03 15:41:58 +00005244/* intra-BSC hand-over with CONNection FAILure and cause Radio Link Failure: check RR release cause */
5245private function f_tc_ho_int_radio_link_failure(charstring id) runs on MSC_ConnHdlr {
5246 g_pars := f_gen_test_hdlr_pars();
5247 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
5248 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Neels Hofmeyr5f144212020-11-03 15:41:58 +00005249
5250 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
5251 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
5252
5253 f_establish_fully(ass_cmd, exp_compl);
5254 f_bts_0_cfg(BSCVTY, {"neighbor bts 1"});
5255
5256 var HandoverState hs := {
5257 rr_ho_cmpl_seen := false,
5258 handover_done := false,
Neels Hofmeyrc741fcb2021-10-02 14:52:28 +02005259 old_chan_nr := -,
5260 expect_target_tsc := BTS_TSC[1]
Neels Hofmeyr5f144212020-11-03 15:41:58 +00005261 };
5262 /* issue hand-over command on VTY */
5263 f_vty_handover(BSCVTY, 0, 0, g_chan_nr, 1);
5264 /* temporarily suspend DChan processing on BTS1 to avoid race with RSLEM_register */
5265 f_rslem_suspend(RSL1_PROC);
5266
5267 /* From the MGW perspective, a handover is is characterized by
5268 * performing one MDCX operation with the MGW. So we expect to see
5269 * one more MDCX during handover. */
5270 g_media.mgcp_conn[0].mdcx_seen_exp := g_media.mgcp_conn[0].crcx_seen_exp + 1;
5271
5272 var RSL_Message rsl;
5273 var PDU_ML3_NW_MS l3;
5274 var RslChannelNr new_chan_nr;
5275 var GsmArfcn arfcn;
5276 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr)) -> value rsl {
5277 l3 := dec_PDU_ML3_NW_MS(rsl.ies[2].body.l3_info.payload);
5278 if (not ischosen(l3.msgs.rrm.handoverCommand)) {
5279 setverdict(fail, "Expected handoverCommand");
5280 mtc.stop;
5281 }
5282 }
5283 f_ChDesc2RslChanNr(l3.msgs.rrm.handoverCommand.channelDescription2,
5284 new_chan_nr, arfcn);
5285
5286 f_rslem_register(0, new_chan_nr, RSL1_PROC);
5287
5288 /* resume processing of RSL DChan messages, which was temporarily suspended
5289 * before performing a hand-over */
5290 f_rslem_resume(RSL1_PROC);
5291 RSL1.receive(tr_RSL_IPA_CRCX(new_chan_nr));
5292
5293 f_sleep(1.0);
5294
5295 /* Handover fails because no HANDO DET appears on the new lchan,
5296 * and the old lchan reports a Radio Link Failure. */
5297 RSL.send(ts_RSL_CONN_FAIL_IND(g_chan_nr, RSL_ERR_RADIO_LINK_FAIL));
5298
5299 var PDU_BSSAP rx_clear_request;
5300 BSSAP.receive(tr_BSSMAP_ClearRequest) -> value rx_clear_request;
5301 var BssmapCause cause := bit2int(rx_clear_request.pdu.bssmap.clearRequest.cause.causeValue);
5302 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5303
5304 var RR_Cause rr_cause := GSM48_RR_CAUSE_ABNORMAL_UNSPEC;
5305
5306 var MgcpCommand mgcp;
5307 interleave {
5308 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE(int2oct(enum2int(rr_cause), 1)))) {}
5309 [] RSL.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {}
Neels Hofmeyr3c5127e2021-07-22 19:18:40 +02005310 [] RSL.receive(tr_RSL_RF_CHAN_REL(g_chan_nr)) {
Neels Hofmeyr5f144212020-11-03 15:41:58 +00005311 RSL.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
Neels Hofmeyre680b012021-07-22 19:19:09 +02005312 f_rslem_unregister(0, g_chan_nr);
Neels Hofmeyr5f144212020-11-03 15:41:58 +00005313 }
5314 [] RSL1.receive(tr_RSL_DEACT_SACCH(new_chan_nr)) {}
Neels Hofmeyr3c5127e2021-07-22 19:18:40 +02005315 [] RSL1.receive(tr_RSL_RF_CHAN_REL(new_chan_nr)) {
Neels Hofmeyr5f144212020-11-03 15:41:58 +00005316 RSL1.send(ts_RSL_RF_CHAN_REL_ACK(new_chan_nr));
Neels Hofmeyre680b012021-07-22 19:19:09 +02005317 f_rslem_unregister(0, g_chan_nr, PT := RSL1_PROC);
Neels Hofmeyr5f144212020-11-03 15:41:58 +00005318 }
5319 [] BSSAP.receive(tr_BSSMAP_ClearComplete) {}
5320 }
5321
5322 f_sleep(0.5);
5323 setverdict(pass);
5324}
5325testcase TC_ho_int_radio_link_failure() runs on test_CT {
5326 var MSC_ConnHdlr vc_conn;
5327 f_init(2, true);
5328 f_sleep(1.0);
5329
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01005330 f_ctrs_bsc_and_bts_handover_init();
Neels Hofmeyr5f144212020-11-03 15:41:58 +00005331
5332 vc_conn := f_start_handler(refers(f_tc_ho_int_radio_link_failure));
5333 vc_conn.done;
5334
5335 /* from f_establish_fully() */
5336 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5337 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5338 /* from handover */
5339 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5340 f_ctrs_bsc_and_bts_add(0, "handover:stopped");
5341 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5342 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:stopped");
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01005343 f_ctrs_bts_add(1, "incoming_intra_bsc_ho:attempted");
5344 f_ctrs_bts_add(1, "incoming_intra_bsc_ho:stopped");
Neels Hofmeyr5f144212020-11-03 15:41:58 +00005345 f_ctrs_bsc_and_bts_verify();
5346 f_shutdown_helper();
5347}
5348
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02005349/* Expecting MGCP to DLCX the endpoint's two connections: towards BTS and towards MSC */
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005350private function f_expect_dlcx_conns() runs on MSC_ConnHdlr {
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02005351 var MgcpCommand mgcp;
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02005352 var template MgcpResponse mgcp_resp;
5353 var MGCP_RecvFrom mrf;
5354 var template MgcpMessage msg_resp;
5355 var template MgcpMessage msg_dlcx := {
5356 command := tr_DLCX()
5357 }
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02005358
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02005359 if (g_pars.aoip) {
5360 MGCP.receive(tr_DLCX()) -> value mgcp {
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02005361 log("Got first DLCX: ", mgcp);
5362 MGCP.send(ts_DLCX_ACK2(mgcp.line.trans_id));
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02005363 };
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02005364
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02005365 MGCP.receive(tr_DLCX()) -> value mgcp {
5366 log("Got second DLCX: ", mgcp);
5367 MGCP.send(ts_DLCX_ACK2(mgcp.line.trans_id));
5368 };
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02005369 } else {
5370 /* For SCCPLite, BSC doesn't handle the MSC-side */
5371 MGCP_MULTI.receive(tr_MGCP_RecvFrom_any(msg_dlcx)) -> value mrf {
5372 log("Got first DLCX: ", mrf.msg.command);
5373 msg_resp := {
5374 response := ts_DLCX_ACK2(mrf.msg.command.line.trans_id)
5375 }
5376 MGCP_MULTI.send(t_MGCP_SendToMrf(mrf, msg_resp));
5377 };
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02005378 }
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02005379}
5380
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005381private function f_ho_out_of_this_bsc(template (omit) BSSMAP_oldToNewBSSIEs exp_oldToNewBSSIEs := omit) runs on MSC_ConnHdlr {
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005382
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005383 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005384 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
5385
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005386 BSSAP.receive(tr_BSSMAP_HandoverRequired(exp_oldToNewBSSIEs));
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005387
5388 f_sleep(0.5);
5389 /* The MSC negotiates Handover Request and Handover Request Ack with
5390 * the other BSS and comes back with a BSSMAP Handover Command
5391 * containing an RR Handover Command coming from the target BSS... */
5392
5393 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
5394 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
5395 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
5396 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
5397 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
5398
5399 /* expect the Handover Command to go out on RR */
5400 var RSL_Message rsl_ho_cmd
5401 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
5402 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
5403 var RSL_IE_Body rsl_ho_cmd_l3;
5404 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
5405 log("RSL message contains no L3 Info IE, expected RR Handover Command");
5406 setverdict(fail);
5407 } else {
5408 log("Found L3 Info: ", rsl_ho_cmd_l3);
5409 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
5410 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
5411 setverdict(fail);
5412 } else {
5413 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
5414 setverdict(pass);
5415 }
5416 }
5417
5418 /* When the other BSS has reported a completed handover, this side is
5419 * torn down. */
5420
5421 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_HANDOVER_SUCCESSFUL;
5422 var BssmapCause cause := enum2int(cause_val);
5423 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5424
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005425 f_expect_dlcx_conns();
Pau Espin Pedrol06199952021-06-15 11:30:00 +02005426
5427 interleave {
5428 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE));
5429 [] RSL.receive(tr_RSL_DEACT_SACCH(g_chan_nr));
5430 [] RSL.receive(tr_RSL_RF_CHAN_REL(g_chan_nr));
Neels Hofmeyr8fcd8772021-07-22 16:12:57 +02005431 [] BSSAP.receive(tr_BSSMAP_ClearComplete);
Pau Espin Pedrol06199952021-06-15 11:30:00 +02005432 }
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005433 setverdict(pass);
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005434}
5435
5436private function f_tc_ho_out_of_this_bsc(charstring id) runs on MSC_ConnHdlr {
5437 g_pars := f_gen_test_hdlr_pars();
5438 var PDU_BSSAP ass_req := f_gen_ass_req();
5439 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
5440 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
5441 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
5442 f_establish_fully(ass_req, exp_compl);
5443
5444 f_ho_out_of_this_bsc();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005445}
5446testcase TC_ho_out_of_this_bsc() runs on test_CT {
5447 var MSC_ConnHdlr vc_conn;
5448
5449 f_init(1, true);
5450 f_sleep(1.0);
5451
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01005452 f_ctrs_bsc_and_bts_handover_init();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005453
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005454 vc_conn := f_start_handler(refers(f_tc_ho_out_of_this_bsc));
5455 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005456
5457 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5458 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5459 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5460 f_ctrs_bsc_and_bts_add(0, "handover:completed");
5461 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
5462 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:completed");
5463 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005464 f_shutdown_helper();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005465}
5466
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00005467private function f_mo_l3_transceive(RSL_DCHAN_PT rsl := RSL,
5468 template (value) RslLinkId link_id := ts_RslLinkID_DCCH(0),
Vadim Yanitskiy2ef6a2f2020-10-08 23:17:32 +07005469 template (present) OCT1 dlci := ?,
Vadim Yanitskiyb93aa432020-10-01 14:23:11 +07005470 octetstring l3 := '0123456789'O)
5471runs on MSC_ConnHdlr {
Neels Hofmeyr43654812020-09-25 01:35:35 +02005472 /* The old lchan and conn should still be active. See that arbitrary L3
5473 * is still going through. */
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00005474 rsl.send(ts_RSL_DATA_IND(g_chan_nr, link_id, l3));
Neels Hofmeyr43654812020-09-25 01:35:35 +02005475 var template PDU_BSSAP exp_data := {
5476 discriminator := '1'B,
5477 spare := '0000000'B,
Vadim Yanitskiyb93aa432020-10-01 14:23:11 +07005478 dlci := dlci,
5479 lengthIndicator := lengthof(l3),
Neels Hofmeyr43654812020-09-25 01:35:35 +02005480 pdu := {
5481 dtap := l3
5482 }
5483 };
5484 BSSAP.receive(exp_data);
5485 setverdict(pass);
5486}
5487
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00005488private function f_mt_l3_transceive(RSL_DCHAN_PT rsl := RSL,
5489 template (present) RslLinkId link_id := tr_RslLinkID_DCCH(0),
Vadim Yanitskiy0033a3b2020-10-01 22:21:16 +07005490 template (value) OCT1 dlci := '00'O,
5491 octetstring l3 := '0123456789'O)
5492runs on MSC_ConnHdlr {
5493 BSSAP.send(PDU_BSSAP:{
5494 discriminator := '1'B,
5495 spare := '0000000'B,
5496 dlci := dlci,
5497 lengthIndicator := lengthof(l3),
5498 pdu := {
5499 dtap := l3
5500 }
5501 });
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00005502 rsl.receive(tr_RSL_DATA_REQ(g_chan_nr, link_id, l3));
Vadim Yanitskiy0033a3b2020-10-01 22:21:16 +07005503 setverdict(pass);
5504}
5505
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005506/* BSC asks for inter-BSC HO, but the MSC decides that it won't happen and
5507 * simply never sends a BSSMAP Handover Command. */
5508private function f_tc_ho_out_fail_no_msc_response(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01005509 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005510
5511 var PDU_BSSAP ass_req := f_gen_ass_req();
5512 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
5513 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
5514 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
5515 f_establish_fully(ass_req, exp_compl);
5516
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005517 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005518 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
5519
5520 BSSAP.receive(tr_BSSMAP_HandoverRequired);
5521
5522 /* osmo-bsc should time out 10 seconds after the handover started.
5523 * Let's give it a bit extra. */
5524 f_sleep(15.0);
5525
Vadim Yanitskiy74ae5eb2020-10-01 22:13:29 +07005526 f_mo_l3_transceive();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005527 f_sleep(1.0);
5528}
5529testcase TC_ho_out_fail_no_msc_response() runs on test_CT {
5530 var MSC_ConnHdlr vc_conn;
5531
5532 f_init(1, true);
5533 f_sleep(1.0);
5534
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01005535 f_ctrs_bsc_and_bts_handover_init();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005536
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005537 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_no_msc_response));
5538 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005539
5540 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5541 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5542 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5543 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
5544 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
5545 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
5546 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005547 f_shutdown_helper();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005548}
5549
5550/* BSC asks for inter-BSC HO, receives BSSMAP Handover Command, but MS reports
5551 * RR Handover Failure. */
5552private function f_tc_ho_out_fail_rr_ho_failure(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01005553 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005554
5555 var PDU_BSSAP ass_req := f_gen_ass_req();
5556 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
5557 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
5558 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
5559 f_establish_fully(ass_req, exp_compl);
5560
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005561 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005562 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
5563
5564 BSSAP.receive(tr_BSSMAP_HandoverRequired);
5565
5566 f_sleep(0.5);
5567 /* The MSC negotiates Handover Request and Handover Request Ack with
5568 * the other BSS and comes back with a BSSMAP Handover Command
5569 * containing an RR Handover Command coming from the target BSS... */
5570
5571 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
5572 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
5573 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
5574 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
5575 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
5576
5577 /* expect the Handover Command to go out on RR */
5578 var RSL_Message rsl_ho_cmd
5579 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
5580 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
5581 var RSL_IE_Body rsl_ho_cmd_l3;
5582 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
5583 log("RSL message contains no L3 Info IE, expected RR Handover Command");
5584 setverdict(fail);
5585 } else {
5586 log("Found L3 Info: ", rsl_ho_cmd_l3);
5587 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
5588 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
5589 setverdict(fail);
5590 } else {
5591 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
5592 setverdict(pass);
5593 }
5594 }
5595
5596 f_sleep(0.2);
5597 f_rsl_send_l3(ts_RRM_HandoverFailure('00'O));
5598
5599 /* Should tell the MSC about the failure */
5600 BSSAP.receive(tr_BSSMAP_HandoverFailure);
5601
5602 f_sleep(1.0);
5603
Vadim Yanitskiy74ae5eb2020-10-01 22:13:29 +07005604 f_mo_l3_transceive();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005605 f_sleep(1.0);
5606
5607 setverdict(pass);
5608 f_sleep(1.0);
5609}
5610testcase TC_ho_out_fail_rr_ho_failure() runs on test_CT {
5611 var MSC_ConnHdlr vc_conn;
5612
5613 f_init(1, true);
5614 f_sleep(1.0);
5615
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01005616 f_ctrs_bsc_and_bts_handover_init();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005617
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005618 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_rr_ho_failure));
5619 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005620
5621 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5622 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5623 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5624 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5625 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
5626 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:failed");
5627 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005628 f_shutdown_helper();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005629}
5630
Neels Hofmeyr10f2bfa2019-07-09 19:33:29 +02005631/* BSC asks for inter-BSC-out HO, receives BSSMAP Handover Command, but then no reply is received about HO outcome
5632 * (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 +02005633 * and the lchan is released. */
5634private function f_tc_ho_out_fail_no_result_after_ho_cmd(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01005635 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005636
5637 var PDU_BSSAP ass_req := f_gen_ass_req();
5638 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
5639 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
5640 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
5641 f_establish_fully(ass_req, exp_compl);
5642
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005643 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005644 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
5645
5646 BSSAP.receive(tr_BSSMAP_HandoverRequired);
5647
5648 f_sleep(0.5);
5649 /* The MSC negotiates Handover Request and Handover Request Ack with
5650 * the other BSS and comes back with a BSSMAP Handover Command
5651 * containing an RR Handover Command coming from the target BSS... */
5652
5653 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
5654 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
5655 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
5656 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
5657 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
5658
5659 /* expect the Handover Command to go out on RR */
5660 var RSL_Message rsl_ho_cmd
5661 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
5662 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
5663 var RSL_IE_Body rsl_ho_cmd_l3;
5664 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
5665 log("RSL message contains no L3 Info IE, expected RR Handover Command");
5666 setverdict(fail);
5667 } else {
5668 log("Found L3 Info: ", rsl_ho_cmd_l3);
5669 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
5670 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
5671 setverdict(fail);
5672 } else {
5673 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
5674 setverdict(pass);
5675 }
5676 }
5677
Neels Hofmeyr10f2bfa2019-07-09 19:33:29 +02005678 /* We get neither success nor failure report from the remote BSS. Eventually T8 times out and we run into 3GPP
5679 * TS 48.008 3.1.5.3.3 "Abnormal Conditions": Clear Request should go to the MSC, and RR should be released
5680 * after Clear Command */
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005681
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005682 var PDU_BSSAP rx_clear_request;
Neels Hofmeyre1797aa2019-07-09 19:34:04 +02005683 BSSAP.receive(tr_BSSMAP_ClearRequest) -> value rx_clear_request;
5684 log("Got BSSMAP Clear Request");
5685 /* Instruct BSC to clear channel */
5686 var BssmapCause cause := bit2int(rx_clear_request.pdu.bssmap.clearRequest.cause.causeValue);
5687 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5688
5689 var MgcpCommand mgcp;
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005690 interleave {
Neels Hofmeyr861a4c12018-11-07 01:23:17 +01005691 [] RSL.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
5692 log("Got Deact SACCH");
5693 }
Harald Welte924b6ea2019-02-04 01:05:34 +01005694 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
Neels Hofmeyr211169d2018-11-07 00:37:29 +01005695 log("Got RR Release");
5696 }
Neels Hofmeyr3c5127e2021-07-22 19:18:40 +02005697 [] RSL.receive(tr_RSL_RF_CHAN_REL(g_chan_nr)) {
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005698 log("Got RF Chan Rel");
5699 RSL.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
Neels Hofmeyre680b012021-07-22 19:19:09 +02005700 f_rslem_unregister(0, g_chan_nr);
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005701 }
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005702 }
5703
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005704 f_expect_dlcx_conns();
Neels Hofmeyr8fcd8772021-07-22 16:12:57 +02005705 BSSAP.receive(tr_BSSMAP_ClearComplete);
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02005706
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005707 setverdict(pass);
5708 f_sleep(1.0);
5709}
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02005710testcase TC_ho_out_fail_no_result_after_ho_cmd() runs on test_CT {
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005711 var MSC_ConnHdlr vc_conn;
5712
5713 f_init(1, true);
5714 f_sleep(1.0);
5715
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01005716 f_ctrs_bsc_and_bts_handover_init();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005717
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02005718 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_no_result_after_ho_cmd));
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005719 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005720
5721 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5722 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5723 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5724 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
5725 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
5726 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
5727 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005728 f_shutdown_helper();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005729}
5730
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005731private function f_ho_into_this_bsc(charstring id, template (omit) BSSMAP_oldToNewBSSIEs oldToNewBSSIEs := omit) runs on MSC_ConnHdlr {
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005732 /* Hack: the proper way would be to wait for the BSSMAP Handover Request ACK and extract the
5733 * actual assigned chan_nr from its L3 (RR Handover Command) message. But osmo-bsc starts acting
5734 * on the lchan even before we get a chance to evaluate the BSSMAP Handover Request ACK. So we
5735 * need to assume that osmo-bsc will activate TS 1 and already set up this lchan's RSL emulation
5736 * before we get started. */
5737 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
5738 f_rslem_register(0, new_chan_nr);
5739 g_chan_nr := new_chan_nr;
Neels Hofmeyr34174bd2021-10-02 14:52:57 +02005740 var uint3_t expect_target_tsc := BTS_TSC[0];
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005741 f_sleep(1.0);
5742
5743 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
5744 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5745 activate(as_Media());
5746
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005747 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02005748 f_gen_handover_req(aoip_tla := g_pars.host_aoip_tla,
Neels Hofmeyr8ebf19c2021-06-21 05:24:01 +02005749 oldToNewBSSIEs := oldToNewBSSIEs,
5750 enc := g_pars.encr)));
Harald Welte6811d102019-04-14 22:23:14 +02005751 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005752
5753 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
5754
5755 var PDU_BSSAP rx_bssap;
5756 var octetstring ho_command_str;
5757
5758 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
Pau Espin Pedrol76ba5412019-06-10 11:00:33 +02005759
Neels Hofmeyr34174bd2021-10-02 14:52:57 +02005760 /* we're sure that the channel activation is done now, verify the parameters in it */
5761 var RSL_Message chan_act := f_rslem_get_last_act(RSL_PROC, 0, g_chan_nr);
5762 f_verify_encr_info(chan_act);
5763 f_chan_act_verify_tsc(chan_act, expect_target_tsc);
Neels Hofmeyr8ebf19c2021-06-21 05:24:01 +02005764
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005765 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
5766 log("Received L3 Info in HO Request Ack: ", ho_command_str);
5767 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
5768 log("L3 Info in HO Request Ack is ", ho_command);
5769
5770 var GsmArfcn arfcn;
5771 var RslChannelNr actual_new_chan_nr;
5772 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
5773 actual_new_chan_nr, arfcn);
5774
5775 if (actual_new_chan_nr != new_chan_nr) {
5776 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
5777 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
5778 setverdict(fail);
5779 return;
5780 }
5781 log("Handover Command chan_nr is", actual_new_chan_nr);
5782
Neels Hofmeyr34174bd2021-10-02 14:52:57 +02005783 var uint3_t got_tsc := rr_chan_desc_tsc(ho_command.msgs.rrm.handoverCommand.channelDescription2);
5784 if (not match(got_tsc, expect_target_tsc)) {
5785 setverdict(fail, "RR Handover Command: unexpected TSC in Channel Description: expected ",
5786 expect_target_tsc, " got ", got_tsc);
5787 mtc.stop;
5788 } else {
5789 log("handoverCommand: verified TSC = ", got_tsc);
5790 }
5791
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005792 /* Now the MSC forwards the RR Handover Command to the other BSC, which
5793 * tells the MS to handover to the new lchan. Here comes the new MS on
5794 * the new lchan with a Handover RACH: */
5795
5796 /* send handover detect */
5797
5798 RSL.send(ts_RSL_HANDO_DET(new_chan_nr));
5799
5800 BSSAP.receive(tr_BSSMAP_HandoverDetect);
5801
5802 /* send handover complete over the new channel */
5803
5804 var PDU_ML3_MS_NW l3_tx := valueof(ts_RRM_HandoverComplete('00'O));
5805 RSL.send(ts_RSL_EST_IND(new_chan_nr, valueof(ts_RslLinkID_DCCH(0)),
5806 enc_PDU_ML3_MS_NW(l3_tx)));
5807
5808 BSSAP.receive(tr_BSSMAP_HandoverComplete);
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005809 setverdict(pass);
5810}
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02005811
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005812private function f_tc_ho_into_this_bsc(charstring id) runs on MSC_ConnHdlr {
Pau Espin Pedrol9ae36d52021-06-15 17:29:43 +02005813 var template PDU_ML3_NW_MS exp_rr_rel_tmpl;
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005814 var template (omit) BSSMAP_oldToNewBSSIEs oldToNewBSSIEs := omit;
5815 if (not istemplatekind(g_pars.last_used_eutran_plmn, "omit")) {
5816 oldToNewBSSIEs := f_ts_BSSMAP_oldToNewBSSIEs(ts_BSSMAP_LastUsedEUTRANPLMNId(g_pars.last_used_eutran_plmn));
Pau Espin Pedrol9ae36d52021-06-15 17:29:43 +02005817 }
5818 if (g_pars.exp_fast_return) {
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005819 exp_rr_rel_tmpl := tr_RRM_RR_RELEASE_CellSelectInd;
Pau Espin Pedrol9ae36d52021-06-15 17:29:43 +02005820 } else {
5821 exp_rr_rel_tmpl := tr_RRM_RR_RELEASE;
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005822 }
5823 f_ho_into_this_bsc(id, oldToNewBSSIEs);
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02005824 f_perform_clear(exp_rr_rel_tmpl := exp_rr_rel_tmpl);
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005825 setverdict(pass);
5826}
Pau Espin Pedrol07866632020-09-03 19:10:55 +02005827function f_tc_ho_into_this_bsc_main(TestHdlrParams pars) runs on test_CT {
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005828 var MSC_ConnHdlr vc_conn;
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005829
5830 f_init(1, true);
5831 f_sleep(1.0);
5832
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01005833 f_ctrs_bsc_and_bts_handover_init();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005834
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005835 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5836 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005837
5838 vc_conn := f_start_handler(refers(f_tc_ho_into_this_bsc), pars);
5839 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005840
5841 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5842 f_ctrs_bsc_and_bts_add(0, "handover:completed");
5843 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
5844 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:completed");
5845 f_ctrs_bsc_and_bts_verify();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005846}
5847
Pau Espin Pedrol07866632020-09-03 19:10:55 +02005848testcase TC_ho_into_this_bsc() runs on test_CT {
5849 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5850 f_tc_ho_into_this_bsc_main(pars);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005851 f_shutdown_helper();
Pau Espin Pedrol07866632020-09-03 19:10:55 +02005852}
5853
Neels Hofmeyr8ebf19c2021-06-21 05:24:01 +02005854function f_tc_ho_into_this_bsc_a5(OCT1 encr_alg) runs on test_CT {
5855 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5856 pars.encr := valueof(t_EncrParams(encr_alg, f_rnd_octstring(8), f_rnd_octstring(16)));
5857 f_tc_ho_into_this_bsc_main(pars);
5858 f_shutdown_helper();
5859}
5860
5861testcase TC_ho_into_this_bsc_a5_0() runs on test_CT {
5862 f_tc_ho_into_this_bsc_a5('01'O);
5863}
5864
5865testcase TC_ho_into_this_bsc_a5_1() runs on test_CT {
5866 f_tc_ho_into_this_bsc_a5('02'O);
5867}
5868
5869testcase TC_ho_into_this_bsc_a5_3() runs on test_CT {
5870 f_tc_ho_into_this_bsc_a5('08'O);
5871}
5872
5873testcase TC_ho_into_this_bsc_a5_4() runs on test_CT {
5874 f_tc_ho_into_this_bsc_a5('10'O);
5875}
5876
Pau Espin Pedrol07866632020-09-03 19:10:55 +02005877testcase TC_ho_into_this_bsc_tla_v6() runs on test_CT {
5878 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5879 pars.host_aoip_tla := "::6";
5880 f_tc_ho_into_this_bsc_main(pars);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005881 f_shutdown_helper();
Pau Espin Pedrol07866632020-09-03 19:10:55 +02005882}
5883
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02005884/* Similar to TC_ho_into_this_bsc, but when in SRVCC, HO Req contains "Old BSS
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005885 to New BSS Information" IE with "Last Used E-UTRAN PLMN Id", which, when the
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02005886 channel is later released (RR CHannel Release), should trigger inclusion of
5887 IE "Cell Selection Indicator after Release of all TCH and SDCCH" with E-UTRAN
5888 neighbors. */
5889testcase TC_srvcc_eutran_to_geran() runs on test_CT {
5890 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5891 pars.last_used_eutran_plmn := '323454'O;
Pau Espin Pedrol9ae36d52021-06-15 17:29:43 +02005892 pars.exp_fast_return := true;
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02005893 f_tc_ho_into_this_bsc_main(pars);
Pau Espin Pedrol211a7142021-06-15 16:43:03 +02005894
5895 f_ctrs_bsc_and_bts_add(0, "srvcc:attempted");
5896 f_ctrs_bsc_and_bts_add(0, "srvcc:completed");
5897 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02005898 f_shutdown_helper();
5899}
5900
Pau Espin Pedrol9ae36d52021-06-15 17:29:43 +02005901/* Same as TC_srvcc_eutran_to_geran, but test explicitly forbiding fast return
5902 on the BTS. As a result, RR Release shouldn't contain the EUTRAN neighbor
5903 list when the channel is released. */
5904testcase TC_srvcc_eutran_to_geran_forbid_fast_return() runs on test_CT {
5905 f_init_vty();
5906 f_vty_allow_srvcc_fast_return(true, 0)
5907
5908 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5909 pars.last_used_eutran_plmn := '323454'O;
5910 pars.exp_fast_return := false;
5911 f_tc_ho_into_this_bsc_main(pars);
5912 f_vty_allow_srvcc_fast_return(false, 0);
5913 f_shutdown_helper();
5914}
5915
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005916private function f_tc_srvcc_eutran_to_geran_ho_out(charstring id) runs on MSC_ConnHdlr {
5917 var template (omit) BSSMAP_oldToNewBSSIEs oldToNewBSSIEs;
5918 oldToNewBSSIEs := f_ts_BSSMAP_oldToNewBSSIEs(ts_BSSMAP_LastUsedEUTRANPLMNId(g_pars.last_used_eutran_plmn));
5919 f_ho_into_this_bsc(id, oldToNewBSSIEs);
5920 f_ho_out_of_this_bsc(oldToNewBSSIEs);
5921 setverdict(pass);
5922}
Pau Espin Pedrol9ae36d52021-06-15 17:29:43 +02005923
5924private function f_tc_srvcc_eutran_to_geran_ho_out_main(boolean disable_fast_return)
5925 runs on test_CT {
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005926 var MSC_ConnHdlr vc_conn;
5927 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5928
5929 f_init(1, true);
Pau Espin Pedrol9ae36d52021-06-15 17:29:43 +02005930 if (disable_fast_return) {
5931 f_vty_allow_srvcc_fast_return(true, 0);
5932 }
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005933 f_sleep(1.0);
5934
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01005935 f_ctrs_bsc_and_bts_handover_init();
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005936
5937 pars.last_used_eutran_plmn := '323454'O;
5938 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5939 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
5940
5941 vc_conn := f_start_handler(refers(f_tc_srvcc_eutran_to_geran_ho_out), pars);
5942 vc_conn.done;
5943
5944 f_ctrs_bsc_and_bts_add(0, "handover:attempted", 2);
5945 f_ctrs_bsc_and_bts_add(0, "handover:completed", 2);
5946 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted", 1);
5947 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:completed", 1);
5948 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted", 1);
5949 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:completed", 1);
Pau Espin Pedrol211a7142021-06-15 16:43:03 +02005950
5951 f_ctrs_bsc_and_bts_add(0, "srvcc:attempted", 1);
5952 f_ctrs_bsc_and_bts_add(0, "srvcc:completed", 1);
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005953 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol9ae36d52021-06-15 17:29:43 +02005954
5955 if (disable_fast_return) {
5956 f_vty_allow_srvcc_fast_return(false, 0);
5957 }
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005958 f_shutdown_helper();
5959}
5960
Pau Espin Pedrol9ae36d52021-06-15 17:29:43 +02005961/* First, HO into BSC from EUTRAN (SRVCC): HO Request contains "Old BSS to New
5962 BSS Information" IE with "Last Used E-UTRAN PLMN Id".
5963 Second, HO to another BSC: HO Required contains "Old BSS to New BSS Information"
5964 IE with "Last Used E-UTRAN PLMN Id" from first step. */
5965testcase TC_srvcc_eutran_to_geran_ho_out() runs on test_CT {
5966 f_tc_srvcc_eutran_to_geran_ho_out_main(false);
5967}
5968/* Validate subsequent intra-GSM-HO works the same (with OldBSSToNewBSSInfo IE)
5969 * independently of fast-reture allowed/forbidden in local BTS */
5970testcase TC_srvcc_eutran_to_geran_ho_out_forbid_fast_return() runs on test_CT {
5971 f_tc_srvcc_eutran_to_geran_ho_out_main(true);
5972}
5973
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005974private function f_tc_ho_in_fail_msc_clears(charstring id) runs on MSC_ConnHdlr {
5975 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
5976 f_rslem_register(0, new_chan_nr);
5977 g_chan_nr := new_chan_nr;
5978 f_sleep(1.0);
5979
5980 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
5981 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5982 activate(as_Media());
5983
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005984 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005985 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02005986 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005987
5988 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
5989
5990 var PDU_BSSAP rx_bssap;
5991 var octetstring ho_command_str;
5992
5993 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
5994
5995 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
5996 log("Received L3 Info in HO Request Ack: ", ho_command_str);
5997 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
5998 log("L3 Info in HO Request Ack is ", ho_command);
5999
6000 var GsmArfcn arfcn;
6001 var RslChannelNr actual_new_chan_nr;
6002 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
6003 actual_new_chan_nr, arfcn);
6004
6005 if (actual_new_chan_nr != new_chan_nr) {
6006 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
6007 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
6008 setverdict(fail);
6009 return;
6010 }
6011 log("Handover Command chan_nr is", actual_new_chan_nr);
6012
Neels Hofmeyr61ca08d2019-05-06 23:52:22 +02006013 /* For deterministic test results, give some time for the MGW endpoint to be configured */
6014 f_sleep(1.0);
6015
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006016 /* Now the MSC forwards the RR Handover Command to the other BSC, which
6017 * tells the MS to handover to the new lchan. In this case, the MS
6018 * reports a Handover Failure to the old BSS, which forwards a BSSMAP
6019 * Handover Failure to the MSC. The procedure according to 3GPP TS
6020 * 48.008 3.1.5.3.2 "Handover Failure" is then that the MSC sends a
6021 * BSSMAP Clear Command: */
6022
6023 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
6024 var BssmapCause cause := enum2int(cause_val);
6025 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
6026
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02006027 f_expect_dlcx_conns();
Neels Hofmeyr8fcd8772021-07-22 16:12:57 +02006028 BSSAP.receive(tr_BSSMAP_ClearComplete);
6029
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006030 setverdict(pass);
6031 f_sleep(1.0);
6032
6033 setverdict(pass);
6034}
6035testcase TC_ho_in_fail_msc_clears() runs on test_CT {
6036 var MSC_ConnHdlr vc_conn;
6037 var TestHdlrParams pars := f_gen_test_hdlr_pars();
6038
6039 f_init(1, true);
6040 f_sleep(1.0);
6041
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01006042 f_ctrs_bsc_and_bts_handover_init();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006043
Neels Hofmeyr90f80962020-06-12 16:16:55 +02006044 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
6045 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006046
6047 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_msc_clears), pars);
6048 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006049
6050 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6051 f_ctrs_bsc_and_bts_add(0, "handover:stopped");
6052 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
6053 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:stopped");
6054 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006055 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006056}
6057
6058private function f_tc_ho_in_fail_msc_clears_after_ho_detect(charstring id) runs on MSC_ConnHdlr {
6059 /* Hack: the proper way would be to wait for the BSSMAP Handover Request ACK and extract the
6060 * actual assigned chan_nr from its L3 (RR Handover Command) message. But osmo-bsc starts acting
6061 * on the lchan even before we get a chance to evaluate the BSSMAP Handover Request ACK. So we
6062 * need to assume that osmo-bsc will activate TS 1 and already set up this lchan's RSL emulation
6063 * before we get started. */
6064 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
6065 f_rslem_register(0, new_chan_nr);
6066 g_chan_nr := new_chan_nr;
6067 f_sleep(1.0);
6068
6069 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
6070 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
6071 activate(as_Media());
6072
Neels Hofmeyr90f80962020-06-12 16:16:55 +02006073 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006074 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02006075 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006076
6077 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
6078
6079 var PDU_BSSAP rx_bssap;
6080 var octetstring ho_command_str;
6081
6082 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
6083
6084 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
6085 log("Received L3 Info in HO Request Ack: ", ho_command_str);
6086 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
6087 log("L3 Info in HO Request Ack is ", ho_command);
6088
6089 var GsmArfcn arfcn;
6090 var RslChannelNr actual_new_chan_nr;
6091 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
6092 actual_new_chan_nr, arfcn);
6093
6094 if (actual_new_chan_nr != new_chan_nr) {
6095 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
6096 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
6097 setverdict(fail);
6098 return;
6099 }
6100 log("Handover Command chan_nr is", actual_new_chan_nr);
6101
6102 /* Now the MSC forwards the RR Handover Command to the other BSC, which
6103 * tells the MS to handover to the new lchan. Here comes the new MS on
6104 * the new lchan with a Handover RACH: */
6105
6106 /* send handover detect */
6107
6108 RSL.send(ts_RSL_HANDO_DET(new_chan_nr));
6109
6110 BSSAP.receive(tr_BSSMAP_HandoverDetect);
6111
6112 /* The MSC chooses to clear the connection now, maybe we got the
6113 * Handover RACH on the new cell but the MS still signaled Handover
6114 * Failure to the old BSS? */
6115
6116 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
6117 var BssmapCause cause := enum2int(cause_val);
6118 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
6119
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02006120 f_expect_dlcx_conns();
Neels Hofmeyr8fcd8772021-07-22 16:12:57 +02006121 BSSAP.receive(tr_BSSMAP_ClearComplete);
6122
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006123 f_sleep(1.0);
6124}
6125testcase TC_ho_in_fail_msc_clears_after_ho_detect() runs on test_CT {
6126 var MSC_ConnHdlr vc_conn;
6127 var TestHdlrParams pars := f_gen_test_hdlr_pars();
6128
6129 f_init(1, true);
6130 f_sleep(1.0);
6131
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01006132 f_ctrs_bsc_and_bts_handover_init();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006133
Neels Hofmeyr90f80962020-06-12 16:16:55 +02006134 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
6135 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006136
6137 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_msc_clears_after_ho_detect), pars);
6138 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006139
6140 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6141 f_ctrs_bsc_and_bts_add(0, "handover:stopped");
6142 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
6143 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:stopped");
6144 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006145 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006146}
6147
6148/* The new BSS's lchan times out before the MSC decides that handover failed. */
6149private function f_tc_ho_in_fail_no_detect(charstring id) runs on MSC_ConnHdlr {
6150 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
6151 f_rslem_register(0, new_chan_nr);
6152 g_chan_nr := new_chan_nr;
6153 f_sleep(1.0);
6154
6155 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
6156 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
6157 activate(as_Media());
6158
Neels Hofmeyr90f80962020-06-12 16:16:55 +02006159 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006160 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02006161 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006162
6163 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
6164
6165 var PDU_BSSAP rx_bssap;
6166 var octetstring ho_command_str;
6167
6168 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
6169
6170 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
6171 log("Received L3 Info in HO Request Ack: ", ho_command_str);
6172 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
6173 log("L3 Info in HO Request Ack is ", ho_command);
6174
6175 var GsmArfcn arfcn;
6176 var RslChannelNr actual_new_chan_nr;
6177 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
6178 actual_new_chan_nr, arfcn);
6179
6180 if (actual_new_chan_nr != new_chan_nr) {
6181 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
6182 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
6183 setverdict(fail);
6184 return;
6185 }
6186 log("Handover Command chan_nr is", actual_new_chan_nr);
6187
6188 /* Now the MSC forwards the RR Handover Command to the other BSC, which
6189 * tells the MS to handover to the new lchan. But the MS never shows up
6190 * on the new lchan. */
6191
6192 BSSAP.receive(tr_BSSMAP_HandoverFailure);
6193
6194 /* Did osmo-bsc also send a Clear Request? */
6195 timer T := 0.5;
6196 T.start;
6197 alt {
6198 [] BSSAP.receive(tr_BSSMAP_ClearRequest);
6199 [] T.timeout { }
6200 }
6201
6202 /* MSC plays along with a Clear Command (no matter whether osmo-bsc
6203 * asked for it, this is a Handover Failure after all). */
6204
6205 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
6206 var BssmapCause cause := enum2int(cause_val);
6207 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
6208
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02006209 f_expect_dlcx_conns();
Neels Hofmeyr8fcd8772021-07-22 16:12:57 +02006210 BSSAP.receive(tr_BSSMAP_ClearComplete);
6211
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006212 f_sleep(1.0);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006213}
6214testcase TC_ho_in_fail_no_detect() runs on test_CT {
6215 var MSC_ConnHdlr vc_conn;
6216 var TestHdlrParams pars := f_gen_test_hdlr_pars();
6217
6218 f_init(1, true);
6219 f_sleep(1.0);
6220
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01006221 f_ctrs_bsc_and_bts_handover_init();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006222
Neels Hofmeyr90f80962020-06-12 16:16:55 +02006223 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
6224 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006225
6226 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_no_detect), pars);
6227 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006228
6229 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6230 f_ctrs_bsc_and_bts_add(0, "handover:error");
6231 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
6232 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:error");
6233 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006234 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006235}
6236
6237/* Same as f_tc_ho_in_fail_no_detect, but MSC fails to send a Clear Command */
6238private function f_tc_ho_in_fail_no_detect2(charstring id) runs on MSC_ConnHdlr {
6239 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
6240 f_rslem_register(0, new_chan_nr);
6241 g_chan_nr := new_chan_nr;
6242 f_sleep(1.0);
6243
6244 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
6245 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
6246 activate(as_Media());
6247
Neels Hofmeyr90f80962020-06-12 16:16:55 +02006248 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006249 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02006250 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006251
6252 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
6253
6254 var PDU_BSSAP rx_bssap;
6255 var octetstring ho_command_str;
6256
6257 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
6258
6259 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
6260 log("Received L3 Info in HO Request Ack: ", ho_command_str);
6261 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
6262 log("L3 Info in HO Request Ack is ", ho_command);
6263
6264 var GsmArfcn arfcn;
6265 var RslChannelNr actual_new_chan_nr;
6266 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
6267 actual_new_chan_nr, arfcn);
6268
6269 if (actual_new_chan_nr != new_chan_nr) {
6270 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
6271 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
6272 setverdict(fail);
6273 return;
6274 }
6275 log("Handover Command chan_nr is", actual_new_chan_nr);
6276
6277 /* Now the MSC forwards the RR Handover Command to the other BSC, which
6278 * tells the MS to handover to the new lchan. But the MS never shows up
6279 * on the new lchan. */
6280
6281 BSSAP.receive(tr_BSSMAP_HandoverFailure);
6282
6283 /* MSC plays dumb and sends no Clear Command */
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006284 var PDU_BSSAP rx_clear_request;
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02006285
6286 BSSAP.receive(tr_BSSMAP_ClearRequest) -> value rx_clear_request {
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006287 var BssmapCause cause := bit2int(rx_clear_request.pdu.bssmap.clearRequest.cause.causeValue);
6288 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
6289 };
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02006290 f_expect_dlcx_conns();
Neels Hofmeyr8fcd8772021-07-22 16:12:57 +02006291 BSSAP.receive(tr_BSSMAP_ClearComplete);
6292
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006293 f_sleep(1.0);
6294}
6295testcase TC_ho_in_fail_no_detect2() runs on test_CT {
6296 var MSC_ConnHdlr vc_conn;
6297 var TestHdlrParams pars := f_gen_test_hdlr_pars();
6298
6299 f_init(1, true);
6300 f_sleep(1.0);
6301
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01006302 f_ctrs_bsc_and_bts_handover_init();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006303
Neels Hofmeyr90f80962020-06-12 16:16:55 +02006304 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
6305 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006306
6307 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_no_detect2), pars);
6308 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006309
6310 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6311 f_ctrs_bsc_and_bts_add(0, "handover:error");
6312 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
6313 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:error");
6314 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006315 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006316}
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01006317
Neels Hofmeyr91401012019-07-11 00:42:35 +02006318type record of charstring Commands;
6319
Neels Hofmeyr666f0432020-07-04 00:53:07 +02006320private function f_bts_0_cfg(TELNETasp_PT pt, Commands cmds := {})
Neels Hofmeyr91401012019-07-11 00:42:35 +02006321{
Neels Hofmeyr666f0432020-07-04 00:53:07 +02006322 f_vty_enter_cfg_bts(pt, 0);
Neels Hofmeyr91401012019-07-11 00:42:35 +02006323 for (var integer i := 0; i < sizeof(cmds); i := i+1) {
Neels Hofmeyr666f0432020-07-04 00:53:07 +02006324 f_vty_transceive(pt, cmds[i]);
Neels Hofmeyr91401012019-07-11 00:42:35 +02006325 }
Neels Hofmeyr666f0432020-07-04 00:53:07 +02006326 f_vty_transceive(pt, "end");
Neels Hofmeyr91401012019-07-11 00:42:35 +02006327}
6328
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01006329private function f_cs7_inst_0_cfg(TELNETasp_PT pt, Commands cmds := {})
6330{
6331 f_vty_enter_cfg_cs7_inst(pt, 0);
6332 for (var integer i := 0; i < sizeof(cmds); i := i+1) {
6333 f_vty_transceive(pt, cmds[i]);
6334 }
6335 f_vty_transceive(pt, "end");
6336}
6337
Neels Hofmeyr91401012019-07-11 00:42:35 +02006338private function f_probe_for_handover(charstring log_label,
6339 charstring log_descr,
6340 charstring handover_vty_cmd,
6341 boolean expect_handover,
Neels Hofmeyr6a955cc2021-10-02 14:53:48 +02006342 boolean is_inter_bsc_handover := false,
6343 template uint3_t expect_target_tsc := ?)
Neels Hofmeyr91401012019-07-11 00:42:35 +02006344runs on MSC_ConnHdlr
6345{
Neels Hofmeyrb3fc8982020-05-11 00:16:42 +02006346 /* We're going to thwart any and all handover attempts, just be ready to handle (and ignore) handover target
6347 * lchans to be established on bts 1 or bts 2. */
6348 f_rslem_suspend(RSL1_PROC);
6349 f_rslem_suspend(RSL2_PROC);
6350
Neels Hofmeyr91401012019-07-11 00:42:35 +02006351 var RSL_Message rsl;
6352
6353 var charstring log_msg := " (expecting handover)"
6354 if (not expect_handover) {
6355 log_msg := " (expecting NO handover)";
6356 }
6357 log("f_probe_for_handover starting: " & log_label & ": " & log_descr & log_msg);
6358 f_vty_transceive(BSCVTY, handover_vty_cmd);
6359
Neels Hofmeyr91401012019-07-11 00:42:35 +02006360 timer T := 2.0;
6361 T.start;
6362
6363 alt {
6364 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr)) -> value rsl {
6365 var PDU_ML3_NW_MS l3 := dec_PDU_ML3_NW_MS(rsl.ies[2].body.l3_info.payload);
6366 log("Rx L3 from net: ", l3);
6367 if (ischosen(l3.msgs.rrm.handoverCommand)) {
6368 var RslChannelNr new_chan_nr;
6369 var GsmArfcn arfcn;
6370 f_ChDesc2RslChanNr(l3.msgs.rrm.handoverCommand.channelDescription2,
6371 new_chan_nr, arfcn);
6372 log("Handover to new chan ", new_chan_nr, " on ARFCN ", arfcn);
6373 log(l3.msgs.rrm.handoverCommand);
6374
Neels Hofmeyr6a955cc2021-10-02 14:53:48 +02006375 /* Verify correct TSC in handoverCommand */
6376 var uint3_t got_tsc := rr_chan_desc_tsc(l3.msgs.rrm.handoverCommand.channelDescription2);
6377 if (not match(got_tsc, expect_target_tsc)) {
6378 setverdict(fail, "RR Handover Command: unexpected TSC in Channel Description: expected ",
6379 expect_target_tsc, " got ", got_tsc);
6380 mtc.stop;
6381 } else {
6382 log("handoverCommand: verified TSC = ", got_tsc, " (matches ",
6383 expect_target_tsc, ")");
6384 }
6385
Neels Hofmeyr91401012019-07-11 00:42:35 +02006386 /* Need to register for new lchan on new BTS -- it's either bts 1 or bts 2. It doesn't really
6387 * matter on which BTS it really is, we're not going to follow through an entire handover
6388 * anyway. */
6389 f_rslem_register(0, new_chan_nr, RSL1_PROC);
6390 f_rslem_resume(RSL1_PROC);
6391 f_rslem_register(0, new_chan_nr, RSL2_PROC);
6392 f_rslem_resume(RSL2_PROC);
6393
6394 if (expect_handover and not is_inter_bsc_handover) {
6395 setverdict(pass);
6396 log("f_probe_for_handover(" & log_label & "): Got RSL Handover Command as expected.");
6397 } else {
6398 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected none, but got RSL Handover Command. "
6399 & log_label & ": " & log_descr);
6400 }
6401
6402 log("f_probe_for_handover(" & log_label & "): Ending the test: Handover Failure stops the procedure.");
6403 /* osmo-bsc has triggered Handover. That's all we need to know for this test, reply with
6404 * Handover Failure. */
6405 f_rsl_send_l3(ts_RRM_HandoverFailure('00'O));
6406
6407 /* target BTS is told to release lchan again; don't care which BTS nor what messages. */
6408 f_sleep(0.5);
6409 RSL1.clear;
6410 RSL2.clear;
6411 log("f_probe_for_handover(" & log_label & "): done (got RSL Handover Command)");
6412 break;
6413 } else {
6414 repeat;
6415 }
6416 }
6417 [] BSSAP.receive(tr_BSSMAP_HandoverRequired) {
6418 if (expect_handover and is_inter_bsc_handover) {
6419 setverdict(pass);
6420 log("f_probe_for_handover(" & log_label & "): Got BSSMAP Handover Required as expected.");
6421 } else {
6422 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected none, but got BSSMAP Handover Required. "
6423 & log_label & ": " & log_descr);
6424 }
6425
6426 log("f_probe_for_handover(" & log_label & "): done (got BSSMAP Handover Required)");
6427
6428 /* Note: f_tc_ho_neighbor_config_start() sets T7, the timeout for BSSMAP Handover Required, to
6429 * 1 second. There is no legal way to quickly abort a handover after a BSSMAP Handover Required,
6430 * setting a short timeout and waiting is the only way. */
6431 log("f_probe_for_handover(" & log_label & "): waiting for inter-BSC HO to time out...");
6432 f_sleep(1.5);
6433 log("f_probe_for_handover(" & log_label & "): ...done");
6434
6435 break;
6436 }
6437 [] T.timeout {
6438 if (expect_handover) {
6439 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected Handover, but got none. "
6440 & log_label & ": " & log_descr);
6441 } else {
6442 setverdict(pass);
6443 log("f_probe_for_handover(" & log_label & "): Got no Handover, as expected.");
6444 }
6445 log("f_probe_for_handover(" & log_label & "): done (got no Handover)");
6446 break;
6447 }
6448 }
6449
6450 f_rslem_resume(RSL1_PROC);
6451 f_rslem_resume(RSL2_PROC);
6452 f_sleep(3.0);
6453 RSL.clear;
6454
6455 log("f_probe_for_handover(" & log_label & "): done clearing");
6456}
6457
6458/* Test the effect of various neighbor configuration scenarios:
6459 *
6460 * To avoid complexity, block off any actual handover operation, and always remain on the lchan at bts 0.
6461 * Reconfigure the neighbors for bts 0, trigger a Handover, and probe whether osmo-bsc does or doesn't start HO.
6462 */
6463private function f_tc_ho_neighbor_config_start() runs on MSC_ConnHdlr {
6464 g_pars := f_gen_test_hdlr_pars();
6465 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
6466 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Neels Hofmeyr91401012019-07-11 00:42:35 +02006467
6468 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
6469 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
6470
6471 /* Establish lchan at bts 0 */
6472 f_establish_fully(ass_cmd, exp_compl);
6473
6474 /* Shorten the inter-BSC Handover timeout, to not wait so long for inter-BSC Handovers */
6475 f_vty_enter_cfg_network(BSCVTY);
6476 f_vty_transceive(BSCVTY, "timer T7 1");
6477 f_vty_transceive(BSCVTY, "end");
6478}
6479
6480private function f_tc_ho_neighbor_config_1(charstring id) runs on MSC_ConnHdlr {
6481 f_tc_ho_neighbor_config_start();
6482
6483 /*
6484 * bts 0 ARFCN 871 BSIC 10
6485 * bts 1 ARFCN 871 BSIC 11
6486 * bts 2 ARFCN 871 BSIC 12
6487 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
6488 */
6489
6490 log("f_tc_ho_neighbor_config: 1. No 'neighbor' config");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02006491 f_bts_0_cfg(BSCVTY, {"no neighbors"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02006492 f_probe_for_handover("1.a", "HO to bts 1 works, implicitly listed as neighbor (legacy behavior when none are configured)",
6493 "handover any to arfcn 871 bsic 11",
Neels Hofmeyr6a955cc2021-10-02 14:53:48 +02006494 true, expect_target_tsc := BTS_TSC[1]);
Neels Hofmeyr91401012019-07-11 00:42:35 +02006495
6496 f_probe_for_handover("1.b", "HO to unknown cell does not start",
6497 "handover any to arfcn 13 bsic 39",
6498 false);
6499
6500 f_probe_for_handover("1.c", "HO to 871-12 is ambiguous = error",
6501 "handover any to arfcn 871 bsic 12",
6502 false);
6503
6504 f_probe_for_handover("1.d", "HO to 871-11 still works (verify that this test properly cleans up)",
6505 "handover any to arfcn 871 bsic 11",
Neels Hofmeyr6a955cc2021-10-02 14:53:48 +02006506 true, expect_target_tsc := BTS_TSC[1]);
Neels Hofmeyr91401012019-07-11 00:42:35 +02006507}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006508testcase TC_ho_neighbor_config_1() runs on test_CT {
6509 var MSC_ConnHdlr vc_conn;
6510 f_init(3, true, guard_timeout := 60.0);
6511 f_sleep(1.0);
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01006512 f_ctrs_bsc_and_bts_handover_init();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006513 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_1));
6514 vc_conn.done;
6515
6516 /* f_tc_ho_neighbor_config_start() */
6517 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
6518 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
6519
6520 /* 1.a */
6521 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
6522 * handover quickly by sending a Handover Failure message. */
6523 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6524 f_ctrs_bsc_and_bts_add(0, "handover:failed");
6525 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
6526 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01006527 f_ctrs_bts_add(1, "incoming_intra_bsc_ho:attempted");
6528 f_ctrs_bts_add(1, "incoming_intra_bsc_ho:failed");
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006529
6530 /* 1.b */
6531 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6532 f_ctrs_bsc_and_bts_add(0, "handover:error");
6533
6534 /* 1.c */
6535 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6536 f_ctrs_bsc_and_bts_add(0, "handover:error");
6537
6538 /* 1.d */
6539 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6540 f_ctrs_bsc_and_bts_add(0, "handover:failed");
6541 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
6542 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01006543 f_ctrs_bts_add(1, "incoming_intra_bsc_ho:attempted");
6544 f_ctrs_bts_add(1, "incoming_intra_bsc_ho:failed");
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006545
6546 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006547 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006548}
6549
Neels Hofmeyr91401012019-07-11 00:42:35 +02006550private function f_tc_ho_neighbor_config_2(charstring id) runs on MSC_ConnHdlr {
6551 f_tc_ho_neighbor_config_start();
6552
6553 /*
6554 * bts 0 ARFCN 871 BSIC 10
6555 * bts 1 ARFCN 871 BSIC 11
6556 * bts 2 ARFCN 871 BSIC 12
6557 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
6558 */
6559
6560 log("f_tc_ho_neighbor_config: 2. explicit local neighbor: 'neighbor bts 1'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02006561 f_bts_0_cfg(BSCVTY, {"neighbor bts 1"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02006562 f_sleep(0.5);
6563
6564 f_probe_for_handover("2.a", "HO to bts 1 works, explicitly listed as neighbor",
6565 "handover any to arfcn 871 bsic 11",
Neels Hofmeyr6a955cc2021-10-02 14:53:48 +02006566 true, expect_target_tsc := BTS_TSC[1]);
Neels Hofmeyr91401012019-07-11 00:42:35 +02006567
6568 f_probe_for_handover("2.b", "HO to bts 2 doesn't work, not listed as neighbor",
6569 "handover any to arfcn 871 bsic 12",
6570 false);
6571}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006572testcase TC_ho_neighbor_config_2() runs on test_CT {
6573 var MSC_ConnHdlr vc_conn;
6574 f_init(3, true, guard_timeout := 50.0);
6575 f_sleep(1.0);
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01006576 f_ctrs_bsc_and_bts_handover_init();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006577 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_2));
6578 vc_conn.done;
6579
6580 /* f_tc_ho_neighbor_config_start() */
6581 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
6582 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
6583
6584 /* 2.a */
6585 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
6586 * handover quickly by sending a Handover Failure message. */
6587 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6588 f_ctrs_bsc_and_bts_add(0, "handover:failed");
6589 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
6590 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01006591 f_ctrs_bts_add(1, "incoming_intra_bsc_ho:attempted");
6592 f_ctrs_bts_add(1, "incoming_intra_bsc_ho:failed");
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006593
6594 /* 2.b */
6595 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6596 f_ctrs_bsc_and_bts_add(0, "handover:error");
6597
6598 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006599 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006600}
6601
Neels Hofmeyr91401012019-07-11 00:42:35 +02006602private function f_tc_ho_neighbor_config_3(charstring id) runs on MSC_ConnHdlr {
6603 f_tc_ho_neighbor_config_start();
6604
6605 /*
6606 * bts 0 ARFCN 871 BSIC 10
6607 * bts 1 ARFCN 871 BSIC 11
6608 * bts 2 ARFCN 871 BSIC 12
6609 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
6610 */
6611
6612 log("f_tc_ho_neighbor_config: 3. explicit local neighbor: 'neighbor bts 2'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02006613 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor bts 2"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02006614 f_sleep(0.5);
6615
6616 f_probe_for_handover("3.a", "HO to bts 1 doesn't work, not listed as neighbor",
6617 "handover any to arfcn 871 bsic 11",
6618 false);
6619 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",
6620 "handover any to arfcn 871 bsic 12",
Neels Hofmeyr6a955cc2021-10-02 14:53:48 +02006621 true, expect_target_tsc := BTS_TSC[2]);
Neels Hofmeyr91401012019-07-11 00:42:35 +02006622}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006623testcase TC_ho_neighbor_config_3() runs on test_CT {
6624 var MSC_ConnHdlr vc_conn;
6625 f_init(3, true, guard_timeout := 50.0);
6626 f_sleep(1.0);
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01006627 f_ctrs_bsc_and_bts_handover_init();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006628 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_3));
6629 vc_conn.done;
6630
6631 /* f_tc_ho_neighbor_config_start() */
6632 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
6633 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
6634
6635 /* 3.a */
6636 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6637 f_ctrs_bsc_and_bts_add(0, "handover:error");
6638
6639 /* 3.b */
6640 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
6641 * handover quickly by sending a Handover Failure message. */
6642 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6643 f_ctrs_bsc_and_bts_add(0, "handover:failed");
6644 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
6645 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01006646 f_ctrs_bts_add(2, "incoming_intra_bsc_ho:attempted");
6647 f_ctrs_bts_add(2, "incoming_intra_bsc_ho:failed");
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006648
6649 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006650 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006651}
6652
Neels Hofmeyr91401012019-07-11 00:42:35 +02006653private function f_tc_ho_neighbor_config_4(charstring id) runs on MSC_ConnHdlr {
6654 f_tc_ho_neighbor_config_start();
6655
6656 /*
6657 * bts 0 ARFCN 871 BSIC 10
6658 * bts 1 ARFCN 871 BSIC 11
6659 * bts 2 ARFCN 871 BSIC 12
6660 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
6661 */
6662
6663 log("f_tc_ho_neighbor_config: 4. explicit remote neighbor: 'neighbor lac 99 arfcn 123 bsic 45'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02006664 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor lac 99 arfcn 123 bsic 45"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02006665 f_sleep(0.5);
6666
6667 f_probe_for_handover("4.a", "HO to bts 1 doesn't work, not listed as neighbor",
6668 "handover any to arfcn 871 bsic 11",
6669 false);
6670 f_probe_for_handover("4.b", "HO to bts 2 doesn't work, not listed as neighbor",
6671 "handover any to arfcn 871 bsic 12",
6672 false);
6673 f_probe_for_handover("4.c", "HO to 123-45 triggers inter-BSC HO",
6674 "handover any to arfcn 123 bsic 45",
6675 true, true);
6676}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006677testcase TC_ho_neighbor_config_4() runs on test_CT {
6678 var MSC_ConnHdlr vc_conn;
6679 f_init(3, true, guard_timeout := 50.0);
6680 f_sleep(1.0);
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01006681 f_ctrs_bsc_and_bts_handover_init();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006682 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_4));
6683 vc_conn.done;
6684
6685 /* f_tc_ho_neighbor_config_start() */
6686 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
6687 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
6688
6689 /* 4.a */
6690 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6691 f_ctrs_bsc_and_bts_add(0, "handover:error");
6692
6693 /* 4.b */
6694 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6695 f_ctrs_bsc_and_bts_add(0, "handover:error");
6696
6697 /* 4.c */
6698 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
6699 * handover quickly by timing out after the Handover Required message */
6700 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6701 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
6702 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
6703 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
6704
6705 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006706 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006707}
6708
Neels Hofmeyr91401012019-07-11 00:42:35 +02006709private function f_tc_ho_neighbor_config_5(charstring id) runs on MSC_ConnHdlr {
6710 f_tc_ho_neighbor_config_start();
6711
6712 /*
6713 * bts 0 ARFCN 871 BSIC 10
6714 * bts 1 ARFCN 871 BSIC 11
6715 * bts 2 ARFCN 871 BSIC 12
6716 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
6717 */
6718
6719 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 +02006720 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor lac 99 arfcn 871 bsic 12"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02006721 f_sleep(0.5);
6722
6723 f_probe_for_handover("5.a", "HO to 871-12 triggers inter-BSC HO (ignoring local cells with same ARFCN+BSIC)",
6724 "handover any to arfcn 871 bsic 12",
6725 true, true);
6726}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006727testcase TC_ho_neighbor_config_5() runs on test_CT {
6728 var MSC_ConnHdlr vc_conn;
6729 f_init(3, true);
6730 f_sleep(1.0);
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01006731 f_ctrs_bsc_and_bts_handover_init();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006732 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_5));
6733 vc_conn.done;
6734
6735 /* f_tc_ho_neighbor_config_start() */
6736 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
6737 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
6738
6739 /* 5 */
6740 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
6741 * handover quickly by timing out after the Handover Required message */
6742 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6743 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
6744 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
6745 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
6746
6747 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006748 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006749}
6750
Neels Hofmeyr91401012019-07-11 00:42:35 +02006751private function f_tc_ho_neighbor_config_6(charstring id) runs on MSC_ConnHdlr {
6752 f_tc_ho_neighbor_config_start();
6753
6754 /*
6755 * bts 0 ARFCN 871 BSIC 10
6756 * bts 1 ARFCN 871 BSIC 11
6757 * bts 2 ARFCN 871 BSIC 12
6758 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
6759 */
6760
6761 log("f_tc_ho_neighbor_config: 6. config error: explicit local and remote neighbors with ambiguous ARFCN+BSIC:"
6762 & " 'neighbor bts 2; neighbor lac 99 arfcn 871 bsic 12'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02006763 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor bts 2", "neighbor lac 99 arfcn 871 bsic 12"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02006764 f_sleep(0.5);
6765
6766 f_probe_for_handover("6.a", "HO to 871-12 is ambiguous = error",
6767 "handover any to arfcn 871 bsic 12",
6768 false);
6769}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006770testcase TC_ho_neighbor_config_6() runs on test_CT {
6771 var MSC_ConnHdlr vc_conn;
6772 f_init(3, true);
6773 f_sleep(1.0);
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01006774 f_ctrs_bsc_and_bts_handover_init();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006775 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_6));
6776 vc_conn.done;
6777
6778 /* f_tc_ho_neighbor_config_start() */
6779 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
6780 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
6781
6782 /* 6.a */
6783 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
6784 * handover quickly by timing out after the Handover Required message */
6785 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6786 f_ctrs_bsc_and_bts_add(0, "handover:error");
6787
6788 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006789 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006790}
6791
Neels Hofmeyr91401012019-07-11 00:42:35 +02006792private function f_tc_ho_neighbor_config_7(charstring id) runs on MSC_ConnHdlr {
6793 f_tc_ho_neighbor_config_start();
6794
6795 /*
6796 * bts 0 ARFCN 871 BSIC 10
6797 * bts 1 ARFCN 871 BSIC 11
6798 * bts 2 ARFCN 871 BSIC 12
6799 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
6800 */
6801
6802 log("f_tc_ho_neighbor_config: 7. explicit local and remote neighbors:"
6803 & " 'neighbor bts 2; neighbor lac 99 arfcn 123 bsic 45'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02006804 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor bts 2", "neighbor lac 99 arfcn 123 bsic 45"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02006805 f_sleep(0.5);
6806
6807 f_probe_for_handover("7.a", "HO to 871-12 does HO to bts 2",
6808 "handover any to arfcn 871 bsic 12",
Neels Hofmeyr6a955cc2021-10-02 14:53:48 +02006809 true, expect_target_tsc := BTS_TSC[2]);
Neels Hofmeyr91401012019-07-11 00:42:35 +02006810 f_probe_for_handover("7.b", "HO to 123-45 triggers inter-BSC HO",
6811 "handover any to arfcn 123 bsic 45",
6812 true, true);
6813}
Neels Hofmeyr91401012019-07-11 00:42:35 +02006814testcase TC_ho_neighbor_config_7() runs on test_CT {
6815 var MSC_ConnHdlr vc_conn;
Neels Hofmeyrf2b88032020-06-16 00:35:04 +02006816 f_init(3, true, guard_timeout := 50.0);
Neels Hofmeyr91401012019-07-11 00:42:35 +02006817 f_sleep(1.0);
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01006818 f_ctrs_bsc_and_bts_handover_init();
Neels Hofmeyr91401012019-07-11 00:42:35 +02006819 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_7));
6820 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006821
6822 /* f_tc_ho_neighbor_config_start() */
6823 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
6824 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
6825
6826 /* 7.a */
6827 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
6828 * handover quickly by sending a Handover Failure message. */
6829 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6830 f_ctrs_bsc_and_bts_add(0, "handover:failed");
6831 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
6832 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01006833 f_ctrs_bts_add(2, "incoming_intra_bsc_ho:attempted");
6834 f_ctrs_bts_add(2, "incoming_intra_bsc_ho:failed");
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006835
6836 /* 7.b */
6837 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
6838 * handover quickly by timing out after the Handover Required message */
6839 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6840 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
6841 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
6842 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
6843
6844 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006845 f_shutdown_helper();
Neels Hofmeyr91401012019-07-11 00:42:35 +02006846}
6847
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01006848/* OS#3041: Open and close N connections in a normal fashion, and expect no
6849 * BSSMAP Reset just because of that. */
6850testcase TC_bssap_rlsd_does_not_cause_bssmap_reset() runs on test_CT {
6851 var default d;
6852 var integer i;
6853 var DchanTuple dt;
6854
6855 f_init();
6856
6857 /* Wait for initial BSSMAP Reset to pass */
6858 f_sleep(4.0);
6859
6860 d := activate(no_bssmap_reset());
6861
6862 /* Setup up a number of connections and RLSD them again from the MSC
6863 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
6864 * Let's do it some more times for good measure. */
Harald Weltec3260d92018-06-11 17:48:16 +02006865 for (i := 0; i < 4; i := i+1) {
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01006866 /* Since we're doing a lot of runs, give each one a fresh
6867 * T_guard from the top. */
6868 T_guard.start;
6869
6870 /* Setup a BSSAP connection and clear it right away. This is
6871 * the MSC telling the BSC about a planned release, it's not an
6872 * erratic loss of a connection. */
Harald Weltea1897182018-06-11 13:53:09 +02006873 dt := f_est_dchan(int2oct(i,1), 23+i, '00010203040506'O);
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01006874
6875 /* MSC disconnects (RLSD). */
6876 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
6877 }
6878
6879 /* In the buggy behavior, a timeout of 2 seconds happens between above
6880 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
6881 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
6882 f_sleep(4.0);
6883
6884 deactivate(d);
6885 f_shutdown_helper();
6886}
Harald Welte552620d2017-12-16 23:21:36 +01006887
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01006888/* OS#3041: Open and close N connections in a normal fashion, and expect no
6889 * BSSMAP Reset just because of that. Invoke the release by a BSSMAP Clear from
6890 * the MSC. */
6891testcase TC_bssmap_clear_does_not_cause_bssmap_reset() runs on test_CT {
6892 var default d;
6893 var integer i;
6894 var DchanTuple dt;
6895 var BSSAP_N_DATA_ind rx_di;
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01006896 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_CALL_CONTROL;
6897 var BssmapCause cause := enum2int(cause_val);
6898
6899 f_init();
6900
6901 /* Wait for initial BSSMAP Reset to pass */
6902 f_sleep(4.0);
6903
6904 d := activate(no_bssmap_reset());
6905
6906 /* Setup up a number of connections and RLSD them again from the MSC
6907 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
6908 * Let's do it some more times for good measure. */
6909 for (i := 0; i < 8; i := i+1) {
6910 /* Since we're doing a lot of runs, give each one a fresh
6911 * T_guard from the top. */
6912 T_guard.start;
6913
6914 /* Setup a BSSAP connection and clear it right away. This is
6915 * the MSC telling the BSC about a planned release, it's not an
6916 * erratic loss of a connection. */
Harald Weltea1897182018-06-11 13:53:09 +02006917 dt := f_est_dchan(int2oct(i,1), 23+i, '00010203040506'O);
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01006918
6919 /* Instruct BSC to clear channel */
6920 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
6921
6922 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02006923 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01006924 }
6925
6926 /* In the buggy behavior, a timeout of 2 seconds happens between above
6927 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
6928 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
6929 f_sleep(4.0);
6930
6931 deactivate(d);
6932 f_shutdown_helper();
6933}
6934
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01006935/* OS#3041: Open and close N connections in a normal fashion, and expect no
6936 * BSSMAP Reset just because of that. Close connections from the MS side with a
6937 * Release Ind on RSL. */
6938testcase TC_ms_rel_ind_does_not_cause_bssmap_reset() runs on test_CT {
6939 var default d;
6940 var integer i;
6941 var DchanTuple dt;
6942 var BSSAP_N_DATA_ind rx_di;
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01006943 var integer j;
6944
6945 f_init();
6946
6947 /* Wait for initial BSSMAP Reset to pass */
6948 f_sleep(4.0);
6949
6950 d := activate(no_bssmap_reset());
6951
6952 /* Setup up a number of connections and RLSD them again from the MSC
6953 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
6954 * Let's do it some more times for good measure. */
6955 for (i := 0; i < 8; i := i+1) {
6956 /* Since we're doing a lot of runs, give each one a fresh
6957 * T_guard from the top. */
6958 T_guard.start;
6959
6960 /* Setup a BSSAP connection and clear it right away. This is
6961 * the MSC telling the BSC about a planned release, it's not an
6962 * erratic loss of a connection. */
6963 dt := f_est_dchan('23'O, 23, '00010203040506'O);
6964
6965 /* simulate RLL REL IND */
6966 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0))));
6967
6968 /* expect Clear Request on MSC side */
6969 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
6970
6971 /* Instruct BSC to clear channel */
6972 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
6973 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
6974
6975 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02006976 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01006977 }
6978
6979 /* In the buggy behavior, a timeout of 2 seconds happens between above
6980 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
6981 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
6982 f_sleep(4.0);
6983
6984 deactivate(d);
6985 f_shutdown_helper();
6986}
6987
Harald Welte94e0c342018-04-07 11:33:23 +02006988/***********************************************************************
6989 * IPA style dynamic PDCH
6990 ***********************************************************************/
6991
6992private function f_dyn_ipa_pdch_act(integer bts_nr, integer trx_nr, integer ts_nr,
6993 template (omit) RSL_Cause nack := omit)
6994runs on test_CT {
6995 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(ts_nr));
6996 var RSL_Message rsl_unused;
6997 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
6998 f_vty_ts_action("pdch activate", bts_nr, trx_nr, ts_nr);
6999 /* expect the BSC to issue the related RSL command */
7000 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
7001 if (istemplatekind(nack, "omit")) {
7002 /* respond with a related acknowledgement */
7003 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
7004 } else {
7005 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_NACK(chan_nr, valueof(nack)));
7006 }
7007}
7008
7009private function f_dyn_ipa_pdch_deact(integer bts_nr, integer trx_nr, integer ts_nr,
7010 template (omit) RSL_Cause nack := omit)
7011runs on test_CT {
7012 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(ts_nr));
7013 var RSL_Message rsl_unused;
7014 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
7015 f_vty_ts_action("pdch deactivate", bts_nr, trx_nr, ts_nr);
7016 /* expect the BSC to issue the related RSL command */
7017 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_DEACT(chan_nr));
7018 if (istemplatekind(nack, "omit")) {
7019 /* respond with a related acknowledgement */
7020 f_ipa_tx(0, ts_RSL_IPA_PDCH_DEACT_ACK(chan_nr));
7021 } else {
7022 f_ipa_tx(0, ts_RSL_IPA_PDCH_DEACT_NACK(chan_nr, valueof(nack)));
7023 }
7024}
7025
7026private function f_ts_dyn_mode_get(integer bts_nr, integer trx_nr, integer ts_nr)
7027runs on test_CT return charstring {
7028 var charstring cmd, resp;
7029 cmd := "show timeslot "&int2str(bts_nr)&" "&int2str(trx_nr)&" "&int2str(ts_nr);
Stefan Sperlingcff13562018-11-13 15:24:06 +01007030 return f_vty_transceive_match_regexp_retry(BSCVTY, cmd, "*\((*)\)*", 0, 4, 1.0);
Harald Welte94e0c342018-04-07 11:33:23 +02007031}
7032
7033private function f_ts_dyn_mode_assert(integer bts_nr, integer trx_nr, integer ts_nr,
7034 template charstring exp)
7035runs on test_CT {
7036 var charstring mode := f_ts_dyn_mode_get(bts_nr, trx_nr, ts_nr);
7037 if (not match(mode, exp)) {
7038 setverdict(fail, "Unexpected TS Mode: ", mode);
Daniel Willmannafce8662018-07-06 23:11:32 +02007039 mtc.stop;
Harald Welte94e0c342018-04-07 11:33:23 +02007040 }
7041}
7042
7043private function f_ts_set_chcomb(integer bts_nr, integer trx_nr, integer ts_nr, charstring chcomb)
7044runs on test_CT {
7045 f_vty_enter_cfg_ts(BSCVTY, bts_nr, trx_nr, ts_nr);
7046 f_vty_transceive(BSCVTY, "phys_chan_config " & chcomb);
7047 f_vty_transceive(BSCVTY, "end");
7048}
7049
Pau Espin Pedrol0953bf82021-07-09 13:20:19 +02007050
7051private function f_ts_reset_chcomb(integer bts_nr) runs on test_CT {
7052 var integer i;
7053 for (i := 0; i < 8; i := i + 1) {
7054 f_ts_set_chcomb(bts_nr, 0, i, phys_chan_config[i]);
7055 }
7056}
7057
Harald Welte94e0c342018-04-07 11:33:23 +02007058private const charstring TCHF_MODE := "TCH/F mode";
7059private const charstring TCHH_MODE := "TCH/H mode";
7060private const charstring PDCH_MODE := "PDCH mode";
7061private const charstring NONE_MODE := "NONE mode";
Pau Espin Pedrol5b381082021-06-28 17:14:03 +02007062private const charstring SDCCH8_MODE := "SDCCH8 mode";
Harald Welte94e0c342018-04-07 11:33:23 +02007063
7064/* Test IPA PDCH activation / deactivation triggered by VTY */
7065testcase TC_dyn_pdch_ipa_act_deact() runs on test_CT {
7066 var RSL_Message rsl_unused;
7067
7068 /* change Timeslot 6 before f_init() starts RSL */
7069 f_init_vty();
7070 f_ts_set_chcomb(0, 0, 6, "TCH/F_PDCH");
7071 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7072
7073 f_init(1, false);
7074 f_sleep(1.0);
7075
7076 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
7077
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02007078 log("TCH/F_PDCH pchan starts out in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02007079 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
7080 /* The BSC will activate the dynamic PDCH by default, so confirm that */
7081 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
7082 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
7083 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02007084 log("TCH/F_PDCH pchan, PDCH ACT was ACKed, so now in PDCH mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02007085 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
7086
7087 /* De-activate it via VTY */
7088 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
7089 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02007090 log("TCH/F_PDCH pchan, PDCH DEACT via VTY, so now back in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02007091 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
7092
7093 /* re-activate it via VTY */
7094 f_dyn_ipa_pdch_act(0, 0, chan_nr.tn);
7095 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02007096 log("TCH/F_PDCH pchan, PDCH ACT via VTY, so now in PDCH mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02007097 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
7098
7099 /* and finally de-activate it again */
7100 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
7101 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02007102 log("TCH/F_PDCH pchan, PDCH DEACT via VTY, so now back in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02007103 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
7104
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02007105 /* clean up config */
7106 f_ts_set_chcomb(0, 0, 6, "PDCH");
7107
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007108 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02007109}
7110
7111/* Test IPA PDCH activation NACK */
7112testcase TC_dyn_pdch_ipa_act_nack() runs on test_CT {
7113 var RSL_Message rsl_unused;
7114
7115 /* change Timeslot 6 before f_init() starts RSL */
7116 f_init_vty();
7117 f_ts_set_chcomb(0, 0, 6, "TCH/F_PDCH");
7118 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7119
7120 f_init(1, false);
7121 f_sleep(1.0);
7122
7123 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
7124
7125 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
7126 /* The BSC will activate the dynamic PDCH by default, so confirm that */
7127 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
7128 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
7129 f_sleep(1.0);
7130 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
7131
7132 /* De-activate it via VTY */
7133 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
7134 f_sleep(1.0);
7135 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
7136
7137 /* re-activate it via VTY, but fail that; check BSC still assumes TCH/F mode */
7138 f_dyn_ipa_pdch_act(0, 0, chan_nr.tn, RSL_ERR_EQUIPMENT_FAIL);
7139 f_sleep(1.0);
7140 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
7141
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02007142 /* clean up config */
7143 f_ts_set_chcomb(0, 0, 6, "PDCH");
7144
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007145 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02007146}
7147
7148
7149/***********************************************************************
7150 * Osmocom style dynamic PDCH
7151 ***********************************************************************/
7152
7153private function f_dyn_osmo_pdch_act(integer bts_nr, integer trx_nr, integer ts_nr,
7154 template (omit) RSL_Cause nack := omit)
7155runs on test_CT {
7156 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(ts_nr));
7157 var RSL_Message rsl_unused;
Pau Espin Pedrol64adf372021-06-28 16:25:47 +02007158 /* ask BSC via VTY to activate a given OSMO style chan as PDCH */
Harald Welte94e0c342018-04-07 11:33:23 +02007159 /* FIXME: no VTY command to activate Osmocom PDCH !! */
7160 /* expect the BSC to issue the related RSL command */
7161 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT(chan_nr, ?));
7162 if (istemplatekind(nack, "omit")) {
7163 /* respond with a related acknowledgement */
7164 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342));
7165 } else {
7166 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, valueof(nack)));
7167 }
7168}
7169
7170private function f_dyn_osmo_pdch_deact(integer bts_nr, integer trx_nr, integer ts_nr,
7171 template (omit) RSL_Cause nack := omit)
7172runs on test_CT {
7173 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(ts_nr));
7174 var RSL_Message rsl_unused;
Pau Espin Pedrol64adf372021-06-28 16:25:47 +02007175 /* ask BSC via VTY to activate a given OSMO style chan as PDCH */
Harald Welte94e0c342018-04-07 11:33:23 +02007176 /* FIXME: no VTY command to activate Osmocom PDCH !! */
7177 /* expect the BSC to issue the related RSL command */
7178 rsl_unused := f_exp_ipa_rx(0, tr_RSL_RF_CHAN_REL(chan_nr));
7179 if (istemplatekind(nack, "omit")) {
7180 /* respond with a related acknowledgement */
7181 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(chan_nr));
7182 } else {
7183 //f_ipa_tx(0, ts_RSL_RF_CHAN_REL_NACK(chan_nr, valueof(nack)));
7184 }
7185}
7186
7187/* Test Osmocom dyn PDCH activation / deactivation triggered by VTY */
7188testcase TC_dyn_pdch_osmo_act_deact() runs on test_CT {
7189 var RSL_Message rsl_unused;
7190
7191 /* change Timeslot 6 before f_init() starts RSL */
7192 f_init_vty();
7193 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_PDCH");
7194 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7195
7196 f_init(1, false);
7197 f_sleep(1.0);
7198
7199 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(6));
7200
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02007201 log("TCH/F_TCH/H_PDCH pchan starts out in disabled mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02007202 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
7203 /* The BSC will activate the dynamic PDCH by default, so confirm that */
7204 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
7205
7206 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342));
7207 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02007208 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 +02007209 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
7210
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02007211 /* clean up config */
7212 f_ts_set_chcomb(0, 0, 6, "PDCH");
7213
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007214 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02007215}
7216
7217/* Test Osmocom dyn PDCH activation NACK behavior */
7218testcase TC_dyn_pdch_osmo_act_nack() runs on test_CT {
7219 var RSL_Message rsl_unused;
7220
7221 /* change Timeslot 6 before f_init() starts RSL */
7222 f_init_vty();
7223 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_PDCH");
7224 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7225
7226 f_init(1, false);
7227 f_sleep(1.0);
7228
7229 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(6));
7230
7231 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
7232 /* The BSC will activate the dynamic PDCH by default, so confirm that */
7233 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
7234
7235 /* NACK this activation and expect the "show timeslot" mode still to be NONE */
7236 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, RSL_ERR_EQUIPMENT_FAIL));
7237 f_sleep(1.0);
7238 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
7239
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02007240 /* clean up config */
7241 f_ts_set_chcomb(0, 0, 6, "PDCH");
7242
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007243 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02007244}
7245
Pau Espin Pedrol5b381082021-06-28 17:14:03 +02007246/* Test Osmocom dyn TS SDCCH8 activation / deactivation */
7247testcase TC_dyn_ts_sdcch8_act_deact() runs on test_CT {
7248 var RSL_Message rsl_unused, rsl_msg;
7249 var DchanTuple dt;
7250 var BSSAP_N_CONNECT_ind rx_c_ind;
7251
7252 /* change Timeslot 6 before f_init() starts RSL */
7253 f_init_vty();
7254 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_SDCCH8_PDCH");
7255 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7256
7257 f_init(1, false);
7258 f_sleep(1.0);
7259
7260 var RslChannelNr pdch_chan_nr := valueof(t_RslChanNr_PDCH(6));
7261
7262 log("TCH/F_TCH/H_SDCCH8_PDCH pchan starts out in disabled mode:");
7263 f_ts_dyn_mode_assert(0, 0, pdch_chan_nr.tn, NONE_MODE);
7264 /* The BSC will activate the dynamic PDCH by default, so confirm that */
7265 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(pdch_chan_nr, ?));
7266
7267 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(pdch_chan_nr, 2342));
7268 f_sleep(1.0);
7269 log("TCH/F_TCH/H_SDCCH8_PDC requested to PDCH ACT on startup, which was ACKed, so now in PDCH:");
7270 f_ts_dyn_mode_assert(0, 0, pdch_chan_nr.tn, PDCH_MODE);
7271
7272 /* Fill TS0 SDCCH channels (NOTE: only 3 SDCCH/4 channels are available
7273 * on CCCH+SDCCH4+CBCH) */
7274 var integer i;
Pau Espin Pedrolce4d5bb2021-10-25 13:31:25 +02007275 for (i := 0; i < NUM_SDCCH_PER_BTS; i := i + 1) {
Pau Espin Pedrol5b381082021-06-28 17:14:03 +02007276 dt := f_est_dchan('23'O, i, '00010203040506'O);
7277 }
7278
7279 /* Now the dyn ts is selected. First PDCH is released, then sdcch chan is activated */
7280 f_ipa_tx(0, ts_RSL_CHAN_RQD(int2oct(oct2int('23'O) + i, 1), 2342));
7281 rsl_unused := f_exp_ipa_rx(0, tr_RSL_RF_CHAN_REL(pdch_chan_nr));
7282 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(pdch_chan_nr));
7283
7284 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7285 dt.rsl_chan_nr := rsl_msg.ies[0].body.chan_nr;
7286
7287 f_ts_dyn_mode_assert(0, 0, dt.rsl_chan_nr.tn, SDCCH8_MODE);
7288 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(dt.rsl_chan_nr, 2342));
7289 rsl_msg := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
7290 f_ts_dyn_mode_assert(0, 0, dt.rsl_chan_nr.tn, SDCCH8_MODE);
7291
7292 f_ipa_tx(0, ts_RSL_EST_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)), '1234'O));
7293 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3('1234'O))) -> value rx_c_ind;
7294 dt.sccp_conn_id := rx_c_ind.connectionId;
7295 BSSAP.send(ts_BSSAP_CONNECT_res(dt.sccp_conn_id));
7296
7297 /* Instruct BSC to clear channel */
7298 var BssmapCause cause := 0;
7299 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
7300 f_exp_chan_rel_and_clear(dt, 0);
7301
7302 /* The BSC will switch the TS back to PDCH once the only lchan using it is released: */
7303 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(pdch_chan_nr, ?));
7304 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(pdch_chan_nr, 2342));
7305 f_sleep(1.0);
7306 f_ts_dyn_mode_assert(0, 0, pdch_chan_nr.tn, PDCH_MODE);
7307
7308 /* clean up config */
7309 f_ts_set_chcomb(0, 0, 6, "PDCH");
7310
7311 f_shutdown_helper();
7312}
7313
Neels Hofmeyre1a7c4d2021-10-23 23:13:01 +02007314/* Validate all 8 subslots of a dynamics TS configured as SDCCH8 are used */
7315testcase TC_dyn_ts_sdcch8_all_subslots_used() runs on test_CT {
7316 var ASP_RSL_Unitdata rsl_ud;
7317 var integer i;
7318 var integer chreq_total, chreq_nochan;
7319
7320 f_init_vty();
7321 for (i := 1; i < 8; i := i + 1) {
7322 if (i == 2) {
7323 f_ts_set_chcomb(0, 0, i, "TCH/F_TCH/H_SDCCH8_PDCH");
7324 } else {
7325 f_ts_set_chcomb(0, 0, i, "PDCH");
7326 }
7327 }
7328 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7329
7330 f_init(1);
7331
7332 /* The dyn TS want to activate PDCH mode, ACK that. */
7333 var RslChannelNr chan_nr;
7334 chan_nr := valueof(t_RslChanNr_PDCH(2));
7335 f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
7336 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342));
7337
7338 f_sleep(1.0);
7339
7340 /* Exhaust all dedicated SDCCH lchans.
7341 /* GSM 44.018 Table 9.1.8.2:
7342 * RA = '13'O -> Establishment cause = 0001xxxx (MS dual rate capable and asks for "SDCCH").
7343 */
7344 for (i := 0; i < NUM_SDCCH_PER_BTS; i := i+1) {
7345 f_est_dchan('13'O, NUM_SDCCH_PER_BTS + i, '00010203040506'O);
7346 }
7347
7348 /* Only the dyn TS is still available. Its first lchan gets converted to SDCCH8 */
7349 f_est_dchan_dyn('33'O, NUM_SDCCH_PER_BTS + i, '00010203040506'O);
7350 /* Also occupy the seven other SDCCH of the dyn TS */
7351 for (i := 0; i < 7; i := i+1) {
7352 f_est_dchan('33'O, NUM_SDCCH_PER_BTS + i, '00010203040506'O);
7353 }
7354
7355 /* clean up config */
7356 f_ts_reset_chcomb(0);
7357
7358 f_shutdown_helper();
7359}
7360
Pau Espin Pedrol0953bf82021-07-09 13:20:19 +02007361/* Test Osmocom dyn TS SDCCH8 activation / deactivation: If activating dyn TS as
7362 SDCCH8 would end up in having no free TCH, then BSC should decide to activate
7363 it as TCH directly instead. SYS#5309. */
7364testcase TC_dyn_ts_sdcch8_tch_call_act_deact() runs on test_CT {
7365 var RSL_Message rsl_unused, rsl_msg;
7366 var DchanTuple dt;
7367 var BSSAP_N_CONNECT_ind rx_c_ind;
7368 var integer i;
7369
7370 /* change Timeslot 6 before f_init() starts RSL */
7371 f_init_vty();
7372 for (i := 1; i < 8; i := i + 1) {
7373 if (i == 6) {
7374 f_ts_set_chcomb(0, 0, i, "TCH/F_TCH/H_SDCCH8_PDCH");
7375 } else {
7376 f_ts_set_chcomb(0, 0, i, "PDCH");
7377 }
7378 }
7379 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7380
7381 f_init(1, false);
7382 f_sleep(1.0);
7383
7384 var RslChannelNr pdch_chan_nr := valueof(t_RslChanNr_PDCH(6));
7385
7386 log("TCH/F_TCH/H_SDCCH8_PDCH pchan starts out in disabled mode:");
7387 f_ts_dyn_mode_assert(0, 0, pdch_chan_nr.tn, NONE_MODE);
7388 /* The BSC will activate the dynamic PDCH by default, so confirm that */
7389 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(pdch_chan_nr, ?));
7390
7391 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(pdch_chan_nr, 2342));
7392 f_sleep(1.0);
7393 log("TCH/F_TCH/H_SDCCH8_PDC requested to PDCH ACT on startup, which was ACKed, so now in PDCH:");
7394 f_ts_dyn_mode_assert(0, 0, pdch_chan_nr.tn, PDCH_MODE);
7395
7396 /* Fill TS0 SDCCH channels (NOTE: only 3 SDCCH/4 channels are available
7397 * on CCCH+SDCCH4+CBCH) */
Pau Espin Pedrol2ebbe7c2021-07-23 16:17:09 +02007398 var OCT1 ra := '43'O; /* RA containing reason=originating speech call*/
Pau Espin Pedrolce4d5bb2021-10-25 13:31:25 +02007399 for (i := 0; i < NUM_SDCCH_PER_BTS; i := i + 1) {
Pau Espin Pedrol2ebbe7c2021-07-23 16:17:09 +02007400 dt := f_est_dchan(ra, i, '00010203040506'O);
Pau Espin Pedrol0953bf82021-07-09 13:20:19 +02007401 }
7402
7403 /* Now the dyn ts is selected. First PDCH is released, then TCH chan is activated */
Pau Espin Pedrol2ebbe7c2021-07-23 16:17:09 +02007404 f_ipa_tx(0, ts_RSL_CHAN_RQD(int2oct(oct2int(ra) + i, 1), 2342));
Pau Espin Pedrol0953bf82021-07-09 13:20:19 +02007405 rsl_unused := f_exp_ipa_rx(0, tr_RSL_RF_CHAN_REL(pdch_chan_nr));
7406 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(pdch_chan_nr));
7407
7408 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7409 dt.rsl_chan_nr := rsl_msg.ies[0].body.chan_nr;
7410
7411 f_ts_dyn_mode_assert(0, 0, dt.rsl_chan_nr.tn, TCHH_MODE);
7412 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(dt.rsl_chan_nr, 2342));
7413 rsl_msg := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
7414 f_ts_dyn_mode_assert(0, 0, dt.rsl_chan_nr.tn, TCHH_MODE);
7415
7416 f_ipa_tx(0, ts_RSL_EST_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)), '1234'O));
7417 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3('1234'O))) -> value rx_c_ind;
7418 dt.sccp_conn_id := rx_c_ind.connectionId;
7419 BSSAP.send(ts_BSSAP_CONNECT_res(dt.sccp_conn_id));
7420
7421 /* Instruct BSC to clear channel */
7422 var BssmapCause cause := 0;
7423 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
7424 f_exp_chan_rel_and_clear(dt, 0);
7425
7426 /* The BSC will switch the TS back to PDCH once the only lchan using it is released: */
7427 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(pdch_chan_nr, ?));
7428 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(pdch_chan_nr, 2342));
7429 f_sleep(1.0);
7430 f_ts_dyn_mode_assert(0, 0, pdch_chan_nr.tn, PDCH_MODE);
7431
7432 /* clean up config */
7433 f_ts_reset_chcomb(0);
7434 /* TODO: clean up other channels? */
7435
7436 f_shutdown_helper();
7437}
7438
Pau Espin Pedrolcdf26142021-06-28 17:14:03 +02007439/* Test Osmocom dyn TS SDCCH8 activation / deactivation when SDCCH fails at BTS */
7440testcase TC_dyn_ts_sdcch8_act_nack() runs on test_CT {
7441 var RSL_Message rsl_unused, rsl_msg;
7442 var DchanTuple dt;
7443 var BSSAP_N_CONNECT_ind rx_c_ind;
7444 var GsmRrMessage rr;
7445
7446 /* change Timeslot 6 before f_init() starts RSL */
7447 f_init_vty();
7448 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_SDCCH8_PDCH");
7449 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7450
7451 f_init(1, false);
7452 f_sleep(1.0);
7453
7454 var RslChannelNr pdch_chan_nr := valueof(t_RslChanNr_PDCH(6));
7455
7456 log("TCH/F_TCH/H_SDCCH8_PDCH pchan starts out in disabled mode:");
7457 f_ts_dyn_mode_assert(0, 0, pdch_chan_nr.tn, NONE_MODE);
7458 /* The BSC will activate the dynamic PDCH by default, so confirm that */
7459 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(pdch_chan_nr, ?));
7460
7461 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(pdch_chan_nr, 2342));
7462 f_sleep(1.0);
7463 log("TCH/F_TCH/H_SDCCH8_PDC requested to PDCH ACT on startup, which was ACKed, so now in PDCH:");
7464 f_ts_dyn_mode_assert(0, 0, pdch_chan_nr.tn, PDCH_MODE);
7465
7466 /* Fill TS0 SDCCH channels (NOTE: only 3 SDCCH/4 channels are available
7467 * on CCCH+SDCCH4+CBCH) */
7468 var integer i;
Pau Espin Pedrolce4d5bb2021-10-25 13:31:25 +02007469 for (i := 0; i < NUM_SDCCH_PER_BTS; i := i + 1) {
Pau Espin Pedrolcdf26142021-06-28 17:14:03 +02007470 dt := f_est_dchan('23'O, i, '00010203040506'O);
7471 }
7472
7473 /* Now the dyn ts is selected. First PDCH is released, then sdcch chan is activated */
7474 f_ipa_tx(0, ts_RSL_CHAN_RQD(int2oct(oct2int('23'O) + i, 1), 2342));
7475 rsl_unused := f_exp_ipa_rx(0, tr_RSL_RF_CHAN_REL(pdch_chan_nr));
7476 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(pdch_chan_nr));
7477
7478 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7479 dt.rsl_chan_nr := rsl_msg.ies[0].body.chan_nr;
7480
7481 f_ts_dyn_mode_assert(0, 0, dt.rsl_chan_nr.tn, SDCCH8_MODE);
7482 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(dt.rsl_chan_nr, RSL_ERR_EQUIPMENT_FAIL));
7483 rsl_msg := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
7484 rr := dec_GsmRrMessage(rsl_msg.ies[1].body.full_imm_ass_info.payload);
7485 if (rr.header.message_type != IMMEDIATE_ASSIGNMENT_REJECT) {
7486 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Expected reject");
7487 }
7488
7489 /* FIXME? Currently the TS stays in state BORKEN: */
7490
7491 /* The BSC will switch the TS back to PDCH once the only lchan using it is released: */
7492 /* rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(pdch_chan_nr, ?));
7493 * f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(pdch_chan_nr, 2342));
7494 * f_sleep(1.0);
7495 * f_ts_dyn_mode_assert(0, 0, pdch_chan_nr.tn, PDCH_MODE)
7496 */
7497
7498 /* clean up config */
7499 f_ts_set_chcomb(0, 0, 6, "PDCH");
7500
7501 f_shutdown_helper();
7502}
7503
Stefan Sperling0796a822018-10-05 13:01:39 +02007504testcase TC_chopped_ipa_ping() runs on test_CT {
Stefan Sperling554123f2018-10-09 14:12:30 +02007505 const Integers bsc_ipa_ports := {mp_bsc_rsl_port, mp_bsc_oml_port, mp_bsc_ctrl_port};
Stefan Sperling0796a822018-10-05 13:01:39 +02007506 for (var integer i := 0; i < lengthof(bsc_ipa_ports); i := i + 1) {
7507 IPA_Testing.f_run_TC_chopped_ipa_ping(mp_bsc_ip, bsc_ipa_ports[i], CONNECT_TO_SERVER);
7508 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007509 f_shutdown_helper();
Stefan Sperling0796a822018-10-05 13:01:39 +02007510}
7511
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02007512testcase TC_chopped_ipa_payload() runs on test_CT {
7513 const Integers bsc_ipa_ports := {mp_bsc_rsl_port, mp_bsc_oml_port
7514 /* TODO: mp_bsc_ctrl_port does not work yet */};
7515 for (var integer i := 0; i < lengthof(bsc_ipa_ports); i := i + 1) {
7516 IPA_Testing.f_run_TC_chopped_ipa_payload(mp_bsc_ip, bsc_ipa_ports[i], CONNECT_TO_SERVER);
7517 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007518 f_shutdown_helper();
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02007519}
7520
Pau Espin Pedrol8f773632019-11-05 11:46:53 +01007521/* Verify the BSC sends the MS Power Parameters IE during CHAN ACT to make sure
7522 the BTS does autonomous MS power control loop */
7523testcase TC_assignment_verify_ms_power_params_ie() runs on test_CT {
7524 var MSC_ConnHdlr vc_conn;
7525 var TestHdlrParams pars := f_gen_test_hdlr_pars();
7526 //pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
7527 pars.exp_ms_power_params := true;
7528
7529 f_init(1, true);
7530 f_sleep(1.0);
7531 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
7532 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007533 f_shutdown_helper();
Pau Espin Pedrol8f773632019-11-05 11:46:53 +01007534}
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02007535
Vadim Yanitskiy4b233042021-06-30 00:58:43 +02007536/* Verify activation and deactivation of the BCCH carrier power reduction mode */
7537testcase TC_c0_power_red_mode() runs on test_CT {
7538 f_init(1);
7539
7540 for (var integer red := 6; red >= 0; red := red - 2) {
7541 /* Configure BCCH carrier power reduction mode via the VTY */
7542 f_vty_transceive(BSCVTY, "bts 0 c0-power-reduction " & int2str(red));
7543
7544 /* Expect Osmocom specific BS Power Control message on the RSL */
7545 var template RSL_Message tr_rsl_pdu := tr_RSL_BS_PWR_CTRL(
7546 chan_nr := t_RslChanNr_BCCH(0),
7547 bs_power := tr_RSL_IE_BS_Power(red / 2));
7548 tr_rsl_pdu.msg_disc := tr_RSL_MsgDisc(RSL_MDISC_CCHAN, false);
7549 var RSL_Message unused := f_exp_ipa_rx(0, tr_rsl_pdu);
7550
7551 /* Additionally verify the applied value over the CTRL interface */
7552 var CtrlValue cred := f_ctrl_get_bts(IPA_CTRL, 0, "c0-power-reduction");
7553 if (cred != int2str(red)) {
7554 setverdict(fail, "Unexpected BCCH carrier power reduction value ",
7555 cred, " (expected ", red, ")");
7556 }
7557 }
7558
7559 f_shutdown_helper();
7560}
7561
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007562/***********************************************************************
7563 * MSC Pooling
7564 ***********************************************************************/
7565
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007566template MobileIdentityLV ts_MI_TMSI_NRI_LV(integer nri_v, integer nri_bitlen := 10) :=
Harald Weltebf397612021-01-14 20:39:46 +01007567 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 +02007568
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007569private function f_expect_lchan_rel(RSL_DCHAN_PT rsl_pt, RSLEM_PROC_PT rsl_proc_pt, template PDU_ML3_NW_MS exp_rr_rel_tmpl := tr_RRM_RR_RELEASE)
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02007570runs on MSC_ConnHdlr {
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02007571 interleave {
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007572 [] rsl_pt.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch exp_rr_rel_tmpl)) {
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02007573 f_logp(BSCVTY, "Got RSL RR Release");
7574 }
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007575 [] rsl_pt.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02007576 f_logp(BSCVTY, "Got RSL Deact SACCH");
7577 }
Neels Hofmeyr3c5127e2021-07-22 19:18:40 +02007578 [] rsl_pt.receive(tr_RSL_RF_CHAN_REL(g_chan_nr)) {
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02007579 f_logp(BSCVTY, "Got RSL RF Chan Rel, sending Rel Ack");
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007580 rsl_pt.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
7581 f_rslem_unregister(0, g_chan_nr, PT := rsl_proc_pt);
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02007582 break;
7583 }
7584 }
7585}
7586
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007587friend function f_perform_clear(RSL_DCHAN_PT rsl_pt := RSL, RSLEM_PROC_PT rsl_proc_pt := RSL_PROC,
7588 template PDU_ML3_NW_MS exp_rr_rel_tmpl := tr_RRM_RR_RELEASE)
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02007589runs on MSC_ConnHdlr {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00007590 f_logp(BSCVTY, "MSC instructs BSC to clear channel");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007591 BSSAP.send(ts_BSSMAP_ClearCommand(0));
7592 interleave {
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007593 [] rsl_pt.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch exp_rr_rel_tmpl)) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00007594 f_logp(BSCVTY, "Got RSL RR Release");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007595 }
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007596 [] rsl_pt.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00007597 f_logp(BSCVTY, "Got RSL Deact SACCH");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007598 }
7599 [] BSSAP.receive(tr_BSSMAP_ClearComplete) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00007600 f_logp(BSCVTY, "Got BSSMAP Clear Complete");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007601 /* Also drop the SCCP connection */
7602 BSSAP.send(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_REQ);
7603 }
Neels Hofmeyr3c5127e2021-07-22 19:18:40 +02007604 [] rsl_pt.receive(tr_RSL_RF_CHAN_REL(g_chan_nr)) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00007605 f_logp(BSCVTY, "Got RSL RF Chan Rel, sending Rel Ack");
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007606 rsl_pt.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
7607 f_rslem_unregister(0, g_chan_nr, PT := rsl_proc_pt);
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007608 }
7609 }
7610}
7611
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007612private function f_perform_compl_l3(RSL_DCHAN_PT rsl_pt, RSLEM_PROC_PT rsl_proc_pt,
7613 template PDU_ML3_MS_NW l3_info, boolean do_clear := true, boolean expect_bssmap_l3 := true)
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007614runs on MSC_ConnHdlr {
7615 timer T := 10.0;
7616 var octetstring l3_enc := enc_PDU_ML3_MS_NW(valueof(l3_info));
7617
Neels Hofmeyr767548a2020-08-09 20:26:07 +00007618 f_logp(BSCVTY, "establish channel, send Complete Layer 3 Info");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007619 f_create_bssmap_exp(l3_enc);
7620
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007621 /* RSL_Emulation.f_chan_est() on rsl_pt:
7622 * This is basically code dup with s/RSL/rsl_pt from:
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007623 * RSL_Emulation.f_chan_est(g_pars.ra, l3_enc, g_pars.link_id, g_pars.fn);
7624 */
7625 var RSL_Message rx_rsl;
7626 var GsmRrMessage rr;
7627
7628 /* request a channel to be established */
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007629 rsl_pt.send(ts_RSLDC_ChanRqd(g_pars.ra, g_pars.fn));
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007630 /* expect immediate assignment.
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007631 * Code dup with s/RSL/rsl_pt from:
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007632 * rx_rsl := f_rx_or_fail(tr_RSL_IMM_ASSIGN);
7633 */
7634 timer Tt := 10.0;
7635
7636 /* request a channel to be established */
7637 Tt.start;
7638 alt {
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007639 [] rsl_pt.receive(tr_RSL_IMM_ASSIGN) -> value rx_rsl {
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007640 Tt.stop;
7641 }
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007642 [] rsl_pt.receive {
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007643 setverdict(fail, "Unexpected RSL message on DCHAN");
7644 mtc.stop;
7645 }
7646 [] Tt.timeout {
7647 setverdict(fail, "Timeout waiting for RSL on DCHAN");
7648 mtc.stop;
7649 }
7650 }
7651 rr := dec_GsmRrMessage(rx_rsl.ies[1].body.full_imm_ass_info.payload);
7652 g_chan_nr := rr.payload.imm_ass.chan_desc.chan_nr;
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007653 rsl_pt.send(ts_RSL_EST_IND(g_chan_nr, valueof(g_pars.link_id), l3_enc));
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007654
7655
Neels Hofmeyr66e15092020-10-12 18:44:41 +00007656 if (expect_bssmap_l3) {
7657 f_logp(BSCVTY, "expect BSSAP Complete Layer 3 Info at MSC");
7658 var template PDU_BSSAP exp_l3_compl;
7659 exp_l3_compl := tr_BSSMAP_ComplL3()
7660 if (g_pars.aoip == false) {
7661 exp_l3_compl.pdu.bssmap.completeLayer3Information.codecList := omit;
7662 } else {
7663 exp_l3_compl.pdu.bssmap.completeLayer3Information.codecList := ?;
7664 }
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007665
Neels Hofmeyr66e15092020-10-12 18:44:41 +00007666 var PDU_BSSAP bssap;
7667 T.start;
7668 alt {
7669 [] BSSAP.receive(exp_l3_compl) -> value bssap {
7670 f_logp(BSCVTY, "received expected Complete Layer 3 Info at MSC");
7671 log("rx exp_l3_compl = ", bssap);
7672 }
7673 [] BSSAP.receive(tr_BSSMAP_ComplL3) {
7674 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received non-matching COMPLETE LAYER 3 INFORMATION");
7675 }
7676 [] T.timeout {
7677 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for COMPLETE LAYER 3 INFORMATION");
7678 }
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007679 }
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007680
Neels Hofmeyr66e15092020-10-12 18:44:41 +00007681 /* start ciphering, if requested */
7682 if (ispresent(g_pars.encr)) {
7683 f_logp(BSCVTY, "start ciphering");
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007684 f_cipher_mode(g_pars.encr, rsl_pt := rsl_pt, rsl_proc_pt := rsl_proc_pt);
Neels Hofmeyr66e15092020-10-12 18:44:41 +00007685 }
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007686 }
7687
7688 if (do_clear) {
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007689 f_perform_clear(rsl_pt, rsl_proc_pt);
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007690 }
7691 setverdict(pass);
7692 f_sleep(1.0);
7693}
7694
7695private function f_tc_mscpool_compl_l3(charstring id) runs on MSC_ConnHdlr {
7696 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
7697 if (g_pars.mscpool.rsl_idx == 0) {
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007698 f_perform_compl_l3(RSL, RSL_PROC, g_pars.mscpool.l3_info);
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007699 } else if (g_pars.mscpool.rsl_idx == 1) {
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007700 f_perform_compl_l3(RSL1, RSL1_PROC, g_pars.mscpool.l3_info);
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007701 } else if (g_pars.mscpool.rsl_idx == 2) {
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007702 f_perform_compl_l3(RSL2, RSL2_PROC, g_pars.mscpool.l3_info);
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007703 }
7704}
7705
7706/* Various Complete Layer 3 by IMSI all end up with the first MSC, because the other MSCs are not connected. */
7707private function f_tc_mscpool_L3Compl_on_1_msc(charstring id) runs on MSC_ConnHdlr {
7708 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007709 f_perform_compl_l3(RSL, RSL_PROC, ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000001'H)), '00F110'O) );
7710 f_perform_compl_l3(RSL, RSL_PROC, ts_CM_SERV_REQ(CM_TYPE_MO_SMS, valueof(ts_MI_IMSI_LV('001010000000002'H))) );
7711 f_perform_compl_l3(RSL, RSL_PROC, ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010000000003'H))) );
7712 f_perform_compl_l3(RSL, RSL_PROC, ts_ML3_MO_MM_IMSI_DET_Ind(valueof(ts_MI_IMSI_LV('001010000000004'H))) );
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007713}
7714testcase TC_mscpool_L3Compl_on_1_msc() runs on test_CT {
7715
7716 f_init(1, true);
7717 f_sleep(1.0);
7718 var MSC_ConnHdlr vc_conn;
7719 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007720
7721 f_ctrs_msc_init();
7722
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007723 vc_conn := f_start_handler(refers(f_tc_mscpool_L3Compl_on_1_msc), pars);
7724 vc_conn.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007725
7726 f_ctrs_msc_expect(0, "mscpool:subscr:new", 4);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007727 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007728}
7729
7730/* Three Layer 3 Complete by IMSI are round-robin'ed across two connected MSCs */
7731/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
7732 * just as well using only RSL. */
7733testcase TC_mscpool_L3Complete_by_imsi_round_robin() runs on test_CT {
7734
7735 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
7736 f_sleep(1.0);
7737
7738 /* Control which MSC gets chosen next by the round-robin, otherwise
7739 * would be randomly affected by which other tests ran before this. */
7740 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
7741
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007742 f_ctrs_msc_init();
7743
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007744 var MSC_ConnHdlr vc_conn1;
7745 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
7746 pars1.mscpool.rsl_idx := 0;
7747 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000001'H)), '00F110'O));
7748 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
7749 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007750 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007751
7752 var MSC_ConnHdlr vc_conn2;
7753 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
7754 pars2.mscpool.rsl_idx := 1;
7755 pars2.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000002'H))));
7756 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
7757 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007758 f_ctrs_msc_expect(1, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007759
7760 /* Test round-robin wrap to the first MSC */
7761 var MSC_ConnHdlr vc_conn3;
7762 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
7763 pars3.mscpool.rsl_idx := 2;
7764 pars3.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010000000003'H))));
7765 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
7766 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007767 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007768 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007769}
7770
7771/* Three LU by TMSI are round-robin'ed across two connected MSCs, because they contain the NULL-NRI 0
7772 * (configured in osmo-bsc.cfg). */
7773/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
7774 * just as well using only RSL. */
7775testcase TC_mscpool_LU_by_tmsi_null_nri_0_round_robin() runs on test_CT {
7776
7777 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
7778 f_sleep(1.0);
7779
7780 /* Control which MSC gets chosen next by the round-robin, otherwise
7781 * would be randomly affected by which other tests ran before this. */
7782 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
7783
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007784 f_ctrs_msc_init();
7785
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007786 var MSC_ConnHdlr vc_conn1;
7787 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
7788 pars1.mscpool.rsl_idx := 0;
7789 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(0)), '00F110'O));
7790 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
7791 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007792 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007793
7794 var MSC_ConnHdlr vc_conn2;
7795 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
7796 pars2.mscpool.rsl_idx := 1;
7797 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(0)), '00F110'O));
7798 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
7799 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007800 f_ctrs_msc_expect(1, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007801
7802 /* Test round-robin wrap to the first MSC */
7803 var MSC_ConnHdlr vc_conn3;
7804 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
7805 pars3.mscpool.rsl_idx := 2;
7806 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(0)), '00F110'O));
7807 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
7808 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007809 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007810 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007811}
7812
7813/* Three LU by TMSI are round-robin'ed across two connected MSCs, because they contain the NULL-NRI 1
7814 * (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
7815 * NULL-NRI setting is stronger than that. */
7816/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
7817 * just as well using only RSL. */
7818testcase TC_mscpool_LU_by_tmsi_null_nri_1_round_robin() runs on test_CT {
7819
7820 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
7821 f_sleep(1.0);
7822
7823 /* Control which MSC gets chosen next by the round-robin, otherwise
7824 * would be randomly affected by which other tests ran before this. */
7825 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
7826
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007827 f_ctrs_msc_init();
7828
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007829 var MSC_ConnHdlr vc_conn1;
7830 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
7831 pars1.mscpool.rsl_idx := 0;
7832 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(1)), '00F110'O));
7833 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
7834 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007835 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007836
7837 var MSC_ConnHdlr vc_conn2;
7838 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
7839 pars2.mscpool.rsl_idx := 1;
7840 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(1)), '00F110'O));
7841 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
7842 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007843 f_ctrs_msc_expect(1, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007844
7845 /* Test round-robin wrap to the first MSC */
7846 var MSC_ConnHdlr vc_conn3;
7847 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
7848 pars3.mscpool.rsl_idx := 2;
7849 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(1)), '00F110'O));
7850 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
7851 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007852 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007853 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007854}
7855
7856/* Three Layer 3 Complete by TMSI are round-robin'ed across two connected MSCs, because they contain an NRI not
7857 * assigned to any MSC (configured in osmo-bsc.cfg). */
7858/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
7859 * just as well using only RSL. */
7860testcase TC_mscpool_L3Complete_by_tmsi_unassigned_nri_round_robin() runs on test_CT {
7861
7862 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
7863 f_sleep(1.0);
7864
7865 /* Control which MSC gets chosen next by the round-robin, otherwise
7866 * would be randomly affected by which other tests ran before this. */
7867 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
7868
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007869 f_ctrs_msc_init();
7870
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007871 var MSC_ConnHdlr vc_conn1;
7872 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
7873 pars1.mscpool.rsl_idx := 0;
7874 /* An NRI that is not assigned to any MSC */
7875 pars1.mscpool.l3_info := valueof(ts_ML3_MO_MM_IMSI_DET_Ind(valueof(ts_MI_TMSI_NRI_LV(1023))));
7876 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
7877 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007878 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007879
7880 var MSC_ConnHdlr vc_conn2;
7881 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
7882 pars2.mscpool.rsl_idx := 1;
7883 /* An NRI that is not assigned to any MSC */
7884 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(768)), '00F110'O));
7885 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
7886 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007887 f_ctrs_msc_expect(1, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007888
7889 /* Test round-robin wrap to the first MSC */
7890 var MSC_ConnHdlr vc_conn3;
7891 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
7892 pars3.mscpool.rsl_idx := 2;
7893 /* An NRI that is not assigned to any MSC */
7894 pars3.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_SS_ACT, valueof(ts_MI_TMSI_NRI_LV(819))));
7895 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
7896 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007897 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007898 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007899}
7900
7901/* Three Layer 3 Complete by TMSI are round-robin'ed across two connected MSCs, because they contain an NRI
7902 * assigned to an MSC that is currently not connected (configured in osmo-bsc.cfg). */
7903/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
7904 * just as well using only RSL. */
7905testcase TC_mscpool_L3Complete_by_tmsi_valid_nri_msc_not_connected_round_robin() runs on test_CT {
7906
7907 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
7908 f_sleep(1.0);
7909
7910 /* Control which MSC gets chosen next by the round-robin, otherwise
7911 * would be randomly affected by which other tests ran before this. */
7912 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
7913
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007914 f_ctrs_msc_init();
7915
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007916 var MSC_ConnHdlr vc_conn1;
7917 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
7918 pars1.mscpool.rsl_idx := 0;
7919 /* An NRI that is assigned to an unconnected MSC */
7920 pars1.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(512))));
7921 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
7922 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007923 f_ctrs_msc_add(2, "mscpool:subscr:attach_lost");
7924 f_ctrs_msc_add(0, "mscpool:subscr:new");
7925 f_ctrs_msc_verify();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007926
7927 var MSC_ConnHdlr vc_conn2;
7928 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
7929 pars2.mscpool.rsl_idx := 1;
7930 /* An NRI that is assigned to an unconnected MSC */
7931 pars2.mscpool.l3_info := valueof(ts_ML3_MO_MM_IMSI_DET_Ind(valueof(ts_MI_TMSI_NRI_LV(767))));
7932 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
7933 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007934 f_ctrs_msc_add(2, "mscpool:subscr:attach_lost");
7935 f_ctrs_msc_add(1, "mscpool:subscr:new");
7936 f_ctrs_msc_verify();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007937
7938 /* Test round-robin wrap to the first MSC */
7939 var MSC_ConnHdlr vc_conn3;
7940 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
7941 pars3.mscpool.rsl_idx := 2;
7942 /* An NRI that is assigned to an unconnected MSC */
7943 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(750)), '00F110'O));
7944 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
7945 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007946 f_ctrs_msc_add(2, "mscpool:subscr:attach_lost");
7947 f_ctrs_msc_add(0, "mscpool:subscr:new");
7948 f_ctrs_msc_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007949 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007950}
7951
7952/* Three Layer 3 Complete by TMSI with valid NRI for the second MSC are all directed to the second MSC (configured in
7953 * osmo-bsc.cfg). */
7954/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
7955 * just as well using only RSL. */
7956testcase TC_mscpool_L3Complete_by_tmsi_valid_nri_1() runs on test_CT {
7957
7958 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
7959 f_sleep(1.0);
7960
7961 /* All TMSIs in this test point at the second MSC, set the round robin to point at the first MSC to make sure
7962 * this is not using round-robin. */
7963 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
7964
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007965 f_ctrs_msc_init();
7966
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007967 var MSC_ConnHdlr vc_conn1;
7968 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 1);
7969 pars1.mscpool.rsl_idx := 0;
7970 /* An NRI of the second MSC's range (256-511) */
7971 pars1.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_SMS, valueof(ts_MI_TMSI_NRI_LV(256))));
7972 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
7973 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007974 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007975
7976 var MSC_ConnHdlr vc_conn2;
7977 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
7978 pars2.mscpool.rsl_idx := 1;
7979 /* An NRI of the second MSC's range (256-511) */
7980 pars2.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(260))));
7981 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
7982 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007983 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007984
7985 var MSC_ConnHdlr vc_conn3;
7986 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 1);
7987 pars3.mscpool.rsl_idx := 2;
7988 /* An NRI of the second MSC's range (256-511) */
7989 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(511)), '00F110'O));
7990 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
7991 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007992 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007993 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007994}
7995
7996/* Layer 3 Complete by TMSI with valid NRI for the third MSC are directed to the third MSC (configured in osmo-bsc.cfg),
7997 * while a round-robin remains unaffected by that. */
7998/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
7999 * just as well using only RSL. */
8000testcase TC_mscpool_L3Complete_by_tmsi_valid_nri_2() runs on test_CT {
8001
8002 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
8003 f_sleep(1.0);
8004
8005 /* All TMSIs in this test point at the third MSC, set the round robin to point at the second MSC to make sure
8006 * this is not using round-robin. */
8007 f_vty_transceive(BSCVTY, "mscpool roundrobin next 1");
8008
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008009 f_ctrs_msc_init();
8010
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008011 var MSC_ConnHdlr vc_conn1;
8012 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 2);
8013 pars1.mscpool.rsl_idx := 0;
8014 /* An NRI of the third MSC's range (512-767) */
8015 pars1.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_SMS, valueof(ts_MI_TMSI_NRI_LV(512))));
8016 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
8017 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008018 f_ctrs_msc_expect(2, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008019
8020 var MSC_ConnHdlr vc_conn2;
8021 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 2);
8022 pars2.mscpool.rsl_idx := 1;
8023 /* An NRI of the third MSC's range (512-767) */
8024 pars2.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(678))));
8025 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
8026 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008027 f_ctrs_msc_expect(2, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008028
8029 /* The above forwardings to third MSC have not affected the round robin, which still points at the second MSC */
8030 var MSC_ConnHdlr vc_conn3;
8031 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 1);
8032 pars3.mscpool.rsl_idx := 2;
8033 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000013'H)), '00F110'O));
8034 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
8035 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008036 f_ctrs_msc_expect(1, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02008037 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008038}
8039
8040/* LU with a TMSI but indicating a different PLMN in its previous LAI: ignore the NRI. */
8041/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
8042 * just as well using only RSL. */
8043testcase TC_mscpool_LU_by_tmsi_from_other_PLMN() runs on test_CT {
8044
8045 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
8046 f_sleep(1.0);
8047
8048 /* The TMSIs in this test points at the second MSC, but since it is from a different PLMN, round-robin is used
8049 * instead, and hits msc 0. */
8050 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
8051
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008052 f_ctrs_msc_init();
8053
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008054 /* An NRI of the second MSC's range (256-511), but a PLMN that doesn't match with osmo-bsc.cfg */
8055 var MSC_ConnHdlr vc_conn1;
8056 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
8057 pars1.mscpool.rsl_idx := 0;
8058 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(260)), '99F999'O));
8059 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
8060 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008061 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008062
8063 /* An NRI of the third MSC's range (512-767) and a matching PLMN gets directed by NRI. */
8064 var MSC_ConnHdlr vc_conn2;
8065 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 2);
8066 pars2.mscpool.rsl_idx := 1;
8067 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(555)), '00F110'O));
8068 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
8069 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008070 f_ctrs_msc_expect(2, "mscpool:subscr:known");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02008071 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008072}
8073
8074/* Make sure that whichever MSC paged a subscriber will also get the Paging Response. Page by IMSI, which would be
8075 * round-robined to another MSC, to make sure the Paging->Response relation is stronger than the NRI->MSC mapping. */
8076private function f_tc_mscpool_paging_imsi(charstring id) runs on MSC_ConnHdlr {
8077 var template BSSMAP_FIELD_CellIdentificationList cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(0) } };
8078 //cid_list := { cIl_allInBSS := ''O };
8079 var RSL_ChanNeeded rsl_chneed := RSL_CHANNEED_SDCCH;
8080 var template BSSMAP_IE_ChannelNeeded bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
8081 var BSSAP_N_UNITDATA_req paging;
8082 var hexstring imsi := '001010000000123'H;
8083
8084 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
8085
Neels Hofmeyr90f80962020-06-12 16:16:55 +02008086 paging := valueof(ts_BSSAP_UNITDATA_req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008087 valueof(ts_BSSMAP_Paging(imsi, cid_list, omit, bssmap_chneed))));
8088 BSSAP.send(paging);
8089
8090 /* Register any RSL conn so that the Paging Command gets received here. With the current RSL_Emulation's main()
8091 * handling of '[bts_role] IPA_PT.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD()))' it doesn't matter at all which
8092 * channel number is picked here. */
8093 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(0, RSL_CHAN_NR_INVALID));
8094 f_rslem_register(0, new_chan_nr);
8095 RSL.receive(tr_RSL_PAGING_CMD(tr_MI_IMSI(imsi)));
8096 f_rslem_unregister(0, new_chan_nr);
8097
8098 /* Despite the round robin pointing at the second MSC ('roundrobin next 1'), the earlier Paging for the same IMSI
8099 * causes this Paging Response to go to the first MSC (bssap_idx := 0). */
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02008100 f_perform_compl_l3(RSL, RSL_PROC, ts_PAG_RESP(valueof(ts_MI_IMSI_LV(imsi))) );
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008101 f_sleep(1.0);
8102}
8103testcase TC_mscpool_paging_and_response_imsi() runs on test_CT {
8104 f_init(nr_bts := 1, handler_mode := true, nr_msc := 3);
8105 f_sleep(1.0);
8106
8107 /* Testing a Paging on the first MSC to get a Paging Response back to the first MSC. Set round robin to the
8108 * second MSC to make sure we're getting the Paging logic, not a coincidental round robin match. */
8109 f_vty_transceive(BSCVTY, "mscpool roundrobin next 1");
8110
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008111 f_ctrs_msc_init();
8112
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008113 var MSC_ConnHdlr vc_conn1;
8114 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
8115 pars1.mscpool.rsl_idx := 0;
Neels Hofmeyr90f80962020-06-12 16:16:55 +02008116 pars1.sccp_addr_bsc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_peer;
8117 pars1.sccp_addr_msc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_own;
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008118 vc_conn1 := f_start_handler(refers(f_tc_mscpool_paging_imsi), pars1);
8119 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008120 f_ctrs_msc_expect(0, "mscpool:subscr:paged");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02008121 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008122}
8123
8124/* Make sure that whichever MSC paged a subscriber will also get the Paging Response. Page by TMSI with an NRI value
8125 * that matches a different MSC, to make sure the Paging->Response relation is stronger than the NRI->MSC mapping. */
8126private function f_tc_mscpool_paging_tmsi(charstring id) runs on MSC_ConnHdlr {
8127 var template BSSMAP_FIELD_CellIdentificationList cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(0) } };
8128 //cid_list := { cIl_allInBSS := ''O };
8129 var RSL_ChanNeeded rsl_chneed := RSL_CHANNEED_SDCCH;
8130 var template BSSMAP_IE_ChannelNeeded bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
8131 var integer nri_v := 300; /* <-- second MSC's NRI */
Harald Weltebf397612021-01-14 20:39:46 +01008132 var octetstring tmsi := f_gen_tmsi(suffix := 0, nri_v := nri_v);
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008133 var BSSAP_N_UNITDATA_req paging;
8134
8135 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
8136
Neels Hofmeyr90f80962020-06-12 16:16:55 +02008137 paging := valueof(ts_BSSAP_UNITDATA_req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008138 valueof(ts_BSSMAP_Paging('001010000000011'H, cid_list, tmsi, bssmap_chneed))));
8139 BSSAP.send(paging);
8140
8141 /* Register any RSL conn so that the Paging Command gets received here. With the current RSL_Emulation's main()
8142 * handling of '[bts_role] IPA_PT.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD()))' it doesn't matter at all which
8143 * channel number is picked here. */
8144 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(0, RSL_CHAN_NR_INVALID));
8145 f_rslem_register(0, new_chan_nr);
8146 RSL.receive(tr_RSL_PAGING_CMD(t_MI_TMSI(tmsi)));
8147 f_rslem_unregister(0, new_chan_nr);
8148
8149 /* Despite the NRI matching the second MSC (NRI from 'msc 1' in osmo-bsc.cfg) and round robin pointing at the
8150 * third MSC ('roundrobin next 2'), the earlier Paging for the same TMSI causes this Paging Response to go to
8151 * the first MSC (bssap_idx := 0). */
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02008152 f_perform_compl_l3(RSL, RSL_PROC, ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(nri_v))) );
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008153 f_sleep(1.0);
8154}
8155testcase TC_mscpool_paging_and_response_tmsi() runs on test_CT {
8156 f_init(nr_bts := 1, handler_mode := true, nr_msc := 3);
8157 f_sleep(1.0);
8158
8159 /* Testing a Paging on the first MSC to get a Paging Response back to the first MSC. Set round robin to the
8160 * third MSC to make sure we're getting the Paging logic, not a coincidental round robin match. */
8161 f_vty_transceive(BSCVTY, "mscpool roundrobin next 2");
8162
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008163 f_ctrs_msc_init();
8164
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008165 var MSC_ConnHdlr vc_conn1;
8166 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
8167 pars1.mscpool.rsl_idx := 0;
Neels Hofmeyr90f80962020-06-12 16:16:55 +02008168 pars1.sccp_addr_bsc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_peer;
8169 pars1.sccp_addr_msc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_own;
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008170 vc_conn1 := f_start_handler(refers(f_tc_mscpool_paging_tmsi), pars1);
8171 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008172 f_ctrs_msc_expect(0, "mscpool:subscr:paged");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02008173 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008174}
8175
8176/* For round-robin, skip an MSC that has 'no allow-attach' set. */
8177/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
8178 * just as well using only RSL. */
8179testcase TC_mscpool_no_allow_attach_round_robin() runs on test_CT {
8180
8181 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
8182 f_sleep(1.0);
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00008183 /* Mark the second MSC as offloading, round-robin should skip this MSC now. */
8184 f_vty_msc_allow_attach(BSCVTY, {true, false, true});
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008185
8186 /* Control which MSC gets chosen next by the round-robin, otherwise
8187 * would be randomly affected by which other tests ran before this. */
8188 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
8189
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008190 f_ctrs_msc_init();
8191
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008192 var MSC_ConnHdlr vc_conn1;
8193 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
8194 pars1.mscpool.rsl_idx := 0;
8195 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000001'H)), '00F110'O));
8196 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
8197 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008198 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008199
8200 var MSC_ConnHdlr vc_conn2;
8201 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 2);
8202 pars2.mscpool.rsl_idx := 1;
8203 pars2.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000002'H))));
8204 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
8205 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008206 f_ctrs_msc_expect(2, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008207
8208 var MSC_ConnHdlr vc_conn3;
8209 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
8210 pars3.mscpool.rsl_idx := 2;
8211 pars3.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010000000003'H))));
8212 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
8213 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008214 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02008215 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008216}
8217
8218/* An MSC that has 'no allow-attach' set should still serve subscribers that are already attached according to their
8219 * TMSI NRI. */
8220testcase TC_mscpool_no_allow_attach_valid_nri() runs on test_CT {
8221
8222 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
8223 f_sleep(1.0);
8224
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00008225 /* Mark the second MSC as offloading, round-robin should skip this MSC now. */
8226 f_vty_msc_allow_attach(BSCVTY, {true, false, true});
8227
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008228 /* Control which MSC gets chosen next by the round-robin, otherwise
8229 * would be randomly affected by which other tests ran before this. */
8230 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
8231
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008232 f_ctrs_msc_init();
8233
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008234 /* Round robin points at msc 0, but the valid NRI directs to msc 1, even though msc 1 has 'no allow-attach'. */
8235 var MSC_ConnHdlr vc_conn1;
8236 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 1);
8237 pars1.mscpool.rsl_idx := 0;
8238 /* An NRI of the second MSC's range (256-511) */
8239 pars1.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_TMSI_NRI_LV(260))));
8240 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
8241 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008242 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008243
8244 var MSC_ConnHdlr vc_conn2;
8245 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 0);
8246 pars2.mscpool.rsl_idx := 1;
8247 pars2.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000002'H))));
8248 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
8249 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008250 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008251
8252 var MSC_ConnHdlr vc_conn3;
8253 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 2);
8254 pars3.mscpool.rsl_idx := 2;
8255 pars3.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000003'H))));
8256 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
8257 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008258 f_ctrs_msc_expect(2, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02008259 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008260}
8261
Philipp Maier783681c2020-07-16 16:47:06 +02008262/* Allow/Deny emergency calls globally via VTY */
8263private function f_vty_allow_emerg_msc(boolean allow) runs on test_CT {
8264 f_vty_enter_cfg_msc(BSCVTY, 0);
8265 if (allow) {
8266 f_vty_transceive(BSCVTY, "allow-emergency allow");
8267 } else {
8268 f_vty_transceive(BSCVTY, "allow-emergency deny");
8269 }
8270 f_vty_transceive(BSCVTY, "exit");
8271 f_vty_transceive(BSCVTY, "exit");
8272}
8273
8274/* Allow/Deny emergency calls per BTS via VTY */
8275private function f_vty_allow_emerg_bts(boolean allow, integer bts_nr) runs on test_CT {
8276 f_vty_enter_cfg_bts(BSCVTY, bts_nr);
8277 if (allow) {
8278 f_vty_transceive(BSCVTY, "rach emergency call allowed 1");
8279 } else {
8280 f_vty_transceive(BSCVTY, "rach emergency call allowed 0");
8281 }
8282 f_vty_transceive(BSCVTY, "exit");
8283 f_vty_transceive(BSCVTY, "exit");
Neels Hofmeyrb6ed80c2020-10-12 22:52:39 +00008284 f_vty_transceive(BSCVTY, "exit");
Philipp Maier783681c2020-07-16 16:47:06 +02008285}
8286
Pau Espin Pedrol9ae36d52021-06-15 17:29:43 +02008287/* Allow/Forbid Fast Return after SRVCC on a given BTS via VTY */
8288private function f_vty_allow_srvcc_fast_return(boolean allow, integer bts_nr) runs on test_CT {
8289 f_vty_enter_cfg_bts(BSCVTY, bts_nr);
8290 if (allow) {
8291 f_vty_transceive(BSCVTY, "srvcc fast-return allow");
8292 } else {
8293 f_vty_transceive(BSCVTY, "srvcc fast-return forbid");
8294 }
8295 f_vty_transceive(BSCVTY, "exit");
8296 f_vty_transceive(BSCVTY, "exit");
8297 f_vty_transceive(BSCVTY, "exit");
8298}
8299
Pau Espin Pedrol14475352021-07-22 15:48:16 +02008300/* Allow/Forbid TCH for signalling if SDCCH exhausted on a given BTS via VTY */
8301private function f_vty_allow_tch_for_signalling(boolean allow, integer bts_nr) runs on test_CT {
8302 f_vty_enter_cfg_bts(BSCVTY, bts_nr);
8303 if (allow) {
8304 f_vty_transceive(BSCVTY, "channel allocator allow-tch-for-signalling 1");
8305 } else {
8306 f_vty_transceive(BSCVTY, "channel allocator allow-tch-for-signalling 0");
8307 }
8308 f_vty_transceive(BSCVTY, "exit");
8309 f_vty_transceive(BSCVTY, "exit");
8310 f_vty_transceive(BSCVTY, "exit");
8311}
8312
Philipp Maier783681c2020-07-16 16:47:06 +02008313/* Begin assignmet procedure and send an EMERGENCY SETUP (RR) */
8314private function f_assignment_emerg_setup() runs on MSC_ConnHdlr {
8315 var PDU_ML3_MS_NW emerg_setup;
8316 var octetstring emerg_setup_enc;
8317 var RSL_Message emerg_setup_data_ind;
8318
8319 f_establish_fully(omit, omit);
8320
8321 emerg_setup := valueof(ts_ML3_MO_CC_EMERG_SETUP(1, valueof(ts_Bcap_voice)));
8322 emerg_setup_enc := enc_PDU_ML3_MS_NW(emerg_setup);
8323 emerg_setup_data_ind := valueof(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), emerg_setup_enc));
8324
8325 RSL.send(emerg_setup_data_ind);
8326}
8327
8328/* Test if the EMERGENCY SETUP gets passed on to the MSC via A when EMERGENCY
8329 * CALLS are permitted by the BSC config. */
8330private function f_TC_assignment_emerg_setup_allow(charstring id) runs on MSC_ConnHdlr {
8331 var PDU_BSSAP emerg_setup_data_ind_bssap;
8332 var PDU_ML3_MS_NW emerg_setup;
8333 timer T := 3.0;
8334
8335 f_assignment_emerg_setup()
8336
8337 T.start;
8338 alt {
8339 [] BSSAP.receive(tr_BSSAP_DTAP) -> value emerg_setup_data_ind_bssap {
8340 emerg_setup := dec_PDU_ML3_MS_NW(emerg_setup_data_ind_bssap.pdu.dtap);
8341 if (not isbound(emerg_setup.msgs.cc.emergencySetup)) {
8342 setverdict(fail, "no emergency setup");
8343 }
8344 }
8345 [] BSSAP.receive {
8346 setverdict(fail, "unexpected BSSAP message!");
8347 }
8348 [] T.timeout {
8349 setverdict(fail, "timout waiting for EMERGENCY SETUP!");
8350 }
8351 }
8352
8353 setverdict(pass);
8354}
8355
8356/* Test if the EMERGENCY SETUP gets blocked by the BSC if EMERGENCY CALLS are
8357 * forbidden by the BSC config. */
8358private function f_TC_assignment_emerg_setup_deny(charstring id) runs on MSC_ConnHdlr {
8359 var PDU_BSSAP emerg_setup_data_ind_bssap;
8360 timer T := 3.0;
8361
8362 f_assignment_emerg_setup()
8363
8364 T.start;
8365 alt {
8366 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
8367 setverdict(pass);
8368 }
8369 [] RSL.receive {
8370 setverdict(fail, "unexpected RSL message!");
8371 }
8372 [] T.timeout {
8373 setverdict(fail, "timout waiting for RR CHANNEL RELEASE!");
8374 }
8375 }
8376}
8377
8378/* EMERGENCY CALL situation #1, allowed globally and by BTS */
8379testcase TC_assignment_emerg_setup_allow() runs on test_CT {
8380 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8381 var MSC_ConnHdlr vc_conn;
8382
8383 f_init(1, true);
8384 f_sleep(1.0);
8385
8386 f_vty_allow_emerg_msc(true);
8387 f_vty_allow_emerg_bts(true, 0);
8388 vc_conn := f_start_handler(refers(f_TC_assignment_emerg_setup_allow), pars);
8389 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02008390 f_shutdown_helper();
Philipp Maier783681c2020-07-16 16:47:06 +02008391}
8392
8393/* EMERGENCY CALL situation #2, forbidden globally but allowed by BTS */
8394testcase TC_assignment_emerg_setup_deny_msc() runs on test_CT {
8395 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8396 var MSC_ConnHdlr vc_conn;
8397
8398 f_init(1, true);
8399 f_sleep(1.0);
8400
8401 f_vty_allow_emerg_msc(false);
8402 f_vty_allow_emerg_bts(true, 0);
8403 vc_conn := f_start_handler(refers(f_TC_assignment_emerg_setup_deny), pars);
8404 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02008405 f_shutdown_helper();
Philipp Maier783681c2020-07-16 16:47:06 +02008406}
8407
8408/* EMERGENCY CALL situation #3, allowed globally but forbidden by BTS */
8409testcase TC_assignment_emerg_setup_deny_bts() runs on test_CT {
8410 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8411 var MSC_ConnHdlr vc_conn;
8412
8413 /* Note: This simulates a spec violation by the MS, correct MS
8414 * implementations would not try to establish an emergency call because
8415 * the system information tells in advance that emergency calls are
8416 * not forbidden */
8417
8418 f_init(1, true);
8419 f_sleep(1.0);
8420
8421 f_vty_allow_emerg_msc(true);
8422 f_vty_allow_emerg_bts(false, 0);
8423 vc_conn := f_start_handler(refers(f_TC_assignment_emerg_setup_deny), pars);
8424 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02008425 f_shutdown_helper();
Philipp Maier783681c2020-07-16 16:47:06 +02008426}
8427
Philipp Maier82812002020-08-13 18:48:27 +02008428/* Test what happens when an emergency call arrives while all TCH channels are
8429 * busy, the BSC is expected to terminate one call in favor of the incoming
8430 * emergency call */
8431testcase TC_emerg_premption() runs on test_CT {
8432 var ASP_RSL_Unitdata rsl_ud;
8433 var integer i;
8434 var integer chreq_total, chreq_nochan;
8435 var RSL_Message rx_rsl;
8436 var RslChannelNr chan_nr;
8437
8438 f_init(1);
8439 f_sleep(1.0);
8440
8441 f_vty_allow_emerg_msc(true);
8442 f_vty_allow_emerg_bts(true, 0);
8443
8444 /* Fill up all channels on the BTS */
8445 chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total");
8446 chreq_nochan := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel");
8447 for (i := 0; i < NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS; i := i+1) {
8448 chan_nr := f_chreq_act_ack('33'O, i);
8449 }
8450 IPA_RSL[0].clear;
8451 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total",
8452 chreq_total + NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS);
8453
8454 /* Send Channel request for emegergency call */
8455 f_ipa_tx(0, ts_RSL_CHAN_RQD('A5'O, 23));
8456
8457 /* Expect the BSC to release one (the first) TCH/F on the BTS */
8458 chan_nr := valueof(t_RslChanNr_Bm(1));
8459 f_expect_chan_rel(0, chan_nr, expect_rr_chan_rel := false, expect_rll_rel_req := false);
8460
8461 /* Expect the BSC to send activate/assign the a channel for the emergency call */
8462 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
8463 chan_nr := rx_rsl.ies[0].body.chan_nr;
8464 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 33));
8465 rx_rsl := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
Philipp Maier104f4c02020-09-11 18:12:18 +02008466
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02008467 f_shutdown_helper();
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008468}
8469
8470/* Hopping parameters per a timeslot */
Vadim Yanitskiybc6654a2020-09-13 01:27:40 +07008471private type record length(0..64) of GsmArfcn ArfcnList;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008472private type record FHParamsTs {
8473 boolean enabled,
8474 uint6_t hsn,
8475 uint6_t maio,
8476 ArfcnList ma
8477};
8478
8479/* Hopping parameters per a transceiver */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008480private type record FHParamsTrx {
Philipp Maier798d8952021-10-19 14:43:19 +02008481 GsmBandArfcn arfcn,
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008482 FHParamsTs ts[8]
8483};
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008484
8485/* Randomly generate the hopping parameters for the given timeslot numbers */
8486private function f_TC_fh_params_gen(template integer tr_tn := (1, 3, 5))
8487runs on test_CT return FHParamsTrx {
8488 var FHParamsTrx fhp;
8489
Philipp Maier798d8952021-10-19 14:43:19 +02008490 /* Generate a random ARFCN in the range of 0 - 3. This ARFCN will
8491 * fall in the GSM900 band. */
8492 fhp.arfcn.arfcn := f_rnd_int(3);
8493 fhp.arfcn.pcs := false;
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07008494
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008495 for (var integer tn := 0; tn < 8; tn := tn + 1) {
8496 if (not match(tn, tr_tn)) {
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008497 fhp.ts[tn].enabled := false;
8498 fhp.ts[tn].ma := { };
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008499 continue;
8500 }
8501
8502 /* Random HSN / MAIO values: 0..63 */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008503 fhp.ts[tn].hsn := f_rnd_int(64);
8504 fhp.ts[tn].maio := f_rnd_int(64);
8505 fhp.ts[tn].ma := { };
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008506
8507 /* Random Mobile Allocation (hopping channels) */
8508 var integer ma_len := 2 + f_rnd_int(9); /* 2..10 channels */
8509 var integer step := 3 + f_rnd_int(4); /* 3..6 stepping */
8510 for (var integer i := 1; i <= ma_len; i := i + 1) {
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008511 fhp.ts[tn].ma := fhp.ts[tn].ma & { i * step };
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008512 }
8513
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008514 fhp.ts[tn].enabled := true;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008515 }
8516
8517 log("f_TC_fh_params_gen(): ", fhp);
8518 return fhp;
8519}
8520
8521/* Make sure that the given Channel Description IE matches the hopping configuration */
8522private function f_TC_fh_params_match_chan_desc(in FHParamsTrx fhp, in ChannelDescription cd)
8523{
8524 var template (present) ChannelDescription tr_cd;
8525 var template (present) MaioHsn tr_maio_hsn;
8526 var uint3_t tn := cd.chan_nr.tn;
8527
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008528 if (fhp.ts[tn].enabled) {
8529 tr_maio_hsn := tr_HsnMaio(fhp.ts[tn].hsn, fhp.ts[tn].maio);
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008530 tr_cd := tr_ChanDescH1(cd.chan_nr, tr_maio_hsn);
8531 } else {
Philipp Maier798d8952021-10-19 14:43:19 +02008532 tr_cd := tr_ChanDescH0(cd.chan_nr, fhp.arfcn.arfcn);
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008533 }
8534
8535 if (not match(cd, tr_cd)) {
8536 setverdict(fail, "Channel Description IE does not match: ",
8537 cd, " vs expected ", tr_cd);
8538 }
8539}
8540
8541/* Make sure that the given Mobile Allocation IE matches the hopping configuration */
8542private function f_TC_fh_params_match_ma(in FHParamsTrx fhp, uint3_t tn,
8543 in MobileAllocationLV ma)
8544{
8545 var template MobileAllocationLV tr_ma := f_TC_fh_params_gen_tr_ma(fhp, tn, ma);
8546
8547 if (not match(ma, tr_ma)) {
8548 setverdict(fail, "Mobile Allocation IE does not match (tn := ",
8549 tn, "): ", ma, " vs expected: ", tr_ma);
8550 } else {
8551 setverdict(pass);
8552 }
8553}
8554
8555private function f_TC_fh_params_gen_tr_ma(in FHParamsTrx fhp, uint3_t tn,
8556 in MobileAllocationLV ma)
8557return template MobileAllocationLV {
8558 /* Mobile Allocation IE is expected to be empty if hopping is not enabled */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008559 if (not fhp.ts[tn].enabled) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008560 return { len := 0, ma := ''B };
8561 }
8562
8563 var bitstring full_mask := f_pad_bit(''B, 1024, '0'B);
8564 var bitstring slot_mask := f_pad_bit(''B, 1024, '0'B);
8565 var bitstring ma_mask := ''B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008566
8567 /* Compose the full bit-mask (all channels, up to 1024 entries) */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008568 for (var integer i := 0; i < lengthof(fhp.ts); i := i + 1) {
8569 for (var integer j := 0; j < lengthof(fhp.ts[i].ma); j := j + 1) {
8570 if (full_mask[fhp.ts[i].ma[j]] == '1'B)
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008571 { continue; }
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008572 full_mask[fhp.ts[i].ma[j]] := '1'B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008573 }
8574 }
8575
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07008576 /* Take ARFCN of the TRX itself into account */
Philipp Maier798d8952021-10-19 14:43:19 +02008577 full_mask[fhp.arfcn.arfcn] := '1'B;
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07008578
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008579 /* Compose a bit-mask for the given timeslot number */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008580 for (var integer i := 0; i < lengthof(fhp.ts[tn].ma); i := i + 1) {
8581 slot_mask[fhp.ts[tn].ma[i]] := '1'B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008582 }
8583
8584 /* Finally, compose the Mobile Allocation bit-mask */
Vadim Yanitskiy3e997362020-09-05 21:08:34 +07008585 for (var integer i := 1; i < lengthof(full_mask); i := i + 1) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008586 if (full_mask[i] != '1'B)
8587 { continue; }
8588
8589 /* FIXME: ma_mask := ma_mask & slot_mask[i]; // triggers a bug in TITAN */
8590 if (slot_mask[i] == '1'B) {
8591 ma_mask := ma_mask & '1'B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008592 } else {
8593 ma_mask := ma_mask & '0'B;
8594 }
8595 }
8596
Vadim Yanitskiy3e997362020-09-05 21:08:34 +07008597 /* ARFCN 0 (if present) goes to the last position of the bit-mask */
8598 if (full_mask[0] == '1'B) {
8599 /* FIXME: ma_mask := ma_mask & slot_mask[0]; // triggers a bug in TITAN */
8600 if (slot_mask[0] == '1'B) {
8601 ma_mask := ma_mask & '1'B;
8602 } else {
8603 ma_mask := ma_mask & '0'B;
8604 }
8605 }
8606
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008607 /* Ensure that ma_mask is octet-aligned */
Vadim Yanitskiy2aa02522020-09-06 14:05:23 +07008608 var integer ma_mask_len := (lengthof(ma_mask) + 8 - 1) / 8;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008609 ma_mask := f_pad_bit(ma_mask, ma_mask_len * 8, '0'B);
8610
8611 return { len := ma_mask_len, ma := ma_mask };
8612}
8613
Philipp Maier798d8952021-10-19 14:43:19 +02008614/* Configure the appropriate band for a given arfcn, exc */
8615private function f_TC_set_band_by_arfcn(integer bts_nr, GsmBandArfcn arfcn) runs on test_CT
8616{
8617 var charstring band;
8618 var GsmBandArfcn arfcn_ := valueof(ts_GsmBandArfcn(arfcn.arfcn, arfcn.pcs, false));
8619
8620 select (arfcn_) {
8621 case (tr_GsmBandArfcn((259..293), false, ?)) { band := "GSM450"; }
8622 case (tr_GsmBandArfcn((306..340), false, ?)) { band := "GSM480"; }
8623 case (tr_GsmBandArfcn((438..511), false, ?)) { band := "GSM750"; }
8624 case (tr_GsmBandArfcn((128..251), false, ?)) { band := "GSM850"; }
8625 case (tr_GsmBandArfcn((0..124), false, ?)) { band := "GSM900"; }
8626 case (tr_GsmBandArfcn((955..1023), false, ?)) { band := "GSM900"; }
8627 case (tr_GsmBandArfcn((512..885), false, ?)) { band := "DCS1800"; }
8628 case (tr_GsmBandArfcn((512..810), true, ?)) { band := "PCS1900"; }
8629 case else { return; }
8630 }
8631
8632 f_vty_enter_cfg_bts(BSCVTY, bts_nr);
8633 f_vty_transceive(BSCVTY, "band " & band);
8634 f_vty_transceive(BSCVTY, "end");
8635}
8636
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008637/* Configure the hopping parameters in accordance with the given record */
8638private function f_TC_fh_params_set(in FHParamsTrx fhp,
8639 uint8_t bts_nr := 0,
8640 uint8_t trx_nr := 0)
8641runs on test_CT {
Philipp Maier798d8952021-10-19 14:43:19 +02008642
8643 f_TC_set_band_by_arfcn(bts_nr, fhp.arfcn);
8644
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008645 /* Enter the configuration node for the given BTS/TRX numbers */
8646 f_vty_enter_cfg_trx(BSCVTY, bts_nr, trx_nr);
8647
Philipp Maier798d8952021-10-19 14:43:19 +02008648 f_vty_transceive(BSCVTY, "arfcn " & int2str(fhp.arfcn.arfcn));
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07008649
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008650 for (var integer tn := 0; tn < lengthof(fhp.ts); tn := tn + 1) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008651 f_vty_transceive(BSCVTY, "timeslot " & int2str(tn));
8652
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008653 if (not fhp.ts[tn].enabled) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008654 f_vty_transceive(BSCVTY, "hopping enabled 0");
8655 f_vty_transceive(BSCVTY, "exit"); /* go back */
8656 continue;
8657 }
8658
8659 /* Configure HSN / MAIO values */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008660 f_vty_transceive(BSCVTY, "hopping sequence-number " & int2str(fhp.ts[tn].hsn));
8661 f_vty_transceive(BSCVTY, "hopping maio " & int2str(fhp.ts[tn].maio));
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008662
8663 /* Configure the Mobile Allocation (hopping channels) */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008664 for (var integer i := 0; i < lengthof(fhp.ts[tn].ma); i := i + 1) {
8665 f_vty_transceive(BSCVTY, "hopping arfcn add " & int2str(fhp.ts[tn].ma[i]));
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008666 }
8667
8668 f_vty_transceive(BSCVTY, "hopping enabled 1");
8669 f_vty_transceive(BSCVTY, "exit"); /* go back */
8670 }
8671
8672 f_vty_transceive(BSCVTY, "end");
8673}
8674
8675/* Disable frequency hopping on all timeslots */
8676private function f_TC_fh_params_unset(in FHParamsTrx fhp,
8677 uint8_t bts_nr := 0,
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07008678 uint8_t trx_nr := 0,
Philipp Maier798d8952021-10-19 14:43:19 +02008679 GsmBandArfcn arfcn := {pcs := false, arfcn := 871})
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008680runs on test_CT {
Philipp Maier798d8952021-10-19 14:43:19 +02008681
8682 f_TC_set_band_by_arfcn(bts_nr, arfcn);
8683
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008684 /* Enter the configuration node for the given BTS/TRX numbers */
8685 f_vty_enter_cfg_trx(BSCVTY, bts_nr, trx_nr);
8686
Philipp Maier798d8952021-10-19 14:43:19 +02008687 f_vty_transceive(BSCVTY, "arfcn " & int2str(arfcn.arfcn));
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07008688
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008689 for (var integer tn := 0; tn < lengthof(fhp.ts); tn := tn + 1) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008690 f_vty_transceive(BSCVTY, "timeslot " & int2str(tn));
8691
8692 /* Delete all ARFCNs from the Mobile Allocation (if any) */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008693 for (var integer i := 0; i < lengthof(fhp.ts[tn].ma); i := i + 1) {
8694 f_vty_transceive(BSCVTY, "hopping arfcn del " & int2str(fhp.ts[tn].ma[i]));
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008695 }
8696
8697 f_vty_transceive(BSCVTY, "hopping enabled 0");
8698 f_vty_transceive(BSCVTY, "exit"); /* go back */
8699 }
8700
8701 f_vty_transceive(BSCVTY, "end");
8702 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
8703}
8704
8705/* Verify presence and correctness of the hopping parameters (HSN, MAIO)
8706 * in the Channel Identification IE of the RSL CHANnel ACTIVation message. */
8707testcase TC_fh_params_chan_activ() runs on test_CT {
8708 var FHParamsTrx fhp := f_TC_fh_params_gen();
8709 var RSL_Message rsl_msg;
8710 var RSL_IE_Body ie;
8711
8712 f_init_vty();
8713
8714 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
8715 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
8716
8717 f_init(1);
8718
8719 /* CS domain: 3 (SDCCH/4+CBCH) + 4 (TCH/F) + 2 (TCH/H) channels available */
8720 for (var integer i := 0; i < 9; i := i + 1) {
8721 f_ipa_tx(0, ts_RSL_CHAN_RQD(f_rnd_ra_cs(), 23));
8722 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
8723
8724 /* Make sure that Channel Identification IE is present */
8725 if (not f_rsl_find_ie(rsl_msg, RSL_IE_CHAN_IDENT, ie)) {
8726 setverdict(fail, "RSL Channel Identification IE is absent");
8727 continue;
8728 }
8729
8730 /* Make sure that hopping parameters (HSN/MAIO) match */
8731 f_TC_fh_params_match_chan_desc(fhp, ie.chan_ident.ch_desc.v);
8732
8733 /* "Mobile Allocation shall be included but empty" - let's check this */
8734 if (ie.chan_ident.ma.v.len != 0) {
8735 setverdict(fail, "Mobile Allocation IE is not empty: ",
8736 ie.chan_ident.ma, ", despite it shall be");
8737 continue;
8738 }
8739 }
8740
8741 /* Disable frequency hopping */
8742 f_TC_fh_params_unset(fhp);
8743
Vadim Yanitskiy21726312020-09-04 01:45:36 +07008744 f_shutdown_helper();
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008745}
8746
8747/* Verify the hopping parameters (HSN, MAIO, MA) in (RR) Immediate Assignment */
8748testcase TC_fh_params_imm_ass() runs on test_CT {
8749 var FHParamsTrx fhp := f_TC_fh_params_gen();
8750 var RSL_Message rsl_msg;
8751 var RSL_IE_Body ie;
8752
8753 f_init_vty();
8754
8755 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
8756 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
8757
8758 f_init(1);
8759
8760 /* CS domain: 3 (SDCCH/4+CBCH) + 4 (TCH/F) + 2 (TCH/H) channels available */
8761 for (var integer i := 0; i < 9; i := i + 1) {
8762 f_ipa_tx(0, ts_RSL_CHAN_RQD(f_rnd_ra_cs(), 23));
8763 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
8764
8765 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(rsl_msg.ies[0].body.chan_nr, 33));
8766 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeC(RSL_MT_IMMEDIATE_ASSIGN_CMD));
8767
8768 /* Make sure that Full Immediate Assign Info IE is present */
8769 if (not f_rsl_find_ie(rsl_msg, RSL_IE_FULL_IMM_ASS_INFO, ie)) {
8770 setverdict(fail, "RSL Full Immediate Assign Info IE is absent");
8771 continue;
8772 }
8773
8774 /* Decode the actual Immediate Assignment message */
8775 var GsmRrMessage rr_msg := dec_GsmRrMessage(ie.full_imm_ass_info.payload);
8776 if (not match(rr_msg.header, t_RrHeader(IMMEDIATE_ASSIGNMENT, ?))) {
8777 setverdict(fail, "Failed to match Immediate Assignment: ", rr_msg);
8778 continue;
8779 }
8780
8781 /* Make sure that hopping parameters (HSN/MAIO) match */
8782 f_TC_fh_params_match_chan_desc(fhp, rr_msg.payload.imm_ass.chan_desc);
8783
8784 /* Make sure that the Mobile Allocation IE matches */
8785 f_TC_fh_params_match_ma(fhp, rr_msg.payload.imm_ass.chan_desc.chan_nr.tn,
8786 rr_msg.payload.imm_ass.mobile_allocation);
8787 }
8788
8789 /* Disable frequency hopping */
8790 f_TC_fh_params_unset(fhp);
Philipp Maier82812002020-08-13 18:48:27 +02008791
Vadim Yanitskiy21726312020-09-04 01:45:36 +07008792 f_shutdown_helper();
Philipp Maier82812002020-08-13 18:48:27 +02008793}
8794
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07008795/* Verify the hopping parameters (HSN, MAIO, MA) in (RR) Assignment Command */
8796testcase TC_fh_params_assignment_cmd() runs on test_CT {
8797 var FHParamsTrx fhp := f_TC_fh_params_gen();
8798 var RSL_Message rsl_msg;
8799 var RSL_IE_Body ie;
8800
8801 f_init_vty();
8802
8803 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
8804 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
8805
8806 f_init(1);
8807
8808 /* HACK: work around "Couldn't find Expect for CRCX" */
8809 vc_MGCP.stop;
8810
8811 var template PDU_BSSAP ass_cmd := f_gen_ass_req();
8812 ass_cmd.pdu.bssmap.assignmentRequest.codecList := ts_BSSMAP_IE_CodecList({ts_CodecFR});
8813
8814 /* CS domain (TCH): 4 (TCH/F) + 2 (TCH/H) channels available
8815 * NOTE: only 3 SDCCH/4 channels are available on CCCH+SDCCH4+CBCH */
8816 for (var integer i := 0; i < 3; i := i + 1) {
8817 /* Establish a dedicated channel, so we can trigger (late) TCH assignment */
8818 var DchanTuple dt := f_est_dchan(f_rnd_ra_cs(), 23, f_rnd_octstring(16));
8819
8820 /* Send a BSSMAP Assignment Command, expect CHANnel ACTIVation */
8821 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ass_cmd));
8822 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
8823
8824 /* ACKnowledge CHANnel ACTIVation, expect RSL DATA REQuest */
8825 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(rsl_msg.ies[0].body.chan_nr, 33));
8826 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeR(RSL_MT_DATA_REQ));
8827
8828 /* Make sure that L3 Information IE is present */
8829 if (not f_rsl_find_ie(rsl_msg, RSL_IE_L3_INFO, ie)) {
8830 setverdict(fail, "RSL L3 Information IE is absent");
8831 continue;
8832 }
8833
8834 /* Decode the L3 message and make sure it is (RR) Assignment Command */
8835 var GsmRrL3Message l3_msg := dec_GsmRrL3Message(ie.l3_info.payload);
8836 if (not match(l3_msg.header, t_RrL3Header(ASSIGNMENT_COMMAND))) {
8837 setverdict(fail, "Failed to match Assignment Command: ", l3_msg);
8838 continue;
8839 }
8840
8841 /* Make sure that hopping parameters (HSN/MAIO) match */
8842 var ChannelDescription chan_desc := l3_msg.payload.ass_cmd.chan_desc;
8843 f_TC_fh_params_match_chan_desc(fhp, chan_desc);
8844
8845 /* Make sure that Cell Channel Description IE is present if FH is enabled */
8846 if (chan_desc.h and not ispresent(l3_msg.payload.ass_cmd.cell_chan_desc)) {
Vadim Yanitskiy38d069d2020-09-02 17:18:57 +07008847 setverdict(fail, "FH enabled, but Cell Channel Description IE is absent");
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07008848 continue;
8849 }
8850
8851 /* Make sure that the Mobile Allocation IE matches (if present) */
8852 var boolean ma_present := ispresent(l3_msg.payload.ass_cmd.mobile_allocation);
8853 if (chan_desc.h and ma_present) {
8854 f_TC_fh_params_match_ma(fhp, chan_desc.chan_nr.tn,
8855 l3_msg.payload.ass_cmd.mobile_allocation.v);
8856 } else if (chan_desc.h and not ma_present) {
8857 setverdict(fail, "FH enabled, but Mobile Allocation IE is absent");
8858 continue;
8859 } else if (not chan_desc.h and ma_present) {
8860 setverdict(fail, "FH disabled, but Mobile Allocation IE is present");
8861 continue;
8862 }
8863 }
8864
8865 /* Give the IUT some time to release all channels */
8866 f_sleep(3.0);
8867
8868 /* Disable frequency hopping */
8869 f_TC_fh_params_unset(fhp);
8870
Vadim Yanitskiy21726312020-09-04 01:45:36 +07008871 f_shutdown_helper();
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07008872}
8873
Vadim Yanitskiy8f5430d2020-09-02 18:51:38 +07008874/* Verify the hopping parameters (HSN, MAIO, MA) in (RR) Handover Command */
8875private function f_TC_fh_params_handover_cmd(in FHParamsTrx fhp)
8876runs on test_CT {
8877 var RSL_Message rsl_msg;
8878 var RSL_IE_Body ie;
8879 var DchanTuple dt;
8880
8881 /* Establish a dedicated channel, so we can trigger handover */
8882 dt := f_est_dchan(f_rnd_ra_cs(), 23, f_rnd_octstring(16));
8883
8884 /* Trigger handover from BTS0 to BTS1 */
8885 f_bts_0_cfg(BSCVTY, { "neighbor bts 1" });
8886 f_vty_handover(BSCVTY, 0, 0, dt.rsl_chan_nr, 1);
8887
8888 /* Expect RSL CHANnel ACTIVation on BTS1/TRX0/TS1 */
8889 rsl_msg := f_exp_ipa_rx(1, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
8890
8891 /* ACKnowledge channel activation and expect (RR) Handover Command */
8892 f_ipa_tx(1, ts_RSL_CHAN_ACT_ACK(rsl_msg.ies[0].body.chan_nr, 33));
8893 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeR(RSL_MT_DATA_REQ));
8894
8895 /* Make sure that L3 Information IE is present */
8896 if (not f_rsl_find_ie(rsl_msg, RSL_IE_L3_INFO, ie)) {
8897 setverdict(fail, "RSL L3 Information IE is absent");
8898 return;
8899 }
8900
8901 /* Decode the L3 message and make sure it is (RR) Handover Command */
8902 var GsmRrL3Message l3_msg := dec_GsmRrL3Message(ie.l3_info.payload);
8903 if (not match(l3_msg.header, t_RrL3Header(HANDOVER_COMMAND))) {
8904 setverdict(fail, "Failed to match Handover Command: ", l3_msg);
8905 return;
8906 }
8907
8908 /* Make sure that we've got SDCCH/8 on TS1 (expected to be hopping) */
8909 var ChannelDescription chan_desc := l3_msg.payload.ho_cmd.chan_desc;
8910 if (not match(chan_desc.chan_nr, t_RslChanNr_SDCCH8(1, ?))) {
8911 setverdict(fail, "Unexpected channel number: ", chan_desc.chan_nr);
8912 return;
8913 }
8914
8915 /* Make sure that hopping parameters (HSN/MAIO) match */
8916 f_TC_fh_params_match_chan_desc(fhp, chan_desc);
8917
8918 /* Make sure that Cell Channel Description IE is present */
8919 if (not ispresent(l3_msg.payload.ho_cmd.cell_chan_desc)) {
8920 setverdict(fail, "FH enabled, but Cell Channel Description IE is absent");
8921 return;
8922 }
8923
8924 /* Make sure that the Mobile Allocation (after time) IE is present and matches */
8925 var boolean ma_present := ispresent(l3_msg.payload.ho_cmd.mobile_allocation);
8926 if (ma_present) {
8927 f_TC_fh_params_match_ma(fhp, chan_desc.chan_nr.tn,
8928 l3_msg.payload.ho_cmd.mobile_allocation.v);
8929 } else {
8930 setverdict(fail, "FH enabled, but Mobile Allocation IE is absent");
8931 return;
8932 }
8933}
8934testcase TC_fh_params_handover_cmd() runs on test_CT {
8935 var FHParamsTrx fhp := f_TC_fh_params_gen();
8936
8937 f_init_vty();
8938
8939 /* (Re)configure TS0 as BCCH and TS1 as SDCCH8 on BTS1/TRX0 */
8940 f_vty_enter_cfg_trx(BSCVTY, bts := 1, trx := 0);
8941
8942 f_vty_transceive(BSCVTY, "timeslot 0");
8943 f_vty_transceive(BSCVTY, "phys_chan_config ccch");
8944 f_vty_transceive(BSCVTY, "exit"); /* go back */
8945
8946 f_vty_transceive(BSCVTY, "timeslot 1");
8947 f_vty_transceive(BSCVTY, "phys_chan_config sdcch8");
8948 f_vty_transceive(BSCVTY, "end"); /* we're done */
8949
8950 f_TC_fh_params_set(fhp, 1); /* Enable frequency hopping on BTS1 */
8951 f_vty_transceive(BSCVTY, "drop bts connection 1 oml");
8952
8953 f_init(2);
8954
8955 f_TC_fh_params_handover_cmd(fhp);
8956
8957 /* Disable frequency hopping on BTS1 */
8958 f_TC_fh_params_unset(fhp, 1);
8959
8960 /* (Re)configure TS0 as CCCH+SDCCH4+CBCH and TS1 as TCH/F */
8961 f_vty_enter_cfg_trx(BSCVTY, bts := 1, trx := 0);
8962
8963 f_vty_transceive(BSCVTY, "timeslot 0");
8964 f_vty_transceive(BSCVTY, "phys_chan_config ccch+sdcch4+cbch");
8965 f_vty_transceive(BSCVTY, "exit"); /* go back */
8966
8967 f_vty_transceive(BSCVTY, "timeslot 1");
8968 f_vty_transceive(BSCVTY, "phys_chan_config tch/f");
8969 f_vty_transceive(BSCVTY, "end"); /* we're done */
8970
8971 f_shutdown_helper();
8972}
8973
Vadim Yanitskiyca974032020-09-01 07:20:39 +07008974/* Verify the hopping parameters in System Information Type 4 */
8975testcase TC_fh_params_si4_cbch() runs on test_CT {
8976 var FHParamsTrx fhp := f_TC_fh_params_gen(tr_tn := 1);
8977 var ASP_RSL_Unitdata rx_rsl_ud;
8978 timer T := 5.0;
8979
8980 f_init_vty();
8981
8982 /* (Re)configure TS0 as BCCH and TS1 as SDCCH8+CBCH */
8983 f_vty_enter_cfg_trx(BSCVTY, trx := 0);
8984
8985 f_vty_transceive(BSCVTY, "timeslot 0");
8986 f_vty_transceive(BSCVTY, "phys_chan_config ccch");
8987 f_vty_transceive(BSCVTY, "exit"); /* go back */
8988
8989 f_vty_transceive(BSCVTY, "timeslot 1");
8990 f_vty_transceive(BSCVTY, "phys_chan_config sdcch8+cbch");
8991 f_vty_transceive(BSCVTY, "end"); /* we're done */
8992
8993 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
8994 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
8995
8996 f_init(1);
8997
8998 T.start;
8999 alt {
9000 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_BCCH_INFO(RSL_SYSTEM_INFO_4))) -> value rx_rsl_ud {
9001 var RSL_IE_Body ie := rx_rsl_ud.rsl.ies[2].body; /* FULL BCCH Information IE */
9002 var SystemInformation si := dec_SystemInformation(ie.other.payload);
9003
9004 /* Make sure that what we decoded is System Information Type 4 */
9005 if (si.header.message_type != SYSTEM_INFORMATION_TYPE_4) {
9006 setverdict(fail, "RSL FULL BCCH Information IE contains: ", si);
9007 repeat;
9008 }
9009
9010 /* Make sure that CBCH Channel Description IE is present */
9011 if (not ispresent(si.payload.si4.cbch_chan_desc)) {
9012 setverdict(fail, "CBCH Channel Description IE is absent");
9013 break;
9014 }
9015
9016 /* Finally, check the hopping parameters (HSN, MAIO) */
9017 var ChannelDescription chan_desc := si.payload.si4.cbch_chan_desc.v;
9018 f_TC_fh_params_match_chan_desc(fhp, chan_desc);
9019
9020 /* 3GPP TS 44.018, section 9.1.36.2 "CBCH Mobile Allocation":
9021 * The CBCH Mobile Allocation IE *shall* be present if FH is enabled. */
9022 if (chan_desc.h and not ispresent(si.payload.si4.cbch_mobile_alloc)) {
9023 setverdict(fail, "FH enabled, but Mobile Allocation IE is absent");
9024 break;
9025 } else if (chan_desc.h and ispresent(si.payload.si4.cbch_mobile_alloc)) {
9026 f_TC_fh_params_match_ma(fhp, chan_desc.chan_nr.tn,
9027 si.payload.si4.cbch_mobile_alloc.v);
9028 }
9029 }
9030 [] IPA_RSL[0].receive { repeat; }
9031 [] T.timeout {
9032 setverdict(fail, "Timeout waiting for RSL BCCH INFOrmation (SI4)");
9033 }
9034 }
9035
9036 /* Disable frequency hopping */
9037 f_TC_fh_params_unset(fhp);
9038
Vadim Yanitskiy8bc46012020-09-06 12:38:01 +07009039 /* (Re)configure TS0 as CCCH+SDCCH4+CBCH and TS1 as TCH/F */
Vadim Yanitskiyca974032020-09-01 07:20:39 +07009040 f_vty_enter_cfg_trx(BSCVTY, trx := 0);
9041
9042 f_vty_transceive(BSCVTY, "timeslot 0");
Vadim Yanitskiy8bc46012020-09-06 12:38:01 +07009043 f_vty_transceive(BSCVTY, "phys_chan_config ccch+sdcch4+cbch");
Vadim Yanitskiyca974032020-09-01 07:20:39 +07009044 f_vty_transceive(BSCVTY, "exit"); /* go back */
9045
9046 f_vty_transceive(BSCVTY, "timeslot 1");
9047 f_vty_transceive(BSCVTY, "phys_chan_config tch/f");
9048 f_vty_transceive(BSCVTY, "end"); /* we're done */
9049
Vadim Yanitskiy21726312020-09-04 01:45:36 +07009050 f_shutdown_helper();
Vadim Yanitskiyca974032020-09-01 07:20:39 +07009051}
9052
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02009053template (value) PDU_BSSAP_LE ts_BSSMAP_LE_BSSLAP(template (value) BSSLAP_PDU bsslap)
9054 := ts_BSSMAP_LE_ConnInfo(BSSMAP_LE_PROT_BSSLAP, data := enc_BSSLAP_PDU(valueof(bsslap)));
9055
9056private function f_match_bsslap(PDU_BSSAP_LE got_bsslap_msg,
9057 template (present) BSSLAP_PDU expect_bsslap)
9058{
9059 var BSSLAP_PDU bsslap := dec_BSSLAP_PDU(got_bsslap_msg.pdu.bssmap.co_info.bsslap_apdu.data);
9060 if (not match(bsslap, expect_bsslap)) {
9061 log("EXPECTING BSSLAP: ", expect_bsslap);
9062 log("GOT BSSLAP: ", bsslap);
9063 setverdict(fail, "BSSLAP is not as expected");
9064 mtc.stop;
9065 }
9066 setverdict(pass);
9067}
9068
9069/* GAD: this is an Ellipsoid point with uncertainty circle, encoded as in 3GPP TS 23.032 §7.3.2. */
9070const octetstring gad_ell_point_unc_circle := '10b0646d0d5f6627'O;
9071
9072private function f_expect_bsslap(template (present) BSSLAP_PDU expect_rx_bsslap) runs on MSC_ConnHdlr {
9073 var PDU_BSSAP_LE rx_bsslap;
9074 BSSAP_LE.receive(tr_BSSMAP_LE_ConnInfo(BSSMAP_LE_PROT_BSSLAP, ?)) -> value(rx_bsslap);
9075 f_match_bsslap(rx_bsslap, expect_rx_bsslap);
9076}
9077
9078/* With an active lchan, start BSSMAP Perform Location Request on A interface, starting BSSMAP-LE Perform Location
9079 * Request on Lb interface. Either with or without the SMLC doing a BSSLAP TA Request. */
9080private function f_lcs_loc_req_for_active_ms(boolean do_ta_request := false) runs on MSC_ConnHdlr {
9081 f_sleep(1.0);
9082
9083 f_establish_fully(omit, omit);
9084 f_bssap_le_register_imsi(g_pars.imsi, omit);
9085
9086 BSSAP.send(valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
9087 ts_CellId_CGI('262'H, '42'H, 23, 42))));
9088
9089 var PDU_BSSAP_LE plr;
9090 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
9091
9092 if (not do_ta_request) {
9093 /* verify TA Layer 3 in APDU. First the APDU type (BSSLAP), then the BSSLAP data contents. */
9094 var template BSSMAP_LE_IE_APDU expect_apdu := tr_BSSMAP_LE_APDU(BSSMAP_LE_PROT_BSSLAP, ?);
9095 if (not match(plr.pdu.bssmap.perf_loc_req.bsslap_apdu, expect_apdu)) {
9096 log("EXPECTING BSSMAP-LE APDU IE ", expect_apdu);
9097 log("GOT BSSMAP-LE APDU IE ", plr.pdu.bssmap.perf_loc_req.bsslap_apdu);
9098 setverdict(fail, "BSSMAP-LE APDU IE is not as expected");
9099 mtc.stop;
9100 }
9101 var template BSSLAP_PDU expect_ta_layer3 := tr_BSSLAP_TA_Layer3(tr_BSSLAP_IE_TA(0));
9102 var BSSLAP_PDU bsslap := dec_BSSLAP_PDU(plr.pdu.bssmap.perf_loc_req.bsslap_apdu.data);
9103 if (not match(bsslap, expect_ta_layer3)) {
9104 log("EXPECTING BSSLAP TA Layer 3: ", expect_ta_layer3);
9105 log("GOT BSSLAP: ", bsslap);
9106 setverdict(fail, "BSSLAP is not as expected");
9107 mtc.stop;
9108 }
9109 /* OsmoBSC directly sent the TA as BSSLAP APDU in the BSSMAP-LE Perform Location Request to the SMLC. The SMLC
9110 * has no need to request the TA from the BSC and directly responds. */
9111 } else {
9112 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
9113 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
9114 f_expect_bsslap(tr_BSSLAP_TA_Resp(?, ?));
9115 }
9116
9117 /* SMLC got the TA from the BSC, now responds with geo information data. */
9118 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(gad_ell_point_unc_circle, omit));
9119 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
9120 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(tr_BSSMAP_IE_LocationEstimate(gad_ell_point_unc_circle)));
9121
9122 /* The LCS was using an active A-interface conn. It should still remain active after this. */
9123 f_mo_l3_transceive();
9124
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02009125 f_perform_clear();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02009126
9127 f_sleep(2.0);
9128 setverdict(pass);
9129}
9130
9131/* With an active lchan, start BSSMAP Perform Location Request on A interface, starting BSSMAP-LE Perform Location
9132 * Request on Lb interface. Without the SMLC doing a BSSLAP TA Request. */
9133private function f_tc_lcs_loc_req_for_active_ms(charstring id) runs on MSC_ConnHdlr {
9134 f_lcs_loc_req_for_active_ms(false);
9135}
9136testcase TC_lcs_loc_req_for_active_ms() runs on test_CT {
9137 var MSC_ConnHdlr vc_conn;
9138 var TestHdlrParams pars := f_gen_test_hdlr_pars();
9139
9140 f_init(1, true);
9141 f_sleep(1.0);
9142 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_active_ms), pars);
9143 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01009144 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02009145}
9146
9147/* With an active lchan, start BSSMAP Perform Location Request on A interface, starting BSSMAP-LE Perform Location
9148 * Request on Lb interface. With the SMLC doing a BSSLAP TA Request. */
9149private function f_tc_lcs_loc_req_for_active_ms_ta_req(charstring id) runs on MSC_ConnHdlr {
9150 f_lcs_loc_req_for_active_ms(true);
9151}
9152testcase TC_lcs_loc_req_for_active_ms_ta_req() runs on test_CT {
9153 var MSC_ConnHdlr vc_conn;
9154 var TestHdlrParams pars := f_gen_test_hdlr_pars();
9155
9156 f_init(1, true);
9157 f_sleep(1.0);
9158 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_active_ms_ta_req), pars);
9159 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01009160 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02009161}
9162
9163/* Clear the A-interface conn only, without doing anything on Abis. Useful for LCS, for cases where there is only an A
9164 * conn without an active lchan. */
9165private function f_clear_A_conn() runs on MSC_ConnHdlr
9166{
9167 var BssmapCause cause := 0;
9168 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
9169 BSSAP.receive(tr_BSSMAP_ClearComplete);
9170 BSSAP.send(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_REQ);
9171
9172 timer no_more_bssap := 5.0;
9173 no_more_bssap.start;
9174 alt {
9175 [] no_more_bssap.timeout { break; }
9176 [] BSSAP.receive(tr_BSSAP_BSSMAP) {
9177 setverdict(fail, "Expected no more BSSAP after Clear Complete");
9178 mtc.stop;
9179 }
9180 }
9181 setverdict(pass);
9182}
9183
9184/* Verify that the A-interface connection is still working, and then clear it, without doing anything on Abis. Useful
9185 * for LCS, for cases where there is only an A conn without an active lchan. */
9186private function f_verify_active_A_conn_and_clear() runs on MSC_ConnHdlr
9187{
9188 f_logp(BSCVTY, "f_verify_active_A_conn_and_clear: test A link, then clear");
9189
9190 /* When an lchan is active, we can send some L3 data from the BTS side and verify that it shows up on the other
9191 * side towards the MSC. When there is no lchan, this is not possible. To probe whether the A-interface
9192 * connection is still up, we need something that echos back on the A-interface. Another LCS request! */
9193 BSSAP.send(valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
9194 ts_CellId_CGI('262'H, '42'H, 23, 42))));
9195 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?));
9196
9197 /* Right, the Perform Location Request showed up on Lb, now we can clear the A conn. */
9198 f_clear_A_conn();
9199 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocAbort(BSSMAP_LE_LCS_CAUSE_REQUEST_ABORTED));
9200 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
9201}
9202
9203/* With *no* active lchan, start BSSMAP Perform Location Request on A interface, starting BSSMAP-LE Perform Location
9204 * Request on Lb interface. BSC will Page for the subscriber as soon as we (virtual SMLC) request the TA via BSSLAP.
9205 */
9206private function f_tc_lcs_loc_req_for_idle_ms(charstring id) runs on MSC_ConnHdlr {
9207 f_sleep(1.0);
9208
9209 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
9210 f_bssap_le_register_imsi(g_pars.imsi, omit);
9211
9212 /* Register to receive the Paging Command */
9213 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
9214 g_chan_nr := new_chan_nr;
9215 f_rslem_register(0, g_chan_nr);
9216
9217 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
9218 valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
9219 ts_CellId_CGI('001'H, '01'H, 1, 0)))));
9220 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
9221
9222 var PDU_BSSAP_LE plr;
9223 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
9224
9225 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
9226 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
9227
9228 /* OsmoBSC needs to Page */
9229 RSL.receive(tr_RSL_PAGING_CMD(tr_MI_IMSI(g_pars.imsi)));
9230 f_logp(BSCVTY, "got Paging Command");
9231
9232 /* MS requests channel. Since the Paging was for LCS, the Paging Response does not trigger a Complete Layer 3 to
9233 * the MSC, and releases the lchan directly. */
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02009234 f_perform_compl_l3(RSL, RSL_PROC, ts_PAG_RESP(valueof(ts_MI_IMSI_LV(g_pars.imsi))), do_clear := false, expect_bssmap_l3 := false);
9235 f_expect_lchan_rel(RSL, RSL_PROC);
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02009236
9237 /* From the Paging Response, the TA is now known to the BSC, and it responds to the SMLC. */
9238
9239 f_expect_bsslap(tr_BSSLAP_TA_Resp(?, ?));
9240
9241 /* SMLC got the TA from the BSC, now responds with geo information data. */
9242 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(gad_ell_point_unc_circle, omit));
9243 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
9244
9245 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(tr_BSSMAP_IE_LocationEstimate(gad_ell_point_unc_circle)));
9246
9247 /* The lchan is gone, the A-interface conn was created for the LCS only.
9248 * Still it is clearly the MSC's job to decide whether to tear down the conn or not. */
9249 f_verify_active_A_conn_and_clear();
9250
9251 f_sleep(2.0);
9252 setverdict(pass);
9253}
9254testcase TC_lcs_loc_req_for_idle_ms() runs on test_CT {
9255 var MSC_ConnHdlr vc_conn;
9256 var TestHdlrParams pars := f_gen_test_hdlr_pars();
9257
9258 f_init(1, true);
9259 f_sleep(1.0);
9260
9261 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
9262 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
9263
9264 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_idle_ms), pars);
9265 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01009266 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02009267}
9268
9269/* With no active lchan, start BSSMAP Perform Location Request on A interface, but omit IMSI; expect failure response.
9270 */
9271private function f_tc_lcs_loc_req_no_subscriber(charstring id) runs on MSC_ConnHdlr {
9272 f_sleep(1.0);
9273
9274 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
9275 f_bssap_le_register_imsi(g_pars.imsi, omit);
9276
9277 /* provoke an abort by omitting both IMSI and IMEI */
9278 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
9279 valueof(ts_BSSMAP_Perform_Location_Request(omit,
9280 ts_CellId_CGI('262'H, '42'H, 23, 42)))));
9281 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
9282
9283 /* BSC tells MSC about failure */
9284 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(
9285 locationEstimate := omit, positioningData := omit,
9286 lCS_Cause := tr_BSSMAP_LcsCause(BSSMAP_LCS_CAUSE_DATA_MISSING_IN_REQ)));
9287
9288 /* There is no lchan. Still the MSC's job to decide whether to tear down the conn or not. */
9289 f_verify_active_A_conn_and_clear();
9290
9291 f_sleep(2.0);
9292 setverdict(pass);
9293}
9294testcase TC_lcs_loc_req_no_subscriber() runs on test_CT {
9295 var MSC_ConnHdlr vc_conn;
9296 var TestHdlrParams pars := f_gen_test_hdlr_pars();
9297
9298 f_init(1, true);
9299 f_sleep(1.0);
9300
9301 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
9302 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
9303
9304 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_no_subscriber), pars);
9305 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01009306 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02009307}
9308
9309/* With an active lchan, start a Perform Location Request on the A-interface, but virtual SMLC does not answer with
9310 * BSSMAP-LE Perform Location Response (before or after sending a BSSLAP TA Request) */
9311private function f_lcs_loc_req_for_active_ms_le_timeout(boolean do_ta) runs on MSC_ConnHdlr {
9312 f_sleep(1.0);
9313
9314 f_establish_fully(omit, omit);
9315 f_bssap_le_register_imsi(g_pars.imsi, omit);
9316
9317 BSSAP.send(valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
9318 ts_CellId_CGI('262'H, '42'H, 23, 42))));
9319
9320 var PDU_BSSAP_LE plr;
9321 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
9322
9323 if (do_ta) {
9324 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
9325 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
9326 f_expect_bsslap(tr_BSSLAP_TA_Resp(?, ?));
9327 }
9328
9329 /* SMLC fails to respond, BSC runs into timeout */
9330 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocAbort(BSSMAP_LE_LCS_CAUSE_SYSTEM_FAILURE));
9331 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
9332
9333 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(
9334 locationEstimate := omit, positioningData := omit,
9335 lCS_Cause := tr_BSSMAP_LcsCause(BSSMAP_LCS_CAUSE_SYSTEM_FAILURE)));
9336
9337 /* There is no lchan. Still the MSC's job to decide whether to tear down the conn or not. */
9338 f_verify_active_A_conn_and_clear();
9339
9340 f_sleep(2.0);
9341 setverdict(pass);
9342}
9343
9344/* With an active lchan, start a Perform Location Request on the A-interface, but virtual SMLC does not answer with
9345 * BSSMAP-LE Perform Location Response, without sending a BSSLAP TA Request. */
9346private function f_tc_lcs_loc_req_for_active_ms_le_timeout(charstring id) runs on MSC_ConnHdlr {
9347 f_lcs_loc_req_for_active_ms_le_timeout(false);
9348}
9349
9350testcase TC_lcs_loc_req_for_active_ms_le_timeout() runs on test_CT {
9351 var MSC_ConnHdlr vc_conn;
9352 var TestHdlrParams pars := f_gen_test_hdlr_pars();
9353
9354 f_init(1, true);
9355 f_sleep(1.0);
9356 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_active_ms_le_timeout), pars);
9357 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01009358 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02009359}
9360
9361/* With an active lchan, start a Perform Location Request on the A-interface, but virtual SMLC does not answer with
9362 * BSSMAP-LE Perform Location Response, after sending a BSSLAP TA Request. */
9363private function f_tc_lcs_loc_req_for_active_ms_le_timeout2(charstring id) runs on MSC_ConnHdlr {
9364 f_lcs_loc_req_for_active_ms_le_timeout(true);
9365}
9366
9367testcase TC_lcs_loc_req_for_active_ms_le_timeout2() runs on test_CT {
9368 var MSC_ConnHdlr vc_conn;
9369 var TestHdlrParams pars := f_gen_test_hdlr_pars();
9370
9371 f_init(1, true);
9372 f_sleep(1.0);
9373 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_active_ms_le_timeout2), pars);
9374 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01009375 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02009376}
9377
9378/* With *no* active lchan, start a Perform Location Request, expecting that the MS will be Paged. */
9379private function f_tc_lcs_loc_req_for_idle_ms_no_pag_resp(charstring id) runs on MSC_ConnHdlr {
9380 f_sleep(1.0);
9381
9382 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
9383 f_bssap_le_register_imsi(g_pars.imsi, omit);
9384
9385 /* Register to receive the Paging Command */
9386 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
9387 g_chan_nr := new_chan_nr;
9388 f_rslem_register(0, g_chan_nr);
9389
9390 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
9391 valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
9392 ts_CellId_CGI('001'H, '01'H, 1, 0)))));
9393 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
9394
9395 var PDU_BSSAP_LE plr;
9396 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
9397
9398 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
9399 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
9400
9401 /* OsmoBSC needs to Page */
9402 var PDU_BSSAP_LE rx_bsslap;
9403 alt {
9404 [] RSL.receive(tr_RSL_PAGING_CMD(tr_MI_IMSI(g_pars.imsi))) {
9405 f_logp(BSCVTY, "got Paging Command");
9406 repeat;
9407 }
9408 [] BSSAP_LE.receive(tr_BSSMAP_LE_ConnInfo(BSSMAP_LE_PROT_BSSLAP, ?)) -> value(rx_bsslap) {
9409 /* MS does not respond to Paging, TA Req runs into timeout. */
9410 f_match_bsslap(rx_bsslap, tr_BSSLAP_Abort(?));
9411 }
9412 }
9413
9414 /* SMLC responds with failure */
9415 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(omit, BSSMAP_LE_LCS_CAUSE_REQUEST_ABORTED));
9416 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
9417
9418 /* BSC tells MSC about failure */
9419 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(
9420 locationEstimate := omit, positioningData := omit,
9421 lCS_Cause := tr_BSSMAP_LcsCause(BSSMAP_LCS_CAUSE_REQUEST_ABORTED)));
9422
9423 /* There is no lchan. Still the MSC's job to decide whether to tear down the conn or not. */
9424 f_verify_active_A_conn_and_clear();
9425
9426 f_sleep(2.0);
9427 setverdict(pass);
9428}
9429testcase TC_lcs_loc_req_for_idle_ms_no_pag_resp() runs on test_CT {
9430 var MSC_ConnHdlr vc_conn;
9431 var TestHdlrParams pars := f_gen_test_hdlr_pars();
9432
9433 f_init(1, true);
9434 f_sleep(1.0);
9435
9436 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
9437 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
9438
9439 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_idle_ms_no_pag_resp), pars);
9440 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01009441 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02009442}
9443
9444/* During an ongoing Location Request, the MS sends a CM Service Request. Expect the same A-conn to be re-used / taken
9445 * over. */
9446private function f_tc_cm_service_during_lcs_loc_req(charstring id) runs on MSC_ConnHdlr {
9447 f_sleep(1.0);
9448
9449 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
9450 f_bssap_le_register_imsi(g_pars.imsi, omit);
9451
9452 /* Register to receive the Paging Command */
9453 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
9454 g_chan_nr := new_chan_nr;
9455 f_rslem_register(0, g_chan_nr);
9456
9457 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
9458 valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
9459 ts_CellId_CGI('001'H, '01'H, 1, 0)))));
9460 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
9461
9462 var PDU_BSSAP_LE plr;
9463 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
9464
9465 /* As the A-interface conn was established for LCS, the MS coincidentally decides to issue a CM Service Request
9466 * and establish Layer 3. It should use the existing A-interface conn. */
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02009467 f_perform_compl_l3(RSL, RSL_PROC, valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV(g_pars.imsi)))),
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02009468 do_clear := false, expect_bssmap_l3 := true);
9469
9470 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
9471 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
9472
9473 /* OsmoBSC already has an lchan, no need to Page, just returns the TA */
9474 f_expect_bsslap(tr_BSSLAP_TA_Resp(?, ?));
9475
9476 /* SMLC got the TA from the BSC, now responds with geo information data. */
9477 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(gad_ell_point_unc_circle, omit));
9478 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
9479 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(tr_BSSMAP_IE_LocationEstimate(gad_ell_point_unc_circle)));
9480
9481 /* The lchan should still exist, it was from a CM Service Request. */
9482 f_mo_l3_transceive();
9483
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02009484 f_perform_clear();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02009485
9486 f_sleep(2.0);
9487 setverdict(pass);
9488}
9489testcase TC_cm_service_during_lcs_loc_req() runs on test_CT {
9490 var MSC_ConnHdlr vc_conn;
9491 var TestHdlrParams pars := f_gen_test_hdlr_pars();
9492
9493 f_init(1, true);
9494 f_sleep(1.0);
9495
9496 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
9497 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
9498
9499 vc_conn := f_start_handler(refers(f_tc_cm_service_during_lcs_loc_req), pars);
9500 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01009501 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02009502}
9503
9504/* During an ongoing Perform Location Request, do a Handover, an expect a BSSLAP Reset message from the BSC to indicate
9505 * the new lchan after handover. */
9506private function f_tc_ho_during_lcs_loc_req(charstring id) runs on MSC_ConnHdlr {
9507 f_sleep(1.0);
9508
9509 f_establish_fully(omit, omit);
9510 f_bssap_le_register_imsi(g_pars.imsi, omit);
9511
9512 BSSAP.send(valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
9513 ts_CellId_CGI('262'H, '42'H, 23, 42))));
9514
9515 var PDU_BSSAP_LE plr;
9516 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
9517
9518 /* SMLC ponders the Location Request, in the meantime the BSC decides to handover */
9519 f_bts_0_cfg(BSCVTY, {"neighbor bts 1"});
9520
9521 var HandoverState hs := {
9522 rr_ho_cmpl_seen := false,
9523 handover_done := false,
Neels Hofmeyrc741fcb2021-10-02 14:52:28 +02009524 old_chan_nr := -,
9525 expect_target_tsc := BTS_TSC[1]
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02009526 };
9527 /* issue hand-over command on VTY */
9528 f_vty_handover(BSCVTY, 0, 0, g_chan_nr, 1);
9529 /* temporarily suspend DChan processing on BTS1 to avoid race with RSLEM_register */
9530 f_rslem_suspend(RSL1_PROC);
9531
9532 /* From the MGW perspective, a handover is is characterized by
9533 * performing one MDCX operation with the MGW. So we expect to see
9534 * one more MDCX during handover. */
9535 g_media.mgcp_conn[0].mdcx_seen_exp := g_media.mgcp_conn[0].crcx_seen_exp + 1;
9536
9537 alt {
9538 [] as_handover(hs);
9539 }
9540
9541 var PDU_BSSAP_LE rx_bsslap;
9542
9543 interleave {
9544 /* Expect the BSC to inform the MSC about the handover */
9545 [] BSSAP.receive(tr_BSSMAP_HandoverPerformed);
9546
9547 /* Expect the BSC to inform the SMLC about the handover */
9548 [] BSSAP_LE.receive(tr_BSSMAP_LE_ConnInfo(BSSMAP_LE_PROT_BSSLAP, ?)) -> value(rx_bsslap) {
9549 f_match_bsslap(rx_bsslap, tr_BSSLAP_Reset(BSSLAP_CAUSE_INTRA_BSS_HO));
9550 }
9551 }
9552
9553 /* SMLC now responds with geo information data. */
9554 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(gad_ell_point_unc_circle, omit));
9555 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
9556 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(tr_BSSMAP_IE_LocationEstimate(gad_ell_point_unc_circle)));
9557
9558 /* lchan still active */
9559 f_mo_l3_transceive(RSL1);
9560
9561 /* MSC decides it is done now. */
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02009562 f_perform_clear(RSL1, RSL1_PROC);
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02009563
9564 f_sleep(2.0);
9565 setverdict(pass);
9566}
9567testcase TC_ho_during_lcs_loc_req() runs on test_CT {
9568 var MSC_ConnHdlr vc_conn;
9569 var TestHdlrParams pars := f_gen_test_hdlr_pars();
9570
9571 f_init(2, true);
9572 f_sleep(1.0);
9573 vc_conn := f_start_handler(refers(f_tc_ho_during_lcs_loc_req), pars);
9574 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01009575 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02009576}
9577
Neels Hofmeyrbf037052020-10-28 22:52:02 +00009578/* Attempt Complete Layer 3 without any MSC available (OS#4832) */
9579private function f_tc_no_msc(charstring id) runs on MSC_ConnHdlr {
9580 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
9581
9582 /* Also disable attach for the single connected MSC */
9583 f_vty_msc_allow_attach(BSCVTY, { false });
9584
9585 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) ));
9586 f_chan_est(g_pars.ra, l3_enc, g_pars.link_id, g_pars.fn);
9587
9588 /* No MSC is found, expecting a proper release on RSL */
9589 interleave {
9590 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
9591 f_logp(BSCVTY, "Got RSL RR Release");
9592 }
9593 [] RSL.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
9594 f_logp(BSCVTY, "Got RSL Deact SACCH");
9595 }
Neels Hofmeyr3c5127e2021-07-22 19:18:40 +02009596 [] RSL.receive(tr_RSL_RF_CHAN_REL(g_chan_nr)) {
Neels Hofmeyrbf037052020-10-28 22:52:02 +00009597 f_logp(BSCVTY, "Got RSL RF Chan Rel, sending Rel Ack");
9598 RSL.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
Neels Hofmeyre680b012021-07-22 19:19:09 +02009599 f_rslem_unregister(0, g_chan_nr);
Neels Hofmeyrbf037052020-10-28 22:52:02 +00009600 }
9601 }
9602 setverdict(pass);
9603}
9604testcase TC_no_msc() runs on test_CT {
9605
9606 f_init(1, true);
9607 f_sleep(1.0);
9608 var MSC_ConnHdlr vc_conn;
9609 var TestHdlrParams pars := f_gen_test_hdlr_pars();
9610
9611 f_ctrs_bsc_init(counternames_bsc_mscpool);
9612
9613 vc_conn := f_start_handler(refers(f_tc_no_msc), pars);
9614 vc_conn.done;
9615
9616 f_ctrs_bsc_add("mscpool:subscr:no_msc");
9617 f_ctrs_bsc_verify();
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01009618 f_shutdown_helper();
Neels Hofmeyrbf037052020-10-28 22:52:02 +00009619}
9620
Harald Welte0ea2d5e2018-04-07 21:40:29 +02009621/* Dyn PDCH todo:
9622 * activate OSMO as TCH/F
9623 * activate OSMO as TCH/H
9624 * does the BSC-located PCU socket get the updated INFO?
9625 * what if no PCU is connected at the time?
9626 * is the info correct on delayed PCU (re)connect?
9627 */
Harald Welte94e0c342018-04-07 11:33:23 +02009628
Neels Hofmeyr87857ec2021-04-25 16:17:47 +00009629private function f_TC_refuse_mode_modif_to_vamos(charstring id) runs on MSC_ConnHdlr {
9630 var PDU_BSSAP ass_cmd := f_gen_ass_req(g_pars.use_osmux);
9631 var template PDU_BSSAP exp_compl := f_gen_exp_compl(g_pars.use_osmux);
9632
9633 /* puzzle together the ASSIGNMENT REQ for given codec[s] */
9634 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
9635 ass_cmd.pdu.bssmap.assignmentRequest.codecList := g_pars.ass_codec_list;
9636 exp_compl.pdu.bssmap.assignmentComplete.speechCodec.codecElements[0] :=
9637 g_pars.ass_codec_list.codecElements[0];
9638 if (isvalue(g_pars.expect_mr_s0_s7)) {
9639 exp_compl.pdu.bssmap.assignmentComplete.speechCodec.codecElements[0].s0_7 :=
9640 g_pars.expect_mr_s0_s7;
9641 }
9642 }
9643 ass_cmd.pdu.bssmap.assignmentRequest.channelType :=
9644 f_BSSMAP_chtype_from_codec(g_pars.ass_codec_list.codecElements[0]);
9645 log("expecting ASS COMPL like this: ", exp_compl);
9646
9647 f_establish_fully(ass_cmd, exp_compl);
9648
Neels Hofmeyr8746b0d2021-06-01 17:25:39 +02009649 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 1 sub-slot 0 modify vamos tsc 2 3");
Neels Hofmeyr87857ec2021-04-25 16:17:47 +00009650
9651 var RSL_Message rsl;
9652
9653 timer T := 5.0;
9654 T.start;
9655 alt {
9656 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr)) -> value rsl {
9657 var PDU_ML3_NW_MS l3 := dec_PDU_ML3_NW_MS(rsl.ies[2].body.l3_info.payload);
9658 log("Rx L3 from net: ", l3);
9659 if (ischosen(l3.msgs.rrm.channelModeModify)) {
9660 setverdict(fail, "Mode Modify to VAMOS succeeded even though BTS does not support VAMOS");
9661 mtc.stop;
9662 }
9663 }
9664 [] RSL.receive(tr_RSL_MODE_MODIFY_REQ(g_chan_nr, ?)) -> value rsl {
9665 setverdict(fail, "Mode Modify to VAMOS succeeded even though BTS does not support VAMOS");
9666 mtc.stop;
9667 }
9668 [] T.timeout {
9669 /* The BTS does not exhibit BTS_FEAT_VAMOS, so no VAMOS related Mode Modify should happen. */
9670 setverdict(pass);
9671 }
9672 }
9673 T.stop;
9674}
9675
9676/* The BSC does *not* indicate BTS_FEAT_VAMOS; make sure that a channel Mode Modify to VAMOS mode is refused by
9677 * osmo-bsc. */
9678testcase TC_refuse_mode_modif_to_vamos() runs on test_CT {
9679 var TestHdlrParams pars := f_gen_test_hdlr_pars();
9680 var MSC_ConnHdlr vc_conn;
9681
9682 f_init(1, true);
9683 f_sleep(1.0);
9684
9685 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
9686 vc_conn := f_start_handler(refers(f_TC_refuse_mode_modif_to_vamos), pars);
9687 vc_conn.done;
9688 f_shutdown_helper();
9689}
9690
9691/* The BSC does *not* indicate BTS_FEAT_VAMOS; make sure that a channel activation to VAMOS mode is refused by osmo-bsc.
9692 */
9693testcase TC_refuse_chan_act_to_vamos() runs on test_CT {
9694 f_init_vty();
9695
9696 f_init(1, false);
9697 f_sleep(1.0);
9698
9699 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 1 sub-slot 0 activate-vamos fr");
9700
9701 var ASP_RSL_Unitdata rx_rsl_ud;
9702 timer T := 5.0;
9703
9704 T.start;
9705 alt {
9706 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(?, IPAC_PROTO_RSL_TRX0)) -> value rx_rsl_ud {
9707 if (rx_rsl_ud.rsl.msg_type == RSL_MT_CHAN_ACTIV) {
9708 T.stop;
9709 setverdict(fail, "CHANnel ACTivate in VAMOS mode succeeded even though BTS does not support VAMOS");
9710 mtc.stop;
9711 }
9712 repeat;
9713 }
9714 [] T.timeout {
9715 /* The BTS does not exhibit BTS_FEAT_VAMOS, so no VAMOS related CHANnel ACTivate should happen. */
9716 setverdict(pass);
9717 }
9718 }
9719}
9720
Neels Hofmeyrd2d9f332021-04-28 22:23:36 +00009721private function f_TC_reassignment_codec(charstring id) runs on MSC_ConnHdlr {
9722 /* First fully set up a speech lchan */
9723 f_TC_assignment_codec(id);
9724
9725 /* Trigger re-assignment to another lchan */
9726 var AssignmentState assignment_st := valueof(ts_AssignmentStateInit);
9727
9728 /* Re-Assignment should tell the MGW endpoint the new lchan's RTP address and port, so expecting to see exactly
9729 * one MDCX on MGCP. */
9730 g_media.mgcp_conn[0].mdcx_seen_exp := g_media.mgcp_conn[0].mdcx_seen_exp + 1;
9731
9732 /* The new lchan will see all-new IPAC_CRCX and IPAC_MDCX messages telling the BTS the same RTP address and port
9733 * as the old lchan used. */
9734 g_media.bts.ipa_crcx_seen := false;
9735 g_media.bts.ipa_mdcx_seen := false;
9736
9737 /* Send different BTS side RTP port number for the new lchan */
9738 g_media.bts.bts.port_nr := 4223;
9739
9740 f_rslem_register(0, valueof(ts_RslChanNr_Bm(2))); /* <-- FIXME: can we somehow infer the timeslot that will be used? */
9741
9742 /* Trigger re-assignment. */
9743 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot " & int2str(g_chan_nr.tn) & " sub-slot 0 assignment");
9744
9745 timer T := 5.0;
9746 T.start;
9747 alt {
9748 [] as_assignment(assignment_st);
9749 [] as_Media();
9750 [] T.timeout {
9751 break;
9752 }
9753 }
9754
9755 if (not assignment_st.assignment_done) {
9756 setverdict(fail, "Assignment did not complete");
9757 mtc.stop;
9758 }
9759
9760 f_check_mgcp_expectations()
9761 setverdict(pass);
9762
9763 f_sleep(2.0);
9764 log("show lchan summary: ", f_vty_transceive_ret(BSCVTY, "show lchan summary"));
9765
9766 /* Instruct BSC to clear channel */
9767 var BssmapCause cause := 0;
9768 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
9769 interleave {
Neels Hofmeyrd2d9f332021-04-28 22:23:36 +00009770 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {}
9771 [] RSL.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {}
Neels Hofmeyr3c5127e2021-07-22 19:18:40 +02009772 [] RSL.receive(tr_RSL_RF_CHAN_REL(g_chan_nr)) {
Neels Hofmeyrd2d9f332021-04-28 22:23:36 +00009773 RSL.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
Neels Hofmeyre680b012021-07-22 19:19:09 +02009774 f_rslem_unregister(0, g_chan_nr);
Neels Hofmeyrd2d9f332021-04-28 22:23:36 +00009775 }
9776 [] BSSAP.receive(tr_BSSMAP_ClearComplete) {
9777 BSSAP.send(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_REQ);
9778 }
9779 }
Neels Hofmeyr40a45d12021-09-23 22:57:12 +02009780 f_expect_dlcx_conns();
Neels Hofmeyrd2d9f332021-04-28 22:23:36 +00009781
9782 f_sleep(0.5);
9783}
9784
9785testcase TC_reassignment_fr() runs on test_CT {
9786 var TestHdlrParams pars := f_gen_test_hdlr_pars();
9787 var MSC_ConnHdlr vc_conn;
9788
9789 f_init(1, true);
9790 f_sleep(1.0);
9791
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01009792 f_ctrs_bsc_and_bts_handover_init();
Neels Hofmeyrd2d9f332021-04-28 22:23:36 +00009793
9794 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
9795 vc_conn := f_start_handler(refers(f_TC_reassignment_codec), pars);
9796 vc_conn.done;
9797
9798 /* from f_establish_fully() */
9799 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
9800 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
9801 /* from re-assignment */
9802 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
9803 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
9804 f_ctrs_bsc_and_bts_verify();
9805 f_shutdown_helper();
9806}
9807
Neels Hofmeyrfeda88e2021-07-19 13:51:29 +02009808const charstring REEST_LOST_CONNECTION := "REEST_LOST_CONNECTION";
9809const charstring REEST_CLEAR := "REEST_CLEAR";
9810const charstring REEST_CLEAR_DONE := "REEST_CLEAR_DONE";
9811
9812/* CM Re-Establishment, 3GPP TS 24.008 4.5.1.6.
9813 * The MS <-> BTS loses radio connection, MS shows up on second BTS and asks for CM Re-Establishment.
9814 * BSC should establish a separate A conn for the same MS, the original A conn is then cleared by
9815 * the MSC as the CM Re-Establishment is handled.
9816 *
9817 * MS bts0 bts1 bsc msc test-component
9818 * |<----->|<----------------->|<-0-->| _1 Establish channel on bts 0
9819 * | | _1 wait a bit, to settle down
9820 * |<-x x--| | _1 "lose connection"
9821 * | | REEST_LOST_CONNECTION
9822 * |----------------->|------->|--1-->| _2 new A-conn: Chan Rqd, Imm Ass, Compl L3 with CM Re-Establishment Req
9823 * | | REEST_CLEAR
9824 * | |<-0---| _1 Clear Command on first A-conn
9825 * | |--0-->| _1 Clear Complete
9826 * | |<----------------->| | _1 Release first channel
9827 * | | REEST_CLEAR_DONE
9828 * |<-----------------|<-------|<-1---| _2 Chan Activ, Assignment Command
9829 * |<-----------------|<-------|<-1---| _2 Clear Command, Release
9830 *
9831 */
9832private function f_tc_cm_reestablishment_1(charstring id) runs on MSC_ConnHdlr {
9833 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
9834 var PDU_BSSAP ass_cmd := f_gen_ass_req();
9835
9836 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
9837 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
9838
9839 f_establish_fully(ass_cmd, exp_compl);
9840
9841 /* The original channel loses connection, MS attemts CM Re-Establishment on another cell, see
9842 * f_tc_cm_reestablishment_2(). This established channel stays active until MSC sends a Clear Command. The time
9843 * when exactly that happens is determined by f_tc_cm_reestablishment_2(). */
9844 f_sleep(2.0);
9845 COORD.send(REEST_LOST_CONNECTION);
9846
9847 alt {
9848 [] COORD.receive(REEST_CLEAR);
9849 [] RSL.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
9850 setverdict(fail, "Unexpected channel release");
9851 mtc.stop;
9852 }
9853 [] RSL.receive(tr_RSL_RF_CHAN_REL(g_chan_nr)) {
9854 setverdict(fail, "Unexpected channel release");
9855 mtc.stop;
9856 }
9857 }
9858 f_perform_clear()
9859 f_expect_dlcx_conns();
Neels Hofmeyr969abd02021-09-23 22:24:08 +02009860 f_create_mgcp_delete_ep(g_media.mgcp_ep);
Neels Hofmeyrfeda88e2021-07-19 13:51:29 +02009861 COORD.send(REEST_CLEAR_DONE);
9862}
9863
9864private function f_tc_cm_reestablishment_2(charstring id) runs on MSC_ConnHdlr {
9865 f_MscConnHdlr_init(g_pars.media_nr, host_bts, host_mgw_mgcp, FR_AMR);
9866
9867 /* The MS lost the connection on the first channel, now establishes another one */
9868 COORD.receive(REEST_LOST_CONNECTION);
9869
9870 var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi));
9871 var PDU_ML3_MS_NW l3_info := valueof(ts_CM_REESTABL_REQ(mi));
9872 var octetstring l3_enc := enc_PDU_ML3_MS_NW(l3_info);
9873
9874 f_create_bssmap_exp(l3_enc);
Neels Hofmeyrc7b1f6d2021-07-20 23:21:36 +02009875 RSL_Emulation.f_chan_est(g_pars.ra, l3_enc, g_pars.link_id, g_pars.fn, rsl_pt := RSL1, rsl_proc_pt := RSL1_PROC);
Neels Hofmeyrfeda88e2021-07-19 13:51:29 +02009876 BSSAP.receive(tr_BSSMAP_ComplL3(l3_enc));
9877
9878 /* MSC got the CM Re-Establishment request and first off clears the previous conn. */
9879 COORD.send(REEST_CLEAR);
9880 COORD.receive(REEST_CLEAR_DONE);
9881
9882 f_sleep(2.0);
9883
9884 /* Answer the CM Re-Establishment with an Assignment Command. */
9885 var template PDU_BSSAP expect_assignment_compl := f_gen_exp_compl();
9886 var PDU_BSSAP ass_cmd := f_gen_ass_req();
9887 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
9888 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
9889
9890 var AssignmentState st := valueof(ts_AssignmentStateInit);
9891 st.voice_call := true;
9892 st.is_assignment := true;
9893
9894 var ExpectCriteria mgcpcrit := {
9895 connid := omit,
9896 endpoint := omit,
9897 transid := omit
9898 };
9899 f_create_mgcp_expect(mgcpcrit);
9900
Neels Hofmeyrc7b1f6d2021-07-20 23:21:36 +02009901 f_rslem_dchan_queue_enable(RSL1_PROC);
Neels Hofmeyrfeda88e2021-07-19 13:51:29 +02009902
9903 BSSAP.send(ass_cmd);
9904
9905 var PDU_BSSAP bssap;
9906
9907 alt {
Neels Hofmeyrc7b1f6d2021-07-20 23:21:36 +02009908 [] as_assignment(st, rsl_pt := RSL1, rsl_proc_pt := RSL1_PROC);
9909 [] as_Media_ipacc(RSL1, RSL2);
9910 [] as_Media_mgw();
Neels Hofmeyrfeda88e2021-07-19 13:51:29 +02009911 [st.assignment_done] BSSAP.receive(expect_assignment_compl) {
9912 break;
9913 }
9914 }
9915
9916 f_sleep(3.0);
9917
9918 f_logp(BSCVTY, "f_tc_cm_reestablishment_2 clearing");
Neels Hofmeyrc7b1f6d2021-07-20 23:21:36 +02009919 f_perform_clear(RSL1, RSL1_PROC);
Neels Hofmeyrfeda88e2021-07-19 13:51:29 +02009920 f_expect_dlcx_conns();
9921}
9922
9923testcase TC_cm_reestablishment() runs on test_CT {
9924 var TestHdlrParams pars1 := f_gen_test_hdlr_pars();
9925 var MSC_ConnHdlr vc_conn1;
9926
9927 var TestHdlrParams pars2 := f_gen_test_hdlr_pars();
9928 var MSC_ConnHdlr vc_conn2;
9929 pars2.imsi := pars1.imsi;
9930 pars2.media_nr := 2;
Neels Hofmeyrbf720202021-10-02 12:58:24 +02009931 pars2.expect_tsc := BTS_TSC[1];
Neels Hofmeyrfeda88e2021-07-19 13:51:29 +02009932
9933 f_init(2, true, guard_timeout := 40.0);
9934 f_sleep(1.0);
9935
9936 vc_conn1 := f_start_handler_create(pars1);
9937 vc_conn2 := f_start_handler_create(pars2);
9938 connect(vc_conn1:COORD, vc_conn2:COORD);
9939 f_start_handler_run(vc_conn1, refers(f_tc_cm_reestablishment_1), pars1);
9940 f_start_handler_run(vc_conn2, refers(f_tc_cm_reestablishment_2), pars2);
9941 vc_conn1.done;
9942 vc_conn2.done;
9943
9944 f_shutdown_helper();
9945}
Neels Hofmeyr87857ec2021-04-25 16:17:47 +00009946
Neels Hofmeyrb07b2952021-08-07 04:23:14 +02009947function f_exp_ipa_rx_nonfatal(integer bts_nr, template (present) RSL_Message t_rx, float t_secs := 2.0,
9948 IpaStreamId sid := IPAC_PROTO_RSL_TRX0, boolean ignore_other_rx := true)
9949runs on test_CT return template (omit) RSL_Message {
9950 var ASP_RSL_Unitdata rx_rsl_ud;
9951 timer T := t_secs;
9952
9953 T.start;
9954 alt {
9955 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(t_rx, sid)) -> value rx_rsl_ud {
9956 T.stop;
9957 }
9958 [ignore_other_rx] IPA_RSL[bts_nr].receive { repeat; }
9959 [not ignore_other_rx] IPA_RSL[bts_nr].receive {
9960 log("f_exp_ipa_rx_nonfatal(): Got different message than ", t_rx);
9961 T.stop;
9962 return omit;
9963 }
9964 [] T.timeout {
9965 return omit;
9966 }
9967 }
9968 return rx_rsl_ud.rsl;
9969}
9970
9971private function f_vty_set_imm_ass(TELNETasp_PT pt, BtsNr bts_nr := 0, charstring imm_ass_setting := "post-chan-ack") {
9972 f_vty_enter_cfg_bts(pt, bts_nr);
9973 f_vty_transceive(pt, "immediate-assignment " & imm_ass_setting);
9974 f_vty_transceive(pt, "exit");
9975 f_vty_transceive(pt, "exit");
9976 f_vty_transceive(pt, "exit");
9977}
9978
9979private function f_verify_imm_ass(RSL_Message imm_ass, template uint8_t ra := ?, template GsmFrameNumber fn := ?,
Neels Hofmeyr07603cf2021-09-07 19:05:52 +02009980 template RslChannelNr chan_nr := ?,
9981 template (present) uint12_t arfcn := ?,
9982 template (present) uint3_t tsc := ?)
Neels Hofmeyrb07b2952021-08-07 04:23:14 +02009983{
9984 var RSL_IE_Body full_imm_ass_info;
9985 if (not f_rsl_find_ie(imm_ass, RSL_IE_FULL_IMM_ASS_INFO, full_imm_ass_info)) {
9986 setverdict(fail, "RSL Full Immediate Assign Info IE is absent");
9987 mtc.stop;
9988 }
9989
9990 var GsmRrMessage rr_imm_ass := dec_GsmRrMessage(full_imm_ass_info.full_imm_ass_info.payload);
9991 var template GsmRrMessage expect_imm_ass := tr_IMM_ASS(ra := ra,
9992 fn := fn,
Neels Hofmeyr07603cf2021-09-07 19:05:52 +02009993 ch_desc := tr_ChanDescH0(chan_nr, arfcn, tsc),
Neels Hofmeyrb07b2952021-08-07 04:23:14 +02009994 page_mode := ?);
9995 if (not match(rr_imm_ass, expect_imm_ass)) {
9996 log("Error: expected ", expect_imm_ass, " got ", rr_imm_ass);
9997 setverdict(fail, "Failed to match Immediate Assignment");
9998 mtc.stop;
9999 }
10000}
10001
10002testcase TC_imm_ass_post_chan_ack() runs on test_CT {
10003 var RSL_Message chan_act;
10004 var RSL_Message imm_ass;
10005
10006 f_init(1, false);
10007 f_sleep(1.0);
10008
10009 /* (should be the default anyway, just to make things clear) */
10010 f_vty_set_imm_ass(BSCVTY, 0, "post-chan-ack");
10011
10012 /* RA containing reason=LU */
10013 var GsmFrameNumber fn := 2342;
10014 var uint8_t ra := 2;
10015 f_ipa_tx(0, ts_RSL_CHAN_RQD(int2oct(ra, 1), fn));
10016
10017 chan_act := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
10018
10019 /* First send the Chan Act ACK */
10020 var RslChannelNr chan_nr := chan_act.ies[0].body.chan_nr;
Neels Hofmeyr07603cf2021-09-07 19:05:52 +020010021 var RSL_IE_Body chan_ident_ie;
10022 if (not f_rsl_find_ie(chan_act, RSL_IE_CHAN_IDENT, chan_ident_ie)) {
10023 setverdict(fail, "RSL Channel Identification IE is absent");
10024 mtc.stop;
10025 }
10026
Neels Hofmeyrb07b2952021-08-07 04:23:14 +020010027 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, fn + 10));
10028
10029 /* Then expect the Immediate Assignment, after we ACKed the chan act */
10030 imm_ass := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
10031
Neels Hofmeyr07603cf2021-09-07 19:05:52 +020010032 f_verify_imm_ass(imm_ass, ra, fn, chan_nr, chan_ident_ie.chan_ident.ch_desc.v.arfcn,
10033 chan_ident_ie.chan_ident.ch_desc.v.tsc);
Neels Hofmeyrb07b2952021-08-07 04:23:14 +020010034
10035 /* Check that the lchan is working */
10036 var octetstring l3 := '00010203040506'O;
10037 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
10038
10039 var BSSAP_N_CONNECT_ind rx_c_ind;
10040 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
10041 BSSAP.send(ts_BSSAP_CONNECT_res(rx_c_ind.connectionId));
10042
10043 f_sleep(1.0);
10044 f_shutdown_helper();
10045}
10046
10047testcase TC_imm_ass_pre_chan_ack() runs on test_CT {
10048 var RSL_Message chan_act;
10049 var RSL_Message imm_ass;
10050
10051 f_init(1, false);
10052 f_sleep(1.0);
10053
10054 f_vty_set_imm_ass(BSCVTY, 0, "pre-chan-ack");
10055
10056 /* RA containing reason=LU */
10057 var GsmFrameNumber fn := 2342;
10058 var uint8_t ra := 2;
10059 f_ipa_tx(0, ts_RSL_CHAN_RQD(int2oct(ra, 1), fn));
10060
10061 /* (set bts 0 cfg back to default) */
10062 f_vty_set_imm_ass(BSCVTY);
10063
10064 chan_act := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
10065 var RslChannelNr chan_nr := chan_act.ies[0].body.chan_nr;
Neels Hofmeyr07603cf2021-09-07 19:05:52 +020010066 var RSL_IE_Body chan_ident_ie;
10067 if (not f_rsl_find_ie(chan_act, RSL_IE_CHAN_IDENT, chan_ident_ie)) {
10068 setverdict(fail, "RSL Channel Identification IE is absent");
10069 mtc.stop;
10070 }
Neels Hofmeyrb07b2952021-08-07 04:23:14 +020010071
10072 /* *FIRST* expect the Immediate Assignment, before we ACK the chan act */
10073 imm_ass := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
Neels Hofmeyr07603cf2021-09-07 19:05:52 +020010074 f_verify_imm_ass(imm_ass, ra, fn, chan_nr, chan_ident_ie.chan_ident.ch_desc.v.arfcn,
10075 chan_ident_ie.chan_ident.ch_desc.v.tsc);
Neels Hofmeyrb07b2952021-08-07 04:23:14 +020010076
10077 /* Only now send the Chan Act ACK */
10078 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, fn+10));
10079
10080 /* Check that the lchan is working */
10081 var octetstring l3 := '00010203040506'O;
10082 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
10083
10084 var BSSAP_N_CONNECT_ind rx_c_ind;
10085 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
10086 BSSAP.send(ts_BSSAP_CONNECT_res(rx_c_ind.connectionId));
10087
10088 f_sleep(1.0);
10089 f_shutdown_helper();
10090}
10091
Neels Hofmeyr23158742021-09-07 19:08:07 +020010092testcase TC_imm_ass_pre_ts_ack() runs on test_CT {
10093 var RSL_Message chan_act;
10094 var RSL_Message imm_ass;
10095
10096 f_init(1, false);
10097 f_sleep(1.0);
10098
10099 f_vty_set_imm_ass(BSCVTY, 0, "pre-ts-ack");
10100
10101 /* RA containing reason=LU */
10102 var GsmFrameNumber fn := 2342;
10103 var uint8_t ra := 2;
10104 f_ipa_tx(0, ts_RSL_CHAN_RQD(int2oct(ra, 1), fn));
10105
10106 /* (set bts 0 cfg back to default) */
10107 f_vty_set_imm_ass(BSCVTY);
10108
10109 chan_act := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
10110 var RslChannelNr chan_nr := chan_act.ies[0].body.chan_nr;
10111 var RSL_IE_Body chan_ident_ie;
10112 if (not f_rsl_find_ie(chan_act, RSL_IE_CHAN_IDENT, chan_ident_ie)) {
10113 setverdict(fail, "RSL Channel Identification IE is absent");
10114 mtc.stop;
10115 }
10116
10117 /* *FIRST* expect the Immediate Assignment, before we ACK the chan act */
10118 imm_ass := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
10119 f_verify_imm_ass(imm_ass, ra, fn, chan_nr, chan_ident_ie.chan_ident.ch_desc.v.arfcn,
10120 chan_ident_ie.chan_ident.ch_desc.v.tsc);
10121
10122 /* Only now send the Chan Act ACK */
10123 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, fn+10));
10124
10125 /* Check that the lchan is working */
10126 var octetstring l3 := '00010203040506'O;
10127 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
10128
10129 var BSSAP_N_CONNECT_ind rx_c_ind;
10130 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
10131 BSSAP.send(ts_BSSAP_CONNECT_res(rx_c_ind.connectionId));
10132
10133 f_sleep(1.0);
10134 f_shutdown_helper();
10135}
10136
Neels Hofmeyr7a6d0602021-08-07 04:23:50 +020010137testcase TC_imm_ass_pre_chan_ack_dyn_ts() runs on test_CT {
10138 /* change Timeslot 6 before f_init() starts RSL */
10139 f_init_vty();
10140 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_PDCH");
10141 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
10142
10143 f_init(1, false);
10144 f_sleep(1.0);
10145
10146 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(6));
10147 /* The BSC will activate the dynamic PDCH by default, so confirm that */
10148 f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
10149 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2323));
10150
10151 /* clean up timeslot 6 config, will only take effect when the OML drops the next time */
10152 f_ts_set_chcomb(0, 0, 6, "PDCH");
10153
10154 /* block all static timeslots so that the dyn TS will be used */
10155 f_disable_all_tch_f();
10156 f_disable_all_tch_h();
10157 f_disable_all_sdcch();
10158
10159 var RSL_Message chan_act;
10160 var RSL_Message imm_ass;
10161
10162 f_init(1, false);
10163 f_sleep(1.0);
10164
10165 f_vty_set_imm_ass(BSCVTY, 0, "pre-chan-ack");
10166
10167 /* RA containing reason=LU */
10168 var GsmFrameNumber fn := 2342;
10169 var uint8_t ra := 2;
10170 f_ipa_tx(0, ts_RSL_CHAN_RQD(int2oct(ra, 1), fn));
10171
10172 /* (set bts 0 cfg back to default) */
10173 f_vty_set_imm_ass(BSCVTY);
10174
10175 /* Expect the dyn TS to deactivate PDCH first */
10176 f_exp_ipa_rx(0, tr_RSL_RF_CHAN_REL(chan_nr));
10177 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(chan_nr));
10178
10179 /* Now activation as SDCCH8 */
10180 chan_nr := valueof(t_RslChanNr_SDCCH8(tn := 6, sub_slot := 0));
10181
10182 chan_act := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
Neels Hofmeyr07603cf2021-09-07 19:05:52 +020010183 var RSL_IE_Body chan_ident_ie;
10184 if (not f_rsl_find_ie(chan_act, RSL_IE_CHAN_IDENT, chan_ident_ie)) {
10185 setverdict(fail, "RSL Channel Identification IE is absent");
10186 mtc.stop;
10187 }
Neels Hofmeyr7a6d0602021-08-07 04:23:50 +020010188
10189 /* *FIRST* expect the Immediate Assignment, before we ACK the chan act */
10190 imm_ass := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
Neels Hofmeyr07603cf2021-09-07 19:05:52 +020010191 f_verify_imm_ass(imm_ass, ra, fn, chan_nr, chan_ident_ie.chan_ident.ch_desc.v.arfcn,
10192 chan_ident_ie.chan_ident.ch_desc.v.tsc);
Neels Hofmeyr7a6d0602021-08-07 04:23:50 +020010193
10194 /* Only now send the Chan Act ACK */
10195 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, fn+10));
10196
10197 /* Check that the lchan is working */
10198 var octetstring l3 := '00010203040506'O;
10199 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
10200
10201 var BSSAP_N_CONNECT_ind rx_c_ind;
10202 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
10203 BSSAP.send(ts_BSSAP_CONNECT_res(rx_c_ind.connectionId));
10204
10205 f_sleep(1.0);
10206 f_shutdown_helper();
10207}
10208
Neels Hofmeyrc8b95c12021-08-07 04:24:02 +020010209testcase TC_imm_ass_pre_ts_ack_dyn_ts() runs on test_CT {
10210 /* change Timeslot 6 before f_init() starts RSL */
10211 f_init_vty();
10212 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_PDCH");
10213 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
10214
10215 f_init(1, false);
10216 f_sleep(1.0);
10217
10218 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(6));
10219 /* The BSC will activate the dynamic PDCH by default, so confirm that */
10220 f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
10221 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2323));
10222
10223 /* clean up timeslot 6 config, will only take effect when the OML drops the next time */
10224 f_ts_set_chcomb(0, 0, 6, "PDCH");
10225
10226 /* block all static timeslots so that the dyn TS will be used */
10227 f_disable_all_tch_f();
10228 f_disable_all_tch_h();
10229 f_disable_all_sdcch();
10230
10231 var RSL_Message chan_act;
10232 var RSL_Message imm_ass;
10233
10234 f_init(1, false);
10235 f_sleep(1.0);
10236
10237 f_vty_set_imm_ass(BSCVTY, 0, "pre-ts-ack");
10238
10239 /* RA containing reason=LU */
10240 var GsmFrameNumber fn := 2342;
10241 var uint8_t ra := 2;
10242 f_ipa_tx(0, ts_RSL_CHAN_RQD(int2oct(ra, 1), fn));
10243
10244 /* (set bts 0 cfg back to default) */
10245 f_vty_set_imm_ass(BSCVTY);
10246
10247 /* Expect the dyn TS to deactivate PDCH first */
10248 f_exp_ipa_rx(0, tr_RSL_RF_CHAN_REL(chan_nr));
10249
10250 /* And already the Immediate Assignment even before the PDCH Deact ACK */
10251 imm_ass := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
10252
10253 /* continue the Osmo style PDCH Deact (usual chan rel) */
10254 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(chan_nr));
10255
10256 /* Now activation as SDCCH8 */
10257 chan_nr := valueof(t_RslChanNr_SDCCH8(tn := 6, sub_slot := 0));
10258
10259 chan_act := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
Neels Hofmeyr07603cf2021-09-07 19:05:52 +020010260 var RSL_IE_Body chan_ident_ie;
10261 if (not f_rsl_find_ie(chan_act, RSL_IE_CHAN_IDENT, chan_ident_ie)) {
10262 setverdict(fail, "RSL Channel Identification IE is absent");
10263 mtc.stop;
10264 }
Neels Hofmeyrc8b95c12021-08-07 04:24:02 +020010265 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, fn+10));
10266
Neels Hofmeyr07603cf2021-09-07 19:05:52 +020010267 f_verify_imm_ass(imm_ass, ra, fn, chan_nr, chan_ident_ie.chan_ident.ch_desc.v.arfcn,
10268 chan_ident_ie.chan_ident.ch_desc.v.tsc);
Neels Hofmeyrc8b95c12021-08-07 04:24:02 +020010269
10270 /* Check that the lchan is working */
10271 var octetstring l3 := '00010203040506'O;
10272 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
10273
10274 var BSSAP_N_CONNECT_ind rx_c_ind;
10275 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
10276 BSSAP.send(ts_BSSAP_CONNECT_res(rx_c_ind.connectionId));
10277
10278 f_sleep(1.0);
10279 f_shutdown_helper();
10280}
10281
Neels Hofmeyr5d7d13f2021-09-07 14:44:36 +020010282/* GET and SET the bts.N.trx.M.rf_locked CTRL variable */
10283testcase TC_ctrl_trx_rf_locked() runs on test_CT {
10284 var MSC_ConnHdlr vc_conn;
10285
10286 f_init(nr_bts := 2, handler_mode := true, nr_msc := 1);
10287 f_sleep(1.0);
10288
10289 /* BTS 0, 1, 2 are OML unlocked, only BTS 0, 1 are actually connected to RSL. */
10290 f_ctrl_get_exp(IPA_CTRL, "rf_states",
10291 "0,0,operational,unlocked,on,rsl-up;" &
10292 "1,0,operational,unlocked,on,rsl-up;" &
10293 "2,0,operational,unlocked,on,rsl-down;" &
10294 "3,0,inoperational,locked,on,rsl-down;");
10295
10296 f_logp(BSCVTY, "TC_ctrl_trx_rf_locked: lock BTS 1 TRX 0");
10297 f_ctrl_set(IPA_CTRL, "bts.1.trx.0.rf_locked", "1");
10298 /* give it a moment to settle the FSM status */
10299 f_sleep(1.0);
10300
10301 /* Now BTS 1 TRX 0 should reflect "locked". Note the RF policy stays "on", because this is still handled
10302 * globally in osmo-bsc. Probably after sending "rf_locked 1" for a TRX, that TRX should reflect an RF policy
10303 * of "off"? But that's for a future patch if at all. */
10304 f_ctrl_get_exp(IPA_CTRL, "rf_states",
10305 "0,0,operational,unlocked,on,rsl-up;" &
10306 "1,0,operational,locked,on,rsl-up;" &
10307 "2,0,operational,unlocked,on,rsl-down;" &
10308 "3,0,inoperational,locked,on,rsl-down;");
10309
10310 f_logp(BSCVTY, "TC_ctrl_trx_rf_locked: lock the already locked TRX, nothing should change");
10311 f_ctrl_set(IPA_CTRL, "bts.1.trx.0.rf_locked", "1");
10312 f_sleep(1.0);
10313 f_ctrl_get_exp(IPA_CTRL, "rf_states",
10314 "0,0,operational,unlocked,on,rsl-up;" &
10315 "1,0,operational,locked,on,rsl-up;" &
10316 "2,0,operational,unlocked,on,rsl-down;" &
10317 "3,0,inoperational,locked,on,rsl-down;");
10318
10319 f_logp(BSCVTY, "TC_ctrl_trx_rf_locked: unlock BTS 1 TRX 0");
10320 f_ctrl_set(IPA_CTRL, "bts.1.trx.0.rf_locked", "0");
10321 f_sleep(1.0);
10322 f_ctrl_get_exp(IPA_CTRL, "rf_states",
10323 "0,0,operational,unlocked,on,rsl-up;" &
10324 "1,0,operational,unlocked,on,rsl-up;" &
10325 "2,0,operational,unlocked,on,rsl-down;" &
10326 "3,0,inoperational,locked,on,rsl-down;");
10327
10328 f_logp(BSCVTY, "TC_ctrl_trx_rf_locked: unlock an already unlocked TRX, nothing should change");
10329 f_ctrl_set(IPA_CTRL, "bts.0.trx.0.rf_locked", "0");
10330 f_sleep(1.0);
10331 f_ctrl_get_exp(IPA_CTRL, "rf_states",
10332 "0,0,operational,unlocked,on,rsl-up;" &
10333 "1,0,operational,unlocked,on,rsl-up;" &
10334 "2,0,operational,unlocked,on,rsl-down;" &
10335 "3,0,inoperational,locked,on,rsl-down;");
10336
10337 f_logp(BSCVTY, "TC_ctrl_trx_rf_locked: unlock an inoperational TRX");
10338 f_ctrl_set(IPA_CTRL, "bts.3.trx.0.rf_locked", "0");
10339 f_sleep(1.0);
10340 f_ctrl_get_exp(IPA_CTRL, "rf_states",
10341 "0,0,operational,unlocked,on,rsl-up;" &
10342 "1,0,operational,unlocked,on,rsl-up;" &
10343 "2,0,operational,unlocked,on,rsl-down;" &
10344 "3,0,inoperational,locked,on,rsl-down;");
10345
10346 f_shutdown_helper();
10347}
10348
Neels Hofmeyr92cfa1c2021-09-28 18:29:44 +020010349/* Reproduce a segfault happening when the SDCCH (primary) lchan is lost in-between a TCH Channel Activ and its Channel
10350 * Activ Ack (SYS#5627). */
10351private function f_TC_lost_sdcch_during_assignment(charstring id) runs on MSC_ConnHdlr {
10352 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Vadim Yanitskiyf0310e32021-10-26 00:30:59 +030010353
10354 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
10355 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Neels Hofmeyr92cfa1c2021-09-28 18:29:44 +020010356
10357 var BSSMAP_FIELD_CodecType codecType;
10358 codecType := valueof(ass_cmd.pdu.bssmap.assignmentRequest.codecList.codecElements[0].codecType);
10359
10360 f_MscConnHdlr_init(g_pars.media_nr, host_bts, host_mgw_mgcp, codecType);
10361
10362 /* First establish a signalling lchan */
10363 f_create_chan_and_exp();
10364 f_rslem_dchan_queue_enable();
10365
10366 /* we should now have a COMPL_L3 at the MSC */
10367 var template PDU_BSSAP exp_l3_compl;
10368 exp_l3_compl := tr_BSSMAP_ComplL3()
10369 if (g_pars.aoip == false) {
10370 exp_l3_compl.pdu.bssmap.completeLayer3Information.codecList := omit;
10371 } else {
10372 exp_l3_compl.pdu.bssmap.completeLayer3Information.codecList := ?;
10373 }
10374 timer T := 10.0;
10375 T.start;
10376 alt {
10377 [] BSSAP.receive(exp_l3_compl);
10378 [] BSSAP.receive(tr_BSSMAP_ComplL3) {
10379 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received non-matching COMPLETE LAYER 3 INFORMATION");
10380 }
10381 [] T.timeout {
10382 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for COMPLETE LAYER 3 INFORMATION");
10383 }
10384 }
10385
10386 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
10387 activate(as_Media_mgw());
10388
10389 var RslChannelNr chan_nr := { u := { ch0 := RSL_CHAN_NR_Bm_ACCH }, tn := 1 };
10390 f_rslem_register(0, chan_nr);
10391
10392 f_rslem_set_auto_chan_act_ack(RSL_PROC, false);
10393 BSSAP.send(ass_cmd);
10394
10395
10396 /* Wait for the Channel Activ for the TCH channel */
10397 var ASP_RSL_Unitdata rx_rsl_ud;
10398 RSL.receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV), sid := ?)) -> value rx_rsl_ud;
10399
10400 /* make the original SDCCH disappear */
10401 RSL.send(ts_RSL_REL_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0))));
10402
10403 /* and ACK the TCH channel activation. This caused a segfault up to OsmoBSC 1.7.0 (SYS#5627) */
10404 RSL.send(ts_ASP_RSL_UD(ts_RSL_CHAN_ACT_ACK(chan_nr, 23), rx_rsl_ud.streamId));
10405
10406 interleave {
10407 [] BSSAP.receive(tr_BSSMAP_AssignmentFail);
10408 [] BSSAP.receive(tr_BSSMAP_ClearRequest);
10409 }
10410
10411 BSSAP.send(ts_BSSMAP_ClearCommand(0));
10412 BSSAP.receive(tr_BSSMAP_ClearComplete);
10413 BSSAP.send(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_REQ);
10414
10415 var MgcpCommand mgcp;
10416 MGCP.receive(tr_DLCX()) -> value mgcp {
10417 MGCP.send(ts_DLCX_ACK2(mgcp.line.trans_id));
10418 };
10419
10420 f_sleep(0.5);
10421}
10422testcase TC_lost_sdcch_during_assignment() runs on test_CT {
10423 var TestHdlrParams pars := f_gen_test_hdlr_pars();
10424 var MSC_ConnHdlr vc_conn;
10425
10426 f_init(1, true);
10427 f_sleep(1.0);
10428
Neels Hofmeyr92cfa1c2021-09-28 18:29:44 +020010429 vc_conn := f_start_handler(refers(f_TC_lost_sdcch_during_assignment), pars);
10430 vc_conn.done;
10431
10432 f_shutdown_helper();
10433}
10434
Neels Hofmeyrbd94fe72021-10-26 22:04:53 +020010435const CounterNameVals counternames_bsc_bts_all_available_allocated := {
10436 { "all_allocated:sdcch", 0 },
10437 { "all_allocated:static_sdcch", 0 },
10438 { "all_allocated:tch", 0 },
10439 { "all_allocated:static_tch", 0 }
10440}
10441
10442private function f_all_allocated_expect_counter_change(charstring_list expect_changed) runs on test_CT
10443{
10444 /* Make sure counters settle first */
10445 f_sleep(1.0);
10446
10447 /* Take a baseline of counters */
10448 f_ctrs_bsc_and_bts_init(1, counternames_bsc_bts_all_available_allocated);
10449
10450 /* Elapse some time so that we see changes in counters, hopefully where expected */
10451 f_sleep(2.0);
10452
10453 /* Get new counters */
10454 var charstring_list all_changed := {};
10455 all_changed := all_changed & f_counter_name_vals_get_changed_n(IPA_CTRL, "bsc", g_ctr_bsc);
10456 all_changed := all_changed & f_counter_name_vals_get_changed_n(IPA_CTRL, "bts", g_ctr_bts);
10457
10458 /* Compare with expectations */
10459 var charstring_list all_expect_changed := {};
10460 for (var integer i := 0; i < lengthof(expect_changed); i := i + 1) {
10461 all_expect_changed := all_expect_changed & { "bsc.0." & expect_changed[i], "bts.0." & expect_changed[i] };
10462 }
10463 f_counter_name_vals_expect_changed_list(all_changed, all_expect_changed);
10464}
10465
10466testcase TC_ratectr_all_available_allocated() runs on test_CT {
10467 var ASP_RSL_Unitdata rsl_ud;
10468 var integer i;
10469 var integer chreq_total, chreq_nochan;
10470
10471 f_init(1);
10472 f_sleep(1.0);
10473
10474 /* Exhaust all dedicated SDCCH lchans.
10475 /* GSM 44.018 Table 9.1.8.2:
10476 * RA = '13'O -> Establishment cause = 0001xxxx (MS dual rate capable and asks for "SDCCH").
10477 */
10478 for (i := 0; i < NUM_SDCCH_PER_BTS; i := i+1) {
10479 f_est_dchan('13'O, NUM_SDCCH_PER_BTS + i, '00010203040506'O);
10480 }
10481
10482 /* Since only bts 0 is connected, expecting all_allocated to become true for both bts 0 and the "global" bsc
10483 * level.
10484 * All SDCCH are now occupied. */
10485 f_all_allocated_expect_counter_change({"all_allocated:sdcch", "all_allocated:static_sdcch"});
10486
10487 /* Also fill up all remaining (TCH) channels */
10488 for (i := 0; i < NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS; i := i+1) {
10489 f_est_dchan('33'O, NUM_SDCCH_PER_BTS + i, '00010203040506'O);
10490 }
10491
10492 /* All TCH are now also occupied */
10493 f_all_allocated_expect_counter_change({"all_allocated:sdcch", "all_allocated:static_sdcch",
10494 "all_allocated:tch", "all_allocated:static_tch"});
10495
10496 f_shutdown_helper();
10497}
10498
10499testcase TC_ratectr_all_available_allocated_dyn() runs on test_CT {
10500 var ASP_RSL_Unitdata rsl_ud;
10501 var integer i;
10502 var integer chreq_total, chreq_nochan;
10503
10504 f_init_vty();
10505 f_ts_set_chcomb(0, 0, 2, "TCH/F_TCH/H_PDCH");
10506 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
10507 /* Now we have 3 TCH/F, 1 OSMO_DYN, 1 TCH/H */
10508
10509 f_init(1, guard_timeout := 60.0);
10510 f_sleep(1.0);
10511
10512 /* The dyn TS wants to activate PDCH mode, ACK that. */
10513 var RslChannelNr chan_nr;
10514 chan_nr := valueof(t_RslChanNr_PDCH(2));
10515 f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
10516 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342));
10517
10518 /* Exhaust all dedicated SDCCH lchans.
10519 /* GSM 44.018 Table 9.1.8.2:
10520 * RA = '13'O -> Establishment cause = 0001xxxx (MS dual rate capable and asks for "SDCCH").
10521 */
10522 for (i := 0; i < NUM_SDCCH_PER_BTS; i := i+1) {
10523 f_est_dchan('13'O, NUM_SDCCH_PER_BTS + i, '00010203040506'O);
10524 }
10525
10526 /* The static SDCCH should now be occupied, while still 3x8 dynamic SDCCH potentially remain. So only
10527 * all_allocated:static_sdcch is counted, all_allocated:sdcch remains zero. */
10528 f_all_allocated_expect_counter_change({"all_allocated:static_sdcch"});
10529
10530 /* Request more SDCCH, hence convert the first dyn TS to SDCCH8.
10531 * Will release them later, so remember all the DchanTuples. */
10532 var DchanTuples dyn_sddch := {};
10533 dyn_sddch := dyn_sddch & { f_est_dchan_dyn('33'O, NUM_SDCCH_PER_BTS + i, '00010203040506'O) };
10534
10535 /* Also occupy the seven other SDCCH of the dyn TS */
10536 for (i := 0; i < 7; i := i+1) {
10537 dyn_sddch := dyn_sddch & { f_est_dchan('33'O, NUM_SDCCH_PER_BTS + i, '00010203040506'O) };
10538 }
10539
10540 /* Now all dynamic SDCCH are also occupied, so for the first time all_allocated:sdcch will trigger... */
10541 f_all_allocated_expect_counter_change({"all_allocated:sdcch", "all_allocated:static_sdcch"});
10542
10543 /* occupy the remaining TCH, three TCH/F and two TCH/H lchans */
10544 for (i := 0; i < 5; i := i+1) {
10545 f_est_dchan('33'O, NUM_SDCCH_PER_BTS + i, '00010203040506'O);
10546 }
10547
10548 /* All TCH lchans are now also occupied, both static and dynamic */
10549 f_all_allocated_expect_counter_change({"all_allocated:sdcch", "all_allocated:static_sdcch",
10550 "all_allocated:tch", "all_allocated:static_tch"});
10551
10552 /* Starting to release the dyn TS: as soon as the first SDCCH gets released, all_allocated:sdcch stops
10553 * incrementing. */
10554 var BssmapCause cause := 0;
10555 var DchanTuple dt := dyn_sddch[0];
10556 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
10557 f_exp_chan_rel_and_clear(dt, 0);
10558
10559 /* one dyn TS SDCCH is free again, so only the static_sdcch should increment. For tch, both static and dynamic
10560 * count as occupied, so those still both increment. */
10561 f_all_allocated_expect_counter_change({"all_allocated:static_sdcch",
10562 "all_allocated:tch", "all_allocated:static_tch"});
10563
10564 /* Release the remaining SDCCH of the dyn TS, so it becomes available as TCH again */
10565 for (i := 1; i < lengthof(dyn_sddch); i := i+1) {
10566 dt := dyn_sddch[i];
10567 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
10568 f_exp_chan_rel_and_clear(dt, 0);
10569 }
10570
10571 /* All SDCCH on the dyn TS are released, the dyn TS wants to activate PDCH again */
10572 chan_nr := valueof(t_RslChanNr_PDCH(2));
10573 f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
10574 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342));
10575
10576 /* Now all channels are occupied except the dyn TS, so expecting only the static counters to increment */
10577 f_all_allocated_expect_counter_change({"all_allocated:static_sdcch", "all_allocated:static_tch"});
10578
10579 /* clean up config */
10580 f_ts_reset_chcomb(0);
10581
10582 f_shutdown_helper();
10583}
10584
Harald Welte28d943e2017-11-25 15:00:50 +010010585control {
Harald Welte898113b2018-01-31 18:32:21 +010010586 /* CTRL interface testing */
Harald Welte4003d112017-12-09 22:35:39 +010010587 execute( TC_ctrl_msc_connection_status() );
Stefan Sperlingb041b3d2018-01-03 17:14:55 +010010588 execute( TC_ctrl_msc0_connection_status() );
Neels Hofmeyrf65ce872021-09-23 18:40:10 +020010589 /* In SCCPlite tests, only one MSC is configured. These tests assume that three MSCs are configured, so only run
10590 * these in the AoIP test suite. */
10591 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
10592 execute( TC_stat_num_msc_connected_1() );
10593 execute( TC_stat_num_msc_connected_2() );
10594 execute( TC_stat_num_msc_connected_3() );
10595 }
Neels Hofmeyr5ce3ae42021-08-29 15:32:00 +020010596 execute( TC_stat_num_bts_connected_1() );
10597 execute( TC_stat_num_bts_connected_2() );
10598 execute( TC_stat_num_bts_connected_3() );
Harald Welte96c94412017-12-09 03:12:45 +010010599 execute( TC_ctrl() );
Neels Hofmeyrf246a922020-05-13 02:27:10 +020010600 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_SCCPlite_SERVER) {
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +020010601 execute( TC_ctrl_location() );
10602 }
Harald Welte898113b2018-01-31 18:32:21 +010010603
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +020010604 execute( TC_si_default() );
Neels Hofmeyr66aeba42020-07-06 02:21:21 +020010605 execute( TC_si2quater_2_earfcns() );
10606 execute( TC_si2quater_3_earfcns() );
10607 execute( TC_si2quater_4_earfcns() );
10608 execute( TC_si2quater_5_earfcns() );
10609 execute( TC_si2quater_6_earfcns() );
Neels Hofmeyrad132f22020-07-08 02:20:16 +020010610 execute( TC_si2quater_12_earfcns() );
10611 execute( TC_si2quater_23_earfcns() );
10612 execute( TC_si2quater_32_earfcns() );
10613 execute( TC_si2quater_33_earfcns() );
10614 execute( TC_si2quater_42_earfcns() );
10615 execute( TC_si2quater_48_earfcns() );
10616 execute( TC_si2quater_49_earfcns() );
Pau Espin Pedrol85a84432020-07-20 18:45:03 +020010617 execute( TC_si_acc_rotate() );
Alexander Couzens4ad3a352020-09-10 22:29:12 +020010618 execute( TC_si_acc_ramp_rotate() );
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +020010619
Harald Welte898113b2018-01-31 18:32:21 +010010620 /* RSL DCHAN Channel ACtivation / Deactivation */
Harald Welteae026692017-12-09 01:03:01 +010010621 execute( TC_chan_act_noreply() );
Harald Welte4003d112017-12-09 22:35:39 +010010622 execute( TC_chan_act_counter() );
Harald Welteae026692017-12-09 01:03:01 +010010623 execute( TC_chan_act_ack_noest() );
Philipp Maier9c60a622020-07-09 15:08:46 +020010624 execute( TC_chan_act_ack_noest_emerg() );
Philipp Maier606f07d2020-08-12 17:21:58 +020010625 execute( TC_chan_rqd_emerg_deny() );
Harald Welteae026692017-12-09 01:03:01 +010010626 execute( TC_chan_act_ack_est_ind_noreply() );
10627 execute( TC_chan_act_ack_est_ind_refused() );
Harald Welte618ef642017-12-14 14:58:20 +010010628 execute( TC_chan_act_nack() );
Harald Welte799c97b2017-12-14 17:50:30 +010010629 execute( TC_chan_exhaustion() );
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +070010630 execute( TC_chan_deact_silence() );
Harald Welte4003d112017-12-09 22:35:39 +010010631 execute( TC_chan_rel_rll_rel_ind() );
10632 execute( TC_chan_rel_conn_fail() );
10633 execute( TC_chan_rel_hard_clear() );
Pau Espin Pedrol841b90d2021-04-15 16:42:52 +020010634 execute( TC_chan_rel_last_eutran_plmn_hard_clear_no_csfb() );
10635 execute( TC_chan_rel_last_eutran_plmn_hard_clear_csfb() );
Harald Welte99787102019-02-04 10:41:36 +010010636 execute( TC_chan_rel_hard_clear_csfb() );
Harald Welted8c36cd2017-12-09 23:05:31 +010010637 execute( TC_chan_rel_hard_rlsd() );
Harald Welte550daf92018-06-11 19:22:13 +020010638 execute( TC_chan_rel_hard_rlsd_ms_dead() );
Harald Welte85804d42017-12-10 14:11:58 +010010639 execute( TC_chan_rel_a_reset() );
Pau Espin Pedrolc675b612020-01-09 19:55:40 +010010640 execute( TC_chan_rel_sccp_tiar_timeout() );
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +020010641 execute( TC_chan_rel_rr_cause() );
Harald Welte6f521d82017-12-11 19:52:02 +010010642
Harald Weltecfe2c962017-12-15 12:09:32 +010010643 execute( TC_outbound_connect() );
Harald Welte898113b2018-01-31 18:32:21 +010010644
10645 /* Assignment related */
Harald Welte16a4adf2017-12-14 18:54:01 +010010646 execute( TC_assignment_cic_only() );
Harald Welte235ebf12017-12-15 14:18:16 +010010647 execute( TC_assignment_csd() );
10648 execute( TC_assignment_ctm() );
10649 execute( TC_assignment_sign() );
Pau Espin Pedrol07866632020-09-03 19:10:55 +020010650 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
10651 execute( TC_assignment_aoip_tla_v6() );
10652 }
Harald Welte235ebf12017-12-15 14:18:16 +010010653 execute( TC_assignment_fr_a5_0() );
10654 execute( TC_assignment_fr_a5_1() );
Neels Hofmeyrf246a922020-05-13 02:27:10 +020010655 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welte8f67d1d2018-05-25 20:38:42 +020010656 execute( TC_assignment_fr_a5_1_codec_missing() );
10657 }
Harald Welte235ebf12017-12-15 14:18:16 +010010658 execute( TC_assignment_fr_a5_3() );
Neels Hofmeyr0d8ec532021-06-11 00:09:48 +020010659 execute( TC_assignment_fr_a5_4() );
Neels Hofmeyr0faeb7a2021-06-10 23:59:35 +020010660 execute( TC_assignment_fr_a5_4_fail() );
Neels Hofmeyr04d6e6a2021-06-11 00:10:02 +020010661 execute( TC_assignment_fr_a5_not_sup() );
Harald Welte3c86ea02018-05-10 22:28:05 +020010662 execute( TC_ciph_mode_a5_0() );
10663 execute( TC_ciph_mode_a5_1() );
Oliver Smith50b98122021-07-09 15:00:28 +020010664 execute( TC_ciph_mode_a5_2_0() );
Oliver Smith1dff88d2021-07-09 08:45:51 +020010665 execute( TC_ciph_mode_a5_2_1() );
Harald Welte3c86ea02018-05-10 22:28:05 +020010666 execute( TC_ciph_mode_a5_3() );
Neels Hofmeyr81ad27f2021-06-11 00:09:40 +020010667 execute( TC_ciph_mode_a5_4() );
Harald Welte16a4adf2017-12-14 18:54:01 +010010668
Harald Welte60aa5762018-03-21 19:33:13 +010010669 execute( TC_assignment_codec_fr() );
Neels Hofmeyr559d5d02021-04-16 16:50:49 +020010670 execute( TC_assignment_codec_fr_by_mode_modify() );
Harald Welte60aa5762018-03-21 19:33:13 +010010671 execute( TC_assignment_codec_hr() );
10672 execute( TC_assignment_codec_efr() );
10673 execute( TC_assignment_codec_amr_f() );
10674 execute( TC_assignment_codec_amr_h() );
Philipp Maier8a581d22019-03-26 18:32:48 +010010675
Neels Hofmeyrf246a922020-05-13 02:27:10 +020010676 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Philipp Maier8a581d22019-03-26 18:32:48 +010010677 execute( TC_assignment_codec_amr_f_S1() );
10678 execute( TC_assignment_codec_amr_h_S1() );
10679 execute( TC_assignment_codec_amr_f_S124() );
10680 execute( TC_assignment_codec_amr_h_S124() );
10681 execute( TC_assignment_codec_amr_f_S0() );
10682 execute( TC_assignment_codec_amr_f_S02() );
10683 execute( TC_assignment_codec_amr_f_S024() );
10684 execute( TC_assignment_codec_amr_f_S0247() );
10685 execute( TC_assignment_codec_amr_h_S0() );
10686 execute( TC_assignment_codec_amr_h_S02() );
10687 execute( TC_assignment_codec_amr_h_S024() );
10688 execute( TC_assignment_codec_amr_h_S0247() );
10689 execute( TC_assignment_codec_amr_f_S01234567() );
10690 execute( TC_assignment_codec_amr_f_S0234567() );
10691 execute( TC_assignment_codec_amr_f_zero() );
10692 execute( TC_assignment_codec_amr_f_unsupp() );
10693 execute( TC_assignment_codec_amr_h_S7() );
Neels Hofmeyr21863562020-11-26 00:34:33 +000010694 execute( TC_assignment_codec_amr_f_start_mode_auto() );
10695 execute( TC_assignment_codec_amr_h_start_mode_auto() );
Neels Hofmeyr3eb94562020-11-26 02:40:26 +000010696 execute( TC_assignment_codec_amr_f_start_mode_4() );
10697 execute( TC_assignment_codec_amr_h_start_mode_4() );
Neels Hofmeyr454d7922020-11-26 02:24:57 +000010698 execute( TC_assignment_codec_amr_startmode_cruft() );
Philipp Maier8a581d22019-03-26 18:32:48 +010010699 }
Harald Welte60aa5762018-03-21 19:33:13 +010010700
Philipp Maierac09bfc2019-01-08 13:41:39 +010010701 execute( TC_assignment_codec_fr_exhausted_req_hr() );
10702 execute( TC_assignment_codec_fr_exhausted_req_fr() );
10703 execute( TC_assignment_codec_fr_exhausted_req_fr_hr() );
10704 execute( TC_assignment_codec_fr_exhausted_req_hr_fr() );
10705 execute( TC_assignment_codec_hr_exhausted_req_fr() );
10706 execute( TC_assignment_codec_hr_exhausted_req_hr() );
10707 execute( TC_assignment_codec_hr_exhausted_req_hr_fr() );
10708 execute( TC_assignment_codec_hr_exhausted_req_fr_hr() );
10709 execute( TC_assignment_codec_req_hr_fr() );
10710 execute( TC_assignment_codec_req_fr_hr() );
Pau Espin Pedrol14475352021-07-22 15:48:16 +020010711 execute( TC_assignment_sdcch_exhausted_req_signalling() );
10712 execute( TC_assignment_sdcch_exhausted_req_signalling_tch_forbidden() );
10713 execute( TC_assignment_sdcch_exhausted_req_voice_tch_forbidden() );
Philipp Maierac09bfc2019-01-08 13:41:39 +010010714
Pau Espin Pedrol23510fb2021-07-20 17:00:38 +020010715 execute( TC_assignment_osmux() );
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +020010716
Harald Welte898113b2018-01-31 18:32:21 +010010717 /* RLL Establish Indication on inactive DCHAN / SAPI */
Harald Welte5cd20ed2017-12-13 21:03:20 +010010718 execute( TC_rll_est_ind_inact_lchan() );
10719 execute( TC_rll_est_ind_inval_sapi1() );
10720 execute( TC_rll_est_ind_inval_sapi3() );
10721 execute( TC_rll_est_ind_inval_sacch() );
10722
Vadim Yanitskiy61f784a2020-10-01 21:12:19 +070010723 /* DLCI / RSL Link ID conversion for MO/MT messages on SAPI0/SAPI3 */
10724 execute( TC_tch_dlci_link_id_sapi() );
10725
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +070010726 /* SAPI N Reject triggered by RLL establishment failures */
10727 execute( TC_rll_rel_ind_sapi_n_reject() );
10728 execute( TC_rll_err_ind_sapi_n_reject() );
10729 execute( TC_rll_timeout_sapi_n_reject() );
10730
Harald Welte898113b2018-01-31 18:32:21 +010010731 /* Paging related tests */
Harald Welte6f521d82017-12-11 19:52:02 +010010732 execute( TC_paging_imsi_nochan() );
10733 execute( TC_paging_tmsi_nochan() );
10734 execute( TC_paging_tmsi_any() );
10735 execute( TC_paging_tmsi_sdcch() );
10736 execute( TC_paging_tmsi_tch_f() );
10737 execute( TC_paging_tmsi_tch_hf() );
10738 execute( TC_paging_imsi_nochan_cgi() );
10739 execute( TC_paging_imsi_nochan_lac_ci() );
10740 execute( TC_paging_imsi_nochan_ci() );
10741 execute( TC_paging_imsi_nochan_lai() );
10742 execute( TC_paging_imsi_nochan_lac() );
10743 execute( TC_paging_imsi_nochan_all() );
Harald Welte751d3eb2018-01-31 15:51:06 +010010744 execute( TC_paging_imsi_nochan_plmn_lac_rnc() );
10745 execute( TC_paging_imsi_nochan_rnc() );
10746 execute( TC_paging_imsi_nochan_lac_rnc() );
10747 execute( TC_paging_imsi_nochan_lacs() );
10748 execute( TC_paging_imsi_nochan_lacs_empty() );
Stefan Sperling049a86e2018-03-20 15:51:00 +010010749 execute( TC_paging_imsi_nochan_cgi_unknown_cid() );
Harald Welte10985002017-12-12 09:29:15 +010010750 execute( TC_paging_imsi_a_reset() );
Harald Weltee65d40e2017-12-13 00:09:06 +010010751 execute( TC_paging_imsi_load() );
Philipp Maier779a7922018-02-16 11:00:37 +010010752 execute( TC_paging_counter() );
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +010010753 execute( TC_paging_resp_unsol() );
Harald Welte4e9b9cc2017-12-14 18:31:02 +010010754
10755 execute( TC_rsl_drop_counter() );
Stefan Sperling830dc9d2018-02-12 21:08:28 +010010756 execute( TC_rsl_unknown_unit_id() );
10757
10758 execute( TC_oml_unknown_unit_id() );
Harald Welte898113b2018-01-31 18:32:21 +010010759
10760 execute( TC_classmark() );
Harald Welteeddf0e92020-06-21 19:42:15 +020010761 execute( TC_common_id() );
Harald Welte898113b2018-01-31 18:32:21 +010010762 execute( TC_unsol_ass_fail() );
Harald Welteea99a002018-01-31 20:46:43 +010010763 execute( TC_unsol_ass_compl() );
Harald Weltefbf9b5e2018-01-31 20:41:23 +010010764 execute( TC_unsol_ho_fail() );
Harald Weltee3bd6582018-01-31 22:51:25 +010010765 execute( TC_err_82_short_msg() );
Harald Weltee9e02e42018-01-31 23:36:25 +010010766 execute( TC_err_84_unknown_msg() );
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +010010767
Harald Welte261af4b2018-02-12 21:20:39 +010010768 execute( TC_ho_int() );
Neels Hofmeyraf88d9d2021-06-21 02:14:27 +020010769 execute( TC_ho_int_a5_0() );
10770 execute( TC_ho_int_a5_1() );
10771 execute( TC_ho_int_a5_3() );
10772 execute( TC_ho_int_a5_4() );
Neels Hofmeyr5f144212020-11-03 15:41:58 +000010773 execute( TC_ho_int_radio_link_failure() );
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +010010774
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +010010775 execute( TC_ho_out_of_this_bsc() );
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +020010776 execute( TC_ho_out_fail_no_msc_response() );
10777 execute( TC_ho_out_fail_rr_ho_failure() );
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +020010778 execute( TC_ho_out_fail_no_result_after_ho_cmd() );
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +010010779
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +010010780 execute( TC_ho_into_this_bsc() );
Neels Hofmeyr8ebf19c2021-06-21 05:24:01 +020010781 execute( TC_ho_into_this_bsc_a5_0() );
10782 execute( TC_ho_into_this_bsc_a5_1() );
10783 execute( TC_ho_into_this_bsc_a5_3() );
10784 execute( TC_ho_into_this_bsc_a5_4() );
Pau Espin Pedrol07866632020-09-03 19:10:55 +020010785 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
10786 execute( TC_ho_into_this_bsc_tla_v6() );
10787 }
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +020010788 execute( TC_srvcc_eutran_to_geran() );
Pau Espin Pedrol35801c32021-04-19 13:03:20 +020010789 execute( TC_srvcc_eutran_to_geran_ho_out() );
Pau Espin Pedrol9ae36d52021-06-15 17:29:43 +020010790 execute( TC_srvcc_eutran_to_geran_forbid_fast_return() );
10791 execute( TC_srvcc_eutran_to_geran_ho_out_forbid_fast_return() );
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +010010792 execute( TC_ho_in_fail_msc_clears() );
10793 execute( TC_ho_in_fail_msc_clears_after_ho_detect() );
10794 execute( TC_ho_in_fail_no_detect() );
10795 execute( TC_ho_in_fail_no_detect2() );
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +010010796
Neels Hofmeyr91401012019-07-11 00:42:35 +020010797 execute( TC_ho_neighbor_config_1() );
10798 execute( TC_ho_neighbor_config_2() );
10799 execute( TC_ho_neighbor_config_3() );
10800 execute( TC_ho_neighbor_config_4() );
10801 execute( TC_ho_neighbor_config_5() );
10802 execute( TC_ho_neighbor_config_6() );
10803 execute( TC_ho_neighbor_config_7() );
10804
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +010010805 execute( TC_bssap_rlsd_does_not_cause_bssmap_reset() );
Neels Hofmeyr4ff93282018-03-12 04:25:35 +010010806 execute( TC_bssmap_clear_does_not_cause_bssmap_reset() );
Neels Hofmeyrfd445c32018-03-09 15:39:31 +010010807 execute( TC_ms_rel_ind_does_not_cause_bssmap_reset() );
Harald Welte94e0c342018-04-07 11:33:23 +020010808
10809 execute( TC_dyn_pdch_ipa_act_deact() );
10810 execute( TC_dyn_pdch_ipa_act_nack() );
10811 execute( TC_dyn_pdch_osmo_act_deact() );
10812 execute( TC_dyn_pdch_osmo_act_nack() );
Pau Espin Pedrole076b3f2021-07-20 16:45:57 +020010813 if (mp_enable_dyn_sdcch8_test) {
10814 execute( TC_dyn_ts_sdcch8_act_deact() );
Neels Hofmeyre1a7c4d2021-10-23 23:13:01 +020010815 execute( TC_dyn_ts_sdcch8_all_subslots_used() );
Vadim Yanitskiy07e4b632021-10-12 14:04:45 +030010816 execute( TC_dyn_ts_sdcch8_tch_call_act_deact() );
Pau Espin Pedrole076b3f2021-07-20 16:45:57 +020010817 execute( TC_dyn_ts_sdcch8_act_nack() );
10818 }
Harald Welte99f3ca02018-06-14 13:40:29 +020010819
Stefan Sperling0796a822018-10-05 13:01:39 +020010820 execute( TC_chopped_ipa_ping() );
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +020010821 execute( TC_chopped_ipa_payload() );
Stefan Sperling0796a822018-10-05 13:01:39 +020010822
Pau Espin Pedrol8f773632019-11-05 11:46:53 +010010823 /* Power control related */
10824 execute( TC_assignment_verify_ms_power_params_ie() );
Vadim Yanitskiy4b233042021-06-30 00:58:43 +020010825 execute( TC_c0_power_red_mode() );
Neels Hofmeyr4f118412020-06-04 15:25:10 +020010826
10827 /* MSC pooling */
10828 /* FIXME: in SCCPlite, indicating how many MSCs should be connected does currently not work. Since
10829 * RESET->RESET-ACK is unconditionally negotiated for all configured MSCs, they always all appear as connected
10830 * to osmo-bsc. The MSC pooling tests however require disconnecting selected MSCs, and hence don't work out as
10831 * intended on SCCPlite. So for now, run these only for SCCP/M3UA. */
10832 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
10833 execute( TC_mscpool_L3Compl_on_1_msc() );
10834 execute( TC_mscpool_L3Complete_by_imsi_round_robin() );
10835 execute( TC_mscpool_LU_by_tmsi_null_nri_0_round_robin() );
10836 execute( TC_mscpool_LU_by_tmsi_null_nri_1_round_robin() );
10837 execute( TC_mscpool_L3Complete_by_tmsi_unassigned_nri_round_robin() );
10838 execute( TC_mscpool_L3Complete_by_tmsi_valid_nri_msc_not_connected_round_robin() );
10839 execute( TC_mscpool_L3Complete_by_tmsi_valid_nri_1() );
10840 execute( TC_mscpool_L3Complete_by_tmsi_valid_nri_2() );
10841 execute( TC_mscpool_LU_by_tmsi_from_other_PLMN() );
10842 execute( TC_mscpool_paging_and_response_imsi() );
10843 execute( TC_mscpool_paging_and_response_tmsi() );
10844 execute( TC_mscpool_no_allow_attach_round_robin() );
10845 execute( TC_mscpool_no_allow_attach_valid_nri() );
10846 }
10847
Harald Welte99f3ca02018-06-14 13:40:29 +020010848 execute( TC_early_conn_fail() );
10849 execute( TC_late_conn_fail() );
Oliver Smithaf03bef2021-08-24 15:34:51 +020010850 execute( TC_stats_conn_fail() );
Harald Welte99f3ca02018-06-14 13:40:29 +020010851
Philipp Maier783681c2020-07-16 16:47:06 +020010852 /* Emergency call handling (deny / allow) */
10853 execute( TC_assignment_emerg_setup_allow() );
10854 execute( TC_assignment_emerg_setup_deny_msc() );
10855 execute( TC_assignment_emerg_setup_deny_bts() );
Philipp Maier82812002020-08-13 18:48:27 +020010856 execute( TC_emerg_premption() );
10857
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +070010858 /* Frequency hopping parameters handling */
10859 execute( TC_fh_params_chan_activ() );
10860 execute( TC_fh_params_imm_ass() );
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +070010861 execute( TC_fh_params_assignment_cmd() );
Vadim Yanitskiy8f5430d2020-09-02 18:51:38 +070010862 execute( TC_fh_params_handover_cmd() );
Vadim Yanitskiyca974032020-09-01 07:20:39 +070010863 execute( TC_fh_params_si4_cbch() );
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +020010864
10865 if (mp_enable_lcs_tests) {
10866 execute( TC_lcs_loc_req_for_active_ms() );
10867 execute( TC_lcs_loc_req_for_active_ms_ta_req() );
10868 execute( TC_lcs_loc_req_for_idle_ms() );
10869 execute( TC_lcs_loc_req_no_subscriber() );
10870 execute( TC_lcs_loc_req_for_active_ms_le_timeout() );
10871 execute( TC_lcs_loc_req_for_active_ms_le_timeout2() );
10872 execute( TC_lcs_loc_req_for_idle_ms_no_pag_resp() );
10873 execute( TC_cm_service_during_lcs_loc_req() );
10874 execute( TC_ho_during_lcs_loc_req() );
10875 }
Neels Hofmeyrbf037052020-10-28 22:52:02 +000010876
10877 execute( TC_no_msc() );
Neels Hofmeyr87857ec2021-04-25 16:17:47 +000010878
10879 execute( TC_refuse_chan_act_to_vamos() );
10880 execute( TC_refuse_mode_modif_to_vamos() );
Neels Hofmeyrd2d9f332021-04-28 22:23:36 +000010881
10882 execute( TC_reassignment_fr() );
Neels Hofmeyrfeda88e2021-07-19 13:51:29 +020010883
10884 execute( TC_cm_reestablishment() );
Neels Hofmeyrb07b2952021-08-07 04:23:14 +020010885
10886 execute( TC_imm_ass_post_chan_ack() );
10887 execute( TC_imm_ass_pre_chan_ack() );
Neels Hofmeyr23158742021-09-07 19:08:07 +020010888 execute( TC_imm_ass_pre_ts_ack() );
Neels Hofmeyr7a6d0602021-08-07 04:23:50 +020010889 execute( TC_imm_ass_pre_chan_ack_dyn_ts() );
Neels Hofmeyrc8b95c12021-08-07 04:24:02 +020010890 execute( TC_imm_ass_pre_ts_ack_dyn_ts() );
Neels Hofmeyr5d7d13f2021-09-07 14:44:36 +020010891
10892 execute( TC_ctrl_trx_rf_locked() );
Neels Hofmeyr92cfa1c2021-09-28 18:29:44 +020010893
Neels Hofmeyrbd94fe72021-10-26 22:04:53 +020010894 execute( TC_ratectr_all_available_allocated() );
10895 execute( TC_ratectr_all_available_allocated_dyn() );
10896
Neels Hofmeyr92cfa1c2021-09-28 18:29:44 +020010897 execute( TC_lost_sdcch_during_assignment() );
Harald Welte28d943e2017-11-25 15:00:50 +010010898}
10899
10900}