blob: 22df0cb64e12a3f2cd9288348771d5e42266787d [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 Pedrol8f30ccd2019-11-01 17:30:57 +0100708 /* Value set in osmo-bsc.cfg "ms max power" */
709 uint8_t mp_exp_ms_power_level := 7;
Harald Weltea4ca4462018-02-09 00:17:14 +0100710}
711
Neels Hofmeyr9f3e6ac2021-04-08 23:09:24 +0200712friend function f_gen_test_hdlr_pars(integer bssap_idx := 0) return TestHdlrParams {
Philipp Maier48604732018-10-09 15:00:37 +0200713
714 var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200715 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Philipp Maier48604732018-10-09 15:00:37 +0200716 pars.aoip := true;
717 } else {
718 pars.aoip := false;
719 }
Pau Espin Pedrol8f30ccd2019-11-01 17:30:57 +0100720 pars.exp_ms_power_level := mp_exp_ms_power_level;
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200721 pars.mscpool.bssap_idx := bssap_idx;
Neels Hofmeyrbf720202021-10-02 12:58:24 +0200722 pars.expect_tsc := BTS_TSC[0];
Neels Hofmeyrb5b7a6e2021-06-04 19:03:45 +0200723
Philipp Maier48604732018-10-09 15:00:37 +0200724 return pars;
725}
726
Neels Hofmeyr22c3f792020-06-17 02:49:28 +0200727/* Convenience functions for rate counters using g_ctr_msc. */
728
729private function f_ctrs_msc_init(integer mscs_count := NUM_MSC, CounterNameVals counternames := counternames_msc_mscpool) runs on test_CT {
730 g_ctr_msc := f_counter_name_vals_get_n(IPA_CTRL, "msc", mscs_count, counternames);
731 log("initial msc rate counters: ", g_ctr_msc);
732}
733
734private function f_ctrs_msc_add(integer msc_nr, charstring countername, integer val := 1) runs on test_CT {
Neels Hofmeyr9656e922020-06-30 01:27:01 +0200735 f_counter_name_vals_list_add(g_ctr_msc, msc_nr, countername, val);
Neels Hofmeyr22c3f792020-06-17 02:49:28 +0200736}
737
738/* f_ctrs_msc_init();
739 * f_do_thing(on_msc := 0);
740 * f_do_thing(on_msc := 0);
741 * f_do_other(on_msc := 1);
742 * f_ctrs_msc_add(0, "thing", 2);
743 * f_ctrs_msc_add(1, "other");
744 * f_ctrs_msc_verify();
745 */
746private function f_ctrs_msc_verify() runs on test_CT {
747 log("verifying msc rate counters: ", g_ctr_msc);
748 f_counter_name_vals_expect_n(IPA_CTRL, "msc", g_ctr_msc);
749}
750
751/* convenience: f_ctrs_msc_add() and f_ctrs_msc_verify() in one call.
752 * f_ctrs_msc_init();
753 * f_do_thing(on_msc := 0);
754 * f_do_thing(on_msc := 0);
755 * f_do_thing(on_msc := 0);
756 * f_ctrs_msc_expect(0, "thing", 3);
757 */
758private function f_ctrs_msc_expect(integer msc_nr, charstring countername, integer val := 1) runs on test_CT {
759 f_ctrs_msc_add(msc_nr, countername, val);
760 f_ctrs_msc_verify();
761}
762
Neels Hofmeyr12941bd2020-08-29 03:21:26 +0000763/* Convenience functions for rate counters using g_ctr_bts, always also including g_ctr_bsc. */
764
Neels Hofmeyrb7581872021-11-07 14:02:49 +0100765private function f_ctrs_bts_init(integer bts_count := NUM_BTS, CounterNameVals counternames := counternames_bsc_bts_handover) runs on test_CT {
Neels Hofmeyr12941bd2020-08-29 03:21:26 +0000766 g_ctr_bts := f_counter_name_vals_get_n(IPA_CTRL, "bts", bts_count, counternames);
Neels Hofmeyr4dec8cc2021-11-29 15:59:44 +0100767 log("initial bts rate counters: ", g_ctr_bts);
Neels Hofmeyrb7581872021-11-07 14:02:49 +0100768}
769
770function f_ctrs_bsc_and_bts_init(integer bts_count := NUM_BTS, CounterNameVals counternames := counternames_bsc_bts_handover) runs on test_CT {
771 f_ctrs_bts_init(bts_count, counternames);
Neels Hofmeyr12941bd2020-08-29 03:21:26 +0000772 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;
Neels Hofmeyr4dec8cc2021-11-29 15:59:44 +0100777 f_ctrs_bts_init(bts_count, bts_names);
Neels Hofmeyrac432fa2021-11-02 16:45:56 +0100778 f_ctrs_bsc_init(counternames_bsc_bts_handover);
779}
780
781private function f_ctrs_bts_add(integer bts_nr, charstring countername, integer val := 1) runs on test_CT {
Neels Hofmeyr12941bd2020-08-29 03:21:26 +0000782 f_counter_name_vals_list_add(g_ctr_bts, bts_nr, countername, val);
Neels Hofmeyrac432fa2021-11-02 16:45:56 +0100783}
784
785private function f_ctrs_bsc_and_bts_add(integer bts_nr, charstring countername, integer val := 1) runs on test_CT {
786 f_ctrs_bts_add(bts_nr, countername, val);
Neels Hofmeyr12941bd2020-08-29 03:21:26 +0000787 f_ctrs_bsc_add(countername, val);
788}
789
Neels Hofmeyrb7581872021-11-07 14:02:49 +0100790function f_ctrs_bts_verify() runs on test_CT {
791 f_counter_name_vals_expect_n(IPA_CTRL, "bts", g_ctr_bts);
792}
793
Neels Hofmeyr12941bd2020-08-29 03:21:26 +0000794/* f_ctrs_bsc_and_bts_init();
795 * f_do_thing(on_bts := 0);
796 * f_do_thing(on_bts := 0);
797 * f_do_other(on_bts := 1);
798 * f_ctrs_bsc_and_bts_add(0, "thing", 2);
799 * f_ctrs_bsc_and_bts_add(1, "other");
800 * f_ctrs_bsc_and_bts_verify();
801 */
802private function f_ctrs_bsc_and_bts_verify() runs on test_CT {
Neels Hofmeyrb7581872021-11-07 14:02:49 +0100803 f_ctrs_bts_verify();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +0000804 f_ctrs_bsc_verify();
805}
806
807/* convenience: f_ctrs_bsc_and_bts_add() and f_ctrs_bsc_and_bts_verify() in one call.
808 * f_ctrs_bsc_and_bts_init();
809 * f_do_thing(on_bts := 0);
810 * f_do_thing(on_bts := 0);
811 * f_do_thing(on_bts := 0);
812 * f_ctrs_bsc_and_bts_expect(0, "thing", 3);
813 */
814private function f_ctrs_bsc_and_bts_expect(integer bts_nr, charstring countername, integer val := 1) runs on test_CT {
815 f_ctrs_bsc_and_bts_add(bts_nr, countername, val);
816 f_ctrs_bsc_and_bts_verify();
817}
818
819
820/* Convenience functions for rate counters using g_ctr_bsc. */
821
822private function f_ctrs_bsc_init(CounterNameVals counternames := counternames_bsc_bts_handover) runs on test_CT {
823 g_ctr_bsc := f_counter_name_vals_get_n(IPA_CTRL, "bsc", 1, counternames);
824 log("initial bsc rate counters: ", g_ctr_bsc);
825}
826
827private function f_ctrs_bsc_add(charstring countername, integer val := 1) runs on test_CT {
828 f_counter_name_vals_list_add(g_ctr_bsc, 0, countername, val);
829}
830
831/* f_ctrs_bsc_init();
832 * f_do_thing();
833 * f_do_thing();
834 * f_do_other();
835 * f_ctrs_bsc_add("thing", 2);
836 * f_ctrs_bsc_add("other");
837 * f_ctrs_bsc_verify();
838 */
839private function f_ctrs_bsc_verify() runs on test_CT {
840 f_counter_name_vals_expect_n(IPA_CTRL, "bsc", g_ctr_bsc);
841}
842
843/* convenience: f_ctrs_bsc_add() and f_ctrs_bsc_verify() in one call.
844 * f_ctrs_bsc_init();
845 * f_do_thing();
846 * f_ctrs_bsc_expect("thing", 1);
847 */
848private function f_ctrs_bsc_expect(charstring countername, integer val := 1) runs on test_CT {
849 f_ctrs_bsc_add(countername, val);
850 f_ctrs_bsc_verify();
851}
852
Neels Hofmeyr22c3f792020-06-17 02:49:28 +0200853
Neels Hofmeyr9f3e6ac2021-04-08 23:09:24 +0200854friend function f_shutdown_helper() runs on test_CT {
Daniel Willmann637ef6c2018-07-25 10:49:09 +0200855 all component.stop;
Philipp Maier282ca4b2018-02-27 17:17:00 +0100856 setverdict(pass);
Daniel Willmannafce8662018-07-06 23:11:32 +0200857 mtc.stop;
Philipp Maier282ca4b2018-02-27 17:17:00 +0100858}
859
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200860private function f_legacy_bssap_reset(integer bssap_idx := 0) runs on test_CT {
Harald Weltea4ca4462018-02-09 00:17:14 +0100861 var BSSAP_N_UNITDATA_ind ud_ind;
Pau Espin Pedrol24c05992020-09-01 12:54:12 +0200862 var boolean reset_received := false;
Harald Weltea4ca4462018-02-09 00:17:14 +0100863 timer T := 5.0;
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200864 BSSAP.send(ts_BSSAP_UNITDATA_req(g_bssap[bssap_idx].sccp_addr_peer, g_bssap[bssap_idx].sccp_addr_own,
865 ts_BSSMAP_Reset(0, g_osmux_enabled)));
Harald Weltea4ca4462018-02-09 00:17:14 +0100866 T.start;
867 alt {
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200868 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(g_bssap[bssap_idx].sccp_addr_own, g_bssap[bssap_idx].sccp_addr_peer,
869 tr_BSSMAP_ResetAck(g_osmux_enabled))) {
Neels Hofmeyr4f5d7be2020-10-16 16:28:16 +0200870 log("BSSMAP: Received RESET-ACK in response to RESET, we're ready to go!");
Harald Weltea4ca4462018-02-09 00:17:14 +0100871 }
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200872 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset(g_osmux_enabled))) -> value ud_ind {
Neels Hofmeyr4f5d7be2020-10-16 16:28:16 +0200873 log("BSSMAP: Respoding to inbound RESET with RESET-ACK");
Harald Weltea4ca4462018-02-09 00:17:14 +0100874 BSSAP.send(ts_BSSAP_UNITDATA_req(ud_ind.callingAddress, ud_ind.calledAddress,
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200875 ts_BSSMAP_ResetAck(g_osmux_enabled)));
Pau Espin Pedrol24c05992020-09-01 12:54:12 +0200876 reset_received := true;
Harald Weltea4ca4462018-02-09 00:17:14 +0100877 repeat;
878 }
879 [] BSSAP.receive { repeat; }
Pau Espin Pedrol24c05992020-09-01 12:54:12 +0200880 [] T.timeout {
Neels Hofmeyr4f5d7be2020-10-16 16:28:16 +0200881 log("BSSMAP: Timeout waiting for RESET-ACK after sending RESET");
Pau Espin Pedrol24c05992020-09-01 12:54:12 +0200882 /* If we received a RESET after ours was sent, it
883 may be a race condition where the other peer beacame
884 available after we sent it, but we are in a desired
885 state anyway, so go forward. */
886 if (not reset_received) {
887 setverdict(fail);
888 }
889 }
Harald Weltea4ca4462018-02-09 00:17:14 +0100890 }
Harald Welte28d943e2017-11-25 15:00:50 +0100891}
892
Harald Welteae026692017-12-09 01:03:01 +0100893type record IPA_Client {
Harald Welte21b46bd2017-12-17 19:46:32 +0100894 /* IPA Emulation component reference */
Harald Welteae026692017-12-09 01:03:01 +0100895 IPA_Emulation_CT vc_IPA,
Harald Welte21b46bd2017-12-17 19:46:32 +0100896 /* Unit-ID and other CCM parameters to use for IPA client emulation */
Harald Welteae026692017-12-09 01:03:01 +0100897 IPA_CCM_Parameters ccm_pars,
Harald Welte21b46bd2017-12-17 19:46:32 +0100898 /* String identifier for this IPA Client */
Harald Welte624f9632017-12-16 19:26:04 +0100899 charstring id,
Harald Welte21b46bd2017-12-17 19:46:32 +0100900 /* Associated RSL Emulation Component (if any). Only used in "Handler mode" */
Harald Welte624f9632017-12-16 19:26:04 +0100901 RSL_Emulation_CT vc_RSL optional
Harald Welte28d943e2017-11-25 15:00:50 +0100902}
903
Harald Welte21b46bd2017-12-17 19:46:32 +0100904/*! Start the IPA/RSL related bits for one IPA_Client.
905 * \param clnt IPA_Client for which to establish
906 * \param bsc_host IP address / hostname of the BSC
907 * \param bsc_port TCP port number of the BSC
908 * \param i number identifying this BTS
909 * \param handler_mode Start an RSL_Emulation_CT component (true) or not (false) */
Harald Welte624f9632017-12-16 19:26:04 +0100910function f_ipa_rsl_start(inout IPA_Client clnt, charstring bsc_host, PortNumber bsc_port, integer i,
911 boolean handler_mode := false)
Harald Welte28d943e2017-11-25 15:00:50 +0100912runs on test_CT {
Harald Welteae026692017-12-09 01:03:01 +0100913 timer T := 10.0;
914
Harald Welte96c94412017-12-09 03:12:45 +0100915 clnt.id := "IPA" & int2str(i) & "-RSL";
Harald Welteae026692017-12-09 01:03:01 +0100916 clnt.vc_IPA := IPA_Emulation_CT.create(clnt.id & "-IPA");
917 clnt.ccm_pars := c_IPA_default_ccm_pars;
918 clnt.ccm_pars.name := "Osmocom TTCN-3 BTS Simulator";
919 clnt.ccm_pars.unit_id := int2str(1234+i) & "/0/0";
Harald Welte624f9632017-12-16 19:26:04 +0100920 if (handler_mode) {
921 clnt.vc_RSL := RSL_Emulation_CT.create(clnt.id & "-RSL");
Harald Welte89ab1912018-02-23 18:56:29 +0100922 connect(clnt.vc_RSL:CCHAN_PT, self:RSL_CCHAN[i]);
Harald Welte624f9632017-12-16 19:26:04 +0100923 }
Harald Welteae026692017-12-09 01:03:01 +0100924
925 map(clnt.vc_IPA:IPA_PORT, system:IPA_CODEC_PT);
Harald Welte624f9632017-12-16 19:26:04 +0100926 if (handler_mode) {
927 connect(clnt.vc_IPA:IPA_RSL_PORT, clnt.vc_RSL:IPA_PT);
928 } else {
929 connect(clnt.vc_IPA:IPA_RSL_PORT, self:IPA_RSL[i]);
930 }
Harald Welteae026692017-12-09 01:03:01 +0100931
Harald Welte5d1a2202017-12-13 19:51:29 +0100932 clnt.vc_IPA.start(IPA_Emulation.main_client(bsc_host, bsc_port, "", 10000+i, clnt.ccm_pars));
Harald Welte624f9632017-12-16 19:26:04 +0100933 if (handler_mode) {
934 clnt.vc_RSL.start(RSL_Emulation.main());
935 return;
936 }
Harald Welteae026692017-12-09 01:03:01 +0100937
938 /* wait for IPA RSL link to connect and send ID ACK */
939 T.start;
940 alt {
Vadim Yanitskiya2afacc2020-05-18 21:16:19 +0700941 [] IPA_RSL[i].receive(tr_ASP_IPA_EV(ASP_IPA_EVENT_ID_ACK)) {
Harald Welteae026692017-12-09 01:03:01 +0100942 T.stop;
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +0700943 IPA_RSL[i].send(ts_ASP_RSL_UD(ts_RSL_PAGING_LOAD_IND(23)));
Harald Welteae026692017-12-09 01:03:01 +0100944 }
Harald Welte60e823a2017-12-10 14:10:59 +0100945 [] IPA_RSL[i].receive(ASP_IPA_Event:?) { repeat }
Harald Welteae026692017-12-09 01:03:01 +0100946 [] IPA_RSL[i].receive { repeat }
947 [] T.timeout {
Harald Welte96c94412017-12-09 03:12:45 +0100948 setverdict(fail, "Timeout RSL waiting for ASP_IPA_EVENT_ID_ACK");
Daniel Willmannafce8662018-07-06 23:11:32 +0200949 mtc.stop;
Harald Welteae026692017-12-09 01:03:01 +0100950 }
951 }
952}
953
Harald Welte12055472018-03-17 20:10:08 +0100954function f_ipa_rsl_stop(inout IPA_Client clnt) runs on test_CT {
955 if (not isbound(clnt) or not isbound(clnt.vc_IPA)) {
956 return;
957 }
958 clnt.vc_IPA.stop;
959 if (isbound(clnt.vc_RSL)) {
960 clnt.vc_RSL.stop;
961 }
962}
963
Harald Welte21b46bd2017-12-17 19:46:32 +0100964/* Wait for the OML connection to be brought up by the external osmo-bts-omldummy */
Harald Weltea5d2ab22017-12-09 14:21:42 +0100965function f_wait_oml(integer bts_nr, charstring status, float secs_max) runs on test_CT {
966 timer T := secs_max;
967 T.start;
968 while (true) {
969 if (f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-connection-state") == status) {
970 T.stop;
Harald Weltebd868bd2017-12-10 18:28:40 +0100971 /* the 'degraded' state exists from OML connection time, and we have to wait
972 * until all MO's are initialized */
973 T.start(1.0);
974 T.timeout;
Harald Weltea5d2ab22017-12-09 14:21:42 +0100975 return;
976 }
Harald Weltef0d6ac62017-12-17 17:02:21 +0100977 f_sleep(0.1);
Harald Weltea5d2ab22017-12-09 14:21:42 +0100978 if (not T.running) {
Max99253902018-11-16 17:57:39 +0100979 setverdict(fail, "Timeout waiting for BTS" & int2str(bts_nr) & " oml-connection-state ", status);
Daniel Willmannafce8662018-07-06 23:11:32 +0200980 mtc.stop;
Harald Weltea5d2ab22017-12-09 14:21:42 +0100981 }
982 }
983}
984
Harald Welte21b46bd2017-12-17 19:46:32 +0100985/* global altstep for global guard timer; also takes care of responding RESET witH RESET-ACK */
Harald Welteae026692017-12-09 01:03:01 +0100986altstep as_Tguard() runs on test_CT {
Harald Welte60e823a2017-12-10 14:10:59 +0100987 var BSSAP_N_UNITDATA_ind ud_ind;
Neels Hofmeyrcc3f76a2018-03-12 01:43:25 +0100988 [] T_guard.timeout {
989 setverdict(fail, "Timeout of T_guard");
Daniel Willmannafce8662018-07-06 23:11:32 +0200990 mtc.stop;
Neels Hofmeyrcc3f76a2018-03-12 01:43:25 +0100991 }
Harald Welte60e823a2017-12-10 14:10:59 +0100992 /* always respond with RESET ACK to RESET */
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200993 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset(g_osmux_enabled))) -> value ud_ind {
Harald Welte60e823a2017-12-10 14:10:59 +0100994 BSSAP.send(ts_BSSAP_UNITDATA_req(ud_ind.callingAddress, ud_ind.calledAddress,
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200995 ts_BSSMAP_ResetAck(g_osmux_enabled)));
Harald Welte69c1c262017-12-13 21:02:08 +0100996 repeat;
Harald Welte60e823a2017-12-10 14:10:59 +0100997 }
Harald Welte28d943e2017-11-25 15:00:50 +0100998}
999
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01001000altstep no_bssmap_reset() runs on test_CT {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001001 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset(g_osmux_enabled))) {
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01001002 setverdict(fail, "unexpected BSSMAP Reset");
Daniel Willmannafce8662018-07-06 23:11:32 +02001003 mtc.stop;
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01001004 }
1005}
1006
Daniel Willmann191e0d92018-01-17 12:44:35 +01001007function f_init_mgcp(charstring id) runs on test_CT {
1008 id := id & "-MGCP";
1009
1010 var MGCPOps ops := {
1011 create_cb := refers(MGCP_Emulation.ExpectedCreateCallback),
1012 unitdata_cb := refers(MGCP_Emulation.DummyUnitdataCallback)
1013 };
1014 var MGCP_conn_parameters mgcp_pars := {
1015 callagent_ip := mp_bsc_ip,
Harald Welte9e4273e2018-01-29 22:01:22 +01001016 callagent_udp_port := -1,
Daniel Willmann191e0d92018-01-17 12:44:35 +01001017 mgw_ip := mp_test_ip,
Pau Espin Pedrol1a026a52019-06-18 17:21:52 +02001018 mgw_udp_port := 2427,
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02001019 /* Enable it for SCCPlite, since we have 2 MGCP sockets towards MGW (UDP one +
1020 the on with MGCP over IPA forwarded from MSC one) */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001021 multi_conn_mode := (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_SCCPlite_SERVER)
Daniel Willmann191e0d92018-01-17 12:44:35 +01001022 };
1023
1024 vc_MGCP := MGCP_Emulation_CT.create(id);
1025 vc_MGCP.start(MGCP_Emulation.main(ops, mgcp_pars, id));
1026}
1027
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001028/* Enable or disable (current default) Osmux. When enabling, BSSMAP Reset
1029 * contains extra IE (OsmuxSupport) and osmo-bsc will handle AssignReq with
1030 * OsmuxCID IE.
1031 */
1032private function f_vty_allow_osmux(boolean allow) runs on test_CT {
1033 f_vty_enter_cfg_msc(BSCVTY, 0);
1034 if (allow) {
1035 f_vty_transceive(BSCVTY, "osmux on");
1036 } else {
1037 f_vty_transceive(BSCVTY, "osmux off");
1038 }
1039 f_vty_transceive(BSCVTY, "exit");
1040 f_vty_transceive(BSCVTY, "exit");
1041 g_osmux_enabled := allow;
1042}
1043
Max2253c0b2018-11-06 19:28:05 +01001044function f_init_vty(charstring id := "foo") runs on test_CT {
Harald Welte94e0c342018-04-07 11:33:23 +02001045 if (BSCVTY.checkstate("Mapped")) {
1046 /* skip initialization if already executed once */
1047 return;
1048 }
Harald Weltebc03c762018-02-12 18:09:38 +01001049 map(self:BSCVTY, system:BSCVTY);
1050 f_vty_set_prompts(BSCVTY);
1051 f_vty_transceive(BSCVTY, "enable");
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01001052 f_cs7_inst_0_cfg(BSCVTY, {"sccp-timer ias " & int2str(g_bsc_sccp_timer_ias),
1053 "sccp-timer iar " & int2str(g_bsc_sccp_timer_iar)});
Harald Weltebc03c762018-02-12 18:09:38 +01001054}
1055
Neels Hofmeyr9f3e6ac2021-04-08 23:09:24 +02001056friend function f_logp(TELNETasp_PT pt, charstring log_msg)
Neels Hofmeyr4f118412020-06-04 15:25:10 +02001057{
1058 // log on TTCN3 log output
1059 log(log_msg);
1060 // log in stderr log
Neels Hofmeyr767548a2020-08-09 20:26:07 +00001061 f_vty_transceive(pt, "logp lglobal notice TTCN3 f_logp(): " & log_msg);
Neels Hofmeyr4f118412020-06-04 15:25:10 +02001062}
1063
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02001064private function f_sysinfo_seen(integer rsl_idx, RSL_Message rsl) runs on test_CT
1065{
1066 if (rsl_idx >= lengthof(g_system_information)) {
1067 g_system_information[rsl_idx] := SystemInformationConfig_omit
1068 }
1069 f_sysinfo_dec_raw(g_system_information[rsl_idx], rsl);
1070}
1071
1072altstep as_catch_RSL_sysinfo(integer rsl_idx) runs on test_CT {
1073 var ASP_RSL_Unitdata rx_rsl_ud;
1074
1075 /* For handler_mode := false, receiving the RSL bootstrap messages directly on IPA_RSL */
1076 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_NO_BCCH_INFO)) -> value rx_rsl_ud {
1077 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1078 repeat;
1079 }
1080 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_BCCH_INFO)) -> value rx_rsl_ud {
1081 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1082 repeat;
1083 }
1084 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_NO_SACCH_FILL)) -> value rx_rsl_ud {
1085 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1086 repeat;
1087 }
1088 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_SACCH_FILL)) -> value rx_rsl_ud {
1089 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1090 repeat;
1091 }
1092
1093 /* For handler_mode := true, receiving the RSL bootstrap messages via RSL_Emulation */
1094 [] RSL_CCHAN[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_NO_BCCH_INFO)) -> value rx_rsl_ud {
1095 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1096 repeat;
1097 }
1098 [] RSL_CCHAN[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_BCCH_INFO)) -> value rx_rsl_ud {
1099 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1100 repeat;
1101 }
1102 [] RSL_CCHAN[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_NO_SACCH_FILL)) -> value rx_rsl_ud {
1103 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1104 repeat;
1105 }
1106 [] RSL_CCHAN[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_SACCH_FILL)) -> value rx_rsl_ud {
1107 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1108 repeat;
1109 }
1110}
1111
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001112/* TODO: use BooleanList from COMMON/src/General_Types.ttcn */
1113private type record of boolean my_BooleanList;
1114
1115private function f_vty_msc_allow_attach(TELNETasp_PT pt, my_BooleanList allow_attach_list)
1116{
Neels Hofmeyr8f576712020-08-12 22:49:53 +00001117 var charstring config := f_vty_transceive_ret(pt, "show running-config");
1118
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001119 for (var integer msc_nr := 0; msc_nr < sizeof(allow_attach_list); msc_nr := msc_nr+1) {
Neels Hofmeyr8f576712020-08-12 22:49:53 +00001120 if (f_strstr(config, "\nmsc " & int2str(msc_nr) & "\n") < 0) {
1121 /* There is no 'msc N' for this msc_nr in the running config, so don't create an empty msc by
1122 * stepping into that config node. */
1123 log("msc ", msc_nr, " is not configured, skipping");
1124 continue;
1125 }
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001126 f_vty_enter_cfg_msc(pt, msc_nr);
1127 if (allow_attach_list[msc_nr]) {
1128 /* strict := false: ignore if osmo-bsc does not support this config option (latest build) */
1129 f_vty_transceive(pt, "allow-attach", strict := false);
1130 } else {
1131 f_vty_transceive(pt, "no allow-attach", strict := false);
1132 }
1133 f_vty_transceive(pt, "exit");
1134 f_vty_transceive(pt, "exit");
1135 }
1136}
1137
Harald Welte21b46bd2017-12-17 19:46:32 +01001138/* global initialization function
1139 * \param nr_bts Number of BTSs we should start/bring up
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001140 * \param handler_mode Start an RSL_Emulation_CT component (true) or not (false).
1141 * \param nr_msc Number of virtual MSCs to bring up to connect to osmo-bsc.
1142 */
1143function f_init(integer nr_bts := NUM_BTS, boolean handler_mode := false, boolean allow_osmux := false,
Neels Hofmeyr4fbad7f2020-06-16 00:30:47 +02001144 integer nr_msc := 1, float guard_timeout := 30.0) runs on test_CT {
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001145 var integer bssap_idx;
Harald Welte28d943e2017-11-25 15:00:50 +01001146
Harald Welteae026692017-12-09 01:03:01 +01001147 if (g_initialized) {
1148 return;
Harald Welte28d943e2017-11-25 15:00:50 +01001149 }
Harald Welteae026692017-12-09 01:03:01 +01001150 g_initialized := true;
1151
Neels Hofmeyr4fbad7f2020-06-16 00:30:47 +02001152 T_guard.start(guard_timeout);
Daniel Willmanne68f9272018-11-27 15:15:28 +01001153 activate(as_Tguard());
1154
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001155 f_init_vty("VirtMSC");
Pau Espin Pedrol23510fb2021-07-20 17:00:38 +02001156 f_vty_allow_osmux(allow_osmux);
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001157
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001158 var my_BooleanList allow_attach := { false, false, false };
Daniel Willmannebdecc02020-08-12 15:30:17 +02001159 f_init_statsd("VirtMSC", vc_STATSD, mp_test_ip, mp_bsc_statsd_port);
1160
Neels Hofmeyr9db8e0e2021-08-23 20:45:58 +02001161 /* Make sure each MSC's internal state is "DISCONNECTED" at first */
1162 for (bssap_idx := 0; bssap_idx < NUM_MSC; bssap_idx := bssap_idx+1) {
1163 f_vty_transceive(BSCVTY, "msc " & int2str(bssap_idx) & " bssmap reset", strict := false);
1164 }
1165
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001166 for (bssap_idx := 0; bssap_idx < nr_msc; bssap_idx := bssap_idx+1) {
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001167 allow_attach[bssap_idx] := true;
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001168 /* Call a function of our 'parent component' RAN_Adapter_CT to start the
1169 * MSC-side BSSAP emulation */
1170 if (handler_mode) {
1171 var RanOps ranops := MSC_RanOps;
1172 ranops.use_osmux := g_osmux_enabled;
1173 f_ran_adapter_init(g_bssap[bssap_idx], mp_bssap_cfg[bssap_idx], "VirtMSC", ranops);
1174 connect(self:SCCPLITE_IPA_CTRL, g_bssap[bssap_idx].vc_RAN:CTRL_CLIENT);
1175 f_ran_adapter_start(g_bssap[bssap_idx]);
1176 } else {
1177 f_ran_adapter_init(g_bssap[bssap_idx], mp_bssap_cfg[bssap_idx], "VirtMSC", omit);
1178 connect(self:BSSAP, g_bssap[bssap_idx].vc_SCCP:SCCP_SP_PORT);
1179 f_ran_adapter_start(g_bssap[bssap_idx]);
1180 f_legacy_bssap_reset();
1181 }
Harald Welte67089ee2018-01-17 22:19:03 +01001182 }
Harald Welted5833a82018-05-27 16:52:56 +02001183
Neels Hofmeyrcfe44062020-10-15 02:28:08 +02001184 if (mp_enable_lcs_tests) {
1185 if (handler_mode) {
1186 f_bssap_le_adapter_init(g_bssap_le, mp_bssap_le_cfg, "VirtSMLC", SMLC_BssapLeOps);
1187 } else {
1188 f_bssap_le_adapter_init(g_bssap_le, mp_bssap_le_cfg, "VirtSMLC", omit);
1189 connect(self:BSSAP_LE, g_bssap_le.vc_SCCP:SCCP_SP_PORT);
1190 }
1191 f_bssap_le_adapter_start(g_bssap_le);
Harald Welte47cd0e32020-08-21 12:39:11 +02001192 }
Harald Welte47cd0e32020-08-21 12:39:11 +02001193
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001194 /* start the test with exactly all enabled MSCs allowed to attach */
1195 f_vty_msc_allow_attach(BSCVTY, allow_attach);
1196
Pau Espin Pedrol9a5b8ff2021-01-04 19:01:31 +01001197 f_ipa_ctrl_start_client(mp_bsc_ip, mp_bsc_ctrl_port);
Harald Welte28d943e2017-11-25 15:00:50 +01001198
Daniel Willmann191e0d92018-01-17 12:44:35 +01001199 f_init_mgcp("VirtMSC");
1200
Neels Hofmeyr0b7365b2020-07-04 00:52:34 +02001201 for (var integer i := 0; i < nr_bts; i := i+1) {
1202 f_init_bts(i, handler_mode);
Harald Welte696ddb62017-12-08 14:01:43 +01001203 }
Neels Hofmeyr0b7365b2020-07-04 00:52:34 +02001204}
Harald Welte696ddb62017-12-08 14:01:43 +01001205
Neels Hofmeyr0b7365b2020-07-04 00:52:34 +02001206function f_init_bts(integer bts_idx := 0, boolean handler_mode := false)
1207runs on test_CT {
1208 /* wait until osmo-bts-omldummy has respawned */
1209 f_wait_oml(bts_idx, "degraded", 5.0);
1210
1211 /* start RSL connection */
1212 f_ipa_rsl_start(bts[bts_idx].rsl, mp_bsc_ip, mp_bsc_rsl_port, bts_idx, handler_mode);
1213 /* wait until BSC tells us "connected" */
1214 f_wait_oml(bts_idx, "connected", 5.0);
Harald Welte28d943e2017-11-25 15:00:50 +01001215}
1216
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02001217function f_init_bts_and_check_sysinfo(integer bts_idx := 0, boolean handler_mode := false,
1218 template SystemInformationConfig expect_si)
1219runs on test_CT {
1220 var default sysinfo := activate(as_catch_RSL_sysinfo(bts_idx));
1221
1222 f_init_bts(bts_idx, handler_mode);
1223
1224 /* Give some time to (hopefully/most likely) collect all system informations from RSL startup.
1225 * We could stop as soon as all expected SI are received, but then we might miss SI that we don't expect and
1226 * that might be sent afterwards. So rather give a generous timeout and be quite sure to catch all SI.
1227 */
1228 f_sleep(5.0);
1229 log("RSL ", bts_idx, " SYSTEM INFORMATION: ", g_system_information[bts_idx]);
1230
1231 deactivate(sysinfo);
1232
1233 if (match(g_system_information[bts_idx], expect_si)) {
1234 setverdict(pass);
1235 } else {
1236 log("RSL ", bts_idx, ": EXPECTED SI: ", expect_si);
1237 log("RSL ", bts_idx, ": GOT SI: ", g_system_information[bts_idx]);
1238 setverdict(fail, "received SI does not match expectations");
1239 return;
1240 }
1241}
1242
Maxd4e56962018-10-31 19:08:25 +01001243/* expect to receive a RSL message matching a specified template on a given BTS / stream */
Harald Welte65e419a2020-08-21 12:38:33 +02001244function 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 +01001245runs on test_CT return RSL_Message {
1246 var ASP_RSL_Unitdata rx_rsl_ud;
1247 timer T := t_secs;
1248
1249 T.start;
1250 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001251 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(t_rx, sid)) -> value rx_rsl_ud {
Harald Welteae026692017-12-09 01:03:01 +01001252 T.stop;
1253 }
1254 [] IPA_RSL[bts_nr].receive { repeat; }
Harald Welteb2917702017-12-10 15:48:52 +01001255 [] T.timeout {
1256 setverdict(fail, "Timeout expecting ", t_rx);
Daniel Willmannafce8662018-07-06 23:11:32 +02001257 mtc.stop;
Harald Welteb2917702017-12-10 15:48:52 +01001258 }
Harald Welteae026692017-12-09 01:03:01 +01001259 }
1260 return rx_rsl_ud.rsl;
1261}
1262
Harald Welte21b46bd2017-12-17 19:46:32 +01001263/* helper function to transmit RSL on a given BTS/stream */
Harald Welte65e419a2020-08-21 12:38:33 +02001264function 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 +01001265runs on test_CT {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001266 IPA_RSL[bts_nr].send(ts_ASP_RSL_UD(t_tx, sid));
Harald Welteae026692017-12-09 01:03:01 +01001267}
1268
1269
Harald Welte4003d112017-12-09 22:35:39 +01001270/* verify we get a CHAN_ACT after CHAN RQD */
Harald Welteae026692017-12-09 01:03:01 +01001271testcase TC_chan_act_noreply() runs on test_CT {
1272 var BSSAP_N_UNITDATA_ind ud_ind;
Harald Welte930d0a72018-03-22 22:08:40 +01001273 var RSL_Message rsl_unused;
Harald Welte28d943e2017-11-25 15:00:50 +01001274
Harald Welte89d42e82017-12-17 16:42:41 +01001275 f_init(1);
Harald Welte28d943e2017-11-25 15:00:50 +01001276
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001277 IPA_RSL[0].send(ts_ASP_RSL_UD(ts_RSL_CHAN_RQD('23'O, 23)));
Harald Welte930d0a72018-03-22 22:08:40 +01001278 rsl_unused := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001279 f_shutdown_helper();
Harald Welte28d943e2017-11-25 15:00:50 +01001280}
1281
Neels Hofmeyr734b1a32021-11-29 16:00:17 +01001282const CounterNameVals counternames_bts_chreq := {
1283 { "chreq:total", 0 },
1284 { "chreq:attempted_emerg", 0 },
1285 { "chreq:attempted_call", 0 },
1286 { "chreq:attempted_location_upd", 0 },
1287 { "chreq:attempted_pag", 0 },
1288 { "chreq:attempted_pdch", 0 },
1289 { "chreq:attempted_other", 0 },
1290 { "chreq:attempted_unknown", 0 },
1291 { "chreq:successful", 0 },
1292 { "chreq:successful_emerg", 0 },
1293 { "chreq:successful_call", 0 },
1294 { "chreq:successful_location_upd", 0 },
1295 { "chreq:successful_pag", 0 },
1296 { "chreq:successful_pdch", 0 },
1297 { "chreq:successful_other", 0 },
1298 { "chreq:successful_unknown", 0 },
1299 { "chreq:no_channel", 0 },
1300 { "chreq:max_delay_exceeded", 0 }
1301};
1302
1303/* verify the "chreq:*" counters */
1304private function f_chan_act_counter(OCT1 ra, charstring chreq_ctr_suffix) runs on test_CT
1305{
1306 var GsmFrameNumber fn := 23;
1307
1308 f_logp(BSCVTY, "f_chan_act_counter(" & chreq_ctr_suffix & ")");
1309
1310 var RSL_Message rx_rsl;
1311 f_ipa_tx(0, ts_RSL_CHAN_RQD(ra, fn));
1312 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
1313 var RslChannelNr chan_nr := rx_rsl.ies[0].body.chan_nr;
1314
1315 f_ctrs_bts_add(0, "chreq:total");
1316 f_ctrs_bts_add(0, "chreq:attempted_" & chreq_ctr_suffix);
1317 f_ctrs_bts_verify();
1318
1319 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, fn+10));
1320 rx_rsl := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
1321
1322 f_ctrs_bts_add(0, "chreq:successful");
1323 f_ctrs_bts_add(0, "chreq:successful_" & chreq_ctr_suffix);
1324 f_ctrs_bts_verify();
1325
1326 /* test is done, release RSL Conn Fail Ind to clean up */
1327 f_ipa_tx(0, ts_RSL_CONN_FAIL_IND(chan_nr, RSL_ERR_RADIO_LINK_FAIL));
1328 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), 10.0);
1329 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(chan_nr));
1330 f_sleep(1.0);
1331}
1332
Harald Welte4003d112017-12-09 22:35:39 +01001333testcase TC_chan_act_counter() runs on test_CT {
1334 var BSSAP_N_UNITDATA_ind ud_ind;
1335 var integer chreq_total;
Harald Welte930d0a72018-03-22 22:08:40 +01001336 var RSL_Message rsl_unused;
Harald Welte4003d112017-12-09 22:35:39 +01001337
Harald Welte89d42e82017-12-17 16:42:41 +01001338 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01001339
Neels Hofmeyr734b1a32021-11-29 16:00:17 +01001340 f_vty_allow_emerg_bts(true, 0);
1341
1342 f_ctrs_bts_init(1, counternames_bts_chreq);
1343
1344 /* emergency call: RA & 0xe0 == 0xa0 --> CHREQ_T_EMERG_CALL */
1345 f_chan_act_counter('a3'O, "emerg");
1346
1347 /* voice TCH/H: RA & 0xf0 == 0x40 --> CHREQ_T_VOICE_CALL_TCH_H */
1348 f_chan_act_counter('43'O, "call");
1349
1350 /* LU: RA & 0xf0 == 0x00 --> CHREQ_T_LOCATION_UPD */
1351 f_chan_act_counter('03'O, "location_upd");
1352
1353 /* Paging: RA & 0xf0 == 0x20 --> CHREQ_T_PAG_R_TCH_F */
1354 f_chan_act_counter('23'O, "pag");
1355 /* Paging: RA & 0xf0 == 0x30 --> CHREQ_T_PAG_R_TCH_FH */
1356 f_chan_act_counter('33'O, "pag");
1357
1358 /* LU: RA & 0xfc == 0x78 --> CHREQ_T_PDCH_TWO_PHASE */
1359 /* no PCU, so PDCH not allowed. Skip this test for now. */
1360 /* f_chan_act_counter('7b'O, "pdch"); */
1361
1362 /* LU: RA & 0xf0 == 0x10 --> CHREQ_T_SDCCH */
1363 f_chan_act_counter('13'O, "other");
Harald Welte4003d112017-12-09 22:35:39 +01001364
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001365 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01001366}
1367
Harald Welteae026692017-12-09 01:03:01 +01001368/* CHAN RQD -> CHAN ACT -> CHAN ACT ACK -> RF CHAN REL */
Philipp Maier9c60a622020-07-09 15:08:46 +02001369private function f_TC_chan_act_ack_noest(OCT1 ra := '23'O) runs on test_CT {
Harald Welteae026692017-12-09 01:03:01 +01001370 var RSL_Message rx_rsl;
1371
Harald Welteae026692017-12-09 01:03:01 +01001372 /* Send CHAN RQD and wait for allocation; acknowledge it */
Philipp Maier9c60a622020-07-09 15:08:46 +02001373 var RslChannelNr chan_nr := f_chreq_act_ack(ra);
Harald Welteae026692017-12-09 01:03:01 +01001374
1375 /* expect BSC to disable the channel again if there's no RLL EST IND */
1376 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX);
1377
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001378 f_shutdown_helper();
Harald Welteae026692017-12-09 01:03:01 +01001379}
1380
Philipp Maier9c60a622020-07-09 15:08:46 +02001381/* Normal variant */
1382testcase TC_chan_act_ack_noest() runs on test_CT {
Philipp Maieraf58db22020-08-12 17:24:40 +02001383 f_init(1);
Philipp Maier9c60a622020-07-09 15:08:46 +02001384 f_TC_chan_act_ack_noest();
1385}
1386
1387/* Emergency call variant */
1388testcase TC_chan_act_ack_noest_emerg() runs on test_CT {
1389 /* See also: 3GPP TS 04.08, Table 9.9, ra=101xxxxx */
Philipp Maieraf58db22020-08-12 17:24:40 +02001390 f_init(1);
1391 f_vty_allow_emerg_bts(true, 0);
Philipp Maier9c60a622020-07-09 15:08:46 +02001392 f_TC_chan_act_ack_noest(ra := 'A5'O);
1393}
1394
Philipp Maier606f07d2020-08-12 17:21:58 +02001395/* Emergency call variant, but emergency calls are not allowed */
1396testcase TC_chan_rqd_emerg_deny() runs on test_CT {
1397 /* See also: 3GPP TS 04.08, Table 9.9, ra=101xxxxx */
1398
1399 var RSL_Message rx_rsl;
1400 var GsmRrMessage rr;
1401
1402 f_init(1);
1403 f_vty_allow_emerg_bts(false, 0);
1404
1405 IPA_RSL[0].clear;
1406 f_ipa_tx(0, ts_RSL_CHAN_RQD('A5'O, 23));
1407
1408 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeC(RSL_MT_IMMEDIATE_ASSIGN_CMD));
1409 rr := dec_GsmRrMessage(rx_rsl.ies[1].body.full_imm_ass_info.payload);
1410 if (rr.header.message_type == IMMEDIATE_ASSIGNMENT_REJECT) {
1411 setverdict(pass);
1412 } else {
1413 setverdict(fail, "immediate assignment not rejected");
1414 }
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01001415
1416 f_shutdown_helper();
Philipp Maier606f07d2020-08-12 17:21:58 +02001417}
1418
Harald Welteae026692017-12-09 01:03:01 +01001419/* Test behavior if MSC never answers to CR */
1420testcase TC_chan_act_ack_est_ind_noreply() runs on test_CT {
Harald Weltef77aef62018-01-28 15:35:42 +01001421 var RslLinkId main_dcch := valueof(ts_RslLinkID_DCCH(0));
1422 var IpaStreamId sid := IPAC_PROTO_RSL_TRX0;
Harald Welteae026692017-12-09 01:03:01 +01001423 var RSL_Message rx_rsl;
Harald Weltef77aef62018-01-28 15:35:42 +01001424 var ASP_RSL_Unitdata rx_rsl_ud;
Harald Welteae026692017-12-09 01:03:01 +01001425
Harald Welte89d42e82017-12-17 16:42:41 +01001426 f_init(1);
Harald Welteae026692017-12-09 01:03:01 +01001427
1428 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +01001429 var RslChannelNr chan_nr := f_chreq_act_ack();
Harald Welteae026692017-12-09 01:03:01 +01001430
1431 var octetstring l3 := '00010203040506'O
1432 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
1433
1434 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3)));
1435
1436 /* expect BSC to disable the channel again if there's no response from MSC */
Harald Weltef77aef62018-01-28 15:35:42 +01001437 /* MS waits 20s (T3210) at LU; 10s (T3230) at CM SERV REQ and 5s (T3220) AT detach */
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001438 f_expect_chan_rel(0, chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001439 f_shutdown_helper();
Harald Welteae026692017-12-09 01:03:01 +01001440}
1441
1442/* Test behavior if MSC answers with CREF to CR */
1443testcase TC_chan_act_ack_est_ind_refused() runs on test_CT {
1444 var BSSAP_N_CONNECT_ind rx_c_ind;
1445 var RSL_Message rx_rsl;
1446
Harald Welte89d42e82017-12-17 16:42:41 +01001447 f_init(1);
Harald Welteae026692017-12-09 01:03:01 +01001448
1449 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +01001450 var RslChannelNr chan_nr := f_chreq_act_ack();
Harald Welteae026692017-12-09 01:03:01 +01001451
1452 var octetstring l3 := '00010203040506'O
1453 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
1454
1455 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
1456 BSSAP.send(ts_BSSAP_DISC_req(rx_c_ind.connectionId, 0));
1457
1458 /* expect BSC to disable the channel */
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001459 f_expect_chan_rel(0, chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001460 f_shutdown_helper();
Harald Welteae026692017-12-09 01:03:01 +01001461}
1462
Harald Welte618ef642017-12-14 14:58:20 +01001463/* CHAN RQD -> CHAN ACT -> CHAN ACT NACK -> RF CHAN REL */
1464testcase TC_chan_act_nack() runs on test_CT {
1465 var RSL_Message rx_rsl;
1466 var integer chact_nack;
1467
Harald Welte89d42e82017-12-17 16:42:41 +01001468 f_init(1);
Harald Welte618ef642017-12-14 14:58:20 +01001469
1470 chact_nack := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chan_act:nack");
1471
1472 f_ipa_tx(0, ts_RSL_CHAN_RQD('33'O, 33));
1473 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
1474 var RslChannelNr chan_nr := rx_rsl.ies[0].body.chan_nr;
1475
1476 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, RSL_ERR_EQUIPMENT_FAIL));
1477
1478 /* wait for some time to hope the NACK arrives before the CTRL GET below */
1479 f_sleep(0.5);
1480
1481 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chan_act:nack", chact_nack+1);
1482
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001483 f_shutdown_helper();
Harald Welte618ef642017-12-14 14:58:20 +01001484}
1485
Harald Welte799c97b2017-12-14 17:50:30 +01001486/* Test for channel exhaustion due to RACH overload */
1487testcase TC_chan_exhaustion() runs on test_CT {
1488 var ASP_RSL_Unitdata rsl_ud;
1489 var integer i;
1490 var integer chreq_total, chreq_nochan;
1491
Harald Welte89d42e82017-12-17 16:42:41 +01001492 f_init(1);
Harald Welte799c97b2017-12-14 17:50:30 +01001493
1494 chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total");
1495 chreq_nochan := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel");
1496
Neels Hofmeyr85fa37f2021-10-06 13:50:38 +02001497 /* GSM 44.018 Table 9.1.8.2:
Pau Espin Pedrolfe200d72018-12-10 12:41:04 +01001498 * RA = '33'O -> Establishment cause = 0011xxxx (MS dual rate capable and asks for "TCH/H or TCH/F").
1499 * With current setup, expect 4xSDCCH + 4xTCH/F + 1xTCH/H to succeed */
Philipp Maiercb6cc482018-03-26 13:08:00 +02001500 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 +01001501 var RslChannelNr chan_nr := f_chreq_act_ack('33'O, i);
Harald Welte799c97b2017-12-14 17:50:30 +01001502 }
1503
1504 IPA_RSL[0].clear;
1505
Harald Weltedd8cbf32018-01-28 12:07:52 +01001506 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total",
Philipp Maiercb6cc482018-03-26 13:08:00 +02001507 chreq_total + NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS);
Harald Welte799c97b2017-12-14 17:50:30 +01001508
1509 /* now expect additional channel activations to fail */
1510 f_ipa_tx(0, ts_RSL_CHAN_RQD('42'O, 42));
1511
1512 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001513 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV))) {
Harald Welte799c97b2017-12-14 17:50:30 +01001514 setverdict(fail, "Received CHAN ACT ACK without resources?!?");
1515 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001516 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_IMM_ASSIGN(?))) -> value rsl_ud {
Harald Welte799c97b2017-12-14 17:50:30 +01001517 var GsmRrMessage rr;
1518 /* match on IMM ASS REJ */
1519 rr := dec_GsmRrMessage(rsl_ud.rsl.ies[1].body.full_imm_ass_info.payload);
1520 if (rr.header.message_type == IMMEDIATE_ASSIGNMENT_REJECT) {
1521 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total",
Philipp Maiercb6cc482018-03-26 13:08:00 +02001522 chreq_total + NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS+1);
Harald Welte799c97b2017-12-14 17:50:30 +01001523 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel",
1524 chreq_nochan+1);
1525 setverdict(pass);
1526 } else {
1527 repeat;
1528 }
1529 }
1530 [] IPA_RSL[0].receive { repeat; }
1531 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001532 f_shutdown_helper();
Harald Welte799c97b2017-12-14 17:50:30 +01001533}
1534
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07001535/* Test channel deactivation due to silence from MS */
1536testcase TC_chan_deact_silence() runs on test_CT {
1537 var RslChannelNr chan_nr;
1538
1539 f_init(1);
1540
1541 /* Request for a dedicated channel */
1542 chan_nr := f_chreq_act_ack('23'O);
1543
1544 /* Wait some time until the channel is released */
1545 f_sleep(2.0);
1546
1547 /* Expect CHANnel RELease */
1548 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001549 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL))) {
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07001550 log("Received CHANnel RELease");
1551 setverdict(pass);
1552 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001553 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_IMM_ASSIGN(?))) {
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07001554 /* See OS#3709, OsmoBSC should not send Immediate
1555 * Assignment Reject since a dedicated channel was
1556 * already allocated, and Immediate Assignment was
1557 * already sent. */
1558 setverdict(fail, "Unexpected Immediate Assignment!");
1559 }
1560 [] IPA_RSL[0].receive {
1561 setverdict(fail, "Unexpected RSL message!");
1562 }
1563 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001564 f_shutdown_helper();
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07001565}
1566
Harald Weltecfe2c962017-12-15 12:09:32 +01001567/***********************************************************************
1568 * Assignment Testing
1569 ***********************************************************************/
1570
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02001571/* Verify that the BSC refuses any BSSAP connection from the MSC (They are all BSC->MSC direction,
1572 * except for the inter-BSC handover, MT side) */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001573testcase TC_outbound_connect(integer bssap_idx := 0) runs on test_CT {
Harald Welte89d42e82017-12-17 16:42:41 +01001574 f_init(1);
Harald Weltecfe2c962017-12-15 12:09:32 +01001575
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001576 BSSAP.send(ts_BSSAP_CONNECT_req(g_bssap[bssap_idx].sccp_addr_peer, g_bssap[bssap_idx].sccp_addr_own,
1577 2342, ts_BSSMAP_AssignmentReq));
Harald Weltecfe2c962017-12-15 12:09:32 +01001578 BSSAP.receive(tr_BSSAP_DISC_ind(2342, ?, ?));
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001579 f_shutdown_helper();
Harald Weltecfe2c962017-12-15 12:09:32 +01001580}
1581
Harald Welte16a4adf2017-12-14 18:54:01 +01001582/* Test behavior if MSC answers with CREF to CR */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001583testcase TC_assignment_cic_only(integer bssap_idx := 0) runs on test_CT {
Harald Welte16a4adf2017-12-14 18:54:01 +01001584 var BSSAP_N_CONNECT_ind rx_c_ind;
1585 var RSL_Message rx_rsl;
1586 var DchanTuple dt;
1587
Harald Welte89d42e82017-12-17 16:42:41 +01001588 f_init(1);
Harald Welte16a4adf2017-12-14 18:54:01 +01001589
1590 dt := f_est_dchan('23'O, 23, '00000000'O);
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001591 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welte17b27da2018-05-25 20:33:53 +02001592 /* send assignment without AoIP IEs */
1593 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_AssignmentReq(ts_BSSMAP_IE_CIC(0, 1))));
1594 } else {
1595 /* Send assignmetn without CIC in IPA case */
1596 var BSSMAP_IE_AoIP_TransportLayerAddress tla :=
1597 valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342));
1598 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_AssignmentReq(omit, tla)));
1599 }
Harald Welte16a4adf2017-12-14 18:54:01 +01001600 alt {
1601 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentComplete)) {
1602 setverdict(fail, "AoIP BSC cannot accept ASSIGNMENT without AoIP Transport IE");
1603 }
Harald Welte235ebf12017-12-15 14:18:16 +01001604 /* TODO: Actually expect GSM0808_CAUSE_REQ_A_IF_TYPE_NOT_SUPP */
Harald Welte16a4adf2017-12-14 18:54:01 +01001605 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentFail)) {
1606 setverdict(pass);
1607 }
1608 [] BSSAP.receive { repeat; }
1609 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001610 f_shutdown_helper();
Harald Welte16a4adf2017-12-14 18:54:01 +01001611}
1612
Harald Welteed848512018-05-24 22:27:58 +02001613/* generate an assignment request for either AoIP or SCCPlite */
Pau Espin Pedrol07866632020-09-03 19:10:55 +02001614function 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 +02001615 var PDU_BSSAP ass_cmd;
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001616 var BSSMAP_IE_Osmo_OsmuxCID osmux_cid := valueof(ts_OsmuxCID(0));
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001617 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welteed848512018-05-24 22:27:58 +02001618 var BSSMAP_IE_AoIP_TransportLayerAddress tla :=
Pau Espin Pedrol07866632020-09-03 19:10:55 +02001619 valueof(f_ts_BSSMAP_IE_AoIP_TLA(aoip_tla, 2342));
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001620 if (osmux_enabled) {
1621 ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla, osmux_cid));
1622 } else {
1623 ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla));
1624 }
Harald Welteed848512018-05-24 22:27:58 +02001625 } else {
1626 var BSSMAP_IE_CircuitIdentityCode cic := valueof(ts_BSSMAP_IE_CIC(0,1));
Pau Espin Pedrol096d73d2019-06-06 12:49:17 +02001627 ass_cmd := valueof(ts_BSSMAP_AssignmentReq(cic, omit));
Harald Welteed848512018-05-24 22:27:58 +02001628 }
1629 return ass_cmd;
1630}
1631
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02001632function f_gen_handover_req(integer bssap_idx := 0, charstring aoip_tla := "1.2.3.4",
Neels Hofmeyr8ebf19c2021-06-21 05:24:01 +02001633 template (omit) BSSMAP_oldToNewBSSIEs oldToNewBSSIEs := omit,
1634 template (omit) TestHdlrEncrParams enc := omit) return PDU_BSSAP {
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01001635 var PDU_BSSAP ho_req;
Neels Hofmeyr8ebf19c2021-06-21 05:24:01 +02001636
1637 var BSSMAP_IE_EncryptionInformation encryptionInformation :=
1638 valueof(ts_BSSMAP_IE_EncrInfo('0000000000000000'O,'01'O));
1639 var template BSSMAP_IE_ChosenEncryptionAlgorithm chosenEncryptionAlgorithm := omit;
1640 var template BSSMAP_IE_KC128 kc128 := omit;
1641 if (ispresent(enc)) {
1642 var TestHdlrEncrParams v_enc := valueof(enc);
1643 encryptionInformation := valueof(ts_BSSMAP_IE_EncrInfo(v_enc.enc_key, v_enc.enc_alg));
1644 chosenEncryptionAlgorithm := valueof(
1645 ts_BSSMAP_IE_ChosenEncryptionAlgorithm(int2oct(enum2int(
Oliver Smith598e1ed2021-07-09 10:28:40 +02001646 f_cipher_mode_bssmap_to_rsl(v_enc.enc_alg)), 1)));
Neels Hofmeyr8ebf19c2021-06-21 05:24:01 +02001647 if (ispresent(v_enc.enc_kc128)) {
1648 kc128 := ts_BSSMAP_IE_Kc128(v_enc.enc_kc128);
1649 }
1650 }
1651
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001652 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01001653 var BSSMAP_IE_AoIP_TransportLayerAddress tla :=
Pau Espin Pedrol07866632020-09-03 19:10:55 +02001654 valueof(f_ts_BSSMAP_IE_AoIP_TLA(aoip_tla, 2342));
Neels Hofmeyr8ebf19c2021-06-21 05:24:01 +02001655 ho_req := valueof(ts_BSSMAP_HandoverRequest(omit, tla, oldToNewBSSIEs := oldToNewBSSIEs,
1656 encryptionInformation := encryptionInformation,
1657 chosenEncryptionAlgorithm := chosenEncryptionAlgorithm,
1658 kC128 := kc128));
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01001659 } else {
1660 var BSSMAP_IE_CircuitIdentityCode cic := valueof(ts_BSSMAP_IE_CIC(0,1));
Neels Hofmeyr8ebf19c2021-06-21 05:24:01 +02001661 ho_req := valueof(ts_BSSMAP_HandoverRequest(cic, omit, oldToNewBSSIEs := oldToNewBSSIEs,
1662 encryptionInformation := encryptionInformation,
1663 chosenEncryptionAlgorithm := chosenEncryptionAlgorithm,
1664 kC128 := kc128));
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01001665 }
1666 return ho_req;
1667}
1668
Harald Welteed848512018-05-24 22:27:58 +02001669/* generate an assignment complete template for either AoIP or SCCPlite */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001670function f_gen_exp_compl(boolean expect_osmux := false, integer bssap_idx := 0) return template PDU_BSSAP {
Harald Welteed848512018-05-24 22:27:58 +02001671 var template PDU_BSSAP exp_compl;
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001672 var BSSMAP_IE_Osmo_OsmuxCID osmux_cid := valueof(ts_OsmuxCID(0));
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001673 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001674 if (expect_osmux) {
1675 exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?, osmux_cid);
1676 } else {
1677 exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?, omit);
1678 }
Harald Welteed848512018-05-24 22:27:58 +02001679 } else {
1680 /* CIC is optional "*" as the MSC allocated it */
Pau Espin Pedrol096d73d2019-06-06 12:49:17 +02001681 exp_compl := tr_BSSMAP_AssignmentComplete(*, omit);
Harald Welteed848512018-05-24 22:27:58 +02001682 }
1683 return exp_compl;
1684}
1685
Harald Welte235ebf12017-12-15 14:18:16 +01001686/* Run everything required up to sending a caller-specified assignment command and expect response */
1687function f_assignment_exp(PDU_BSSAP ass_cmd, template PDU_BSSAP exp, charstring fail_text)
1688runs on test_CT {
1689 var BSSAP_N_CONNECT_ind rx_c_ind;
1690 var RSL_Message rx_rsl;
1691 var DchanTuple dt;
1692
Harald Welte89d42e82017-12-17 16:42:41 +01001693 f_init(1);
Harald Welte235ebf12017-12-15 14:18:16 +01001694
1695 dt := f_est_dchan('23'O, 23, '00000000'O);
1696 /* send assignment without AoIP IEs */
1697 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ass_cmd));
1698 alt {
1699 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentComplete)) {
1700 if (ischosen(exp.pdu.bssmap.assignmentComplete)) {
1701 setverdict(pass);
1702 } else {
1703 setverdict(fail, fail_text);
1704 }
1705 }
1706 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentFail)) {
1707 if (ischosen(exp.pdu.bssmap.assignmentFailure)) {
1708 setverdict(pass);
1709 } else {
1710 setverdict(fail, fail_text);
1711 }
1712 }
1713 [] BSSAP.receive { repeat; }
1714 }
1715}
1716testcase TC_assignment_csd() runs on test_CT {
1717 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +02001718 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte235ebf12017-12-15 14:18:16 +01001719 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeCSD);
1720 //exp_fail.pdu.bssmap.assignmentFailure.cause.causeValue := int2bit(enum2int(GSM0808_CAUSE_REQ_CODEC_TYPE_OR_CONFIG_UNAVAIL), 7);
1721 f_assignment_exp(ass_cmd, exp_fail, "BSC accepted Assignment for CSD");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001722 f_shutdown_helper();
Harald Welte235ebf12017-12-15 14:18:16 +01001723}
1724
1725testcase TC_assignment_ctm() runs on test_CT {
1726 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +02001727 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte235ebf12017-12-15 14:18:16 +01001728 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeCTM);
1729 //exp_fail.pdu.bssmap.assignmentFailure.cause.causeValue := int2bit(enum2int(GSM0808_CAUSE_REQ_CODEC_TYPE_OR_CONFIG_UNAVAIL), 7);
1730 f_assignment_exp(ass_cmd, exp_fail, "BSC accepted Assignment for Speech+CTM");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001731 f_shutdown_helper();
Harald Welte235ebf12017-12-15 14:18:16 +01001732}
1733
Harald Welte4003d112017-12-09 22:35:39 +01001734type record DchanTuple {
1735 integer sccp_conn_id,
1736 RslChannelNr rsl_chan_nr
Harald Weltea5d2ab22017-12-09 14:21:42 +01001737}
1738
Neels Hofmeyrbd94fe72021-10-26 22:04:53 +02001739type record of DchanTuple DchanTuples;
1740
Harald Welted6939652017-12-13 21:02:46 +01001741/* Send CHAN RQD and wait for allocation; acknowledge it */
1742private function f_chreq_act_ack(OCT1 ra := '23'O, GsmFrameNumber fn := 23)
1743runs on test_CT return RslChannelNr {
1744 var RSL_Message rx_rsl;
1745 f_ipa_tx(0, ts_RSL_CHAN_RQD(ra, fn));
1746 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
1747 var RslChannelNr chan_nr := rx_rsl.ies[0].body.chan_nr;
1748 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, fn+10));
Daniel Willmannf4ac4ce2018-08-02 14:06:30 +02001749 rx_rsl := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
Harald Welted6939652017-12-13 21:02:46 +01001750 return chan_nr;
1751}
1752
Harald Welte4003d112017-12-09 22:35:39 +01001753/* helper function to establish a dedicated channel via BTS and MSC */
1754function f_est_dchan(OCT1 ra, GsmFrameNumber fn, octetstring l3)
1755runs on test_CT return DchanTuple {
1756 var BSSAP_N_CONNECT_ind rx_c_ind;
Harald Welte4003d112017-12-09 22:35:39 +01001757 var DchanTuple dt;
Harald Weltea5d2ab22017-12-09 14:21:42 +01001758
Harald Welte4003d112017-12-09 22:35:39 +01001759 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +01001760 dt.rsl_chan_nr := f_chreq_act_ack(ra, fn);
Harald Welte4003d112017-12-09 22:35:39 +01001761
1762 f_ipa_tx(0, ts_RSL_EST_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
1763
1764 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
1765 dt.sccp_conn_id := rx_c_ind.connectionId;
1766 BSSAP.send(ts_BSSAP_CONNECT_res(dt.sccp_conn_id));
1767
1768 return dt;
Harald Weltea5d2ab22017-12-09 14:21:42 +01001769}
1770
Neels Hofmeyre1a7c4d2021-10-23 23:13:01 +02001771/* Like f_est_dchan(), but for the first lchan of a dynamic timeslot: first ACK the deactivation of PDCH. */
1772function f_est_dchan_dyn(OCT1 ra, GsmFrameNumber fn, octetstring l3)
1773runs on test_CT return DchanTuple {
1774 var BSSAP_N_CONNECT_ind rx_c_ind;
1775 var DchanTuple dt;
1776
1777 /* Send CHAN RQD */
1778 var RSL_Message rx_rsl;
1779 f_ipa_tx(0, ts_RSL_CHAN_RQD(ra, fn));
1780
1781 /* The dyn TS first deactivates PDCH */
1782 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX);
1783 dt.rsl_chan_nr := rx_rsl.ies[0].body.chan_nr;
1784 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
1785
1786 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
1787 dt.rsl_chan_nr := rx_rsl.ies[0].body.chan_nr;
1788
1789 /* Now activates the signalling channel */
1790 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(dt.rsl_chan_nr, fn+10));
1791 rx_rsl := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
1792
1793 f_ipa_tx(0, ts_RSL_EST_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
1794
1795 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
1796 dt.sccp_conn_id := rx_c_ind.connectionId;
1797 BSSAP.send(ts_BSSAP_CONNECT_res(dt.sccp_conn_id));
1798
1799 return dt;
1800}
1801
Harald Welte641fcbe2018-06-14 10:58:35 +02001802/* expect RF CAN REL from BTS, acknowledge it and clear the MSC side */
1803private function f_exp_chan_rel_and_clear(DchanTuple dt, integer bts_nr := 0) runs on test_CT {
1804 var RSL_Message rx_rsl;
1805 /* expect BSC to disable the channel */
1806 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX);
1807 /* respond with CHAN REL ACK */
1808 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
1809
1810 /* expect Clear Complete from BSC */
1811 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete));
1812
1813 /* MSC disconnects as instructed. */
1814 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1815}
1816
Harald Welte4003d112017-12-09 22:35:39 +01001817/* Test behavior of channel release after unilateral RLL REL IND (DISC from MS) */
1818testcase TC_chan_rel_rll_rel_ind() runs on test_CT {
Neels Hofmeyr27f64362018-03-12 01:44:00 +01001819 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +01001820 var DchanTuple dt;
Harald Welte96c94412017-12-09 03:12:45 +01001821
Harald Welte89d42e82017-12-17 16:42:41 +01001822 f_init(1);
Harald Welte96c94412017-12-09 03:12:45 +01001823
Harald Welte4003d112017-12-09 22:35:39 +01001824 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1825
1826 /* simulate RLL REL IND */
1827 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0))));
1828
Neels Hofmeyr27f64362018-03-12 01:44:00 +01001829 /* expect Clear Request on MSC side */
1830 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
1831
1832 /* Instruct BSC to clear channel */
1833 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
1834 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
1835
Harald Welte4003d112017-12-09 22:35:39 +01001836 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02001837 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyr27f64362018-03-12 01:44:00 +01001838
1839 /* wait for SCCP emulation to do its job */
1840 f_sleep(1.0);
Harald Welte4003d112017-12-09 22:35:39 +01001841
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001842 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01001843}
1844
1845/* Test behavior of channel release after CONN FAIL IND from BTS */
1846testcase TC_chan_rel_conn_fail() runs on test_CT {
1847 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +01001848 var DchanTuple dt;
1849
Harald Welte89d42e82017-12-17 16:42:41 +01001850 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01001851
1852 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1853
1854 /* simulate CONN FAIL IND */
Harald Weltea8ed9062017-12-14 09:46:01 +01001855 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 +01001856 /* TODO: different cause values? */
1857
Harald Welte4003d112017-12-09 22:35:39 +01001858 /* expect Clear Request from BSC */
1859 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
1860
1861 /* Instruct BSC to clear channel */
1862 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
1863 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
1864
Harald Welte6ff76ea2018-01-28 13:08:01 +01001865 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02001866 f_exp_chan_rel_and_clear(dt, 0);
Harald Welte4003d112017-12-09 22:35:39 +01001867
1868 /* wait for SCCP emulation to do its job */
1869 f_sleep(1.0);
1870
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001871 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01001872}
1873
Harald Welte99f3ca02018-06-14 13:40:29 +02001874/* Test behavior of early CONN FAIL IND from BTS (before EST IND!) */
1875/* See also https://www.osmocom.org/issues/3182 */
1876testcase TC_early_conn_fail() runs on test_CT {
1877 var RSL_Message rx_rsl;
1878 var DchanTuple dt;
1879
1880 f_init(1);
1881
1882 /* BTS->BSC: Send CHAN RQD and wait for allocation; acknowledge it */
Harald Weltec46ea3c2020-10-10 18:46:12 +02001883 dt.rsl_chan_nr := f_chreq_act_ack(f_rnd_ra_cs(), 23);
Harald Welte99f3ca02018-06-14 13:40:29 +02001884
1885 /* BTS->BSC: simulate CONN FAIL IND */
1886 f_ipa_tx(0, ts_RSL_CONN_FAIL_IND(dt.rsl_chan_nr, RSL_ERR_RADIO_LINK_FAIL));
1887
1888 /* BTS->BSC: Expect RF channel release from BSC on Abis */
1889 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), 10.0);
1890
1891 /* BTS<-BSC: respond with CHAN REL ACK */
1892 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
1893
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001894 f_shutdown_helper();
Harald Welte99f3ca02018-06-14 13:40:29 +02001895}
1896
1897/* Test behavior of late CONN FAIL IND from BTS (ater REL IND!) */
1898/* See also https://www.osmocom.org/issues/3182 */
1899testcase TC_late_conn_fail() runs on test_CT {
1900 var RSL_Message rx_rsl;
1901 var DchanTuple dt;
1902
1903 f_init(1);
1904
1905 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1906
1907 /* BSC<-MSC: Instruct BSC to clear connection */
1908 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(0)));
1909
1910 /* BTS->BSC: expect BSC to deactivate SACCH */
1911 rx_rsl := f_exp_ipa_rx(0, tr_RSL_DEACT_SACCH(dt.rsl_chan_nr));
1912
1913 /* BTS->BSC: simulate a late CONN FAIL IND from BTS */
1914 f_ipa_tx(0, ts_RSL_CONN_FAIL_IND(dt.rsl_chan_nr, RSL_ERR_RADIO_LINK_FAIL));
1915
1916 /* BTS<-BSC: Expect RF channel release from BSC on Abis */
1917 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), 10.0);
1918 /* BTS->BSC: respond with CHAN REL ACK */
1919 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
1920
1921 /* BSC->MSC: expect Clear Complete from BSC */
1922 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete));
1923
1924 /* BSC<-MSC: MSC disconnects as requested. */
1925 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1926
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001927 f_shutdown_helper();
Harald Welte99f3ca02018-06-14 13:40:29 +02001928}
1929
Oliver Smithaf03bef2021-08-24 15:34:51 +02001930private function f_TC_stats_conn_fail(charstring id) runs on MSC_ConnHdlr {
1931 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
1932 var PDU_BSSAP ass_cmd := f_gen_ass_req();
1933
1934 f_statsd_reset();
1935
1936 /* Establish SDCCH */
1937 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeCSD);
1938 f_establish_fully(ass_cmd, exp_fail);
1939
1940 /* Expect stats to be 0 */
1941 var StatsDExpects expect := {
1942 {name := "TTCN3.bts.0.chan.rf_fail", mtype := "c", min := 0, max := 0},
1943 {name := "TTCN3.bts.0.chan.rf_fail_sdcch", mtype := "c", min := 0, max := 0}
1944 };
1945 f_statsd_expect(expect);
1946
1947 /* Simulate CONN FAIL IND on SDCCH */
1948 RSL.send(ts_ASP_RSL_UD(
1949 ts_RSL_CONN_FAIL_IND(g_chan_nr, RSL_ERR_RADIO_LINK_FAIL),
1950 IPAC_PROTO_RSL_TRX0));
1951
Neels Hofmeyr58be48a2021-09-07 18:39:21 +02001952 f_sleep(1.0);
1953
Oliver Smithaf03bef2021-08-24 15:34:51 +02001954 /* Expect stats to be 1 */
1955 expect := {
1956 {name := "TTCN3.bts.0.chan.rf_fail", mtype := "c", min := 1, max := 1},
1957 {name := "TTCN3.bts.0.chan.rf_fail_sdcch", mtype := "c", min := 1, max := 1}
1958 };
1959 f_statsd_expect(expect);
1960}
1961testcase TC_stats_conn_fail() runs on test_CT {
1962 var TestHdlrParams pars := f_gen_test_hdlr_pars();
1963 var MSC_ConnHdlr vc_conn;
1964
1965 f_init(1, true);
1966 f_sleep(1.0);
1967
1968 vc_conn := f_start_handler(refers(f_TC_stats_conn_fail), pars);
1969 vc_conn.done;
1970
1971 f_shutdown_helper();
1972}
1973
Neels Hofmeyrf44ccd12018-11-05 19:15:23 +01001974function f_expect_chan_rel(integer bts_nr, RslChannelNr rsl_chan_nr,
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001975 boolean expect_deact_sacch := true,
1976 boolean expect_rr_chan_rel := true,
1977 boolean expect_rll_rel_req := true,
Harald Welte99787102019-02-04 10:41:36 +01001978 boolean handle_rll_rel := true,
Pau Espin Pedrol36bd4fa2021-04-15 13:00:24 +02001979 template CellSelIndValue expect_cells := omit,
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001980 template RR_Cause expect_rr_cause := ?
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001981 ) runs on test_CT {
Harald Welte91d54a52018-01-28 15:35:07 +01001982
1983 var RslLinkId main_dcch := valueof(ts_RslLinkID_DCCH(0));
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001984 var boolean got_deact_sacch := false;
1985 var boolean got_rr_chan_rel := false;
1986 var boolean got_rll_rel_req := false;
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001987 var ASP_RSL_Unitdata ud;
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001988 var RSL_IE_Body l3_ie;
1989 var PDU_ML3_NW_MS l3;
1990 var RR_Cause got_cause;
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001991 log("f_expect_chan_rel() expecting: expect_deact_sacch=", expect_deact_sacch, " expect_rr_chan_rel=", expect_rr_chan_rel,
1992 " expect_rll_rel_req=", expect_rll_rel_req);
Harald Welte91d54a52018-01-28 15:35:07 +01001993 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001994 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_DEACT_SACCH(rsl_chan_nr))) {
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001995 got_deact_sacch := true;
Harald Welte91d54a52018-01-28 15:35:07 +01001996 repeat;
1997 }
Pau Espin Pedrol841b90d2021-04-15 16:42:52 +02001998 [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 +01001999 got_rr_chan_rel := true;
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002000
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02002001 if (f_rsl_find_ie(ud.rsl, RSL_IE_L3_INFO, l3_ie) == false) {
2002 setverdict(fail, "cannot find L3");
2003 mtc.stop;
2004 }
2005 l3 := dec_PDU_ML3_NW_MS(l3_ie.l3_info.payload);
2006
Pau Espin Pedrol36bd4fa2021-04-15 13:00:24 +02002007 if (not istemplatekind(expect_cells, "omit")) {
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002008 var CellSelIndValue cells := dec_CellSelIndValue(
2009 l3.msgs.rrm.channelRelease.cellSelectionIndicator.cellSelectionIndicatorValue);
2010
Pau Espin Pedrol36bd4fa2021-04-15 13:00:24 +02002011 log("GOT RR CHANNEL RELEASE WITH CELLS: ", cells);
2012 if (match(cells, expect_cells)) {
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002013 setverdict(pass);
2014 } else {
Pau Espin Pedrol36bd4fa2021-04-15 13:00:24 +02002015 log("EXPECTED CELLS: ", expect_cells);
2016 setverdict(fail, "Received cells list on RR Channel Release does not match expectations");
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002017 }
2018 }
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02002019
2020 if (not istemplatekind(expect_rr_cause, "omit")) {
2021 int2enum(oct2int(l3.msgs.rrm.channelRelease.rRCause.valuePart), got_cause);
2022 log("GOT CAUSE CODE: ", l3.msgs.rrm.channelRelease.rRCause.valuePart, " = ", got_cause);
2023 if (match(got_cause, expect_rr_cause)) {
2024 setverdict(pass);
2025 } else {
2026 log("EXPECTED CAUSE CODE: ", expect_rr_cause);
2027 setverdict(fail, "Received RR Channel Release Cause code does not match expectations");
2028 }
2029 }
Harald Welte99787102019-02-04 10:41:36 +01002030 repeat;
2031 }
Pau Espin Pedrol841b90d2021-04-15 16:42:52 +02002032 [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 +01002033 got_rr_chan_rel := true;
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02002034
2035 if (not istemplatekind(expect_rr_cause, "omit")) {
2036 if (f_rsl_find_ie(ud.rsl, RSL_IE_L3_INFO, l3_ie) == false) {
2037 setverdict(fail, "cannot find L3");
2038 mtc.stop;
2039 }
2040 l3 := dec_PDU_ML3_NW_MS(l3_ie.l3_info.payload);
2041
2042 int2enum(oct2int(l3.msgs.rrm.channelRelease.rRCause.valuePart), got_cause);
2043 log("GOT CAUSE CODE: ", l3.msgs.rrm.channelRelease.rRCause.valuePart, " = ", got_cause);
2044 if (match(got_cause, expect_rr_cause)) {
2045 setverdict(pass);
2046 } else {
2047 log("EXPECTED CAUSE CODE: ", expect_rr_cause);
2048 setverdict(fail, "Received RR Channel Release Cause code does not match expectations");
2049 }
2050 }
Neels Hofmeyr211169d2018-11-07 00:37:29 +01002051 repeat;
2052 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07002053 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_REL_REQ(rsl_chan_nr, ?))) {
Neels Hofmeyra5302c82018-11-04 23:09:58 +01002054 got_rll_rel_req := true;
Harald Welte91d54a52018-01-28 15:35:07 +01002055 /* FIXME: Why are we getting this for LinkID SACCH? */
Neels Hofmeyra5302c82018-11-04 23:09:58 +01002056 if (handle_rll_rel) {
2057 f_ipa_tx(0, ts_RSL_REL_CONF(rsl_chan_nr, main_dcch));
2058 }
Harald Welte91d54a52018-01-28 15:35:07 +01002059 repeat;
2060 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07002061 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL))) {
Harald Welte91d54a52018-01-28 15:35:07 +01002062 /* respond with CHAN REL ACK */
2063 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(rsl_chan_nr));
2064 }
2065 /* ignore any user data */
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07002066 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeR(?))) {
Harald Welte91d54a52018-01-28 15:35:07 +01002067 repeat;
2068 }
2069 }
Neels Hofmeyra5302c82018-11-04 23:09:58 +01002070
2071 log("f_expect_chan_rel() summary: got_deact_sacch=", got_deact_sacch, " got_rr_chan_rel=", got_rr_chan_rel,
2072 " got_rll_rel_req=", got_rll_rel_req);
2073
2074 if (expect_deact_sacch != got_deact_sacch) {
2075 setverdict(fail, "f_expect_chan_rel(): expect_deact_sacch=", expect_deact_sacch, " got_deact_sacch=", got_deact_sacch);
2076 }
2077 if (expect_rr_chan_rel != got_rr_chan_rel) {
2078 setverdict(fail, "f_expect_chan_rel(): expect_rr_chan_rel=", expect_rr_chan_rel, " got_rr_chan_rel=", got_rr_chan_rel);
2079 }
2080 if (expect_rll_rel_req != got_rll_rel_req) {
2081 setverdict(fail, "f_expect_chan_rel(): expect_rll_rel_req=", expect_rll_rel_req, " got_rll_rel_req=", got_rll_rel_req);
2082 }
Harald Welte91d54a52018-01-28 15:35:07 +01002083}
2084
Harald Welte4003d112017-12-09 22:35:39 +01002085/* Test behavior of channel release after hard Clear Command from MSC */
2086testcase TC_chan_rel_hard_clear() runs on test_CT {
2087 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +01002088 var DchanTuple dt;
Harald Welte4003d112017-12-09 22:35:39 +01002089
Harald Welte89d42e82017-12-17 16:42:41 +01002090 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01002091
2092 dt := f_est_dchan('23'O, 23, '00010203040506'O);
2093
2094 /* Instruct BSC to clear channel */
2095 var BssmapCause cause := 0;
2096 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
2097
2098 /* expect Clear Complete from BSC on A */
2099 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
2100 /* release the SCCP connection */
2101 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2102 }
2103
Neels Hofmeyra5302c82018-11-04 23:09:58 +01002104 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002105 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01002106}
2107
Pau Espin Pedrol841b90d2021-04-15 16:42:52 +02002108function f_TC_chan_rel_last_eutran_plmn_hard_clear(boolean tx_csfb_ind) runs on test_CT {
2109 var BSSAP_N_DATA_ind rx_di;
2110 var DchanTuple dt;
2111
2112 f_init(1);
2113
2114 dt := f_est_dchan('23'O, 23, '00010203040506'O);
2115 /* Send CommonID with some random PLMN (BSC doesn't take it into account
2116 /* yet when generating the EUTRAN neigh list in RR CHannel Release) */
2117 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_CommonId('001019876543210'H, '323454'O)));
2118
2119 /* Instruct BSC to clear channel */
2120 var BssmapCause cause := 0;
2121 if (tx_csfb_ind) {
2122 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommandCSFB(cause)));
2123 } else {
2124 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
2125 }
2126
2127 /* expect Clear Complete from BSC on A */
2128 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
2129 /* release the SCCP connection */
2130 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2131 }
2132
2133 /* 1 neighbor is added by default in osmo-bts.cfg and
2134 SystemInformationConfig_default, use that: */
2135 var template CellSelIndValue exp_cells := f_tr_rr_chan_rel_earfcns(1);
2136
2137 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false, expect_cells := exp_cells);
2138 f_shutdown_helper();
2139}
2140
2141/* Test behavior of RR Channel rRelease after Clear Command without CSFB indicator
2142 from MSC, previously receiving any CommonID containing the "Last Used E-UTRAN
2143 PLMN Id". According to spec (3GPP TS 48.008 sec 3.1.30) that's the bit requesting
2144 EUTRAN neighbor list sent later on by BSC in RR Channel, so receiving CSFB
2145 Indicator or not shouldn't matter at all. */
2146testcase TC_chan_rel_last_eutran_plmn_hard_clear_no_csfb() runs on test_CT {
2147 f_TC_chan_rel_last_eutran_plmn_hard_clear(false);
2148}
2149
2150/* Test behavior of RR Channel rRelease after Clear Command with CSFB indicator from
2151 MSC, previously receiving any CommonID containing the "Last Used E-UTRAN PLMN
2152 Id". According to spec (3GPP TS 48.008 sec 3.1.30) that's the bit requesting
2153 EUTRAN neighbor list sent later on by BSC in RR Channel. */
2154testcase TC_chan_rel_last_eutran_plmn_hard_clear_csfb() runs on test_CT {
2155 f_TC_chan_rel_last_eutran_plmn_hard_clear(true);
2156}
2157
2158/* Test behavior of RR Channel Release after Clear Command with CSFB indicator from
2159 MSC, without receiving any CommonID containing the "Last Used E-UTRAN PLMN
2160 Id". According to spec (TS 48.008 version 16.0.0 Release 16 "3.2.1.21") the
2161 CSFB Indicator should not be used anymore, and hence, there should be no
2162 EUTRAN neighbor list sent by BSC in RR Channel release since no CommonId with
2163 Last Used E-UTRAN PLMN Id" IE was sent for this conn. */
Harald Welte99787102019-02-04 10:41:36 +01002164testcase TC_chan_rel_hard_clear_csfb() runs on test_CT {
2165 var BSSAP_N_DATA_ind rx_di;
2166 var DchanTuple dt;
2167
2168 f_init(1);
2169
2170 dt := f_est_dchan('23'O, 23, '00010203040506'O);
2171
2172 /* Instruct BSC to clear channel */
2173 var BssmapCause cause := 0;
2174 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommandCSFB(cause)));
2175
2176 /* expect Clear Complete from BSC on A */
2177 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
2178 /* release the SCCP connection */
2179 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2180 }
2181
Pau Espin Pedrol841b90d2021-04-15 16:42:52 +02002182 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002183 f_shutdown_helper();
Harald Welte99787102019-02-04 10:41:36 +01002184}
2185
Harald Welted8c36cd2017-12-09 23:05:31 +01002186/* Test behavior of channel release after hard RLSD from MSC */
2187testcase TC_chan_rel_hard_rlsd() runs on test_CT {
Harald Welted8c36cd2017-12-09 23:05:31 +01002188 var DchanTuple dt;
Harald Welted8c36cd2017-12-09 23:05:31 +01002189
Harald Welte89d42e82017-12-17 16:42:41 +01002190 f_init(1);
Harald Welted8c36cd2017-12-09 23:05:31 +01002191
2192 dt := f_est_dchan('23'O, 23, '00010203040506'O);
2193
2194 /* release the SCCP connection */
2195 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2196
Neels Hofmeyra5302c82018-11-04 23:09:58 +01002197 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002198 f_shutdown_helper();
Harald Welted8c36cd2017-12-09 23:05:31 +01002199}
2200
Harald Welte550daf92018-06-11 19:22:13 +02002201/* Test behavior of channel release after hard RLSD from MSC and MS is not responding to RLL REL REQ */
2202testcase TC_chan_rel_hard_rlsd_ms_dead() runs on test_CT {
2203 var DchanTuple dt;
2204
2205 f_init(1);
2206
2207 dt := f_est_dchan('23'O, 23, '00010203040506'O);
2208
2209 /* release the SCCP connection */
2210 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2211
Neels Hofmeyra5302c82018-11-04 23:09:58 +01002212 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002213 f_shutdown_helper();
Harald Welte550daf92018-06-11 19:22:13 +02002214}
2215
Harald Welte85804d42017-12-10 14:11:58 +01002216/* Test behavior of channel release after BSSMAP RESET from MSC */
2217testcase TC_chan_rel_a_reset() runs on test_CT {
Harald Welte85804d42017-12-10 14:11:58 +01002218 var DchanTuple dt;
Harald Welte85804d42017-12-10 14:11:58 +01002219
Harald Welte89d42e82017-12-17 16:42:41 +01002220 f_init(1);
Harald Welte85804d42017-12-10 14:11:58 +01002221
2222 dt := f_est_dchan('23'O, 23, '00010203040506'O);
2223
2224 /* Clear the queue, it might still contain stuff like IMMEDIATE ASSIGN */
2225 IPA_RSL[0].clear;
2226
2227 /* perform BSSAP RESET, expect RESET ACK and DISC.ind on connection */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02002228 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 +01002229 interleave {
Neels Hofmeyrf246a922020-05-13 02:27:10 +02002230 [] 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 +01002231 [] BSSAP.receive(tr_BSSAP_DISC_ind(dt.sccp_conn_id, ?, ?)) { }
2232 }
2233
Neels Hofmeyra5302c82018-11-04 23:09:58 +01002234 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002235 f_shutdown_helper();
Harald Welte85804d42017-12-10 14:11:58 +01002236}
2237
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01002238/* Verify T(iar) triggers and releases the channel */
2239testcase TC_chan_rel_sccp_tiar_timeout() runs on test_CT {
2240 var DchanTuple dt;
2241
2242 /* Set T(iar) in BSC low enough that it will trigger before other side
2243 has time to keep alive with a T(ias). Keep recommended ratio of
2244 T(iar) >= T(ias)*2 */
2245 g_bsc_sccp_timer_ias := 2;
2246 g_bsc_sccp_timer_iar := 5;
2247
2248 f_init(1);
2249
2250 dt := f_est_dchan('23'O, 23, '00010203040506'O);
2251 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002252 f_shutdown_helper();
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01002253}
2254
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02002255private function f_tc_chan_rel_rr_cause(myBSSMAP_Cause clear_cmd_cause, template RR_Cause expect_rr_cause)
2256runs on test_CT
2257{
2258 var DchanTuple dt;
2259
2260 dt := f_est_dchan('23'O, 23, '00010203040506'O);
2261 var BssmapCause cause := 0;
2262 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(enum2int(clear_cmd_cause))));
2263 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
2264 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2265 }
2266
2267 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 +02002268}
2269
2270/* Test that Clear Command cause codes affect the RR Channel Release cause code */
2271testcase TC_chan_rel_rr_cause() runs on test_CT {
2272 f_init(1);
2273
2274 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_CALL_CONTROL, GSM48_RR_CAUSE_NORMAL);
2275 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_HANDOVER_SUCCESSFUL, GSM48_RR_CAUSE_NORMAL);
2276 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_PREEMPTION, GSM48_RR_CAUSE_PREMPTIVE_REL);
2277 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_RADIO_INTERFACE_MESSAGE_FAILURE, GSM48_RR_CAUSE_PROT_ERROR_UNSPC);
2278 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_RADIO_INTERFACE_FAILURE, GSM48_RR_CAUSE_ABNORMAL_UNSPEC);
2279 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_EQUIPMENT_FAILURE, GSM48_RR_CAUSE_ABNORMAL_UNSPEC);
Vadim Yanitskiye18aebb2021-01-03 13:10:43 +01002280
2281 f_shutdown_helper();
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02002282}
2283
Harald Welte5cd20ed2017-12-13 21:03:20 +01002284/* Test behavior if RSL EST IND for non-active channel */
2285testcase TC_rll_est_ind_inact_lchan() runs on test_CT {
2286 timer T := 2.0;
2287
Harald Welte89d42e82017-12-17 16:42:41 +01002288 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01002289
2290 var octetstring l3 := '00010203040506'O;
2291 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
2292 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(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 non-active lchan");
2298 }
2299 [] BSSAP.receive {}
2300 [] IPA_RSL[0].receive {}
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
2307/* Test behavior if RSL EST IND for invalid SAPI */
2308testcase TC_rll_est_ind_inval_sapi1() runs on test_CT {
2309 var RslChannelNr chan_nr;
2310
Harald Welte89d42e82017-12-17 16:42:41 +01002311 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01002312
2313 chan_nr := f_chreq_act_ack()
2314
2315 var octetstring l3 := '00010203040506'O;
2316 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(1)), l3));
2317
2318 timer T := 2.0;
2319 T.start;
2320 alt {
2321 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
2322 setverdict(fail, "MSC received COMPL L3 for invalid SAPI 1");
2323 }
2324 [] BSSAP.receive { repeat; }
2325 [] IPA_RSL[0].receive { repeat; }
2326 [] T.timeout {}
2327 }
2328
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002329 f_shutdown_helper();
Harald Welte5cd20ed2017-12-13 21:03:20 +01002330}
2331
2332/* Test behavior if RSL EST IND for invalid SAPI */
2333testcase TC_rll_est_ind_inval_sapi3() runs on test_CT {
2334 timer T := 2.0;
2335
Harald Welte89d42e82017-12-17 16:42:41 +01002336 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01002337
2338 var RslChannelNr chan_nr := f_chreq_act_ack();
2339
2340 var octetstring l3 := '00010203040506'O;
2341 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(3)), l3));
2342
2343 T.start;
2344 alt {
2345 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
2346 setverdict(fail, "MSC received COMPL L3 for invalid SAPI 3");
2347 }
2348 [] BSSAP.receive { repeat; }
2349 [] IPA_RSL[0].receive { repeat; }
2350 [] T.timeout {}
2351 }
2352
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002353 f_shutdown_helper();
Harald Welte5cd20ed2017-12-13 21:03:20 +01002354}
2355
2356/* Test behavior if RSL EST IND for invalid SACCH */
2357testcase TC_rll_est_ind_inval_sacch() runs on test_CT {
2358 timer T := 2.0;
2359
Harald Welte89d42e82017-12-17 16:42:41 +01002360 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01002361
2362 var RslChannelNr chan_nr := f_chreq_act_ack();
2363
2364 var octetstring l3 := '00010203040506'O;
2365 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_SACCH(0)), l3));
2366
2367 T.start;
2368 alt {
2369 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
2370 setverdict(fail, "MSC received COMPL L3 for invalid Link SACCH");
2371 }
2372 [] BSSAP.receive { repeat; }
2373 [] IPA_RSL[0].receive { repeat; }
2374 [] T.timeout {}
2375 }
2376
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002377 f_shutdown_helper();
Harald Welte5cd20ed2017-12-13 21:03:20 +01002378}
2379
Vadim Yanitskiy61f784a2020-10-01 21:12:19 +07002380/* Verify DLCI / RSL Link ID conversion for MO/MT messages on SAPI0/SAPI3 */
2381private function f_TC_tch_dlci_link_id_sapi(charstring id) runs on MSC_ConnHdlr {
2382 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2383 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2384
2385 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2386 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
2387
2388 f_establish_fully(ass_cmd, exp_compl);
2389
2390 /* SAPI0 has already been established by f_establish_fully(), establish SAPI3 */
2391 RSL.send(ts_RSL_EST_IND(g_chan_nr, ts_RslLinkID_SACCH(3), '0904'O));
2392 /* Expect BSSAP/DTAP on SAPI3 (DLCI IE) */
2393 BSSAP.receive(PDU_BSSAP:{
2394 discriminator := '1'B,
2395 spare := '0000000'B,
2396 dlci := 'C3'O,
2397 lengthIndicator := ?,
2398 pdu := { dtap := '0904'O }
2399 });
2400
2401 /* Send messages on DCCH/SAPI0 and ACCH/SAPI3 */
2402 for (var integer i := 0; i < 32; i := i + 1) {
2403 var octetstring l3 := '09'O & f_rnd_octstring(14);
2404 var template (value) RslLinkId link_id;
2405 var template (value) OCT1 dlci;
2406
2407 if (i mod 2 == 0) {
2408 /* SAPI0 on FACCH or SDCCH */
2409 link_id := ts_RslLinkID_DCCH(0);
2410 dlci := '80'O;
2411 } else {
2412 /* SAPI3 on SACCH */
2413 link_id := ts_RslLinkID_SACCH(3);
2414 dlci := 'C3'O;
2415 }
2416
2417 /* Send MO message: RSL -> BSSAP */
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00002418 f_mo_l3_transceive(RSL, link_id, dlci, l3);
Vadim Yanitskiy61f784a2020-10-01 21:12:19 +07002419 /* Send MT message: BSSAP -> RSL */
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00002420 f_mt_l3_transceive(RSL, link_id, dlci, l3);
Vadim Yanitskiy61f784a2020-10-01 21:12:19 +07002421 }
2422}
2423testcase TC_tch_dlci_link_id_sapi() runs on test_CT {
2424 var TestHdlrParams pars := f_gen_test_hdlr_pars();
2425 var MSC_ConnHdlr vc_conn;
2426
2427 f_init(1, true);
2428 f_sleep(1.0);
2429
2430 vc_conn := f_start_handler(refers(f_TC_tch_dlci_link_id_sapi), pars);
2431 vc_conn.done;
2432
2433 f_shutdown_helper();
2434}
2435
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07002436private function f_exp_sapi_n_reject(template (present) GsmSapi sapi := ?,
2437 template myBSSMAP_Cause cause := ?,
2438 float T_val := 2.0)
2439runs on test_CT {
2440 var BSSAP_N_DATA_ind rx_di;
2441 timer T;
2442
2443 var template BSSMAP_IE_Cause tr_cause := tr_BSSMAP_IE_Cause(cause);
2444 var template PDU_BSSAP tr_pdu := tr_BSSMAP_SAPInReject(sapi);
2445
2446 T.start(T_val);
2447 alt {
2448 [] BSSAP.receive(tr_BSSAP_DATA_ind(?, tr_pdu)) -> value rx_di {
2449 var BSSMAP_IE_Cause rx_cause := rx_di.userData.pdu.bssmap.sAPInReject.cause;
2450 if (not match(rx_cause, tr_cause)) {
2451 setverdict(fail, "Rx unexpected Cause IE: ",
2452 rx_cause, " vs expected ", tr_cause);
2453 }
2454 setverdict(pass);
2455 }
2456 [] BSSAP.receive(BSSAP_N_DATA_ind:?) -> value rx_di {
2457 setverdict(fail, "Rx unexpected BSSAP PDU: ", rx_di);
2458 }
2459 [] T.timeout {
2460 setverdict(fail, "Timeout waiting for BSSMAP SAPI N Reject");
2461 }
2462 }
2463}
2464
2465/* Check if we get SAPI N Reject on receipt of unexpected RLL RELease INDication */
2466testcase TC_rll_rel_ind_sapi_n_reject() runs on test_CT {
2467 var octetstring rnd_data := f_rnd_octstring(16);
2468 var RSL_Message rx_rsl;
2469 var DchanTuple dt;
2470
2471 f_init(1);
2472
2473 /* MS establishes a SAPI=0 link on DCCH */
2474 dt := f_est_dchan(f_rnd_ra_cs(), 23, rnd_data);
2475
2476 /* MSC sends some data on (not yet established) SAPI=3 link */
2477 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSAP_DTAP(rnd_data, '03'O)));
2478 /* BSC attempts to establish a SAPI=3 link on DCCH */
2479 rx_rsl := f_exp_ipa_rx(0, tr_RSL_EST_REQ(dt.rsl_chan_nr, tr_RslLinkID_DCCH(3)));
2480
2481 /* MS sends unexpected RELease INDication on SAPI=3 */
2482 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, ts_RslLinkID_DCCH(3)));
2483 /* We expect to receive BSSMAP SAPI N Reject message from the BSC */
2484 f_exp_sapi_n_reject(3, GSM0808_CAUSE_MS_NOT_EQUIPPED);
2485
2486 /* Clean up the connection */
2487 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2488 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
2489
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002490 f_shutdown_helper();
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07002491}
2492
2493/* Check if we get SAPI N Reject on receipt of unexpected RLL ERROR INDication */
2494testcase TC_rll_err_ind_sapi_n_reject() runs on test_CT {
2495 var octetstring rnd_data := f_rnd_octstring(16);
2496 var RSL_Message rx_rsl;
2497 var DchanTuple dt;
2498
2499 f_init(1);
2500
2501 /* MS establishes a SAPI=0 link on DCCH */
2502 dt := f_est_dchan(f_rnd_ra_cs(), 23, rnd_data);
2503
2504 /* MSC sends some data on (not yet established) SAPI=3 link */
2505 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSAP_DTAP(rnd_data, '03'O)));
2506 /* BSC attempts to establish a SAPI=3 link on DCCH */
2507 rx_rsl := f_exp_ipa_rx(0, tr_RSL_EST_REQ(dt.rsl_chan_nr, tr_RslLinkID_DCCH(3)));
2508
2509 /* BTS sends unexpected ERROR INDication on SAPI=3 */
2510 f_ipa_tx(0, ts_RSL_ERROR_IND(dt.rsl_chan_nr, ts_RslLinkID_DCCH(3), ''O));
2511 /* We expect to receive BSSMAP SAPI N Reject message from the BSC */
2512 f_exp_sapi_n_reject(3, GSM0808_CAUSE_BSS_NOT_EQUIPPED);
2513
2514 /* Clean up the connection */
2515 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2516 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
2517
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002518 f_shutdown_helper();
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07002519}
2520
2521/* Check if we get SAPI N Reject due to a SAPI=3 link establishment timeout */
2522testcase TC_rll_timeout_sapi_n_reject() runs on test_CT {
2523 var octetstring rnd_data := f_rnd_octstring(16);
2524 var RSL_Message rx_rsl;
2525 var DchanTuple dt;
2526
2527 f_init(1);
2528
2529 /* MS establishes a SAPI=0 link on DCCH */
2530 dt := f_est_dchan(f_rnd_ra_cs(), 23, rnd_data);
2531
2532 /* MSC sends some data on (not yet established) SAPI=3 link */
2533 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSAP_DTAP(rnd_data, '03'O)));
2534 /* BSC attempts to establish a SAPI=3 link on DCCH */
2535 rx_rsl := f_exp_ipa_rx(0, tr_RSL_EST_REQ(dt.rsl_chan_nr, tr_RslLinkID_DCCH(3)));
2536
2537 /* MS does not respond, so the link establishment timeout triggers SAPI N Reject */
2538 f_exp_sapi_n_reject(3, GSM0808_CAUSE_BSS_NOT_EQUIPPED, T_val := 8.0);
2539
2540 /* Clean up the connection */
2541 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2542 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
2543
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002544 f_shutdown_helper();
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07002545}
2546
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02002547testcase TC_si_default() runs on test_CT {
2548 f_init(0);
2549 f_init_bts_and_check_sysinfo(0, expect_si := SystemInformationConfig_default);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002550 f_shutdown_helper();
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02002551}
Harald Welte4003d112017-12-09 22:35:39 +01002552
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002553/* We're testing SI2quater with lists of EARFCNs. Instead of just incrementing EARFCNs, also pick some from the edges of
2554 * the entire value range. This function provides the same EARFCN numbers for the same earfcn_index */
2555private function f_test_si2quater_earfcn_by_idx(integer earfcn_index) return uint16_t
2556{
2557 select (earfcn_index) {
2558 case (0) {
2559 /* E-ARFCN 111 is already added in the osmo-bsc.cfg */
2560 return 111;
2561 }
2562 case (1) {
2563 return 1;
2564 }
2565 case (2) {
2566 return 0;
2567 }
2568 case (3) {
2569 return 65535;
2570 }
2571 case else {
2572 return 23 * (earfcn_index - 3);
2573 }
2574 }
2575}
2576
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002577function f_test_si2quater(integer total_earfcns, template SystemInformationConfig expect_si,
2578 template CellSelIndValue expect_cells := omit) runs on test_CT {
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002579
2580 f_init(0);
2581
2582 /* E-ARFCN 111 is already added in the osmo-bsc.cfg, so only add more arfcns if total_earfcns > 1 */
2583 for (var integer i := 1; i < total_earfcns; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002584 f_bts_0_cfg(BSCVTY, {"si2quater neighbor-list add earfcn " & int2str(f_test_si2quater_earfcn_by_idx(i))
2585 & " thresh-hi 20 thresh-lo 10 prio 3 qrxlv 22 meas 3"});
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002586 }
2587
2588 f_init_bts_and_check_sysinfo(0, expect_si := expect_si);
2589
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002590 if (not istemplatekind(expect_cells, "omit")) {
2591 /* Also check that RR Channel Release contains these EARFCNs.
2592 * (copied code from TC_chan_rel_hard_clear_csfb) */
2593 var BSSAP_N_DATA_ind rx_di;
2594 var DchanTuple dt;
2595
2596 dt := f_est_dchan('23'O, 23, '00010203040506'O);
Pau Espin Pedrold0046312021-04-19 16:35:58 +02002597 /* Send CommonID with some random PLMN (BSC doesn't take it into account
2598 * yet when generating the EUTRAN neigh list in RR CHannel Release) */
2599 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_CommonId('001019876543210'H, '323454'O)));
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002600
2601 /* Instruct BSC to clear channel */
2602 var BssmapCause cause := 0;
2603 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommandCSFB(cause)));
2604
2605 /* expect Clear Complete from BSC on A */
2606 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
2607 /* release the SCCP connection */
2608 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2609 }
2610
Pau Espin Pedrol841b90d2021-04-15 16:42:52 +02002611 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 +02002612 }
2613
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002614 for (var integer i := 1; i < total_earfcns; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002615 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 +02002616 }
2617}
2618
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002619private function f_tr_si2quater_earfcns(integer count) return template SI2quaterRestOctetsList
2620{
2621 var template SI2quaterRestOctetsList si2quater := {};
2622 var integer si2quater_count := (count + 2) / 3;
2623
2624 for (var integer i := 0; i < count; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002625 var integer earfcn := f_test_si2quater_earfcn_by_idx(i);
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002626 var integer index := i / 3;
2627 var integer earfcn_index := i mod 3;
2628 if (index >= lengthof(si2quater)) {
2629 si2quater[index] := tr_SI2quaterRestOctets_EUTRAN(index := index, count := si2quater_count - 1);
2630 }
2631 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);
2632 }
2633
2634 return si2quater;
2635}
2636
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002637private function f_tr_rr_chan_rel_earfcns(integer count) return template CellSelIndValue
2638{
2639 var template CellSelIndValue_EUTRAN_Descrs cells := {};
2640
Alexander Couzensf74b5cb2020-09-10 22:28:40 +02002641 /* the lte neighbors must match the config & vty to pass this test */
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002642 for (var integer i := 0; i < count; i := i + 1) {
2643 var integer earfcn := f_test_si2quater_earfcn_by_idx(i);
Alexander Couzensf74b5cb2020-09-10 22:28:40 +02002644 cells[i] := tr_CellSelIndValue_EUTRAN_Descr(earfcn, '1'B, 3);
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002645 }
2646
2647 return tr_CellSelIndValue_EUTRAN(cells);
2648}
2649
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002650private function f_tc_si2quater_n_earfcns(integer n) runs on test_CT
2651{
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002652 var template SystemInformationConfig sic := SystemInformationConfig_default;
Pau Espin Pedrol8ab62e42020-12-18 16:19:11 +01002653 sic.si2quater := f_tr_si2quater_earfcns(n);
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002654 var template CellSelIndValue cells := f_tr_rr_chan_rel_earfcns(n);
2655 f_test_si2quater(n, sic, cells);
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002656}
2657
2658testcase TC_si2quater_2_earfcns() runs on test_CT {
2659 f_tc_si2quater_n_earfcns(2);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002660 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002661}
2662
2663testcase TC_si2quater_3_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002664 f_tc_si2quater_n_earfcns(3);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002665 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002666}
2667
2668testcase TC_si2quater_4_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002669 f_tc_si2quater_n_earfcns(4);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002670 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002671}
2672
2673testcase TC_si2quater_5_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002674 f_tc_si2quater_n_earfcns(5);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002675 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002676}
2677
2678testcase TC_si2quater_6_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002679 f_tc_si2quater_n_earfcns(6);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002680 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002681}
2682
2683testcase TC_si2quater_12_earfcns() runs on test_CT {
2684 f_tc_si2quater_n_earfcns(12);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002685 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002686}
2687
2688testcase TC_si2quater_23_earfcns() runs on test_CT {
2689 f_tc_si2quater_n_earfcns(23);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002690 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002691}
2692
2693testcase TC_si2quater_32_earfcns() runs on test_CT {
2694 f_tc_si2quater_n_earfcns(32);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002695 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002696}
2697
2698testcase TC_si2quater_33_earfcns() runs on test_CT {
2699 f_tc_si2quater_n_earfcns(33);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002700 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002701}
2702
2703testcase TC_si2quater_42_earfcns() runs on test_CT {
2704 f_tc_si2quater_n_earfcns(42);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002705 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002706}
2707
2708testcase TC_si2quater_48_earfcns() runs on test_CT {
2709 f_tc_si2quater_n_earfcns(48);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002710 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002711}
2712
2713/* verify the VTY error response when adding too many EARFCNs, and showing that osmo-bsc still sends 16 SI2quater with
2714 * 48 EARFCNs. */
2715testcase TC_si2quater_49_earfcns() runs on test_CT {
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002716 var template SystemInformationConfig sic := SystemInformationConfig_default;
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002717 sic.si2quater := f_tr_si2quater_earfcns(48); /* 48, not 49! */
2718 f_init(0);
2719
2720 for (var integer i := 1; i < 48; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002721 f_bts_0_cfg(BSCVTY, {"si2quater neighbor-list add earfcn " & int2str(f_test_si2quater_earfcn_by_idx(i))
2722 & " thresh-hi 20 thresh-lo 10 prio 3 qrxlv 22 meas 3"});
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002723 }
2724
2725 /* The 49th EARFCN no longer fits, expect VTY error */
2726 f_vty_enter_cfg_bts(BSCVTY, 0);
2727 var charstring vty_error;
2728 vty_error := f_vty_transceive_ret(BSCVTY,
2729 "si2quater neighbor-list add earfcn 70 thresh-hi 20 thresh-lo 10 prio 3 qrxlv 22 meas 3")
2730 f_vty_transceive(BSCVTY, "end");
2731
2732 if (f_strstr(vty_error, "Unable to add ARFCN 70") >= 0) {
2733 log("Got expected VTY error: ", vty_error);
2734 setverdict(pass);
2735 } else {
2736 setverdict(fail, "Expected the 49th EUTRAN ARFCN to be rejected by vty config, got: ", vty_error);
2737 }
2738
2739 f_init_bts_and_check_sysinfo(0, expect_si := sic);
2740
2741 for (var integer i := 1; i < 48; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002742 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 +02002743 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002744 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002745}
2746
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002747private function f_acc09_count_allowed(AccessControlClass acc) return uint8_t
2748{
2749 var uint8_t count := 0;
2750 for (var integer i := 5; i < 16; i := i + 1) {
2751 if (acc[i] == '0'B) { /* the list marks barred, we count allowed */
2752 count := count + 1;
2753 }
2754 }
2755 return count;
2756}
2757
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002758private function f_recv_next_si1(integer rsl_idx := 0) runs on test_CT return SystemInformationType1
2759{
2760 var ASP_RSL_Unitdata rx_rsl_ud;
2761 var SystemInformationType1 last_si1;
2762
2763 timer T := 30.0;
2764 T.start;
2765 alt {
2766 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD((tr_RSL_NO_BCCH_INFO,
2767 tr_RSL_BCCH_INFO,
2768 tr_RSL_NO_SACCH_FILL,
2769 tr_RSL_SACCH_FILL))
2770 ) -> value rx_rsl_ud {
2771 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
2772 if (g_system_information[rsl_idx].si1 == omit) {
2773 repeat;
2774 }
2775 last_si1 := g_system_information[rsl_idx].si1;
2776 g_system_information[rsl_idx].si1 := omit;
2777 T.stop;
2778 }
Vadim Yanitskiy79ebd5e2021-01-04 00:12:55 +01002779 [] IPA_RSL[rsl_idx].receive { repeat; }
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002780 [] T.timeout { setverdict(fail, "Timeout receiving next SI1"); }
2781 }
2782 return last_si1;
2783}
2784
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002785/* verify ACC rotate feature */
2786testcase TC_si_acc_rotate() runs on test_CT {
2787 var template SystemInformationConfig sic := SystemInformationConfig_default;
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002788 var SystemInformationType1 last_si1;
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002789 var AccessControlClass acc;
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002790 var uint8_t count;
2791 var integer times_allowed[10] := { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
2792
2793 f_init(0, guard_timeout := 60.0);
2794
2795 f_bts_0_cfg(BSCVTY, {"rach access-control-class 5 barred",
2796 "access-control-class-rotate 3",
2797 "access-control-class-rotate-quantum 1"});
2798
2799 /* Init and get first sysinfo */
2800 f_init_bts_and_check_sysinfo(0, expect_si := ?);
2801
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002802 for (var integer i:= 0; i < 20; i := i + 1) {
2803 last_si1 := f_recv_next_si1(0);
2804 acc := last_si1.rach_control.acc;
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002805 count := f_acc09_count_allowed(acc);
2806 log("RSL: GOT SI1 ACC len=", count, ": ", acc);
2807
2808 if (count != 3) {
2809 log("RSL: EXPECTED SI ACC len=3");
2810 setverdict(fail, "received SI does not match expectations");
2811 break;
2812 }
2813
2814 for (var integer j := 0; j < 10; j := j + 1) {
2815 if (acc[16 - 1 - j] == '0'B) { /* the list marks barred, we count allowed */
2816 times_allowed[j] := times_allowed[j] + 1;
2817 }
2818 }
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002819 }
2820
2821 for (var integer j := 0; j < 10; j := j + 1) {
2822 log("ACC", j, " allowed ", times_allowed[j], " times" );
2823 if (j != 5 and times_allowed[j] < 3) {
2824 setverdict(fail, "ACC", j, " ERROR: allowed ", times_allowed[j], " < 1 times");
2825 } else if (j == 5 and times_allowed[j] > 0) {
2826 setverdict(fail, "ACC", j, " ERROR: allowed ", times_allowed[j], " > 0 times");
2827 }
2828 }
2829
2830 f_bts_0_cfg(BSCVTY, {"access-control-class-rotate 10",
2831 "rach access-control-class 5 allowed"});
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002832 f_shutdown_helper();
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002833}
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002834
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002835/* verify ACC startup ramp+rotate feature */
2836testcase TC_si_acc_ramp_rotate() runs on test_CT {
2837 var template SystemInformationConfig sic := SystemInformationConfig_default;
2838 var SystemInformationType1 last_si1;
2839 var AccessControlClass acc;
2840 var ASP_RSL_Unitdata rx_rsl_ud;
2841 var uint8_t count;
2842 var uint8_t prev_count;
2843 var integer times_allowed[10] := { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
2844
2845 f_init(0, guard_timeout := 80.0);
2846
2847 f_bts_0_cfg(BSCVTY, {"rach access-control-class 4 barred",
2848 "access-control-class-rotate 0",
2849 "access-control-class-rotate-quantum 1",
2850 "access-control-class-ramping",
2851 "access-control-class-ramping-step-interval 5",
2852 "access-control-class-ramping-step-size 5"});
2853
2854 /* Init and get first sysinfo */
2855 f_init_bts_and_check_sysinfo(0, expect_si := ?);
2856 last_si1 := g_system_information[0].si1;
2857 acc := last_si1.rach_control.acc;
2858 count := f_acc09_count_allowed(acc);
2859 /* Adm subset size was set to 0 above, so wait until all ACC are barred */
2860 while (count > 0) {
2861 last_si1 := f_recv_next_si1(0);
2862 acc := last_si1.rach_control.acc;
2863 count := f_acc09_count_allowed(acc);
2864 log("RSL: wait len()=0: GOT SI1 ACC len=", count, ": ", acc);
2865 }
2866
2867 /* Increase adm subset size, we should see ramping start up */
2868 f_bts_0_cfg(BSCVTY, {"access-control-class-rotate 10"});
2869 prev_count := 0;
2870 while (true) {
2871 last_si1 := f_recv_next_si1(0);
2872 acc := last_si1.rach_control.acc;
2873 count := f_acc09_count_allowed(acc);
2874 log("RSL: GOT SI1 ACC len=", count, ": ", acc);
2875
2876 if (prev_count > count) {
2877 setverdict(fail, "ACC allowed count dropped while expecting grow: ", prev_count, " -> ", count);
2878 break;
2879 }
2880
2881 if (count == 9) {
2882 break; /* Maximum reached (10 - 1 perm barred), done here */
2883 }
2884
2885 prev_count := count;
2886 }
2887
2888 setverdict(pass);
2889
2890 f_bts_0_cfg(BSCVTY, {"access-control-class-rotate 10",
2891 "rach access-control-class 4 allowed",
2892 "no access-control-class-ramping"});
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002893 f_shutdown_helper();
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002894}
2895
Harald Welte4003d112017-12-09 22:35:39 +01002896testcase TC_ctrl_msc_connection_status() runs on test_CT {
2897 var charstring ctrl_resp;
2898
Harald Welte89d42e82017-12-17 16:42:41 +01002899 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01002900
2901 /* See https://osmocom.org/issues/2729 */
2902 f_ctrl_get_exp(IPA_CTRL, "msc_connection_status", "connected");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002903 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01002904}
2905
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01002906testcase TC_ctrl_msc0_connection_status() runs on test_CT {
2907 var charstring ctrl_resp;
2908
2909 f_init(1);
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01002910
2911 f_ctrl_get_exp(IPA_CTRL, "msc.0.connection_status", "connected");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002912 f_shutdown_helper();
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01002913}
2914
Neels Hofmeyr0bc470d2021-08-21 13:37:13 +02002915/* Verify correct stats on the number of configured and connected MSCs */
2916private function f_tc_stat_num_msc_connected_msc_connhdlr(integer expect_num_msc_connected) runs on MSC_ConnHdlr {
2917 g_pars := f_gen_test_hdlr_pars();
2918 var StatsDExpects expect := {
2919 { name := "TTCN3.bsc.0.num_msc.connected", mtype := "g", min := expect_num_msc_connected, max := expect_num_msc_connected },
2920 { name := "TTCN3.bsc.0.num_msc.total", mtype := "g", min := NUM_MSC, max := NUM_MSC }
2921 };
2922 f_statsd_expect(expect);
2923}
2924
2925private function f_tc_stat_num_msc_connected_test_ct(void_fn tc_fn, integer nr_msc) runs on test_CT
2926{
2927 var MSC_ConnHdlr vc_conn;
2928
2929 f_init(nr_bts := 1, handler_mode := true, nr_msc := nr_msc);
2930 f_sleep(1.0);
2931 vc_conn := f_start_handler(tc_fn);
2932 vc_conn.done;
2933
2934 /* Also verify stat exposed on CTRL interface */
2935 f_ctrl_get_exp(IPA_CTRL, "stat_item.last.bsc.0.num_msc:connected", int2str(nr_msc));
2936 f_ctrl_get_exp(IPA_CTRL, "stat_item.last.bsc.0.num_msc:total", int2str(NUM_MSC));
2937
2938 f_shutdown_helper();
2939}
2940
2941/* Verify that when 1 MSC is active, that num_msc:connected reports 1. */
2942private function f_tc_stat_num_msc_connected_1(charstring id) runs on MSC_ConnHdlr {
2943 f_tc_stat_num_msc_connected_msc_connhdlr(1);
2944}
2945testcase TC_stat_num_msc_connected_1() runs on test_CT {
2946 f_tc_stat_num_msc_connected_test_ct(refers(f_tc_stat_num_msc_connected_1), 1);
2947}
2948
2949/* Verify that when 2 MSCs are active, that num_msc:connected reports 2. */
2950private function f_tc_stat_num_msc_connected_2(charstring id) runs on MSC_ConnHdlr {
2951 f_tc_stat_num_msc_connected_msc_connhdlr(2);
2952}
2953testcase TC_stat_num_msc_connected_2() runs on test_CT {
2954 f_tc_stat_num_msc_connected_test_ct(refers(f_tc_stat_num_msc_connected_2), 2);
2955}
2956
2957/* Verify that when 3 MSCs are active, that num_msc:connected reports 3. */
2958private function f_tc_stat_num_msc_connected_3(charstring id) runs on MSC_ConnHdlr {
2959 f_tc_stat_num_msc_connected_msc_connhdlr(3);
2960}
2961testcase TC_stat_num_msc_connected_3() runs on test_CT {
2962 f_tc_stat_num_msc_connected_test_ct(refers(f_tc_stat_num_msc_connected_3), 3);
2963}
2964
Neels Hofmeyr5ce3ae42021-08-29 15:32:00 +02002965/* Verify correct stats on the number of configured and connected MSCs */
2966private function f_tc_stat_num_bts_connected_msc_connhdlr(integer expect_num_bts_connected) runs on MSC_ConnHdlr {
2967 g_pars := f_gen_test_hdlr_pars();
2968 var StatsDExpects expect := {
2969 { name := "TTCN3.bsc.0.num_bts.oml_connected", mtype := "g", min := expect_num_bts_connected, max := NUM_BTS_CFG },
2970 { name := "TTCN3.bsc.0.num_bts.all_trx_rsl_connected", mtype := "g", min := expect_num_bts_connected, max := expect_num_bts_connected },
2971 { name := "TTCN3.bsc.0.num_bts.total", mtype := "g", min := NUM_BTS_CFG, max := NUM_BTS_CFG },
2972 { name := "TTCN3.bsc.0.num_trx.rsl_connected", mtype := "g", min := expect_num_bts_connected, max := expect_num_bts_connected },
2973 { name := "TTCN3.bsc.0.num_trx.total", mtype := "g", min := NUM_BTS_CFG, max := NUM_BTS_CFG }
2974 };
2975 f_statsd_expect(expect);
2976}
2977
2978private function f_tc_stat_num_bts_connected_test_ct(void_fn tc_fn, integer nr_bts) runs on test_CT {
2979 var MSC_ConnHdlr vc_conn;
2980
2981 f_init(nr_bts := nr_bts, handler_mode := true, nr_msc := 1);
2982 f_sleep(1.0);
2983 vc_conn := f_start_handler(tc_fn);
2984 vc_conn.done;
2985
2986 /* Also verify stat exposed on CTRL interface */
2987 f_ctrl_get_exp(IPA_CTRL, "stat_item.last.bsc.0.num_bts:all_trx_rsl_connected", int2str(nr_bts));
2988 f_ctrl_get_exp(IPA_CTRL, "stat_item.last.bsc.0.num_bts:total", int2str(NUM_BTS_CFG));
2989 f_ctrl_get_exp(IPA_CTRL, "stat_item.last.bsc.0.num_trx:rsl_connected", int2str(nr_bts));
2990 f_ctrl_get_exp(IPA_CTRL, "stat_item.last.bsc.0.num_trx:total", int2str(NUM_BTS_CFG));
2991
Neels Hofmeyra41ae302021-09-06 22:06:02 +02002992 /* Verify rf_states exposed on CTRL interface */
2993 var charstring expect_net_rf_states := "";
2994 for (var integer i := 0; i < NUM_BTS_CFG; i := i + 1) {
2995 var charstring expect_bts_rf_states := int2str(i) & ",0,";
2996 if (i < NUM_BTS) {
2997 /* In these tests, OML for the first NUM_BTS are always connected via osmo-bts-omldummy */
2998 expect_bts_rf_states := expect_bts_rf_states & "operational,unlocked,";
2999 } else {
3000 /* For remaining i < NUM_BTS_CFG, OML is not connected, i.e. inoperational */
3001 expect_bts_rf_states := expect_bts_rf_states & "inoperational,locked,";
3002 }
3003 /* The RF policy is still global in osmo-bsc, i.e. always "on" */
3004 expect_bts_rf_states := expect_bts_rf_states & "on,";
3005 if (i < nr_bts) {
3006 /* For BTS where RSL is connected, the RSL state will be "up" */
3007 expect_bts_rf_states := expect_bts_rf_states & "rsl-up;";
3008 } else {
3009 expect_bts_rf_states := expect_bts_rf_states & "rsl-down;";
3010 }
3011
3012 f_ctrl_get_exp(IPA_CTRL, "bts." & int2str(i) & ".rf_states", expect_bts_rf_states);
3013 expect_net_rf_states := expect_net_rf_states & expect_bts_rf_states;
3014 }
3015 f_ctrl_get_exp(IPA_CTRL, "rf_states", expect_net_rf_states);
3016
Neels Hofmeyr5ce3ae42021-08-29 15:32:00 +02003017 f_shutdown_helper();
3018}
3019
3020/* Verify that when 1 BTS is connected, that num_{bts,trx}:*_connected reports 1. */
3021private function f_tc_stat_num_bts_connected_1(charstring id) runs on MSC_ConnHdlr {
3022 f_tc_stat_num_bts_connected_msc_connhdlr(1);
3023}
3024testcase TC_stat_num_bts_connected_1() runs on test_CT {
3025 f_tc_stat_num_bts_connected_test_ct(refers(f_tc_stat_num_bts_connected_1), 1);
3026}
3027
3028/* Verify that when 2 BTS is connected, that num_{bts,trx}:*_connected reports 2. */
3029private function f_tc_stat_num_bts_connected_2(charstring id) runs on MSC_ConnHdlr {
3030 f_tc_stat_num_bts_connected_msc_connhdlr(2);
3031}
3032testcase TC_stat_num_bts_connected_2() runs on test_CT {
3033 f_tc_stat_num_bts_connected_test_ct(refers(f_tc_stat_num_bts_connected_2), 2);
3034}
3035
3036/* Verify that when 3 BTS is connected, that num_{bts,trx}:*_connected reports 3. */
3037private function f_tc_stat_num_bts_connected_3(charstring id) runs on MSC_ConnHdlr {
3038 f_tc_stat_num_bts_connected_msc_connhdlr(3);
3039}
3040testcase TC_stat_num_bts_connected_3() runs on test_CT {
3041 f_tc_stat_num_bts_connected_test_ct(refers(f_tc_stat_num_bts_connected_3), 3);
3042}
3043
Harald Welte4003d112017-12-09 22:35:39 +01003044testcase TC_ctrl() runs on test_CT {
3045 var charstring ctrl_resp;
3046
Harald Welte89d42e82017-12-17 16:42:41 +01003047 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01003048
3049 /* all below values must match the osmo-bsc.cfg config file used */
3050
Harald Welte6a129692018-03-17 17:30:14 +01003051 f_ctrl_get_exp(IPA_CTRL, "mcc", "001");
3052 f_ctrl_get_exp(IPA_CTRL, "mnc", "01");
Oliver Smith75aa0202019-08-19 14:17:50 +02003053 f_ctrl_get_exp(IPA_CTRL, "number-of-bts", "4");
Harald Welte4003d112017-12-09 22:35:39 +01003054
3055 var integer bts_nr := 0;
3056 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "location-area-code", "1");
3057 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "cell-identity", "0");
3058 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "oml-connection-state", "connected");
3059 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "gprs-mode", "gprs");
3060 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "rf_state", "operational,unlocked,on");
3061 f_ctrl_get_exp_trx(IPA_CTRL, bts_nr, 0, "arfcn", "871");
3062 f_ctrl_get_exp_trx(IPA_CTRL, bts_nr, 0, "max-power-reduction", "20");
3063
3064 var integer uptime := str2int(f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-uptime"));
3065 f_sleep(2.0);
3066 if (str2int(f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-uptime")) < uptime+1) {
3067 setverdict(fail, "oml-uptime not incrementing as expected");
3068 }
3069 /* TODO: Disconnect RSL, imply that OML is disconnected and check for uptime zero? */
3070
3071 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted", 0);
3072
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003073 f_shutdown_helper();
Harald Welte96c94412017-12-09 03:12:45 +01003074}
3075
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +02003076/* Verify that Upon receival of SET "location", BSC forwards a TRAP
3077 "location-state" over the SCCPlite IPA conn */
3078testcase TC_ctrl_location() runs on test_CT {
3079 var MSC_ConnHdlr vc_conn;
3080 var integer bts_nr := 0;
3081
3082 f_init(1, true);
3083 f_sleep(1.0);
3084
3085 f_ctrl_set_bts(IPA_CTRL, bts_nr, "location", "1234567,fix3d,0.340000,0.560000,0.780000");
3086 f_ctrl_exp_trap(SCCPLITE_IPA_CTRL, "bts." & int2str(bts_nr) & ".location-state",
3087 "1234567,fix3d,0.340000,0.560000,0.780000,operational,unlocked,on,001,01");
3088
3089 f_ctrl_set(SCCPLITE_IPA_CTRL, "rf_locked", "1");
3090 f_sleep(2.0);
3091
3092 f_ctrl_set_bts(IPA_CTRL, bts_nr, "location", "1234888,fix3d,0.350000,0.570000,0.790000");
3093 f_ctrl_exp_trap(SCCPLITE_IPA_CTRL, "bts." & int2str(bts_nr) & ".location-state",
3094 "1234888,fix3d,0.350000,0.570000,0.790000,operational,locked,off,001,01");
3095
3096 /* should match the one from config */
3097 f_ctrl_set(SCCPLITE_IPA_CTRL, "rf_locked", "0");
3098
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003099 f_shutdown_helper();
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +02003100}
3101
Harald Welte6f521d82017-12-11 19:52:02 +01003102
3103/***********************************************************************
3104 * Paging Testing
3105 ***********************************************************************/
3106
3107type record Cell_Identity {
3108 GsmMcc mcc,
3109 GsmMnc mnc,
3110 GsmLac lac,
3111 GsmCellId ci
3112};
Harald Welte24135bd2018-03-17 19:27:53 +01003113private const Cell_Identity cid := { '001'H, '01'H, 1, 0 };
Stefan Sperling049a86e2018-03-20 15:51:00 +01003114private const Cell_Identity unknown_cid := { '678'H, 'f90'H, 1, 0 };
Harald Welte6f521d82017-12-11 19:52:02 +01003115
Harald Welte5d1a2202017-12-13 19:51:29 +01003116type set of integer BtsIdList;
3117
3118private function f_bts_in_list(integer bts_id, BtsIdList bts_ids) return boolean {
3119 for (var integer j := 0; j < sizeof(bts_ids); j := j + 1) {
3120 if (bts_id == bts_ids[j]) {
3121 return true;
3122 }
3123 }
3124 return false;
3125}
Harald Welte6f521d82017-12-11 19:52:02 +01003126
3127/* core paging test helper function; used by most paging test cases */
3128private function f_pageing_helper(hexstring imsi,
3129 template BSSMAP_FIELD_CellIdentificationList cid_list,
Harald Welte5d1a2202017-12-13 19:51:29 +01003130 BtsIdList bts_ids := { 0 },
Harald Welte6f521d82017-12-11 19:52:02 +01003131 template RSL_ChanNeeded rsl_chneed := omit,
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07003132 template (omit) OCT4 tmsi := omit) runs on test_CT
Harald Welte6f521d82017-12-11 19:52:02 +01003133{
3134 var template BSSMAP_IE_ChannelNeeded bssmap_chneed;
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07003135 var template MobileIdentityV mi;
Harald Welte6f521d82017-12-11 19:52:02 +01003136 var RSL_Message rx_rsl;
3137 var integer paging_group := hex2int(imsi[lengthof(imsi)-1]);
Harald Welte5d1a2202017-12-13 19:51:29 +01003138 var integer i;
Harald Welte6f521d82017-12-11 19:52:02 +01003139
3140 f_init();
Harald Welte6f521d82017-12-11 19:52:02 +01003141
3142 /* Clear the queue, it might still contain stuff like BCCH FILLING */
Harald Weltec3068592018-03-17 19:55:31 +01003143 for (i := 0; i < NUM_BTS; i := i + 1) {
3144 IPA_RSL[i].clear;
Harald Welte5d1a2202017-12-13 19:51:29 +01003145 }
Harald Welte6f521d82017-12-11 19:52:02 +01003146
3147 if (isvalue(rsl_chneed)) {
3148 /* The values of 08.08 3.2.2.36 and 08.58 9.3.40 are luckily identical */
3149 bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
3150 } else {
3151 bssmap_chneed := omit;
3152 }
3153
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003154 BSSAP.send(ts_BSSAP_UNITDATA_req(g_bssap[0].sccp_addr_peer, g_bssap[0].sccp_addr_own,
3155 ts_BSSMAP_Paging(imsi, cid_list, tmsi, bssmap_chneed)));
Harald Welte6f521d82017-12-11 19:52:02 +01003156
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07003157 if (not istemplatekind(tmsi, "omit")) {
3158 mi := t_MI_TMSI(tmsi);
Harald Welte6f521d82017-12-11 19:52:02 +01003159 } else {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07003160 mi := tr_MI_IMSI(imsi);
Harald Welte6f521d82017-12-11 19:52:02 +01003161 }
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07003162
Harald Welte5d1a2202017-12-13 19:51:29 +01003163 for (i := 0; i < sizeof(bts_ids); i := i + 1) {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07003164 rx_rsl := f_exp_ipa_rx(bts_ids[i], tr_RSL_PAGING_CMD(mi));
Harald Welte5d1a2202017-12-13 19:51:29 +01003165 /* check channel type, paging group */
3166 if (rx_rsl.ies[1].body.paging_group != paging_group) {
3167 setverdict(fail, "Paging for wrong paging group");
3168 }
3169 if (ispresent(rsl_chneed) and
3170 rx_rsl.ies[3].body.chan_needed.chan_needed != valueof(rsl_chneed)) {
3171 setverdict(fail, "RSL Channel Needed != BSSMAP Channel Needed");
3172 }
Harald Welte6f521d82017-12-11 19:52:02 +01003173 }
Harald Welte2fccd982018-01-31 15:48:19 +01003174 f_sleep(2.0);
Harald Welte5d1a2202017-12-13 19:51:29 +01003175 /* do a quick check on all not-included BTSs if they received paging */
3176 for (i := 0; i < NUM_BTS; i := i + 1) {
3177 timer T := 0.1;
3178 if (f_bts_in_list(i, bts_ids)) {
3179 continue;
3180 }
3181 T.start;
3182 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07003183 [] IPA_RSL[i].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(mi))) {
Harald Welte5d1a2202017-12-13 19:51:29 +01003184 setverdict(fail, "Paging on BTS ", i, " which is not part of ", bts_ids);
3185 }
3186 [] IPA_RSL[i].receive { repeat; }
3187 [] T.timeout { }
3188 }
Harald Welte6f521d82017-12-11 19:52:02 +01003189 }
3190
3191 setverdict(pass);
3192}
3193
Harald Welte5d1a2202017-12-13 19:51:29 +01003194const BtsIdList c_BtsId_all := { 0, 1, 2 };
Harald Welte751d3eb2018-01-31 15:51:06 +01003195const BtsIdList c_BtsId_none := { };
Harald Welte5d1a2202017-12-13 19:51:29 +01003196const BtsIdList c_BtsId_LAC1 := { 0, 1 };
3197const BtsIdList c_BtsId_LAC2 := { 2 };
3198
Harald Welte6f521d82017-12-11 19:52:02 +01003199/* PAGING by IMSI + TMSI */
3200testcase TC_paging_imsi_nochan() runs on test_CT {
3201 var BSSMAP_FIELD_CellIdentificationList cid_list;
3202 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Philipp Maier8c04b0a2018-02-23 13:48:48 +01003203 f_pageing_helper('001010100000001'H, cid_list, c_BtsId_all, omit, omit);
Philipp Maier282ca4b2018-02-27 17:17:00 +01003204 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01003205}
3206
3207/* PAGING by IMSI + TMSI */
3208testcase TC_paging_tmsi_nochan() runs on test_CT {
3209 var BSSMAP_FIELD_CellIdentificationList cid_list;
3210 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01003211 f_pageing_helper('001010100000001'H, cid_list, c_BtsId_all, omit, 'A1B2C301'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01003212 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01003213}
3214
3215/* Paging with different "channel needed' values */
3216testcase TC_paging_tmsi_any() runs on test_CT {
3217 var BSSMAP_FIELD_CellIdentificationList cid_list;
3218 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01003219 f_pageing_helper('001010100000002'H, cid_list, c_BtsId_all, RSL_CHANNEED_ANY, 'A1B2C302'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01003220 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01003221}
3222testcase TC_paging_tmsi_sdcch() runs on test_CT {
3223 var BSSMAP_FIELD_CellIdentificationList cid_list;
3224 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01003225 f_pageing_helper('001010100000003'H, cid_list, c_BtsId_all, RSL_CHANNEED_SDCCH, 'A1B2C303'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01003226 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01003227}
3228testcase TC_paging_tmsi_tch_f() runs on test_CT {
3229 var BSSMAP_FIELD_CellIdentificationList cid_list;
3230 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01003231 f_pageing_helper('001010000000004'H, cid_list, c_BtsId_all, RSL_CHANNEED_TCH_F, 'A1B2C304'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01003232 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01003233}
3234testcase TC_paging_tmsi_tch_hf() runs on test_CT {
3235 var BSSMAP_FIELD_CellIdentificationList cid_list;
3236 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01003237 f_pageing_helper('001010000000005'H, cid_list, c_BtsId_all, RSL_CHANNEED_TCH_ForH, 'A1B2C305'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01003238 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01003239}
3240
3241/* Paging by CGI */
3242testcase TC_paging_imsi_nochan_cgi() runs on test_CT {
3243 var template BSSMAP_FIELD_CellIdentificationList cid_list;
3244 cid_list := { cIl_CGI := { ts_BSSMAP_CI_CGI(cid.mcc, cid.mnc, cid.lac, cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01003245 f_pageing_helper('001010000000006'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01003246 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01003247}
3248
3249/* Paging by LAC+CI */
3250testcase TC_paging_imsi_nochan_lac_ci() runs on test_CT {
3251 var template BSSMAP_FIELD_CellIdentificationList cid_list;
3252 cid_list := { cIl_LAC_CI := { ts_BSSMAP_CI_LAC_CI(cid.lac, cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01003253 f_pageing_helper('001010000000007'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01003254 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01003255}
3256
3257/* Paging by CI */
3258testcase TC_paging_imsi_nochan_ci() runs on test_CT {
3259 var template BSSMAP_FIELD_CellIdentificationList cid_list;
3260 cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01003261 f_pageing_helper('001010000000008'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01003262 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01003263}
3264
3265/* Paging by LAI */
3266testcase TC_paging_imsi_nochan_lai() runs on test_CT {
3267 var template BSSMAP_FIELD_CellIdentificationList cid_list;
3268 cid_list := { cIl_LAI := { ts_BSSMAP_CI_LAI(cid.mcc, cid.mnc, cid.lac) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01003269 f_pageing_helper('001010000000009'H, cid_list, c_BtsId_LAC1);
Philipp Maier282ca4b2018-02-27 17:17:00 +01003270 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01003271}
3272
3273/* Paging by LAC */
3274testcase TC_paging_imsi_nochan_lac() runs on test_CT {
3275 var template BSSMAP_FIELD_CellIdentificationList cid_list;
3276 cid_list := { cIl_LAC := { ts_BSSMAP_CI_LAC(cid.lac) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01003277 f_pageing_helper('001010000000010'H, cid_list, c_BtsId_LAC1);
Philipp Maier282ca4b2018-02-27 17:17:00 +01003278 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01003279}
3280
3281/* Paging by "all in BSS" */
3282testcase TC_paging_imsi_nochan_all() runs on test_CT {
3283 var template BSSMAP_FIELD_CellIdentificationList cid_list;
3284 cid_list := { cIl_allInBSS := ''O };
Harald Welte5d1a2202017-12-13 19:51:29 +01003285 f_pageing_helper('001010000000011'H, cid_list, c_BtsId_all);
Philipp Maier282ca4b2018-02-27 17:17:00 +01003286 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01003287}
3288
Stefan Sperling7b5e1782018-03-20 19:32:43 +01003289/* Paging by PLMN+LAC+RNC; We do not implement this; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01003290testcase TC_paging_imsi_nochan_plmn_lac_rnc() runs on test_CT {
3291 var template BSSMAP_FIELD_CellIdentificationList cid_list;
3292 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 +01003293 f_pageing_helper('001010000000012'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01003294 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01003295}
Harald Welte6f521d82017-12-11 19:52:02 +01003296
Stefan Sperling7b5e1782018-03-20 19:32:43 +01003297/* Paging by RNC; We do not implement this; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01003298testcase TC_paging_imsi_nochan_rnc() runs on test_CT {
3299 var template BSSMAP_FIELD_CellIdentificationList cid_list;
3300 cid_list := { cIl_RNC := { int2oct(13, 2) } };
Stefan Sperling7b5e1782018-03-20 19:32:43 +01003301 f_pageing_helper('001010000000013'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01003302 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01003303}
3304
Stefan Sperling7b5e1782018-03-20 19:32:43 +01003305/* Paging by LAC+RNC; We do not implement; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01003306testcase TC_paging_imsi_nochan_lac_rnc() runs on test_CT {
3307 var template BSSMAP_FIELD_CellIdentificationList cid_list;
3308 cid_list := { cIl_LAC_RNC := { ts_BSSMAP_CI_LAC_RNC(cid.lac, 14) } };
Stefan Sperling7b5e1782018-03-20 19:32:43 +01003309 f_pageing_helper('001010000000014'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01003310 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01003311}
3312
Harald Welte6f521d82017-12-11 19:52:02 +01003313/* Paging on multiple cells (multiple entries in list): Verify all of them page */
Harald Welte751d3eb2018-01-31 15:51:06 +01003314testcase TC_paging_imsi_nochan_lacs() runs on test_CT {
3315 var template BSSMAP_FIELD_CellIdentificationList cid_list;
3316 cid_list := { cIl_LAC := { ts_BSSMAP_CI_LAC(1), ts_BSSMAP_CI_LAC(2) } };
3317 f_pageing_helper('001010000000015'H, cid_list, c_BtsId_all);
Philipp Maier282ca4b2018-02-27 17:17:00 +01003318 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01003319}
3320
3321/* Paging on empty list: Verify none of them page */
3322testcase TC_paging_imsi_nochan_lacs_empty() runs on test_CT {
3323 var template BSSMAP_FIELD_CellIdentificationList cid_list;
3324 cid_list := { cIl_LAC := { } };
3325 f_pageing_helper('001010000000016'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01003326 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01003327}
3328
Stefan Sperling049a86e2018-03-20 15:51:00 +01003329/* Paging by CGI with unknown MCC/MNC: Verify nothing is paged. */
3330testcase TC_paging_imsi_nochan_cgi_unknown_cid() runs on test_CT {
3331 var template BSSMAP_FIELD_CellIdentificationList cid_list;
3332 cid_list := { cIl_CGI := { ts_BSSMAP_CI_CGI(unknown_cid.mcc, unknown_cid.mnc, unknown_cid.lac, unknown_cid.ci) } };
3333 f_pageing_helper('001010000000006'H, cid_list, c_BtsId_none);
3334 f_shutdown_helper();
3335}
3336
Harald Welte6f521d82017-12-11 19:52:02 +01003337/* Verify paging retransmission interval + count */
3338/* Verify paging stops after channel establishment */
Harald Welte6f521d82017-12-11 19:52:02 +01003339/* Test behavior under paging overload */
Harald Welteae026692017-12-09 01:03:01 +01003340
Harald Weltee65d40e2017-12-13 00:09:06 +01003341/* Verify PCH load */
3342testcase TC_paging_imsi_load() runs on test_CT {
3343 var BSSMAP_FIELD_CellIdentificationList cid_list;
3344 timer T := 4.0;
Harald Welte2caa1062018-03-17 18:19:05 +01003345 timer T_retrans := 1.0;
Harald Weltee65d40e2017-12-13 00:09:06 +01003346 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01003347 f_pageing_helper('001010123456789'H, cid_list, c_BtsId_all);
Harald Weltee65d40e2017-12-13 00:09:06 +01003348
3349 /* tell BSC there is no paging space anymore */
3350 f_ipa_tx(0, ts_RSL_PAGING_LOAD_IND(0));
Harald Welte3b57ab52018-03-17 18:01:10 +01003351 f_sleep(0.2);
3352 IPA_RSL[0].clear;
Harald Weltee65d40e2017-12-13 00:09:06 +01003353
3354 /* Wait for 4 seconds if any more PAGING CMD are received on RSL. Normally,
3355 * there would be 8 retransmissions during 4 seconds */
3356 T.start;
Harald Welte2caa1062018-03-17 18:19:05 +01003357 T_retrans.start;
Harald Weltee65d40e2017-12-13 00:09:06 +01003358 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07003359 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Weltee65d40e2017-12-13 00:09:06 +01003360 setverdict(fail, "Received PAGING after LOAD_IND(0)");
Daniel Willmannafce8662018-07-06 23:11:32 +02003361 mtc.stop;
Harald Weltee65d40e2017-12-13 00:09:06 +01003362 }
Harald Welte2caa1062018-03-17 18:19:05 +01003363 [] T_retrans.timeout {
3364 /* re-trnsmit the zero-space LOAD IND to avoid BSC 'auto credit' */
3365 f_ipa_tx(0, ts_RSL_PAGING_LOAD_IND(0));
3366 T_retrans.start;
3367 repeat;
3368 }
Harald Weltee65d40e2017-12-13 00:09:06 +01003369 [] T.timeout {
3370 setverdict(pass);
3371 }
3372 }
Philipp Maier282ca4b2018-02-27 17:17:00 +01003373
3374 f_shutdown_helper();
Harald Weltee65d40e2017-12-13 00:09:06 +01003375}
3376
Harald Welte235ebf12017-12-15 14:18:16 +01003377/* Verify Paging Counter */
Harald Welte1ff69992017-12-14 12:31:17 +01003378testcase TC_paging_counter() runs on test_CT {
3379 var BSSMAP_FIELD_CellIdentificationList cid_list;
3380 timer T := 4.0;
3381 var integer i;
3382 var integer paging_attempted_bsc;
3383 var integer paging_attempted_bts[NUM_BTS];
Oliver Smith8b343d32021-11-26 13:01:42 +01003384 var integer paging_expired_bsc;
Harald Welte1ff69992017-12-14 12:31:17 +01003385 var integer paging_expired_bts[NUM_BTS];
3386 cid_list := valueof(ts_BSSMAP_CIL_noCell);
3387
3388 f_init();
3389
3390 /* read counters before paging */
3391 paging_attempted_bsc := f_ctrl_get_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted");
Oliver Smith8b343d32021-11-26 13:01:42 +01003392 if (Misc_Helpers.f_osmo_repo_is("nightly")) { /* osmo-bsc > 1.8.0 */
3393 paging_expired_bsc := f_ctrl_get_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:expired");
3394 }
Harald Welte1ff69992017-12-14 12:31:17 +01003395 for (i := 0; i < NUM_BTS; i := i+1) {
3396 paging_attempted_bts[i] := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", i, "paging:attempted");
3397 paging_expired_bts[i] := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", i, "paging:expired");
3398 }
3399
3400 f_pageing_helper('001230000000001'H, cid_list, c_BtsId_all);
3401
3402 /* expect the attempted pages on BSC and each BTSs to have incremented by one */
3403 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted", paging_attempted_bsc+1);
3404 for (i := 0; i < NUM_BTS; i := i+1) {
3405 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", i, "paging:attempted",
3406 paging_attempted_bts[i]+1);
3407 }
3408
3409 /* assume that 12s later the paging on all BTSs have expired and hence incremented by 1 */
3410 f_sleep(12.0);
Oliver Smith8b343d32021-11-26 13:01:42 +01003411 if (Misc_Helpers.f_osmo_repo_is("nightly")) { /* osmo-bsc > 1.8.0 */
3412 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:expired", paging_expired_bsc+1);
3413 }
Harald Welte1ff69992017-12-14 12:31:17 +01003414 for (i := 0; i < NUM_BTS; i := i+1) {
3415 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", i, "paging:expired",
3416 paging_expired_bts[i]+1);
3417 }
Harald Welte1ff69992017-12-14 12:31:17 +01003418
Philipp Maier282ca4b2018-02-27 17:17:00 +01003419 f_shutdown_helper();
Harald Welte1ff69992017-12-14 12:31:17 +01003420}
3421
3422
Harald Welte10985002017-12-12 09:29:15 +01003423/* Verify paging stops after A-RESET */
3424testcase TC_paging_imsi_a_reset() runs on test_CT {
3425 var BSSMAP_FIELD_CellIdentificationList cid_list;
3426 timer T := 3.0;
3427 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01003428 f_pageing_helper('001010123456789'H, cid_list, c_BtsId_all);
Harald Welte10985002017-12-12 09:29:15 +01003429
3430 /* Perform a BSSMAP Reset and wait for ACK */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003431 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 +01003432 alt {
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003433 [] 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 +01003434 [] BSSAP.receive { repeat; }
3435 }
3436
Daniel Willmanncbef3982018-07-30 09:22:40 +02003437 /* Wait to avoid a possible race condition if a paging message is
3438 * received right before the reset ACK. */
3439 f_sleep(0.2);
3440
Harald Welte10985002017-12-12 09:29:15 +01003441 /* Clear the queue, it might still contain stuff like BCCH FILLING */
Philipp Maier1e6b4422018-02-23 14:02:13 +01003442 for (var integer i := 0; i < sizeof(IPA_RSL); i := i+1) {
3443 IPA_RSL[i].clear;
3444 }
Harald Welte10985002017-12-12 09:29:15 +01003445
3446 /* Wait for 3 seconds if any more PAGING CMD are received on RSL */
3447 T.start;
3448 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07003449 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Welte10985002017-12-12 09:29:15 +01003450 setverdict(fail, "Received PAGING after A-RESET");
Daniel Willmannafce8662018-07-06 23:11:32 +02003451 mtc.stop;
Harald Welte10985002017-12-12 09:29:15 +01003452 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07003453 [] IPA_RSL[1].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Welte5d1a2202017-12-13 19:51:29 +01003454 setverdict(fail, "Received PAGING after A-RESET");
Daniel Willmannafce8662018-07-06 23:11:32 +02003455 mtc.stop;
Harald Welte5d1a2202017-12-13 19:51:29 +01003456 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07003457 [] IPA_RSL[2].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Welte5d1a2202017-12-13 19:51:29 +01003458 setverdict(fail, "Received PAGING after A-RESET");
Daniel Willmannafce8662018-07-06 23:11:32 +02003459 mtc.stop;
Harald Welte5d1a2202017-12-13 19:51:29 +01003460 }
Harald Welte10985002017-12-12 09:29:15 +01003461 [] T.timeout {
3462 setverdict(pass);
3463 }
3464 }
Philipp Maier282ca4b2018-02-27 17:17:00 +01003465
3466 f_shutdown_helper();
Harald Welte10985002017-12-12 09:29:15 +01003467}
Harald Welteae026692017-12-09 01:03:01 +01003468
Philipp Maierf45824a2019-08-14 14:44:10 +02003469/* Verify how we handle unsolicited Paging Response. In case of an unsolicit
3470 * paging response we can not know which MSC is in charge, so we will blindly
3471 * pick the first configured MSC. This behavior is required in order to make
3472 * MT-CSFB calls working because in those cases the BSC can not know that the
3473 * MSC has already paged the subscriver via SGs. So any MT-CSFB call will look
3474 * like an unsolicited Paging Response to the MSC.
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003475 */
3476testcase TC_paging_resp_unsol() runs on test_CT {
3477
3478 f_init(1);
Philipp Maierf45824a2019-08-14 14:44:10 +02003479 timer T := 5.0;
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003480
3481 var BSSAP_N_CONNECT_ind rx_c_ind;
3482 var DchanTuple dt;
3483 var PDU_ML3_MS_NW l3 := valueof(ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010008880018'H))));
Philipp Maierf45824a2019-08-14 14:44:10 +02003484 var octetstring rr_pag_resp := enc_PDU_ML3_MS_NW(l3);
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003485
3486 /* Send CHAN RQD and wait for allocation; acknowledge it */
3487 dt.rsl_chan_nr := f_chreq_act_ack();
3488
3489 /* Send unsolicited Paging response (no matching Paging CMD stored in BSC) */
3490 f_ipa_tx(0, ts_RSL_EST_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)), enc_PDU_ML3_MS_NW(l3)));
3491
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003492
Philipp Maierf45824a2019-08-14 14:44:10 +02003493 /* Expevct a CR with a matching Paging response on the A-Interface */
3494 T.start;
3495 alt {
3496 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(rr_pag_resp))) {
3497 setverdict(pass);
3498 }
3499 [] BSSAP.receive {
3500 setverdict(fail, "Received unexpected message on A-Interface!");
3501 }
3502 [] T.timeout {
3503 setverdict(fail, "Received nothing on A-Interface!");
3504 }
3505 }
3506
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003507 f_shutdown_helper();
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003508}
3509
Harald Welte4e9b9cc2017-12-14 18:31:02 +01003510/* Test RSL link drop causes counter increment */
3511testcase TC_rsl_drop_counter() runs on test_CT {
3512 var integer rsl_fail;
3513
Harald Welte89d42e82017-12-17 16:42:41 +01003514 f_init(1);
Harald Welte4e9b9cc2017-12-14 18:31:02 +01003515
3516 rsl_fail := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "rsl_fail");
3517
3518 bts[0].rsl.vc_IPA.stop;
3519
3520 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "rsl_fail", rsl_fail+1);
3521
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003522 f_shutdown_helper();
Harald Welte4e9b9cc2017-12-14 18:31:02 +01003523}
3524
3525/* TODO: Test OML link drop causes counter increment */
3526
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003527/* The body of TC_rsl_unknown_unit_id() and TC_oml_unknown_unit_id() tests. */
3528function f_ipa_unknown_unit_id(integer mp_bsc_ipa_port) runs on test_CT return boolean {
3529 timer T := 10.0;
3530
3531 bts[0].rsl.id := "IPA-0-RSL";
3532 bts[0].rsl.vc_IPA := IPA_Emulation_CT.create(bts[0].rsl.id & "-IPA");
3533 bts[0].rsl.ccm_pars := c_IPA_default_ccm_pars;
3534 bts[0].rsl.ccm_pars.name := "Osmocom TTCN-3 BTS Simulator";
Oliver Smith92c2bdb2019-08-20 15:11:24 +02003535 bts[0].rsl.ccm_pars.unit_id := "99/0/0"; /* value which is unknown at BTS */
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003536
Pau Espin Pedrol9a5b8ff2021-01-04 19:01:31 +01003537 f_ipa_ctrl_start_client(mp_bsc_ip, mp_bsc_ctrl_port);
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003538
3539 f_init_mgcp("VirtMSC");
3540
3541 /* start RSL/OML connection (XXX re-uses RSL port/protocol definitions for OML) */
3542 map(bts[0].rsl.vc_IPA:IPA_PORT, system:IPA);
3543 connect(bts[0].rsl.vc_IPA:IPA_RSL_PORT, self:IPA_RSL[0]);
3544 bts[0].rsl.vc_IPA.start(IPA_Emulation.main_client(mp_bsc_ip, mp_bsc_ipa_port, "", 10000, bts[0].rsl.ccm_pars));
3545
3546 /* wait for IPA OML link to connect and then disconnect */
3547 T.start;
3548 alt {
Vadim Yanitskiya2afacc2020-05-18 21:16:19 +07003549 [] IPA_RSL[0].receive(tr_ASP_IPA_EV(ASP_IPA_EVENT_DOWN)) {
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003550 T.stop;
3551 return true;
3552 }
3553 [] IPA_RSL[0].receive { repeat }
3554 [] T.timeout {
Daniel Willmannafce8662018-07-06 23:11:32 +02003555 return false;
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003556 }
3557 }
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003558 return false;
3559}
3560
3561/* BSC should close an RSL connection from a BTS with unknown unit ID (OS#2714). */
3562testcase TC_rsl_unknown_unit_id() runs on test_CT {
3563 if (f_ipa_unknown_unit_id(mp_bsc_rsl_port)) {
3564 setverdict(pass);
3565 } else {
3566 setverdict(fail, "Timeout RSL waiting for connection to close");
3567 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003568 f_shutdown_helper();
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003569}
3570
3571
3572/* BSC should close an RSL connection from a BTS with unknown unit ID (OS#2714). */
3573testcase TC_oml_unknown_unit_id() runs on test_CT {
3574 if (f_ipa_unknown_unit_id(mp_bsc_oml_port)) {
3575 setverdict(pass);
3576 } else {
3577 setverdict(fail, "Timeout OML waiting for connection to close");
3578 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003579 f_shutdown_helper();
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003580}
3581
3582
Harald Weltec1a2fff2017-12-17 11:06:19 +01003583/***********************************************************************
Harald Welte6811d102019-04-14 22:23:14 +02003584 * "New world" test cases using RSL_Emulation + RAN_Emulation
Harald Weltec1a2fff2017-12-17 11:06:19 +01003585 ***********************************************************************/
3586
Harald Welte6811d102019-04-14 22:23:14 +02003587import from RAN_Emulation all;
Harald Welte47cd0e32020-08-21 12:39:11 +02003588import from BSSAP_LE_Emulation all;
Harald Weltec1a2fff2017-12-17 11:06:19 +01003589import from RSL_Emulation all;
3590import from MSC_ConnectionHandler all;
3591
3592type function void_fn(charstring id) runs on MSC_ConnHdlr;
3593
Harald Welte336820c2018-05-31 20:34:52 +02003594/* helper function to create and connect a MSC_ConnHdlr component */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003595private function f_connect_handler(inout MSC_ConnHdlr vc_conn, integer bssap_idx := 0) runs on test_CT {
3596 connect(vc_conn:RAN, g_bssap[bssap_idx].vc_RAN:PROC);
Daniel Willmann191e0d92018-01-17 12:44:35 +01003597 connect(vc_conn:MGCP_PROC, vc_MGCP:MGCP_PROC);
Harald Weltec1a2fff2017-12-17 11:06:19 +01003598 connect(vc_conn:RSL, bts[0].rsl.vc_RSL:CLIENT_PT);
Harald Weltef70df652018-01-29 22:00:23 +01003599 connect(vc_conn:RSL_PROC, bts[0].rsl.vc_RSL:RSL_PROC);
Philipp Maier88f4ae82018-03-01 14:00:58 +01003600 if (isvalue(bts[1])) {
Philipp Maier956a92f2018-02-16 10:58:07 +01003601 connect(vc_conn:RSL1, bts[1].rsl.vc_RSL:CLIENT_PT);
3602 connect(vc_conn:RSL1_PROC, bts[1].rsl.vc_RSL:RSL_PROC);
3603 }
Neels Hofmeyr91401012019-07-11 00:42:35 +02003604 if (isvalue(bts[2])) {
3605 connect(vc_conn:RSL2, bts[2].rsl.vc_RSL:CLIENT_PT);
3606 connect(vc_conn:RSL2_PROC, bts[2].rsl.vc_RSL:RSL_PROC);
3607 }
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003608 connect(vc_conn:BSSAP, g_bssap[bssap_idx].vc_RAN:CLIENT);
Neels Hofmeyrcfe44062020-10-15 02:28:08 +02003609 if (mp_enable_lcs_tests) {
3610 connect(vc_conn:BSSAP_LE, g_bssap_le.vc_BSSAP_LE:CLIENT);
3611 connect(vc_conn:BSSAP_LE_PROC, g_bssap_le.vc_BSSAP_LE:PROC);
3612 }
Daniel Willmann191e0d92018-01-17 12:44:35 +01003613 connect(vc_conn:MGCP, vc_MGCP:MGCP_CLIENT);
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02003614 connect(vc_conn:MGCP_MULTI, vc_MGCP:MGCP_CLIENT_MULTI);
Daniel Willmannebdecc02020-08-12 15:30:17 +02003615 connect(vc_conn:STATSD_PROC, vc_STATSD:STATSD_PROC);
Harald Welte336820c2018-05-31 20:34:52 +02003616}
3617
Neels Hofmeyrda436782021-07-20 22:09:06 +02003618function f_start_handler_create(template (omit) TestHdlrParams pars := omit)
Harald Welte336820c2018-05-31 20:34:52 +02003619runs on test_CT return MSC_ConnHdlr {
3620 var charstring id := testcasename();
3621 var MSC_ConnHdlr vc_conn;
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003622 var integer bssap_idx := 0;
3623 if (isvalue(pars)) {
3624 bssap_idx := valueof(pars).mscpool.bssap_idx;
3625 }
Harald Welte336820c2018-05-31 20:34:52 +02003626 vc_conn := MSC_ConnHdlr.create(id);
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003627 f_connect_handler(vc_conn, bssap_idx);
Neels Hofmeyrda436782021-07-20 22:09:06 +02003628 return vc_conn;
3629}
3630
3631function f_start_handler_run(MSC_ConnHdlr vc_conn, void_fn fn, template (omit) TestHdlrParams pars := omit)
3632runs on test_CT return MSC_ConnHdlr {
3633 var charstring id := testcasename();
Neels Hofmeyr1708d1b2020-10-10 16:56:48 +02003634 /* Emit a marker to appear in the SUT's own logging output */
Neels Hofmeyrda436782021-07-20 22:09:06 +02003635 f_logp(BSCVTY, id & "() start");
Harald Weltea0630032018-03-20 21:09:55 +01003636 vc_conn.start(f_handler_init(fn, id, pars));
Harald Weltec1a2fff2017-12-17 11:06:19 +01003637 return vc_conn;
3638}
3639
Neels Hofmeyrda436782021-07-20 22:09:06 +02003640function f_start_handler(void_fn fn, template (omit) TestHdlrParams pars := omit)
3641runs on test_CT return MSC_ConnHdlr {
3642 return f_start_handler_run(f_start_handler_create(pars), fn, pars);
3643}
3644
Harald Weltea0630032018-03-20 21:09:55 +01003645/* first function inside ConnHdlr component; sets g_pars + starts function */
3646private function f_handler_init(void_fn fn, charstring id, template (omit) TestHdlrParams pars := omit)
3647runs on MSC_ConnHdlr {
3648 if (isvalue(pars)) {
3649 g_pars := valueof(pars);
3650 }
3651 fn.apply(id);
3652}
3653
Oliver Smith26a3db72021-07-09 13:51:29 +02003654private function f_vty_encryption_a5(charstring options) runs on test_CT {
3655 f_vty_transceive(BSCVTY, "configure terminal");
3656 f_vty_transceive(BSCVTY, "network");
3657 f_vty_transceive(BSCVTY, "encryption a5 " & options);
3658 f_vty_transceive(BSCVTY, "exit");
3659 f_vty_transceive(BSCVTY, "exit");
3660}
3661
3662private function f_vty_encryption_a5_reset() runs on test_CT {
3663 /* keep in sync with docker-playground.git ttcn3-bsc-test/osmo-bsc.cfg */
3664 f_vty_encryption_a5("0 1 3");
3665}
3666
Harald Welte3c86ea02018-05-10 22:28:05 +02003667/* Establish signalling channel (non-assignment case) followed by cipher mode */
3668private function f_tc_ciph_mode_a5(charstring id) runs on MSC_ConnHdlr {
Harald Welteed848512018-05-24 22:27:58 +02003669 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3670 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte3c86ea02018-05-10 22:28:05 +02003671 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeSIGNAL);
Philipp Maier23000732018-05-18 11:25:37 +02003672 ass_cmd.pdu.bssmap.assignmentRequest.circuitIdentityCode := omit;
3673 ass_cmd.pdu.bssmap.assignmentRequest.aoIPTransportLayer := omit;
3674 exp_compl.pdu.bssmap.assignmentComplete.circuitIdentityCode := omit;
3675 exp_compl.pdu.bssmap.assignmentComplete.aoIPTransportLayer := omit;
Harald Welte3c86ea02018-05-10 22:28:05 +02003676
Philipp Maier23000732018-05-18 11:25:37 +02003677 f_establish_fully(ass_cmd, exp_compl);
Harald Welte3c86ea02018-05-10 22:28:05 +02003678}
3679testcase TC_ciph_mode_a5_0() runs on test_CT {
3680 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003681 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02003682 pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
3683
3684 f_init(1, true);
3685 f_sleep(1.0);
3686 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
3687 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003688 f_shutdown_helper();
Harald Welte3c86ea02018-05-10 22:28:05 +02003689}
3690testcase TC_ciph_mode_a5_1() runs on test_CT {
3691 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003692 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02003693 pars.encr := valueof(t_EncrParams('02'O, f_rnd_octstring(8)));
3694
3695 f_init(1, true);
3696 f_sleep(1.0);
3697 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
3698 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003699 f_shutdown_helper();
Harald Welte3c86ea02018-05-10 22:28:05 +02003700}
Oliver Smith50b98122021-07-09 15:00:28 +02003701/* OS#4975: verify that A5/2 is preferred over A5/0 */
3702testcase TC_ciph_mode_a5_2_0() runs on test_CT {
3703 var MSC_ConnHdlr vc_conn;
3704 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3705
3706 pars.encr := valueof(t_EncrParams('05'O, f_rnd_octstring(8))); /* A5/0 and A5/2 (0x01|0x04)*/
3707 pars.encr_exp_enc_alg := '04'O; /* A5/2 */
3708
3709 f_init(1, true);
3710 f_vty_encryption_a5("0 1 2 3");
3711 f_sleep(1.0);
3712 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
3713 vc_conn.done;
3714 f_vty_encryption_a5_reset();
3715 f_shutdown_helper();
3716}
Oliver Smith1dff88d2021-07-09 08:45:51 +02003717/* OS#4975: verify that A5/1 is preferred over A5/2 */
3718testcase TC_ciph_mode_a5_2_1() runs on test_CT {
3719 var MSC_ConnHdlr vc_conn;
3720 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3721
3722 pars.encr := valueof(t_EncrParams('06'O, f_rnd_octstring(8))); /* A5/1 and A5/2 (0x02|0x04)*/
3723 pars.encr_exp_enc_alg := '02'O; /* A5/1 */
3724
3725 f_init(1, true);
3726 f_vty_encryption_a5("1 2");
3727 f_sleep(1.0);
3728 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
3729 vc_conn.done;
3730 f_vty_encryption_a5_reset();
3731 f_shutdown_helper();
3732}
Harald Welte3c86ea02018-05-10 22:28:05 +02003733testcase TC_ciph_mode_a5_3() runs on test_CT {
3734 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003735 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02003736 pars.encr := valueof(t_EncrParams('08'O, f_rnd_octstring(8)));
3737
3738 f_init(1, true);
3739 f_sleep(1.0);
3740 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
3741 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003742 f_shutdown_helper();
Harald Welte3c86ea02018-05-10 22:28:05 +02003743}
Neels Hofmeyr81ad27f2021-06-11 00:09:40 +02003744/* Establish a Signalling channel with A5/4 encryption. */
3745testcase TC_ciph_mode_a5_4() runs on test_CT {
3746 var MSC_ConnHdlr vc_conn;
3747 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3748 pars.encr := valueof(t_EncrParams('10'O, f_rnd_octstring(8), f_rnd_octstring(16)));
Harald Welte3c86ea02018-05-10 22:28:05 +02003749
Neels Hofmeyr81ad27f2021-06-11 00:09:40 +02003750 f_init(1, true);
Oliver Smith26a3db72021-07-09 13:51:29 +02003751 f_vty_encryption_a5("0 1 3 4");
Neels Hofmeyr81ad27f2021-06-11 00:09:40 +02003752 f_sleep(1.0);
3753 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
3754 vc_conn.done;
Oliver Smith26a3db72021-07-09 13:51:29 +02003755 f_vty_encryption_a5_reset();
Neels Hofmeyr81ad27f2021-06-11 00:09:40 +02003756 f_shutdown_helper();
3757}
Pau Espin Pedrol07866632020-09-03 19:10:55 +02003758/* establish initial channel, enable ciphering followed by assignment to ciphered channel */
3759private function f_tc_assignment_aoip_tla_v6(charstring id) runs on MSC_ConnHdlr {
3760 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3761 var PDU_BSSAP ass_cmd := f_gen_ass_req(aoip_tla := "::3");
3762 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3763 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
3764
3765 f_establish_fully(ass_cmd, exp_compl);
3766}
3767testcase TC_assignment_aoip_tla_v6() runs on test_CT {
3768 var MSC_ConnHdlr vc_conn;
3769 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3770
3771 f_init(1, true);
3772 f_sleep(1.0);
3773 vc_conn := f_start_handler(refers(f_tc_assignment_aoip_tla_v6), pars);
3774 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003775 f_shutdown_helper();
Pau Espin Pedrol07866632020-09-03 19:10:55 +02003776}
3777
Harald Welte3c86ea02018-05-10 22:28:05 +02003778
3779/* establish initial channel, enable ciphering followed by assignment to ciphered channel */
Harald Welte651fcdc2018-05-10 20:23:16 +02003780private function f_tc_assignment_fr_a5(charstring id) runs on MSC_ConnHdlr {
Harald Welteed848512018-05-24 22:27:58 +02003781 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3782 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Weltec1a2fff2017-12-17 11:06:19 +01003783
Harald Welte552620d2017-12-16 23:21:36 +01003784 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3785 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Welte73cd2712017-12-17 00:44:52 +01003786
Harald Weltea0630032018-03-20 21:09:55 +01003787 f_establish_fully(ass_cmd, exp_compl);
Harald Welte552620d2017-12-16 23:21:36 +01003788}
Harald Welte552620d2017-12-16 23:21:36 +01003789testcase TC_assignment_fr_a5_0() runs on test_CT {
3790 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003791 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02003792 pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
Harald Welte552620d2017-12-16 23:21:36 +01003793
Harald Welte89d42e82017-12-17 16:42:41 +01003794 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01003795 f_sleep(1.0);
Harald Welte651fcdc2018-05-10 20:23:16 +02003796 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
Harald Welte552620d2017-12-16 23:21:36 +01003797 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003798 f_shutdown_helper();
Harald Welte552620d2017-12-16 23:21:36 +01003799}
Harald Welte552620d2017-12-16 23:21:36 +01003800testcase TC_assignment_fr_a5_1() runs on test_CT {
Harald Weltec1a2fff2017-12-17 11:06:19 +01003801 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003802 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02003803 pars.encr := valueof(t_EncrParams('02'O, f_rnd_octstring(8)));
Harald Weltec1a2fff2017-12-17 11:06:19 +01003804
Harald Welte89d42e82017-12-17 16:42:41 +01003805 f_init(1, true);
Harald Weltec1a2fff2017-12-17 11:06:19 +01003806 f_sleep(1.0);
Harald Welte651fcdc2018-05-10 20:23:16 +02003807 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
3808 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003809 f_shutdown_helper();
Harald Welte651fcdc2018-05-10 20:23:16 +02003810}
3811testcase TC_assignment_fr_a5_3() runs on test_CT {
3812 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003813 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02003814 pars.encr := valueof(t_EncrParams('08'O, f_rnd_octstring(8)));
Harald Weltec1a2fff2017-12-17 11:06:19 +01003815
Harald Welte651fcdc2018-05-10 20:23:16 +02003816 f_init(1, true);
3817 f_sleep(1.0);
3818 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
Harald Weltec1a2fff2017-12-17 11:06:19 +01003819 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003820 f_shutdown_helper();
Harald Weltec1a2fff2017-12-17 11:06:19 +01003821}
Neels Hofmeyr0d8ec532021-06-11 00:09:48 +02003822/* Establish a Signalling channel and re-assign to TCH/F with A5/4 encryption. */
3823testcase TC_assignment_fr_a5_4() runs on test_CT {
3824 var MSC_ConnHdlr vc_conn;
3825 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3826 pars.encr := valueof(t_EncrParams('10'O, f_rnd_octstring(8), f_rnd_octstring(16)));
3827
3828 f_init(1, true);
Oliver Smith7eabd312021-07-12 14:18:56 +02003829 f_vty_encryption_a5("0 1 3 4");
Neels Hofmeyr0d8ec532021-06-11 00:09:48 +02003830 f_sleep(1.0);
3831 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
3832 vc_conn.done;
Oliver Smith7eabd312021-07-12 14:18:56 +02003833 f_vty_encryption_a5_reset();
Neels Hofmeyr0d8ec532021-06-11 00:09:48 +02003834 f_shutdown_helper();
3835}
Harald Weltec1a2fff2017-12-17 11:06:19 +01003836
Neels Hofmeyr0faeb7a2021-06-10 23:59:35 +02003837/* Allow only A5/4, but omit the Kc128 IE from MSC's msg. Expect Cipher Mode Reject. */
3838testcase TC_assignment_fr_a5_4_fail() runs on test_CT {
3839 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3840 var MSC_ConnHdlr vc_conn;
3841
3842 f_init(1, true);
3843 f_sleep(1.0);
3844
3845 pars.encr := valueof(t_EncrParams('10'O, f_rnd_octstring(8))); // A5/4 support, but Kc128 missing!
3846 vc_conn := f_start_handler(refers(f_TC_assignment_a5_not_sup), pars);
3847 vc_conn.done;
3848 f_shutdown_helper();
3849}
3850
Harald Welte552620d2017-12-16 23:21:36 +01003851/* Expect ASSIGNMENT FAIL if mandatory IE is missing */
3852private function f_tc_assignment_fr_a5_1_codec_missing(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02003853 g_pars := f_gen_test_hdlr_pars();
Harald Welte552620d2017-12-16 23:21:36 +01003854 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +02003855 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte552620d2017-12-16 23:21:36 +01003856
3857 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02003858 /* Omit: ass_cmd.pdu.bssmap.assignmentRequest.codecList */
3859
Harald Weltea0630032018-03-20 21:09:55 +01003860 f_establish_fully(ass_cmd, exp_fail);
Harald Welte552620d2017-12-16 23:21:36 +01003861}
Harald Welte552620d2017-12-16 23:21:36 +01003862testcase TC_assignment_fr_a5_1_codec_missing() runs on test_CT {
3863 var MSC_ConnHdlr vc_conn;
3864
Harald Welte89d42e82017-12-17 16:42:41 +01003865 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01003866 f_sleep(1.0);
3867
Harald Welte8863fa12018-05-10 20:15:27 +02003868 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5_1_codec_missing));
Harald Welte552620d2017-12-16 23:21:36 +01003869 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003870 f_shutdown_helper();
Harald Welte552620d2017-12-16 23:21:36 +01003871}
3872
Neels Hofmeyr04d6e6a2021-06-11 00:10:02 +02003873private function f_TC_assignment_a5_not_sup(charstring id) runs on MSC_ConnHdlr {
3874 var template PDU_BSSAP exp_ass_cpl := f_gen_exp_compl();
3875 var PDU_BSSAP exp_ass_req := f_gen_ass_req();
Harald Welte552620d2017-12-16 23:21:36 +01003876
Neels Hofmeyr04d6e6a2021-06-11 00:10:02 +02003877 exp_ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3878 exp_ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
3879
3880 /* this is like the beginning of f_establish_fully(), but only up to ciphering reject */
3881
3882 var BSSMAP_FIELD_CodecType codecType;
3883 timer T := 10.0;
3884
3885 codecType := exp_ass_req.pdu.bssmap.assignmentRequest.codecList.codecElements[0].codecType;
3886 f_MscConnHdlr_init(g_pars.media_nr, host_bts, host_mgw_mgcp, codecType);
3887
3888 f_create_chan_and_exp();
3889 /* we should now have a COMPL_L3 at the MSC */
3890
3891 var template PDU_BSSAP exp_l3_compl;
3892 exp_l3_compl := tr_BSSMAP_ComplL3()
3893 if (g_pars.aoip == false) {
3894 exp_l3_compl.pdu.bssmap.completeLayer3Information.codecList := omit;
3895 } else {
3896 exp_l3_compl.pdu.bssmap.completeLayer3Information.codecList := ?;
3897 }
3898 T.start;
3899 alt {
3900 [] BSSAP.receive(exp_l3_compl);
3901 [] BSSAP.receive(tr_BSSMAP_ComplL3) {
3902 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received non-matching COMPLETE LAYER 3 INFORMATION");
3903 }
3904 [] T.timeout {
3905 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for COMPLETE LAYER 3 INFORMATION");
3906 }
3907 }
3908
3909 /* Start ciphering, expect Cipher Mode Reject */
Neels Hofmeyr6c388f22021-06-11 02:36:56 +02003910 f_cipher_mode(g_pars.encr, exp_fail := true);
Harald Welte552620d2017-12-16 23:21:36 +01003911}
Neels Hofmeyr04d6e6a2021-06-11 00:10:02 +02003912testcase TC_assignment_fr_a5_not_sup() runs on test_CT {
3913 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte552620d2017-12-16 23:21:36 +01003914 var MSC_ConnHdlr vc_conn;
3915
Harald Welte89d42e82017-12-17 16:42:41 +01003916 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01003917 f_sleep(1.0);
3918
Neels Hofmeyr0588cad2021-06-11 01:38:18 +02003919 pars.encr := valueof(t_EncrParams('20'O, f_rnd_octstring(8), f_rnd_octstring(16)));
Neels Hofmeyr04d6e6a2021-06-11 00:10:02 +02003920 vc_conn := f_start_handler(refers(f_TC_assignment_a5_not_sup), pars);
Harald Welte552620d2017-12-16 23:21:36 +01003921 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003922 f_shutdown_helper();
Harald Welte552620d2017-12-16 23:21:36 +01003923}
3924
3925
Harald Welte4532e0a2017-12-23 02:05:44 +01003926private function f_tc_assignment_sign(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02003927 g_pars := f_gen_test_hdlr_pars();
Harald Welte4532e0a2017-12-23 02:05:44 +01003928 var template PDU_BSSAP exp_compl := tr_BSSMAP_AssignmentComplete(omit, omit);
Philipp Maier48604732018-10-09 15:00:37 +02003929 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte4532e0a2017-12-23 02:05:44 +01003930 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeSIGNAL);
Daniel Willmannebdecc02020-08-12 15:30:17 +02003931
3932 f_statsd_reset();
Harald Weltea0630032018-03-20 21:09:55 +01003933 f_establish_fully(ass_cmd, exp_compl);
Daniel Willmannebdecc02020-08-12 15:30:17 +02003934
3935 var StatsDExpects expect := {
Daniel Willmannc5398f72020-09-21 10:41:35 +02003936 { name := "TTCN3.bts.0.chreq.total", mtype := "c", min := 1, max := 1},
3937 { name := "TTCN3.bts.0.chreq.successful", mtype := "c", min := 1, max := 1},
Daniel Willmannebdecc02020-08-12 15:30:17 +02003938 { name := "TTCN3.bsc.0.assignment.attempted", mtype := "c", min := 1, max := 1},
3939 { name := "TTCN3.bsc.0.assignment.completed", mtype := "c", min := 1, max := 1}
3940 };
3941 f_statsd_expect(expect);
Harald Welte4532e0a2017-12-23 02:05:44 +01003942}
3943
3944testcase TC_assignment_sign() runs on test_CT {
3945 var MSC_ConnHdlr vc_conn;
3946
3947 f_init(1, true);
3948 f_sleep(1.0);
3949
Harald Welte8863fa12018-05-10 20:15:27 +02003950 vc_conn := f_start_handler(refers(f_tc_assignment_sign));
Harald Welte4532e0a2017-12-23 02:05:44 +01003951 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003952 f_shutdown_helper();
Harald Welte4532e0a2017-12-23 02:05:44 +01003953}
3954
Harald Welte60aa5762018-03-21 19:33:13 +01003955/***********************************************************************
3956 * Codec (list) testing
3957 ***********************************************************************/
3958
3959/* check if the given rsl_mode is compatible with the a_elem */
3960private function f_match_codec(BSSMAP_FIELD_CodecElement a_elem, RSL_IE_ChannelMode rsl_mode)
3961return boolean {
3962 select (a_elem.codecType) {
3963 case (GSM_FR) {
3964 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM1))) {
3965 return true;
3966 }
3967 }
3968 case (GSM_HR) {
3969 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1))) {
3970 return true;
3971 }
3972 }
3973 case (GSM_EFR) {
3974 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM2))) {
3975 return true;
3976 }
3977 }
3978 case (FR_AMR) {
3979 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM3))) {
3980 return true;
3981 }
3982 }
3983 case (HR_AMR) {
3984 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM3))) {
3985 return true;
3986 }
3987 }
3988 case else { }
3989 }
3990 return false;
3991}
3992
3993/* check if the given rsl_mode is compatible with the a_list */
3994private function f_match_codecs(BSSMAP_IE_SpeechCodecList a_list, RSL_IE_ChannelMode rsl_mode)
3995return boolean {
3996 for (var integer i := 0; i < sizeof(a_list); i := i+1) {
3997 if (f_match_codec(a_list.codecElements[i], rsl_mode)) {
3998 return true;
3999 }
4000 }
4001 return false;
4002}
4003
4004/* determine BSSMAP_IE_ChannelType from *first* element of BSSMAP_FIELD_CodecElement */
Philipp Maier61f6b572018-07-06 14:03:38 +02004005function f_BSSMAP_chtype_from_codec(BSSMAP_FIELD_CodecElement a_elem)
Harald Welte60aa5762018-03-21 19:33:13 +01004006return BSSMAP_IE_ChannelType {
4007 /* FIXME: actually look at all elements of BSSMAP_IE_SpeechCodecList */
4008 var BSSMAP_IE_ChannelType ret := valueof(ts_BSSMAP_IE_ChannelType);
4009 select (a_elem.codecType) {
4010 case (GSM_FR) {
4011 ret.channelRateAndType := ChRate_TCHF;
4012 ret.speechId_DataIndicator := Spdi_TCHF_FR;
4013 }
4014 case (GSM_HR) {
4015 ret.channelRateAndType := ChRate_TCHH;
4016 ret.speechId_DataIndicator := Spdi_TCHH_HR;
4017 }
4018 case (GSM_EFR) {
4019 ret.channelRateAndType := ChRate_TCHF;
4020 ret.speechId_DataIndicator := Spdi_TCHF_EFR;
4021 }
4022 case (FR_AMR) {
4023 ret.channelRateAndType := ChRate_TCHF;
4024 ret.speechId_DataIndicator := Spdi_TCHF_AMR;
4025 }
4026 case (HR_AMR) {
4027 ret.channelRateAndType := ChRate_TCHH;
4028 ret.speechId_DataIndicator := Spdi_TCHH_AMR;
4029 }
4030 case else {
4031 setverdict(fail, "Unsupported codec ", a_elem);
Daniel Willmannafce8662018-07-06 23:11:32 +02004032 mtc.stop;
Harald Welte60aa5762018-03-21 19:33:13 +01004033 }
4034 }
4035 return ret;
4036}
4037
Harald Weltea63b9102018-03-22 20:36:16 +01004038private function f_rsl_chmod_tmpl_from_codec(BSSMAP_FIELD_CodecElement a_elem)
4039return template RSL_IE_Body {
4040 var template RSL_IE_Body mode_ie := {
4041 chan_mode := {
4042 len := ?,
4043 reserved := ?,
4044 dtx_d := ?,
4045 dtx_u := ?,
4046 spd_ind := RSL_SPDI_SPEECH,
4047 ch_rate_type := -,
4048 coding_alg_rate := -
4049 }
4050 }
4051
4052 select (a_elem.codecType) {
4053 case (GSM_FR) {
4054 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
4055 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM1;
4056 }
4057 case (GSM_HR) {
4058 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_H;
4059 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM1;
4060 }
4061 case (GSM_EFR) {
4062 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
4063 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM2;
4064 }
4065 case (FR_AMR) {
4066 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
4067 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM3;
4068 }
4069 case (HR_AMR) {
4070 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_H;
4071 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM3;
4072 }
4073 }
4074 return mode_ie;
4075}
4076
Harald Welte60aa5762018-03-21 19:33:13 +01004077type record CodecListTest {
4078 BSSMAP_IE_SpeechCodecList codec_list,
4079 charstring id
4080}
4081type record of CodecListTest CodecListTests
4082
4083private function f_TC_assignment_codec(charstring id) runs on MSC_ConnHdlr {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02004084 var PDU_BSSAP ass_cmd := f_gen_ass_req(g_pars.use_osmux);
4085 var template PDU_BSSAP exp_compl := f_gen_exp_compl(g_pars.use_osmux);
Harald Welte60aa5762018-03-21 19:33:13 +01004086
4087 /* puzzle together the ASSIGNMENT REQ for given codec[s] */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02004088 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welte79f3f542018-05-25 20:02:37 +02004089 ass_cmd.pdu.bssmap.assignmentRequest.codecList := g_pars.ass_codec_list;
4090 exp_compl.pdu.bssmap.assignmentComplete.speechCodec.codecElements[0] :=
4091 g_pars.ass_codec_list.codecElements[0];
Philipp Maierd0e64b02019-03-13 14:15:23 +01004092 if (isvalue(g_pars.expect_mr_s0_s7)) {
4093 exp_compl.pdu.bssmap.assignmentComplete.speechCodec.codecElements[0].s0_7 :=
4094 g_pars.expect_mr_s0_s7;
4095 }
Harald Welte79f3f542018-05-25 20:02:37 +02004096 }
Harald Welte60aa5762018-03-21 19:33:13 +01004097 ass_cmd.pdu.bssmap.assignmentRequest.channelType :=
4098 f_BSSMAP_chtype_from_codec(g_pars.ass_codec_list.codecElements[0]);
Harald Welte60aa5762018-03-21 19:33:13 +01004099 log("expecting ASS COMPL like this: ", exp_compl);
4100
4101 f_establish_fully(ass_cmd, exp_compl);
Harald Weltea63b9102018-03-22 20:36:16 +01004102
Neels Hofmeyr559d5d02021-04-16 16:50:49 +02004103 if (not g_pars.expect_channel_mode_modify) {
4104 /* Verify that the RSL-side activation actually matches our expectations */
4105 var RSL_Message rsl := f_rslem_get_last_act(RSL_PROC, 0, g_chan_nr);
Harald Weltea63b9102018-03-22 20:36:16 +01004106
Neels Hofmeyr559d5d02021-04-16 16:50:49 +02004107 var RSL_IE_Body mode_ie;
4108 if (f_rsl_find_ie(rsl, RSL_IE_CHAN_MODE, mode_ie) == false) {
4109 setverdict(fail, "Couldn't find CHAN_MODE IE");
Daniel Willmannafce8662018-07-06 23:11:32 +02004110 mtc.stop;
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02004111 }
Neels Hofmeyr559d5d02021-04-16 16:50:49 +02004112 var template RSL_IE_Body t_mode_ie := f_rsl_chmod_tmpl_from_codec(g_pars.ass_codec_list.codecElements[0]);
4113 if (not match(mode_ie, t_mode_ie)) {
4114 log("mode_ie ", mode_ie, " != t_mode_ie ", t_mode_ie);
4115 setverdict(fail, "RSL Channel Mode IE doesn't match expectation");
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02004116 }
Neels Hofmeyr559d5d02021-04-16 16:50:49 +02004117
4118 var RSL_IE_Body mr_conf;
4119 if (g_pars.expect_mr_conf_ie != omit) {
4120 if (f_rsl_find_ie(rsl, RSL_IE_MR_CONFIG, mr_conf) == false) {
4121 setverdict(fail, "Missing MR CONFIG IE in RSL Chan Activ");
4122 mtc.stop;
4123 }
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02004124 log("found RSL MR CONFIG IE: ", mr_conf);
Neels Hofmeyr559d5d02021-04-16 16:50:49 +02004125
4126 if (not match(mr_conf, g_pars.expect_mr_conf_ie)) {
4127 setverdict(fail, "RSL MR CONFIG IE does not match expectation. Expected: ",
4128 g_pars.expect_mr_conf_ie);
4129 }
4130 } else {
4131 if (f_rsl_find_ie(rsl, RSL_IE_MR_CONFIG, mr_conf) == true) {
4132 log("found RSL MR CONFIG IE: ", mr_conf);
4133 setverdict(fail, "Found MR CONFIG IE in RSL Chan Activ, expecting omit");
4134 mtc.stop;
4135 }
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02004136 }
4137 }
Harald Welte60aa5762018-03-21 19:33:13 +01004138}
4139
Philipp Maierd0e64b02019-03-13 14:15:23 +01004140private function f_TC_assignment_codec_fail(charstring id) runs on MSC_ConnHdlr {
4141
4142 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4143 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
4144
4145 /* puzzle together the ASSIGNMENT REQ for given codec[s] */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02004146 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Philipp Maierd0e64b02019-03-13 14:15:23 +01004147 ass_cmd.pdu.bssmap.assignmentRequest.codecList := g_pars.ass_codec_list;
4148 }
4149 ass_cmd.pdu.bssmap.assignmentRequest.channelType :=
4150 f_BSSMAP_chtype_from_codec(g_pars.ass_codec_list.codecElements[0]);
4151 log("expecting ASS FAIL like this: ", exp_fail);
4152
4153 f_establish_fully(ass_cmd, exp_fail);
4154}
4155
Neels Hofmeyrbcfc9442021-11-29 16:44:08 +01004156const CounterNameVals counternames_bsc_bts_assignment := {
4157 { "assignment:attempted", 0 },
4158 { "assignment:completed", 0 },
4159 { "assignment:stopped", 0 },
4160 { "assignment:no_channel", 0 },
4161 { "assignment:timeout", 0 },
4162 { "assignment:failed", 0 },
4163 { "assignment:error", 0 }
4164};
4165
4166const CounterNameVals counternames_bts_assignment := {
4167 { "assignment:attempted_sign", 0 },
4168 { "assignment:attempted_speech", 0 },
4169 { "assignment:completed_sign", 0 },
4170 { "assignment:completed_speech", 0 },
4171 { "assignment:stopped_sign", 0 },
4172 { "assignment:stopped_speech", 0 },
4173 { "assignment:no_channel_sign", 0 },
4174 { "assignment:no_channel_speech", 0 },
4175 { "assignment:timeout_sign", 0 },
4176 { "assignment:timeout_speech", 0 },
4177 { "assignment:failed_sign", 0 },
4178 { "assignment:failed_speech", 0 },
4179 { "assignment:error_sign", 0 },
4180 { "assignment:error_speech", 0 }
4181};
4182
4183function f_ctrs_bsc_and_bts_assignment_init(integer bts_count := NUM_BTS) runs on test_CT {
4184 var CounterNameVals bts_names := counternames_bsc_bts_assignment & counternames_bts_assignment;
4185 f_ctrs_bts_init(bts_count, bts_names);
4186 f_ctrs_bsc_init(counternames_bsc_bts_assignment);
4187}
4188
Harald Welte60aa5762018-03-21 19:33:13 +01004189testcase TC_assignment_codec_fr() 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;
4192
4193 f_init(1, true);
4194 f_sleep(1.0);
Neels Hofmeyrbcfc9442021-11-29 16:44:08 +01004195 f_ctrs_bsc_and_bts_assignment_init(1);
Harald Welte60aa5762018-03-21 19:33:13 +01004196
4197 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Welte8863fa12018-05-10 20:15:27 +02004198 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01004199 vc_conn.done;
Neels Hofmeyrbcfc9442021-11-29 16:44:08 +01004200
4201 f_ctrs_bsc_and_bts_add(0, "assignment:attempted", 1);
4202 f_ctrs_bts_add(0, "assignment:attempted_speech", 1);
4203 f_ctrs_bsc_and_bts_add(0, "assignment:completed", 1);
4204 f_ctrs_bts_add(0, "assignment:completed_speech", 1);
4205 f_ctrs_bts_verify();
4206
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004207 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01004208}
4209
4210testcase TC_assignment_codec_hr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02004211 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01004212 var MSC_ConnHdlr vc_conn;
4213
4214 f_init(1, true);
4215 f_sleep(1.0);
Neels Hofmeyrbcfc9442021-11-29 16:44:08 +01004216 f_ctrs_bsc_and_bts_assignment_init(1);
Harald Welte60aa5762018-03-21 19:33:13 +01004217
4218 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
Harald Welte8863fa12018-05-10 20:15:27 +02004219 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01004220 vc_conn.done;
Neels Hofmeyrbcfc9442021-11-29 16:44:08 +01004221
4222 f_ctrs_bsc_and_bts_add(0, "assignment:attempted", 1);
4223 f_ctrs_bts_add(0, "assignment:attempted_speech", 1);
4224 f_ctrs_bsc_and_bts_add(0, "assignment:completed", 1);
4225 f_ctrs_bts_add(0, "assignment:completed_speech", 1);
4226 f_ctrs_bts_verify();
4227
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004228 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01004229}
4230
4231testcase TC_assignment_codec_efr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02004232 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01004233 var MSC_ConnHdlr vc_conn;
4234
4235 f_init(1, true);
4236 f_sleep(1.0);
4237
4238 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecEFR}));
Harald Welte8863fa12018-05-10 20:15:27 +02004239 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01004240 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004241 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01004242}
4243
Philipp Maierd0e64b02019-03-13 14:15:23 +01004244/* Allow 5,90k only (current default config) */
4245private function f_allow_amr_rate_5_90k() runs on test_CT {
Neels Hofmeyr2a5670b2020-11-25 23:39:57 +00004246 f_vty_cfg_msc(BSCVTY, 0, {
4247 "amr-config 12_2k forbidden",
4248 "amr-config 10_2k forbidden",
4249 "amr-config 7_95k forbidden",
4250 "amr-config 7_40k forbidden",
4251 "amr-config 6_70k forbidden",
4252 "amr-config 5_90k allowed",
4253 "amr-config 5_15k forbidden",
4254 "amr-config 4_75k forbidden"
4255 });
Philipp Maierd0e64b02019-03-13 14:15:23 +01004256}
4257
4258/* Allow 4,75k, 5,90k, 4,70k and 12,2k, which are the most common rates
4259 * ("Config-NB-Code = 1") */
4260private function f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k() runs on test_CT {
Neels Hofmeyr2a5670b2020-11-25 23:39:57 +00004261 f_vty_cfg_msc(BSCVTY, 0, {
4262 "amr-config 12_2k allowed",
4263 "amr-config 10_2k forbidden",
4264 "amr-config 7_95k forbidden",
4265 "amr-config 7_40k allowed",
4266 "amr-config 6_70k forbidden",
4267 "amr-config 5_90k allowed",
4268 "amr-config 5_15k forbidden",
4269 "amr-config 4_75k allowed"
4270 });
Philipp Maierd0e64b02019-03-13 14:15:23 +01004271}
4272
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00004273private function f_vty_amr_start_mode_set(boolean fr, charstring startmode) runs on test_CT {
4274 var charstring tch;
4275 if (fr) {
4276 tch := "tch-f";
4277 } else {
4278 tch := "tch-h";
4279 }
4280 f_vty_cfg_bts(BSCVTY, 0, { "amr " & tch & " start-mode " & startmode });
4281}
4282
4283/* Set the AMR start-mode for this TCH back to the default configuration. */
4284private function f_vty_amr_start_mode_restore(boolean fr) runs on test_CT {
4285 f_vty_amr_start_mode_set(fr, "auto");
4286}
4287
Harald Welte60aa5762018-03-21 19:33:13 +01004288testcase TC_assignment_codec_amr_f() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02004289 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01004290 var MSC_ConnHdlr vc_conn;
Philipp Maier7695a0d2018-09-27 17:52:14 +02004291
4292 /* Note: This setups the codec configuration. The parameter payload in
4293 * mr_conf must be consistant with the parameter codecElements in pars
4294 * and also must match the amr-config in osmo-bsc.cfg! */
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02004295 var RSL_IE_Body mr_conf := {
4296 other := {
4297 len := 2,
4298 payload := '2804'O
4299 }
4300 };
Harald Welte60aa5762018-03-21 19:33:13 +01004301
Philipp Maier7695a0d2018-09-27 17:52:14 +02004302 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
Philipp Maier806f8f12019-03-12 12:13:41 +01004303 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
Philipp Maier7695a0d2018-09-27 17:52:14 +02004304 pars.ass_codec_list.codecElements[0].s8_15 := '01010111'B;
4305 pars.expect_mr_conf_ie := mr_conf;
4306
Harald Welte60aa5762018-03-21 19:33:13 +01004307 f_init(1, true);
4308 f_sleep(1.0);
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00004309 f_vty_amr_start_mode_set(true, "1");
Neels Hofmeyrbcfc9442021-11-29 16:44:08 +01004310 f_ctrs_bsc_and_bts_assignment_init(1);
Harald Welte60aa5762018-03-21 19:33:13 +01004311
Harald Welte8863fa12018-05-10 20:15:27 +02004312 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01004313 vc_conn.done;
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00004314
Neels Hofmeyrbcfc9442021-11-29 16:44:08 +01004315 f_ctrs_bsc_and_bts_add(0, "assignment:attempted", 1);
4316 f_ctrs_bts_add(0, "assignment:attempted_speech", 1);
4317 f_ctrs_bsc_and_bts_add(0, "assignment:completed", 1);
4318 f_ctrs_bts_add(0, "assignment:completed_speech", 1);
4319 f_ctrs_bts_verify();
4320
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00004321 f_vty_amr_start_mode_restore(true);
Vadim Yanitskiy292e5962021-01-03 14:18:47 +01004322 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01004323}
4324
4325testcase TC_assignment_codec_amr_h() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02004326 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01004327 var MSC_ConnHdlr vc_conn;
Philipp Maier7695a0d2018-09-27 17:52:14 +02004328
4329 /* See note above */
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02004330 var RSL_IE_Body mr_conf := {
4331 other := {
4332 len := 2,
4333 payload := '2804'O
4334 }
4335 };
Harald Welte60aa5762018-03-21 19:33:13 +01004336
Philipp Maier7695a0d2018-09-27 17:52:14 +02004337 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
Philipp Maier806f8f12019-03-12 12:13:41 +01004338 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
Philipp Maier7695a0d2018-09-27 17:52:14 +02004339 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
4340 pars.expect_mr_conf_ie := mr_conf;
4341
Harald Welte60aa5762018-03-21 19:33:13 +01004342 f_init(1, true);
4343 f_sleep(1.0);
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00004344 f_vty_amr_start_mode_set(false, "1");
Neels Hofmeyrbcfc9442021-11-29 16:44:08 +01004345 f_ctrs_bsc_and_bts_assignment_init(1);
Harald Welte60aa5762018-03-21 19:33:13 +01004346
Harald Welte8863fa12018-05-10 20:15:27 +02004347 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01004348 vc_conn.done;
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00004349
Neels Hofmeyrbcfc9442021-11-29 16:44:08 +01004350 f_ctrs_bsc_and_bts_add(0, "assignment:attempted", 1);
4351 f_ctrs_bts_add(0, "assignment:attempted_speech", 1);
4352 f_ctrs_bsc_and_bts_add(0, "assignment:completed", 1);
4353 f_ctrs_bts_add(0, "assignment:completed_speech", 1);
4354 f_ctrs_bts_verify();
4355
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00004356 f_vty_amr_start_mode_restore(false);
Vadim Yanitskiy292e5962021-01-03 14:18:47 +01004357 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01004358}
4359
Neels Hofmeyr559d5d02021-04-16 16:50:49 +02004360/* Establish signalling on a TCH/F lchan, and then switch to speech mode without a new Assignment. */
4361testcase TC_assignment_codec_fr_by_mode_modify() runs on test_CT {
4362 var TestHdlrParams pars := f_gen_test_hdlr_pars();
4363 var MSC_ConnHdlr vc_conn;
4364
4365 f_init(1, true);
4366 f_sleep(1.0);
4367
4368 /* By disabling all SDCCH, the MS should be given a TCH/F for signalling. Then activating an FR codec should
4369 * merely do a Channel Mode Modify, and not assign to a new lchan. f_establish_fully() already accounts for
4370 * expecting a Channel Mode Modify if the channel type is compatible. */
4371 f_disable_all_sdcch();
4372 f_disable_all_tch_h();
4373
4374 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4375 pars.expect_channel_mode_modify := true;
4376 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
4377 vc_conn.done;
4378
4379 f_enable_all_sdcch();
4380 f_enable_all_tch();
4381 f_shutdown_helper();
4382}
4383
Neels Hofmeyr454d7922020-11-26 02:24:57 +00004384/* 'amr start-mode auto' should not keep the (unused) 'smod' bits from previous configuration */
4385testcase TC_assignment_codec_amr_startmode_cruft() runs on test_CT {
4386 var TestHdlrParams pars := f_gen_test_hdlr_pars();
4387 var MSC_ConnHdlr vc_conn;
4388
4389 var RSL_IE_Body mr_conf := {
4390 other := {
4391 len := 2,
4392 payload := '2004'O /* <- expect ICMI=0, smod=00 */
4393 }
4394 };
4395
4396 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
4397 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
4398 pars.ass_codec_list.codecElements[0].s8_15 := '01010111'B;
4399 pars.expect_mr_conf_ie := mr_conf;
4400
4401 f_init(1, true);
4402 f_sleep(1.0);
4403
4404 /* First set nonzero start mode bits */
4405 f_vty_amr_start_mode_set(true, "4");
4406 /* Now set to auto, and expect the startmode bits to be zero in the message, i.e. ensure that osmo-bsc does not
4407 * let the startmode bits stick around and has deterministic MultiRate config for 'start-mode auto'; that is
4408 * ensured by above '2004'O, where 'x0xx'O indicates ICMI = 0, spare = 0, smod = 00. */
4409 f_vty_amr_start_mode_set(true, "auto");
4410
4411 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
4412 vc_conn.done;
Neels Hofmeyr454d7922020-11-26 02:24:57 +00004413
4414 /* Clear the startmode bits to not affect subsequent tests, in case the bits should indeed stick around. */
4415 f_vty_amr_start_mode_set(true, "1");
4416 f_vty_amr_start_mode_restore(true);
Vadim Yanitskiy292e5962021-01-03 14:18:47 +01004417 f_shutdown_helper();
Neels Hofmeyr454d7922020-11-26 02:24:57 +00004418}
4419
Neels Hofmeyr21863562020-11-26 00:34:33 +00004420function f_TC_assignment_codec_amr(boolean fr, octetstring mrconf, bitstring s8_s0, bitstring exp_s8_s0,
4421 charstring start_mode := "1")
Philipp Maierd0e64b02019-03-13 14:15:23 +01004422runs on test_CT {
4423
4424 var TestHdlrParams pars := f_gen_test_hdlr_pars();
4425 var MSC_ConnHdlr vc_conn;
4426
4427 /* See note above */
4428 var RSL_IE_Body mr_conf := {
4429 other := {
4430 len := lengthof(mrconf),
4431 payload := mrconf
4432 }
4433 };
4434
4435 if (fr) {
4436 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
4437 } else {
4438 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
4439 }
4440 pars.ass_codec_list.codecElements[0].s0_7 := s8_s0;
4441 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
4442 pars.expect_mr_conf_ie := mr_conf;
4443 pars.expect_mr_s0_s7 := exp_s8_s0;
4444
4445 f_init(1, true);
4446 f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k();
Neels Hofmeyr21863562020-11-26 00:34:33 +00004447 f_vty_amr_start_mode_set(fr, start_mode);
Philipp Maierd0e64b02019-03-13 14:15:23 +01004448 f_sleep(1.0);
4449
4450 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
4451 vc_conn.done;
4452 f_allow_amr_rate_5_90k();
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00004453 f_vty_amr_start_mode_restore(fr);
Philipp Maierd0e64b02019-03-13 14:15:23 +01004454}
4455
4456function f_TC_assignment_codec_amr_fail(boolean fr, bitstring s8_s0)
4457runs on test_CT {
4458
4459 var TestHdlrParams pars := f_gen_test_hdlr_pars();
4460 var MSC_ConnHdlr vc_conn;
4461
4462 if (fr) {
4463 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
4464 } else {
4465 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
4466 }
4467 pars.ass_codec_list.codecElements[0].s0_7 := s8_s0;
4468 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
4469
4470 f_init(1, true);
4471 f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k();
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00004472 f_vty_amr_start_mode_set(fr, "1");
Philipp Maierd0e64b02019-03-13 14:15:23 +01004473 f_sleep(1.0);
4474
4475 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fail), pars);
4476 vc_conn.done;
4477 f_allow_amr_rate_5_90k();
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00004478 f_vty_amr_start_mode_restore(fr);
Philipp Maierd0e64b02019-03-13 14:15:23 +01004479}
4480
4481
4482/* Set S1, we expect an AMR multirate configuration IE with all four rates
4483 * set. */
4484testcase TC_assignment_codec_amr_f_S1() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004485 f_TC_assignment_codec_amr(true, '289520882208'O, '00000010'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004486 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004487}
4488
4489/* Set S1, we expect an AMR multirate configuration IE with the lower three
4490 * rates set. */
4491testcase TC_assignment_codec_amr_h_S1() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004492 f_TC_assignment_codec_amr(false, '2815208820'O, '00000010'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004493 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004494}
4495
4496/* Set S1 and two other rates, we expect an AMR MULTIRATE CONFIGURATION IE with
4497 * all four rates (and only S1 set in the ASSIGNMENT COMPLETE) */
4498testcase TC_assignment_codec_amr_f_S124() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004499 f_TC_assignment_codec_amr(true, '289520882208'O, '00010110'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004500 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004501}
4502
4503/* Set S1 and two other rates, we expect an AMR MULTIRATE CONFIGURATION IE with
4504 * all four rates (and only S1 set in the ASSIGNMENT COMPLETE) */
4505testcase TC_assignment_codec_amr_h_S124() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004506 f_TC_assignment_codec_amr(false, '2815208820'O, '00010110'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004507 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004508}
4509
4510/* The following block of tests selects more and more rates until all four
4511 * possible rates are in the active set (full rate) */
4512testcase TC_assignment_codec_amr_f_S0() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004513 f_TC_assignment_codec_amr(true, '2801'O, '00000001'B, '00000001'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004514 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004515}
4516
4517testcase TC_assignment_codec_amr_f_S02() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004518 f_TC_assignment_codec_amr(true, '28052080'O, '00000101'B, '00000101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004519 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004520}
4521
4522testcase TC_assignment_codec_amr_f_S024() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004523 f_TC_assignment_codec_amr(true, '2815208820'O, '00010101'B, '00010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004524 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004525}
4526
4527testcase TC_assignment_codec_amr_f_S0247() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004528 f_TC_assignment_codec_amr(true, '289520882208'O, '10010101'B, '10010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004529 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004530}
4531
4532/* The following block of tests selects more and more rates until all three
4533 * possible rates are in the active set (half rate) */
4534testcase TC_assignment_codec_amr_h_S0() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004535 f_TC_assignment_codec_amr(false, '2801'O, '00000001'B, '00000001'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004536 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004537}
4538
4539testcase TC_assignment_codec_amr_h_S02() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004540 f_TC_assignment_codec_amr(false, '28052080'O, '00000101'B, '00000101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004541 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004542}
4543
4544testcase TC_assignment_codec_amr_h_S024() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004545 f_TC_assignment_codec_amr(false, '2815208820'O, '00010101'B, '00010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004546 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004547}
4548
4549/* The following block tests what happens when the MSC does offer rate
4550 * configurations that are not supported by the BSC. Normally such situations
4551 * should not happen because the MSC gets informed by the BSC in advance via
4552 * the L3 COMPLETE message which rates are applicable. The MSC should not try
4553 * to offer rates that are not applicable anyway. */
4554
4555testcase TC_assignment_codec_amr_h_S0247() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004556 /* Try to include 12,2k in into the active set even though the channel
4557 * is half rate only. The BSC is expected to remove the 12,0k */
4558 f_TC_assignment_codec_amr(false, '2815208820'O, '10010101'B, '00010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004559 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004560}
4561
4562testcase TC_assignment_codec_amr_f_S01234567() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004563 /* See what happens when all rates are selected at once. Since then
4564 * Also S1 is selected, this setting will be prefered and we should
4565 * get 12.2k, 7,40k, 5,90k, and 4,75k in the active set. */
4566 f_TC_assignment_codec_amr(true, '289520882208'O, '11111111'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004567 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004568}
4569
4570testcase TC_assignment_codec_amr_f_S0234567() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004571 /* Same as above, but with S1 missing, the MSC is then expected to
4572 * select the currently supported rates, which are also 12.2k, 7,40k,
4573 * 5,90k, and 4,75k, into the active set. */
4574 f_TC_assignment_codec_amr(true, '289520882208'O, '11111101'B, '10010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004575 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004576}
4577
4578testcase TC_assignment_codec_amr_f_zero() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004579 /* Try to select no rates at all */
4580 f_TC_assignment_codec_amr_fail(true, '00000000'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004581 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004582}
4583
4584testcase TC_assignment_codec_amr_f_unsupp() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004585 /* Try to select only unsupported rates */
4586 f_TC_assignment_codec_amr_fail(true, '01101000'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004587 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004588}
4589
4590testcase TC_assignment_codec_amr_h_S7() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004591 /* Try to select 12,2k for half rate */
4592 f_TC_assignment_codec_amr_fail(false, '10000000'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004593 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004594}
4595
Neels Hofmeyr21863562020-11-26 00:34:33 +00004596testcase TC_assignment_codec_amr_f_start_mode_auto() runs on test_CT {
4597 f_TC_assignment_codec_amr(true, '209520882208'O, '11111111'B, '00000010'B,
4598 start_mode := "auto");
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01004599 f_shutdown_helper();
Neels Hofmeyr21863562020-11-26 00:34:33 +00004600}
4601
4602testcase TC_assignment_codec_amr_h_start_mode_auto() runs on test_CT {
4603 f_TC_assignment_codec_amr(false, '2015208820'O, '10010101'B, '00010101'B,
4604 start_mode := "auto");
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01004605 f_shutdown_helper();
Neels Hofmeyr21863562020-11-26 00:34:33 +00004606}
4607
Neels Hofmeyr3eb94562020-11-26 02:40:26 +00004608testcase TC_assignment_codec_amr_f_start_mode_4() runs on test_CT {
Vadim Yanitskiy7815f482021-01-03 17:07:37 +01004609 /* "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 +00004610 f_TC_assignment_codec_amr(true, '2b9520882208'O, '11111111'B, '00000010'B,
4611 start_mode := "4");
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01004612 f_shutdown_helper();
Neels Hofmeyr3eb94562020-11-26 02:40:26 +00004613}
4614
4615testcase TC_assignment_codec_amr_h_start_mode_4() runs on test_CT {
Vadim Yanitskiy7815f482021-01-03 17:07:37 +01004616 /* "amr tch-h modes 0 2 4" => total 3 modes and start mode 4 => '10'B on the wire */
4617 f_TC_assignment_codec_amr(false, '2a15208820'O, '10010101'B, '00010101'B,
Neels Hofmeyr3eb94562020-11-26 02:40:26 +00004618 start_mode := "4");
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01004619 f_shutdown_helper();
Neels Hofmeyr3eb94562020-11-26 02:40:26 +00004620}
4621
Philipp Maierac09bfc2019-01-08 13:41:39 +01004622private function f_disable_all_tch_f() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01004623 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 1 sub-slot 0 borken");
4624 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 2 sub-slot 0 borken");
4625 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 3 sub-slot 0 borken");
4626 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 4 sub-slot 0 borken");
Philipp Maierac09bfc2019-01-08 13:41:39 +01004627}
4628
4629private function f_disable_all_tch_h() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01004630 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 0 borken");
4631 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 1 borken");
Philipp Maierac09bfc2019-01-08 13:41:39 +01004632}
4633
4634private function f_enable_all_tch() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01004635 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 1 sub-slot 0 unused");
4636 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 2 sub-slot 0 unused");
4637 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 3 sub-slot 0 unused");
4638 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 4 sub-slot 0 unused");
4639 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 0 unused");
4640 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 1 unused");
Philipp Maierac09bfc2019-01-08 13:41:39 +01004641}
4642
Neels Hofmeyr559d5d02021-04-16 16:50:49 +02004643private function f_disable_all_sdcch() runs on test_CT {
4644 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 0 sub-slot 0 borken");
4645 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 0 sub-slot 1 borken");
4646 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 0 sub-slot 2 borken");
4647 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 0 sub-slot 3 borken");
4648}
4649
4650private function f_enable_all_sdcch() runs on test_CT {
4651 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 0 sub-slot 0 unused");
4652 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 0 sub-slot 1 unused");
4653 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 0 sub-slot 2 unused");
4654 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 0 sub-slot 3 unused");
4655}
4656
Philipp Maierac09bfc2019-01-08 13:41:39 +01004657/* Allow HR only */
4658private function f_TC_assignment_codec_xr_exhausted_req_hr(charstring id) runs on MSC_ConnHdlr {
4659 g_pars := f_gen_test_hdlr_pars();
4660 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4661 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4662 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4663 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '09'O;
4664 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '05'O;
4665 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
4666 f_establish_fully(ass_cmd, exp_compl);
4667}
4668
4669/* Allow FR only */
4670private function f_TC_assignment_codec_xr_exhausted_req_fr(charstring id) runs on MSC_ConnHdlr {
4671 g_pars := f_gen_test_hdlr_pars();
4672 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4673 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4674 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4675 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '08'O;
4676 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '01'O;
4677 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4678 f_establish_fully(ass_cmd, exp_compl);
4679}
4680
4681/* Allow HR only (expect assignment failure) */
4682private function f_TC_assignment_codec_xr_exhausted_req_hr_fail(charstring id) runs on MSC_ConnHdlr {
4683 g_pars := f_gen_test_hdlr_pars();
4684 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4685 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
4686 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4687 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '09'O;
4688 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '05'O;
4689 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
4690 f_establish_fully(ass_cmd, exp_fail);
4691}
4692
4693/* Allow FR only (expect assignment failure) */
4694private function f_TC_assignment_codec_xr_exhausted_req_fr_fail(charstring id) runs on MSC_ConnHdlr {
4695 g_pars := f_gen_test_hdlr_pars();
4696 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4697 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
4698 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4699 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '08'O;
4700 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '01'O;
4701 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4702 f_establish_fully(ass_cmd, exp_fail);
4703}
4704
4705/* Allow FR and HR, but prefer FR */
4706private function f_TC_assignment_codec_fr_exhausted_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
4707 g_pars := f_gen_test_hdlr_pars();
4708 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4709 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4710 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4711 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
4712 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
4713 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
4714 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
4715 f_establish_fully(ass_cmd, exp_compl);
4716}
4717
4718/* Allow FR and HR, but prefer HR */
4719private function f_TC_assignment_codec_fr_exhausted_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
4720 g_pars := f_gen_test_hdlr_pars();
4721 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4722 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4723 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4724 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
4725 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
4726 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
4727 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
4728 f_establish_fully(ass_cmd, exp_compl);
4729}
4730
4731/* Allow FR and HR, but prefer FR */
4732private function f_TC_assignment_codec_hr_exhausted_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
4733 g_pars := f_gen_test_hdlr_pars();
4734 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4735 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4736 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4737 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
4738 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
4739 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
4740 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
4741 f_establish_fully(ass_cmd, exp_compl);
4742}
4743
4744/* Allow FR and HR, but prefer HR */
4745private function f_TC_assignment_codec_hr_exhausted_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
4746 g_pars := f_gen_test_hdlr_pars();
4747 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4748 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4749 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4750 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
4751 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
4752 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
4753 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
4754 f_establish_fully(ass_cmd, exp_compl);
4755}
4756
4757/* Request a HR channel while all FR channels are exhausted, this is expected
4758 * to work without conflicts */
4759testcase TC_assignment_codec_fr_exhausted_req_hr() runs on test_CT {
4760 var MSC_ConnHdlr vc_conn;
4761 f_init(1, true);
4762 f_sleep(1.0);
4763 f_enable_all_tch();
4764 f_disable_all_tch_f();
4765 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_hr));
4766 vc_conn.done;
4767 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004768 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004769}
4770
4771/* Request a FR channel while all FR channels are exhausted, this is expected
4772 * to fail. */
4773testcase TC_assignment_codec_fr_exhausted_req_fr() runs on test_CT {
4774 var MSC_ConnHdlr vc_conn;
4775 f_init(1, true);
4776 f_sleep(1.0);
4777 f_enable_all_tch();
4778 f_disable_all_tch_f();
4779 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_fr_fail));
4780 vc_conn.done;
4781 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004782 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004783}
4784
4785/* Request a FR (prefered) or alternatively a HR channel while all FR channels
4786 * are exhausted, this is expected to be resolved by selecting a HR channel. */
4787testcase TC_assignment_codec_fr_exhausted_req_fr_hr() runs on test_CT {
4788 var MSC_ConnHdlr vc_conn;
4789 f_init(1, true);
4790 f_sleep(1.0);
4791 f_enable_all_tch();
4792 f_disable_all_tch_f();
4793 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fr_exhausted_req_fr_hr));
4794 vc_conn.done;
4795 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004796 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004797}
4798
4799/* Request a HR (prefered) or alternatively a FR channel while all FR channels
4800 * are exhausted, this is expected to work without conflicts. */
4801testcase TC_assignment_codec_fr_exhausted_req_hr_fr() runs on test_CT {
4802 var MSC_ConnHdlr vc_conn;
4803 f_init(1, true);
4804 f_sleep(1.0);
4805 f_enable_all_tch();
4806 f_disable_all_tch_f();
4807 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fr_exhausted_req_hr_fr));
4808 vc_conn.done;
4809 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004810 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004811}
4812
4813/* Request a FR channel while all HR channels are exhausted, this is expected
4814 * to work without conflicts */
4815testcase TC_assignment_codec_hr_exhausted_req_fr() runs on test_CT {
4816 var MSC_ConnHdlr vc_conn;
4817 f_init(1, true);
4818 f_sleep(1.0);
4819 f_enable_all_tch();
4820 f_disable_all_tch_h();
4821 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_fr));
4822 vc_conn.done;
4823 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004824 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004825}
4826
4827/* Request a HR channel while all HR channels are exhausted, this is expected
4828 * to fail. */
4829testcase TC_assignment_codec_hr_exhausted_req_hr() runs on test_CT {
4830 var MSC_ConnHdlr vc_conn;
4831 f_init(1, true);
4832 f_sleep(1.0);
4833 f_enable_all_tch();
4834 f_disable_all_tch_h();
4835 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_hr_fail));
4836 vc_conn.done;
4837 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004838 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004839}
4840
4841/* Request a HR (prefered) or alternatively a FR channel while all HR channels
4842 * are exhausted, this is expected to be resolved by selecting a FR channel. */
4843testcase TC_assignment_codec_hr_exhausted_req_hr_fr() runs on test_CT {
4844 var MSC_ConnHdlr vc_conn;
4845 f_init(1, true);
4846 f_sleep(1.0);
4847 f_enable_all_tch();
4848 f_disable_all_tch_h();
4849 vc_conn := f_start_handler(refers(f_TC_assignment_codec_hr_exhausted_req_hr_fr));
4850 vc_conn.done;
4851 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004852 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004853}
4854
4855/* Request a FR (prefered) or alternatively a HR channel while all HR channels
4856 * are exhausted, this is expected to work without conflicts. */
4857testcase TC_assignment_codec_hr_exhausted_req_fr_hr() runs on test_CT {
4858 var MSC_ConnHdlr vc_conn;
4859 f_init(1, true);
4860 f_sleep(1.0);
4861 f_enable_all_tch();
4862 f_disable_all_tch_h();
4863 vc_conn := f_start_handler(refers(f_TC_assignment_codec_hr_exhausted_req_fr_hr));
4864 vc_conn.done;
4865 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004866 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004867}
4868
4869/* Allow FR and HR, but prefer HR */
4870private function f_TC_assignment_codec_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
4871 g_pars := f_gen_test_hdlr_pars();
4872 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4873 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4874 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4875 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
4876 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
4877 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
4878 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
4879 f_establish_fully(ass_cmd, exp_compl);
4880}
4881
4882/* Allow FR and HR, but prefer FR */
4883private function f_TC_assignment_codec_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
4884 g_pars := f_gen_test_hdlr_pars();
4885 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4886 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4887 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4888 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
4889 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
4890 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
4891 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
4892 f_establish_fully(ass_cmd, exp_compl);
4893}
4894
4895/* Request a HR (prefered) or alternatively a FR channel, it is expected that
4896 * HR, which is the prefered type, is selected. */
4897testcase TC_assignment_codec_req_hr_fr() runs on test_CT {
4898 var MSC_ConnHdlr vc_conn;
4899 f_init(1, true);
4900 f_sleep(1.0);
4901 f_enable_all_tch();
4902 vc_conn := f_start_handler(refers(f_TC_assignment_codec_req_hr_fr));
4903 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004904 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004905}
4906
4907/* Request a FR (prefered) or alternatively a HR channel, it is expected that
4908 * FR, which is the prefered type, is selected. */
4909testcase TC_assignment_codec_req_fr_hr() runs on test_CT {
4910 var MSC_ConnHdlr vc_conn;
4911 f_init(1, true);
4912 f_sleep(1.0);
4913 f_enable_all_tch();
4914 vc_conn := f_start_handler(refers(f_TC_assignment_codec_req_fr_hr));
4915 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004916 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004917}
4918
Pau Espin Pedrol14475352021-07-22 15:48:16 +02004919/* request a signalling channel with all SDCCH exhausted, it is expected that a TCH will be selected */
4920private function f_TC_assignment_sdcch_exhausted_req_signalling(charstring id) runs on MSC_ConnHdlr {
4921 g_pars := f_gen_test_hdlr_pars();
4922 g_pars.ra := '02'O; /* RA containing reason=LU */
4923
4924 var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi));
4925 var PDU_ML3_MS_NW l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, mi));
4926 var octetstring l3_enc := enc_PDU_ML3_MS_NW(l3_info);
4927 var template uint3_t tsc := ?;
4928
4929 f_MscConnHdlr_init(g_pars.media_nr, host_bts, host_mgw_mgcp, FR_AMR);
4930 f_create_bssmap_exp(l3_enc);
4931 /* call helper function for CHAN_RQD -> IMM ASS ->EST_IND */
4932 RSL_Emulation.f_chan_est(g_pars.ra, l3_enc, g_pars.link_id, g_pars.fn, tsc);
4933
4934 /* we should now have a COMPL_L3 at the MSC */
4935 timer T := 10.0;
4936 T.start;
4937 alt {
4938 [] BSSAP.receive(tr_BSSMAP_ComplL3);
4939 [] T.timeout {
4940 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for COMPLETE LAYER 3 INFORMATION");
4941 }
4942 }
4943}
4944testcase TC_assignment_sdcch_exhausted_req_signalling() runs on test_CT {
4945 var MSC_ConnHdlr vc_conn;
4946 f_init(1, true);
4947 f_sleep(1.0);
4948 f_disable_all_sdcch();
4949 vc_conn := f_start_handler(refers(f_TC_assignment_sdcch_exhausted_req_signalling));
4950 vc_conn.done;
4951 f_enable_all_sdcch();
4952 f_shutdown_helper();
4953}
4954
4955/* Request a signalling channel with all SDCCH exhausted, it is
4956 expected that no TCH will be selected for signalling and assigment will fail
4957 because it's dictated by VTY config */
4958testcase TC_assignment_sdcch_exhausted_req_signalling_tch_forbidden() runs on test_CT {
4959 var RSL_Message rsl_unused, rsl_msg;
4960 var GsmRrMessage rr;
4961 f_init(1, false);
4962 f_sleep(1.0);
4963 f_vty_allow_tch_for_signalling(false, 0);
4964 f_disable_all_sdcch();
4965
4966 /* RA containing reason=LU */
4967 f_ipa_tx(0, ts_RSL_CHAN_RQD('02'O, 2342));
4968 rsl_msg := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
4969 rr := dec_GsmRrMessage(rsl_msg.ies[1].body.full_imm_ass_info.payload);
4970 if (rr.header.message_type != IMMEDIATE_ASSIGNMENT_REJECT) {
4971 setverdict(fail, "Expected reject");
4972 }
4973
4974 f_vty_allow_tch_for_signalling(true, 0);
4975 f_enable_all_sdcch();
4976 f_shutdown_helper();
4977}
4978
4979/* Request a voice channel with all SDCCH exhausted, it is
4980 * expected that TCH channel will be allocated since the VTY option is only
4981 * aimed at signalling requests */
4982private function f_TC_assignment_sdcch_exhausted_req_voice_tch_forbidden(charstring id) runs on MSC_ConnHdlr {
4983 g_pars := f_gen_test_hdlr_pars();
4984 g_pars.ra := '43'O; /* RA containing reason=originating speech call*/
4985
4986 var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi));
4987 var PDU_ML3_MS_NW l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, mi));
4988 var octetstring l3_enc := enc_PDU_ML3_MS_NW(l3_info);
4989 var template uint3_t tsc := ?;
4990
4991 f_MscConnHdlr_init(g_pars.media_nr, host_bts, host_mgw_mgcp, FR_AMR);
4992 f_create_bssmap_exp(l3_enc);
4993 /* call helper function for CHAN_RQD -> IMM ASS ->EST_IND */
4994 RSL_Emulation.f_chan_est(g_pars.ra, l3_enc, g_pars.link_id, g_pars.fn, tsc);
4995
4996 /* we should now have a COMPL_L3 at the MSC */
4997 timer T := 10.0;
4998 T.start;
4999 alt {
5000 [] BSSAP.receive(tr_BSSMAP_ComplL3);
5001 [] T.timeout {
5002 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for COMPLETE LAYER 3 INFORMATION");
5003 }
5004 }
5005}
5006testcase TC_assignment_sdcch_exhausted_req_voice_tch_forbidden() runs on test_CT {
5007 var MSC_ConnHdlr vc_conn;
5008 f_init(1, true);
5009 f_sleep(1.0);
5010 f_vty_allow_tch_for_signalling(false, 0);
5011 f_disable_all_sdcch();
5012
5013 vc_conn := f_start_handler(refers(f_TC_assignment_sdcch_exhausted_req_voice_tch_forbidden));
5014 vc_conn.done;
5015
5016 f_vty_allow_tch_for_signalling(true, 0);
5017 f_enable_all_sdcch();
5018 f_shutdown_helper();
5019}
5020
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02005021testcase TC_assignment_osmux() runs on test_CT {
5022 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5023 var MSC_ConnHdlr vc_conn;
5024
5025 /* See note above */
5026 var RSL_IE_Body mr_conf := {
5027 other := {
5028 len := 2,
5029 payload := '2804'O
5030 }
5031 };
5032
5033 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
5034 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
5035 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
5036 pars.expect_mr_conf_ie := mr_conf;
5037 pars.use_osmux := true;
5038
5039 f_init(1, true, true);
5040 f_sleep(1.0);
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00005041 f_vty_amr_start_mode_set(false, "1");
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02005042
5043 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
5044 vc_conn.done;
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00005045
5046 f_vty_amr_start_mode_restore(false);
Vadim Yanitskiy292e5962021-01-03 14:18:47 +01005047 f_shutdown_helper();
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02005048}
5049
Neels Hofmeyr92b12b72018-09-18 14:30:23 +02005050/* test the procedure of the MSC requesting a Classmark Update:
5051 * a) BSSMAP Classmark Request should result in RR CLASSMARK ENQUIRY,
5052 * b) L3 RR CLASSMARK CHANGE should result in BSSMAP CLASSMARK UPDATE */
Harald Welte898113b2018-01-31 18:32:21 +01005053private function f_tc_classmark(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02005054 g_pars := f_gen_test_hdlr_pars();
5055
Harald Weltea0630032018-03-20 21:09:55 +01005056 f_create_chan_and_exp();
Harald Welte898113b2018-01-31 18:32:21 +01005057 /* we should now have a COMPL_L3 at the MSC */
5058 BSSAP.receive(tr_BSSMAP_ComplL3);
5059
Neels Hofmeyr92b12b72018-09-18 14:30:23 +02005060 BSSAP.send(ts_BSSMAP_ClassmarkRequest);
5061 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_CM_ENQUIRY));
5062
Harald Welte898113b2018-01-31 18:32:21 +01005063 f_rsl_send_l3(ts_RRM_CM_CHG(valueof(ts_CM2)));
5064 BSSAP.receive(tr_BSSMAP_ClassmarkUpd(?, omit));
5065 setverdict(pass);
5066}
5067testcase TC_classmark() runs on test_CT {
5068 var MSC_ConnHdlr vc_conn;
5069 f_init(1, true);
5070 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02005071 vc_conn := f_start_handler(refers(f_tc_classmark));
Harald Welte898113b2018-01-31 18:32:21 +01005072 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005073 f_shutdown_helper();
Harald Welte898113b2018-01-31 18:32:21 +01005074}
5075
Harald Welteeddf0e92020-06-21 19:42:15 +02005076/* Send a CommonID from the simulated MSC and verify that the information is used to
5077 * fill BSC-internal data structures (specifically, bsc_subscr associated with subscr_conn) */
5078private function f_tc_common_id(charstring id) runs on MSC_ConnHdlr {
5079 g_pars := f_gen_test_hdlr_pars();
5080 f_MscConnHdlr_init_vty();
5081
5082 f_create_chan_and_exp();
5083 /* we should now have a COMPL_L3 at the MSC */
5084 BSSAP.receive(tr_BSSMAP_ComplL3);
5085
5086 /* Send CommonID */
5087 BSSAP.send(ts_BSSMAP_CommonId(g_pars.imsi));
5088
5089 /* Use VTY to verify that the IMSI of the subscr_conn is set */
5090 var charstring regex := "*(IMSI: " & hex2str(g_pars.imsi) & ")*";
5091 f_vty_transceive_match_regexp_retry(BSCVTY, "show conns", regex, 0, 4, 1.0);
5092
5093 setverdict(pass);
5094}
5095testcase TC_common_id() runs on test_CT {
5096 var MSC_ConnHdlr vc_conn;
5097 f_init(1, true);
5098 f_sleep(1.0);
5099 vc_conn := f_start_handler(refers(f_tc_common_id));
5100 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005101 f_shutdown_helper();
Harald Welteeddf0e92020-06-21 19:42:15 +02005102}
5103
Harald Weltee3bd6582018-01-31 22:51:25 +01005104private function f_est_single_l3(template PDU_ML3_MS_NW l3) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02005105 g_pars := f_gen_test_hdlr_pars();
Harald Weltea0630032018-03-20 21:09:55 +01005106 f_create_chan_and_exp();
Harald Welte898113b2018-01-31 18:32:21 +01005107 /* we should now have a COMPL_L3 at the MSC */
5108 BSSAP.receive(tr_BSSMAP_ComplL3);
5109
Harald Weltee3bd6582018-01-31 22:51:25 +01005110 /* send the single message we want to send */
5111 f_rsl_send_l3(l3);
5112}
5113
5114private function f_bssap_expect_nothing(float sec := 5.00) runs on MSC_ConnHdlr {
5115 timer T := sec;
5116 var PDU_BSSAP bssap;
Harald Welte898113b2018-01-31 18:32:21 +01005117 T.start;
5118 alt {
Harald Weltee3bd6582018-01-31 22:51:25 +01005119 [] BSSAP.receive(PDU_BSSAP:?) -> value bssap {
5120 setverdict(fail, "Unexpected BSSMAP ", bssap);
Daniel Willmannafce8662018-07-06 23:11:32 +02005121 mtc.stop;
Harald Welte898113b2018-01-31 18:32:21 +01005122 }
5123 [] T.timeout {
5124 setverdict(pass);
5125 }
5126 }
5127}
5128
Harald Weltee3bd6582018-01-31 22:51:25 +01005129/* unsolicited ASSIGNMENT FAIL (without ASSIGN) from MS shouldn't bring BSC down */
5130private function f_tc_unsol_ass_fail(charstring id) runs on MSC_ConnHdlr {
5131 f_est_single_l3(ts_RRM_AssignmentFailure('00'O));
5132 f_bssap_expect_nothing();
5133}
Harald Welte898113b2018-01-31 18:32:21 +01005134testcase TC_unsol_ass_fail() runs on test_CT {
5135 var MSC_ConnHdlr vc_conn;
5136 f_init(1, true);
5137 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02005138 vc_conn := f_start_handler(refers(f_tc_unsol_ass_fail));
Harald Welte898113b2018-01-31 18:32:21 +01005139 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005140 f_shutdown_helper();
Harald Welte898113b2018-01-31 18:32:21 +01005141}
Harald Welte552620d2017-12-16 23:21:36 +01005142
Harald Welteea99a002018-01-31 20:46:43 +01005143
5144/* unsolicited ASSIGNMENT COMPLETE (without ASSIGN) from MS shouldn't bring BSC down */
5145private function f_tc_unsol_ass_compl(charstring id) runs on MSC_ConnHdlr {
Harald Weltee3bd6582018-01-31 22:51:25 +01005146 f_est_single_l3(ts_RRM_AssignmentComplete('00'O));
5147 f_bssap_expect_nothing();
Harald Welteea99a002018-01-31 20:46:43 +01005148}
5149testcase TC_unsol_ass_compl() runs on test_CT {
5150 var MSC_ConnHdlr vc_conn;
5151 f_init(1, true);
5152 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02005153 vc_conn := f_start_handler(refers(f_tc_unsol_ass_compl));
Harald Welteea99a002018-01-31 20:46:43 +01005154 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005155 f_shutdown_helper();
Harald Welteea99a002018-01-31 20:46:43 +01005156}
5157
5158
Harald Weltefbf9b5e2018-01-31 20:41:23 +01005159/* unsolicited HANDOVER FAIL (without ASSIGN) from MS shouldn't bring BSC down */
5160private function f_tc_unsol_ho_fail(charstring id) runs on MSC_ConnHdlr {
Harald Weltee3bd6582018-01-31 22:51:25 +01005161 f_est_single_l3(ts_RRM_HandoverFailure('00'O));
5162 f_bssap_expect_nothing();
Harald Weltefbf9b5e2018-01-31 20:41:23 +01005163}
Harald Weltefbf9b5e2018-01-31 20:41:23 +01005164testcase TC_unsol_ho_fail() runs on test_CT {
5165 var MSC_ConnHdlr vc_conn;
5166 f_init(1, true);
5167 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02005168 vc_conn := f_start_handler(refers(f_tc_unsol_ho_fail));
Harald Weltefbf9b5e2018-01-31 20:41:23 +01005169 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005170 f_shutdown_helper();
Harald Weltefbf9b5e2018-01-31 20:41:23 +01005171}
5172
5173
Harald Weltee3bd6582018-01-31 22:51:25 +01005174/* short message from MS should be ignored */
5175private function f_tc_err_82_short_msg(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02005176 g_pars := f_gen_test_hdlr_pars();
Harald Weltea0630032018-03-20 21:09:55 +01005177 f_create_chan_and_exp();
Harald Weltee3bd6582018-01-31 22:51:25 +01005178 /* we should now have a COMPL_L3 at the MSC */
5179 BSSAP.receive(tr_BSSMAP_ComplL3);
5180
5181 /* send short message */
5182 RSL.send(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), ''O));
5183 f_bssap_expect_nothing();
5184}
5185testcase TC_err_82_short_msg() runs on test_CT {
5186 var MSC_ConnHdlr vc_conn;
5187 f_init(1, true);
5188 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02005189 vc_conn := f_start_handler(refers(f_tc_err_82_short_msg));
Harald Weltee3bd6582018-01-31 22:51:25 +01005190 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005191 f_shutdown_helper();
Harald Weltee3bd6582018-01-31 22:51:25 +01005192}
5193
5194
Harald Weltee9e02e42018-01-31 23:36:25 +01005195/* 24.008 8.4 Unknown message must trigger RR STATUS */
5196private function f_tc_err_84_unknown_msg(charstring id) runs on MSC_ConnHdlr {
5197 f_est_single_l3(ts_RRM_UL_REL('00'O));
5198 timer T := 3.0
5199 alt {
5200 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_STATUS)) {
5201 setverdict(pass);
5202 }
5203 [] BSSAP.receive { setverdict(fail, "unexpected BSSAP"); }
Harald Welte458fd372018-03-21 11:26:23 +01005204 [] T.timeout { setverdict(fail, "Timeout waiting for RR STATUS"); }
Harald Weltee9e02e42018-01-31 23:36:25 +01005205 }
5206}
5207testcase TC_err_84_unknown_msg() runs on test_CT {
5208 var MSC_ConnHdlr vc_conn;
5209 f_init(1, true);
5210 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02005211 vc_conn := f_start_handler(refers(f_tc_err_84_unknown_msg));
Harald Weltee9e02e42018-01-31 23:36:25 +01005212 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005213 f_shutdown_helper();
Harald Weltee9e02e42018-01-31 23:36:25 +01005214}
5215
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005216/***********************************************************************
5217 * Handover
5218 ***********************************************************************/
5219
Harald Welte94e0c342018-04-07 11:33:23 +02005220/* execute a "bts <0-255> trx <0-255> timeslot <0-7> " command on given Dchan */
5221private function f_vty_ts_action(charstring suffix, integer bts_nr, integer trx_nr, integer ts_nr)
5222runs on test_CT {
5223 var charstring cmd := "bts "&int2str(bts_nr)&" trx "&int2str(trx_nr)&
5224 " timeslot "&int2str(ts_nr)&" ";
5225 f_vty_transceive(BSCVTY, cmd & suffix);
5226}
5227
Harald Welte261af4b2018-02-12 21:20:39 +01005228/* 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 +07005229private function f_vty_ss_action(TELNETasp_PT pt, charstring suffix,
5230 uint8_t bts_nr, uint8_t trx_nr,
5231 in RslChannelNr chan_nr)
5232{
Harald Welte261af4b2018-02-12 21:20:39 +01005233 /* FIXME: resolve those from component-global state */
5234 var integer ts_nr := chan_nr.tn;
5235 var integer ss_nr;
5236 if (ischosen(chan_nr.u.ch0)) {
5237 ss_nr := 0;
5238 } else if (ischosen(chan_nr.u.lm)) {
5239 ss_nr := chan_nr.u.lm.sub_chan;
5240 } else if (ischosen(chan_nr.u.sdcch4)) {
5241 ss_nr := chan_nr.u.sdcch4.sub_chan;
5242 } else if (ischosen(chan_nr.u.sdcch8)) {
5243 ss_nr := chan_nr.u.sdcch8.sub_chan;
5244 } else {
5245 setverdict(fail, "Invalid ChanNr ", chan_nr);
Daniel Willmannafce8662018-07-06 23:11:32 +02005246 mtc.stop;
Harald Welte261af4b2018-02-12 21:20:39 +01005247 }
5248
5249 var charstring cmd := "bts "&int2str(bts_nr)&" trx "&int2str(trx_nr)&
5250 " timeslot "&int2str(ts_nr)&" sub-slot "&int2str(ss_nr)&" ";
Vadim Yanitskiy00070722020-09-02 17:27:57 +07005251 f_vty_transceive(pt, cmd & suffix);
Harald Welte261af4b2018-02-12 21:20:39 +01005252}
5253
Neels Hofmeyr91401012019-07-11 00:42:35 +02005254/* Even though the VTY command to trigger handover takes a new BTS number as argument, behind the scenes osmo-bsc always
5255 * translates that to a target ARFCN+BSIC first. See bsc_vty.c trigger_ho_or_as(), which puts the selected BTS' neighbor
5256 * ident key (ARFCN + BSIC) in the struct passed on to handover_request(). handover_start() then resolves that to a
5257 * viable actual neighbor cell. So from the internal osmo-bsc perspective, we always request handover to an ARFCN + BSIC
5258 * pair, not really to a specific BTS number. */
Vadim Yanitskiy00070722020-09-02 17:27:57 +07005259private function f_vty_handover(TELNETasp_PT pt, uint8_t bts_nr, uint8_t trx_nr,
5260 in RslChannelNr chan_nr, uint8_t new_bts_nr)
5261{
5262 f_vty_ss_action(pt, "handover " & int2str(new_bts_nr), bts_nr, trx_nr, chan_nr);
Harald Welte261af4b2018-02-12 21:20:39 +01005263}
5264
5265/* intra-BSC hand-over between BTS0 and BTS1 */
5266private function f_tc_ho_int(charstring id) runs on MSC_ConnHdlr {
Harald Welteed848512018-05-24 22:27:58 +02005267 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
5268 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte261af4b2018-02-12 21:20:39 +01005269
5270 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
5271 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
5272
Harald Weltea0630032018-03-20 21:09:55 +01005273 f_establish_fully(ass_cmd, exp_compl);
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005274 f_bts_0_cfg(BSCVTY, {"neighbor bts 1"});
Harald Welte261af4b2018-02-12 21:20:39 +01005275
5276 var HandoverState hs := {
5277 rr_ho_cmpl_seen := false,
5278 handover_done := false,
Neels Hofmeyrc741fcb2021-10-02 14:52:28 +02005279 old_chan_nr := -,
5280 expect_target_tsc := BTS_TSC[1]
Harald Welte261af4b2018-02-12 21:20:39 +01005281 };
Neels Hofmeyrc2cf4542021-10-02 12:26:38 +02005282 /* issue hand-over command on VTY, from BTS 0 to BTS 1 */
Vadim Yanitskiy00070722020-09-02 17:27:57 +07005283 f_vty_handover(BSCVTY, 0, 0, g_chan_nr, 1);
Harald Welte261af4b2018-02-12 21:20:39 +01005284 /* temporarily suspend DChan processing on BTS1 to avoid race with RSLEM_register */
5285 f_rslem_suspend(RSL1_PROC);
Philipp Maier3e2af5d2018-07-11 17:01:05 +02005286
5287 /* From the MGW perspective, a handover is is characterized by
5288 * performing one MDCX operation with the MGW. So we expect to see
5289 * one more MDCX during handover. */
5290 g_media.mgcp_conn[0].mdcx_seen_exp := g_media.mgcp_conn[0].crcx_seen_exp + 1;
5291
Harald Welte261af4b2018-02-12 21:20:39 +01005292 alt {
5293 [] as_handover(hs);
Harald Welte261af4b2018-02-12 21:20:39 +01005294 }
Philipp Maier3e2af5d2018-07-11 17:01:05 +02005295
Philipp Maier4dae0652018-11-12 12:03:26 +01005296 /* Since this is an internal handover we expect the BSC to inform the
5297 * MSC about the event */
5298 BSSAP.receive(tr_BSSMAP_HandoverPerformed);
5299
Philipp Maier3e2af5d2018-07-11 17:01:05 +02005300 /* Check the amount of MGCP transactions is still consistant with the
5301 * test expectation */
5302 f_check_mgcp_expectations()
Neels Hofmeyraf88d9d2021-06-21 02:14:27 +02005303
Neels Hofmeyrc2cf4542021-10-02 12:26:38 +02005304 var RSL_Message chan_act := f_rslem_get_last_act(RSL1_PROC, 0, g_chan_nr);
5305
Neels Hofmeyraf88d9d2021-06-21 02:14:27 +02005306 /* Ensure the Channel Activation for the new channel contained the right encryption params. as_handover() set
5307 * 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 +02005308 f_verify_encr_info(chan_act);
5309
5310 f_chan_act_verify_tsc(chan_act, BTS_TSC[1]);
Neels Hofmeyraf88d9d2021-06-21 02:14:27 +02005311
Neels Hofmeyr861a4c12018-11-07 01:23:17 +01005312 f_sleep(0.5);
Harald Welte261af4b2018-02-12 21:20:39 +01005313}
5314
5315testcase TC_ho_int() runs on test_CT {
Neels Hofmeyr5f7a9df2021-06-21 01:30:43 +02005316 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte261af4b2018-02-12 21:20:39 +01005317 var MSC_ConnHdlr vc_conn;
5318 f_init(2, true);
5319 f_sleep(1.0);
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005320
Neels Hofmeyrc2cf4542021-10-02 12:26:38 +02005321 pars.expect_tsc := BTS_TSC[0];
5322
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01005323 f_ctrs_bsc_and_bts_handover_init();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005324
Neels Hofmeyr5f7a9df2021-06-21 01:30:43 +02005325 vc_conn := f_start_handler(refers(f_tc_ho_int), pars);
Harald Welte261af4b2018-02-12 21:20:39 +01005326 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005327
5328 /* from f_establish_fully() */
5329 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5330 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5331 /* from handover */
5332 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5333 f_ctrs_bsc_and_bts_add(0, "handover:completed");
5334 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5335 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:completed");
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01005336 f_ctrs_bts_add(1, "incoming_intra_bsc_ho:attempted");
5337 f_ctrs_bts_add(1, "incoming_intra_bsc_ho:completed");
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005338 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005339 f_shutdown_helper();
Harald Welte261af4b2018-02-12 21:20:39 +01005340}
Harald Weltee9e02e42018-01-31 23:36:25 +01005341
Oliver Smith7eabd312021-07-12 14:18:56 +02005342function 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 +02005343 var MSC_ConnHdlr vc_conn;
5344 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5345 pars.encr := valueof(t_EncrParams(encr_alg, f_rnd_octstring(8), f_rnd_octstring(16)));
5346
5347 f_init(2, true);
Oliver Smith7eabd312021-07-12 14:18:56 +02005348 f_vty_encryption_a5(enc_a5);
Neels Hofmeyraf88d9d2021-06-21 02:14:27 +02005349 f_sleep(1.0);
5350
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01005351 f_ctrs_bsc_and_bts_handover_init();
Neels Hofmeyraf88d9d2021-06-21 02:14:27 +02005352
5353 vc_conn := f_start_handler(refers(f_tc_ho_int), pars);
5354 vc_conn.done;
5355
5356 /* from f_establish_fully() */
5357 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5358 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5359 /* from handover */
5360 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5361 f_ctrs_bsc_and_bts_add(0, "handover:completed");
5362 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5363 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:completed");
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01005364 f_ctrs_bts_add(1, "incoming_intra_bsc_ho:attempted");
5365 f_ctrs_bts_add(1, "incoming_intra_bsc_ho:completed");
Neels Hofmeyraf88d9d2021-06-21 02:14:27 +02005366 f_ctrs_bsc_and_bts_verify();
Oliver Smith7eabd312021-07-12 14:18:56 +02005367 f_vty_encryption_a5_reset();
Neels Hofmeyraf88d9d2021-06-21 02:14:27 +02005368 f_shutdown_helper();
5369}
5370
5371testcase TC_ho_int_a5_0() runs on test_CT {
5372 f_tc_ho_int_a5('01'O);
5373}
5374
5375testcase TC_ho_int_a5_1() runs on test_CT {
5376 f_tc_ho_int_a5('02'O);
5377}
5378
5379testcase TC_ho_int_a5_3() runs on test_CT {
5380 f_tc_ho_int_a5('08'O);
5381}
5382
5383testcase TC_ho_int_a5_4() runs on test_CT {
Oliver Smith7eabd312021-07-12 14:18:56 +02005384 f_tc_ho_int_a5('10'O, "0 1 3 4");
Neels Hofmeyraf88d9d2021-06-21 02:14:27 +02005385}
5386
Neels Hofmeyr5f144212020-11-03 15:41:58 +00005387/* intra-BSC hand-over with CONNection FAILure and cause Radio Link Failure: check RR release cause */
5388private function f_tc_ho_int_radio_link_failure(charstring id) runs on MSC_ConnHdlr {
5389 g_pars := f_gen_test_hdlr_pars();
5390 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
5391 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Neels Hofmeyr5f144212020-11-03 15:41:58 +00005392
5393 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
5394 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
5395
5396 f_establish_fully(ass_cmd, exp_compl);
5397 f_bts_0_cfg(BSCVTY, {"neighbor bts 1"});
5398
5399 var HandoverState hs := {
5400 rr_ho_cmpl_seen := false,
5401 handover_done := false,
Neels Hofmeyrc741fcb2021-10-02 14:52:28 +02005402 old_chan_nr := -,
5403 expect_target_tsc := BTS_TSC[1]
Neels Hofmeyr5f144212020-11-03 15:41:58 +00005404 };
5405 /* issue hand-over command on VTY */
5406 f_vty_handover(BSCVTY, 0, 0, g_chan_nr, 1);
5407 /* temporarily suspend DChan processing on BTS1 to avoid race with RSLEM_register */
5408 f_rslem_suspend(RSL1_PROC);
5409
5410 /* From the MGW perspective, a handover is is characterized by
5411 * performing one MDCX operation with the MGW. So we expect to see
5412 * one more MDCX during handover. */
5413 g_media.mgcp_conn[0].mdcx_seen_exp := g_media.mgcp_conn[0].crcx_seen_exp + 1;
5414
5415 var RSL_Message rsl;
5416 var PDU_ML3_NW_MS l3;
5417 var RslChannelNr new_chan_nr;
5418 var GsmArfcn arfcn;
5419 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr)) -> value rsl {
5420 l3 := dec_PDU_ML3_NW_MS(rsl.ies[2].body.l3_info.payload);
5421 if (not ischosen(l3.msgs.rrm.handoverCommand)) {
5422 setverdict(fail, "Expected handoverCommand");
5423 mtc.stop;
5424 }
5425 }
5426 f_ChDesc2RslChanNr(l3.msgs.rrm.handoverCommand.channelDescription2,
5427 new_chan_nr, arfcn);
5428
5429 f_rslem_register(0, new_chan_nr, RSL1_PROC);
5430
5431 /* resume processing of RSL DChan messages, which was temporarily suspended
5432 * before performing a hand-over */
5433 f_rslem_resume(RSL1_PROC);
5434 RSL1.receive(tr_RSL_IPA_CRCX(new_chan_nr));
5435
5436 f_sleep(1.0);
5437
5438 /* Handover fails because no HANDO DET appears on the new lchan,
5439 * and the old lchan reports a Radio Link Failure. */
5440 RSL.send(ts_RSL_CONN_FAIL_IND(g_chan_nr, RSL_ERR_RADIO_LINK_FAIL));
5441
5442 var PDU_BSSAP rx_clear_request;
5443 BSSAP.receive(tr_BSSMAP_ClearRequest) -> value rx_clear_request;
5444 var BssmapCause cause := bit2int(rx_clear_request.pdu.bssmap.clearRequest.cause.causeValue);
5445 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5446
5447 var RR_Cause rr_cause := GSM48_RR_CAUSE_ABNORMAL_UNSPEC;
5448
5449 var MgcpCommand mgcp;
5450 interleave {
5451 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE(int2oct(enum2int(rr_cause), 1)))) {}
5452 [] RSL.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {}
Neels Hofmeyr3c5127e2021-07-22 19:18:40 +02005453 [] RSL.receive(tr_RSL_RF_CHAN_REL(g_chan_nr)) {
Neels Hofmeyr5f144212020-11-03 15:41:58 +00005454 RSL.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
Neels Hofmeyre680b012021-07-22 19:19:09 +02005455 f_rslem_unregister(0, g_chan_nr);
Neels Hofmeyr5f144212020-11-03 15:41:58 +00005456 }
5457 [] RSL1.receive(tr_RSL_DEACT_SACCH(new_chan_nr)) {}
Neels Hofmeyr3c5127e2021-07-22 19:18:40 +02005458 [] RSL1.receive(tr_RSL_RF_CHAN_REL(new_chan_nr)) {
Neels Hofmeyr5f144212020-11-03 15:41:58 +00005459 RSL1.send(ts_RSL_RF_CHAN_REL_ACK(new_chan_nr));
Neels Hofmeyre680b012021-07-22 19:19:09 +02005460 f_rslem_unregister(0, g_chan_nr, PT := RSL1_PROC);
Neels Hofmeyr5f144212020-11-03 15:41:58 +00005461 }
5462 [] BSSAP.receive(tr_BSSMAP_ClearComplete) {}
5463 }
5464
5465 f_sleep(0.5);
5466 setverdict(pass);
5467}
5468testcase TC_ho_int_radio_link_failure() runs on test_CT {
5469 var MSC_ConnHdlr vc_conn;
5470 f_init(2, true);
5471 f_sleep(1.0);
5472
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01005473 f_ctrs_bsc_and_bts_handover_init();
Neels Hofmeyr5f144212020-11-03 15:41:58 +00005474
5475 vc_conn := f_start_handler(refers(f_tc_ho_int_radio_link_failure));
5476 vc_conn.done;
5477
5478 /* from f_establish_fully() */
5479 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5480 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5481 /* from handover */
5482 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5483 f_ctrs_bsc_and_bts_add(0, "handover:stopped");
5484 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5485 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:stopped");
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01005486 f_ctrs_bts_add(1, "incoming_intra_bsc_ho:attempted");
5487 f_ctrs_bts_add(1, "incoming_intra_bsc_ho:stopped");
Neels Hofmeyr5f144212020-11-03 15:41:58 +00005488 f_ctrs_bsc_and_bts_verify();
5489 f_shutdown_helper();
5490}
5491
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02005492/* Expecting MGCP to DLCX the endpoint's two connections: towards BTS and towards MSC */
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005493private function f_expect_dlcx_conns() runs on MSC_ConnHdlr {
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02005494 var MgcpCommand mgcp;
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02005495 var template MgcpResponse mgcp_resp;
5496 var MGCP_RecvFrom mrf;
5497 var template MgcpMessage msg_resp;
5498 var template MgcpMessage msg_dlcx := {
5499 command := tr_DLCX()
5500 }
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02005501
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02005502 if (g_pars.aoip) {
5503 MGCP.receive(tr_DLCX()) -> value mgcp {
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02005504 log("Got first DLCX: ", mgcp);
5505 MGCP.send(ts_DLCX_ACK2(mgcp.line.trans_id));
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02005506 };
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02005507
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02005508 MGCP.receive(tr_DLCX()) -> value mgcp {
5509 log("Got second DLCX: ", mgcp);
5510 MGCP.send(ts_DLCX_ACK2(mgcp.line.trans_id));
5511 };
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02005512 } else {
5513 /* For SCCPLite, BSC doesn't handle the MSC-side */
5514 MGCP_MULTI.receive(tr_MGCP_RecvFrom_any(msg_dlcx)) -> value mrf {
5515 log("Got first DLCX: ", mrf.msg.command);
5516 msg_resp := {
5517 response := ts_DLCX_ACK2(mrf.msg.command.line.trans_id)
5518 }
5519 MGCP_MULTI.send(t_MGCP_SendToMrf(mrf, msg_resp));
5520 };
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02005521 }
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02005522}
5523
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005524private 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 +01005525
Neels Hofmeyrafe2ea52021-11-24 15:16:12 +01005526 var NcellReports neighbor_rep := {
5527 { rxlev := 20, bcch_freq := 0, bsic := 11 }
5528 };
5529 var octetstring l3_mr := enc_GsmRrL3Message(valueof(ts_MEAS_REP(true, 8, 8, reps := neighbor_rep)));
5530 RSL.send(ts_RSL_MEAS_RES(g_chan_nr, 0, ts_RSL_IE_UplinkMeas, ts_RSL_IE_BS_Power(0), ts_RSL_IE_L1Info,
5531 l3_mr, 0));
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005532
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005533 BSSAP.receive(tr_BSSMAP_HandoverRequired(exp_oldToNewBSSIEs));
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005534
5535 f_sleep(0.5);
5536 /* The MSC negotiates Handover Request and Handover Request Ack with
5537 * the other BSS and comes back with a BSSMAP Handover Command
5538 * containing an RR Handover Command coming from the target BSS... */
5539
5540 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
5541 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
5542 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
5543 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
5544 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
5545
5546 /* expect the Handover Command to go out on RR */
5547 var RSL_Message rsl_ho_cmd
5548 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
5549 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
5550 var RSL_IE_Body rsl_ho_cmd_l3;
5551 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
5552 log("RSL message contains no L3 Info IE, expected RR Handover Command");
5553 setverdict(fail);
5554 } else {
5555 log("Found L3 Info: ", rsl_ho_cmd_l3);
5556 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
5557 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
5558 setverdict(fail);
5559 } else {
5560 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
5561 setverdict(pass);
5562 }
5563 }
5564
5565 /* When the other BSS has reported a completed handover, this side is
5566 * torn down. */
5567
5568 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_HANDOVER_SUCCESSFUL;
5569 var BssmapCause cause := enum2int(cause_val);
5570 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5571
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005572 f_expect_dlcx_conns();
Pau Espin Pedrol06199952021-06-15 11:30:00 +02005573
5574 interleave {
5575 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE));
5576 [] RSL.receive(tr_RSL_DEACT_SACCH(g_chan_nr));
5577 [] RSL.receive(tr_RSL_RF_CHAN_REL(g_chan_nr));
Neels Hofmeyr8fcd8772021-07-22 16:12:57 +02005578 [] BSSAP.receive(tr_BSSMAP_ClearComplete);
Pau Espin Pedrol06199952021-06-15 11:30:00 +02005579 }
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005580 setverdict(pass);
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005581}
5582
5583private function f_tc_ho_out_of_this_bsc(charstring id) runs on MSC_ConnHdlr {
5584 g_pars := f_gen_test_hdlr_pars();
5585 var PDU_BSSAP ass_req := f_gen_ass_req();
5586 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
5587 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
5588 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
5589 f_establish_fully(ass_req, exp_compl);
5590
5591 f_ho_out_of_this_bsc();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005592}
5593testcase TC_ho_out_of_this_bsc() runs on test_CT {
5594 var MSC_ConnHdlr vc_conn;
5595
Neels Hofmeyrafe2ea52021-11-24 15:16:12 +01005596 f_init_vty();
5597 f_bts_0_cfg(BSCVTY,
5598 {"neighbor-list mode automatic",
5599 "handover 1",
5600 "handover algorithm 2",
5601 "handover2 window rxlev averaging 1",
5602 "neighbor lac 99 arfcn 123 bsic any"});
5603 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
5604
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005605 f_init(1, true);
5606 f_sleep(1.0);
5607
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01005608 f_ctrs_bsc_and_bts_handover_init();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005609
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005610 vc_conn := f_start_handler(refers(f_tc_ho_out_of_this_bsc));
5611 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005612
5613 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5614 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5615 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5616 f_ctrs_bsc_and_bts_add(0, "handover:completed");
5617 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
5618 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:completed");
5619 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005620 f_shutdown_helper();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005621}
5622
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00005623private function f_mo_l3_transceive(RSL_DCHAN_PT rsl := RSL,
5624 template (value) RslLinkId link_id := ts_RslLinkID_DCCH(0),
Vadim Yanitskiy2ef6a2f2020-10-08 23:17:32 +07005625 template (present) OCT1 dlci := ?,
Vadim Yanitskiyb93aa432020-10-01 14:23:11 +07005626 octetstring l3 := '0123456789'O)
5627runs on MSC_ConnHdlr {
Neels Hofmeyr43654812020-09-25 01:35:35 +02005628 /* The old lchan and conn should still be active. See that arbitrary L3
5629 * is still going through. */
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00005630 rsl.send(ts_RSL_DATA_IND(g_chan_nr, link_id, l3));
Neels Hofmeyr43654812020-09-25 01:35:35 +02005631 var template PDU_BSSAP exp_data := {
5632 discriminator := '1'B,
5633 spare := '0000000'B,
Vadim Yanitskiyb93aa432020-10-01 14:23:11 +07005634 dlci := dlci,
5635 lengthIndicator := lengthof(l3),
Neels Hofmeyr43654812020-09-25 01:35:35 +02005636 pdu := {
5637 dtap := l3
5638 }
5639 };
5640 BSSAP.receive(exp_data);
5641 setverdict(pass);
5642}
5643
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00005644private function f_mt_l3_transceive(RSL_DCHAN_PT rsl := RSL,
5645 template (present) RslLinkId link_id := tr_RslLinkID_DCCH(0),
Vadim Yanitskiy0033a3b2020-10-01 22:21:16 +07005646 template (value) OCT1 dlci := '00'O,
5647 octetstring l3 := '0123456789'O)
5648runs on MSC_ConnHdlr {
5649 BSSAP.send(PDU_BSSAP:{
5650 discriminator := '1'B,
5651 spare := '0000000'B,
5652 dlci := dlci,
5653 lengthIndicator := lengthof(l3),
5654 pdu := {
5655 dtap := l3
5656 }
5657 });
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00005658 rsl.receive(tr_RSL_DATA_REQ(g_chan_nr, link_id, l3));
Vadim Yanitskiy0033a3b2020-10-01 22:21:16 +07005659 setverdict(pass);
5660}
5661
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005662/* BSC asks for inter-BSC HO, but the MSC decides that it won't happen and
5663 * simply never sends a BSSMAP Handover Command. */
5664private function f_tc_ho_out_fail_no_msc_response(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01005665 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005666
5667 var PDU_BSSAP ass_req := f_gen_ass_req();
5668 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
5669 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
5670 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
5671 f_establish_fully(ass_req, exp_compl);
5672
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005673 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005674 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
5675
5676 BSSAP.receive(tr_BSSMAP_HandoverRequired);
5677
5678 /* osmo-bsc should time out 10 seconds after the handover started.
5679 * Let's give it a bit extra. */
5680 f_sleep(15.0);
5681
Vadim Yanitskiy74ae5eb2020-10-01 22:13:29 +07005682 f_mo_l3_transceive();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005683 f_sleep(1.0);
5684}
5685testcase TC_ho_out_fail_no_msc_response() runs on test_CT {
5686 var MSC_ConnHdlr vc_conn;
5687
5688 f_init(1, true);
5689 f_sleep(1.0);
5690
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01005691 f_ctrs_bsc_and_bts_handover_init();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005692
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005693 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_no_msc_response));
5694 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005695
5696 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5697 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5698 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5699 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
5700 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
5701 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
5702 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005703 f_shutdown_helper();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005704}
5705
5706/* BSC asks for inter-BSC HO, receives BSSMAP Handover Command, but MS reports
5707 * RR Handover Failure. */
5708private function f_tc_ho_out_fail_rr_ho_failure(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01005709 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005710
5711 var PDU_BSSAP ass_req := f_gen_ass_req();
5712 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
5713 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
5714 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
5715 f_establish_fully(ass_req, exp_compl);
5716
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005717 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005718 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
5719
5720 BSSAP.receive(tr_BSSMAP_HandoverRequired);
5721
5722 f_sleep(0.5);
5723 /* The MSC negotiates Handover Request and Handover Request Ack with
5724 * the other BSS and comes back with a BSSMAP Handover Command
5725 * containing an RR Handover Command coming from the target BSS... */
5726
5727 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
5728 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
5729 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
5730 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
5731 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
5732
5733 /* expect the Handover Command to go out on RR */
5734 var RSL_Message rsl_ho_cmd
5735 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
5736 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
5737 var RSL_IE_Body rsl_ho_cmd_l3;
5738 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
5739 log("RSL message contains no L3 Info IE, expected RR Handover Command");
5740 setverdict(fail);
5741 } else {
5742 log("Found L3 Info: ", rsl_ho_cmd_l3);
5743 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
5744 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
5745 setverdict(fail);
5746 } else {
5747 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
5748 setverdict(pass);
5749 }
5750 }
5751
5752 f_sleep(0.2);
5753 f_rsl_send_l3(ts_RRM_HandoverFailure('00'O));
5754
5755 /* Should tell the MSC about the failure */
5756 BSSAP.receive(tr_BSSMAP_HandoverFailure);
5757
5758 f_sleep(1.0);
5759
Vadim Yanitskiy74ae5eb2020-10-01 22:13:29 +07005760 f_mo_l3_transceive();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005761 f_sleep(1.0);
5762
5763 setverdict(pass);
5764 f_sleep(1.0);
5765}
5766testcase TC_ho_out_fail_rr_ho_failure() runs on test_CT {
5767 var MSC_ConnHdlr vc_conn;
5768
5769 f_init(1, true);
5770 f_sleep(1.0);
5771
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01005772 f_ctrs_bsc_and_bts_handover_init();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005773
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005774 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_rr_ho_failure));
5775 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005776
5777 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5778 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5779 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5780 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5781 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
5782 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:failed");
5783 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005784 f_shutdown_helper();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005785}
5786
Neels Hofmeyr10f2bfa2019-07-09 19:33:29 +02005787/* BSC asks for inter-BSC-out HO, receives BSSMAP Handover Command, but then no reply is received about HO outcome
5788 * (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 +02005789 * and the lchan is released. */
5790private function f_tc_ho_out_fail_no_result_after_ho_cmd(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01005791 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005792
5793 var PDU_BSSAP ass_req := f_gen_ass_req();
5794 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
5795 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
5796 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
5797 f_establish_fully(ass_req, exp_compl);
5798
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005799 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005800 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
5801
5802 BSSAP.receive(tr_BSSMAP_HandoverRequired);
5803
5804 f_sleep(0.5);
5805 /* The MSC negotiates Handover Request and Handover Request Ack with
5806 * the other BSS and comes back with a BSSMAP Handover Command
5807 * containing an RR Handover Command coming from the target BSS... */
5808
5809 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
5810 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
5811 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
5812 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
5813 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
5814
5815 /* expect the Handover Command to go out on RR */
5816 var RSL_Message rsl_ho_cmd
5817 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
5818 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
5819 var RSL_IE_Body rsl_ho_cmd_l3;
5820 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
5821 log("RSL message contains no L3 Info IE, expected RR Handover Command");
5822 setverdict(fail);
5823 } else {
5824 log("Found L3 Info: ", rsl_ho_cmd_l3);
5825 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
5826 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
5827 setverdict(fail);
5828 } else {
5829 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
5830 setverdict(pass);
5831 }
5832 }
5833
Neels Hofmeyr10f2bfa2019-07-09 19:33:29 +02005834 /* We get neither success nor failure report from the remote BSS. Eventually T8 times out and we run into 3GPP
5835 * TS 48.008 3.1.5.3.3 "Abnormal Conditions": Clear Request should go to the MSC, and RR should be released
5836 * after Clear Command */
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005837
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005838 var PDU_BSSAP rx_clear_request;
Neels Hofmeyre1797aa2019-07-09 19:34:04 +02005839 BSSAP.receive(tr_BSSMAP_ClearRequest) -> value rx_clear_request;
5840 log("Got BSSMAP Clear Request");
5841 /* Instruct BSC to clear channel */
5842 var BssmapCause cause := bit2int(rx_clear_request.pdu.bssmap.clearRequest.cause.causeValue);
5843 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5844
5845 var MgcpCommand mgcp;
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005846 interleave {
Neels Hofmeyr861a4c12018-11-07 01:23:17 +01005847 [] RSL.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
5848 log("Got Deact SACCH");
5849 }
Harald Welte924b6ea2019-02-04 01:05:34 +01005850 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
Neels Hofmeyr211169d2018-11-07 00:37:29 +01005851 log("Got RR Release");
5852 }
Neels Hofmeyr3c5127e2021-07-22 19:18:40 +02005853 [] RSL.receive(tr_RSL_RF_CHAN_REL(g_chan_nr)) {
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005854 log("Got RF Chan Rel");
5855 RSL.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
Neels Hofmeyre680b012021-07-22 19:19:09 +02005856 f_rslem_unregister(0, g_chan_nr);
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005857 }
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005858 }
5859
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005860 f_expect_dlcx_conns();
Neels Hofmeyr8fcd8772021-07-22 16:12:57 +02005861 BSSAP.receive(tr_BSSMAP_ClearComplete);
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02005862
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005863 setverdict(pass);
5864 f_sleep(1.0);
5865}
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02005866testcase TC_ho_out_fail_no_result_after_ho_cmd() runs on test_CT {
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005867 var MSC_ConnHdlr vc_conn;
5868
5869 f_init(1, true);
5870 f_sleep(1.0);
5871
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01005872 f_ctrs_bsc_and_bts_handover_init();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005873
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02005874 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_no_result_after_ho_cmd));
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005875 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005876
5877 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5878 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5879 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5880 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
5881 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
5882 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
5883 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005884 f_shutdown_helper();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005885}
5886
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005887private 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 +01005888 /* Hack: the proper way would be to wait for the BSSMAP Handover Request ACK and extract the
5889 * actual assigned chan_nr from its L3 (RR Handover Command) message. But osmo-bsc starts acting
5890 * on the lchan even before we get a chance to evaluate the BSSMAP Handover Request ACK. So we
5891 * need to assume that osmo-bsc will activate TS 1 and already set up this lchan's RSL emulation
5892 * before we get started. */
5893 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
5894 f_rslem_register(0, new_chan_nr);
5895 g_chan_nr := new_chan_nr;
Neels Hofmeyr34174bd2021-10-02 14:52:57 +02005896 var uint3_t expect_target_tsc := BTS_TSC[0];
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005897 f_sleep(1.0);
5898
5899 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
5900 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5901 activate(as_Media());
5902
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005903 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02005904 f_gen_handover_req(aoip_tla := g_pars.host_aoip_tla,
Neels Hofmeyr8ebf19c2021-06-21 05:24:01 +02005905 oldToNewBSSIEs := oldToNewBSSIEs,
5906 enc := g_pars.encr)));
Harald Welte6811d102019-04-14 22:23:14 +02005907 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005908
5909 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
5910
5911 var PDU_BSSAP rx_bssap;
5912 var octetstring ho_command_str;
5913
5914 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
Pau Espin Pedrol76ba5412019-06-10 11:00:33 +02005915
Neels Hofmeyr34174bd2021-10-02 14:52:57 +02005916 /* we're sure that the channel activation is done now, verify the parameters in it */
5917 var RSL_Message chan_act := f_rslem_get_last_act(RSL_PROC, 0, g_chan_nr);
5918 f_verify_encr_info(chan_act);
5919 f_chan_act_verify_tsc(chan_act, expect_target_tsc);
Neels Hofmeyr8ebf19c2021-06-21 05:24:01 +02005920
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005921 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
5922 log("Received L3 Info in HO Request Ack: ", ho_command_str);
5923 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
5924 log("L3 Info in HO Request Ack is ", ho_command);
5925
5926 var GsmArfcn arfcn;
5927 var RslChannelNr actual_new_chan_nr;
5928 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
5929 actual_new_chan_nr, arfcn);
5930
5931 if (actual_new_chan_nr != new_chan_nr) {
5932 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
5933 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
5934 setverdict(fail);
5935 return;
5936 }
5937 log("Handover Command chan_nr is", actual_new_chan_nr);
5938
Neels Hofmeyr34174bd2021-10-02 14:52:57 +02005939 var uint3_t got_tsc := rr_chan_desc_tsc(ho_command.msgs.rrm.handoverCommand.channelDescription2);
5940 if (not match(got_tsc, expect_target_tsc)) {
5941 setverdict(fail, "RR Handover Command: unexpected TSC in Channel Description: expected ",
5942 expect_target_tsc, " got ", got_tsc);
5943 mtc.stop;
5944 } else {
5945 log("handoverCommand: verified TSC = ", got_tsc);
5946 }
5947
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005948 /* Now the MSC forwards the RR Handover Command to the other BSC, which
5949 * tells the MS to handover to the new lchan. Here comes the new MS on
5950 * the new lchan with a Handover RACH: */
5951
5952 /* send handover detect */
5953
5954 RSL.send(ts_RSL_HANDO_DET(new_chan_nr));
5955
5956 BSSAP.receive(tr_BSSMAP_HandoverDetect);
5957
5958 /* send handover complete over the new channel */
5959
5960 var PDU_ML3_MS_NW l3_tx := valueof(ts_RRM_HandoverComplete('00'O));
5961 RSL.send(ts_RSL_EST_IND(new_chan_nr, valueof(ts_RslLinkID_DCCH(0)),
5962 enc_PDU_ML3_MS_NW(l3_tx)));
5963
5964 BSSAP.receive(tr_BSSMAP_HandoverComplete);
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005965 setverdict(pass);
5966}
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02005967
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005968private function f_tc_ho_into_this_bsc(charstring id) runs on MSC_ConnHdlr {
Pau Espin Pedrol9ae36d52021-06-15 17:29:43 +02005969 var template PDU_ML3_NW_MS exp_rr_rel_tmpl;
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005970 var template (omit) BSSMAP_oldToNewBSSIEs oldToNewBSSIEs := omit;
5971 if (not istemplatekind(g_pars.last_used_eutran_plmn, "omit")) {
5972 oldToNewBSSIEs := f_ts_BSSMAP_oldToNewBSSIEs(ts_BSSMAP_LastUsedEUTRANPLMNId(g_pars.last_used_eutran_plmn));
Pau Espin Pedrol9ae36d52021-06-15 17:29:43 +02005973 }
5974 if (g_pars.exp_fast_return) {
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005975 exp_rr_rel_tmpl := tr_RRM_RR_RELEASE_CellSelectInd;
Pau Espin Pedrol9ae36d52021-06-15 17:29:43 +02005976 } else {
5977 exp_rr_rel_tmpl := tr_RRM_RR_RELEASE;
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005978 }
5979 f_ho_into_this_bsc(id, oldToNewBSSIEs);
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02005980 f_perform_clear(exp_rr_rel_tmpl := exp_rr_rel_tmpl);
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005981 setverdict(pass);
5982}
Pau Espin Pedrol07866632020-09-03 19:10:55 +02005983function f_tc_ho_into_this_bsc_main(TestHdlrParams pars) runs on test_CT {
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005984 var MSC_ConnHdlr vc_conn;
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005985
5986 f_init(1, true);
5987 f_sleep(1.0);
5988
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01005989 f_ctrs_bsc_and_bts_handover_init();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005990
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005991 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5992 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005993
5994 vc_conn := f_start_handler(refers(f_tc_ho_into_this_bsc), pars);
5995 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005996
5997 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5998 f_ctrs_bsc_and_bts_add(0, "handover:completed");
5999 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
6000 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:completed");
6001 f_ctrs_bsc_and_bts_verify();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01006002}
6003
Pau Espin Pedrol07866632020-09-03 19:10:55 +02006004testcase TC_ho_into_this_bsc() runs on test_CT {
6005 var TestHdlrParams pars := f_gen_test_hdlr_pars();
6006 f_tc_ho_into_this_bsc_main(pars);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006007 f_shutdown_helper();
Pau Espin Pedrol07866632020-09-03 19:10:55 +02006008}
6009
Neels Hofmeyr8ebf19c2021-06-21 05:24:01 +02006010function f_tc_ho_into_this_bsc_a5(OCT1 encr_alg) runs on test_CT {
6011 var TestHdlrParams pars := f_gen_test_hdlr_pars();
6012 pars.encr := valueof(t_EncrParams(encr_alg, f_rnd_octstring(8), f_rnd_octstring(16)));
6013 f_tc_ho_into_this_bsc_main(pars);
6014 f_shutdown_helper();
6015}
6016
6017testcase TC_ho_into_this_bsc_a5_0() runs on test_CT {
6018 f_tc_ho_into_this_bsc_a5('01'O);
6019}
6020
6021testcase TC_ho_into_this_bsc_a5_1() runs on test_CT {
6022 f_tc_ho_into_this_bsc_a5('02'O);
6023}
6024
6025testcase TC_ho_into_this_bsc_a5_3() runs on test_CT {
6026 f_tc_ho_into_this_bsc_a5('08'O);
6027}
6028
6029testcase TC_ho_into_this_bsc_a5_4() runs on test_CT {
6030 f_tc_ho_into_this_bsc_a5('10'O);
6031}
6032
Pau Espin Pedrol07866632020-09-03 19:10:55 +02006033testcase TC_ho_into_this_bsc_tla_v6() runs on test_CT {
6034 var TestHdlrParams pars := f_gen_test_hdlr_pars();
6035 pars.host_aoip_tla := "::6";
6036 f_tc_ho_into_this_bsc_main(pars);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006037 f_shutdown_helper();
Pau Espin Pedrol07866632020-09-03 19:10:55 +02006038}
6039
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02006040/* Similar to TC_ho_into_this_bsc, but when in SRVCC, HO Req contains "Old BSS
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02006041 to New BSS Information" IE with "Last Used E-UTRAN PLMN Id", which, when the
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02006042 channel is later released (RR CHannel Release), should trigger inclusion of
6043 IE "Cell Selection Indicator after Release of all TCH and SDCCH" with E-UTRAN
6044 neighbors. */
6045testcase TC_srvcc_eutran_to_geran() runs on test_CT {
6046 var TestHdlrParams pars := f_gen_test_hdlr_pars();
6047 pars.last_used_eutran_plmn := '323454'O;
Pau Espin Pedrol9ae36d52021-06-15 17:29:43 +02006048 pars.exp_fast_return := true;
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02006049 f_tc_ho_into_this_bsc_main(pars);
Pau Espin Pedrol211a7142021-06-15 16:43:03 +02006050
6051 f_ctrs_bsc_and_bts_add(0, "srvcc:attempted");
6052 f_ctrs_bsc_and_bts_add(0, "srvcc:completed");
6053 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02006054 f_shutdown_helper();
6055}
6056
Pau Espin Pedrol9ae36d52021-06-15 17:29:43 +02006057/* Same as TC_srvcc_eutran_to_geran, but test explicitly forbiding fast return
6058 on the BTS. As a result, RR Release shouldn't contain the EUTRAN neighbor
6059 list when the channel is released. */
6060testcase TC_srvcc_eutran_to_geran_forbid_fast_return() runs on test_CT {
6061 f_init_vty();
6062 f_vty_allow_srvcc_fast_return(true, 0)
6063
6064 var TestHdlrParams pars := f_gen_test_hdlr_pars();
6065 pars.last_used_eutran_plmn := '323454'O;
6066 pars.exp_fast_return := false;
6067 f_tc_ho_into_this_bsc_main(pars);
6068 f_vty_allow_srvcc_fast_return(false, 0);
6069 f_shutdown_helper();
6070}
6071
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02006072private function f_tc_srvcc_eutran_to_geran_ho_out(charstring id) runs on MSC_ConnHdlr {
6073 var template (omit) BSSMAP_oldToNewBSSIEs oldToNewBSSIEs;
6074 oldToNewBSSIEs := f_ts_BSSMAP_oldToNewBSSIEs(ts_BSSMAP_LastUsedEUTRANPLMNId(g_pars.last_used_eutran_plmn));
6075 f_ho_into_this_bsc(id, oldToNewBSSIEs);
6076 f_ho_out_of_this_bsc(oldToNewBSSIEs);
6077 setverdict(pass);
6078}
Pau Espin Pedrol9ae36d52021-06-15 17:29:43 +02006079
6080private function f_tc_srvcc_eutran_to_geran_ho_out_main(boolean disable_fast_return)
6081 runs on test_CT {
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02006082 var MSC_ConnHdlr vc_conn;
6083 var TestHdlrParams pars := f_gen_test_hdlr_pars();
6084
6085 f_init(1, true);
Pau Espin Pedrol9ae36d52021-06-15 17:29:43 +02006086 if (disable_fast_return) {
6087 f_vty_allow_srvcc_fast_return(true, 0);
6088 }
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02006089 f_sleep(1.0);
6090
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01006091 f_ctrs_bsc_and_bts_handover_init();
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02006092
6093 pars.last_used_eutran_plmn := '323454'O;
6094 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
6095 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
6096
6097 vc_conn := f_start_handler(refers(f_tc_srvcc_eutran_to_geran_ho_out), pars);
6098 vc_conn.done;
6099
6100 f_ctrs_bsc_and_bts_add(0, "handover:attempted", 2);
6101 f_ctrs_bsc_and_bts_add(0, "handover:completed", 2);
6102 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted", 1);
6103 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:completed", 1);
6104 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted", 1);
6105 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:completed", 1);
Pau Espin Pedrol211a7142021-06-15 16:43:03 +02006106
6107 f_ctrs_bsc_and_bts_add(0, "srvcc:attempted", 1);
6108 f_ctrs_bsc_and_bts_add(0, "srvcc:completed", 1);
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02006109 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol9ae36d52021-06-15 17:29:43 +02006110
6111 if (disable_fast_return) {
6112 f_vty_allow_srvcc_fast_return(false, 0);
6113 }
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02006114 f_shutdown_helper();
6115}
6116
Pau Espin Pedrol9ae36d52021-06-15 17:29:43 +02006117/* First, HO into BSC from EUTRAN (SRVCC): HO Request contains "Old BSS to New
6118 BSS Information" IE with "Last Used E-UTRAN PLMN Id".
6119 Second, HO to another BSC: HO Required contains "Old BSS to New BSS Information"
6120 IE with "Last Used E-UTRAN PLMN Id" from first step. */
6121testcase TC_srvcc_eutran_to_geran_ho_out() runs on test_CT {
6122 f_tc_srvcc_eutran_to_geran_ho_out_main(false);
6123}
6124/* Validate subsequent intra-GSM-HO works the same (with OldBSSToNewBSSInfo IE)
6125 * independently of fast-reture allowed/forbidden in local BTS */
6126testcase TC_srvcc_eutran_to_geran_ho_out_forbid_fast_return() runs on test_CT {
6127 f_tc_srvcc_eutran_to_geran_ho_out_main(true);
6128}
6129
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006130private function f_tc_ho_in_fail_msc_clears(charstring id) runs on MSC_ConnHdlr {
6131 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
6132 f_rslem_register(0, new_chan_nr);
6133 g_chan_nr := new_chan_nr;
6134 f_sleep(1.0);
6135
6136 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
6137 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
6138 activate(as_Media());
6139
Neels Hofmeyr90f80962020-06-12 16:16:55 +02006140 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006141 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02006142 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006143
6144 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
6145
6146 var PDU_BSSAP rx_bssap;
6147 var octetstring ho_command_str;
6148
6149 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
6150
6151 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
6152 log("Received L3 Info in HO Request Ack: ", ho_command_str);
6153 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
6154 log("L3 Info in HO Request Ack is ", ho_command);
6155
6156 var GsmArfcn arfcn;
6157 var RslChannelNr actual_new_chan_nr;
6158 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
6159 actual_new_chan_nr, arfcn);
6160
6161 if (actual_new_chan_nr != new_chan_nr) {
6162 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
6163 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
6164 setverdict(fail);
6165 return;
6166 }
6167 log("Handover Command chan_nr is", actual_new_chan_nr);
6168
Neels Hofmeyr61ca08d2019-05-06 23:52:22 +02006169 /* For deterministic test results, give some time for the MGW endpoint to be configured */
6170 f_sleep(1.0);
6171
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006172 /* Now the MSC forwards the RR Handover Command to the other BSC, which
6173 * tells the MS to handover to the new lchan. In this case, the MS
6174 * reports a Handover Failure to the old BSS, which forwards a BSSMAP
6175 * Handover Failure to the MSC. The procedure according to 3GPP TS
6176 * 48.008 3.1.5.3.2 "Handover Failure" is then that the MSC sends a
6177 * BSSMAP Clear Command: */
6178
6179 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
6180 var BssmapCause cause := enum2int(cause_val);
6181 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
6182
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02006183 f_expect_dlcx_conns();
Neels Hofmeyr8fcd8772021-07-22 16:12:57 +02006184 BSSAP.receive(tr_BSSMAP_ClearComplete);
6185
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006186 setverdict(pass);
6187 f_sleep(1.0);
6188
6189 setverdict(pass);
6190}
6191testcase TC_ho_in_fail_msc_clears() runs on test_CT {
6192 var MSC_ConnHdlr vc_conn;
6193 var TestHdlrParams pars := f_gen_test_hdlr_pars();
6194
6195 f_init(1, true);
6196 f_sleep(1.0);
6197
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01006198 f_ctrs_bsc_and_bts_handover_init();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006199
Neels Hofmeyr90f80962020-06-12 16:16:55 +02006200 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
6201 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006202
6203 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_msc_clears), pars);
6204 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006205
6206 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6207 f_ctrs_bsc_and_bts_add(0, "handover:stopped");
6208 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
6209 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:stopped");
6210 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006211 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006212}
6213
6214private function f_tc_ho_in_fail_msc_clears_after_ho_detect(charstring id) runs on MSC_ConnHdlr {
6215 /* Hack: the proper way would be to wait for the BSSMAP Handover Request ACK and extract the
6216 * actual assigned chan_nr from its L3 (RR Handover Command) message. But osmo-bsc starts acting
6217 * on the lchan even before we get a chance to evaluate the BSSMAP Handover Request ACK. So we
6218 * need to assume that osmo-bsc will activate TS 1 and already set up this lchan's RSL emulation
6219 * before we get started. */
6220 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
6221 f_rslem_register(0, new_chan_nr);
6222 g_chan_nr := new_chan_nr;
6223 f_sleep(1.0);
6224
6225 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
6226 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
6227 activate(as_Media());
6228
Neels Hofmeyr90f80962020-06-12 16:16:55 +02006229 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006230 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02006231 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006232
6233 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
6234
6235 var PDU_BSSAP rx_bssap;
6236 var octetstring ho_command_str;
6237
6238 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
6239
6240 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
6241 log("Received L3 Info in HO Request Ack: ", ho_command_str);
6242 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
6243 log("L3 Info in HO Request Ack is ", ho_command);
6244
6245 var GsmArfcn arfcn;
6246 var RslChannelNr actual_new_chan_nr;
6247 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
6248 actual_new_chan_nr, arfcn);
6249
6250 if (actual_new_chan_nr != new_chan_nr) {
6251 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
6252 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
6253 setverdict(fail);
6254 return;
6255 }
6256 log("Handover Command chan_nr is", actual_new_chan_nr);
6257
6258 /* Now the MSC forwards the RR Handover Command to the other BSC, which
6259 * tells the MS to handover to the new lchan. Here comes the new MS on
6260 * the new lchan with a Handover RACH: */
6261
6262 /* send handover detect */
6263
6264 RSL.send(ts_RSL_HANDO_DET(new_chan_nr));
6265
6266 BSSAP.receive(tr_BSSMAP_HandoverDetect);
6267
6268 /* The MSC chooses to clear the connection now, maybe we got the
6269 * Handover RACH on the new cell but the MS still signaled Handover
6270 * Failure to the old BSS? */
6271
6272 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
6273 var BssmapCause cause := enum2int(cause_val);
6274 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
6275
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02006276 f_expect_dlcx_conns();
Neels Hofmeyr8fcd8772021-07-22 16:12:57 +02006277 BSSAP.receive(tr_BSSMAP_ClearComplete);
6278
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006279 f_sleep(1.0);
6280}
6281testcase TC_ho_in_fail_msc_clears_after_ho_detect() runs on test_CT {
6282 var MSC_ConnHdlr vc_conn;
6283 var TestHdlrParams pars := f_gen_test_hdlr_pars();
6284
6285 f_init(1, true);
6286 f_sleep(1.0);
6287
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01006288 f_ctrs_bsc_and_bts_handover_init();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006289
Neels Hofmeyr90f80962020-06-12 16:16:55 +02006290 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
6291 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006292
6293 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_msc_clears_after_ho_detect), pars);
6294 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006295
6296 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6297 f_ctrs_bsc_and_bts_add(0, "handover:stopped");
6298 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
6299 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:stopped");
6300 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006301 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006302}
6303
6304/* The new BSS's lchan times out before the MSC decides that handover failed. */
6305private function f_tc_ho_in_fail_no_detect(charstring id) runs on MSC_ConnHdlr {
6306 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
6307 f_rslem_register(0, new_chan_nr);
6308 g_chan_nr := new_chan_nr;
6309 f_sleep(1.0);
6310
6311 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
6312 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
6313 activate(as_Media());
6314
Neels Hofmeyr90f80962020-06-12 16:16:55 +02006315 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006316 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02006317 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006318
6319 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
6320
6321 var PDU_BSSAP rx_bssap;
6322 var octetstring ho_command_str;
6323
6324 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
6325
6326 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
6327 log("Received L3 Info in HO Request Ack: ", ho_command_str);
6328 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
6329 log("L3 Info in HO Request Ack is ", ho_command);
6330
6331 var GsmArfcn arfcn;
6332 var RslChannelNr actual_new_chan_nr;
6333 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
6334 actual_new_chan_nr, arfcn);
6335
6336 if (actual_new_chan_nr != new_chan_nr) {
6337 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
6338 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
6339 setverdict(fail);
6340 return;
6341 }
6342 log("Handover Command chan_nr is", actual_new_chan_nr);
6343
6344 /* Now the MSC forwards the RR Handover Command to the other BSC, which
6345 * tells the MS to handover to the new lchan. But the MS never shows up
6346 * on the new lchan. */
6347
6348 BSSAP.receive(tr_BSSMAP_HandoverFailure);
6349
6350 /* Did osmo-bsc also send a Clear Request? */
6351 timer T := 0.5;
6352 T.start;
6353 alt {
6354 [] BSSAP.receive(tr_BSSMAP_ClearRequest);
6355 [] T.timeout { }
6356 }
6357
6358 /* MSC plays along with a Clear Command (no matter whether osmo-bsc
6359 * asked for it, this is a Handover Failure after all). */
6360
6361 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
6362 var BssmapCause cause := enum2int(cause_val);
6363 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
6364
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02006365 f_expect_dlcx_conns();
Neels Hofmeyr8fcd8772021-07-22 16:12:57 +02006366 BSSAP.receive(tr_BSSMAP_ClearComplete);
6367
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006368 f_sleep(1.0);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006369}
6370testcase TC_ho_in_fail_no_detect() runs on test_CT {
6371 var MSC_ConnHdlr vc_conn;
6372 var TestHdlrParams pars := f_gen_test_hdlr_pars();
6373
6374 f_init(1, true);
6375 f_sleep(1.0);
6376
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01006377 f_ctrs_bsc_and_bts_handover_init();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006378
Neels Hofmeyr90f80962020-06-12 16:16:55 +02006379 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
6380 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006381
6382 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_no_detect), pars);
6383 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006384
6385 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6386 f_ctrs_bsc_and_bts_add(0, "handover:error");
6387 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
6388 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:error");
6389 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006390 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006391}
6392
6393/* Same as f_tc_ho_in_fail_no_detect, but MSC fails to send a Clear Command */
6394private function f_tc_ho_in_fail_no_detect2(charstring id) runs on MSC_ConnHdlr {
6395 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
6396 f_rslem_register(0, new_chan_nr);
6397 g_chan_nr := new_chan_nr;
6398 f_sleep(1.0);
6399
6400 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
6401 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
6402 activate(as_Media());
6403
Neels Hofmeyr90f80962020-06-12 16:16:55 +02006404 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006405 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02006406 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006407
6408 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
6409
6410 var PDU_BSSAP rx_bssap;
6411 var octetstring ho_command_str;
6412
6413 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
6414
6415 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
6416 log("Received L3 Info in HO Request Ack: ", ho_command_str);
6417 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
6418 log("L3 Info in HO Request Ack is ", ho_command);
6419
6420 var GsmArfcn arfcn;
6421 var RslChannelNr actual_new_chan_nr;
6422 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
6423 actual_new_chan_nr, arfcn);
6424
6425 if (actual_new_chan_nr != new_chan_nr) {
6426 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
6427 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
6428 setverdict(fail);
6429 return;
6430 }
6431 log("Handover Command chan_nr is", actual_new_chan_nr);
6432
6433 /* Now the MSC forwards the RR Handover Command to the other BSC, which
6434 * tells the MS to handover to the new lchan. But the MS never shows up
6435 * on the new lchan. */
6436
6437 BSSAP.receive(tr_BSSMAP_HandoverFailure);
6438
6439 /* MSC plays dumb and sends no Clear Command */
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006440 var PDU_BSSAP rx_clear_request;
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02006441
6442 BSSAP.receive(tr_BSSMAP_ClearRequest) -> value rx_clear_request {
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006443 var BssmapCause cause := bit2int(rx_clear_request.pdu.bssmap.clearRequest.cause.causeValue);
6444 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
6445 };
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02006446 f_expect_dlcx_conns();
Neels Hofmeyr8fcd8772021-07-22 16:12:57 +02006447 BSSAP.receive(tr_BSSMAP_ClearComplete);
6448
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006449 f_sleep(1.0);
6450}
6451testcase TC_ho_in_fail_no_detect2() runs on test_CT {
6452 var MSC_ConnHdlr vc_conn;
6453 var TestHdlrParams pars := f_gen_test_hdlr_pars();
6454
6455 f_init(1, true);
6456 f_sleep(1.0);
6457
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01006458 f_ctrs_bsc_and_bts_handover_init();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006459
Neels Hofmeyr90f80962020-06-12 16:16:55 +02006460 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
6461 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006462
6463 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_no_detect2), pars);
6464 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006465
6466 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6467 f_ctrs_bsc_and_bts_add(0, "handover:error");
6468 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
6469 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:error");
6470 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006471 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006472}
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01006473
Neels Hofmeyr91401012019-07-11 00:42:35 +02006474type record of charstring Commands;
6475
Neels Hofmeyr666f0432020-07-04 00:53:07 +02006476private function f_bts_0_cfg(TELNETasp_PT pt, Commands cmds := {})
Neels Hofmeyr91401012019-07-11 00:42:35 +02006477{
Neels Hofmeyr666f0432020-07-04 00:53:07 +02006478 f_vty_enter_cfg_bts(pt, 0);
Neels Hofmeyr91401012019-07-11 00:42:35 +02006479 for (var integer i := 0; i < sizeof(cmds); i := i+1) {
Neels Hofmeyr666f0432020-07-04 00:53:07 +02006480 f_vty_transceive(pt, cmds[i]);
Neels Hofmeyr91401012019-07-11 00:42:35 +02006481 }
Neels Hofmeyr666f0432020-07-04 00:53:07 +02006482 f_vty_transceive(pt, "end");
Neels Hofmeyr91401012019-07-11 00:42:35 +02006483}
6484
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01006485private function f_cs7_inst_0_cfg(TELNETasp_PT pt, Commands cmds := {})
6486{
6487 f_vty_enter_cfg_cs7_inst(pt, 0);
6488 for (var integer i := 0; i < sizeof(cmds); i := i+1) {
6489 f_vty_transceive(pt, cmds[i]);
6490 }
6491 f_vty_transceive(pt, "end");
6492}
6493
Neels Hofmeyr91401012019-07-11 00:42:35 +02006494private function f_probe_for_handover(charstring log_label,
6495 charstring log_descr,
6496 charstring handover_vty_cmd,
6497 boolean expect_handover,
Neels Hofmeyr6a955cc2021-10-02 14:53:48 +02006498 boolean is_inter_bsc_handover := false,
6499 template uint3_t expect_target_tsc := ?)
Neels Hofmeyr91401012019-07-11 00:42:35 +02006500runs on MSC_ConnHdlr
6501{
Neels Hofmeyrb3fc8982020-05-11 00:16:42 +02006502 /* We're going to thwart any and all handover attempts, just be ready to handle (and ignore) handover target
6503 * lchans to be established on bts 1 or bts 2. */
6504 f_rslem_suspend(RSL1_PROC);
6505 f_rslem_suspend(RSL2_PROC);
6506
Neels Hofmeyr91401012019-07-11 00:42:35 +02006507 var RSL_Message rsl;
6508
6509 var charstring log_msg := " (expecting handover)"
6510 if (not expect_handover) {
6511 log_msg := " (expecting NO handover)";
6512 }
6513 log("f_probe_for_handover starting: " & log_label & ": " & log_descr & log_msg);
6514 f_vty_transceive(BSCVTY, handover_vty_cmd);
6515
Neels Hofmeyr91401012019-07-11 00:42:35 +02006516 timer T := 2.0;
6517 T.start;
6518
6519 alt {
6520 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr)) -> value rsl {
6521 var PDU_ML3_NW_MS l3 := dec_PDU_ML3_NW_MS(rsl.ies[2].body.l3_info.payload);
6522 log("Rx L3 from net: ", l3);
6523 if (ischosen(l3.msgs.rrm.handoverCommand)) {
6524 var RslChannelNr new_chan_nr;
6525 var GsmArfcn arfcn;
6526 f_ChDesc2RslChanNr(l3.msgs.rrm.handoverCommand.channelDescription2,
6527 new_chan_nr, arfcn);
6528 log("Handover to new chan ", new_chan_nr, " on ARFCN ", arfcn);
6529 log(l3.msgs.rrm.handoverCommand);
6530
Neels Hofmeyr6a955cc2021-10-02 14:53:48 +02006531 /* Verify correct TSC in handoverCommand */
6532 var uint3_t got_tsc := rr_chan_desc_tsc(l3.msgs.rrm.handoverCommand.channelDescription2);
6533 if (not match(got_tsc, expect_target_tsc)) {
6534 setverdict(fail, "RR Handover Command: unexpected TSC in Channel Description: expected ",
6535 expect_target_tsc, " got ", got_tsc);
6536 mtc.stop;
6537 } else {
6538 log("handoverCommand: verified TSC = ", got_tsc, " (matches ",
6539 expect_target_tsc, ")");
6540 }
6541
Neels Hofmeyr91401012019-07-11 00:42:35 +02006542 /* Need to register for new lchan on new BTS -- it's either bts 1 or bts 2. It doesn't really
6543 * matter on which BTS it really is, we're not going to follow through an entire handover
6544 * anyway. */
6545 f_rslem_register(0, new_chan_nr, RSL1_PROC);
6546 f_rslem_resume(RSL1_PROC);
6547 f_rslem_register(0, new_chan_nr, RSL2_PROC);
6548 f_rslem_resume(RSL2_PROC);
6549
6550 if (expect_handover and not is_inter_bsc_handover) {
6551 setverdict(pass);
6552 log("f_probe_for_handover(" & log_label & "): Got RSL Handover Command as expected.");
6553 } else {
6554 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected none, but got RSL Handover Command. "
6555 & log_label & ": " & log_descr);
6556 }
6557
6558 log("f_probe_for_handover(" & log_label & "): Ending the test: Handover Failure stops the procedure.");
6559 /* osmo-bsc has triggered Handover. That's all we need to know for this test, reply with
6560 * Handover Failure. */
6561 f_rsl_send_l3(ts_RRM_HandoverFailure('00'O));
6562
6563 /* target BTS is told to release lchan again; don't care which BTS nor what messages. */
6564 f_sleep(0.5);
6565 RSL1.clear;
6566 RSL2.clear;
6567 log("f_probe_for_handover(" & log_label & "): done (got RSL Handover Command)");
6568 break;
6569 } else {
6570 repeat;
6571 }
6572 }
6573 [] BSSAP.receive(tr_BSSMAP_HandoverRequired) {
6574 if (expect_handover and is_inter_bsc_handover) {
6575 setverdict(pass);
6576 log("f_probe_for_handover(" & log_label & "): Got BSSMAP Handover Required as expected.");
6577 } else {
6578 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected none, but got BSSMAP Handover Required. "
6579 & log_label & ": " & log_descr);
6580 }
6581
6582 log("f_probe_for_handover(" & log_label & "): done (got BSSMAP Handover Required)");
6583
6584 /* Note: f_tc_ho_neighbor_config_start() sets T7, the timeout for BSSMAP Handover Required, to
6585 * 1 second. There is no legal way to quickly abort a handover after a BSSMAP Handover Required,
6586 * setting a short timeout and waiting is the only way. */
6587 log("f_probe_for_handover(" & log_label & "): waiting for inter-BSC HO to time out...");
6588 f_sleep(1.5);
6589 log("f_probe_for_handover(" & log_label & "): ...done");
6590
6591 break;
6592 }
6593 [] T.timeout {
6594 if (expect_handover) {
6595 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected Handover, but got none. "
6596 & log_label & ": " & log_descr);
6597 } else {
6598 setverdict(pass);
6599 log("f_probe_for_handover(" & log_label & "): Got no Handover, as expected.");
6600 }
6601 log("f_probe_for_handover(" & log_label & "): done (got no Handover)");
6602 break;
6603 }
6604 }
6605
6606 f_rslem_resume(RSL1_PROC);
6607 f_rslem_resume(RSL2_PROC);
6608 f_sleep(3.0);
6609 RSL.clear;
6610
6611 log("f_probe_for_handover(" & log_label & "): done clearing");
6612}
6613
6614/* Test the effect of various neighbor configuration scenarios:
6615 *
6616 * To avoid complexity, block off any actual handover operation, and always remain on the lchan at bts 0.
6617 * Reconfigure the neighbors for bts 0, trigger a Handover, and probe whether osmo-bsc does or doesn't start HO.
6618 */
6619private function f_tc_ho_neighbor_config_start() runs on MSC_ConnHdlr {
6620 g_pars := f_gen_test_hdlr_pars();
6621 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
6622 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Neels Hofmeyr91401012019-07-11 00:42:35 +02006623
6624 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
6625 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
6626
6627 /* Establish lchan at bts 0 */
6628 f_establish_fully(ass_cmd, exp_compl);
6629
6630 /* Shorten the inter-BSC Handover timeout, to not wait so long for inter-BSC Handovers */
6631 f_vty_enter_cfg_network(BSCVTY);
6632 f_vty_transceive(BSCVTY, "timer T7 1");
6633 f_vty_transceive(BSCVTY, "end");
6634}
6635
6636private function f_tc_ho_neighbor_config_1(charstring id) runs on MSC_ConnHdlr {
6637 f_tc_ho_neighbor_config_start();
6638
6639 /*
6640 * bts 0 ARFCN 871 BSIC 10
6641 * bts 1 ARFCN 871 BSIC 11
6642 * bts 2 ARFCN 871 BSIC 12
6643 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
6644 */
6645
6646 log("f_tc_ho_neighbor_config: 1. No 'neighbor' config");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02006647 f_bts_0_cfg(BSCVTY, {"no neighbors"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02006648 f_probe_for_handover("1.a", "HO to bts 1 works, implicitly listed as neighbor (legacy behavior when none are configured)",
6649 "handover any to arfcn 871 bsic 11",
Neels Hofmeyr6a955cc2021-10-02 14:53:48 +02006650 true, expect_target_tsc := BTS_TSC[1]);
Neels Hofmeyr91401012019-07-11 00:42:35 +02006651
6652 f_probe_for_handover("1.b", "HO to unknown cell does not start",
6653 "handover any to arfcn 13 bsic 39",
6654 false);
6655
6656 f_probe_for_handover("1.c", "HO to 871-12 is ambiguous = error",
6657 "handover any to arfcn 871 bsic 12",
6658 false);
6659
6660 f_probe_for_handover("1.d", "HO to 871-11 still works (verify that this test properly cleans up)",
6661 "handover any to arfcn 871 bsic 11",
Neels Hofmeyr6a955cc2021-10-02 14:53:48 +02006662 true, expect_target_tsc := BTS_TSC[1]);
Neels Hofmeyr91401012019-07-11 00:42:35 +02006663}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006664testcase TC_ho_neighbor_config_1() runs on test_CT {
6665 var MSC_ConnHdlr vc_conn;
6666 f_init(3, true, guard_timeout := 60.0);
6667 f_sleep(1.0);
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01006668 f_ctrs_bsc_and_bts_handover_init();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006669 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_1));
6670 vc_conn.done;
6671
6672 /* f_tc_ho_neighbor_config_start() */
6673 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
6674 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
6675
6676 /* 1.a */
6677 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
6678 * handover quickly by sending a Handover Failure message. */
6679 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6680 f_ctrs_bsc_and_bts_add(0, "handover:failed");
6681 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
6682 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01006683 f_ctrs_bts_add(1, "incoming_intra_bsc_ho:attempted");
6684 f_ctrs_bts_add(1, "incoming_intra_bsc_ho:failed");
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006685
6686 /* 1.b */
6687 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6688 f_ctrs_bsc_and_bts_add(0, "handover:error");
6689
6690 /* 1.c */
6691 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6692 f_ctrs_bsc_and_bts_add(0, "handover:error");
6693
6694 /* 1.d */
6695 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6696 f_ctrs_bsc_and_bts_add(0, "handover:failed");
6697 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
6698 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01006699 f_ctrs_bts_add(1, "incoming_intra_bsc_ho:attempted");
6700 f_ctrs_bts_add(1, "incoming_intra_bsc_ho:failed");
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006701
6702 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006703 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006704}
6705
Neels Hofmeyr91401012019-07-11 00:42:35 +02006706private function f_tc_ho_neighbor_config_2(charstring id) runs on MSC_ConnHdlr {
6707 f_tc_ho_neighbor_config_start();
6708
6709 /*
6710 * bts 0 ARFCN 871 BSIC 10
6711 * bts 1 ARFCN 871 BSIC 11
6712 * bts 2 ARFCN 871 BSIC 12
6713 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
6714 */
6715
6716 log("f_tc_ho_neighbor_config: 2. explicit local neighbor: 'neighbor bts 1'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02006717 f_bts_0_cfg(BSCVTY, {"neighbor bts 1"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02006718 f_sleep(0.5);
6719
6720 f_probe_for_handover("2.a", "HO to bts 1 works, explicitly listed as neighbor",
6721 "handover any to arfcn 871 bsic 11",
Neels Hofmeyr6a955cc2021-10-02 14:53:48 +02006722 true, expect_target_tsc := BTS_TSC[1]);
Neels Hofmeyr91401012019-07-11 00:42:35 +02006723
6724 f_probe_for_handover("2.b", "HO to bts 2 doesn't work, not listed as neighbor",
6725 "handover any to arfcn 871 bsic 12",
6726 false);
6727}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006728testcase TC_ho_neighbor_config_2() runs on test_CT {
6729 var MSC_ConnHdlr vc_conn;
6730 f_init(3, true, guard_timeout := 50.0);
6731 f_sleep(1.0);
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01006732 f_ctrs_bsc_and_bts_handover_init();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006733 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_2));
6734 vc_conn.done;
6735
6736 /* f_tc_ho_neighbor_config_start() */
6737 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
6738 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
6739
6740 /* 2.a */
6741 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
6742 * handover quickly by sending a Handover Failure message. */
6743 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6744 f_ctrs_bsc_and_bts_add(0, "handover:failed");
6745 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
6746 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01006747 f_ctrs_bts_add(1, "incoming_intra_bsc_ho:attempted");
6748 f_ctrs_bts_add(1, "incoming_intra_bsc_ho:failed");
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006749
6750 /* 2.b */
6751 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6752 f_ctrs_bsc_and_bts_add(0, "handover:error");
6753
6754 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006755 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006756}
6757
Neels Hofmeyr91401012019-07-11 00:42:35 +02006758private function f_tc_ho_neighbor_config_3(charstring id) runs on MSC_ConnHdlr {
6759 f_tc_ho_neighbor_config_start();
6760
6761 /*
6762 * bts 0 ARFCN 871 BSIC 10
6763 * bts 1 ARFCN 871 BSIC 11
6764 * bts 2 ARFCN 871 BSIC 12
6765 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
6766 */
6767
6768 log("f_tc_ho_neighbor_config: 3. explicit local neighbor: 'neighbor bts 2'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02006769 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor bts 2"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02006770 f_sleep(0.5);
6771
6772 f_probe_for_handover("3.a", "HO to bts 1 doesn't work, not listed as neighbor",
6773 "handover any to arfcn 871 bsic 11",
6774 false);
6775 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",
6776 "handover any to arfcn 871 bsic 12",
Neels Hofmeyr6a955cc2021-10-02 14:53:48 +02006777 true, expect_target_tsc := BTS_TSC[2]);
Neels Hofmeyr91401012019-07-11 00:42:35 +02006778}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006779testcase TC_ho_neighbor_config_3() runs on test_CT {
6780 var MSC_ConnHdlr vc_conn;
6781 f_init(3, true, guard_timeout := 50.0);
6782 f_sleep(1.0);
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01006783 f_ctrs_bsc_and_bts_handover_init();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006784 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_3));
6785 vc_conn.done;
6786
6787 /* f_tc_ho_neighbor_config_start() */
6788 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
6789 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
6790
6791 /* 3.a */
6792 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6793 f_ctrs_bsc_and_bts_add(0, "handover:error");
6794
6795 /* 3.b */
6796 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
6797 * handover quickly by sending a Handover Failure message. */
6798 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6799 f_ctrs_bsc_and_bts_add(0, "handover:failed");
6800 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
6801 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01006802 f_ctrs_bts_add(2, "incoming_intra_bsc_ho:attempted");
6803 f_ctrs_bts_add(2, "incoming_intra_bsc_ho:failed");
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006804
6805 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006806 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006807}
6808
Neels Hofmeyr91401012019-07-11 00:42:35 +02006809private function f_tc_ho_neighbor_config_4(charstring id) runs on MSC_ConnHdlr {
6810 f_tc_ho_neighbor_config_start();
6811
6812 /*
6813 * bts 0 ARFCN 871 BSIC 10
6814 * bts 1 ARFCN 871 BSIC 11
6815 * bts 2 ARFCN 871 BSIC 12
6816 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
6817 */
6818
6819 log("f_tc_ho_neighbor_config: 4. explicit remote neighbor: 'neighbor lac 99 arfcn 123 bsic 45'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02006820 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor lac 99 arfcn 123 bsic 45"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02006821 f_sleep(0.5);
6822
6823 f_probe_for_handover("4.a", "HO to bts 1 doesn't work, not listed as neighbor",
6824 "handover any to arfcn 871 bsic 11",
6825 false);
6826 f_probe_for_handover("4.b", "HO to bts 2 doesn't work, not listed as neighbor",
6827 "handover any to arfcn 871 bsic 12",
6828 false);
6829 f_probe_for_handover("4.c", "HO to 123-45 triggers inter-BSC HO",
6830 "handover any to arfcn 123 bsic 45",
6831 true, true);
6832}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006833testcase TC_ho_neighbor_config_4() runs on test_CT {
6834 var MSC_ConnHdlr vc_conn;
6835 f_init(3, true, guard_timeout := 50.0);
6836 f_sleep(1.0);
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01006837 f_ctrs_bsc_and_bts_handover_init();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006838 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_4));
6839 vc_conn.done;
6840
6841 /* f_tc_ho_neighbor_config_start() */
6842 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
6843 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
6844
6845 /* 4.a */
6846 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6847 f_ctrs_bsc_and_bts_add(0, "handover:error");
6848
6849 /* 4.b */
6850 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6851 f_ctrs_bsc_and_bts_add(0, "handover:error");
6852
6853 /* 4.c */
6854 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
6855 * handover quickly by timing out after the Handover Required message */
6856 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6857 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
6858 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
6859 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
6860
6861 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006862 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006863}
6864
Neels Hofmeyr91401012019-07-11 00:42:35 +02006865private function f_tc_ho_neighbor_config_5(charstring id) runs on MSC_ConnHdlr {
6866 f_tc_ho_neighbor_config_start();
6867
6868 /*
6869 * bts 0 ARFCN 871 BSIC 10
6870 * bts 1 ARFCN 871 BSIC 11
6871 * bts 2 ARFCN 871 BSIC 12
6872 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
6873 */
6874
6875 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 +02006876 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor lac 99 arfcn 871 bsic 12"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02006877 f_sleep(0.5);
6878
6879 f_probe_for_handover("5.a", "HO to 871-12 triggers inter-BSC HO (ignoring local cells with same ARFCN+BSIC)",
6880 "handover any to arfcn 871 bsic 12",
6881 true, true);
6882}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006883testcase TC_ho_neighbor_config_5() runs on test_CT {
6884 var MSC_ConnHdlr vc_conn;
6885 f_init(3, true);
6886 f_sleep(1.0);
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01006887 f_ctrs_bsc_and_bts_handover_init();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006888 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_5));
6889 vc_conn.done;
6890
6891 /* f_tc_ho_neighbor_config_start() */
6892 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
6893 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
6894
6895 /* 5 */
6896 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
6897 * handover quickly by timing out after the Handover Required message */
6898 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6899 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
6900 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
6901 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
6902
6903 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006904 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006905}
6906
Neels Hofmeyr91401012019-07-11 00:42:35 +02006907private function f_tc_ho_neighbor_config_6(charstring id) runs on MSC_ConnHdlr {
6908 f_tc_ho_neighbor_config_start();
6909
6910 /*
6911 * bts 0 ARFCN 871 BSIC 10
6912 * bts 1 ARFCN 871 BSIC 11
6913 * bts 2 ARFCN 871 BSIC 12
6914 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
6915 */
6916
6917 log("f_tc_ho_neighbor_config: 6. config error: explicit local and remote neighbors with ambiguous ARFCN+BSIC:"
6918 & " 'neighbor bts 2; neighbor lac 99 arfcn 871 bsic 12'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02006919 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor bts 2", "neighbor lac 99 arfcn 871 bsic 12"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02006920 f_sleep(0.5);
6921
6922 f_probe_for_handover("6.a", "HO to 871-12 is ambiguous = error",
6923 "handover any to arfcn 871 bsic 12",
6924 false);
6925}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006926testcase TC_ho_neighbor_config_6() runs on test_CT {
6927 var MSC_ConnHdlr vc_conn;
6928 f_init(3, true);
6929 f_sleep(1.0);
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01006930 f_ctrs_bsc_and_bts_handover_init();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006931 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_6));
6932 vc_conn.done;
6933
6934 /* f_tc_ho_neighbor_config_start() */
6935 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
6936 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
6937
6938 /* 6.a */
6939 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
6940 * handover quickly by timing out after the Handover Required message */
6941 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6942 f_ctrs_bsc_and_bts_add(0, "handover:error");
6943
6944 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006945 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006946}
6947
Neels Hofmeyr91401012019-07-11 00:42:35 +02006948private function f_tc_ho_neighbor_config_7(charstring id) runs on MSC_ConnHdlr {
6949 f_tc_ho_neighbor_config_start();
6950
6951 /*
6952 * bts 0 ARFCN 871 BSIC 10
6953 * bts 1 ARFCN 871 BSIC 11
6954 * bts 2 ARFCN 871 BSIC 12
6955 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
6956 */
6957
6958 log("f_tc_ho_neighbor_config: 7. explicit local and remote neighbors:"
6959 & " 'neighbor bts 2; neighbor lac 99 arfcn 123 bsic 45'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02006960 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor bts 2", "neighbor lac 99 arfcn 123 bsic 45"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02006961 f_sleep(0.5);
6962
6963 f_probe_for_handover("7.a", "HO to 871-12 does HO to bts 2",
6964 "handover any to arfcn 871 bsic 12",
Neels Hofmeyr6a955cc2021-10-02 14:53:48 +02006965 true, expect_target_tsc := BTS_TSC[2]);
Neels Hofmeyr91401012019-07-11 00:42:35 +02006966 f_probe_for_handover("7.b", "HO to 123-45 triggers inter-BSC HO",
6967 "handover any to arfcn 123 bsic 45",
6968 true, true);
6969}
Neels Hofmeyr91401012019-07-11 00:42:35 +02006970testcase TC_ho_neighbor_config_7() runs on test_CT {
6971 var MSC_ConnHdlr vc_conn;
Neels Hofmeyrf2b88032020-06-16 00:35:04 +02006972 f_init(3, true, guard_timeout := 50.0);
Neels Hofmeyr91401012019-07-11 00:42:35 +02006973 f_sleep(1.0);
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01006974 f_ctrs_bsc_and_bts_handover_init();
Neels Hofmeyr91401012019-07-11 00:42:35 +02006975 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_7));
6976 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006977
6978 /* f_tc_ho_neighbor_config_start() */
6979 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
6980 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
6981
6982 /* 7.a */
6983 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
6984 * handover quickly by sending a Handover Failure message. */
6985 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6986 f_ctrs_bsc_and_bts_add(0, "handover:failed");
6987 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
6988 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01006989 f_ctrs_bts_add(2, "incoming_intra_bsc_ho:attempted");
6990 f_ctrs_bts_add(2, "incoming_intra_bsc_ho:failed");
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006991
6992 /* 7.b */
6993 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
6994 * handover quickly by timing out after the Handover Required message */
6995 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6996 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
6997 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
6998 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
6999
7000 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007001 f_shutdown_helper();
Neels Hofmeyr91401012019-07-11 00:42:35 +02007002}
7003
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01007004/* OS#3041: Open and close N connections in a normal fashion, and expect no
7005 * BSSMAP Reset just because of that. */
7006testcase TC_bssap_rlsd_does_not_cause_bssmap_reset() runs on test_CT {
7007 var default d;
7008 var integer i;
7009 var DchanTuple dt;
7010
7011 f_init();
7012
7013 /* Wait for initial BSSMAP Reset to pass */
7014 f_sleep(4.0);
7015
7016 d := activate(no_bssmap_reset());
7017
7018 /* Setup up a number of connections and RLSD them again from the MSC
7019 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
7020 * Let's do it some more times for good measure. */
Harald Weltec3260d92018-06-11 17:48:16 +02007021 for (i := 0; i < 4; i := i+1) {
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01007022 /* Since we're doing a lot of runs, give each one a fresh
7023 * T_guard from the top. */
7024 T_guard.start;
7025
7026 /* Setup a BSSAP connection and clear it right away. This is
7027 * the MSC telling the BSC about a planned release, it's not an
7028 * erratic loss of a connection. */
Harald Weltea1897182018-06-11 13:53:09 +02007029 dt := f_est_dchan(int2oct(i,1), 23+i, '00010203040506'O);
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01007030
7031 /* MSC disconnects (RLSD). */
7032 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
7033 }
7034
7035 /* In the buggy behavior, a timeout of 2 seconds happens between above
7036 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
7037 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
7038 f_sleep(4.0);
7039
7040 deactivate(d);
7041 f_shutdown_helper();
7042}
Harald Welte552620d2017-12-16 23:21:36 +01007043
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01007044/* OS#3041: Open and close N connections in a normal fashion, and expect no
7045 * BSSMAP Reset just because of that. Invoke the release by a BSSMAP Clear from
7046 * the MSC. */
7047testcase TC_bssmap_clear_does_not_cause_bssmap_reset() runs on test_CT {
7048 var default d;
7049 var integer i;
7050 var DchanTuple dt;
7051 var BSSAP_N_DATA_ind rx_di;
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01007052 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_CALL_CONTROL;
7053 var BssmapCause cause := enum2int(cause_val);
7054
7055 f_init();
7056
7057 /* Wait for initial BSSMAP Reset to pass */
7058 f_sleep(4.0);
7059
7060 d := activate(no_bssmap_reset());
7061
7062 /* Setup up a number of connections and RLSD them again from the MSC
7063 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
7064 * Let's do it some more times for good measure. */
7065 for (i := 0; i < 8; i := i+1) {
7066 /* Since we're doing a lot of runs, give each one a fresh
7067 * T_guard from the top. */
7068 T_guard.start;
7069
7070 /* Setup a BSSAP connection and clear it right away. This is
7071 * the MSC telling the BSC about a planned release, it's not an
7072 * erratic loss of a connection. */
Harald Weltea1897182018-06-11 13:53:09 +02007073 dt := f_est_dchan(int2oct(i,1), 23+i, '00010203040506'O);
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01007074
7075 /* Instruct BSC to clear channel */
7076 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
7077
7078 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02007079 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01007080 }
7081
7082 /* In the buggy behavior, a timeout of 2 seconds happens between above
7083 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
7084 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
7085 f_sleep(4.0);
7086
7087 deactivate(d);
7088 f_shutdown_helper();
7089}
7090
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01007091/* OS#3041: Open and close N connections in a normal fashion, and expect no
7092 * BSSMAP Reset just because of that. Close connections from the MS side with a
7093 * Release Ind on RSL. */
7094testcase TC_ms_rel_ind_does_not_cause_bssmap_reset() runs on test_CT {
7095 var default d;
7096 var integer i;
7097 var DchanTuple dt;
7098 var BSSAP_N_DATA_ind rx_di;
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01007099 var integer j;
7100
7101 f_init();
7102
7103 /* Wait for initial BSSMAP Reset to pass */
7104 f_sleep(4.0);
7105
7106 d := activate(no_bssmap_reset());
7107
7108 /* Setup up a number of connections and RLSD them again from the MSC
7109 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
7110 * Let's do it some more times for good measure. */
7111 for (i := 0; i < 8; i := i+1) {
7112 /* Since we're doing a lot of runs, give each one a fresh
7113 * T_guard from the top. */
7114 T_guard.start;
7115
7116 /* Setup a BSSAP connection and clear it right away. This is
7117 * the MSC telling the BSC about a planned release, it's not an
7118 * erratic loss of a connection. */
7119 dt := f_est_dchan('23'O, 23, '00010203040506'O);
7120
7121 /* simulate RLL REL IND */
7122 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0))));
7123
7124 /* expect Clear Request on MSC side */
7125 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
7126
7127 /* Instruct BSC to clear channel */
7128 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
7129 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
7130
7131 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02007132 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01007133 }
7134
7135 /* In the buggy behavior, a timeout of 2 seconds happens between above
7136 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
7137 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
7138 f_sleep(4.0);
7139
7140 deactivate(d);
7141 f_shutdown_helper();
7142}
7143
Harald Welte94e0c342018-04-07 11:33:23 +02007144/***********************************************************************
7145 * IPA style dynamic PDCH
7146 ***********************************************************************/
7147
7148private function f_dyn_ipa_pdch_act(integer bts_nr, integer trx_nr, integer ts_nr,
7149 template (omit) RSL_Cause nack := omit)
7150runs on test_CT {
7151 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(ts_nr));
7152 var RSL_Message rsl_unused;
7153 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
7154 f_vty_ts_action("pdch activate", bts_nr, trx_nr, ts_nr);
7155 /* expect the BSC to issue the related RSL command */
7156 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
7157 if (istemplatekind(nack, "omit")) {
7158 /* respond with a related acknowledgement */
7159 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
7160 } else {
7161 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_NACK(chan_nr, valueof(nack)));
7162 }
7163}
7164
7165private function f_dyn_ipa_pdch_deact(integer bts_nr, integer trx_nr, integer ts_nr,
7166 template (omit) RSL_Cause nack := omit)
7167runs on test_CT {
7168 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(ts_nr));
7169 var RSL_Message rsl_unused;
7170 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
7171 f_vty_ts_action("pdch deactivate", bts_nr, trx_nr, ts_nr);
7172 /* expect the BSC to issue the related RSL command */
7173 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_DEACT(chan_nr));
7174 if (istemplatekind(nack, "omit")) {
7175 /* respond with a related acknowledgement */
7176 f_ipa_tx(0, ts_RSL_IPA_PDCH_DEACT_ACK(chan_nr));
7177 } else {
7178 f_ipa_tx(0, ts_RSL_IPA_PDCH_DEACT_NACK(chan_nr, valueof(nack)));
7179 }
7180}
7181
7182private function f_ts_dyn_mode_get(integer bts_nr, integer trx_nr, integer ts_nr)
7183runs on test_CT return charstring {
7184 var charstring cmd, resp;
7185 cmd := "show timeslot "&int2str(bts_nr)&" "&int2str(trx_nr)&" "&int2str(ts_nr);
Stefan Sperlingcff13562018-11-13 15:24:06 +01007186 return f_vty_transceive_match_regexp_retry(BSCVTY, cmd, "*\((*)\)*", 0, 4, 1.0);
Harald Welte94e0c342018-04-07 11:33:23 +02007187}
7188
7189private function f_ts_dyn_mode_assert(integer bts_nr, integer trx_nr, integer ts_nr,
7190 template charstring exp)
7191runs on test_CT {
7192 var charstring mode := f_ts_dyn_mode_get(bts_nr, trx_nr, ts_nr);
7193 if (not match(mode, exp)) {
7194 setverdict(fail, "Unexpected TS Mode: ", mode);
Daniel Willmannafce8662018-07-06 23:11:32 +02007195 mtc.stop;
Harald Welte94e0c342018-04-07 11:33:23 +02007196 }
7197}
7198
7199private function f_ts_set_chcomb(integer bts_nr, integer trx_nr, integer ts_nr, charstring chcomb)
7200runs on test_CT {
7201 f_vty_enter_cfg_ts(BSCVTY, bts_nr, trx_nr, ts_nr);
7202 f_vty_transceive(BSCVTY, "phys_chan_config " & chcomb);
7203 f_vty_transceive(BSCVTY, "end");
7204}
7205
Pau Espin Pedrol0953bf82021-07-09 13:20:19 +02007206
7207private function f_ts_reset_chcomb(integer bts_nr) runs on test_CT {
7208 var integer i;
7209 for (i := 0; i < 8; i := i + 1) {
7210 f_ts_set_chcomb(bts_nr, 0, i, phys_chan_config[i]);
7211 }
7212}
7213
Harald Welte94e0c342018-04-07 11:33:23 +02007214private const charstring TCHF_MODE := "TCH/F mode";
7215private const charstring TCHH_MODE := "TCH/H mode";
7216private const charstring PDCH_MODE := "PDCH mode";
7217private const charstring NONE_MODE := "NONE mode";
Pau Espin Pedrol5b381082021-06-28 17:14:03 +02007218private const charstring SDCCH8_MODE := "SDCCH8 mode";
Harald Welte94e0c342018-04-07 11:33:23 +02007219
7220/* Test IPA PDCH activation / deactivation triggered by VTY */
7221testcase TC_dyn_pdch_ipa_act_deact() runs on test_CT {
7222 var RSL_Message rsl_unused;
7223
7224 /* change Timeslot 6 before f_init() starts RSL */
7225 f_init_vty();
7226 f_ts_set_chcomb(0, 0, 6, "TCH/F_PDCH");
7227 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7228
7229 f_init(1, false);
7230 f_sleep(1.0);
7231
7232 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
7233
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02007234 log("TCH/F_PDCH pchan starts out in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02007235 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
7236 /* The BSC will activate the dynamic PDCH by default, so confirm that */
7237 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
7238 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
7239 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02007240 log("TCH/F_PDCH pchan, PDCH ACT was ACKed, so now in PDCH mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02007241 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
7242
7243 /* De-activate it via VTY */
7244 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
7245 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02007246 log("TCH/F_PDCH pchan, PDCH DEACT via VTY, so now back in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02007247 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
7248
7249 /* re-activate it via VTY */
7250 f_dyn_ipa_pdch_act(0, 0, chan_nr.tn);
7251 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02007252 log("TCH/F_PDCH pchan, PDCH ACT via VTY, so now in PDCH mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02007253 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
7254
7255 /* and finally de-activate it again */
7256 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
7257 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02007258 log("TCH/F_PDCH pchan, PDCH DEACT via VTY, so now back in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02007259 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
7260
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02007261 /* clean up config */
7262 f_ts_set_chcomb(0, 0, 6, "PDCH");
7263
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007264 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02007265}
7266
7267/* Test IPA PDCH activation NACK */
7268testcase TC_dyn_pdch_ipa_act_nack() runs on test_CT {
7269 var RSL_Message rsl_unused;
7270
7271 /* change Timeslot 6 before f_init() starts RSL */
7272 f_init_vty();
7273 f_ts_set_chcomb(0, 0, 6, "TCH/F_PDCH");
7274 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7275
7276 f_init(1, false);
7277 f_sleep(1.0);
7278
7279 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
7280
7281 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
7282 /* The BSC will activate the dynamic PDCH by default, so confirm that */
7283 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
7284 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
7285 f_sleep(1.0);
7286 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
7287
7288 /* De-activate it via VTY */
7289 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
7290 f_sleep(1.0);
7291 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
7292
7293 /* re-activate it via VTY, but fail that; check BSC still assumes TCH/F mode */
7294 f_dyn_ipa_pdch_act(0, 0, chan_nr.tn, RSL_ERR_EQUIPMENT_FAIL);
7295 f_sleep(1.0);
7296 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
7297
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02007298 /* clean up config */
7299 f_ts_set_chcomb(0, 0, 6, "PDCH");
7300
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007301 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02007302}
7303
7304
7305/***********************************************************************
7306 * Osmocom style dynamic PDCH
7307 ***********************************************************************/
7308
7309private function f_dyn_osmo_pdch_act(integer bts_nr, integer trx_nr, integer ts_nr,
7310 template (omit) RSL_Cause nack := omit)
7311runs on test_CT {
7312 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(ts_nr));
7313 var RSL_Message rsl_unused;
Pau Espin Pedrol64adf372021-06-28 16:25:47 +02007314 /* ask BSC via VTY to activate a given OSMO style chan as PDCH */
Harald Welte94e0c342018-04-07 11:33:23 +02007315 /* FIXME: no VTY command to activate Osmocom PDCH !! */
7316 /* expect the BSC to issue the related RSL command */
7317 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT(chan_nr, ?));
7318 if (istemplatekind(nack, "omit")) {
7319 /* respond with a related acknowledgement */
7320 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342));
7321 } else {
7322 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, valueof(nack)));
7323 }
7324}
7325
7326private function f_dyn_osmo_pdch_deact(integer bts_nr, integer trx_nr, integer ts_nr,
7327 template (omit) RSL_Cause nack := omit)
7328runs on test_CT {
7329 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(ts_nr));
7330 var RSL_Message rsl_unused;
Pau Espin Pedrol64adf372021-06-28 16:25:47 +02007331 /* ask BSC via VTY to activate a given OSMO style chan as PDCH */
Harald Welte94e0c342018-04-07 11:33:23 +02007332 /* FIXME: no VTY command to activate Osmocom PDCH !! */
7333 /* expect the BSC to issue the related RSL command */
7334 rsl_unused := f_exp_ipa_rx(0, tr_RSL_RF_CHAN_REL(chan_nr));
7335 if (istemplatekind(nack, "omit")) {
7336 /* respond with a related acknowledgement */
7337 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(chan_nr));
7338 } else {
7339 //f_ipa_tx(0, ts_RSL_RF_CHAN_REL_NACK(chan_nr, valueof(nack)));
7340 }
7341}
7342
7343/* Test Osmocom dyn PDCH activation / deactivation triggered by VTY */
7344testcase TC_dyn_pdch_osmo_act_deact() runs on test_CT {
7345 var RSL_Message rsl_unused;
7346
7347 /* change Timeslot 6 before f_init() starts RSL */
7348 f_init_vty();
7349 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_PDCH");
7350 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7351
7352 f_init(1, false);
7353 f_sleep(1.0);
7354
7355 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(6));
7356
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02007357 log("TCH/F_TCH/H_PDCH pchan starts out in disabled mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02007358 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
7359 /* The BSC will activate the dynamic PDCH by default, so confirm that */
7360 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
7361
7362 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342));
7363 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02007364 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 +02007365 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
7366
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02007367 /* clean up config */
7368 f_ts_set_chcomb(0, 0, 6, "PDCH");
7369
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007370 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02007371}
7372
7373/* Test Osmocom dyn PDCH activation NACK behavior */
7374testcase TC_dyn_pdch_osmo_act_nack() runs on test_CT {
7375 var RSL_Message rsl_unused;
7376
7377 /* change Timeslot 6 before f_init() starts RSL */
7378 f_init_vty();
7379 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_PDCH");
7380 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7381
7382 f_init(1, false);
7383 f_sleep(1.0);
7384
7385 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(6));
7386
7387 f_ts_dyn_mode_assert(0, 0, 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(chan_nr, ?));
7390
7391 /* NACK this activation and expect the "show timeslot" mode still to be NONE */
7392 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, RSL_ERR_EQUIPMENT_FAIL));
7393 f_sleep(1.0);
7394 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
7395
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02007396 /* clean up config */
7397 f_ts_set_chcomb(0, 0, 6, "PDCH");
7398
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007399 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02007400}
7401
Pau Espin Pedrol5b381082021-06-28 17:14:03 +02007402/* Test Osmocom dyn TS SDCCH8 activation / deactivation */
7403testcase TC_dyn_ts_sdcch8_act_deact() runs on test_CT {
7404 var RSL_Message rsl_unused, rsl_msg;
7405 var DchanTuple dt;
7406 var BSSAP_N_CONNECT_ind rx_c_ind;
7407
7408 /* change Timeslot 6 before f_init() starts RSL */
7409 f_init_vty();
7410 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_SDCCH8_PDCH");
7411 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7412
7413 f_init(1, false);
7414 f_sleep(1.0);
7415
7416 var RslChannelNr pdch_chan_nr := valueof(t_RslChanNr_PDCH(6));
7417
7418 log("TCH/F_TCH/H_SDCCH8_PDCH pchan starts out in disabled mode:");
7419 f_ts_dyn_mode_assert(0, 0, pdch_chan_nr.tn, NONE_MODE);
7420 /* The BSC will activate the dynamic PDCH by default, so confirm that */
7421 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(pdch_chan_nr, ?));
7422
7423 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(pdch_chan_nr, 2342));
7424 f_sleep(1.0);
7425 log("TCH/F_TCH/H_SDCCH8_PDC requested to PDCH ACT on startup, which was ACKed, so now in PDCH:");
7426 f_ts_dyn_mode_assert(0, 0, pdch_chan_nr.tn, PDCH_MODE);
7427
7428 /* Fill TS0 SDCCH channels (NOTE: only 3 SDCCH/4 channels are available
7429 * on CCCH+SDCCH4+CBCH) */
7430 var integer i;
Pau Espin Pedrolce4d5bb2021-10-25 13:31:25 +02007431 for (i := 0; i < NUM_SDCCH_PER_BTS; i := i + 1) {
Pau Espin Pedrol5b381082021-06-28 17:14:03 +02007432 dt := f_est_dchan('23'O, i, '00010203040506'O);
7433 }
7434
7435 /* Now the dyn ts is selected. First PDCH is released, then sdcch chan is activated */
7436 f_ipa_tx(0, ts_RSL_CHAN_RQD(int2oct(oct2int('23'O) + i, 1), 2342));
7437 rsl_unused := f_exp_ipa_rx(0, tr_RSL_RF_CHAN_REL(pdch_chan_nr));
7438 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(pdch_chan_nr));
7439
7440 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7441 dt.rsl_chan_nr := rsl_msg.ies[0].body.chan_nr;
7442
7443 f_ts_dyn_mode_assert(0, 0, dt.rsl_chan_nr.tn, SDCCH8_MODE);
7444 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(dt.rsl_chan_nr, 2342));
7445 rsl_msg := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
7446 f_ts_dyn_mode_assert(0, 0, dt.rsl_chan_nr.tn, SDCCH8_MODE);
7447
7448 f_ipa_tx(0, ts_RSL_EST_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)), '1234'O));
7449 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3('1234'O))) -> value rx_c_ind;
7450 dt.sccp_conn_id := rx_c_ind.connectionId;
7451 BSSAP.send(ts_BSSAP_CONNECT_res(dt.sccp_conn_id));
7452
7453 /* Instruct BSC to clear channel */
7454 var BssmapCause cause := 0;
7455 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
7456 f_exp_chan_rel_and_clear(dt, 0);
7457
7458 /* The BSC will switch the TS back to PDCH once the only lchan using it is released: */
7459 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(pdch_chan_nr, ?));
7460 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(pdch_chan_nr, 2342));
7461 f_sleep(1.0);
7462 f_ts_dyn_mode_assert(0, 0, pdch_chan_nr.tn, PDCH_MODE);
7463
7464 /* clean up config */
7465 f_ts_set_chcomb(0, 0, 6, "PDCH");
7466
7467 f_shutdown_helper();
7468}
7469
Neels Hofmeyre1a7c4d2021-10-23 23:13:01 +02007470/* Validate all 8 subslots of a dynamics TS configured as SDCCH8 are used */
7471testcase TC_dyn_ts_sdcch8_all_subslots_used() runs on test_CT {
7472 var ASP_RSL_Unitdata rsl_ud;
7473 var integer i;
7474 var integer chreq_total, chreq_nochan;
7475
7476 f_init_vty();
7477 for (i := 1; i < 8; i := i + 1) {
7478 if (i == 2) {
7479 f_ts_set_chcomb(0, 0, i, "TCH/F_TCH/H_SDCCH8_PDCH");
7480 } else {
7481 f_ts_set_chcomb(0, 0, i, "PDCH");
7482 }
7483 }
7484 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7485
7486 f_init(1);
7487
7488 /* The dyn TS want to activate PDCH mode, ACK that. */
7489 var RslChannelNr chan_nr;
7490 chan_nr := valueof(t_RslChanNr_PDCH(2));
7491 f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
7492 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342));
7493
7494 f_sleep(1.0);
7495
7496 /* Exhaust all dedicated SDCCH lchans.
7497 /* GSM 44.018 Table 9.1.8.2:
7498 * RA = '13'O -> Establishment cause = 0001xxxx (MS dual rate capable and asks for "SDCCH").
7499 */
7500 for (i := 0; i < NUM_SDCCH_PER_BTS; i := i+1) {
7501 f_est_dchan('13'O, NUM_SDCCH_PER_BTS + i, '00010203040506'O);
7502 }
7503
7504 /* Only the dyn TS is still available. Its first lchan gets converted to SDCCH8 */
7505 f_est_dchan_dyn('33'O, NUM_SDCCH_PER_BTS + i, '00010203040506'O);
7506 /* Also occupy the seven other SDCCH of the dyn TS */
7507 for (i := 0; i < 7; i := i+1) {
7508 f_est_dchan('33'O, NUM_SDCCH_PER_BTS + i, '00010203040506'O);
7509 }
7510
7511 /* clean up config */
7512 f_ts_reset_chcomb(0);
7513
7514 f_shutdown_helper();
7515}
7516
Pau Espin Pedrol0953bf82021-07-09 13:20:19 +02007517/* Test Osmocom dyn TS SDCCH8 activation / deactivation: If activating dyn TS as
7518 SDCCH8 would end up in having no free TCH, then BSC should decide to activate
7519 it as TCH directly instead. SYS#5309. */
7520testcase TC_dyn_ts_sdcch8_tch_call_act_deact() runs on test_CT {
7521 var RSL_Message rsl_unused, rsl_msg;
7522 var DchanTuple dt;
7523 var BSSAP_N_CONNECT_ind rx_c_ind;
7524 var integer i;
7525
7526 /* change Timeslot 6 before f_init() starts RSL */
7527 f_init_vty();
7528 for (i := 1; i < 8; i := i + 1) {
7529 if (i == 6) {
7530 f_ts_set_chcomb(0, 0, i, "TCH/F_TCH/H_SDCCH8_PDCH");
7531 } else {
7532 f_ts_set_chcomb(0, 0, i, "PDCH");
7533 }
7534 }
7535 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7536
7537 f_init(1, false);
7538 f_sleep(1.0);
7539
7540 var RslChannelNr pdch_chan_nr := valueof(t_RslChanNr_PDCH(6));
7541
7542 log("TCH/F_TCH/H_SDCCH8_PDCH pchan starts out in disabled mode:");
7543 f_ts_dyn_mode_assert(0, 0, pdch_chan_nr.tn, NONE_MODE);
7544 /* The BSC will activate the dynamic PDCH by default, so confirm that */
7545 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(pdch_chan_nr, ?));
7546
7547 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(pdch_chan_nr, 2342));
7548 f_sleep(1.0);
7549 log("TCH/F_TCH/H_SDCCH8_PDC requested to PDCH ACT on startup, which was ACKed, so now in PDCH:");
7550 f_ts_dyn_mode_assert(0, 0, pdch_chan_nr.tn, PDCH_MODE);
7551
7552 /* Fill TS0 SDCCH channels (NOTE: only 3 SDCCH/4 channels are available
7553 * on CCCH+SDCCH4+CBCH) */
Pau Espin Pedrol2ebbe7c2021-07-23 16:17:09 +02007554 var OCT1 ra := '43'O; /* RA containing reason=originating speech call*/
Pau Espin Pedrolce4d5bb2021-10-25 13:31:25 +02007555 for (i := 0; i < NUM_SDCCH_PER_BTS; i := i + 1) {
Pau Espin Pedrol2ebbe7c2021-07-23 16:17:09 +02007556 dt := f_est_dchan(ra, i, '00010203040506'O);
Pau Espin Pedrol0953bf82021-07-09 13:20:19 +02007557 }
7558
7559 /* Now the dyn ts is selected. First PDCH is released, then TCH chan is activated */
Pau Espin Pedrol2ebbe7c2021-07-23 16:17:09 +02007560 f_ipa_tx(0, ts_RSL_CHAN_RQD(int2oct(oct2int(ra) + i, 1), 2342));
Pau Espin Pedrol0953bf82021-07-09 13:20:19 +02007561 rsl_unused := f_exp_ipa_rx(0, tr_RSL_RF_CHAN_REL(pdch_chan_nr));
7562 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(pdch_chan_nr));
7563
7564 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7565 dt.rsl_chan_nr := rsl_msg.ies[0].body.chan_nr;
7566
7567 f_ts_dyn_mode_assert(0, 0, dt.rsl_chan_nr.tn, TCHH_MODE);
7568 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(dt.rsl_chan_nr, 2342));
7569 rsl_msg := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
7570 f_ts_dyn_mode_assert(0, 0, dt.rsl_chan_nr.tn, TCHH_MODE);
7571
7572 f_ipa_tx(0, ts_RSL_EST_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)), '1234'O));
7573 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3('1234'O))) -> value rx_c_ind;
7574 dt.sccp_conn_id := rx_c_ind.connectionId;
7575 BSSAP.send(ts_BSSAP_CONNECT_res(dt.sccp_conn_id));
7576
7577 /* Instruct BSC to clear channel */
7578 var BssmapCause cause := 0;
7579 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
7580 f_exp_chan_rel_and_clear(dt, 0);
7581
7582 /* The BSC will switch the TS back to PDCH once the only lchan using it is released: */
7583 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(pdch_chan_nr, ?));
7584 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(pdch_chan_nr, 2342));
7585 f_sleep(1.0);
7586 f_ts_dyn_mode_assert(0, 0, pdch_chan_nr.tn, PDCH_MODE);
7587
7588 /* clean up config */
7589 f_ts_reset_chcomb(0);
7590 /* TODO: clean up other channels? */
7591
7592 f_shutdown_helper();
7593}
7594
Pau Espin Pedrolcdf26142021-06-28 17:14:03 +02007595/* Test Osmocom dyn TS SDCCH8 activation / deactivation when SDCCH fails at BTS */
7596testcase TC_dyn_ts_sdcch8_act_nack() runs on test_CT {
7597 var RSL_Message rsl_unused, rsl_msg;
7598 var DchanTuple dt;
7599 var BSSAP_N_CONNECT_ind rx_c_ind;
7600 var GsmRrMessage rr;
7601
7602 /* change Timeslot 6 before f_init() starts RSL */
7603 f_init_vty();
7604 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_SDCCH8_PDCH");
7605 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7606
7607 f_init(1, false);
7608 f_sleep(1.0);
7609
7610 var RslChannelNr pdch_chan_nr := valueof(t_RslChanNr_PDCH(6));
7611
7612 log("TCH/F_TCH/H_SDCCH8_PDCH pchan starts out in disabled mode:");
7613 f_ts_dyn_mode_assert(0, 0, pdch_chan_nr.tn, NONE_MODE);
7614 /* The BSC will activate the dynamic PDCH by default, so confirm that */
7615 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(pdch_chan_nr, ?));
7616
7617 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(pdch_chan_nr, 2342));
7618 f_sleep(1.0);
7619 log("TCH/F_TCH/H_SDCCH8_PDC requested to PDCH ACT on startup, which was ACKed, so now in PDCH:");
7620 f_ts_dyn_mode_assert(0, 0, pdch_chan_nr.tn, PDCH_MODE);
7621
7622 /* Fill TS0 SDCCH channels (NOTE: only 3 SDCCH/4 channels are available
7623 * on CCCH+SDCCH4+CBCH) */
7624 var integer i;
Pau Espin Pedrolce4d5bb2021-10-25 13:31:25 +02007625 for (i := 0; i < NUM_SDCCH_PER_BTS; i := i + 1) {
Pau Espin Pedrolcdf26142021-06-28 17:14:03 +02007626 dt := f_est_dchan('23'O, i, '00010203040506'O);
7627 }
7628
7629 /* Now the dyn ts is selected. First PDCH is released, then sdcch chan is activated */
7630 f_ipa_tx(0, ts_RSL_CHAN_RQD(int2oct(oct2int('23'O) + i, 1), 2342));
7631 rsl_unused := f_exp_ipa_rx(0, tr_RSL_RF_CHAN_REL(pdch_chan_nr));
7632 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(pdch_chan_nr));
7633
7634 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7635 dt.rsl_chan_nr := rsl_msg.ies[0].body.chan_nr;
7636
7637 f_ts_dyn_mode_assert(0, 0, dt.rsl_chan_nr.tn, SDCCH8_MODE);
7638 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(dt.rsl_chan_nr, RSL_ERR_EQUIPMENT_FAIL));
7639 rsl_msg := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
7640 rr := dec_GsmRrMessage(rsl_msg.ies[1].body.full_imm_ass_info.payload);
7641 if (rr.header.message_type != IMMEDIATE_ASSIGNMENT_REJECT) {
7642 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Expected reject");
7643 }
7644
7645 /* FIXME? Currently the TS stays in state BORKEN: */
7646
7647 /* The BSC will switch the TS back to PDCH once the only lchan using it is released: */
7648 /* rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(pdch_chan_nr, ?));
7649 * f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(pdch_chan_nr, 2342));
7650 * f_sleep(1.0);
7651 * f_ts_dyn_mode_assert(0, 0, pdch_chan_nr.tn, PDCH_MODE)
7652 */
7653
7654 /* clean up config */
7655 f_ts_set_chcomb(0, 0, 6, "PDCH");
7656
7657 f_shutdown_helper();
7658}
7659
Stefan Sperling0796a822018-10-05 13:01:39 +02007660testcase TC_chopped_ipa_ping() runs on test_CT {
Stefan Sperling554123f2018-10-09 14:12:30 +02007661 const Integers bsc_ipa_ports := {mp_bsc_rsl_port, mp_bsc_oml_port, mp_bsc_ctrl_port};
Stefan Sperling0796a822018-10-05 13:01:39 +02007662 for (var integer i := 0; i < lengthof(bsc_ipa_ports); i := i + 1) {
7663 IPA_Testing.f_run_TC_chopped_ipa_ping(mp_bsc_ip, bsc_ipa_ports[i], CONNECT_TO_SERVER);
7664 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007665 f_shutdown_helper();
Stefan Sperling0796a822018-10-05 13:01:39 +02007666}
7667
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02007668testcase TC_chopped_ipa_payload() runs on test_CT {
7669 const Integers bsc_ipa_ports := {mp_bsc_rsl_port, mp_bsc_oml_port
7670 /* TODO: mp_bsc_ctrl_port does not work yet */};
7671 for (var integer i := 0; i < lengthof(bsc_ipa_ports); i := i + 1) {
7672 IPA_Testing.f_run_TC_chopped_ipa_payload(mp_bsc_ip, bsc_ipa_ports[i], CONNECT_TO_SERVER);
7673 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007674 f_shutdown_helper();
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02007675}
7676
Pau Espin Pedrol8f773632019-11-05 11:46:53 +01007677/* Verify the BSC sends the MS Power Parameters IE during CHAN ACT to make sure
7678 the BTS does autonomous MS power control loop */
7679testcase TC_assignment_verify_ms_power_params_ie() runs on test_CT {
7680 var MSC_ConnHdlr vc_conn;
7681 var TestHdlrParams pars := f_gen_test_hdlr_pars();
7682 //pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
7683 pars.exp_ms_power_params := true;
7684
7685 f_init(1, true);
7686 f_sleep(1.0);
7687 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
7688 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007689 f_shutdown_helper();
Pau Espin Pedrol8f773632019-11-05 11:46:53 +01007690}
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02007691
Vadim Yanitskiy4b233042021-06-30 00:58:43 +02007692/* Verify activation and deactivation of the BCCH carrier power reduction mode */
7693testcase TC_c0_power_red_mode() runs on test_CT {
7694 f_init(1);
7695
7696 for (var integer red := 6; red >= 0; red := red - 2) {
7697 /* Configure BCCH carrier power reduction mode via the VTY */
7698 f_vty_transceive(BSCVTY, "bts 0 c0-power-reduction " & int2str(red));
7699
7700 /* Expect Osmocom specific BS Power Control message on the RSL */
7701 var template RSL_Message tr_rsl_pdu := tr_RSL_BS_PWR_CTRL(
7702 chan_nr := t_RslChanNr_BCCH(0),
7703 bs_power := tr_RSL_IE_BS_Power(red / 2));
7704 tr_rsl_pdu.msg_disc := tr_RSL_MsgDisc(RSL_MDISC_CCHAN, false);
7705 var RSL_Message unused := f_exp_ipa_rx(0, tr_rsl_pdu);
7706
7707 /* Additionally verify the applied value over the CTRL interface */
7708 var CtrlValue cred := f_ctrl_get_bts(IPA_CTRL, 0, "c0-power-reduction");
7709 if (cred != int2str(red)) {
7710 setverdict(fail, "Unexpected BCCH carrier power reduction value ",
7711 cred, " (expected ", red, ")");
7712 }
7713 }
7714
7715 f_shutdown_helper();
7716}
7717
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007718/***********************************************************************
7719 * MSC Pooling
7720 ***********************************************************************/
7721
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007722template MobileIdentityLV ts_MI_TMSI_NRI_LV(integer nri_v, integer nri_bitlen := 10) :=
Harald Weltebf397612021-01-14 20:39:46 +01007723 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 +02007724
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007725private 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 +02007726runs on MSC_ConnHdlr {
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02007727 interleave {
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007728 [] rsl_pt.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch exp_rr_rel_tmpl)) {
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02007729 f_logp(BSCVTY, "Got RSL RR Release");
7730 }
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007731 [] rsl_pt.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02007732 f_logp(BSCVTY, "Got RSL Deact SACCH");
7733 }
Neels Hofmeyr3c5127e2021-07-22 19:18:40 +02007734 [] rsl_pt.receive(tr_RSL_RF_CHAN_REL(g_chan_nr)) {
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02007735 f_logp(BSCVTY, "Got RSL RF Chan Rel, sending Rel Ack");
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007736 rsl_pt.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
7737 f_rslem_unregister(0, g_chan_nr, PT := rsl_proc_pt);
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02007738 break;
7739 }
7740 }
7741}
7742
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007743friend function f_perform_clear(RSL_DCHAN_PT rsl_pt := RSL, RSLEM_PROC_PT rsl_proc_pt := RSL_PROC,
7744 template PDU_ML3_NW_MS exp_rr_rel_tmpl := tr_RRM_RR_RELEASE)
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02007745runs on MSC_ConnHdlr {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00007746 f_logp(BSCVTY, "MSC instructs BSC to clear channel");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007747 BSSAP.send(ts_BSSMAP_ClearCommand(0));
7748 interleave {
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007749 [] rsl_pt.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch exp_rr_rel_tmpl)) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00007750 f_logp(BSCVTY, "Got RSL RR Release");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007751 }
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007752 [] rsl_pt.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00007753 f_logp(BSCVTY, "Got RSL Deact SACCH");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007754 }
7755 [] BSSAP.receive(tr_BSSMAP_ClearComplete) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00007756 f_logp(BSCVTY, "Got BSSMAP Clear Complete");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007757 /* Also drop the SCCP connection */
7758 BSSAP.send(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_REQ);
7759 }
Neels Hofmeyr3c5127e2021-07-22 19:18:40 +02007760 [] rsl_pt.receive(tr_RSL_RF_CHAN_REL(g_chan_nr)) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00007761 f_logp(BSCVTY, "Got RSL RF Chan Rel, sending Rel Ack");
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007762 rsl_pt.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
7763 f_rslem_unregister(0, g_chan_nr, PT := rsl_proc_pt);
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007764 }
7765 }
7766}
7767
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007768private function f_perform_compl_l3(RSL_DCHAN_PT rsl_pt, RSLEM_PROC_PT rsl_proc_pt,
7769 template PDU_ML3_MS_NW l3_info, boolean do_clear := true, boolean expect_bssmap_l3 := true)
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007770runs on MSC_ConnHdlr {
7771 timer T := 10.0;
7772 var octetstring l3_enc := enc_PDU_ML3_MS_NW(valueof(l3_info));
7773
Neels Hofmeyr767548a2020-08-09 20:26:07 +00007774 f_logp(BSCVTY, "establish channel, send Complete Layer 3 Info");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007775 f_create_bssmap_exp(l3_enc);
7776
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007777 /* RSL_Emulation.f_chan_est() on rsl_pt:
7778 * This is basically code dup with s/RSL/rsl_pt from:
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007779 * RSL_Emulation.f_chan_est(g_pars.ra, l3_enc, g_pars.link_id, g_pars.fn);
7780 */
7781 var RSL_Message rx_rsl;
7782 var GsmRrMessage rr;
7783
7784 /* request a channel to be established */
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007785 rsl_pt.send(ts_RSLDC_ChanRqd(g_pars.ra, g_pars.fn));
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007786 /* expect immediate assignment.
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007787 * Code dup with s/RSL/rsl_pt from:
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007788 * rx_rsl := f_rx_or_fail(tr_RSL_IMM_ASSIGN);
7789 */
7790 timer Tt := 10.0;
7791
7792 /* request a channel to be established */
7793 Tt.start;
7794 alt {
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007795 [] rsl_pt.receive(tr_RSL_IMM_ASSIGN) -> value rx_rsl {
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007796 Tt.stop;
7797 }
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007798 [] rsl_pt.receive {
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007799 setverdict(fail, "Unexpected RSL message on DCHAN");
7800 mtc.stop;
7801 }
7802 [] Tt.timeout {
7803 setverdict(fail, "Timeout waiting for RSL on DCHAN");
7804 mtc.stop;
7805 }
7806 }
7807 rr := dec_GsmRrMessage(rx_rsl.ies[1].body.full_imm_ass_info.payload);
7808 g_chan_nr := rr.payload.imm_ass.chan_desc.chan_nr;
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007809 rsl_pt.send(ts_RSL_EST_IND(g_chan_nr, valueof(g_pars.link_id), l3_enc));
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007810
7811
Neels Hofmeyr66e15092020-10-12 18:44:41 +00007812 if (expect_bssmap_l3) {
7813 f_logp(BSCVTY, "expect BSSAP Complete Layer 3 Info at MSC");
7814 var template PDU_BSSAP exp_l3_compl;
7815 exp_l3_compl := tr_BSSMAP_ComplL3()
7816 if (g_pars.aoip == false) {
7817 exp_l3_compl.pdu.bssmap.completeLayer3Information.codecList := omit;
7818 } else {
7819 exp_l3_compl.pdu.bssmap.completeLayer3Information.codecList := ?;
7820 }
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007821
Neels Hofmeyr66e15092020-10-12 18:44:41 +00007822 var PDU_BSSAP bssap;
7823 T.start;
7824 alt {
7825 [] BSSAP.receive(exp_l3_compl) -> value bssap {
7826 f_logp(BSCVTY, "received expected Complete Layer 3 Info at MSC");
7827 log("rx exp_l3_compl = ", bssap);
7828 }
7829 [] BSSAP.receive(tr_BSSMAP_ComplL3) {
7830 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received non-matching COMPLETE LAYER 3 INFORMATION");
7831 }
7832 [] T.timeout {
7833 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for COMPLETE LAYER 3 INFORMATION");
7834 }
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007835 }
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007836
Neels Hofmeyr66e15092020-10-12 18:44:41 +00007837 /* start ciphering, if requested */
7838 if (ispresent(g_pars.encr)) {
7839 f_logp(BSCVTY, "start ciphering");
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007840 f_cipher_mode(g_pars.encr, rsl_pt := rsl_pt, rsl_proc_pt := rsl_proc_pt);
Neels Hofmeyr66e15092020-10-12 18:44:41 +00007841 }
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007842 }
7843
7844 if (do_clear) {
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007845 f_perform_clear(rsl_pt, rsl_proc_pt);
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007846 }
7847 setverdict(pass);
7848 f_sleep(1.0);
7849}
7850
7851private function f_tc_mscpool_compl_l3(charstring id) runs on MSC_ConnHdlr {
7852 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
7853 if (g_pars.mscpool.rsl_idx == 0) {
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007854 f_perform_compl_l3(RSL, RSL_PROC, g_pars.mscpool.l3_info);
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007855 } else if (g_pars.mscpool.rsl_idx == 1) {
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007856 f_perform_compl_l3(RSL1, RSL1_PROC, g_pars.mscpool.l3_info);
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007857 } else if (g_pars.mscpool.rsl_idx == 2) {
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007858 f_perform_compl_l3(RSL2, RSL2_PROC, g_pars.mscpool.l3_info);
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007859 }
7860}
7861
7862/* Various Complete Layer 3 by IMSI all end up with the first MSC, because the other MSCs are not connected. */
7863private function f_tc_mscpool_L3Compl_on_1_msc(charstring id) runs on MSC_ConnHdlr {
7864 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007865 f_perform_compl_l3(RSL, RSL_PROC, ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000001'H)), '00F110'O) );
7866 f_perform_compl_l3(RSL, RSL_PROC, ts_CM_SERV_REQ(CM_TYPE_MO_SMS, valueof(ts_MI_IMSI_LV('001010000000002'H))) );
7867 f_perform_compl_l3(RSL, RSL_PROC, ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010000000003'H))) );
7868 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 +02007869}
7870testcase TC_mscpool_L3Compl_on_1_msc() runs on test_CT {
7871
7872 f_init(1, true);
7873 f_sleep(1.0);
7874 var MSC_ConnHdlr vc_conn;
7875 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007876
7877 f_ctrs_msc_init();
7878
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007879 vc_conn := f_start_handler(refers(f_tc_mscpool_L3Compl_on_1_msc), pars);
7880 vc_conn.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007881
7882 f_ctrs_msc_expect(0, "mscpool:subscr:new", 4);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007883 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007884}
7885
7886/* Three Layer 3 Complete by IMSI are round-robin'ed across two connected MSCs */
7887/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
7888 * just as well using only RSL. */
7889testcase TC_mscpool_L3Complete_by_imsi_round_robin() runs on test_CT {
7890
7891 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
7892 f_sleep(1.0);
7893
7894 /* Control which MSC gets chosen next by the round-robin, otherwise
7895 * would be randomly affected by which other tests ran before this. */
7896 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
7897
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007898 f_ctrs_msc_init();
7899
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007900 var MSC_ConnHdlr vc_conn1;
7901 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
7902 pars1.mscpool.rsl_idx := 0;
7903 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000001'H)), '00F110'O));
7904 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
7905 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007906 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007907
7908 var MSC_ConnHdlr vc_conn2;
7909 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
7910 pars2.mscpool.rsl_idx := 1;
7911 pars2.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000002'H))));
7912 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
7913 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007914 f_ctrs_msc_expect(1, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007915
7916 /* Test round-robin wrap to the first MSC */
7917 var MSC_ConnHdlr vc_conn3;
7918 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
7919 pars3.mscpool.rsl_idx := 2;
7920 pars3.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010000000003'H))));
7921 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
7922 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007923 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007924 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007925}
7926
7927/* Three LU by TMSI are round-robin'ed across two connected MSCs, because they contain the NULL-NRI 0
7928 * (configured in osmo-bsc.cfg). */
7929/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
7930 * just as well using only RSL. */
7931testcase TC_mscpool_LU_by_tmsi_null_nri_0_round_robin() runs on test_CT {
7932
7933 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
7934 f_sleep(1.0);
7935
7936 /* Control which MSC gets chosen next by the round-robin, otherwise
7937 * would be randomly affected by which other tests ran before this. */
7938 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
7939
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007940 f_ctrs_msc_init();
7941
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007942 var MSC_ConnHdlr vc_conn1;
7943 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
7944 pars1.mscpool.rsl_idx := 0;
7945 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(0)), '00F110'O));
7946 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
7947 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007948 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007949
7950 var MSC_ConnHdlr vc_conn2;
7951 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
7952 pars2.mscpool.rsl_idx := 1;
7953 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(0)), '00F110'O));
7954 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
7955 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007956 f_ctrs_msc_expect(1, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007957
7958 /* Test round-robin wrap to the first MSC */
7959 var MSC_ConnHdlr vc_conn3;
7960 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
7961 pars3.mscpool.rsl_idx := 2;
7962 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(0)), '00F110'O));
7963 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
7964 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007965 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007966 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007967}
7968
7969/* Three LU by TMSI are round-robin'ed across two connected MSCs, because they contain the NULL-NRI 1
7970 * (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
7971 * NULL-NRI setting is stronger than that. */
7972/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
7973 * just as well using only RSL. */
7974testcase TC_mscpool_LU_by_tmsi_null_nri_1_round_robin() runs on test_CT {
7975
7976 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
7977 f_sleep(1.0);
7978
7979 /* Control which MSC gets chosen next by the round-robin, otherwise
7980 * would be randomly affected by which other tests ran before this. */
7981 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
7982
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007983 f_ctrs_msc_init();
7984
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007985 var MSC_ConnHdlr vc_conn1;
7986 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
7987 pars1.mscpool.rsl_idx := 0;
7988 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(1)), '00F110'O));
7989 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
7990 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007991 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007992
7993 var MSC_ConnHdlr vc_conn2;
7994 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
7995 pars2.mscpool.rsl_idx := 1;
7996 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(1)), '00F110'O));
7997 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
7998 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007999 f_ctrs_msc_expect(1, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008000
8001 /* Test round-robin wrap to the first MSC */
8002 var MSC_ConnHdlr vc_conn3;
8003 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
8004 pars3.mscpool.rsl_idx := 2;
8005 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(1)), '00F110'O));
8006 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
8007 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008008 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02008009 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008010}
8011
8012/* Three Layer 3 Complete by TMSI are round-robin'ed across two connected MSCs, because they contain an NRI not
8013 * assigned to any MSC (configured in osmo-bsc.cfg). */
8014/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
8015 * just as well using only RSL. */
8016testcase TC_mscpool_L3Complete_by_tmsi_unassigned_nri_round_robin() runs on test_CT {
8017
8018 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
8019 f_sleep(1.0);
8020
8021 /* Control which MSC gets chosen next by the round-robin, otherwise
8022 * would be randomly affected by which other tests ran before this. */
8023 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
8024
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008025 f_ctrs_msc_init();
8026
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008027 var MSC_ConnHdlr vc_conn1;
8028 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
8029 pars1.mscpool.rsl_idx := 0;
8030 /* An NRI that is not assigned to any MSC */
8031 pars1.mscpool.l3_info := valueof(ts_ML3_MO_MM_IMSI_DET_Ind(valueof(ts_MI_TMSI_NRI_LV(1023))));
8032 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
8033 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008034 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008035
8036 var MSC_ConnHdlr vc_conn2;
8037 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
8038 pars2.mscpool.rsl_idx := 1;
8039 /* An NRI that is not assigned to any MSC */
8040 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(768)), '00F110'O));
8041 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
8042 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008043 f_ctrs_msc_expect(1, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008044
8045 /* Test round-robin wrap to the first MSC */
8046 var MSC_ConnHdlr vc_conn3;
8047 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
8048 pars3.mscpool.rsl_idx := 2;
8049 /* An NRI that is not assigned to any MSC */
8050 pars3.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_SS_ACT, valueof(ts_MI_TMSI_NRI_LV(819))));
8051 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
8052 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008053 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02008054 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008055}
8056
8057/* Three Layer 3 Complete by TMSI are round-robin'ed across two connected MSCs, because they contain an NRI
8058 * assigned to an MSC that is currently not connected (configured in osmo-bsc.cfg). */
8059/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
8060 * just as well using only RSL. */
8061testcase TC_mscpool_L3Complete_by_tmsi_valid_nri_msc_not_connected_round_robin() runs on test_CT {
8062
8063 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
8064 f_sleep(1.0);
8065
8066 /* Control which MSC gets chosen next by the round-robin, otherwise
8067 * would be randomly affected by which other tests ran before this. */
8068 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
8069
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008070 f_ctrs_msc_init();
8071
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008072 var MSC_ConnHdlr vc_conn1;
8073 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
8074 pars1.mscpool.rsl_idx := 0;
8075 /* An NRI that is assigned to an unconnected MSC */
8076 pars1.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(512))));
8077 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
8078 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008079 f_ctrs_msc_add(2, "mscpool:subscr:attach_lost");
8080 f_ctrs_msc_add(0, "mscpool:subscr:new");
8081 f_ctrs_msc_verify();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008082
8083 var MSC_ConnHdlr vc_conn2;
8084 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
8085 pars2.mscpool.rsl_idx := 1;
8086 /* An NRI that is assigned to an unconnected MSC */
8087 pars2.mscpool.l3_info := valueof(ts_ML3_MO_MM_IMSI_DET_Ind(valueof(ts_MI_TMSI_NRI_LV(767))));
8088 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
8089 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008090 f_ctrs_msc_add(2, "mscpool:subscr:attach_lost");
8091 f_ctrs_msc_add(1, "mscpool:subscr:new");
8092 f_ctrs_msc_verify();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008093
8094 /* Test round-robin wrap to the first MSC */
8095 var MSC_ConnHdlr vc_conn3;
8096 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
8097 pars3.mscpool.rsl_idx := 2;
8098 /* An NRI that is assigned to an unconnected MSC */
8099 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(750)), '00F110'O));
8100 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
8101 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008102 f_ctrs_msc_add(2, "mscpool:subscr:attach_lost");
8103 f_ctrs_msc_add(0, "mscpool:subscr:new");
8104 f_ctrs_msc_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02008105 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008106}
8107
8108/* Three Layer 3 Complete by TMSI with valid NRI for the second MSC are all directed to the second MSC (configured in
8109 * osmo-bsc.cfg). */
8110/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
8111 * just as well using only RSL. */
8112testcase TC_mscpool_L3Complete_by_tmsi_valid_nri_1() runs on test_CT {
8113
8114 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
8115 f_sleep(1.0);
8116
8117 /* All TMSIs in this test point at the second MSC, set the round robin to point at the first MSC to make sure
8118 * this is not using round-robin. */
8119 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
8120
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008121 f_ctrs_msc_init();
8122
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008123 var MSC_ConnHdlr vc_conn1;
8124 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 1);
8125 pars1.mscpool.rsl_idx := 0;
8126 /* An NRI of the second MSC's range (256-511) */
8127 pars1.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_SMS, valueof(ts_MI_TMSI_NRI_LV(256))));
8128 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
8129 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008130 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008131
8132 var MSC_ConnHdlr vc_conn2;
8133 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
8134 pars2.mscpool.rsl_idx := 1;
8135 /* An NRI of the second MSC's range (256-511) */
8136 pars2.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(260))));
8137 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
8138 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008139 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008140
8141 var MSC_ConnHdlr vc_conn3;
8142 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 1);
8143 pars3.mscpool.rsl_idx := 2;
8144 /* An NRI of the second MSC's range (256-511) */
8145 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(511)), '00F110'O));
8146 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
8147 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008148 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02008149 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008150}
8151
8152/* Layer 3 Complete by TMSI with valid NRI for the third MSC are directed to the third MSC (configured in osmo-bsc.cfg),
8153 * while a round-robin remains unaffected by that. */
8154/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
8155 * just as well using only RSL. */
8156testcase TC_mscpool_L3Complete_by_tmsi_valid_nri_2() runs on test_CT {
8157
8158 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
8159 f_sleep(1.0);
8160
8161 /* All TMSIs in this test point at the third MSC, set the round robin to point at the second MSC to make sure
8162 * this is not using round-robin. */
8163 f_vty_transceive(BSCVTY, "mscpool roundrobin next 1");
8164
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008165 f_ctrs_msc_init();
8166
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008167 var MSC_ConnHdlr vc_conn1;
8168 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 2);
8169 pars1.mscpool.rsl_idx := 0;
8170 /* An NRI of the third MSC's range (512-767) */
8171 pars1.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_SMS, valueof(ts_MI_TMSI_NRI_LV(512))));
8172 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
8173 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008174 f_ctrs_msc_expect(2, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008175
8176 var MSC_ConnHdlr vc_conn2;
8177 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 2);
8178 pars2.mscpool.rsl_idx := 1;
8179 /* An NRI of the third MSC's range (512-767) */
8180 pars2.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(678))));
8181 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
8182 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008183 f_ctrs_msc_expect(2, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008184
8185 /* The above forwardings to third MSC have not affected the round robin, which still points at the second MSC */
8186 var MSC_ConnHdlr vc_conn3;
8187 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 1);
8188 pars3.mscpool.rsl_idx := 2;
8189 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000013'H)), '00F110'O));
8190 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
8191 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008192 f_ctrs_msc_expect(1, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02008193 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008194}
8195
8196/* LU with a TMSI but indicating a different PLMN in its previous LAI: ignore the NRI. */
8197/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
8198 * just as well using only RSL. */
8199testcase TC_mscpool_LU_by_tmsi_from_other_PLMN() runs on test_CT {
8200
8201 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
8202 f_sleep(1.0);
8203
8204 /* The TMSIs in this test points at the second MSC, but since it is from a different PLMN, round-robin is used
8205 * instead, and hits msc 0. */
8206 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
8207
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008208 f_ctrs_msc_init();
8209
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008210 /* An NRI of the second MSC's range (256-511), but a PLMN that doesn't match with osmo-bsc.cfg */
8211 var MSC_ConnHdlr vc_conn1;
8212 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
8213 pars1.mscpool.rsl_idx := 0;
8214 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(260)), '99F999'O));
8215 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
8216 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008217 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008218
8219 /* An NRI of the third MSC's range (512-767) and a matching PLMN gets directed by NRI. */
8220 var MSC_ConnHdlr vc_conn2;
8221 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 2);
8222 pars2.mscpool.rsl_idx := 1;
8223 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(555)), '00F110'O));
8224 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
8225 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008226 f_ctrs_msc_expect(2, "mscpool:subscr:known");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02008227 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008228}
8229
8230/* Make sure that whichever MSC paged a subscriber will also get the Paging Response. Page by IMSI, which would be
8231 * round-robined to another MSC, to make sure the Paging->Response relation is stronger than the NRI->MSC mapping. */
8232private function f_tc_mscpool_paging_imsi(charstring id) runs on MSC_ConnHdlr {
8233 var template BSSMAP_FIELD_CellIdentificationList cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(0) } };
8234 //cid_list := { cIl_allInBSS := ''O };
8235 var RSL_ChanNeeded rsl_chneed := RSL_CHANNEED_SDCCH;
8236 var template BSSMAP_IE_ChannelNeeded bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
8237 var BSSAP_N_UNITDATA_req paging;
8238 var hexstring imsi := '001010000000123'H;
8239
8240 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
8241
Neels Hofmeyr90f80962020-06-12 16:16:55 +02008242 paging := valueof(ts_BSSAP_UNITDATA_req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008243 valueof(ts_BSSMAP_Paging(imsi, cid_list, omit, bssmap_chneed))));
8244 BSSAP.send(paging);
8245
8246 /* Register any RSL conn so that the Paging Command gets received here. With the current RSL_Emulation's main()
8247 * handling of '[bts_role] IPA_PT.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD()))' it doesn't matter at all which
8248 * channel number is picked here. */
8249 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(0, RSL_CHAN_NR_INVALID));
8250 f_rslem_register(0, new_chan_nr);
8251 RSL.receive(tr_RSL_PAGING_CMD(tr_MI_IMSI(imsi)));
8252 f_rslem_unregister(0, new_chan_nr);
8253
8254 /* Despite the round robin pointing at the second MSC ('roundrobin next 1'), the earlier Paging for the same IMSI
8255 * causes this Paging Response to go to the first MSC (bssap_idx := 0). */
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02008256 f_perform_compl_l3(RSL, RSL_PROC, ts_PAG_RESP(valueof(ts_MI_IMSI_LV(imsi))) );
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008257 f_sleep(1.0);
8258}
8259testcase TC_mscpool_paging_and_response_imsi() runs on test_CT {
8260 f_init(nr_bts := 1, handler_mode := true, nr_msc := 3);
8261 f_sleep(1.0);
8262
8263 /* Testing a Paging on the first MSC to get a Paging Response back to the first MSC. Set round robin to the
8264 * second MSC to make sure we're getting the Paging logic, not a coincidental round robin match. */
8265 f_vty_transceive(BSCVTY, "mscpool roundrobin next 1");
8266
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008267 f_ctrs_msc_init();
8268
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008269 var MSC_ConnHdlr vc_conn1;
8270 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
8271 pars1.mscpool.rsl_idx := 0;
Neels Hofmeyr90f80962020-06-12 16:16:55 +02008272 pars1.sccp_addr_bsc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_peer;
8273 pars1.sccp_addr_msc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_own;
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008274 vc_conn1 := f_start_handler(refers(f_tc_mscpool_paging_imsi), pars1);
8275 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008276 f_ctrs_msc_expect(0, "mscpool:subscr:paged");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02008277 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008278}
8279
8280/* Make sure that whichever MSC paged a subscriber will also get the Paging Response. Page by TMSI with an NRI value
8281 * that matches a different MSC, to make sure the Paging->Response relation is stronger than the NRI->MSC mapping. */
8282private function f_tc_mscpool_paging_tmsi(charstring id) runs on MSC_ConnHdlr {
8283 var template BSSMAP_FIELD_CellIdentificationList cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(0) } };
8284 //cid_list := { cIl_allInBSS := ''O };
8285 var RSL_ChanNeeded rsl_chneed := RSL_CHANNEED_SDCCH;
8286 var template BSSMAP_IE_ChannelNeeded bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
8287 var integer nri_v := 300; /* <-- second MSC's NRI */
Harald Weltebf397612021-01-14 20:39:46 +01008288 var octetstring tmsi := f_gen_tmsi(suffix := 0, nri_v := nri_v);
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008289 var BSSAP_N_UNITDATA_req paging;
8290
8291 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
8292
Neels Hofmeyr90f80962020-06-12 16:16:55 +02008293 paging := valueof(ts_BSSAP_UNITDATA_req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008294 valueof(ts_BSSMAP_Paging('001010000000011'H, cid_list, tmsi, bssmap_chneed))));
8295 BSSAP.send(paging);
8296
8297 /* Register any RSL conn so that the Paging Command gets received here. With the current RSL_Emulation's main()
8298 * handling of '[bts_role] IPA_PT.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD()))' it doesn't matter at all which
8299 * channel number is picked here. */
8300 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(0, RSL_CHAN_NR_INVALID));
8301 f_rslem_register(0, new_chan_nr);
8302 RSL.receive(tr_RSL_PAGING_CMD(t_MI_TMSI(tmsi)));
8303 f_rslem_unregister(0, new_chan_nr);
8304
8305 /* Despite the NRI matching the second MSC (NRI from 'msc 1' in osmo-bsc.cfg) and round robin pointing at the
8306 * third MSC ('roundrobin next 2'), the earlier Paging for the same TMSI causes this Paging Response to go to
8307 * the first MSC (bssap_idx := 0). */
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02008308 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 +02008309 f_sleep(1.0);
8310}
8311testcase TC_mscpool_paging_and_response_tmsi() runs on test_CT {
8312 f_init(nr_bts := 1, handler_mode := true, nr_msc := 3);
8313 f_sleep(1.0);
8314
8315 /* Testing a Paging on the first MSC to get a Paging Response back to the first MSC. Set round robin to the
8316 * third MSC to make sure we're getting the Paging logic, not a coincidental round robin match. */
8317 f_vty_transceive(BSCVTY, "mscpool roundrobin next 2");
8318
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008319 f_ctrs_msc_init();
8320
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008321 var MSC_ConnHdlr vc_conn1;
8322 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
8323 pars1.mscpool.rsl_idx := 0;
Neels Hofmeyr90f80962020-06-12 16:16:55 +02008324 pars1.sccp_addr_bsc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_peer;
8325 pars1.sccp_addr_msc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_own;
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008326 vc_conn1 := f_start_handler(refers(f_tc_mscpool_paging_tmsi), pars1);
8327 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008328 f_ctrs_msc_expect(0, "mscpool:subscr:paged");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02008329 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008330}
8331
8332/* For round-robin, skip an MSC that has 'no allow-attach' set. */
8333/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
8334 * just as well using only RSL. */
8335testcase TC_mscpool_no_allow_attach_round_robin() runs on test_CT {
8336
8337 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
8338 f_sleep(1.0);
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00008339 /* Mark the second MSC as offloading, round-robin should skip this MSC now. */
8340 f_vty_msc_allow_attach(BSCVTY, {true, false, true});
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008341
8342 /* Control which MSC gets chosen next by the round-robin, otherwise
8343 * would be randomly affected by which other tests ran before this. */
8344 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
8345
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008346 f_ctrs_msc_init();
8347
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008348 var MSC_ConnHdlr vc_conn1;
8349 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
8350 pars1.mscpool.rsl_idx := 0;
8351 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000001'H)), '00F110'O));
8352 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
8353 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008354 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008355
8356 var MSC_ConnHdlr vc_conn2;
8357 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 2);
8358 pars2.mscpool.rsl_idx := 1;
8359 pars2.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000002'H))));
8360 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
8361 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008362 f_ctrs_msc_expect(2, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008363
8364 var MSC_ConnHdlr vc_conn3;
8365 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
8366 pars3.mscpool.rsl_idx := 2;
8367 pars3.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010000000003'H))));
8368 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
8369 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008370 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02008371 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008372}
8373
8374/* An MSC that has 'no allow-attach' set should still serve subscribers that are already attached according to their
8375 * TMSI NRI. */
8376testcase TC_mscpool_no_allow_attach_valid_nri() runs on test_CT {
8377
8378 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
8379 f_sleep(1.0);
8380
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00008381 /* Mark the second MSC as offloading, round-robin should skip this MSC now. */
8382 f_vty_msc_allow_attach(BSCVTY, {true, false, true});
8383
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008384 /* Control which MSC gets chosen next by the round-robin, otherwise
8385 * would be randomly affected by which other tests ran before this. */
8386 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
8387
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008388 f_ctrs_msc_init();
8389
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008390 /* Round robin points at msc 0, but the valid NRI directs to msc 1, even though msc 1 has 'no allow-attach'. */
8391 var MSC_ConnHdlr vc_conn1;
8392 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 1);
8393 pars1.mscpool.rsl_idx := 0;
8394 /* An NRI of the second MSC's range (256-511) */
8395 pars1.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_TMSI_NRI_LV(260))));
8396 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
8397 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008398 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008399
8400 var MSC_ConnHdlr vc_conn2;
8401 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 0);
8402 pars2.mscpool.rsl_idx := 1;
8403 pars2.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000002'H))));
8404 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
8405 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008406 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008407
8408 var MSC_ConnHdlr vc_conn3;
8409 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 2);
8410 pars3.mscpool.rsl_idx := 2;
8411 pars3.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000003'H))));
8412 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
8413 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008414 f_ctrs_msc_expect(2, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02008415 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008416}
8417
Philipp Maier783681c2020-07-16 16:47:06 +02008418/* Allow/Deny emergency calls globally via VTY */
8419private function f_vty_allow_emerg_msc(boolean allow) runs on test_CT {
8420 f_vty_enter_cfg_msc(BSCVTY, 0);
8421 if (allow) {
8422 f_vty_transceive(BSCVTY, "allow-emergency allow");
8423 } else {
8424 f_vty_transceive(BSCVTY, "allow-emergency deny");
8425 }
8426 f_vty_transceive(BSCVTY, "exit");
8427 f_vty_transceive(BSCVTY, "exit");
8428}
8429
8430/* Allow/Deny emergency calls per BTS via VTY */
8431private function f_vty_allow_emerg_bts(boolean allow, integer bts_nr) runs on test_CT {
8432 f_vty_enter_cfg_bts(BSCVTY, bts_nr);
8433 if (allow) {
8434 f_vty_transceive(BSCVTY, "rach emergency call allowed 1");
8435 } else {
8436 f_vty_transceive(BSCVTY, "rach emergency call allowed 0");
8437 }
8438 f_vty_transceive(BSCVTY, "exit");
8439 f_vty_transceive(BSCVTY, "exit");
Neels Hofmeyrb6ed80c2020-10-12 22:52:39 +00008440 f_vty_transceive(BSCVTY, "exit");
Philipp Maier783681c2020-07-16 16:47:06 +02008441}
8442
Pau Espin Pedrol9ae36d52021-06-15 17:29:43 +02008443/* Allow/Forbid Fast Return after SRVCC on a given BTS via VTY */
8444private function f_vty_allow_srvcc_fast_return(boolean allow, integer bts_nr) runs on test_CT {
8445 f_vty_enter_cfg_bts(BSCVTY, bts_nr);
8446 if (allow) {
8447 f_vty_transceive(BSCVTY, "srvcc fast-return allow");
8448 } else {
8449 f_vty_transceive(BSCVTY, "srvcc fast-return forbid");
8450 }
8451 f_vty_transceive(BSCVTY, "exit");
8452 f_vty_transceive(BSCVTY, "exit");
8453 f_vty_transceive(BSCVTY, "exit");
8454}
8455
Pau Espin Pedrol14475352021-07-22 15:48:16 +02008456/* Allow/Forbid TCH for signalling if SDCCH exhausted on a given BTS via VTY */
8457private function f_vty_allow_tch_for_signalling(boolean allow, integer bts_nr) runs on test_CT {
8458 f_vty_enter_cfg_bts(BSCVTY, bts_nr);
8459 if (allow) {
8460 f_vty_transceive(BSCVTY, "channel allocator allow-tch-for-signalling 1");
8461 } else {
8462 f_vty_transceive(BSCVTY, "channel allocator allow-tch-for-signalling 0");
8463 }
8464 f_vty_transceive(BSCVTY, "exit");
8465 f_vty_transceive(BSCVTY, "exit");
8466 f_vty_transceive(BSCVTY, "exit");
8467}
8468
Philipp Maier783681c2020-07-16 16:47:06 +02008469/* Begin assignmet procedure and send an EMERGENCY SETUP (RR) */
8470private function f_assignment_emerg_setup() runs on MSC_ConnHdlr {
8471 var PDU_ML3_MS_NW emerg_setup;
8472 var octetstring emerg_setup_enc;
8473 var RSL_Message emerg_setup_data_ind;
8474
8475 f_establish_fully(omit, omit);
8476
8477 emerg_setup := valueof(ts_ML3_MO_CC_EMERG_SETUP(1, valueof(ts_Bcap_voice)));
8478 emerg_setup_enc := enc_PDU_ML3_MS_NW(emerg_setup);
8479 emerg_setup_data_ind := valueof(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), emerg_setup_enc));
8480
8481 RSL.send(emerg_setup_data_ind);
8482}
8483
8484/* Test if the EMERGENCY SETUP gets passed on to the MSC via A when EMERGENCY
8485 * CALLS are permitted by the BSC config. */
8486private function f_TC_assignment_emerg_setup_allow(charstring id) runs on MSC_ConnHdlr {
8487 var PDU_BSSAP emerg_setup_data_ind_bssap;
8488 var PDU_ML3_MS_NW emerg_setup;
8489 timer T := 3.0;
8490
8491 f_assignment_emerg_setup()
8492
8493 T.start;
8494 alt {
8495 [] BSSAP.receive(tr_BSSAP_DTAP) -> value emerg_setup_data_ind_bssap {
8496 emerg_setup := dec_PDU_ML3_MS_NW(emerg_setup_data_ind_bssap.pdu.dtap);
8497 if (not isbound(emerg_setup.msgs.cc.emergencySetup)) {
8498 setverdict(fail, "no emergency setup");
8499 }
8500 }
8501 [] BSSAP.receive {
8502 setverdict(fail, "unexpected BSSAP message!");
8503 }
8504 [] T.timeout {
8505 setverdict(fail, "timout waiting for EMERGENCY SETUP!");
8506 }
8507 }
8508
8509 setverdict(pass);
8510}
8511
8512/* Test if the EMERGENCY SETUP gets blocked by the BSC if EMERGENCY CALLS are
8513 * forbidden by the BSC config. */
8514private function f_TC_assignment_emerg_setup_deny(charstring id) runs on MSC_ConnHdlr {
8515 var PDU_BSSAP emerg_setup_data_ind_bssap;
8516 timer T := 3.0;
8517
8518 f_assignment_emerg_setup()
8519
8520 T.start;
8521 alt {
8522 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
8523 setverdict(pass);
8524 }
8525 [] RSL.receive {
8526 setverdict(fail, "unexpected RSL message!");
8527 }
8528 [] T.timeout {
8529 setverdict(fail, "timout waiting for RR CHANNEL RELEASE!");
8530 }
8531 }
8532}
8533
8534/* EMERGENCY CALL situation #1, allowed globally and by BTS */
8535testcase TC_assignment_emerg_setup_allow() runs on test_CT {
8536 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8537 var MSC_ConnHdlr vc_conn;
8538
8539 f_init(1, true);
8540 f_sleep(1.0);
8541
8542 f_vty_allow_emerg_msc(true);
8543 f_vty_allow_emerg_bts(true, 0);
8544 vc_conn := f_start_handler(refers(f_TC_assignment_emerg_setup_allow), pars);
8545 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02008546 f_shutdown_helper();
Philipp Maier783681c2020-07-16 16:47:06 +02008547}
8548
8549/* EMERGENCY CALL situation #2, forbidden globally but allowed by BTS */
8550testcase TC_assignment_emerg_setup_deny_msc() runs on test_CT {
8551 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8552 var MSC_ConnHdlr vc_conn;
8553
8554 f_init(1, true);
8555 f_sleep(1.0);
8556
8557 f_vty_allow_emerg_msc(false);
8558 f_vty_allow_emerg_bts(true, 0);
8559 vc_conn := f_start_handler(refers(f_TC_assignment_emerg_setup_deny), pars);
8560 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02008561 f_shutdown_helper();
Philipp Maier783681c2020-07-16 16:47:06 +02008562}
8563
8564/* EMERGENCY CALL situation #3, allowed globally but forbidden by BTS */
8565testcase TC_assignment_emerg_setup_deny_bts() runs on test_CT {
8566 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8567 var MSC_ConnHdlr vc_conn;
8568
8569 /* Note: This simulates a spec violation by the MS, correct MS
8570 * implementations would not try to establish an emergency call because
8571 * the system information tells in advance that emergency calls are
8572 * not forbidden */
8573
8574 f_init(1, true);
8575 f_sleep(1.0);
8576
8577 f_vty_allow_emerg_msc(true);
8578 f_vty_allow_emerg_bts(false, 0);
8579 vc_conn := f_start_handler(refers(f_TC_assignment_emerg_setup_deny), pars);
8580 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02008581 f_shutdown_helper();
Philipp Maier783681c2020-07-16 16:47:06 +02008582}
8583
Philipp Maier82812002020-08-13 18:48:27 +02008584/* Test what happens when an emergency call arrives while all TCH channels are
8585 * busy, the BSC is expected to terminate one call in favor of the incoming
8586 * emergency call */
8587testcase TC_emerg_premption() runs on test_CT {
8588 var ASP_RSL_Unitdata rsl_ud;
8589 var integer i;
8590 var integer chreq_total, chreq_nochan;
8591 var RSL_Message rx_rsl;
8592 var RslChannelNr chan_nr;
8593
8594 f_init(1);
8595 f_sleep(1.0);
8596
8597 f_vty_allow_emerg_msc(true);
8598 f_vty_allow_emerg_bts(true, 0);
8599
8600 /* Fill up all channels on the BTS */
8601 chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total");
8602 chreq_nochan := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel");
8603 for (i := 0; i < NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS; i := i+1) {
8604 chan_nr := f_chreq_act_ack('33'O, i);
8605 }
8606 IPA_RSL[0].clear;
8607 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total",
8608 chreq_total + NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS);
8609
8610 /* Send Channel request for emegergency call */
8611 f_ipa_tx(0, ts_RSL_CHAN_RQD('A5'O, 23));
8612
8613 /* Expect the BSC to release one (the first) TCH/F on the BTS */
8614 chan_nr := valueof(t_RslChanNr_Bm(1));
8615 f_expect_chan_rel(0, chan_nr, expect_rr_chan_rel := false, expect_rll_rel_req := false);
8616
8617 /* Expect the BSC to send activate/assign the a channel for the emergency call */
8618 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
8619 chan_nr := rx_rsl.ies[0].body.chan_nr;
8620 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 33));
8621 rx_rsl := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
Philipp Maier104f4c02020-09-11 18:12:18 +02008622
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02008623 f_shutdown_helper();
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008624}
8625
8626/* Hopping parameters per a timeslot */
Vadim Yanitskiybc6654a2020-09-13 01:27:40 +07008627private type record length(0..64) of GsmArfcn ArfcnList;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008628private type record FHParamsTs {
8629 boolean enabled,
8630 uint6_t hsn,
8631 uint6_t maio,
8632 ArfcnList ma
8633};
8634
8635/* Hopping parameters per a transceiver */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008636private type record FHParamsTrx {
Philipp Maier798d8952021-10-19 14:43:19 +02008637 GsmBandArfcn arfcn,
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008638 FHParamsTs ts[8]
8639};
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008640
8641/* Randomly generate the hopping parameters for the given timeslot numbers */
8642private function f_TC_fh_params_gen(template integer tr_tn := (1, 3, 5))
8643runs on test_CT return FHParamsTrx {
8644 var FHParamsTrx fhp;
8645
Philipp Maier798d8952021-10-19 14:43:19 +02008646 /* Generate a random ARFCN in the range of 0 - 3. This ARFCN will
8647 * fall in the GSM900 band. */
8648 fhp.arfcn.arfcn := f_rnd_int(3);
8649 fhp.arfcn.pcs := false;
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07008650
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008651 for (var integer tn := 0; tn < 8; tn := tn + 1) {
8652 if (not match(tn, tr_tn)) {
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008653 fhp.ts[tn].enabled := false;
8654 fhp.ts[tn].ma := { };
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008655 continue;
8656 }
8657
8658 /* Random HSN / MAIO values: 0..63 */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008659 fhp.ts[tn].hsn := f_rnd_int(64);
8660 fhp.ts[tn].maio := f_rnd_int(64);
8661 fhp.ts[tn].ma := { };
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008662
8663 /* Random Mobile Allocation (hopping channels) */
8664 var integer ma_len := 2 + f_rnd_int(9); /* 2..10 channels */
8665 var integer step := 3 + f_rnd_int(4); /* 3..6 stepping */
8666 for (var integer i := 1; i <= ma_len; i := i + 1) {
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008667 fhp.ts[tn].ma := fhp.ts[tn].ma & { i * step };
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008668 }
8669
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008670 fhp.ts[tn].enabled := true;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008671 }
8672
8673 log("f_TC_fh_params_gen(): ", fhp);
8674 return fhp;
8675}
8676
8677/* Make sure that the given Channel Description IE matches the hopping configuration */
8678private function f_TC_fh_params_match_chan_desc(in FHParamsTrx fhp, in ChannelDescription cd)
8679{
8680 var template (present) ChannelDescription tr_cd;
8681 var template (present) MaioHsn tr_maio_hsn;
8682 var uint3_t tn := cd.chan_nr.tn;
8683
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008684 if (fhp.ts[tn].enabled) {
8685 tr_maio_hsn := tr_HsnMaio(fhp.ts[tn].hsn, fhp.ts[tn].maio);
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008686 tr_cd := tr_ChanDescH1(cd.chan_nr, tr_maio_hsn);
8687 } else {
Philipp Maier798d8952021-10-19 14:43:19 +02008688 tr_cd := tr_ChanDescH0(cd.chan_nr, fhp.arfcn.arfcn);
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008689 }
8690
8691 if (not match(cd, tr_cd)) {
8692 setverdict(fail, "Channel Description IE does not match: ",
8693 cd, " vs expected ", tr_cd);
8694 }
8695}
8696
8697/* Make sure that the given Mobile Allocation IE matches the hopping configuration */
8698private function f_TC_fh_params_match_ma(in FHParamsTrx fhp, uint3_t tn,
8699 in MobileAllocationLV ma)
8700{
8701 var template MobileAllocationLV tr_ma := f_TC_fh_params_gen_tr_ma(fhp, tn, ma);
8702
8703 if (not match(ma, tr_ma)) {
8704 setverdict(fail, "Mobile Allocation IE does not match (tn := ",
8705 tn, "): ", ma, " vs expected: ", tr_ma);
8706 } else {
8707 setverdict(pass);
8708 }
8709}
8710
8711private function f_TC_fh_params_gen_tr_ma(in FHParamsTrx fhp, uint3_t tn,
8712 in MobileAllocationLV ma)
8713return template MobileAllocationLV {
8714 /* Mobile Allocation IE is expected to be empty if hopping is not enabled */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008715 if (not fhp.ts[tn].enabled) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008716 return { len := 0, ma := ''B };
8717 }
8718
8719 var bitstring full_mask := f_pad_bit(''B, 1024, '0'B);
8720 var bitstring slot_mask := f_pad_bit(''B, 1024, '0'B);
8721 var bitstring ma_mask := ''B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008722
8723 /* Compose the full bit-mask (all channels, up to 1024 entries) */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008724 for (var integer i := 0; i < lengthof(fhp.ts); i := i + 1) {
8725 for (var integer j := 0; j < lengthof(fhp.ts[i].ma); j := j + 1) {
8726 if (full_mask[fhp.ts[i].ma[j]] == '1'B)
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008727 { continue; }
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008728 full_mask[fhp.ts[i].ma[j]] := '1'B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008729 }
8730 }
8731
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07008732 /* Take ARFCN of the TRX itself into account */
Philipp Maier798d8952021-10-19 14:43:19 +02008733 full_mask[fhp.arfcn.arfcn] := '1'B;
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07008734
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008735 /* Compose a bit-mask for the given timeslot number */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008736 for (var integer i := 0; i < lengthof(fhp.ts[tn].ma); i := i + 1) {
8737 slot_mask[fhp.ts[tn].ma[i]] := '1'B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008738 }
8739
8740 /* Finally, compose the Mobile Allocation bit-mask */
Vadim Yanitskiy3e997362020-09-05 21:08:34 +07008741 for (var integer i := 1; i < lengthof(full_mask); i := i + 1) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008742 if (full_mask[i] != '1'B)
8743 { continue; }
8744
8745 /* FIXME: ma_mask := ma_mask & slot_mask[i]; // triggers a bug in TITAN */
8746 if (slot_mask[i] == '1'B) {
8747 ma_mask := ma_mask & '1'B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008748 } else {
8749 ma_mask := ma_mask & '0'B;
8750 }
8751 }
8752
Vadim Yanitskiy3e997362020-09-05 21:08:34 +07008753 /* ARFCN 0 (if present) goes to the last position of the bit-mask */
8754 if (full_mask[0] == '1'B) {
8755 /* FIXME: ma_mask := ma_mask & slot_mask[0]; // triggers a bug in TITAN */
8756 if (slot_mask[0] == '1'B) {
8757 ma_mask := ma_mask & '1'B;
8758 } else {
8759 ma_mask := ma_mask & '0'B;
8760 }
8761 }
8762
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008763 /* Ensure that ma_mask is octet-aligned */
Vadim Yanitskiy2aa02522020-09-06 14:05:23 +07008764 var integer ma_mask_len := (lengthof(ma_mask) + 8 - 1) / 8;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008765 ma_mask := f_pad_bit(ma_mask, ma_mask_len * 8, '0'B);
8766
8767 return { len := ma_mask_len, ma := ma_mask };
8768}
8769
Philipp Maier798d8952021-10-19 14:43:19 +02008770/* Configure the appropriate band for a given arfcn, exc */
8771private function f_TC_set_band_by_arfcn(integer bts_nr, GsmBandArfcn arfcn) runs on test_CT
8772{
8773 var charstring band;
8774 var GsmBandArfcn arfcn_ := valueof(ts_GsmBandArfcn(arfcn.arfcn, arfcn.pcs, false));
8775
8776 select (arfcn_) {
8777 case (tr_GsmBandArfcn((259..293), false, ?)) { band := "GSM450"; }
8778 case (tr_GsmBandArfcn((306..340), false, ?)) { band := "GSM480"; }
8779 case (tr_GsmBandArfcn((438..511), false, ?)) { band := "GSM750"; }
8780 case (tr_GsmBandArfcn((128..251), false, ?)) { band := "GSM850"; }
8781 case (tr_GsmBandArfcn((0..124), false, ?)) { band := "GSM900"; }
8782 case (tr_GsmBandArfcn((955..1023), false, ?)) { band := "GSM900"; }
8783 case (tr_GsmBandArfcn((512..885), false, ?)) { band := "DCS1800"; }
8784 case (tr_GsmBandArfcn((512..810), true, ?)) { band := "PCS1900"; }
8785 case else { return; }
8786 }
8787
8788 f_vty_enter_cfg_bts(BSCVTY, bts_nr);
8789 f_vty_transceive(BSCVTY, "band " & band);
8790 f_vty_transceive(BSCVTY, "end");
8791}
8792
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008793/* Configure the hopping parameters in accordance with the given record */
8794private function f_TC_fh_params_set(in FHParamsTrx fhp,
8795 uint8_t bts_nr := 0,
8796 uint8_t trx_nr := 0)
8797runs on test_CT {
Philipp Maier798d8952021-10-19 14:43:19 +02008798
8799 f_TC_set_band_by_arfcn(bts_nr, fhp.arfcn);
8800
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008801 /* Enter the configuration node for the given BTS/TRX numbers */
8802 f_vty_enter_cfg_trx(BSCVTY, bts_nr, trx_nr);
8803
Philipp Maier798d8952021-10-19 14:43:19 +02008804 f_vty_transceive(BSCVTY, "arfcn " & int2str(fhp.arfcn.arfcn));
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07008805
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008806 for (var integer tn := 0; tn < lengthof(fhp.ts); tn := tn + 1) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008807 f_vty_transceive(BSCVTY, "timeslot " & int2str(tn));
8808
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008809 if (not fhp.ts[tn].enabled) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008810 f_vty_transceive(BSCVTY, "hopping enabled 0");
8811 f_vty_transceive(BSCVTY, "exit"); /* go back */
8812 continue;
8813 }
8814
8815 /* Configure HSN / MAIO values */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008816 f_vty_transceive(BSCVTY, "hopping sequence-number " & int2str(fhp.ts[tn].hsn));
8817 f_vty_transceive(BSCVTY, "hopping maio " & int2str(fhp.ts[tn].maio));
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008818
8819 /* Configure the Mobile Allocation (hopping channels) */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008820 for (var integer i := 0; i < lengthof(fhp.ts[tn].ma); i := i + 1) {
8821 f_vty_transceive(BSCVTY, "hopping arfcn add " & int2str(fhp.ts[tn].ma[i]));
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008822 }
8823
8824 f_vty_transceive(BSCVTY, "hopping enabled 1");
8825 f_vty_transceive(BSCVTY, "exit"); /* go back */
8826 }
8827
8828 f_vty_transceive(BSCVTY, "end");
8829}
8830
8831/* Disable frequency hopping on all timeslots */
8832private function f_TC_fh_params_unset(in FHParamsTrx fhp,
8833 uint8_t bts_nr := 0,
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07008834 uint8_t trx_nr := 0,
Philipp Maier798d8952021-10-19 14:43:19 +02008835 GsmBandArfcn arfcn := {pcs := false, arfcn := 871})
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008836runs on test_CT {
Philipp Maier798d8952021-10-19 14:43:19 +02008837
8838 f_TC_set_band_by_arfcn(bts_nr, arfcn);
8839
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008840 /* Enter the configuration node for the given BTS/TRX numbers */
8841 f_vty_enter_cfg_trx(BSCVTY, bts_nr, trx_nr);
8842
Philipp Maier798d8952021-10-19 14:43:19 +02008843 f_vty_transceive(BSCVTY, "arfcn " & int2str(arfcn.arfcn));
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07008844
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008845 for (var integer tn := 0; tn < lengthof(fhp.ts); tn := tn + 1) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008846 f_vty_transceive(BSCVTY, "timeslot " & int2str(tn));
8847
8848 /* Delete all ARFCNs from the Mobile Allocation (if any) */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008849 for (var integer i := 0; i < lengthof(fhp.ts[tn].ma); i := i + 1) {
8850 f_vty_transceive(BSCVTY, "hopping arfcn del " & int2str(fhp.ts[tn].ma[i]));
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008851 }
8852
8853 f_vty_transceive(BSCVTY, "hopping enabled 0");
8854 f_vty_transceive(BSCVTY, "exit"); /* go back */
8855 }
8856
8857 f_vty_transceive(BSCVTY, "end");
8858 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
8859}
8860
8861/* Verify presence and correctness of the hopping parameters (HSN, MAIO)
8862 * in the Channel Identification IE of the RSL CHANnel ACTIVation message. */
8863testcase TC_fh_params_chan_activ() runs on test_CT {
8864 var FHParamsTrx fhp := f_TC_fh_params_gen();
8865 var RSL_Message rsl_msg;
8866 var RSL_IE_Body ie;
8867
8868 f_init_vty();
8869
8870 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
8871 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
8872
8873 f_init(1);
8874
8875 /* CS domain: 3 (SDCCH/4+CBCH) + 4 (TCH/F) + 2 (TCH/H) channels available */
8876 for (var integer i := 0; i < 9; i := i + 1) {
8877 f_ipa_tx(0, ts_RSL_CHAN_RQD(f_rnd_ra_cs(), 23));
8878 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
8879
8880 /* Make sure that Channel Identification IE is present */
8881 if (not f_rsl_find_ie(rsl_msg, RSL_IE_CHAN_IDENT, ie)) {
8882 setverdict(fail, "RSL Channel Identification IE is absent");
8883 continue;
8884 }
8885
8886 /* Make sure that hopping parameters (HSN/MAIO) match */
8887 f_TC_fh_params_match_chan_desc(fhp, ie.chan_ident.ch_desc.v);
8888
8889 /* "Mobile Allocation shall be included but empty" - let's check this */
8890 if (ie.chan_ident.ma.v.len != 0) {
8891 setverdict(fail, "Mobile Allocation IE is not empty: ",
8892 ie.chan_ident.ma, ", despite it shall be");
8893 continue;
8894 }
8895 }
8896
8897 /* Disable frequency hopping */
8898 f_TC_fh_params_unset(fhp);
8899
Vadim Yanitskiy21726312020-09-04 01:45:36 +07008900 f_shutdown_helper();
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008901}
8902
8903/* Verify the hopping parameters (HSN, MAIO, MA) in (RR) Immediate Assignment */
8904testcase TC_fh_params_imm_ass() runs on test_CT {
8905 var FHParamsTrx fhp := f_TC_fh_params_gen();
8906 var RSL_Message rsl_msg;
8907 var RSL_IE_Body ie;
8908
8909 f_init_vty();
8910
8911 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
8912 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
8913
8914 f_init(1);
8915
8916 /* CS domain: 3 (SDCCH/4+CBCH) + 4 (TCH/F) + 2 (TCH/H) channels available */
8917 for (var integer i := 0; i < 9; i := i + 1) {
8918 f_ipa_tx(0, ts_RSL_CHAN_RQD(f_rnd_ra_cs(), 23));
8919 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
8920
8921 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(rsl_msg.ies[0].body.chan_nr, 33));
8922 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeC(RSL_MT_IMMEDIATE_ASSIGN_CMD));
8923
8924 /* Make sure that Full Immediate Assign Info IE is present */
8925 if (not f_rsl_find_ie(rsl_msg, RSL_IE_FULL_IMM_ASS_INFO, ie)) {
8926 setverdict(fail, "RSL Full Immediate Assign Info IE is absent");
8927 continue;
8928 }
8929
8930 /* Decode the actual Immediate Assignment message */
8931 var GsmRrMessage rr_msg := dec_GsmRrMessage(ie.full_imm_ass_info.payload);
8932 if (not match(rr_msg.header, t_RrHeader(IMMEDIATE_ASSIGNMENT, ?))) {
8933 setverdict(fail, "Failed to match Immediate Assignment: ", rr_msg);
8934 continue;
8935 }
8936
8937 /* Make sure that hopping parameters (HSN/MAIO) match */
8938 f_TC_fh_params_match_chan_desc(fhp, rr_msg.payload.imm_ass.chan_desc);
8939
8940 /* Make sure that the Mobile Allocation IE matches */
8941 f_TC_fh_params_match_ma(fhp, rr_msg.payload.imm_ass.chan_desc.chan_nr.tn,
8942 rr_msg.payload.imm_ass.mobile_allocation);
8943 }
8944
8945 /* Disable frequency hopping */
8946 f_TC_fh_params_unset(fhp);
Philipp Maier82812002020-08-13 18:48:27 +02008947
Vadim Yanitskiy21726312020-09-04 01:45:36 +07008948 f_shutdown_helper();
Philipp Maier82812002020-08-13 18:48:27 +02008949}
8950
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07008951/* Verify the hopping parameters (HSN, MAIO, MA) in (RR) Assignment Command */
8952testcase TC_fh_params_assignment_cmd() runs on test_CT {
8953 var FHParamsTrx fhp := f_TC_fh_params_gen();
8954 var RSL_Message rsl_msg;
8955 var RSL_IE_Body ie;
8956
8957 f_init_vty();
8958
8959 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
8960 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
8961
8962 f_init(1);
8963
8964 /* HACK: work around "Couldn't find Expect for CRCX" */
8965 vc_MGCP.stop;
8966
8967 var template PDU_BSSAP ass_cmd := f_gen_ass_req();
8968 ass_cmd.pdu.bssmap.assignmentRequest.codecList := ts_BSSMAP_IE_CodecList({ts_CodecFR});
8969
8970 /* CS domain (TCH): 4 (TCH/F) + 2 (TCH/H) channels available
8971 * NOTE: only 3 SDCCH/4 channels are available on CCCH+SDCCH4+CBCH */
8972 for (var integer i := 0; i < 3; i := i + 1) {
8973 /* Establish a dedicated channel, so we can trigger (late) TCH assignment */
8974 var DchanTuple dt := f_est_dchan(f_rnd_ra_cs(), 23, f_rnd_octstring(16));
8975
8976 /* Send a BSSMAP Assignment Command, expect CHANnel ACTIVation */
8977 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ass_cmd));
8978 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
8979
8980 /* ACKnowledge CHANnel ACTIVation, expect RSL DATA REQuest */
8981 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(rsl_msg.ies[0].body.chan_nr, 33));
8982 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeR(RSL_MT_DATA_REQ));
8983
8984 /* Make sure that L3 Information IE is present */
8985 if (not f_rsl_find_ie(rsl_msg, RSL_IE_L3_INFO, ie)) {
8986 setverdict(fail, "RSL L3 Information IE is absent");
8987 continue;
8988 }
8989
8990 /* Decode the L3 message and make sure it is (RR) Assignment Command */
8991 var GsmRrL3Message l3_msg := dec_GsmRrL3Message(ie.l3_info.payload);
8992 if (not match(l3_msg.header, t_RrL3Header(ASSIGNMENT_COMMAND))) {
8993 setverdict(fail, "Failed to match Assignment Command: ", l3_msg);
8994 continue;
8995 }
8996
8997 /* Make sure that hopping parameters (HSN/MAIO) match */
8998 var ChannelDescription chan_desc := l3_msg.payload.ass_cmd.chan_desc;
8999 f_TC_fh_params_match_chan_desc(fhp, chan_desc);
9000
9001 /* Make sure that Cell Channel Description IE is present if FH is enabled */
9002 if (chan_desc.h and not ispresent(l3_msg.payload.ass_cmd.cell_chan_desc)) {
Vadim Yanitskiy38d069d2020-09-02 17:18:57 +07009003 setverdict(fail, "FH enabled, but Cell Channel Description IE is absent");
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07009004 continue;
9005 }
9006
9007 /* Make sure that the Mobile Allocation IE matches (if present) */
9008 var boolean ma_present := ispresent(l3_msg.payload.ass_cmd.mobile_allocation);
9009 if (chan_desc.h and ma_present) {
9010 f_TC_fh_params_match_ma(fhp, chan_desc.chan_nr.tn,
9011 l3_msg.payload.ass_cmd.mobile_allocation.v);
9012 } else if (chan_desc.h and not ma_present) {
9013 setverdict(fail, "FH enabled, but Mobile Allocation IE is absent");
9014 continue;
9015 } else if (not chan_desc.h and ma_present) {
9016 setverdict(fail, "FH disabled, but Mobile Allocation IE is present");
9017 continue;
9018 }
9019 }
9020
9021 /* Give the IUT some time to release all channels */
9022 f_sleep(3.0);
9023
9024 /* Disable frequency hopping */
9025 f_TC_fh_params_unset(fhp);
9026
Vadim Yanitskiy21726312020-09-04 01:45:36 +07009027 f_shutdown_helper();
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07009028}
9029
Vadim Yanitskiy8f5430d2020-09-02 18:51:38 +07009030/* Verify the hopping parameters (HSN, MAIO, MA) in (RR) Handover Command */
9031private function f_TC_fh_params_handover_cmd(in FHParamsTrx fhp)
9032runs on test_CT {
9033 var RSL_Message rsl_msg;
9034 var RSL_IE_Body ie;
9035 var DchanTuple dt;
9036
9037 /* Establish a dedicated channel, so we can trigger handover */
9038 dt := f_est_dchan(f_rnd_ra_cs(), 23, f_rnd_octstring(16));
Vadim Yanitskiyc18ff472021-11-18 20:15:37 +03009039 f_sleep(0.5);
Vadim Yanitskiy8f5430d2020-09-02 18:51:38 +07009040
9041 /* Trigger handover from BTS0 to BTS1 */
9042 f_bts_0_cfg(BSCVTY, { "neighbor bts 1" });
9043 f_vty_handover(BSCVTY, 0, 0, dt.rsl_chan_nr, 1);
9044
9045 /* Expect RSL CHANnel ACTIVation on BTS1/TRX0/TS1 */
9046 rsl_msg := f_exp_ipa_rx(1, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
9047
9048 /* ACKnowledge channel activation and expect (RR) Handover Command */
9049 f_ipa_tx(1, ts_RSL_CHAN_ACT_ACK(rsl_msg.ies[0].body.chan_nr, 33));
9050 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeR(RSL_MT_DATA_REQ));
9051
9052 /* Make sure that L3 Information IE is present */
9053 if (not f_rsl_find_ie(rsl_msg, RSL_IE_L3_INFO, ie)) {
9054 setverdict(fail, "RSL L3 Information IE is absent");
9055 return;
9056 }
9057
9058 /* Decode the L3 message and make sure it is (RR) Handover Command */
9059 var GsmRrL3Message l3_msg := dec_GsmRrL3Message(ie.l3_info.payload);
9060 if (not match(l3_msg.header, t_RrL3Header(HANDOVER_COMMAND))) {
9061 setverdict(fail, "Failed to match Handover Command: ", l3_msg);
9062 return;
9063 }
9064
9065 /* Make sure that we've got SDCCH/8 on TS1 (expected to be hopping) */
9066 var ChannelDescription chan_desc := l3_msg.payload.ho_cmd.chan_desc;
9067 if (not match(chan_desc.chan_nr, t_RslChanNr_SDCCH8(1, ?))) {
9068 setverdict(fail, "Unexpected channel number: ", chan_desc.chan_nr);
9069 return;
9070 }
9071
9072 /* Make sure that hopping parameters (HSN/MAIO) match */
9073 f_TC_fh_params_match_chan_desc(fhp, chan_desc);
9074
9075 /* Make sure that Cell Channel Description IE is present */
9076 if (not ispresent(l3_msg.payload.ho_cmd.cell_chan_desc)) {
9077 setverdict(fail, "FH enabled, but Cell Channel Description IE is absent");
9078 return;
9079 }
9080
9081 /* Make sure that the Mobile Allocation (after time) IE is present and matches */
9082 var boolean ma_present := ispresent(l3_msg.payload.ho_cmd.mobile_allocation);
9083 if (ma_present) {
9084 f_TC_fh_params_match_ma(fhp, chan_desc.chan_nr.tn,
9085 l3_msg.payload.ho_cmd.mobile_allocation.v);
9086 } else {
9087 setverdict(fail, "FH enabled, but Mobile Allocation IE is absent");
9088 return;
9089 }
9090}
9091testcase TC_fh_params_handover_cmd() runs on test_CT {
9092 var FHParamsTrx fhp := f_TC_fh_params_gen();
9093
9094 f_init_vty();
9095
9096 /* (Re)configure TS0 as BCCH and TS1 as SDCCH8 on BTS1/TRX0 */
9097 f_vty_enter_cfg_trx(BSCVTY, bts := 1, trx := 0);
9098
9099 f_vty_transceive(BSCVTY, "timeslot 0");
9100 f_vty_transceive(BSCVTY, "phys_chan_config ccch");
9101 f_vty_transceive(BSCVTY, "exit"); /* go back */
9102
9103 f_vty_transceive(BSCVTY, "timeslot 1");
9104 f_vty_transceive(BSCVTY, "phys_chan_config sdcch8");
9105 f_vty_transceive(BSCVTY, "end"); /* we're done */
9106
9107 f_TC_fh_params_set(fhp, 1); /* Enable frequency hopping on BTS1 */
9108 f_vty_transceive(BSCVTY, "drop bts connection 1 oml");
9109
9110 f_init(2);
9111
9112 f_TC_fh_params_handover_cmd(fhp);
9113
9114 /* Disable frequency hopping on BTS1 */
9115 f_TC_fh_params_unset(fhp, 1);
9116
9117 /* (Re)configure TS0 as CCCH+SDCCH4+CBCH and TS1 as TCH/F */
9118 f_vty_enter_cfg_trx(BSCVTY, bts := 1, trx := 0);
9119
9120 f_vty_transceive(BSCVTY, "timeslot 0");
9121 f_vty_transceive(BSCVTY, "phys_chan_config ccch+sdcch4+cbch");
9122 f_vty_transceive(BSCVTY, "exit"); /* go back */
9123
9124 f_vty_transceive(BSCVTY, "timeslot 1");
9125 f_vty_transceive(BSCVTY, "phys_chan_config tch/f");
9126 f_vty_transceive(BSCVTY, "end"); /* we're done */
9127
9128 f_shutdown_helper();
9129}
9130
Vadim Yanitskiyca974032020-09-01 07:20:39 +07009131/* Verify the hopping parameters in System Information Type 4 */
9132testcase TC_fh_params_si4_cbch() runs on test_CT {
9133 var FHParamsTrx fhp := f_TC_fh_params_gen(tr_tn := 1);
9134 var ASP_RSL_Unitdata rx_rsl_ud;
9135 timer T := 5.0;
9136
9137 f_init_vty();
9138
9139 /* (Re)configure TS0 as BCCH and TS1 as SDCCH8+CBCH */
9140 f_vty_enter_cfg_trx(BSCVTY, trx := 0);
9141
9142 f_vty_transceive(BSCVTY, "timeslot 0");
9143 f_vty_transceive(BSCVTY, "phys_chan_config ccch");
9144 f_vty_transceive(BSCVTY, "exit"); /* go back */
9145
9146 f_vty_transceive(BSCVTY, "timeslot 1");
9147 f_vty_transceive(BSCVTY, "phys_chan_config sdcch8+cbch");
9148 f_vty_transceive(BSCVTY, "end"); /* we're done */
9149
9150 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
9151 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
9152
9153 f_init(1);
9154
9155 T.start;
9156 alt {
9157 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_BCCH_INFO(RSL_SYSTEM_INFO_4))) -> value rx_rsl_ud {
9158 var RSL_IE_Body ie := rx_rsl_ud.rsl.ies[2].body; /* FULL BCCH Information IE */
9159 var SystemInformation si := dec_SystemInformation(ie.other.payload);
9160
9161 /* Make sure that what we decoded is System Information Type 4 */
9162 if (si.header.message_type != SYSTEM_INFORMATION_TYPE_4) {
9163 setverdict(fail, "RSL FULL BCCH Information IE contains: ", si);
9164 repeat;
9165 }
9166
9167 /* Make sure that CBCH Channel Description IE is present */
9168 if (not ispresent(si.payload.si4.cbch_chan_desc)) {
9169 setverdict(fail, "CBCH Channel Description IE is absent");
9170 break;
9171 }
9172
9173 /* Finally, check the hopping parameters (HSN, MAIO) */
9174 var ChannelDescription chan_desc := si.payload.si4.cbch_chan_desc.v;
9175 f_TC_fh_params_match_chan_desc(fhp, chan_desc);
9176
9177 /* 3GPP TS 44.018, section 9.1.36.2 "CBCH Mobile Allocation":
9178 * The CBCH Mobile Allocation IE *shall* be present if FH is enabled. */
9179 if (chan_desc.h and not ispresent(si.payload.si4.cbch_mobile_alloc)) {
9180 setverdict(fail, "FH enabled, but Mobile Allocation IE is absent");
9181 break;
9182 } else if (chan_desc.h and ispresent(si.payload.si4.cbch_mobile_alloc)) {
9183 f_TC_fh_params_match_ma(fhp, chan_desc.chan_nr.tn,
9184 si.payload.si4.cbch_mobile_alloc.v);
9185 }
9186 }
9187 [] IPA_RSL[0].receive { repeat; }
9188 [] T.timeout {
9189 setverdict(fail, "Timeout waiting for RSL BCCH INFOrmation (SI4)");
9190 }
9191 }
9192
9193 /* Disable frequency hopping */
9194 f_TC_fh_params_unset(fhp);
9195
Vadim Yanitskiy8bc46012020-09-06 12:38:01 +07009196 /* (Re)configure TS0 as CCCH+SDCCH4+CBCH and TS1 as TCH/F */
Vadim Yanitskiyca974032020-09-01 07:20:39 +07009197 f_vty_enter_cfg_trx(BSCVTY, trx := 0);
9198
9199 f_vty_transceive(BSCVTY, "timeslot 0");
Vadim Yanitskiy8bc46012020-09-06 12:38:01 +07009200 f_vty_transceive(BSCVTY, "phys_chan_config ccch+sdcch4+cbch");
Vadim Yanitskiyca974032020-09-01 07:20:39 +07009201 f_vty_transceive(BSCVTY, "exit"); /* go back */
9202
9203 f_vty_transceive(BSCVTY, "timeslot 1");
9204 f_vty_transceive(BSCVTY, "phys_chan_config tch/f");
9205 f_vty_transceive(BSCVTY, "end"); /* we're done */
9206
Vadim Yanitskiy21726312020-09-04 01:45:36 +07009207 f_shutdown_helper();
Vadim Yanitskiyca974032020-09-01 07:20:39 +07009208}
9209
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02009210template (value) PDU_BSSAP_LE ts_BSSMAP_LE_BSSLAP(template (value) BSSLAP_PDU bsslap)
9211 := ts_BSSMAP_LE_ConnInfo(BSSMAP_LE_PROT_BSSLAP, data := enc_BSSLAP_PDU(valueof(bsslap)));
9212
9213private function f_match_bsslap(PDU_BSSAP_LE got_bsslap_msg,
9214 template (present) BSSLAP_PDU expect_bsslap)
9215{
9216 var BSSLAP_PDU bsslap := dec_BSSLAP_PDU(got_bsslap_msg.pdu.bssmap.co_info.bsslap_apdu.data);
9217 if (not match(bsslap, expect_bsslap)) {
9218 log("EXPECTING BSSLAP: ", expect_bsslap);
9219 log("GOT BSSLAP: ", bsslap);
9220 setverdict(fail, "BSSLAP is not as expected");
9221 mtc.stop;
9222 }
9223 setverdict(pass);
9224}
9225
9226/* GAD: this is an Ellipsoid point with uncertainty circle, encoded as in 3GPP TS 23.032 §7.3.2. */
9227const octetstring gad_ell_point_unc_circle := '10b0646d0d5f6627'O;
9228
9229private function f_expect_bsslap(template (present) BSSLAP_PDU expect_rx_bsslap) runs on MSC_ConnHdlr {
9230 var PDU_BSSAP_LE rx_bsslap;
9231 BSSAP_LE.receive(tr_BSSMAP_LE_ConnInfo(BSSMAP_LE_PROT_BSSLAP, ?)) -> value(rx_bsslap);
9232 f_match_bsslap(rx_bsslap, expect_rx_bsslap);
9233}
9234
9235/* With an active lchan, start BSSMAP Perform Location Request on A interface, starting BSSMAP-LE Perform Location
9236 * Request on Lb interface. Either with or without the SMLC doing a BSSLAP TA Request. */
9237private function f_lcs_loc_req_for_active_ms(boolean do_ta_request := false) runs on MSC_ConnHdlr {
9238 f_sleep(1.0);
9239
9240 f_establish_fully(omit, omit);
9241 f_bssap_le_register_imsi(g_pars.imsi, omit);
9242
9243 BSSAP.send(valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
9244 ts_CellId_CGI('262'H, '42'H, 23, 42))));
9245
9246 var PDU_BSSAP_LE plr;
9247 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
9248
9249 if (not do_ta_request) {
9250 /* verify TA Layer 3 in APDU. First the APDU type (BSSLAP), then the BSSLAP data contents. */
9251 var template BSSMAP_LE_IE_APDU expect_apdu := tr_BSSMAP_LE_APDU(BSSMAP_LE_PROT_BSSLAP, ?);
9252 if (not match(plr.pdu.bssmap.perf_loc_req.bsslap_apdu, expect_apdu)) {
9253 log("EXPECTING BSSMAP-LE APDU IE ", expect_apdu);
9254 log("GOT BSSMAP-LE APDU IE ", plr.pdu.bssmap.perf_loc_req.bsslap_apdu);
9255 setverdict(fail, "BSSMAP-LE APDU IE is not as expected");
9256 mtc.stop;
9257 }
9258 var template BSSLAP_PDU expect_ta_layer3 := tr_BSSLAP_TA_Layer3(tr_BSSLAP_IE_TA(0));
9259 var BSSLAP_PDU bsslap := dec_BSSLAP_PDU(plr.pdu.bssmap.perf_loc_req.bsslap_apdu.data);
9260 if (not match(bsslap, expect_ta_layer3)) {
9261 log("EXPECTING BSSLAP TA Layer 3: ", expect_ta_layer3);
9262 log("GOT BSSLAP: ", bsslap);
9263 setverdict(fail, "BSSLAP is not as expected");
9264 mtc.stop;
9265 }
9266 /* OsmoBSC directly sent the TA as BSSLAP APDU in the BSSMAP-LE Perform Location Request to the SMLC. The SMLC
9267 * has no need to request the TA from the BSC and directly responds. */
9268 } else {
9269 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
9270 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
9271 f_expect_bsslap(tr_BSSLAP_TA_Resp(?, ?));
9272 }
9273
9274 /* SMLC got the TA from the BSC, now responds with geo information data. */
9275 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(gad_ell_point_unc_circle, omit));
9276 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
9277 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(tr_BSSMAP_IE_LocationEstimate(gad_ell_point_unc_circle)));
9278
9279 /* The LCS was using an active A-interface conn. It should still remain active after this. */
9280 f_mo_l3_transceive();
9281
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02009282 f_perform_clear();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02009283
9284 f_sleep(2.0);
9285 setverdict(pass);
9286}
9287
9288/* With an active lchan, start BSSMAP Perform Location Request on A interface, starting BSSMAP-LE Perform Location
9289 * Request on Lb interface. Without the SMLC doing a BSSLAP TA Request. */
9290private function f_tc_lcs_loc_req_for_active_ms(charstring id) runs on MSC_ConnHdlr {
9291 f_lcs_loc_req_for_active_ms(false);
9292}
9293testcase TC_lcs_loc_req_for_active_ms() runs on test_CT {
9294 var MSC_ConnHdlr vc_conn;
9295 var TestHdlrParams pars := f_gen_test_hdlr_pars();
9296
9297 f_init(1, true);
9298 f_sleep(1.0);
9299 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_active_ms), pars);
9300 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01009301 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02009302}
9303
9304/* With an active lchan, start BSSMAP Perform Location Request on A interface, starting BSSMAP-LE Perform Location
9305 * Request on Lb interface. With the SMLC doing a BSSLAP TA Request. */
9306private function f_tc_lcs_loc_req_for_active_ms_ta_req(charstring id) runs on MSC_ConnHdlr {
9307 f_lcs_loc_req_for_active_ms(true);
9308}
9309testcase TC_lcs_loc_req_for_active_ms_ta_req() runs on test_CT {
9310 var MSC_ConnHdlr vc_conn;
9311 var TestHdlrParams pars := f_gen_test_hdlr_pars();
9312
9313 f_init(1, true);
9314 f_sleep(1.0);
9315 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_active_ms_ta_req), pars);
9316 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01009317 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02009318}
9319
9320/* Clear the A-interface conn only, without doing anything on Abis. Useful for LCS, for cases where there is only an A
9321 * conn without an active lchan. */
9322private function f_clear_A_conn() runs on MSC_ConnHdlr
9323{
9324 var BssmapCause cause := 0;
9325 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
9326 BSSAP.receive(tr_BSSMAP_ClearComplete);
9327 BSSAP.send(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_REQ);
9328
9329 timer no_more_bssap := 5.0;
9330 no_more_bssap.start;
9331 alt {
9332 [] no_more_bssap.timeout { break; }
9333 [] BSSAP.receive(tr_BSSAP_BSSMAP) {
9334 setverdict(fail, "Expected no more BSSAP after Clear Complete");
9335 mtc.stop;
9336 }
9337 }
9338 setverdict(pass);
9339}
9340
9341/* Verify that the A-interface connection is still working, and then clear it, without doing anything on Abis. Useful
9342 * for LCS, for cases where there is only an A conn without an active lchan. */
9343private function f_verify_active_A_conn_and_clear() runs on MSC_ConnHdlr
9344{
9345 f_logp(BSCVTY, "f_verify_active_A_conn_and_clear: test A link, then clear");
9346
9347 /* When an lchan is active, we can send some L3 data from the BTS side and verify that it shows up on the other
9348 * side towards the MSC. When there is no lchan, this is not possible. To probe whether the A-interface
9349 * connection is still up, we need something that echos back on the A-interface. Another LCS request! */
9350 BSSAP.send(valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
9351 ts_CellId_CGI('262'H, '42'H, 23, 42))));
9352 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?));
9353
9354 /* Right, the Perform Location Request showed up on Lb, now we can clear the A conn. */
9355 f_clear_A_conn();
9356 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocAbort(BSSMAP_LE_LCS_CAUSE_REQUEST_ABORTED));
9357 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
9358}
9359
9360/* With *no* active lchan, start BSSMAP Perform Location Request on A interface, starting BSSMAP-LE Perform Location
9361 * Request on Lb interface. BSC will Page for the subscriber as soon as we (virtual SMLC) request the TA via BSSLAP.
9362 */
9363private function f_tc_lcs_loc_req_for_idle_ms(charstring id) runs on MSC_ConnHdlr {
9364 f_sleep(1.0);
9365
9366 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
9367 f_bssap_le_register_imsi(g_pars.imsi, omit);
9368
9369 /* Register to receive the Paging Command */
9370 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
9371 g_chan_nr := new_chan_nr;
9372 f_rslem_register(0, g_chan_nr);
9373
9374 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
9375 valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
9376 ts_CellId_CGI('001'H, '01'H, 1, 0)))));
9377 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
9378
9379 var PDU_BSSAP_LE plr;
9380 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
9381
9382 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
9383 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
9384
9385 /* OsmoBSC needs to Page */
9386 RSL.receive(tr_RSL_PAGING_CMD(tr_MI_IMSI(g_pars.imsi)));
9387 f_logp(BSCVTY, "got Paging Command");
9388
9389 /* MS requests channel. Since the Paging was for LCS, the Paging Response does not trigger a Complete Layer 3 to
9390 * the MSC, and releases the lchan directly. */
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02009391 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);
9392 f_expect_lchan_rel(RSL, RSL_PROC);
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02009393
9394 /* From the Paging Response, the TA is now known to the BSC, and it responds to the SMLC. */
9395
9396 f_expect_bsslap(tr_BSSLAP_TA_Resp(?, ?));
9397
9398 /* SMLC got the TA from the BSC, now responds with geo information data. */
9399 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(gad_ell_point_unc_circle, omit));
9400 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
9401
9402 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(tr_BSSMAP_IE_LocationEstimate(gad_ell_point_unc_circle)));
9403
9404 /* The lchan is gone, the A-interface conn was created for the LCS only.
9405 * Still it is clearly the MSC's job to decide whether to tear down the conn or not. */
9406 f_verify_active_A_conn_and_clear();
9407
9408 f_sleep(2.0);
9409 setverdict(pass);
9410}
9411testcase TC_lcs_loc_req_for_idle_ms() runs on test_CT {
9412 var MSC_ConnHdlr vc_conn;
9413 var TestHdlrParams pars := f_gen_test_hdlr_pars();
9414
9415 f_init(1, true);
9416 f_sleep(1.0);
9417
9418 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
9419 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
9420
9421 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_idle_ms), pars);
9422 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01009423 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02009424}
9425
9426/* With no active lchan, start BSSMAP Perform Location Request on A interface, but omit IMSI; expect failure response.
9427 */
9428private function f_tc_lcs_loc_req_no_subscriber(charstring id) runs on MSC_ConnHdlr {
9429 f_sleep(1.0);
9430
9431 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
9432 f_bssap_le_register_imsi(g_pars.imsi, omit);
9433
9434 /* provoke an abort by omitting both IMSI and IMEI */
9435 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
9436 valueof(ts_BSSMAP_Perform_Location_Request(omit,
9437 ts_CellId_CGI('262'H, '42'H, 23, 42)))));
9438 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
9439
9440 /* BSC tells MSC about failure */
9441 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(
9442 locationEstimate := omit, positioningData := omit,
9443 lCS_Cause := tr_BSSMAP_LcsCause(BSSMAP_LCS_CAUSE_DATA_MISSING_IN_REQ)));
9444
9445 /* There is no lchan. Still the MSC's job to decide whether to tear down the conn or not. */
9446 f_verify_active_A_conn_and_clear();
9447
9448 f_sleep(2.0);
9449 setverdict(pass);
9450}
9451testcase TC_lcs_loc_req_no_subscriber() runs on test_CT {
9452 var MSC_ConnHdlr vc_conn;
9453 var TestHdlrParams pars := f_gen_test_hdlr_pars();
9454
9455 f_init(1, true);
9456 f_sleep(1.0);
9457
9458 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
9459 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
9460
9461 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_no_subscriber), pars);
9462 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01009463 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02009464}
9465
9466/* With an active lchan, start a Perform Location Request on the A-interface, but virtual SMLC does not answer with
9467 * BSSMAP-LE Perform Location Response (before or after sending a BSSLAP TA Request) */
9468private function f_lcs_loc_req_for_active_ms_le_timeout(boolean do_ta) runs on MSC_ConnHdlr {
9469 f_sleep(1.0);
9470
9471 f_establish_fully(omit, omit);
9472 f_bssap_le_register_imsi(g_pars.imsi, omit);
9473
9474 BSSAP.send(valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
9475 ts_CellId_CGI('262'H, '42'H, 23, 42))));
9476
9477 var PDU_BSSAP_LE plr;
9478 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
9479
9480 if (do_ta) {
9481 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
9482 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
9483 f_expect_bsslap(tr_BSSLAP_TA_Resp(?, ?));
9484 }
9485
9486 /* SMLC fails to respond, BSC runs into timeout */
9487 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocAbort(BSSMAP_LE_LCS_CAUSE_SYSTEM_FAILURE));
9488 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
9489
9490 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(
9491 locationEstimate := omit, positioningData := omit,
9492 lCS_Cause := tr_BSSMAP_LcsCause(BSSMAP_LCS_CAUSE_SYSTEM_FAILURE)));
9493
9494 /* There is no lchan. Still the MSC's job to decide whether to tear down the conn or not. */
9495 f_verify_active_A_conn_and_clear();
9496
9497 f_sleep(2.0);
9498 setverdict(pass);
9499}
9500
9501/* With an active lchan, start a Perform Location Request on the A-interface, but virtual SMLC does not answer with
9502 * BSSMAP-LE Perform Location Response, without sending a BSSLAP TA Request. */
9503private function f_tc_lcs_loc_req_for_active_ms_le_timeout(charstring id) runs on MSC_ConnHdlr {
9504 f_lcs_loc_req_for_active_ms_le_timeout(false);
9505}
9506
9507testcase TC_lcs_loc_req_for_active_ms_le_timeout() runs on test_CT {
9508 var MSC_ConnHdlr vc_conn;
9509 var TestHdlrParams pars := f_gen_test_hdlr_pars();
9510
9511 f_init(1, true);
9512 f_sleep(1.0);
9513 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_active_ms_le_timeout), pars);
9514 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01009515 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02009516}
9517
9518/* With an active lchan, start a Perform Location Request on the A-interface, but virtual SMLC does not answer with
9519 * BSSMAP-LE Perform Location Response, after sending a BSSLAP TA Request. */
9520private function f_tc_lcs_loc_req_for_active_ms_le_timeout2(charstring id) runs on MSC_ConnHdlr {
9521 f_lcs_loc_req_for_active_ms_le_timeout(true);
9522}
9523
9524testcase TC_lcs_loc_req_for_active_ms_le_timeout2() runs on test_CT {
9525 var MSC_ConnHdlr vc_conn;
9526 var TestHdlrParams pars := f_gen_test_hdlr_pars();
9527
9528 f_init(1, true);
9529 f_sleep(1.0);
9530 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_active_ms_le_timeout2), pars);
9531 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01009532 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02009533}
9534
9535/* With *no* active lchan, start a Perform Location Request, expecting that the MS will be Paged. */
9536private function f_tc_lcs_loc_req_for_idle_ms_no_pag_resp(charstring id) runs on MSC_ConnHdlr {
9537 f_sleep(1.0);
9538
9539 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
9540 f_bssap_le_register_imsi(g_pars.imsi, omit);
9541
9542 /* Register to receive the Paging Command */
9543 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
9544 g_chan_nr := new_chan_nr;
9545 f_rslem_register(0, g_chan_nr);
9546
9547 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
9548 valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
9549 ts_CellId_CGI('001'H, '01'H, 1, 0)))));
9550 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
9551
9552 var PDU_BSSAP_LE plr;
9553 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
9554
9555 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
9556 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
9557
9558 /* OsmoBSC needs to Page */
9559 var PDU_BSSAP_LE rx_bsslap;
9560 alt {
9561 [] RSL.receive(tr_RSL_PAGING_CMD(tr_MI_IMSI(g_pars.imsi))) {
9562 f_logp(BSCVTY, "got Paging Command");
9563 repeat;
9564 }
9565 [] BSSAP_LE.receive(tr_BSSMAP_LE_ConnInfo(BSSMAP_LE_PROT_BSSLAP, ?)) -> value(rx_bsslap) {
9566 /* MS does not respond to Paging, TA Req runs into timeout. */
9567 f_match_bsslap(rx_bsslap, tr_BSSLAP_Abort(?));
9568 }
9569 }
9570
9571 /* SMLC responds with failure */
9572 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(omit, BSSMAP_LE_LCS_CAUSE_REQUEST_ABORTED));
9573 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
9574
9575 /* BSC tells MSC about failure */
9576 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(
9577 locationEstimate := omit, positioningData := omit,
9578 lCS_Cause := tr_BSSMAP_LcsCause(BSSMAP_LCS_CAUSE_REQUEST_ABORTED)));
9579
9580 /* There is no lchan. Still the MSC's job to decide whether to tear down the conn or not. */
9581 f_verify_active_A_conn_and_clear();
9582
9583 f_sleep(2.0);
9584 setverdict(pass);
9585}
9586testcase TC_lcs_loc_req_for_idle_ms_no_pag_resp() runs on test_CT {
9587 var MSC_ConnHdlr vc_conn;
9588 var TestHdlrParams pars := f_gen_test_hdlr_pars();
9589
9590 f_init(1, true);
9591 f_sleep(1.0);
9592
9593 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
9594 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
9595
9596 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_idle_ms_no_pag_resp), pars);
9597 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01009598 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02009599}
9600
9601/* During an ongoing Location Request, the MS sends a CM Service Request. Expect the same A-conn to be re-used / taken
9602 * over. */
9603private function f_tc_cm_service_during_lcs_loc_req(charstring id) runs on MSC_ConnHdlr {
9604 f_sleep(1.0);
9605
9606 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
9607 f_bssap_le_register_imsi(g_pars.imsi, omit);
9608
9609 /* Register to receive the Paging Command */
9610 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
9611 g_chan_nr := new_chan_nr;
9612 f_rslem_register(0, g_chan_nr);
9613
9614 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
9615 valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
9616 ts_CellId_CGI('001'H, '01'H, 1, 0)))));
9617 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
9618
9619 var PDU_BSSAP_LE plr;
9620 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
9621
9622 /* As the A-interface conn was established for LCS, the MS coincidentally decides to issue a CM Service Request
9623 * and establish Layer 3. It should use the existing A-interface conn. */
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02009624 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 +02009625 do_clear := false, expect_bssmap_l3 := true);
9626
9627 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
9628 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
9629
9630 /* OsmoBSC already has an lchan, no need to Page, just returns the TA */
9631 f_expect_bsslap(tr_BSSLAP_TA_Resp(?, ?));
9632
9633 /* SMLC got the TA from the BSC, now responds with geo information data. */
9634 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(gad_ell_point_unc_circle, omit));
9635 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
9636 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(tr_BSSMAP_IE_LocationEstimate(gad_ell_point_unc_circle)));
9637
9638 /* The lchan should still exist, it was from a CM Service Request. */
9639 f_mo_l3_transceive();
9640
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02009641 f_perform_clear();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02009642
9643 f_sleep(2.0);
9644 setverdict(pass);
9645}
9646testcase TC_cm_service_during_lcs_loc_req() runs on test_CT {
9647 var MSC_ConnHdlr vc_conn;
9648 var TestHdlrParams pars := f_gen_test_hdlr_pars();
9649
9650 f_init(1, true);
9651 f_sleep(1.0);
9652
9653 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
9654 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
9655
9656 vc_conn := f_start_handler(refers(f_tc_cm_service_during_lcs_loc_req), pars);
9657 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01009658 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02009659}
9660
9661/* During an ongoing Perform Location Request, do a Handover, an expect a BSSLAP Reset message from the BSC to indicate
9662 * the new lchan after handover. */
9663private function f_tc_ho_during_lcs_loc_req(charstring id) runs on MSC_ConnHdlr {
9664 f_sleep(1.0);
9665
9666 f_establish_fully(omit, omit);
9667 f_bssap_le_register_imsi(g_pars.imsi, omit);
9668
9669 BSSAP.send(valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
9670 ts_CellId_CGI('262'H, '42'H, 23, 42))));
9671
9672 var PDU_BSSAP_LE plr;
9673 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
9674
9675 /* SMLC ponders the Location Request, in the meantime the BSC decides to handover */
9676 f_bts_0_cfg(BSCVTY, {"neighbor bts 1"});
9677
9678 var HandoverState hs := {
9679 rr_ho_cmpl_seen := false,
9680 handover_done := false,
Neels Hofmeyrc741fcb2021-10-02 14:52:28 +02009681 old_chan_nr := -,
9682 expect_target_tsc := BTS_TSC[1]
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02009683 };
9684 /* issue hand-over command on VTY */
9685 f_vty_handover(BSCVTY, 0, 0, g_chan_nr, 1);
9686 /* temporarily suspend DChan processing on BTS1 to avoid race with RSLEM_register */
9687 f_rslem_suspend(RSL1_PROC);
9688
9689 /* From the MGW perspective, a handover is is characterized by
9690 * performing one MDCX operation with the MGW. So we expect to see
9691 * one more MDCX during handover. */
9692 g_media.mgcp_conn[0].mdcx_seen_exp := g_media.mgcp_conn[0].crcx_seen_exp + 1;
9693
9694 alt {
9695 [] as_handover(hs);
9696 }
9697
9698 var PDU_BSSAP_LE rx_bsslap;
9699
9700 interleave {
9701 /* Expect the BSC to inform the MSC about the handover */
9702 [] BSSAP.receive(tr_BSSMAP_HandoverPerformed);
9703
9704 /* Expect the BSC to inform the SMLC about the handover */
9705 [] BSSAP_LE.receive(tr_BSSMAP_LE_ConnInfo(BSSMAP_LE_PROT_BSSLAP, ?)) -> value(rx_bsslap) {
9706 f_match_bsslap(rx_bsslap, tr_BSSLAP_Reset(BSSLAP_CAUSE_INTRA_BSS_HO));
9707 }
9708 }
9709
9710 /* SMLC now responds with geo information data. */
9711 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(gad_ell_point_unc_circle, omit));
9712 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
9713 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(tr_BSSMAP_IE_LocationEstimate(gad_ell_point_unc_circle)));
9714
9715 /* lchan still active */
9716 f_mo_l3_transceive(RSL1);
9717
9718 /* MSC decides it is done now. */
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02009719 f_perform_clear(RSL1, RSL1_PROC);
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02009720
9721 f_sleep(2.0);
9722 setverdict(pass);
9723}
9724testcase TC_ho_during_lcs_loc_req() runs on test_CT {
9725 var MSC_ConnHdlr vc_conn;
9726 var TestHdlrParams pars := f_gen_test_hdlr_pars();
9727
9728 f_init(2, true);
9729 f_sleep(1.0);
9730 vc_conn := f_start_handler(refers(f_tc_ho_during_lcs_loc_req), pars);
9731 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01009732 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02009733}
9734
Neels Hofmeyrbf037052020-10-28 22:52:02 +00009735/* Attempt Complete Layer 3 without any MSC available (OS#4832) */
9736private function f_tc_no_msc(charstring id) runs on MSC_ConnHdlr {
9737 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
9738
9739 /* Also disable attach for the single connected MSC */
9740 f_vty_msc_allow_attach(BSCVTY, { false });
9741
9742 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) ));
9743 f_chan_est(g_pars.ra, l3_enc, g_pars.link_id, g_pars.fn);
9744
9745 /* No MSC is found, expecting a proper release on RSL */
9746 interleave {
9747 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
9748 f_logp(BSCVTY, "Got RSL RR Release");
9749 }
9750 [] RSL.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
9751 f_logp(BSCVTY, "Got RSL Deact SACCH");
9752 }
Neels Hofmeyr3c5127e2021-07-22 19:18:40 +02009753 [] RSL.receive(tr_RSL_RF_CHAN_REL(g_chan_nr)) {
Neels Hofmeyrbf037052020-10-28 22:52:02 +00009754 f_logp(BSCVTY, "Got RSL RF Chan Rel, sending Rel Ack");
9755 RSL.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
Neels Hofmeyre680b012021-07-22 19:19:09 +02009756 f_rslem_unregister(0, g_chan_nr);
Neels Hofmeyrbf037052020-10-28 22:52:02 +00009757 }
9758 }
9759 setverdict(pass);
9760}
9761testcase TC_no_msc() runs on test_CT {
9762
9763 f_init(1, true);
9764 f_sleep(1.0);
9765 var MSC_ConnHdlr vc_conn;
9766 var TestHdlrParams pars := f_gen_test_hdlr_pars();
9767
9768 f_ctrs_bsc_init(counternames_bsc_mscpool);
9769
9770 vc_conn := f_start_handler(refers(f_tc_no_msc), pars);
9771 vc_conn.done;
9772
9773 f_ctrs_bsc_add("mscpool:subscr:no_msc");
9774 f_ctrs_bsc_verify();
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01009775 f_shutdown_helper();
Neels Hofmeyrbf037052020-10-28 22:52:02 +00009776}
9777
Harald Welte0ea2d5e2018-04-07 21:40:29 +02009778/* Dyn PDCH todo:
9779 * activate OSMO as TCH/F
9780 * activate OSMO as TCH/H
9781 * does the BSC-located PCU socket get the updated INFO?
9782 * what if no PCU is connected at the time?
9783 * is the info correct on delayed PCU (re)connect?
9784 */
Harald Welte94e0c342018-04-07 11:33:23 +02009785
Neels Hofmeyr87857ec2021-04-25 16:17:47 +00009786private function f_TC_refuse_mode_modif_to_vamos(charstring id) runs on MSC_ConnHdlr {
9787 var PDU_BSSAP ass_cmd := f_gen_ass_req(g_pars.use_osmux);
9788 var template PDU_BSSAP exp_compl := f_gen_exp_compl(g_pars.use_osmux);
9789
9790 /* puzzle together the ASSIGNMENT REQ for given codec[s] */
9791 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
9792 ass_cmd.pdu.bssmap.assignmentRequest.codecList := g_pars.ass_codec_list;
9793 exp_compl.pdu.bssmap.assignmentComplete.speechCodec.codecElements[0] :=
9794 g_pars.ass_codec_list.codecElements[0];
9795 if (isvalue(g_pars.expect_mr_s0_s7)) {
9796 exp_compl.pdu.bssmap.assignmentComplete.speechCodec.codecElements[0].s0_7 :=
9797 g_pars.expect_mr_s0_s7;
9798 }
9799 }
9800 ass_cmd.pdu.bssmap.assignmentRequest.channelType :=
9801 f_BSSMAP_chtype_from_codec(g_pars.ass_codec_list.codecElements[0]);
9802 log("expecting ASS COMPL like this: ", exp_compl);
9803
9804 f_establish_fully(ass_cmd, exp_compl);
9805
Neels Hofmeyr8746b0d2021-06-01 17:25:39 +02009806 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 +00009807
9808 var RSL_Message rsl;
9809
9810 timer T := 5.0;
9811 T.start;
9812 alt {
9813 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr)) -> value rsl {
9814 var PDU_ML3_NW_MS l3 := dec_PDU_ML3_NW_MS(rsl.ies[2].body.l3_info.payload);
9815 log("Rx L3 from net: ", l3);
9816 if (ischosen(l3.msgs.rrm.channelModeModify)) {
9817 setverdict(fail, "Mode Modify to VAMOS succeeded even though BTS does not support VAMOS");
9818 mtc.stop;
9819 }
9820 }
9821 [] RSL.receive(tr_RSL_MODE_MODIFY_REQ(g_chan_nr, ?)) -> value rsl {
9822 setverdict(fail, "Mode Modify to VAMOS succeeded even though BTS does not support VAMOS");
9823 mtc.stop;
9824 }
9825 [] T.timeout {
9826 /* The BTS does not exhibit BTS_FEAT_VAMOS, so no VAMOS related Mode Modify should happen. */
9827 setverdict(pass);
9828 }
9829 }
9830 T.stop;
9831}
9832
9833/* The BSC does *not* indicate BTS_FEAT_VAMOS; make sure that a channel Mode Modify to VAMOS mode is refused by
9834 * osmo-bsc. */
9835testcase TC_refuse_mode_modif_to_vamos() runs on test_CT {
9836 var TestHdlrParams pars := f_gen_test_hdlr_pars();
9837 var MSC_ConnHdlr vc_conn;
9838
9839 f_init(1, true);
9840 f_sleep(1.0);
9841
9842 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
9843 vc_conn := f_start_handler(refers(f_TC_refuse_mode_modif_to_vamos), pars);
9844 vc_conn.done;
9845 f_shutdown_helper();
9846}
9847
9848/* The BSC does *not* indicate BTS_FEAT_VAMOS; make sure that a channel activation to VAMOS mode is refused by osmo-bsc.
9849 */
9850testcase TC_refuse_chan_act_to_vamos() runs on test_CT {
9851 f_init_vty();
9852
9853 f_init(1, false);
9854 f_sleep(1.0);
9855
9856 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 1 sub-slot 0 activate-vamos fr");
9857
9858 var ASP_RSL_Unitdata rx_rsl_ud;
9859 timer T := 5.0;
9860
9861 T.start;
9862 alt {
9863 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(?, IPAC_PROTO_RSL_TRX0)) -> value rx_rsl_ud {
9864 if (rx_rsl_ud.rsl.msg_type == RSL_MT_CHAN_ACTIV) {
9865 T.stop;
9866 setverdict(fail, "CHANnel ACTivate in VAMOS mode succeeded even though BTS does not support VAMOS");
9867 mtc.stop;
9868 }
9869 repeat;
9870 }
9871 [] T.timeout {
9872 /* The BTS does not exhibit BTS_FEAT_VAMOS, so no VAMOS related CHANnel ACTivate should happen. */
9873 setverdict(pass);
9874 }
9875 }
9876}
9877
Neels Hofmeyrd2d9f332021-04-28 22:23:36 +00009878private function f_TC_reassignment_codec(charstring id) runs on MSC_ConnHdlr {
9879 /* First fully set up a speech lchan */
9880 f_TC_assignment_codec(id);
9881
9882 /* Trigger re-assignment to another lchan */
9883 var AssignmentState assignment_st := valueof(ts_AssignmentStateInit);
9884
9885 /* Re-Assignment should tell the MGW endpoint the new lchan's RTP address and port, so expecting to see exactly
9886 * one MDCX on MGCP. */
9887 g_media.mgcp_conn[0].mdcx_seen_exp := g_media.mgcp_conn[0].mdcx_seen_exp + 1;
9888
9889 /* The new lchan will see all-new IPAC_CRCX and IPAC_MDCX messages telling the BTS the same RTP address and port
9890 * as the old lchan used. */
9891 g_media.bts.ipa_crcx_seen := false;
9892 g_media.bts.ipa_mdcx_seen := false;
9893
9894 /* Send different BTS side RTP port number for the new lchan */
9895 g_media.bts.bts.port_nr := 4223;
9896
9897 f_rslem_register(0, valueof(ts_RslChanNr_Bm(2))); /* <-- FIXME: can we somehow infer the timeslot that will be used? */
9898
9899 /* Trigger re-assignment. */
9900 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot " & int2str(g_chan_nr.tn) & " sub-slot 0 assignment");
9901
9902 timer T := 5.0;
9903 T.start;
9904 alt {
9905 [] as_assignment(assignment_st);
9906 [] as_Media();
9907 [] T.timeout {
9908 break;
9909 }
9910 }
9911
9912 if (not assignment_st.assignment_done) {
9913 setverdict(fail, "Assignment did not complete");
9914 mtc.stop;
9915 }
9916
9917 f_check_mgcp_expectations()
9918 setverdict(pass);
9919
9920 f_sleep(2.0);
9921 log("show lchan summary: ", f_vty_transceive_ret(BSCVTY, "show lchan summary"));
9922
9923 /* Instruct BSC to clear channel */
9924 var BssmapCause cause := 0;
9925 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
9926 interleave {
Neels Hofmeyrd2d9f332021-04-28 22:23:36 +00009927 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {}
9928 [] RSL.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {}
Neels Hofmeyr3c5127e2021-07-22 19:18:40 +02009929 [] RSL.receive(tr_RSL_RF_CHAN_REL(g_chan_nr)) {
Neels Hofmeyrd2d9f332021-04-28 22:23:36 +00009930 RSL.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
Neels Hofmeyre680b012021-07-22 19:19:09 +02009931 f_rslem_unregister(0, g_chan_nr);
Neels Hofmeyrd2d9f332021-04-28 22:23:36 +00009932 }
9933 [] BSSAP.receive(tr_BSSMAP_ClearComplete) {
9934 BSSAP.send(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_REQ);
9935 }
9936 }
Neels Hofmeyr40a45d12021-09-23 22:57:12 +02009937 f_expect_dlcx_conns();
Neels Hofmeyrd2d9f332021-04-28 22:23:36 +00009938
9939 f_sleep(0.5);
9940}
9941
9942testcase TC_reassignment_fr() runs on test_CT {
9943 var TestHdlrParams pars := f_gen_test_hdlr_pars();
9944 var MSC_ConnHdlr vc_conn;
9945
9946 f_init(1, true);
9947 f_sleep(1.0);
9948
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01009949 f_ctrs_bsc_and_bts_handover_init();
Neels Hofmeyrd2d9f332021-04-28 22:23:36 +00009950
9951 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
9952 vc_conn := f_start_handler(refers(f_TC_reassignment_codec), pars);
9953 vc_conn.done;
9954
9955 /* from f_establish_fully() */
9956 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
9957 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
9958 /* from re-assignment */
9959 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
9960 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
9961 f_ctrs_bsc_and_bts_verify();
9962 f_shutdown_helper();
9963}
9964
Neels Hofmeyrfeda88e2021-07-19 13:51:29 +02009965const charstring REEST_LOST_CONNECTION := "REEST_LOST_CONNECTION";
9966const charstring REEST_CLEAR := "REEST_CLEAR";
9967const charstring REEST_CLEAR_DONE := "REEST_CLEAR_DONE";
9968
9969/* CM Re-Establishment, 3GPP TS 24.008 4.5.1.6.
9970 * The MS <-> BTS loses radio connection, MS shows up on second BTS and asks for CM Re-Establishment.
9971 * BSC should establish a separate A conn for the same MS, the original A conn is then cleared by
9972 * the MSC as the CM Re-Establishment is handled.
9973 *
9974 * MS bts0 bts1 bsc msc test-component
9975 * |<----->|<----------------->|<-0-->| _1 Establish channel on bts 0
9976 * | | _1 wait a bit, to settle down
9977 * |<-x x--| | _1 "lose connection"
9978 * | | REEST_LOST_CONNECTION
9979 * |----------------->|------->|--1-->| _2 new A-conn: Chan Rqd, Imm Ass, Compl L3 with CM Re-Establishment Req
9980 * | | REEST_CLEAR
9981 * | |<-0---| _1 Clear Command on first A-conn
9982 * | |--0-->| _1 Clear Complete
9983 * | |<----------------->| | _1 Release first channel
9984 * | | REEST_CLEAR_DONE
9985 * |<-----------------|<-------|<-1---| _2 Chan Activ, Assignment Command
9986 * |<-----------------|<-------|<-1---| _2 Clear Command, Release
9987 *
9988 */
9989private function f_tc_cm_reestablishment_1(charstring id) runs on MSC_ConnHdlr {
9990 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
9991 var PDU_BSSAP ass_cmd := f_gen_ass_req();
9992
9993 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
9994 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
9995
9996 f_establish_fully(ass_cmd, exp_compl);
9997
9998 /* The original channel loses connection, MS attemts CM Re-Establishment on another cell, see
9999 * f_tc_cm_reestablishment_2(). This established channel stays active until MSC sends a Clear Command. The time
10000 * when exactly that happens is determined by f_tc_cm_reestablishment_2(). */
10001 f_sleep(2.0);
10002 COORD.send(REEST_LOST_CONNECTION);
10003
10004 alt {
10005 [] COORD.receive(REEST_CLEAR);
10006 [] RSL.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
10007 setverdict(fail, "Unexpected channel release");
10008 mtc.stop;
10009 }
10010 [] RSL.receive(tr_RSL_RF_CHAN_REL(g_chan_nr)) {
10011 setverdict(fail, "Unexpected channel release");
10012 mtc.stop;
10013 }
10014 }
10015 f_perform_clear()
10016 f_expect_dlcx_conns();
Neels Hofmeyr969abd02021-09-23 22:24:08 +020010017 f_create_mgcp_delete_ep(g_media.mgcp_ep);
Neels Hofmeyrfeda88e2021-07-19 13:51:29 +020010018 COORD.send(REEST_CLEAR_DONE);
10019}
10020
10021private function f_tc_cm_reestablishment_2(charstring id) runs on MSC_ConnHdlr {
10022 f_MscConnHdlr_init(g_pars.media_nr, host_bts, host_mgw_mgcp, FR_AMR);
10023
10024 /* The MS lost the connection on the first channel, now establishes another one */
10025 COORD.receive(REEST_LOST_CONNECTION);
10026
10027 var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi));
10028 var PDU_ML3_MS_NW l3_info := valueof(ts_CM_REESTABL_REQ(mi));
10029 var octetstring l3_enc := enc_PDU_ML3_MS_NW(l3_info);
10030
10031 f_create_bssmap_exp(l3_enc);
Neels Hofmeyrc7b1f6d2021-07-20 23:21:36 +020010032 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 +020010033 BSSAP.receive(tr_BSSMAP_ComplL3(l3_enc));
10034
10035 /* MSC got the CM Re-Establishment request and first off clears the previous conn. */
10036 COORD.send(REEST_CLEAR);
10037 COORD.receive(REEST_CLEAR_DONE);
10038
10039 f_sleep(2.0);
10040
10041 /* Answer the CM Re-Establishment with an Assignment Command. */
10042 var template PDU_BSSAP expect_assignment_compl := f_gen_exp_compl();
10043 var PDU_BSSAP ass_cmd := f_gen_ass_req();
10044 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
10045 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
10046
10047 var AssignmentState st := valueof(ts_AssignmentStateInit);
10048 st.voice_call := true;
10049 st.is_assignment := true;
10050
10051 var ExpectCriteria mgcpcrit := {
10052 connid := omit,
10053 endpoint := omit,
10054 transid := omit
10055 };
10056 f_create_mgcp_expect(mgcpcrit);
10057
Neels Hofmeyrc7b1f6d2021-07-20 23:21:36 +020010058 f_rslem_dchan_queue_enable(RSL1_PROC);
Neels Hofmeyrfeda88e2021-07-19 13:51:29 +020010059
10060 BSSAP.send(ass_cmd);
10061
10062 var PDU_BSSAP bssap;
10063
10064 alt {
Neels Hofmeyrc7b1f6d2021-07-20 23:21:36 +020010065 [] as_assignment(st, rsl_pt := RSL1, rsl_proc_pt := RSL1_PROC);
10066 [] as_Media_ipacc(RSL1, RSL2);
10067 [] as_Media_mgw();
Neels Hofmeyrfeda88e2021-07-19 13:51:29 +020010068 [st.assignment_done] BSSAP.receive(expect_assignment_compl) {
10069 break;
10070 }
10071 }
10072
10073 f_sleep(3.0);
10074
10075 f_logp(BSCVTY, "f_tc_cm_reestablishment_2 clearing");
Neels Hofmeyrc7b1f6d2021-07-20 23:21:36 +020010076 f_perform_clear(RSL1, RSL1_PROC);
Neels Hofmeyrfeda88e2021-07-19 13:51:29 +020010077 f_expect_dlcx_conns();
10078}
10079
10080testcase TC_cm_reestablishment() runs on test_CT {
10081 var TestHdlrParams pars1 := f_gen_test_hdlr_pars();
10082 var MSC_ConnHdlr vc_conn1;
10083
10084 var TestHdlrParams pars2 := f_gen_test_hdlr_pars();
10085 var MSC_ConnHdlr vc_conn2;
10086 pars2.imsi := pars1.imsi;
10087 pars2.media_nr := 2;
Neels Hofmeyrbf720202021-10-02 12:58:24 +020010088 pars2.expect_tsc := BTS_TSC[1];
Neels Hofmeyrfeda88e2021-07-19 13:51:29 +020010089
10090 f_init(2, true, guard_timeout := 40.0);
10091 f_sleep(1.0);
10092
10093 vc_conn1 := f_start_handler_create(pars1);
10094 vc_conn2 := f_start_handler_create(pars2);
10095 connect(vc_conn1:COORD, vc_conn2:COORD);
10096 f_start_handler_run(vc_conn1, refers(f_tc_cm_reestablishment_1), pars1);
10097 f_start_handler_run(vc_conn2, refers(f_tc_cm_reestablishment_2), pars2);
10098 vc_conn1.done;
10099 vc_conn2.done;
10100
10101 f_shutdown_helper();
10102}
Neels Hofmeyr87857ec2021-04-25 16:17:47 +000010103
Neels Hofmeyrb07b2952021-08-07 04:23:14 +020010104function f_exp_ipa_rx_nonfatal(integer bts_nr, template (present) RSL_Message t_rx, float t_secs := 2.0,
10105 IpaStreamId sid := IPAC_PROTO_RSL_TRX0, boolean ignore_other_rx := true)
10106runs on test_CT return template (omit) RSL_Message {
10107 var ASP_RSL_Unitdata rx_rsl_ud;
10108 timer T := t_secs;
10109
10110 T.start;
10111 alt {
10112 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(t_rx, sid)) -> value rx_rsl_ud {
10113 T.stop;
10114 }
10115 [ignore_other_rx] IPA_RSL[bts_nr].receive { repeat; }
10116 [not ignore_other_rx] IPA_RSL[bts_nr].receive {
10117 log("f_exp_ipa_rx_nonfatal(): Got different message than ", t_rx);
10118 T.stop;
10119 return omit;
10120 }
10121 [] T.timeout {
10122 return omit;
10123 }
10124 }
10125 return rx_rsl_ud.rsl;
10126}
10127
10128private function f_vty_set_imm_ass(TELNETasp_PT pt, BtsNr bts_nr := 0, charstring imm_ass_setting := "post-chan-ack") {
10129 f_vty_enter_cfg_bts(pt, bts_nr);
10130 f_vty_transceive(pt, "immediate-assignment " & imm_ass_setting);
10131 f_vty_transceive(pt, "exit");
10132 f_vty_transceive(pt, "exit");
10133 f_vty_transceive(pt, "exit");
10134}
10135
10136private function f_verify_imm_ass(RSL_Message imm_ass, template uint8_t ra := ?, template GsmFrameNumber fn := ?,
Neels Hofmeyr07603cf2021-09-07 19:05:52 +020010137 template RslChannelNr chan_nr := ?,
10138 template (present) uint12_t arfcn := ?,
10139 template (present) uint3_t tsc := ?)
Neels Hofmeyrb07b2952021-08-07 04:23:14 +020010140{
10141 var RSL_IE_Body full_imm_ass_info;
10142 if (not f_rsl_find_ie(imm_ass, RSL_IE_FULL_IMM_ASS_INFO, full_imm_ass_info)) {
10143 setverdict(fail, "RSL Full Immediate Assign Info IE is absent");
10144 mtc.stop;
10145 }
10146
10147 var GsmRrMessage rr_imm_ass := dec_GsmRrMessage(full_imm_ass_info.full_imm_ass_info.payload);
10148 var template GsmRrMessage expect_imm_ass := tr_IMM_ASS(ra := ra,
10149 fn := fn,
Neels Hofmeyr07603cf2021-09-07 19:05:52 +020010150 ch_desc := tr_ChanDescH0(chan_nr, arfcn, tsc),
Neels Hofmeyrb07b2952021-08-07 04:23:14 +020010151 page_mode := ?);
10152 if (not match(rr_imm_ass, expect_imm_ass)) {
10153 log("Error: expected ", expect_imm_ass, " got ", rr_imm_ass);
10154 setverdict(fail, "Failed to match Immediate Assignment");
10155 mtc.stop;
10156 }
10157}
10158
10159testcase TC_imm_ass_post_chan_ack() runs on test_CT {
10160 var RSL_Message chan_act;
10161 var RSL_Message imm_ass;
10162
10163 f_init(1, false);
10164 f_sleep(1.0);
10165
10166 /* (should be the default anyway, just to make things clear) */
10167 f_vty_set_imm_ass(BSCVTY, 0, "post-chan-ack");
10168
10169 /* RA containing reason=LU */
10170 var GsmFrameNumber fn := 2342;
10171 var uint8_t ra := 2;
10172 f_ipa_tx(0, ts_RSL_CHAN_RQD(int2oct(ra, 1), fn));
10173
10174 chan_act := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
10175
10176 /* First send the Chan Act ACK */
10177 var RslChannelNr chan_nr := chan_act.ies[0].body.chan_nr;
Neels Hofmeyr07603cf2021-09-07 19:05:52 +020010178 var RSL_IE_Body chan_ident_ie;
10179 if (not f_rsl_find_ie(chan_act, RSL_IE_CHAN_IDENT, chan_ident_ie)) {
10180 setverdict(fail, "RSL Channel Identification IE is absent");
10181 mtc.stop;
10182 }
10183
Neels Hofmeyrb07b2952021-08-07 04:23:14 +020010184 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, fn + 10));
10185
10186 /* Then expect the Immediate Assignment, after we ACKed the chan act */
10187 imm_ass := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
10188
Neels Hofmeyr07603cf2021-09-07 19:05:52 +020010189 f_verify_imm_ass(imm_ass, ra, fn, chan_nr, chan_ident_ie.chan_ident.ch_desc.v.arfcn,
10190 chan_ident_ie.chan_ident.ch_desc.v.tsc);
Neels Hofmeyrb07b2952021-08-07 04:23:14 +020010191
10192 /* Check that the lchan is working */
10193 var octetstring l3 := '00010203040506'O;
10194 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
10195
10196 var BSSAP_N_CONNECT_ind rx_c_ind;
10197 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
10198 BSSAP.send(ts_BSSAP_CONNECT_res(rx_c_ind.connectionId));
10199
10200 f_sleep(1.0);
10201 f_shutdown_helper();
10202}
10203
10204testcase TC_imm_ass_pre_chan_ack() runs on test_CT {
10205 var RSL_Message chan_act;
10206 var RSL_Message imm_ass;
10207
10208 f_init(1, false);
10209 f_sleep(1.0);
10210
10211 f_vty_set_imm_ass(BSCVTY, 0, "pre-chan-ack");
10212
10213 /* RA containing reason=LU */
10214 var GsmFrameNumber fn := 2342;
10215 var uint8_t ra := 2;
10216 f_ipa_tx(0, ts_RSL_CHAN_RQD(int2oct(ra, 1), fn));
10217
10218 /* (set bts 0 cfg back to default) */
10219 f_vty_set_imm_ass(BSCVTY);
10220
10221 chan_act := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
10222 var RslChannelNr chan_nr := chan_act.ies[0].body.chan_nr;
Neels Hofmeyr07603cf2021-09-07 19:05:52 +020010223 var RSL_IE_Body chan_ident_ie;
10224 if (not f_rsl_find_ie(chan_act, RSL_IE_CHAN_IDENT, chan_ident_ie)) {
10225 setverdict(fail, "RSL Channel Identification IE is absent");
10226 mtc.stop;
10227 }
Neels Hofmeyrb07b2952021-08-07 04:23:14 +020010228
10229 /* *FIRST* expect the Immediate Assignment, before we ACK the chan act */
10230 imm_ass := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
Neels Hofmeyr07603cf2021-09-07 19:05:52 +020010231 f_verify_imm_ass(imm_ass, ra, fn, chan_nr, chan_ident_ie.chan_ident.ch_desc.v.arfcn,
10232 chan_ident_ie.chan_ident.ch_desc.v.tsc);
Neels Hofmeyrb07b2952021-08-07 04:23:14 +020010233
10234 /* Only now send the Chan Act ACK */
10235 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, fn+10));
10236
10237 /* Check that the lchan is working */
10238 var octetstring l3 := '00010203040506'O;
10239 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
10240
10241 var BSSAP_N_CONNECT_ind rx_c_ind;
10242 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
10243 BSSAP.send(ts_BSSAP_CONNECT_res(rx_c_ind.connectionId));
10244
10245 f_sleep(1.0);
10246 f_shutdown_helper();
10247}
10248
Neels Hofmeyr23158742021-09-07 19:08:07 +020010249testcase TC_imm_ass_pre_ts_ack() runs on test_CT {
10250 var RSL_Message chan_act;
10251 var RSL_Message imm_ass;
10252
10253 f_init(1, false);
10254 f_sleep(1.0);
10255
10256 f_vty_set_imm_ass(BSCVTY, 0, "pre-ts-ack");
10257
10258 /* RA containing reason=LU */
10259 var GsmFrameNumber fn := 2342;
10260 var uint8_t ra := 2;
10261 f_ipa_tx(0, ts_RSL_CHAN_RQD(int2oct(ra, 1), fn));
10262
10263 /* (set bts 0 cfg back to default) */
10264 f_vty_set_imm_ass(BSCVTY);
10265
10266 chan_act := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
10267 var RslChannelNr chan_nr := chan_act.ies[0].body.chan_nr;
10268 var RSL_IE_Body chan_ident_ie;
10269 if (not f_rsl_find_ie(chan_act, RSL_IE_CHAN_IDENT, chan_ident_ie)) {
10270 setverdict(fail, "RSL Channel Identification IE is absent");
10271 mtc.stop;
10272 }
10273
10274 /* *FIRST* expect the Immediate Assignment, before we ACK the chan act */
10275 imm_ass := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
10276 f_verify_imm_ass(imm_ass, ra, fn, chan_nr, chan_ident_ie.chan_ident.ch_desc.v.arfcn,
10277 chan_ident_ie.chan_ident.ch_desc.v.tsc);
10278
10279 /* Only now send the Chan Act ACK */
10280 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, fn+10));
10281
10282 /* Check that the lchan is working */
10283 var octetstring l3 := '00010203040506'O;
10284 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
10285
10286 var BSSAP_N_CONNECT_ind rx_c_ind;
10287 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
10288 BSSAP.send(ts_BSSAP_CONNECT_res(rx_c_ind.connectionId));
10289
10290 f_sleep(1.0);
10291 f_shutdown_helper();
10292}
10293
Neels Hofmeyr7a6d0602021-08-07 04:23:50 +020010294testcase TC_imm_ass_pre_chan_ack_dyn_ts() runs on test_CT {
10295 /* change Timeslot 6 before f_init() starts RSL */
10296 f_init_vty();
10297 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_PDCH");
10298 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
10299
10300 f_init(1, false);
10301 f_sleep(1.0);
10302
10303 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(6));
10304 /* The BSC will activate the dynamic PDCH by default, so confirm that */
10305 f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
10306 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2323));
10307
10308 /* clean up timeslot 6 config, will only take effect when the OML drops the next time */
10309 f_ts_set_chcomb(0, 0, 6, "PDCH");
10310
10311 /* block all static timeslots so that the dyn TS will be used */
10312 f_disable_all_tch_f();
10313 f_disable_all_tch_h();
10314 f_disable_all_sdcch();
10315
10316 var RSL_Message chan_act;
10317 var RSL_Message imm_ass;
10318
10319 f_init(1, false);
10320 f_sleep(1.0);
10321
10322 f_vty_set_imm_ass(BSCVTY, 0, "pre-chan-ack");
10323
10324 /* RA containing reason=LU */
10325 var GsmFrameNumber fn := 2342;
10326 var uint8_t ra := 2;
10327 f_ipa_tx(0, ts_RSL_CHAN_RQD(int2oct(ra, 1), fn));
10328
10329 /* (set bts 0 cfg back to default) */
10330 f_vty_set_imm_ass(BSCVTY);
10331
10332 /* Expect the dyn TS to deactivate PDCH first */
10333 f_exp_ipa_rx(0, tr_RSL_RF_CHAN_REL(chan_nr));
10334 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(chan_nr));
10335
10336 /* Now activation as SDCCH8 */
10337 chan_nr := valueof(t_RslChanNr_SDCCH8(tn := 6, sub_slot := 0));
10338
10339 chan_act := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
Neels Hofmeyr07603cf2021-09-07 19:05:52 +020010340 var RSL_IE_Body chan_ident_ie;
10341 if (not f_rsl_find_ie(chan_act, RSL_IE_CHAN_IDENT, chan_ident_ie)) {
10342 setverdict(fail, "RSL Channel Identification IE is absent");
10343 mtc.stop;
10344 }
Neels Hofmeyr7a6d0602021-08-07 04:23:50 +020010345
10346 /* *FIRST* expect the Immediate Assignment, before we ACK the chan act */
10347 imm_ass := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
Neels Hofmeyr07603cf2021-09-07 19:05:52 +020010348 f_verify_imm_ass(imm_ass, ra, fn, chan_nr, chan_ident_ie.chan_ident.ch_desc.v.arfcn,
10349 chan_ident_ie.chan_ident.ch_desc.v.tsc);
Neels Hofmeyr7a6d0602021-08-07 04:23:50 +020010350
10351 /* Only now send the Chan Act ACK */
10352 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, fn+10));
10353
10354 /* Check that the lchan is working */
10355 var octetstring l3 := '00010203040506'O;
10356 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
10357
10358 var BSSAP_N_CONNECT_ind rx_c_ind;
10359 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
10360 BSSAP.send(ts_BSSAP_CONNECT_res(rx_c_ind.connectionId));
10361
10362 f_sleep(1.0);
10363 f_shutdown_helper();
10364}
10365
Neels Hofmeyrc8b95c12021-08-07 04:24:02 +020010366testcase TC_imm_ass_pre_ts_ack_dyn_ts() runs on test_CT {
10367 /* change Timeslot 6 before f_init() starts RSL */
10368 f_init_vty();
10369 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_PDCH");
10370 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
10371
10372 f_init(1, false);
10373 f_sleep(1.0);
10374
10375 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(6));
10376 /* The BSC will activate the dynamic PDCH by default, so confirm that */
10377 f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
10378 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2323));
10379
10380 /* clean up timeslot 6 config, will only take effect when the OML drops the next time */
10381 f_ts_set_chcomb(0, 0, 6, "PDCH");
10382
10383 /* block all static timeslots so that the dyn TS will be used */
10384 f_disable_all_tch_f();
10385 f_disable_all_tch_h();
10386 f_disable_all_sdcch();
10387
10388 var RSL_Message chan_act;
10389 var RSL_Message imm_ass;
10390
10391 f_init(1, false);
10392 f_sleep(1.0);
10393
10394 f_vty_set_imm_ass(BSCVTY, 0, "pre-ts-ack");
10395
10396 /* RA containing reason=LU */
10397 var GsmFrameNumber fn := 2342;
10398 var uint8_t ra := 2;
10399 f_ipa_tx(0, ts_RSL_CHAN_RQD(int2oct(ra, 1), fn));
10400
10401 /* (set bts 0 cfg back to default) */
10402 f_vty_set_imm_ass(BSCVTY);
10403
10404 /* Expect the dyn TS to deactivate PDCH first */
10405 f_exp_ipa_rx(0, tr_RSL_RF_CHAN_REL(chan_nr));
10406
10407 /* And already the Immediate Assignment even before the PDCH Deact ACK */
10408 imm_ass := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
10409
10410 /* continue the Osmo style PDCH Deact (usual chan rel) */
10411 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(chan_nr));
10412
10413 /* Now activation as SDCCH8 */
10414 chan_nr := valueof(t_RslChanNr_SDCCH8(tn := 6, sub_slot := 0));
10415
10416 chan_act := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
Neels Hofmeyr07603cf2021-09-07 19:05:52 +020010417 var RSL_IE_Body chan_ident_ie;
10418 if (not f_rsl_find_ie(chan_act, RSL_IE_CHAN_IDENT, chan_ident_ie)) {
10419 setverdict(fail, "RSL Channel Identification IE is absent");
10420 mtc.stop;
10421 }
Neels Hofmeyrc8b95c12021-08-07 04:24:02 +020010422 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, fn+10));
10423
Neels Hofmeyr07603cf2021-09-07 19:05:52 +020010424 f_verify_imm_ass(imm_ass, ra, fn, chan_nr, chan_ident_ie.chan_ident.ch_desc.v.arfcn,
10425 chan_ident_ie.chan_ident.ch_desc.v.tsc);
Neels Hofmeyrc8b95c12021-08-07 04:24:02 +020010426
10427 /* Check that the lchan is working */
10428 var octetstring l3 := '00010203040506'O;
10429 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
10430
10431 var BSSAP_N_CONNECT_ind rx_c_ind;
10432 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
10433 BSSAP.send(ts_BSSAP_CONNECT_res(rx_c_ind.connectionId));
10434
10435 f_sleep(1.0);
10436 f_shutdown_helper();
10437}
10438
Neels Hofmeyr5d7d13f2021-09-07 14:44:36 +020010439/* GET and SET the bts.N.trx.M.rf_locked CTRL variable */
10440testcase TC_ctrl_trx_rf_locked() runs on test_CT {
10441 var MSC_ConnHdlr vc_conn;
10442
10443 f_init(nr_bts := 2, handler_mode := true, nr_msc := 1);
10444 f_sleep(1.0);
10445
10446 /* BTS 0, 1, 2 are OML unlocked, only BTS 0, 1 are actually connected to RSL. */
10447 f_ctrl_get_exp(IPA_CTRL, "rf_states",
10448 "0,0,operational,unlocked,on,rsl-up;" &
10449 "1,0,operational,unlocked,on,rsl-up;" &
10450 "2,0,operational,unlocked,on,rsl-down;" &
10451 "3,0,inoperational,locked,on,rsl-down;");
10452
10453 f_logp(BSCVTY, "TC_ctrl_trx_rf_locked: lock BTS 1 TRX 0");
10454 f_ctrl_set(IPA_CTRL, "bts.1.trx.0.rf_locked", "1");
10455 /* give it a moment to settle the FSM status */
10456 f_sleep(1.0);
10457
10458 /* Now BTS 1 TRX 0 should reflect "locked". Note the RF policy stays "on", because this is still handled
10459 * globally in osmo-bsc. Probably after sending "rf_locked 1" for a TRX, that TRX should reflect an RF policy
10460 * of "off"? But that's for a future patch if at all. */
10461 f_ctrl_get_exp(IPA_CTRL, "rf_states",
10462 "0,0,operational,unlocked,on,rsl-up;" &
10463 "1,0,operational,locked,on,rsl-up;" &
10464 "2,0,operational,unlocked,on,rsl-down;" &
10465 "3,0,inoperational,locked,on,rsl-down;");
10466
10467 f_logp(BSCVTY, "TC_ctrl_trx_rf_locked: lock the already locked TRX, nothing should change");
10468 f_ctrl_set(IPA_CTRL, "bts.1.trx.0.rf_locked", "1");
10469 f_sleep(1.0);
10470 f_ctrl_get_exp(IPA_CTRL, "rf_states",
10471 "0,0,operational,unlocked,on,rsl-up;" &
10472 "1,0,operational,locked,on,rsl-up;" &
10473 "2,0,operational,unlocked,on,rsl-down;" &
10474 "3,0,inoperational,locked,on,rsl-down;");
10475
10476 f_logp(BSCVTY, "TC_ctrl_trx_rf_locked: unlock BTS 1 TRX 0");
10477 f_ctrl_set(IPA_CTRL, "bts.1.trx.0.rf_locked", "0");
10478 f_sleep(1.0);
10479 f_ctrl_get_exp(IPA_CTRL, "rf_states",
10480 "0,0,operational,unlocked,on,rsl-up;" &
10481 "1,0,operational,unlocked,on,rsl-up;" &
10482 "2,0,operational,unlocked,on,rsl-down;" &
10483 "3,0,inoperational,locked,on,rsl-down;");
10484
10485 f_logp(BSCVTY, "TC_ctrl_trx_rf_locked: unlock an already unlocked TRX, nothing should change");
10486 f_ctrl_set(IPA_CTRL, "bts.0.trx.0.rf_locked", "0");
10487 f_sleep(1.0);
10488 f_ctrl_get_exp(IPA_CTRL, "rf_states",
10489 "0,0,operational,unlocked,on,rsl-up;" &
10490 "1,0,operational,unlocked,on,rsl-up;" &
10491 "2,0,operational,unlocked,on,rsl-down;" &
10492 "3,0,inoperational,locked,on,rsl-down;");
10493
10494 f_logp(BSCVTY, "TC_ctrl_trx_rf_locked: unlock an inoperational TRX");
10495 f_ctrl_set(IPA_CTRL, "bts.3.trx.0.rf_locked", "0");
10496 f_sleep(1.0);
10497 f_ctrl_get_exp(IPA_CTRL, "rf_states",
10498 "0,0,operational,unlocked,on,rsl-up;" &
10499 "1,0,operational,unlocked,on,rsl-up;" &
10500 "2,0,operational,unlocked,on,rsl-down;" &
10501 "3,0,inoperational,locked,on,rsl-down;");
10502
10503 f_shutdown_helper();
10504}
10505
Neels Hofmeyrb7581872021-11-07 14:02:49 +010010506const CounterNameVals counternames_cm_serv_rej := {
10507 { "cm_serv_rej", 0 },
10508 { "cm_serv_rej:imsi_unknown_in_hlr", 0 },
10509 { "cm_serv_rej:illegal_ms", 0 },
10510 { "cm_serv_rej:imsi_unknown_in_vlr", 0 },
10511 { "cm_serv_rej:imei_not_accepted", 0 },
10512 { "cm_serv_rej:illegal_me", 0 },
10513 { "cm_serv_rej:plmn_not_allowed", 0 },
10514 { "cm_serv_rej:loc_not_allowed", 0 },
10515 { "cm_serv_rej:roaming_not_allowed", 0 },
10516 { "cm_serv_rej:network_failure", 0 },
10517 { "cm_serv_rej:synch_failure", 0 },
10518 { "cm_serv_rej:congestion", 0 },
10519 { "cm_serv_rej:srv_opt_not_supported", 0 },
10520 { "cm_serv_rej:rqd_srv_opt_not_supported", 0 },
10521 { "cm_serv_rej:srv_opt_tmp_out_of_order", 0 },
10522 { "cm_serv_rej:call_can_not_be_identified", 0 },
10523 { "cm_serv_rej:incorrect_message", 0 },
10524 { "cm_serv_rej:invalid_mandantory_inf", 0 },
10525 { "cm_serv_rej:msg_type_not_implemented", 0 },
10526 { "cm_serv_rej:msg_type_not_compatible", 0 },
10527 { "cm_serv_rej:inf_eleme_not_implemented", 0 },
10528 { "cm_serv_rej:condtional_ie_error", 0 },
10529 { "cm_serv_rej:msg_not_compatible", 0 },
10530 { "cm_serv_rej:protocol_error", 0 },
10531 { "cm_serv_rej:retry_in_new_cell", 0 }
10532};
10533
10534private function f_TC_cm_serv_rej(charstring id) runs on MSC_ConnHdlr
10535{
10536 f_create_chan_and_exp();
10537 BSSAP.send(ts_PDU_DTAP_MT(ts_CM_SERV_REJ('02'O), '00'O));
Neels Hofmeyr87a65612021-11-16 15:56:45 +010010538 f_sleep(1.0);
Neels Hofmeyrb7581872021-11-07 14:02:49 +010010539}
10540testcase TC_cm_serv_rej() runs on test_CT {
10541 var TestHdlrParams pars := f_gen_test_hdlr_pars();
10542 var MSC_ConnHdlr vc_conn;
10543
10544 f_init(1, true);
10545 f_sleep(1.0);
10546
10547 f_ctrs_bts_init(1, counternames_cm_serv_rej);
10548
10549 vc_conn := f_start_handler(refers(f_TC_cm_serv_rej), pars);
10550 vc_conn.done;
10551
10552 f_ctrs_bts_add(0, "cm_serv_rej", 1);
10553 f_ctrs_bts_add(0, "cm_serv_rej:imsi_unknown_in_hlr", 1);
10554 f_ctrs_bts_verify();
10555
Neels Hofmeyr87a65612021-11-16 15:56:45 +010010556 f_sleep(1.0);
Neels Hofmeyrb7581872021-11-07 14:02:49 +010010557 f_shutdown_helper();
10558}
10559
Neels Hofmeyr92cfa1c2021-09-28 18:29:44 +020010560/* Reproduce a segfault happening when the SDCCH (primary) lchan is lost in-between a TCH Channel Activ and its Channel
10561 * Activ Ack (SYS#5627). */
10562private function f_TC_lost_sdcch_during_assignment(charstring id) runs on MSC_ConnHdlr {
10563 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Vadim Yanitskiyf0310e32021-10-26 00:30:59 +030010564
10565 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
10566 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Neels Hofmeyr92cfa1c2021-09-28 18:29:44 +020010567
10568 var BSSMAP_FIELD_CodecType codecType;
10569 codecType := valueof(ass_cmd.pdu.bssmap.assignmentRequest.codecList.codecElements[0].codecType);
10570
10571 f_MscConnHdlr_init(g_pars.media_nr, host_bts, host_mgw_mgcp, codecType);
10572
10573 /* First establish a signalling lchan */
10574 f_create_chan_and_exp();
10575 f_rslem_dchan_queue_enable();
10576
10577 /* we should now have a COMPL_L3 at the MSC */
10578 var template PDU_BSSAP exp_l3_compl;
10579 exp_l3_compl := tr_BSSMAP_ComplL3()
10580 if (g_pars.aoip == false) {
10581 exp_l3_compl.pdu.bssmap.completeLayer3Information.codecList := omit;
10582 } else {
10583 exp_l3_compl.pdu.bssmap.completeLayer3Information.codecList := ?;
10584 }
10585 timer T := 10.0;
10586 T.start;
10587 alt {
10588 [] BSSAP.receive(exp_l3_compl);
10589 [] BSSAP.receive(tr_BSSMAP_ComplL3) {
10590 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received non-matching COMPLETE LAYER 3 INFORMATION");
10591 }
10592 [] T.timeout {
10593 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for COMPLETE LAYER 3 INFORMATION");
10594 }
10595 }
10596
10597 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
10598 activate(as_Media_mgw());
10599
10600 var RslChannelNr chan_nr := { u := { ch0 := RSL_CHAN_NR_Bm_ACCH }, tn := 1 };
10601 f_rslem_register(0, chan_nr);
10602
10603 f_rslem_set_auto_chan_act_ack(RSL_PROC, false);
10604 BSSAP.send(ass_cmd);
10605
10606
10607 /* Wait for the Channel Activ for the TCH channel */
10608 var ASP_RSL_Unitdata rx_rsl_ud;
10609 RSL.receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV), sid := ?)) -> value rx_rsl_ud;
10610
10611 /* make the original SDCCH disappear */
10612 RSL.send(ts_RSL_REL_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0))));
10613
10614 /* and ACK the TCH channel activation. This caused a segfault up to OsmoBSC 1.7.0 (SYS#5627) */
10615 RSL.send(ts_ASP_RSL_UD(ts_RSL_CHAN_ACT_ACK(chan_nr, 23), rx_rsl_ud.streamId));
10616
10617 interleave {
10618 [] BSSAP.receive(tr_BSSMAP_AssignmentFail);
10619 [] BSSAP.receive(tr_BSSMAP_ClearRequest);
10620 }
10621
10622 BSSAP.send(ts_BSSMAP_ClearCommand(0));
10623 BSSAP.receive(tr_BSSMAP_ClearComplete);
10624 BSSAP.send(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_REQ);
10625
10626 var MgcpCommand mgcp;
10627 MGCP.receive(tr_DLCX()) -> value mgcp {
10628 MGCP.send(ts_DLCX_ACK2(mgcp.line.trans_id));
10629 };
10630
10631 f_sleep(0.5);
10632}
10633testcase TC_lost_sdcch_during_assignment() runs on test_CT {
10634 var TestHdlrParams pars := f_gen_test_hdlr_pars();
10635 var MSC_ConnHdlr vc_conn;
10636
10637 f_init(1, true);
10638 f_sleep(1.0);
10639
Neels Hofmeyr92cfa1c2021-09-28 18:29:44 +020010640 vc_conn := f_start_handler(refers(f_TC_lost_sdcch_during_assignment), pars);
10641 vc_conn.done;
10642
10643 f_shutdown_helper();
10644}
10645
Neels Hofmeyrbd94fe72021-10-26 22:04:53 +020010646const CounterNameVals counternames_bsc_bts_all_available_allocated := {
10647 { "all_allocated:sdcch", 0 },
10648 { "all_allocated:static_sdcch", 0 },
10649 { "all_allocated:tch", 0 },
10650 { "all_allocated:static_tch", 0 }
10651}
10652
10653private function f_all_allocated_expect_counter_change(charstring_list expect_changed) runs on test_CT
10654{
10655 /* Make sure counters settle first */
10656 f_sleep(1.0);
10657
10658 /* Take a baseline of counters */
10659 f_ctrs_bsc_and_bts_init(1, counternames_bsc_bts_all_available_allocated);
10660
10661 /* Elapse some time so that we see changes in counters, hopefully where expected */
10662 f_sleep(2.0);
10663
10664 /* Get new counters */
10665 var charstring_list all_changed := {};
10666 all_changed := all_changed & f_counter_name_vals_get_changed_n(IPA_CTRL, "bsc", g_ctr_bsc);
10667 all_changed := all_changed & f_counter_name_vals_get_changed_n(IPA_CTRL, "bts", g_ctr_bts);
10668
10669 /* Compare with expectations */
10670 var charstring_list all_expect_changed := {};
10671 for (var integer i := 0; i < lengthof(expect_changed); i := i + 1) {
10672 all_expect_changed := all_expect_changed & { "bsc.0." & expect_changed[i], "bts.0." & expect_changed[i] };
10673 }
10674 f_counter_name_vals_expect_changed_list(all_changed, all_expect_changed);
10675}
10676
10677testcase TC_ratectr_all_available_allocated() runs on test_CT {
10678 var ASP_RSL_Unitdata rsl_ud;
10679 var integer i;
10680 var integer chreq_total, chreq_nochan;
10681
10682 f_init(1);
10683 f_sleep(1.0);
10684
10685 /* Exhaust all dedicated SDCCH lchans.
10686 /* GSM 44.018 Table 9.1.8.2:
10687 * RA = '13'O -> Establishment cause = 0001xxxx (MS dual rate capable and asks for "SDCCH").
10688 */
10689 for (i := 0; i < NUM_SDCCH_PER_BTS; i := i+1) {
10690 f_est_dchan('13'O, NUM_SDCCH_PER_BTS + i, '00010203040506'O);
10691 }
10692
10693 /* Since only bts 0 is connected, expecting all_allocated to become true for both bts 0 and the "global" bsc
10694 * level.
10695 * All SDCCH are now occupied. */
10696 f_all_allocated_expect_counter_change({"all_allocated:sdcch", "all_allocated:static_sdcch"});
10697
10698 /* Also fill up all remaining (TCH) channels */
10699 for (i := 0; i < NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS; i := i+1) {
10700 f_est_dchan('33'O, NUM_SDCCH_PER_BTS + i, '00010203040506'O);
10701 }
10702
10703 /* All TCH are now also occupied */
10704 f_all_allocated_expect_counter_change({"all_allocated:sdcch", "all_allocated:static_sdcch",
10705 "all_allocated:tch", "all_allocated:static_tch"});
10706
10707 f_shutdown_helper();
10708}
10709
10710testcase TC_ratectr_all_available_allocated_dyn() runs on test_CT {
10711 var ASP_RSL_Unitdata rsl_ud;
10712 var integer i;
10713 var integer chreq_total, chreq_nochan;
10714
10715 f_init_vty();
10716 f_ts_set_chcomb(0, 0, 2, "TCH/F_TCH/H_PDCH");
10717 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
10718 /* Now we have 3 TCH/F, 1 OSMO_DYN, 1 TCH/H */
10719
10720 f_init(1, guard_timeout := 60.0);
10721 f_sleep(1.0);
10722
10723 /* The dyn TS wants to activate PDCH mode, ACK that. */
10724 var RslChannelNr chan_nr;
10725 chan_nr := valueof(t_RslChanNr_PDCH(2));
10726 f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
10727 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342));
10728
10729 /* Exhaust all dedicated SDCCH lchans.
10730 /* GSM 44.018 Table 9.1.8.2:
10731 * RA = '13'O -> Establishment cause = 0001xxxx (MS dual rate capable and asks for "SDCCH").
10732 */
10733 for (i := 0; i < NUM_SDCCH_PER_BTS; i := i+1) {
10734 f_est_dchan('13'O, NUM_SDCCH_PER_BTS + i, '00010203040506'O);
10735 }
10736
10737 /* The static SDCCH should now be occupied, while still 3x8 dynamic SDCCH potentially remain. So only
10738 * all_allocated:static_sdcch is counted, all_allocated:sdcch remains zero. */
10739 f_all_allocated_expect_counter_change({"all_allocated:static_sdcch"});
10740
10741 /* Request more SDCCH, hence convert the first dyn TS to SDCCH8.
10742 * Will release them later, so remember all the DchanTuples. */
10743 var DchanTuples dyn_sddch := {};
10744 dyn_sddch := dyn_sddch & { f_est_dchan_dyn('33'O, NUM_SDCCH_PER_BTS + i, '00010203040506'O) };
10745
10746 /* Also occupy the seven other SDCCH of the dyn TS */
10747 for (i := 0; i < 7; i := i+1) {
10748 dyn_sddch := dyn_sddch & { f_est_dchan('33'O, NUM_SDCCH_PER_BTS + i, '00010203040506'O) };
10749 }
10750
10751 /* Now all dynamic SDCCH are also occupied, so for the first time all_allocated:sdcch will trigger... */
10752 f_all_allocated_expect_counter_change({"all_allocated:sdcch", "all_allocated:static_sdcch"});
10753
10754 /* occupy the remaining TCH, three TCH/F and two TCH/H lchans */
10755 for (i := 0; i < 5; i := i+1) {
10756 f_est_dchan('33'O, NUM_SDCCH_PER_BTS + i, '00010203040506'O);
10757 }
10758
10759 /* All TCH lchans are now also occupied, both static and dynamic */
10760 f_all_allocated_expect_counter_change({"all_allocated:sdcch", "all_allocated:static_sdcch",
10761 "all_allocated:tch", "all_allocated:static_tch"});
10762
10763 /* Starting to release the dyn TS: as soon as the first SDCCH gets released, all_allocated:sdcch stops
10764 * incrementing. */
10765 var BssmapCause cause := 0;
10766 var DchanTuple dt := dyn_sddch[0];
10767 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
10768 f_exp_chan_rel_and_clear(dt, 0);
10769
10770 /* one dyn TS SDCCH is free again, so only the static_sdcch should increment. For tch, both static and dynamic
10771 * count as occupied, so those still both increment. */
10772 f_all_allocated_expect_counter_change({"all_allocated:static_sdcch",
10773 "all_allocated:tch", "all_allocated:static_tch"});
10774
10775 /* Release the remaining SDCCH of the dyn TS, so it becomes available as TCH again */
10776 for (i := 1; i < lengthof(dyn_sddch); i := i+1) {
10777 dt := dyn_sddch[i];
10778 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
10779 f_exp_chan_rel_and_clear(dt, 0);
10780 }
10781
10782 /* All SDCCH on the dyn TS are released, the dyn TS wants to activate PDCH again */
10783 chan_nr := valueof(t_RslChanNr_PDCH(2));
10784 f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
10785 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342));
10786
10787 /* Now all channels are occupied except the dyn TS, so expecting only the static counters to increment */
10788 f_all_allocated_expect_counter_change({"all_allocated:static_sdcch", "all_allocated:static_tch"});
10789
10790 /* clean up config */
10791 f_ts_reset_chcomb(0);
10792
10793 f_shutdown_helper();
10794}
10795
Harald Welte28d943e2017-11-25 15:00:50 +010010796control {
Harald Welte898113b2018-01-31 18:32:21 +010010797 /* CTRL interface testing */
Harald Welte4003d112017-12-09 22:35:39 +010010798 execute( TC_ctrl_msc_connection_status() );
Stefan Sperlingb041b3d2018-01-03 17:14:55 +010010799 execute( TC_ctrl_msc0_connection_status() );
Neels Hofmeyrf65ce872021-09-23 18:40:10 +020010800 /* In SCCPlite tests, only one MSC is configured. These tests assume that three MSCs are configured, so only run
10801 * these in the AoIP test suite. */
10802 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
10803 execute( TC_stat_num_msc_connected_1() );
10804 execute( TC_stat_num_msc_connected_2() );
10805 execute( TC_stat_num_msc_connected_3() );
10806 }
Neels Hofmeyr5ce3ae42021-08-29 15:32:00 +020010807 execute( TC_stat_num_bts_connected_1() );
10808 execute( TC_stat_num_bts_connected_2() );
10809 execute( TC_stat_num_bts_connected_3() );
Harald Welte96c94412017-12-09 03:12:45 +010010810 execute( TC_ctrl() );
Neels Hofmeyrf246a922020-05-13 02:27:10 +020010811 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_SCCPlite_SERVER) {
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +020010812 execute( TC_ctrl_location() );
10813 }
Harald Welte898113b2018-01-31 18:32:21 +010010814
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +020010815 execute( TC_si_default() );
Neels Hofmeyr66aeba42020-07-06 02:21:21 +020010816 execute( TC_si2quater_2_earfcns() );
10817 execute( TC_si2quater_3_earfcns() );
10818 execute( TC_si2quater_4_earfcns() );
10819 execute( TC_si2quater_5_earfcns() );
10820 execute( TC_si2quater_6_earfcns() );
Neels Hofmeyrad132f22020-07-08 02:20:16 +020010821 execute( TC_si2quater_12_earfcns() );
10822 execute( TC_si2quater_23_earfcns() );
10823 execute( TC_si2quater_32_earfcns() );
10824 execute( TC_si2quater_33_earfcns() );
10825 execute( TC_si2quater_42_earfcns() );
10826 execute( TC_si2quater_48_earfcns() );
10827 execute( TC_si2quater_49_earfcns() );
Pau Espin Pedrol85a84432020-07-20 18:45:03 +020010828 execute( TC_si_acc_rotate() );
Alexander Couzens4ad3a352020-09-10 22:29:12 +020010829 execute( TC_si_acc_ramp_rotate() );
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +020010830
Harald Welte898113b2018-01-31 18:32:21 +010010831 /* RSL DCHAN Channel ACtivation / Deactivation */
Harald Welteae026692017-12-09 01:03:01 +010010832 execute( TC_chan_act_noreply() );
Harald Welte4003d112017-12-09 22:35:39 +010010833 execute( TC_chan_act_counter() );
Harald Welteae026692017-12-09 01:03:01 +010010834 execute( TC_chan_act_ack_noest() );
Philipp Maier9c60a622020-07-09 15:08:46 +020010835 execute( TC_chan_act_ack_noest_emerg() );
Philipp Maier606f07d2020-08-12 17:21:58 +020010836 execute( TC_chan_rqd_emerg_deny() );
Harald Welteae026692017-12-09 01:03:01 +010010837 execute( TC_chan_act_ack_est_ind_noreply() );
10838 execute( TC_chan_act_ack_est_ind_refused() );
Harald Welte618ef642017-12-14 14:58:20 +010010839 execute( TC_chan_act_nack() );
Harald Welte799c97b2017-12-14 17:50:30 +010010840 execute( TC_chan_exhaustion() );
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +070010841 execute( TC_chan_deact_silence() );
Harald Welte4003d112017-12-09 22:35:39 +010010842 execute( TC_chan_rel_rll_rel_ind() );
10843 execute( TC_chan_rel_conn_fail() );
10844 execute( TC_chan_rel_hard_clear() );
Pau Espin Pedrol841b90d2021-04-15 16:42:52 +020010845 execute( TC_chan_rel_last_eutran_plmn_hard_clear_no_csfb() );
10846 execute( TC_chan_rel_last_eutran_plmn_hard_clear_csfb() );
Harald Welte99787102019-02-04 10:41:36 +010010847 execute( TC_chan_rel_hard_clear_csfb() );
Harald Welted8c36cd2017-12-09 23:05:31 +010010848 execute( TC_chan_rel_hard_rlsd() );
Harald Welte550daf92018-06-11 19:22:13 +020010849 execute( TC_chan_rel_hard_rlsd_ms_dead() );
Harald Welte85804d42017-12-10 14:11:58 +010010850 execute( TC_chan_rel_a_reset() );
Pau Espin Pedrolc675b612020-01-09 19:55:40 +010010851 execute( TC_chan_rel_sccp_tiar_timeout() );
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +020010852 execute( TC_chan_rel_rr_cause() );
Harald Welte6f521d82017-12-11 19:52:02 +010010853
Harald Weltecfe2c962017-12-15 12:09:32 +010010854 execute( TC_outbound_connect() );
Harald Welte898113b2018-01-31 18:32:21 +010010855
10856 /* Assignment related */
Harald Welte16a4adf2017-12-14 18:54:01 +010010857 execute( TC_assignment_cic_only() );
Harald Welte235ebf12017-12-15 14:18:16 +010010858 execute( TC_assignment_csd() );
10859 execute( TC_assignment_ctm() );
10860 execute( TC_assignment_sign() );
Pau Espin Pedrol07866632020-09-03 19:10:55 +020010861 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
10862 execute( TC_assignment_aoip_tla_v6() );
10863 }
Harald Welte235ebf12017-12-15 14:18:16 +010010864 execute( TC_assignment_fr_a5_0() );
10865 execute( TC_assignment_fr_a5_1() );
Neels Hofmeyrf246a922020-05-13 02:27:10 +020010866 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welte8f67d1d2018-05-25 20:38:42 +020010867 execute( TC_assignment_fr_a5_1_codec_missing() );
10868 }
Harald Welte235ebf12017-12-15 14:18:16 +010010869 execute( TC_assignment_fr_a5_3() );
Neels Hofmeyr0d8ec532021-06-11 00:09:48 +020010870 execute( TC_assignment_fr_a5_4() );
Neels Hofmeyr0faeb7a2021-06-10 23:59:35 +020010871 execute( TC_assignment_fr_a5_4_fail() );
Neels Hofmeyr04d6e6a2021-06-11 00:10:02 +020010872 execute( TC_assignment_fr_a5_not_sup() );
Harald Welte3c86ea02018-05-10 22:28:05 +020010873 execute( TC_ciph_mode_a5_0() );
10874 execute( TC_ciph_mode_a5_1() );
Oliver Smith50b98122021-07-09 15:00:28 +020010875 execute( TC_ciph_mode_a5_2_0() );
Oliver Smith1dff88d2021-07-09 08:45:51 +020010876 execute( TC_ciph_mode_a5_2_1() );
Harald Welte3c86ea02018-05-10 22:28:05 +020010877 execute( TC_ciph_mode_a5_3() );
Neels Hofmeyr81ad27f2021-06-11 00:09:40 +020010878 execute( TC_ciph_mode_a5_4() );
Harald Welte16a4adf2017-12-14 18:54:01 +010010879
Harald Welte60aa5762018-03-21 19:33:13 +010010880 execute( TC_assignment_codec_fr() );
Neels Hofmeyr559d5d02021-04-16 16:50:49 +020010881 execute( TC_assignment_codec_fr_by_mode_modify() );
Harald Welte60aa5762018-03-21 19:33:13 +010010882 execute( TC_assignment_codec_hr() );
10883 execute( TC_assignment_codec_efr() );
10884 execute( TC_assignment_codec_amr_f() );
10885 execute( TC_assignment_codec_amr_h() );
Philipp Maier8a581d22019-03-26 18:32:48 +010010886
Neels Hofmeyrf246a922020-05-13 02:27:10 +020010887 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Philipp Maier8a581d22019-03-26 18:32:48 +010010888 execute( TC_assignment_codec_amr_f_S1() );
10889 execute( TC_assignment_codec_amr_h_S1() );
10890 execute( TC_assignment_codec_amr_f_S124() );
10891 execute( TC_assignment_codec_amr_h_S124() );
10892 execute( TC_assignment_codec_amr_f_S0() );
10893 execute( TC_assignment_codec_amr_f_S02() );
10894 execute( TC_assignment_codec_amr_f_S024() );
10895 execute( TC_assignment_codec_amr_f_S0247() );
10896 execute( TC_assignment_codec_amr_h_S0() );
10897 execute( TC_assignment_codec_amr_h_S02() );
10898 execute( TC_assignment_codec_amr_h_S024() );
10899 execute( TC_assignment_codec_amr_h_S0247() );
10900 execute( TC_assignment_codec_amr_f_S01234567() );
10901 execute( TC_assignment_codec_amr_f_S0234567() );
10902 execute( TC_assignment_codec_amr_f_zero() );
10903 execute( TC_assignment_codec_amr_f_unsupp() );
10904 execute( TC_assignment_codec_amr_h_S7() );
Neels Hofmeyr21863562020-11-26 00:34:33 +000010905 execute( TC_assignment_codec_amr_f_start_mode_auto() );
10906 execute( TC_assignment_codec_amr_h_start_mode_auto() );
Neels Hofmeyr3eb94562020-11-26 02:40:26 +000010907 execute( TC_assignment_codec_amr_f_start_mode_4() );
10908 execute( TC_assignment_codec_amr_h_start_mode_4() );
Neels Hofmeyr454d7922020-11-26 02:24:57 +000010909 execute( TC_assignment_codec_amr_startmode_cruft() );
Philipp Maier8a581d22019-03-26 18:32:48 +010010910 }
Harald Welte60aa5762018-03-21 19:33:13 +010010911
Philipp Maierac09bfc2019-01-08 13:41:39 +010010912 execute( TC_assignment_codec_fr_exhausted_req_hr() );
10913 execute( TC_assignment_codec_fr_exhausted_req_fr() );
10914 execute( TC_assignment_codec_fr_exhausted_req_fr_hr() );
10915 execute( TC_assignment_codec_fr_exhausted_req_hr_fr() );
10916 execute( TC_assignment_codec_hr_exhausted_req_fr() );
10917 execute( TC_assignment_codec_hr_exhausted_req_hr() );
10918 execute( TC_assignment_codec_hr_exhausted_req_hr_fr() );
10919 execute( TC_assignment_codec_hr_exhausted_req_fr_hr() );
10920 execute( TC_assignment_codec_req_hr_fr() );
10921 execute( TC_assignment_codec_req_fr_hr() );
Pau Espin Pedrol14475352021-07-22 15:48:16 +020010922 execute( TC_assignment_sdcch_exhausted_req_signalling() );
10923 execute( TC_assignment_sdcch_exhausted_req_signalling_tch_forbidden() );
10924 execute( TC_assignment_sdcch_exhausted_req_voice_tch_forbidden() );
Philipp Maierac09bfc2019-01-08 13:41:39 +010010925
Pau Espin Pedrol23510fb2021-07-20 17:00:38 +020010926 execute( TC_assignment_osmux() );
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +020010927
Harald Welte898113b2018-01-31 18:32:21 +010010928 /* RLL Establish Indication on inactive DCHAN / SAPI */
Harald Welte5cd20ed2017-12-13 21:03:20 +010010929 execute( TC_rll_est_ind_inact_lchan() );
10930 execute( TC_rll_est_ind_inval_sapi1() );
10931 execute( TC_rll_est_ind_inval_sapi3() );
10932 execute( TC_rll_est_ind_inval_sacch() );
10933
Vadim Yanitskiy61f784a2020-10-01 21:12:19 +070010934 /* DLCI / RSL Link ID conversion for MO/MT messages on SAPI0/SAPI3 */
10935 execute( TC_tch_dlci_link_id_sapi() );
10936
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +070010937 /* SAPI N Reject triggered by RLL establishment failures */
10938 execute( TC_rll_rel_ind_sapi_n_reject() );
10939 execute( TC_rll_err_ind_sapi_n_reject() );
10940 execute( TC_rll_timeout_sapi_n_reject() );
10941
Harald Welte898113b2018-01-31 18:32:21 +010010942 /* Paging related tests */
Harald Welte6f521d82017-12-11 19:52:02 +010010943 execute( TC_paging_imsi_nochan() );
10944 execute( TC_paging_tmsi_nochan() );
10945 execute( TC_paging_tmsi_any() );
10946 execute( TC_paging_tmsi_sdcch() );
10947 execute( TC_paging_tmsi_tch_f() );
10948 execute( TC_paging_tmsi_tch_hf() );
10949 execute( TC_paging_imsi_nochan_cgi() );
10950 execute( TC_paging_imsi_nochan_lac_ci() );
10951 execute( TC_paging_imsi_nochan_ci() );
10952 execute( TC_paging_imsi_nochan_lai() );
10953 execute( TC_paging_imsi_nochan_lac() );
10954 execute( TC_paging_imsi_nochan_all() );
Harald Welte751d3eb2018-01-31 15:51:06 +010010955 execute( TC_paging_imsi_nochan_plmn_lac_rnc() );
10956 execute( TC_paging_imsi_nochan_rnc() );
10957 execute( TC_paging_imsi_nochan_lac_rnc() );
10958 execute( TC_paging_imsi_nochan_lacs() );
10959 execute( TC_paging_imsi_nochan_lacs_empty() );
Stefan Sperling049a86e2018-03-20 15:51:00 +010010960 execute( TC_paging_imsi_nochan_cgi_unknown_cid() );
Harald Welte10985002017-12-12 09:29:15 +010010961 execute( TC_paging_imsi_a_reset() );
Harald Weltee65d40e2017-12-13 00:09:06 +010010962 execute( TC_paging_imsi_load() );
Philipp Maier779a7922018-02-16 11:00:37 +010010963 execute( TC_paging_counter() );
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +010010964 execute( TC_paging_resp_unsol() );
Harald Welte4e9b9cc2017-12-14 18:31:02 +010010965
10966 execute( TC_rsl_drop_counter() );
Stefan Sperling830dc9d2018-02-12 21:08:28 +010010967 execute( TC_rsl_unknown_unit_id() );
10968
10969 execute( TC_oml_unknown_unit_id() );
Harald Welte898113b2018-01-31 18:32:21 +010010970
10971 execute( TC_classmark() );
Harald Welteeddf0e92020-06-21 19:42:15 +020010972 execute( TC_common_id() );
Harald Welte898113b2018-01-31 18:32:21 +010010973 execute( TC_unsol_ass_fail() );
Harald Welteea99a002018-01-31 20:46:43 +010010974 execute( TC_unsol_ass_compl() );
Harald Weltefbf9b5e2018-01-31 20:41:23 +010010975 execute( TC_unsol_ho_fail() );
Harald Weltee3bd6582018-01-31 22:51:25 +010010976 execute( TC_err_82_short_msg() );
Harald Weltee9e02e42018-01-31 23:36:25 +010010977 execute( TC_err_84_unknown_msg() );
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +010010978
Harald Welte261af4b2018-02-12 21:20:39 +010010979 execute( TC_ho_int() );
Neels Hofmeyraf88d9d2021-06-21 02:14:27 +020010980 execute( TC_ho_int_a5_0() );
10981 execute( TC_ho_int_a5_1() );
10982 execute( TC_ho_int_a5_3() );
10983 execute( TC_ho_int_a5_4() );
Neels Hofmeyr5f144212020-11-03 15:41:58 +000010984 execute( TC_ho_int_radio_link_failure() );
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +010010985
Neels Hofmeyrafe2ea52021-11-24 15:16:12 +010010986 /* TC_ho_out_of_this_bsc is run last, see comment below */
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +020010987 execute( TC_ho_out_fail_no_msc_response() );
10988 execute( TC_ho_out_fail_rr_ho_failure() );
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +020010989 execute( TC_ho_out_fail_no_result_after_ho_cmd() );
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +010010990
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +010010991 execute( TC_ho_into_this_bsc() );
Neels Hofmeyr8ebf19c2021-06-21 05:24:01 +020010992 execute( TC_ho_into_this_bsc_a5_0() );
10993 execute( TC_ho_into_this_bsc_a5_1() );
10994 execute( TC_ho_into_this_bsc_a5_3() );
10995 execute( TC_ho_into_this_bsc_a5_4() );
Pau Espin Pedrol07866632020-09-03 19:10:55 +020010996 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
10997 execute( TC_ho_into_this_bsc_tla_v6() );
10998 }
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +020010999 execute( TC_srvcc_eutran_to_geran() );
Pau Espin Pedrol35801c32021-04-19 13:03:20 +020011000 execute( TC_srvcc_eutran_to_geran_ho_out() );
Pau Espin Pedrol9ae36d52021-06-15 17:29:43 +020011001 execute( TC_srvcc_eutran_to_geran_forbid_fast_return() );
11002 execute( TC_srvcc_eutran_to_geran_ho_out_forbid_fast_return() );
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +010011003 execute( TC_ho_in_fail_msc_clears() );
11004 execute( TC_ho_in_fail_msc_clears_after_ho_detect() );
11005 execute( TC_ho_in_fail_no_detect() );
11006 execute( TC_ho_in_fail_no_detect2() );
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +010011007
Neels Hofmeyr91401012019-07-11 00:42:35 +020011008 execute( TC_ho_neighbor_config_1() );
11009 execute( TC_ho_neighbor_config_2() );
11010 execute( TC_ho_neighbor_config_3() );
11011 execute( TC_ho_neighbor_config_4() );
11012 execute( TC_ho_neighbor_config_5() );
11013 execute( TC_ho_neighbor_config_6() );
11014 execute( TC_ho_neighbor_config_7() );
11015
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +010011016 execute( TC_bssap_rlsd_does_not_cause_bssmap_reset() );
Neels Hofmeyr4ff93282018-03-12 04:25:35 +010011017 execute( TC_bssmap_clear_does_not_cause_bssmap_reset() );
Neels Hofmeyrfd445c32018-03-09 15:39:31 +010011018 execute( TC_ms_rel_ind_does_not_cause_bssmap_reset() );
Harald Welte94e0c342018-04-07 11:33:23 +020011019
11020 execute( TC_dyn_pdch_ipa_act_deact() );
11021 execute( TC_dyn_pdch_ipa_act_nack() );
11022 execute( TC_dyn_pdch_osmo_act_deact() );
11023 execute( TC_dyn_pdch_osmo_act_nack() );
Pau Espin Pedrol37a4c152021-11-16 19:02:23 +010011024 execute( TC_dyn_ts_sdcch8_act_deact() );
11025 execute( TC_dyn_ts_sdcch8_all_subslots_used() );
11026 execute( TC_dyn_ts_sdcch8_tch_call_act_deact() );
11027 execute( TC_dyn_ts_sdcch8_act_nack() );
Harald Welte99f3ca02018-06-14 13:40:29 +020011028
Stefan Sperling0796a822018-10-05 13:01:39 +020011029 execute( TC_chopped_ipa_ping() );
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +020011030 execute( TC_chopped_ipa_payload() );
Stefan Sperling0796a822018-10-05 13:01:39 +020011031
Pau Espin Pedrol8f773632019-11-05 11:46:53 +010011032 /* Power control related */
11033 execute( TC_assignment_verify_ms_power_params_ie() );
Vadim Yanitskiy4b233042021-06-30 00:58:43 +020011034 execute( TC_c0_power_red_mode() );
Neels Hofmeyr4f118412020-06-04 15:25:10 +020011035
11036 /* MSC pooling */
11037 /* FIXME: in SCCPlite, indicating how many MSCs should be connected does currently not work. Since
11038 * RESET->RESET-ACK is unconditionally negotiated for all configured MSCs, they always all appear as connected
11039 * to osmo-bsc. The MSC pooling tests however require disconnecting selected MSCs, and hence don't work out as
11040 * intended on SCCPlite. So for now, run these only for SCCP/M3UA. */
11041 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
11042 execute( TC_mscpool_L3Compl_on_1_msc() );
11043 execute( TC_mscpool_L3Complete_by_imsi_round_robin() );
11044 execute( TC_mscpool_LU_by_tmsi_null_nri_0_round_robin() );
11045 execute( TC_mscpool_LU_by_tmsi_null_nri_1_round_robin() );
11046 execute( TC_mscpool_L3Complete_by_tmsi_unassigned_nri_round_robin() );
11047 execute( TC_mscpool_L3Complete_by_tmsi_valid_nri_msc_not_connected_round_robin() );
11048 execute( TC_mscpool_L3Complete_by_tmsi_valid_nri_1() );
11049 execute( TC_mscpool_L3Complete_by_tmsi_valid_nri_2() );
11050 execute( TC_mscpool_LU_by_tmsi_from_other_PLMN() );
11051 execute( TC_mscpool_paging_and_response_imsi() );
11052 execute( TC_mscpool_paging_and_response_tmsi() );
11053 execute( TC_mscpool_no_allow_attach_round_robin() );
11054 execute( TC_mscpool_no_allow_attach_valid_nri() );
11055 }
11056
Harald Welte99f3ca02018-06-14 13:40:29 +020011057 execute( TC_early_conn_fail() );
11058 execute( TC_late_conn_fail() );
Oliver Smithaf03bef2021-08-24 15:34:51 +020011059 execute( TC_stats_conn_fail() );
Harald Welte99f3ca02018-06-14 13:40:29 +020011060
Philipp Maier783681c2020-07-16 16:47:06 +020011061 /* Emergency call handling (deny / allow) */
11062 execute( TC_assignment_emerg_setup_allow() );
11063 execute( TC_assignment_emerg_setup_deny_msc() );
11064 execute( TC_assignment_emerg_setup_deny_bts() );
Philipp Maier82812002020-08-13 18:48:27 +020011065 execute( TC_emerg_premption() );
11066
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +070011067 /* Frequency hopping parameters handling */
11068 execute( TC_fh_params_chan_activ() );
11069 execute( TC_fh_params_imm_ass() );
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +070011070 execute( TC_fh_params_assignment_cmd() );
Vadim Yanitskiy8f5430d2020-09-02 18:51:38 +070011071 execute( TC_fh_params_handover_cmd() );
Vadim Yanitskiyca974032020-09-01 07:20:39 +070011072 execute( TC_fh_params_si4_cbch() );
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +020011073
11074 if (mp_enable_lcs_tests) {
11075 execute( TC_lcs_loc_req_for_active_ms() );
11076 execute( TC_lcs_loc_req_for_active_ms_ta_req() );
11077 execute( TC_lcs_loc_req_for_idle_ms() );
11078 execute( TC_lcs_loc_req_no_subscriber() );
11079 execute( TC_lcs_loc_req_for_active_ms_le_timeout() );
11080 execute( TC_lcs_loc_req_for_active_ms_le_timeout2() );
11081 execute( TC_lcs_loc_req_for_idle_ms_no_pag_resp() );
11082 execute( TC_cm_service_during_lcs_loc_req() );
11083 execute( TC_ho_during_lcs_loc_req() );
11084 }
Neels Hofmeyrbf037052020-10-28 22:52:02 +000011085
11086 execute( TC_no_msc() );
Neels Hofmeyr87857ec2021-04-25 16:17:47 +000011087
11088 execute( TC_refuse_chan_act_to_vamos() );
11089 execute( TC_refuse_mode_modif_to_vamos() );
Neels Hofmeyrd2d9f332021-04-28 22:23:36 +000011090
11091 execute( TC_reassignment_fr() );
Neels Hofmeyrfeda88e2021-07-19 13:51:29 +020011092
11093 execute( TC_cm_reestablishment() );
Neels Hofmeyrb07b2952021-08-07 04:23:14 +020011094
11095 execute( TC_imm_ass_post_chan_ack() );
11096 execute( TC_imm_ass_pre_chan_ack() );
Neels Hofmeyr23158742021-09-07 19:08:07 +020011097 execute( TC_imm_ass_pre_ts_ack() );
Neels Hofmeyr7a6d0602021-08-07 04:23:50 +020011098 execute( TC_imm_ass_pre_chan_ack_dyn_ts() );
Neels Hofmeyrc8b95c12021-08-07 04:24:02 +020011099 execute( TC_imm_ass_pre_ts_ack_dyn_ts() );
Neels Hofmeyr5d7d13f2021-09-07 14:44:36 +020011100
11101 execute( TC_ctrl_trx_rf_locked() );
Neels Hofmeyr92cfa1c2021-09-28 18:29:44 +020011102
Neels Hofmeyrbd94fe72021-10-26 22:04:53 +020011103 execute( TC_ratectr_all_available_allocated() );
11104 execute( TC_ratectr_all_available_allocated_dyn() );
11105
Neels Hofmeyrb7581872021-11-07 14:02:49 +010011106 execute( TC_cm_serv_rej() );
11107
Neels Hofmeyr92cfa1c2021-09-28 18:29:44 +020011108 execute( TC_lost_sdcch_during_assignment() );
Neels Hofmeyrafe2ea52021-11-24 15:16:12 +010011109
11110 /* Run TC_ho_out_of_this_bsc last, because it may trigger a segfault before osmo-bsc's patch
11111 * with change-id I5a3345ab0005a73597f5c27207480912a2f5aae6 */
11112 execute( TC_ho_out_of_this_bsc() );
Harald Welte28d943e2017-11-25 15:00:50 +010011113}
11114
11115}