blob: 3aaab853b1d1aa8df3ca4f201ac71fe65dacdb9b [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;
Neels Hofmeyr04d6e6a2021-06-11 00:10:02 +02003883
3884 codecType := exp_ass_req.pdu.bssmap.assignmentRequest.codecList.codecElements[0].codecType;
3885 f_MscConnHdlr_init(g_pars.media_nr, host_bts, host_mgw_mgcp, codecType);
3886
3887 f_create_chan_and_exp();
3888 /* we should now have a COMPL_L3 at the MSC */
3889
Neels Hofmeyr04d6e6a2021-06-11 00:10:02 +02003890 /* Start ciphering, expect Cipher Mode Reject */
Neels Hofmeyr6c388f22021-06-11 02:36:56 +02003891 f_cipher_mode(g_pars.encr, exp_fail := true);
Harald Welte552620d2017-12-16 23:21:36 +01003892}
Neels Hofmeyr04d6e6a2021-06-11 00:10:02 +02003893testcase TC_assignment_fr_a5_not_sup() runs on test_CT {
3894 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte552620d2017-12-16 23:21:36 +01003895 var MSC_ConnHdlr vc_conn;
3896
Harald Welte89d42e82017-12-17 16:42:41 +01003897 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01003898 f_sleep(1.0);
3899
Neels Hofmeyr0588cad2021-06-11 01:38:18 +02003900 pars.encr := valueof(t_EncrParams('20'O, f_rnd_octstring(8), f_rnd_octstring(16)));
Neels Hofmeyr04d6e6a2021-06-11 00:10:02 +02003901 vc_conn := f_start_handler(refers(f_TC_assignment_a5_not_sup), pars);
Harald Welte552620d2017-12-16 23:21:36 +01003902 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003903 f_shutdown_helper();
Harald Welte552620d2017-12-16 23:21:36 +01003904}
3905
3906
Harald Welte4532e0a2017-12-23 02:05:44 +01003907private function f_tc_assignment_sign(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02003908 g_pars := f_gen_test_hdlr_pars();
Harald Welte4532e0a2017-12-23 02:05:44 +01003909 var template PDU_BSSAP exp_compl := tr_BSSMAP_AssignmentComplete(omit, omit);
Philipp Maier48604732018-10-09 15:00:37 +02003910 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte4532e0a2017-12-23 02:05:44 +01003911 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeSIGNAL);
Daniel Willmannebdecc02020-08-12 15:30:17 +02003912
3913 f_statsd_reset();
Harald Weltea0630032018-03-20 21:09:55 +01003914 f_establish_fully(ass_cmd, exp_compl);
Daniel Willmannebdecc02020-08-12 15:30:17 +02003915
3916 var StatsDExpects expect := {
Daniel Willmannc5398f72020-09-21 10:41:35 +02003917 { name := "TTCN3.bts.0.chreq.total", mtype := "c", min := 1, max := 1},
3918 { name := "TTCN3.bts.0.chreq.successful", mtype := "c", min := 1, max := 1},
Daniel Willmannebdecc02020-08-12 15:30:17 +02003919 { name := "TTCN3.bsc.0.assignment.attempted", mtype := "c", min := 1, max := 1},
3920 { name := "TTCN3.bsc.0.assignment.completed", mtype := "c", min := 1, max := 1}
3921 };
3922 f_statsd_expect(expect);
Harald Welte4532e0a2017-12-23 02:05:44 +01003923}
3924
3925testcase TC_assignment_sign() runs on test_CT {
3926 var MSC_ConnHdlr vc_conn;
3927
3928 f_init(1, true);
3929 f_sleep(1.0);
3930
Harald Welte8863fa12018-05-10 20:15:27 +02003931 vc_conn := f_start_handler(refers(f_tc_assignment_sign));
Harald Welte4532e0a2017-12-23 02:05:44 +01003932 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003933 f_shutdown_helper();
Harald Welte4532e0a2017-12-23 02:05:44 +01003934}
3935
Harald Welte60aa5762018-03-21 19:33:13 +01003936/***********************************************************************
3937 * Codec (list) testing
3938 ***********************************************************************/
3939
3940/* check if the given rsl_mode is compatible with the a_elem */
3941private function f_match_codec(BSSMAP_FIELD_CodecElement a_elem, RSL_IE_ChannelMode rsl_mode)
3942return boolean {
3943 select (a_elem.codecType) {
3944 case (GSM_FR) {
3945 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM1))) {
3946 return true;
3947 }
3948 }
3949 case (GSM_HR) {
3950 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1))) {
3951 return true;
3952 }
3953 }
3954 case (GSM_EFR) {
3955 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM2))) {
3956 return true;
3957 }
3958 }
3959 case (FR_AMR) {
3960 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM3))) {
3961 return true;
3962 }
3963 }
3964 case (HR_AMR) {
3965 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM3))) {
3966 return true;
3967 }
3968 }
3969 case else { }
3970 }
3971 return false;
3972}
3973
3974/* check if the given rsl_mode is compatible with the a_list */
3975private function f_match_codecs(BSSMAP_IE_SpeechCodecList a_list, RSL_IE_ChannelMode rsl_mode)
3976return boolean {
3977 for (var integer i := 0; i < sizeof(a_list); i := i+1) {
3978 if (f_match_codec(a_list.codecElements[i], rsl_mode)) {
3979 return true;
3980 }
3981 }
3982 return false;
3983}
3984
3985/* determine BSSMAP_IE_ChannelType from *first* element of BSSMAP_FIELD_CodecElement */
Philipp Maier61f6b572018-07-06 14:03:38 +02003986function f_BSSMAP_chtype_from_codec(BSSMAP_FIELD_CodecElement a_elem)
Harald Welte60aa5762018-03-21 19:33:13 +01003987return BSSMAP_IE_ChannelType {
3988 /* FIXME: actually look at all elements of BSSMAP_IE_SpeechCodecList */
3989 var BSSMAP_IE_ChannelType ret := valueof(ts_BSSMAP_IE_ChannelType);
3990 select (a_elem.codecType) {
3991 case (GSM_FR) {
3992 ret.channelRateAndType := ChRate_TCHF;
3993 ret.speechId_DataIndicator := Spdi_TCHF_FR;
3994 }
3995 case (GSM_HR) {
3996 ret.channelRateAndType := ChRate_TCHH;
3997 ret.speechId_DataIndicator := Spdi_TCHH_HR;
3998 }
3999 case (GSM_EFR) {
4000 ret.channelRateAndType := ChRate_TCHF;
4001 ret.speechId_DataIndicator := Spdi_TCHF_EFR;
4002 }
4003 case (FR_AMR) {
4004 ret.channelRateAndType := ChRate_TCHF;
4005 ret.speechId_DataIndicator := Spdi_TCHF_AMR;
4006 }
4007 case (HR_AMR) {
4008 ret.channelRateAndType := ChRate_TCHH;
4009 ret.speechId_DataIndicator := Spdi_TCHH_AMR;
4010 }
4011 case else {
4012 setverdict(fail, "Unsupported codec ", a_elem);
Daniel Willmannafce8662018-07-06 23:11:32 +02004013 mtc.stop;
Harald Welte60aa5762018-03-21 19:33:13 +01004014 }
4015 }
4016 return ret;
4017}
4018
Harald Weltea63b9102018-03-22 20:36:16 +01004019private function f_rsl_chmod_tmpl_from_codec(BSSMAP_FIELD_CodecElement a_elem)
4020return template RSL_IE_Body {
4021 var template RSL_IE_Body mode_ie := {
4022 chan_mode := {
4023 len := ?,
4024 reserved := ?,
4025 dtx_d := ?,
4026 dtx_u := ?,
4027 spd_ind := RSL_SPDI_SPEECH,
4028 ch_rate_type := -,
4029 coding_alg_rate := -
4030 }
4031 }
4032
4033 select (a_elem.codecType) {
4034 case (GSM_FR) {
4035 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
4036 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM1;
4037 }
4038 case (GSM_HR) {
4039 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_H;
4040 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM1;
4041 }
4042 case (GSM_EFR) {
4043 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
4044 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM2;
4045 }
4046 case (FR_AMR) {
4047 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
4048 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM3;
4049 }
4050 case (HR_AMR) {
4051 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_H;
4052 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM3;
4053 }
4054 }
4055 return mode_ie;
4056}
4057
Harald Welte60aa5762018-03-21 19:33:13 +01004058type record CodecListTest {
4059 BSSMAP_IE_SpeechCodecList codec_list,
4060 charstring id
4061}
4062type record of CodecListTest CodecListTests
4063
4064private function f_TC_assignment_codec(charstring id) runs on MSC_ConnHdlr {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02004065 var PDU_BSSAP ass_cmd := f_gen_ass_req(g_pars.use_osmux);
4066 var template PDU_BSSAP exp_compl := f_gen_exp_compl(g_pars.use_osmux);
Harald Welte60aa5762018-03-21 19:33:13 +01004067
4068 /* puzzle together the ASSIGNMENT REQ for given codec[s] */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02004069 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welte79f3f542018-05-25 20:02:37 +02004070 ass_cmd.pdu.bssmap.assignmentRequest.codecList := g_pars.ass_codec_list;
4071 exp_compl.pdu.bssmap.assignmentComplete.speechCodec.codecElements[0] :=
4072 g_pars.ass_codec_list.codecElements[0];
Philipp Maierd0e64b02019-03-13 14:15:23 +01004073 if (isvalue(g_pars.expect_mr_s0_s7)) {
4074 exp_compl.pdu.bssmap.assignmentComplete.speechCodec.codecElements[0].s0_7 :=
4075 g_pars.expect_mr_s0_s7;
4076 }
Harald Welte79f3f542018-05-25 20:02:37 +02004077 }
Harald Welte60aa5762018-03-21 19:33:13 +01004078 ass_cmd.pdu.bssmap.assignmentRequest.channelType :=
4079 f_BSSMAP_chtype_from_codec(g_pars.ass_codec_list.codecElements[0]);
Harald Welte60aa5762018-03-21 19:33:13 +01004080 log("expecting ASS COMPL like this: ", exp_compl);
4081
4082 f_establish_fully(ass_cmd, exp_compl);
Harald Weltea63b9102018-03-22 20:36:16 +01004083
Neels Hofmeyr559d5d02021-04-16 16:50:49 +02004084 if (not g_pars.expect_channel_mode_modify) {
4085 /* Verify that the RSL-side activation actually matches our expectations */
4086 var RSL_Message rsl := f_rslem_get_last_act(RSL_PROC, 0, g_chan_nr);
Harald Weltea63b9102018-03-22 20:36:16 +01004087
Neels Hofmeyr559d5d02021-04-16 16:50:49 +02004088 var RSL_IE_Body mode_ie;
4089 if (f_rsl_find_ie(rsl, RSL_IE_CHAN_MODE, mode_ie) == false) {
4090 setverdict(fail, "Couldn't find CHAN_MODE IE");
Daniel Willmannafce8662018-07-06 23:11:32 +02004091 mtc.stop;
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02004092 }
Neels Hofmeyr559d5d02021-04-16 16:50:49 +02004093 var template RSL_IE_Body t_mode_ie := f_rsl_chmod_tmpl_from_codec(g_pars.ass_codec_list.codecElements[0]);
4094 if (not match(mode_ie, t_mode_ie)) {
4095 log("mode_ie ", mode_ie, " != t_mode_ie ", t_mode_ie);
4096 setverdict(fail, "RSL Channel Mode IE doesn't match expectation");
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02004097 }
Neels Hofmeyr559d5d02021-04-16 16:50:49 +02004098
4099 var RSL_IE_Body mr_conf;
4100 if (g_pars.expect_mr_conf_ie != omit) {
4101 if (f_rsl_find_ie(rsl, RSL_IE_MR_CONFIG, mr_conf) == false) {
4102 setverdict(fail, "Missing MR CONFIG IE in RSL Chan Activ");
4103 mtc.stop;
4104 }
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02004105 log("found RSL MR CONFIG IE: ", mr_conf);
Neels Hofmeyr559d5d02021-04-16 16:50:49 +02004106
4107 if (not match(mr_conf, g_pars.expect_mr_conf_ie)) {
4108 setverdict(fail, "RSL MR CONFIG IE does not match expectation. Expected: ",
4109 g_pars.expect_mr_conf_ie);
4110 }
4111 } else {
4112 if (f_rsl_find_ie(rsl, RSL_IE_MR_CONFIG, mr_conf) == true) {
4113 log("found RSL MR CONFIG IE: ", mr_conf);
4114 setverdict(fail, "Found MR CONFIG IE in RSL Chan Activ, expecting omit");
4115 mtc.stop;
4116 }
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02004117 }
4118 }
Harald Welte60aa5762018-03-21 19:33:13 +01004119}
4120
Philipp Maierd0e64b02019-03-13 14:15:23 +01004121private function f_TC_assignment_codec_fail(charstring id) runs on MSC_ConnHdlr {
4122
4123 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4124 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
4125
4126 /* puzzle together the ASSIGNMENT REQ for given codec[s] */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02004127 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Philipp Maierd0e64b02019-03-13 14:15:23 +01004128 ass_cmd.pdu.bssmap.assignmentRequest.codecList := g_pars.ass_codec_list;
4129 }
4130 ass_cmd.pdu.bssmap.assignmentRequest.channelType :=
4131 f_BSSMAP_chtype_from_codec(g_pars.ass_codec_list.codecElements[0]);
4132 log("expecting ASS FAIL like this: ", exp_fail);
4133
4134 f_establish_fully(ass_cmd, exp_fail);
4135}
4136
Neels Hofmeyrbcfc9442021-11-29 16:44:08 +01004137const CounterNameVals counternames_bsc_bts_assignment := {
4138 { "assignment:attempted", 0 },
4139 { "assignment:completed", 0 },
4140 { "assignment:stopped", 0 },
4141 { "assignment:no_channel", 0 },
4142 { "assignment:timeout", 0 },
4143 { "assignment:failed", 0 },
4144 { "assignment:error", 0 }
4145};
4146
4147const CounterNameVals counternames_bts_assignment := {
4148 { "assignment:attempted_sign", 0 },
4149 { "assignment:attempted_speech", 0 },
4150 { "assignment:completed_sign", 0 },
4151 { "assignment:completed_speech", 0 },
4152 { "assignment:stopped_sign", 0 },
4153 { "assignment:stopped_speech", 0 },
4154 { "assignment:no_channel_sign", 0 },
4155 { "assignment:no_channel_speech", 0 },
4156 { "assignment:timeout_sign", 0 },
4157 { "assignment:timeout_speech", 0 },
4158 { "assignment:failed_sign", 0 },
4159 { "assignment:failed_speech", 0 },
4160 { "assignment:error_sign", 0 },
4161 { "assignment:error_speech", 0 }
4162};
4163
4164function f_ctrs_bsc_and_bts_assignment_init(integer bts_count := NUM_BTS) runs on test_CT {
4165 var CounterNameVals bts_names := counternames_bsc_bts_assignment & counternames_bts_assignment;
4166 f_ctrs_bts_init(bts_count, bts_names);
4167 f_ctrs_bsc_init(counternames_bsc_bts_assignment);
4168}
4169
Harald Welte60aa5762018-03-21 19:33:13 +01004170testcase TC_assignment_codec_fr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02004171 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01004172 var MSC_ConnHdlr vc_conn;
4173
4174 f_init(1, true);
4175 f_sleep(1.0);
Neels Hofmeyrbcfc9442021-11-29 16:44:08 +01004176 f_ctrs_bsc_and_bts_assignment_init(1);
Harald Welte60aa5762018-03-21 19:33:13 +01004177
4178 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Welte8863fa12018-05-10 20:15:27 +02004179 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01004180 vc_conn.done;
Neels Hofmeyrbcfc9442021-11-29 16:44:08 +01004181
4182 f_ctrs_bsc_and_bts_add(0, "assignment:attempted", 1);
4183 f_ctrs_bts_add(0, "assignment:attempted_speech", 1);
4184 f_ctrs_bsc_and_bts_add(0, "assignment:completed", 1);
4185 f_ctrs_bts_add(0, "assignment:completed_speech", 1);
4186 f_ctrs_bts_verify();
4187
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004188 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01004189}
4190
4191testcase TC_assignment_codec_hr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02004192 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01004193 var MSC_ConnHdlr vc_conn;
4194
4195 f_init(1, true);
4196 f_sleep(1.0);
Neels Hofmeyrbcfc9442021-11-29 16:44:08 +01004197 f_ctrs_bsc_and_bts_assignment_init(1);
Harald Welte60aa5762018-03-21 19:33:13 +01004198
4199 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
Harald Welte8863fa12018-05-10 20:15:27 +02004200 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01004201 vc_conn.done;
Neels Hofmeyrbcfc9442021-11-29 16:44:08 +01004202
4203 f_ctrs_bsc_and_bts_add(0, "assignment:attempted", 1);
4204 f_ctrs_bts_add(0, "assignment:attempted_speech", 1);
4205 f_ctrs_bsc_and_bts_add(0, "assignment:completed", 1);
4206 f_ctrs_bts_add(0, "assignment:completed_speech", 1);
4207 f_ctrs_bts_verify();
4208
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004209 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01004210}
4211
4212testcase TC_assignment_codec_efr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02004213 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01004214 var MSC_ConnHdlr vc_conn;
4215
4216 f_init(1, true);
4217 f_sleep(1.0);
4218
4219 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecEFR}));
Harald Welte8863fa12018-05-10 20:15:27 +02004220 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01004221 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004222 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01004223}
4224
Philipp Maierd0e64b02019-03-13 14:15:23 +01004225/* Allow 5,90k only (current default config) */
4226private function f_allow_amr_rate_5_90k() runs on test_CT {
Neels Hofmeyr2a5670b2020-11-25 23:39:57 +00004227 f_vty_cfg_msc(BSCVTY, 0, {
4228 "amr-config 12_2k forbidden",
4229 "amr-config 10_2k forbidden",
4230 "amr-config 7_95k forbidden",
4231 "amr-config 7_40k forbidden",
4232 "amr-config 6_70k forbidden",
4233 "amr-config 5_90k allowed",
4234 "amr-config 5_15k forbidden",
4235 "amr-config 4_75k forbidden"
4236 });
Philipp Maierd0e64b02019-03-13 14:15:23 +01004237}
4238
4239/* Allow 4,75k, 5,90k, 4,70k and 12,2k, which are the most common rates
4240 * ("Config-NB-Code = 1") */
4241private function f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k() runs on test_CT {
Neels Hofmeyr2a5670b2020-11-25 23:39:57 +00004242 f_vty_cfg_msc(BSCVTY, 0, {
4243 "amr-config 12_2k allowed",
4244 "amr-config 10_2k forbidden",
4245 "amr-config 7_95k forbidden",
4246 "amr-config 7_40k allowed",
4247 "amr-config 6_70k forbidden",
4248 "amr-config 5_90k allowed",
4249 "amr-config 5_15k forbidden",
4250 "amr-config 4_75k allowed"
4251 });
Philipp Maierd0e64b02019-03-13 14:15:23 +01004252}
4253
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00004254private function f_vty_amr_start_mode_set(boolean fr, charstring startmode) runs on test_CT {
4255 var charstring tch;
4256 if (fr) {
4257 tch := "tch-f";
4258 } else {
4259 tch := "tch-h";
4260 }
4261 f_vty_cfg_bts(BSCVTY, 0, { "amr " & tch & " start-mode " & startmode });
4262}
4263
4264/* Set the AMR start-mode for this TCH back to the default configuration. */
4265private function f_vty_amr_start_mode_restore(boolean fr) runs on test_CT {
4266 f_vty_amr_start_mode_set(fr, "auto");
4267}
4268
Harald Welte60aa5762018-03-21 19:33:13 +01004269testcase TC_assignment_codec_amr_f() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02004270 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01004271 var MSC_ConnHdlr vc_conn;
Philipp Maier7695a0d2018-09-27 17:52:14 +02004272
4273 /* Note: This setups the codec configuration. The parameter payload in
4274 * mr_conf must be consistant with the parameter codecElements in pars
4275 * and also must match the amr-config in osmo-bsc.cfg! */
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02004276 var RSL_IE_Body mr_conf := {
4277 other := {
4278 len := 2,
4279 payload := '2804'O
4280 }
4281 };
Harald Welte60aa5762018-03-21 19:33:13 +01004282
Philipp Maier7695a0d2018-09-27 17:52:14 +02004283 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
Philipp Maier806f8f12019-03-12 12:13:41 +01004284 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
Philipp Maier7695a0d2018-09-27 17:52:14 +02004285 pars.ass_codec_list.codecElements[0].s8_15 := '01010111'B;
4286 pars.expect_mr_conf_ie := mr_conf;
4287
Harald Welte60aa5762018-03-21 19:33:13 +01004288 f_init(1, true);
4289 f_sleep(1.0);
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00004290 f_vty_amr_start_mode_set(true, "1");
Neels Hofmeyrbcfc9442021-11-29 16:44:08 +01004291 f_ctrs_bsc_and_bts_assignment_init(1);
Harald Welte60aa5762018-03-21 19:33:13 +01004292
Harald Welte8863fa12018-05-10 20:15:27 +02004293 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01004294 vc_conn.done;
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00004295
Neels Hofmeyrbcfc9442021-11-29 16:44:08 +01004296 f_ctrs_bsc_and_bts_add(0, "assignment:attempted", 1);
4297 f_ctrs_bts_add(0, "assignment:attempted_speech", 1);
4298 f_ctrs_bsc_and_bts_add(0, "assignment:completed", 1);
4299 f_ctrs_bts_add(0, "assignment:completed_speech", 1);
4300 f_ctrs_bts_verify();
4301
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00004302 f_vty_amr_start_mode_restore(true);
Vadim Yanitskiy292e5962021-01-03 14:18:47 +01004303 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01004304}
4305
4306testcase TC_assignment_codec_amr_h() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02004307 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01004308 var MSC_ConnHdlr vc_conn;
Philipp Maier7695a0d2018-09-27 17:52:14 +02004309
4310 /* See note above */
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02004311 var RSL_IE_Body mr_conf := {
4312 other := {
4313 len := 2,
4314 payload := '2804'O
4315 }
4316 };
Harald Welte60aa5762018-03-21 19:33:13 +01004317
Philipp Maier7695a0d2018-09-27 17:52:14 +02004318 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
Philipp Maier806f8f12019-03-12 12:13:41 +01004319 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
Philipp Maier7695a0d2018-09-27 17:52:14 +02004320 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
4321 pars.expect_mr_conf_ie := mr_conf;
4322
Harald Welte60aa5762018-03-21 19:33:13 +01004323 f_init(1, true);
4324 f_sleep(1.0);
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00004325 f_vty_amr_start_mode_set(false, "1");
Neels Hofmeyrbcfc9442021-11-29 16:44:08 +01004326 f_ctrs_bsc_and_bts_assignment_init(1);
Harald Welte60aa5762018-03-21 19:33:13 +01004327
Harald Welte8863fa12018-05-10 20:15:27 +02004328 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01004329 vc_conn.done;
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00004330
Neels Hofmeyrbcfc9442021-11-29 16:44:08 +01004331 f_ctrs_bsc_and_bts_add(0, "assignment:attempted", 1);
4332 f_ctrs_bts_add(0, "assignment:attempted_speech", 1);
4333 f_ctrs_bsc_and_bts_add(0, "assignment:completed", 1);
4334 f_ctrs_bts_add(0, "assignment:completed_speech", 1);
4335 f_ctrs_bts_verify();
4336
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00004337 f_vty_amr_start_mode_restore(false);
Vadim Yanitskiy292e5962021-01-03 14:18:47 +01004338 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01004339}
4340
Neels Hofmeyr559d5d02021-04-16 16:50:49 +02004341/* Establish signalling on a TCH/F lchan, and then switch to speech mode without a new Assignment. */
4342testcase TC_assignment_codec_fr_by_mode_modify() runs on test_CT {
4343 var TestHdlrParams pars := f_gen_test_hdlr_pars();
4344 var MSC_ConnHdlr vc_conn;
4345
4346 f_init(1, true);
4347 f_sleep(1.0);
4348
4349 /* By disabling all SDCCH, the MS should be given a TCH/F for signalling. Then activating an FR codec should
4350 * merely do a Channel Mode Modify, and not assign to a new lchan. f_establish_fully() already accounts for
4351 * expecting a Channel Mode Modify if the channel type is compatible. */
4352 f_disable_all_sdcch();
4353 f_disable_all_tch_h();
4354
4355 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4356 pars.expect_channel_mode_modify := true;
4357 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
4358 vc_conn.done;
4359
4360 f_enable_all_sdcch();
4361 f_enable_all_tch();
4362 f_shutdown_helper();
4363}
4364
Neels Hofmeyr454d7922020-11-26 02:24:57 +00004365/* 'amr start-mode auto' should not keep the (unused) 'smod' bits from previous configuration */
4366testcase TC_assignment_codec_amr_startmode_cruft() runs on test_CT {
4367 var TestHdlrParams pars := f_gen_test_hdlr_pars();
4368 var MSC_ConnHdlr vc_conn;
4369
4370 var RSL_IE_Body mr_conf := {
4371 other := {
4372 len := 2,
4373 payload := '2004'O /* <- expect ICMI=0, smod=00 */
4374 }
4375 };
4376
4377 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
4378 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
4379 pars.ass_codec_list.codecElements[0].s8_15 := '01010111'B;
4380 pars.expect_mr_conf_ie := mr_conf;
4381
4382 f_init(1, true);
4383 f_sleep(1.0);
4384
4385 /* First set nonzero start mode bits */
4386 f_vty_amr_start_mode_set(true, "4");
4387 /* Now set to auto, and expect the startmode bits to be zero in the message, i.e. ensure that osmo-bsc does not
4388 * let the startmode bits stick around and has deterministic MultiRate config for 'start-mode auto'; that is
4389 * ensured by above '2004'O, where 'x0xx'O indicates ICMI = 0, spare = 0, smod = 00. */
4390 f_vty_amr_start_mode_set(true, "auto");
4391
4392 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
4393 vc_conn.done;
Neels Hofmeyr454d7922020-11-26 02:24:57 +00004394
4395 /* Clear the startmode bits to not affect subsequent tests, in case the bits should indeed stick around. */
4396 f_vty_amr_start_mode_set(true, "1");
4397 f_vty_amr_start_mode_restore(true);
Vadim Yanitskiy292e5962021-01-03 14:18:47 +01004398 f_shutdown_helper();
Neels Hofmeyr454d7922020-11-26 02:24:57 +00004399}
4400
Neels Hofmeyr21863562020-11-26 00:34:33 +00004401function f_TC_assignment_codec_amr(boolean fr, octetstring mrconf, bitstring s8_s0, bitstring exp_s8_s0,
4402 charstring start_mode := "1")
Philipp Maierd0e64b02019-03-13 14:15:23 +01004403runs on test_CT {
4404
4405 var TestHdlrParams pars := f_gen_test_hdlr_pars();
4406 var MSC_ConnHdlr vc_conn;
4407
4408 /* See note above */
4409 var RSL_IE_Body mr_conf := {
4410 other := {
4411 len := lengthof(mrconf),
4412 payload := mrconf
4413 }
4414 };
4415
4416 if (fr) {
4417 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
4418 } else {
4419 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
4420 }
4421 pars.ass_codec_list.codecElements[0].s0_7 := s8_s0;
4422 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
4423 pars.expect_mr_conf_ie := mr_conf;
4424 pars.expect_mr_s0_s7 := exp_s8_s0;
4425
4426 f_init(1, true);
4427 f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k();
Neels Hofmeyr21863562020-11-26 00:34:33 +00004428 f_vty_amr_start_mode_set(fr, start_mode);
Philipp Maierd0e64b02019-03-13 14:15:23 +01004429 f_sleep(1.0);
4430
4431 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
4432 vc_conn.done;
4433 f_allow_amr_rate_5_90k();
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00004434 f_vty_amr_start_mode_restore(fr);
Philipp Maierd0e64b02019-03-13 14:15:23 +01004435}
4436
4437function f_TC_assignment_codec_amr_fail(boolean fr, bitstring s8_s0)
4438runs on test_CT {
4439
4440 var TestHdlrParams pars := f_gen_test_hdlr_pars();
4441 var MSC_ConnHdlr vc_conn;
4442
4443 if (fr) {
4444 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
4445 } else {
4446 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
4447 }
4448 pars.ass_codec_list.codecElements[0].s0_7 := s8_s0;
4449 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
4450
4451 f_init(1, true);
4452 f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k();
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00004453 f_vty_amr_start_mode_set(fr, "1");
Philipp Maierd0e64b02019-03-13 14:15:23 +01004454 f_sleep(1.0);
4455
4456 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fail), pars);
4457 vc_conn.done;
4458 f_allow_amr_rate_5_90k();
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00004459 f_vty_amr_start_mode_restore(fr);
Philipp Maierd0e64b02019-03-13 14:15:23 +01004460}
4461
4462
4463/* Set S1, we expect an AMR multirate configuration IE with all four rates
4464 * set. */
4465testcase TC_assignment_codec_amr_f_S1() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004466 f_TC_assignment_codec_amr(true, '289520882208'O, '00000010'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004467 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004468}
4469
4470/* Set S1, we expect an AMR multirate configuration IE with the lower three
4471 * rates set. */
4472testcase TC_assignment_codec_amr_h_S1() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004473 f_TC_assignment_codec_amr(false, '2815208820'O, '00000010'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004474 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004475}
4476
4477/* Set S1 and two other rates, we expect an AMR MULTIRATE CONFIGURATION IE with
4478 * all four rates (and only S1 set in the ASSIGNMENT COMPLETE) */
4479testcase TC_assignment_codec_amr_f_S124() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004480 f_TC_assignment_codec_amr(true, '289520882208'O, '00010110'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004481 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004482}
4483
4484/* Set S1 and two other rates, we expect an AMR MULTIRATE CONFIGURATION IE with
4485 * all four rates (and only S1 set in the ASSIGNMENT COMPLETE) */
4486testcase TC_assignment_codec_amr_h_S124() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004487 f_TC_assignment_codec_amr(false, '2815208820'O, '00010110'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004488 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004489}
4490
4491/* The following block of tests selects more and more rates until all four
4492 * possible rates are in the active set (full rate) */
4493testcase TC_assignment_codec_amr_f_S0() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004494 f_TC_assignment_codec_amr(true, '2801'O, '00000001'B, '00000001'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004495 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004496}
4497
4498testcase TC_assignment_codec_amr_f_S02() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004499 f_TC_assignment_codec_amr(true, '28052080'O, '00000101'B, '00000101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004500 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004501}
4502
4503testcase TC_assignment_codec_amr_f_S024() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004504 f_TC_assignment_codec_amr(true, '2815208820'O, '00010101'B, '00010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004505 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004506}
4507
4508testcase TC_assignment_codec_amr_f_S0247() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004509 f_TC_assignment_codec_amr(true, '289520882208'O, '10010101'B, '10010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004510 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004511}
4512
4513/* The following block of tests selects more and more rates until all three
4514 * possible rates are in the active set (half rate) */
4515testcase TC_assignment_codec_amr_h_S0() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004516 f_TC_assignment_codec_amr(false, '2801'O, '00000001'B, '00000001'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004517 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004518}
4519
4520testcase TC_assignment_codec_amr_h_S02() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004521 f_TC_assignment_codec_amr(false, '28052080'O, '00000101'B, '00000101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004522 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004523}
4524
4525testcase TC_assignment_codec_amr_h_S024() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004526 f_TC_assignment_codec_amr(false, '2815208820'O, '00010101'B, '00010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004527 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004528}
4529
4530/* The following block tests what happens when the MSC does offer rate
4531 * configurations that are not supported by the BSC. Normally such situations
4532 * should not happen because the MSC gets informed by the BSC in advance via
4533 * the L3 COMPLETE message which rates are applicable. The MSC should not try
4534 * to offer rates that are not applicable anyway. */
4535
4536testcase TC_assignment_codec_amr_h_S0247() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004537 /* Try to include 12,2k in into the active set even though the channel
4538 * is half rate only. The BSC is expected to remove the 12,0k */
4539 f_TC_assignment_codec_amr(false, '2815208820'O, '10010101'B, '00010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004540 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004541}
4542
4543testcase TC_assignment_codec_amr_f_S01234567() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004544 /* See what happens when all rates are selected at once. Since then
4545 * Also S1 is selected, this setting will be prefered and we should
4546 * get 12.2k, 7,40k, 5,90k, and 4,75k in the active set. */
4547 f_TC_assignment_codec_amr(true, '289520882208'O, '11111111'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004548 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004549}
4550
4551testcase TC_assignment_codec_amr_f_S0234567() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004552 /* Same as above, but with S1 missing, the MSC is then expected to
4553 * select the currently supported rates, which are also 12.2k, 7,40k,
4554 * 5,90k, and 4,75k, into the active set. */
4555 f_TC_assignment_codec_amr(true, '289520882208'O, '11111101'B, '10010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004556 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004557}
4558
4559testcase TC_assignment_codec_amr_f_zero() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004560 /* Try to select no rates at all */
4561 f_TC_assignment_codec_amr_fail(true, '00000000'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004562 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004563}
4564
4565testcase TC_assignment_codec_amr_f_unsupp() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004566 /* Try to select only unsupported rates */
4567 f_TC_assignment_codec_amr_fail(true, '01101000'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004568 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004569}
4570
4571testcase TC_assignment_codec_amr_h_S7() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004572 /* Try to select 12,2k for half rate */
4573 f_TC_assignment_codec_amr_fail(false, '10000000'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004574 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004575}
4576
Neels Hofmeyr21863562020-11-26 00:34:33 +00004577testcase TC_assignment_codec_amr_f_start_mode_auto() runs on test_CT {
4578 f_TC_assignment_codec_amr(true, '209520882208'O, '11111111'B, '00000010'B,
4579 start_mode := "auto");
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01004580 f_shutdown_helper();
Neels Hofmeyr21863562020-11-26 00:34:33 +00004581}
4582
4583testcase TC_assignment_codec_amr_h_start_mode_auto() runs on test_CT {
4584 f_TC_assignment_codec_amr(false, '2015208820'O, '10010101'B, '00010101'B,
4585 start_mode := "auto");
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01004586 f_shutdown_helper();
Neels Hofmeyr21863562020-11-26 00:34:33 +00004587}
4588
Neels Hofmeyr3eb94562020-11-26 02:40:26 +00004589testcase TC_assignment_codec_amr_f_start_mode_4() runs on test_CT {
Vadim Yanitskiy7815f482021-01-03 17:07:37 +01004590 /* "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 +00004591 f_TC_assignment_codec_amr(true, '2b9520882208'O, '11111111'B, '00000010'B,
4592 start_mode := "4");
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01004593 f_shutdown_helper();
Neels Hofmeyr3eb94562020-11-26 02:40:26 +00004594}
4595
4596testcase TC_assignment_codec_amr_h_start_mode_4() runs on test_CT {
Vadim Yanitskiy7815f482021-01-03 17:07:37 +01004597 /* "amr tch-h modes 0 2 4" => total 3 modes and start mode 4 => '10'B on the wire */
4598 f_TC_assignment_codec_amr(false, '2a15208820'O, '10010101'B, '00010101'B,
Neels Hofmeyr3eb94562020-11-26 02:40:26 +00004599 start_mode := "4");
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01004600 f_shutdown_helper();
Neels Hofmeyr3eb94562020-11-26 02:40:26 +00004601}
4602
Philipp Maierac09bfc2019-01-08 13:41:39 +01004603private function f_disable_all_tch_f() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01004604 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 1 sub-slot 0 borken");
4605 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 2 sub-slot 0 borken");
4606 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 3 sub-slot 0 borken");
4607 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 4 sub-slot 0 borken");
Philipp Maierac09bfc2019-01-08 13:41:39 +01004608}
4609
4610private function f_disable_all_tch_h() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01004611 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 0 borken");
4612 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 1 borken");
Philipp Maierac09bfc2019-01-08 13:41:39 +01004613}
4614
4615private function f_enable_all_tch() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01004616 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 1 sub-slot 0 unused");
4617 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 2 sub-slot 0 unused");
4618 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 3 sub-slot 0 unused");
4619 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 4 sub-slot 0 unused");
4620 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 0 unused");
4621 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 1 unused");
Philipp Maierac09bfc2019-01-08 13:41:39 +01004622}
4623
Neels Hofmeyr559d5d02021-04-16 16:50:49 +02004624private function f_disable_all_sdcch() runs on test_CT {
4625 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 0 sub-slot 0 borken");
4626 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 0 sub-slot 1 borken");
4627 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 0 sub-slot 2 borken");
4628 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 0 sub-slot 3 borken");
4629}
4630
4631private function f_enable_all_sdcch() runs on test_CT {
4632 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 0 sub-slot 0 unused");
4633 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 0 sub-slot 1 unused");
4634 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 0 sub-slot 2 unused");
4635 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 0 sub-slot 3 unused");
4636}
4637
Philipp Maierac09bfc2019-01-08 13:41:39 +01004638/* Allow HR only */
4639private function f_TC_assignment_codec_xr_exhausted_req_hr(charstring id) runs on MSC_ConnHdlr {
4640 g_pars := f_gen_test_hdlr_pars();
4641 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4642 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4643 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4644 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '09'O;
4645 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '05'O;
4646 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
4647 f_establish_fully(ass_cmd, exp_compl);
4648}
4649
4650/* Allow FR only */
4651private function f_TC_assignment_codec_xr_exhausted_req_fr(charstring id) runs on MSC_ConnHdlr {
4652 g_pars := f_gen_test_hdlr_pars();
4653 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4654 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4655 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4656 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '08'O;
4657 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '01'O;
4658 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4659 f_establish_fully(ass_cmd, exp_compl);
4660}
4661
4662/* Allow HR only (expect assignment failure) */
4663private function f_TC_assignment_codec_xr_exhausted_req_hr_fail(charstring id) runs on MSC_ConnHdlr {
4664 g_pars := f_gen_test_hdlr_pars();
4665 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4666 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
4667 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4668 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '09'O;
4669 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '05'O;
4670 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
4671 f_establish_fully(ass_cmd, exp_fail);
4672}
4673
4674/* Allow FR only (expect assignment failure) */
4675private function f_TC_assignment_codec_xr_exhausted_req_fr_fail(charstring id) runs on MSC_ConnHdlr {
4676 g_pars := f_gen_test_hdlr_pars();
4677 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4678 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
4679 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4680 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '08'O;
4681 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '01'O;
4682 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4683 f_establish_fully(ass_cmd, exp_fail);
4684}
4685
4686/* Allow FR and HR, but prefer FR */
4687private function f_TC_assignment_codec_fr_exhausted_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
4688 g_pars := f_gen_test_hdlr_pars();
4689 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4690 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4691 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4692 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
4693 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
4694 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
4695 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
4696 f_establish_fully(ass_cmd, exp_compl);
4697}
4698
4699/* Allow FR and HR, but prefer HR */
4700private function f_TC_assignment_codec_fr_exhausted_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
4701 g_pars := f_gen_test_hdlr_pars();
4702 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4703 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4704 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4705 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
4706 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
4707 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
4708 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
4709 f_establish_fully(ass_cmd, exp_compl);
4710}
4711
4712/* Allow FR and HR, but prefer FR */
4713private function f_TC_assignment_codec_hr_exhausted_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
4714 g_pars := f_gen_test_hdlr_pars();
4715 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4716 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4717 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4718 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
4719 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
4720 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
4721 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
4722 f_establish_fully(ass_cmd, exp_compl);
4723}
4724
4725/* Allow FR and HR, but prefer HR */
4726private function f_TC_assignment_codec_hr_exhausted_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
4727 g_pars := f_gen_test_hdlr_pars();
4728 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4729 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4730 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4731 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
4732 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
4733 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
4734 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
4735 f_establish_fully(ass_cmd, exp_compl);
4736}
4737
4738/* Request a HR channel while all FR channels are exhausted, this is expected
4739 * to work without conflicts */
4740testcase TC_assignment_codec_fr_exhausted_req_hr() runs on test_CT {
4741 var MSC_ConnHdlr vc_conn;
4742 f_init(1, true);
4743 f_sleep(1.0);
4744 f_enable_all_tch();
4745 f_disable_all_tch_f();
4746 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_hr));
4747 vc_conn.done;
4748 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004749 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004750}
4751
4752/* Request a FR channel while all FR channels are exhausted, this is expected
4753 * to fail. */
4754testcase TC_assignment_codec_fr_exhausted_req_fr() runs on test_CT {
4755 var MSC_ConnHdlr vc_conn;
4756 f_init(1, true);
4757 f_sleep(1.0);
4758 f_enable_all_tch();
4759 f_disable_all_tch_f();
4760 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_fr_fail));
4761 vc_conn.done;
4762 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004763 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004764}
4765
4766/* Request a FR (prefered) or alternatively a HR channel while all FR channels
4767 * are exhausted, this is expected to be resolved by selecting a HR channel. */
4768testcase TC_assignment_codec_fr_exhausted_req_fr_hr() runs on test_CT {
4769 var MSC_ConnHdlr vc_conn;
4770 f_init(1, true);
4771 f_sleep(1.0);
4772 f_enable_all_tch();
4773 f_disable_all_tch_f();
4774 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fr_exhausted_req_fr_hr));
4775 vc_conn.done;
4776 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004777 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004778}
4779
4780/* Request a HR (prefered) or alternatively a FR channel while all FR channels
4781 * are exhausted, this is expected to work without conflicts. */
4782testcase TC_assignment_codec_fr_exhausted_req_hr_fr() runs on test_CT {
4783 var MSC_ConnHdlr vc_conn;
4784 f_init(1, true);
4785 f_sleep(1.0);
4786 f_enable_all_tch();
4787 f_disable_all_tch_f();
4788 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fr_exhausted_req_hr_fr));
4789 vc_conn.done;
4790 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004791 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004792}
4793
4794/* Request a FR channel while all HR channels are exhausted, this is expected
4795 * to work without conflicts */
4796testcase TC_assignment_codec_hr_exhausted_req_fr() runs on test_CT {
4797 var MSC_ConnHdlr vc_conn;
4798 f_init(1, true);
4799 f_sleep(1.0);
4800 f_enable_all_tch();
4801 f_disable_all_tch_h();
4802 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_fr));
4803 vc_conn.done;
4804 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004805 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004806}
4807
4808/* Request a HR channel while all HR channels are exhausted, this is expected
4809 * to fail. */
4810testcase TC_assignment_codec_hr_exhausted_req_hr() runs on test_CT {
4811 var MSC_ConnHdlr vc_conn;
4812 f_init(1, true);
4813 f_sleep(1.0);
4814 f_enable_all_tch();
4815 f_disable_all_tch_h();
4816 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_hr_fail));
4817 vc_conn.done;
4818 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004819 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004820}
4821
4822/* Request a HR (prefered) or alternatively a FR channel while all HR channels
4823 * are exhausted, this is expected to be resolved by selecting a FR channel. */
4824testcase TC_assignment_codec_hr_exhausted_req_hr_fr() runs on test_CT {
4825 var MSC_ConnHdlr vc_conn;
4826 f_init(1, true);
4827 f_sleep(1.0);
4828 f_enable_all_tch();
4829 f_disable_all_tch_h();
4830 vc_conn := f_start_handler(refers(f_TC_assignment_codec_hr_exhausted_req_hr_fr));
4831 vc_conn.done;
4832 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004833 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004834}
4835
4836/* Request a FR (prefered) or alternatively a HR channel while all HR channels
4837 * are exhausted, this is expected to work without conflicts. */
4838testcase TC_assignment_codec_hr_exhausted_req_fr_hr() runs on test_CT {
4839 var MSC_ConnHdlr vc_conn;
4840 f_init(1, true);
4841 f_sleep(1.0);
4842 f_enable_all_tch();
4843 f_disable_all_tch_h();
4844 vc_conn := f_start_handler(refers(f_TC_assignment_codec_hr_exhausted_req_fr_hr));
4845 vc_conn.done;
4846 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004847 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004848}
4849
4850/* Allow FR and HR, but prefer HR */
4851private function f_TC_assignment_codec_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
4852 g_pars := f_gen_test_hdlr_pars();
4853 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4854 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4855 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4856 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
4857 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
4858 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
4859 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
4860 f_establish_fully(ass_cmd, exp_compl);
4861}
4862
4863/* Allow FR and HR, but prefer FR */
4864private function f_TC_assignment_codec_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
4865 g_pars := f_gen_test_hdlr_pars();
4866 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4867 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4868 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4869 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
4870 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
4871 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
4872 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
4873 f_establish_fully(ass_cmd, exp_compl);
4874}
4875
4876/* Request a HR (prefered) or alternatively a FR channel, it is expected that
4877 * HR, which is the prefered type, is selected. */
4878testcase TC_assignment_codec_req_hr_fr() runs on test_CT {
4879 var MSC_ConnHdlr vc_conn;
4880 f_init(1, true);
4881 f_sleep(1.0);
4882 f_enable_all_tch();
4883 vc_conn := f_start_handler(refers(f_TC_assignment_codec_req_hr_fr));
4884 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004885 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004886}
4887
4888/* Request a FR (prefered) or alternatively a HR channel, it is expected that
4889 * FR, which is the prefered type, is selected. */
4890testcase TC_assignment_codec_req_fr_hr() runs on test_CT {
4891 var MSC_ConnHdlr vc_conn;
4892 f_init(1, true);
4893 f_sleep(1.0);
4894 f_enable_all_tch();
4895 vc_conn := f_start_handler(refers(f_TC_assignment_codec_req_fr_hr));
4896 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004897 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004898}
4899
Pau Espin Pedrol14475352021-07-22 15:48:16 +02004900/* request a signalling channel with all SDCCH exhausted, it is expected that a TCH will be selected */
4901private function f_TC_assignment_sdcch_exhausted_req_signalling(charstring id) runs on MSC_ConnHdlr {
4902 g_pars := f_gen_test_hdlr_pars();
4903 g_pars.ra := '02'O; /* RA containing reason=LU */
4904
4905 var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi));
4906 var PDU_ML3_MS_NW l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, mi));
4907 var octetstring l3_enc := enc_PDU_ML3_MS_NW(l3_info);
4908 var template uint3_t tsc := ?;
4909
4910 f_MscConnHdlr_init(g_pars.media_nr, host_bts, host_mgw_mgcp, FR_AMR);
4911 f_create_bssmap_exp(l3_enc);
4912 /* call helper function for CHAN_RQD -> IMM ASS ->EST_IND */
4913 RSL_Emulation.f_chan_est(g_pars.ra, l3_enc, g_pars.link_id, g_pars.fn, tsc);
4914
4915 /* we should now have a COMPL_L3 at the MSC */
4916 timer T := 10.0;
4917 T.start;
4918 alt {
4919 [] BSSAP.receive(tr_BSSMAP_ComplL3);
4920 [] T.timeout {
4921 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for COMPLETE LAYER 3 INFORMATION");
4922 }
4923 }
4924}
4925testcase TC_assignment_sdcch_exhausted_req_signalling() runs on test_CT {
4926 var MSC_ConnHdlr vc_conn;
4927 f_init(1, true);
4928 f_sleep(1.0);
4929 f_disable_all_sdcch();
4930 vc_conn := f_start_handler(refers(f_TC_assignment_sdcch_exhausted_req_signalling));
4931 vc_conn.done;
4932 f_enable_all_sdcch();
4933 f_shutdown_helper();
4934}
4935
4936/* Request a signalling channel with all SDCCH exhausted, it is
4937 expected that no TCH will be selected for signalling and assigment will fail
4938 because it's dictated by VTY config */
4939testcase TC_assignment_sdcch_exhausted_req_signalling_tch_forbidden() runs on test_CT {
4940 var RSL_Message rsl_unused, rsl_msg;
4941 var GsmRrMessage rr;
4942 f_init(1, false);
4943 f_sleep(1.0);
4944 f_vty_allow_tch_for_signalling(false, 0);
4945 f_disable_all_sdcch();
4946
4947 /* RA containing reason=LU */
4948 f_ipa_tx(0, ts_RSL_CHAN_RQD('02'O, 2342));
4949 rsl_msg := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
4950 rr := dec_GsmRrMessage(rsl_msg.ies[1].body.full_imm_ass_info.payload);
4951 if (rr.header.message_type != IMMEDIATE_ASSIGNMENT_REJECT) {
4952 setverdict(fail, "Expected reject");
4953 }
4954
4955 f_vty_allow_tch_for_signalling(true, 0);
4956 f_enable_all_sdcch();
4957 f_shutdown_helper();
4958}
4959
4960/* Request a voice channel with all SDCCH exhausted, it is
4961 * expected that TCH channel will be allocated since the VTY option is only
4962 * aimed at signalling requests */
4963private function f_TC_assignment_sdcch_exhausted_req_voice_tch_forbidden(charstring id) runs on MSC_ConnHdlr {
4964 g_pars := f_gen_test_hdlr_pars();
4965 g_pars.ra := '43'O; /* RA containing reason=originating speech call*/
4966
4967 var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi));
4968 var PDU_ML3_MS_NW l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, mi));
4969 var octetstring l3_enc := enc_PDU_ML3_MS_NW(l3_info);
4970 var template uint3_t tsc := ?;
4971
4972 f_MscConnHdlr_init(g_pars.media_nr, host_bts, host_mgw_mgcp, FR_AMR);
4973 f_create_bssmap_exp(l3_enc);
4974 /* call helper function for CHAN_RQD -> IMM ASS ->EST_IND */
4975 RSL_Emulation.f_chan_est(g_pars.ra, l3_enc, g_pars.link_id, g_pars.fn, tsc);
4976
4977 /* we should now have a COMPL_L3 at the MSC */
4978 timer T := 10.0;
4979 T.start;
4980 alt {
4981 [] BSSAP.receive(tr_BSSMAP_ComplL3);
4982 [] T.timeout {
4983 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for COMPLETE LAYER 3 INFORMATION");
4984 }
4985 }
4986}
4987testcase TC_assignment_sdcch_exhausted_req_voice_tch_forbidden() runs on test_CT {
4988 var MSC_ConnHdlr vc_conn;
4989 f_init(1, true);
4990 f_sleep(1.0);
4991 f_vty_allow_tch_for_signalling(false, 0);
4992 f_disable_all_sdcch();
4993
4994 vc_conn := f_start_handler(refers(f_TC_assignment_sdcch_exhausted_req_voice_tch_forbidden));
4995 vc_conn.done;
4996
4997 f_vty_allow_tch_for_signalling(true, 0);
4998 f_enable_all_sdcch();
4999 f_shutdown_helper();
5000}
5001
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02005002testcase TC_assignment_osmux() runs on test_CT {
5003 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5004 var MSC_ConnHdlr vc_conn;
5005
5006 /* See note above */
5007 var RSL_IE_Body mr_conf := {
5008 other := {
5009 len := 2,
5010 payload := '2804'O
5011 }
5012 };
5013
5014 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
5015 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
5016 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
5017 pars.expect_mr_conf_ie := mr_conf;
5018 pars.use_osmux := true;
5019
5020 f_init(1, true, true);
5021 f_sleep(1.0);
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00005022 f_vty_amr_start_mode_set(false, "1");
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02005023
5024 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
5025 vc_conn.done;
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00005026
5027 f_vty_amr_start_mode_restore(false);
Vadim Yanitskiy292e5962021-01-03 14:18:47 +01005028 f_shutdown_helper();
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02005029}
5030
Neels Hofmeyr92b12b72018-09-18 14:30:23 +02005031/* test the procedure of the MSC requesting a Classmark Update:
5032 * a) BSSMAP Classmark Request should result in RR CLASSMARK ENQUIRY,
5033 * b) L3 RR CLASSMARK CHANGE should result in BSSMAP CLASSMARK UPDATE */
Harald Welte898113b2018-01-31 18:32:21 +01005034private function f_tc_classmark(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02005035 g_pars := f_gen_test_hdlr_pars();
5036
Harald Weltea0630032018-03-20 21:09:55 +01005037 f_create_chan_and_exp();
Harald Welte898113b2018-01-31 18:32:21 +01005038 /* we should now have a COMPL_L3 at the MSC */
Harald Welte898113b2018-01-31 18:32:21 +01005039
Neels Hofmeyr92b12b72018-09-18 14:30:23 +02005040 BSSAP.send(ts_BSSMAP_ClassmarkRequest);
5041 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_CM_ENQUIRY));
5042
Harald Welte898113b2018-01-31 18:32:21 +01005043 f_rsl_send_l3(ts_RRM_CM_CHG(valueof(ts_CM2)));
5044 BSSAP.receive(tr_BSSMAP_ClassmarkUpd(?, omit));
5045 setverdict(pass);
5046}
5047testcase TC_classmark() runs on test_CT {
5048 var MSC_ConnHdlr vc_conn;
5049 f_init(1, true);
5050 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02005051 vc_conn := f_start_handler(refers(f_tc_classmark));
Harald Welte898113b2018-01-31 18:32:21 +01005052 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005053 f_shutdown_helper();
Harald Welte898113b2018-01-31 18:32:21 +01005054}
5055
Harald Welteeddf0e92020-06-21 19:42:15 +02005056/* Send a CommonID from the simulated MSC and verify that the information is used to
5057 * fill BSC-internal data structures (specifically, bsc_subscr associated with subscr_conn) */
5058private function f_tc_common_id(charstring id) runs on MSC_ConnHdlr {
5059 g_pars := f_gen_test_hdlr_pars();
5060 f_MscConnHdlr_init_vty();
5061
5062 f_create_chan_and_exp();
5063 /* we should now have a COMPL_L3 at the MSC */
Harald Welteeddf0e92020-06-21 19:42:15 +02005064
5065 /* Send CommonID */
5066 BSSAP.send(ts_BSSMAP_CommonId(g_pars.imsi));
5067
5068 /* Use VTY to verify that the IMSI of the subscr_conn is set */
5069 var charstring regex := "*(IMSI: " & hex2str(g_pars.imsi) & ")*";
5070 f_vty_transceive_match_regexp_retry(BSCVTY, "show conns", regex, 0, 4, 1.0);
5071
5072 setverdict(pass);
5073}
5074testcase TC_common_id() runs on test_CT {
5075 var MSC_ConnHdlr vc_conn;
5076 f_init(1, true);
5077 f_sleep(1.0);
5078 vc_conn := f_start_handler(refers(f_tc_common_id));
5079 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005080 f_shutdown_helper();
Harald Welteeddf0e92020-06-21 19:42:15 +02005081}
5082
Harald Weltee3bd6582018-01-31 22:51:25 +01005083private function f_est_single_l3(template PDU_ML3_MS_NW l3) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02005084 g_pars := f_gen_test_hdlr_pars();
Harald Weltea0630032018-03-20 21:09:55 +01005085 f_create_chan_and_exp();
Harald Welte898113b2018-01-31 18:32:21 +01005086 /* we should now have a COMPL_L3 at the MSC */
Harald Welte898113b2018-01-31 18:32:21 +01005087
Harald Weltee3bd6582018-01-31 22:51:25 +01005088 /* send the single message we want to send */
5089 f_rsl_send_l3(l3);
5090}
5091
5092private function f_bssap_expect_nothing(float sec := 5.00) runs on MSC_ConnHdlr {
5093 timer T := sec;
5094 var PDU_BSSAP bssap;
Harald Welte898113b2018-01-31 18:32:21 +01005095 T.start;
5096 alt {
Harald Weltee3bd6582018-01-31 22:51:25 +01005097 [] BSSAP.receive(PDU_BSSAP:?) -> value bssap {
5098 setverdict(fail, "Unexpected BSSMAP ", bssap);
Daniel Willmannafce8662018-07-06 23:11:32 +02005099 mtc.stop;
Harald Welte898113b2018-01-31 18:32:21 +01005100 }
5101 [] T.timeout {
5102 setverdict(pass);
5103 }
5104 }
5105}
5106
Harald Weltee3bd6582018-01-31 22:51:25 +01005107/* unsolicited ASSIGNMENT FAIL (without ASSIGN) from MS shouldn't bring BSC down */
5108private function f_tc_unsol_ass_fail(charstring id) runs on MSC_ConnHdlr {
5109 f_est_single_l3(ts_RRM_AssignmentFailure('00'O));
5110 f_bssap_expect_nothing();
5111}
Harald Welte898113b2018-01-31 18:32:21 +01005112testcase TC_unsol_ass_fail() runs on test_CT {
5113 var MSC_ConnHdlr vc_conn;
5114 f_init(1, true);
5115 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02005116 vc_conn := f_start_handler(refers(f_tc_unsol_ass_fail));
Harald Welte898113b2018-01-31 18:32:21 +01005117 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005118 f_shutdown_helper();
Harald Welte898113b2018-01-31 18:32:21 +01005119}
Harald Welte552620d2017-12-16 23:21:36 +01005120
Harald Welteea99a002018-01-31 20:46:43 +01005121
5122/* unsolicited ASSIGNMENT COMPLETE (without ASSIGN) from MS shouldn't bring BSC down */
5123private function f_tc_unsol_ass_compl(charstring id) runs on MSC_ConnHdlr {
Harald Weltee3bd6582018-01-31 22:51:25 +01005124 f_est_single_l3(ts_RRM_AssignmentComplete('00'O));
5125 f_bssap_expect_nothing();
Harald Welteea99a002018-01-31 20:46:43 +01005126}
5127testcase TC_unsol_ass_compl() runs on test_CT {
5128 var MSC_ConnHdlr vc_conn;
5129 f_init(1, true);
5130 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02005131 vc_conn := f_start_handler(refers(f_tc_unsol_ass_compl));
Harald Welteea99a002018-01-31 20:46:43 +01005132 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005133 f_shutdown_helper();
Harald Welteea99a002018-01-31 20:46:43 +01005134}
5135
5136
Harald Weltefbf9b5e2018-01-31 20:41:23 +01005137/* unsolicited HANDOVER FAIL (without ASSIGN) from MS shouldn't bring BSC down */
5138private function f_tc_unsol_ho_fail(charstring id) runs on MSC_ConnHdlr {
Harald Weltee3bd6582018-01-31 22:51:25 +01005139 f_est_single_l3(ts_RRM_HandoverFailure('00'O));
5140 f_bssap_expect_nothing();
Harald Weltefbf9b5e2018-01-31 20:41:23 +01005141}
Harald Weltefbf9b5e2018-01-31 20:41:23 +01005142testcase TC_unsol_ho_fail() runs on test_CT {
5143 var MSC_ConnHdlr vc_conn;
5144 f_init(1, true);
5145 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02005146 vc_conn := f_start_handler(refers(f_tc_unsol_ho_fail));
Harald Weltefbf9b5e2018-01-31 20:41:23 +01005147 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005148 f_shutdown_helper();
Harald Weltefbf9b5e2018-01-31 20:41:23 +01005149}
5150
5151
Harald Weltee3bd6582018-01-31 22:51:25 +01005152/* short message from MS should be ignored */
5153private function f_tc_err_82_short_msg(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02005154 g_pars := f_gen_test_hdlr_pars();
Harald Weltea0630032018-03-20 21:09:55 +01005155 f_create_chan_and_exp();
Harald Weltee3bd6582018-01-31 22:51:25 +01005156 /* we should now have a COMPL_L3 at the MSC */
Harald Weltee3bd6582018-01-31 22:51:25 +01005157
5158 /* send short message */
5159 RSL.send(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), ''O));
5160 f_bssap_expect_nothing();
5161}
5162testcase TC_err_82_short_msg() runs on test_CT {
5163 var MSC_ConnHdlr vc_conn;
5164 f_init(1, true);
5165 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02005166 vc_conn := f_start_handler(refers(f_tc_err_82_short_msg));
Harald Weltee3bd6582018-01-31 22:51:25 +01005167 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005168 f_shutdown_helper();
Harald Weltee3bd6582018-01-31 22:51:25 +01005169}
5170
5171
Harald Weltee9e02e42018-01-31 23:36:25 +01005172/* 24.008 8.4 Unknown message must trigger RR STATUS */
5173private function f_tc_err_84_unknown_msg(charstring id) runs on MSC_ConnHdlr {
5174 f_est_single_l3(ts_RRM_UL_REL('00'O));
5175 timer T := 3.0
5176 alt {
5177 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_STATUS)) {
5178 setverdict(pass);
5179 }
5180 [] BSSAP.receive { setverdict(fail, "unexpected BSSAP"); }
Harald Welte458fd372018-03-21 11:26:23 +01005181 [] T.timeout { setverdict(fail, "Timeout waiting for RR STATUS"); }
Harald Weltee9e02e42018-01-31 23:36:25 +01005182 }
5183}
5184testcase TC_err_84_unknown_msg() runs on test_CT {
5185 var MSC_ConnHdlr vc_conn;
5186 f_init(1, true);
5187 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02005188 vc_conn := f_start_handler(refers(f_tc_err_84_unknown_msg));
Harald Weltee9e02e42018-01-31 23:36:25 +01005189 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005190 f_shutdown_helper();
Harald Weltee9e02e42018-01-31 23:36:25 +01005191}
5192
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005193/***********************************************************************
5194 * Handover
5195 ***********************************************************************/
5196
Harald Welte94e0c342018-04-07 11:33:23 +02005197/* execute a "bts <0-255> trx <0-255> timeslot <0-7> " command on given Dchan */
5198private function f_vty_ts_action(charstring suffix, integer bts_nr, integer trx_nr, integer ts_nr)
5199runs on test_CT {
5200 var charstring cmd := "bts "&int2str(bts_nr)&" trx "&int2str(trx_nr)&
5201 " timeslot "&int2str(ts_nr)&" ";
5202 f_vty_transceive(BSCVTY, cmd & suffix);
5203}
5204
Harald Welte261af4b2018-02-12 21:20:39 +01005205/* 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 +07005206private function f_vty_ss_action(TELNETasp_PT pt, charstring suffix,
5207 uint8_t bts_nr, uint8_t trx_nr,
5208 in RslChannelNr chan_nr)
5209{
Harald Welte261af4b2018-02-12 21:20:39 +01005210 /* FIXME: resolve those from component-global state */
5211 var integer ts_nr := chan_nr.tn;
5212 var integer ss_nr;
5213 if (ischosen(chan_nr.u.ch0)) {
5214 ss_nr := 0;
5215 } else if (ischosen(chan_nr.u.lm)) {
5216 ss_nr := chan_nr.u.lm.sub_chan;
5217 } else if (ischosen(chan_nr.u.sdcch4)) {
5218 ss_nr := chan_nr.u.sdcch4.sub_chan;
5219 } else if (ischosen(chan_nr.u.sdcch8)) {
5220 ss_nr := chan_nr.u.sdcch8.sub_chan;
5221 } else {
5222 setverdict(fail, "Invalid ChanNr ", chan_nr);
Daniel Willmannafce8662018-07-06 23:11:32 +02005223 mtc.stop;
Harald Welte261af4b2018-02-12 21:20:39 +01005224 }
5225
5226 var charstring cmd := "bts "&int2str(bts_nr)&" trx "&int2str(trx_nr)&
5227 " timeslot "&int2str(ts_nr)&" sub-slot "&int2str(ss_nr)&" ";
Vadim Yanitskiy00070722020-09-02 17:27:57 +07005228 f_vty_transceive(pt, cmd & suffix);
Harald Welte261af4b2018-02-12 21:20:39 +01005229}
5230
Neels Hofmeyr91401012019-07-11 00:42:35 +02005231/* Even though the VTY command to trigger handover takes a new BTS number as argument, behind the scenes osmo-bsc always
5232 * translates that to a target ARFCN+BSIC first. See bsc_vty.c trigger_ho_or_as(), which puts the selected BTS' neighbor
5233 * ident key (ARFCN + BSIC) in the struct passed on to handover_request(). handover_start() then resolves that to a
5234 * viable actual neighbor cell. So from the internal osmo-bsc perspective, we always request handover to an ARFCN + BSIC
5235 * pair, not really to a specific BTS number. */
Vadim Yanitskiy00070722020-09-02 17:27:57 +07005236private function f_vty_handover(TELNETasp_PT pt, uint8_t bts_nr, uint8_t trx_nr,
5237 in RslChannelNr chan_nr, uint8_t new_bts_nr)
5238{
5239 f_vty_ss_action(pt, "handover " & int2str(new_bts_nr), bts_nr, trx_nr, chan_nr);
Harald Welte261af4b2018-02-12 21:20:39 +01005240}
5241
5242/* intra-BSC hand-over between BTS0 and BTS1 */
5243private function f_tc_ho_int(charstring id) runs on MSC_ConnHdlr {
Harald Welteed848512018-05-24 22:27:58 +02005244 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
5245 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte261af4b2018-02-12 21:20:39 +01005246
5247 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
5248 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
5249
Harald Weltea0630032018-03-20 21:09:55 +01005250 f_establish_fully(ass_cmd, exp_compl);
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005251 f_bts_0_cfg(BSCVTY, {"neighbor bts 1"});
Harald Welte261af4b2018-02-12 21:20:39 +01005252
5253 var HandoverState hs := {
5254 rr_ho_cmpl_seen := false,
5255 handover_done := false,
Neels Hofmeyrc741fcb2021-10-02 14:52:28 +02005256 old_chan_nr := -,
5257 expect_target_tsc := BTS_TSC[1]
Harald Welte261af4b2018-02-12 21:20:39 +01005258 };
Neels Hofmeyrc2cf4542021-10-02 12:26:38 +02005259 /* issue hand-over command on VTY, from BTS 0 to BTS 1 */
Vadim Yanitskiy00070722020-09-02 17:27:57 +07005260 f_vty_handover(BSCVTY, 0, 0, g_chan_nr, 1);
Harald Welte261af4b2018-02-12 21:20:39 +01005261 /* temporarily suspend DChan processing on BTS1 to avoid race with RSLEM_register */
5262 f_rslem_suspend(RSL1_PROC);
Philipp Maier3e2af5d2018-07-11 17:01:05 +02005263
5264 /* From the MGW perspective, a handover is is characterized by
5265 * performing one MDCX operation with the MGW. So we expect to see
5266 * one more MDCX during handover. */
5267 g_media.mgcp_conn[0].mdcx_seen_exp := g_media.mgcp_conn[0].crcx_seen_exp + 1;
5268
Harald Welte261af4b2018-02-12 21:20:39 +01005269 alt {
5270 [] as_handover(hs);
Harald Welte261af4b2018-02-12 21:20:39 +01005271 }
Philipp Maier3e2af5d2018-07-11 17:01:05 +02005272
Philipp Maier4dae0652018-11-12 12:03:26 +01005273 /* Since this is an internal handover we expect the BSC to inform the
5274 * MSC about the event */
5275 BSSAP.receive(tr_BSSMAP_HandoverPerformed);
5276
Philipp Maier3e2af5d2018-07-11 17:01:05 +02005277 /* Check the amount of MGCP transactions is still consistant with the
5278 * test expectation */
5279 f_check_mgcp_expectations()
Neels Hofmeyraf88d9d2021-06-21 02:14:27 +02005280
Neels Hofmeyrc2cf4542021-10-02 12:26:38 +02005281 var RSL_Message chan_act := f_rslem_get_last_act(RSL1_PROC, 0, g_chan_nr);
5282
Neels Hofmeyraf88d9d2021-06-21 02:14:27 +02005283 /* Ensure the Channel Activation for the new channel contained the right encryption params. as_handover() set
5284 * 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 +02005285 f_verify_encr_info(chan_act);
5286
5287 f_chan_act_verify_tsc(chan_act, BTS_TSC[1]);
Neels Hofmeyraf88d9d2021-06-21 02:14:27 +02005288
Neels Hofmeyr861a4c12018-11-07 01:23:17 +01005289 f_sleep(0.5);
Harald Welte261af4b2018-02-12 21:20:39 +01005290}
5291
5292testcase TC_ho_int() runs on test_CT {
Neels Hofmeyr5f7a9df2021-06-21 01:30:43 +02005293 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte261af4b2018-02-12 21:20:39 +01005294 var MSC_ConnHdlr vc_conn;
5295 f_init(2, true);
5296 f_sleep(1.0);
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005297
Neels Hofmeyrc2cf4542021-10-02 12:26:38 +02005298 pars.expect_tsc := BTS_TSC[0];
5299
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01005300 f_ctrs_bsc_and_bts_handover_init();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005301
Neels Hofmeyr5f7a9df2021-06-21 01:30:43 +02005302 vc_conn := f_start_handler(refers(f_tc_ho_int), pars);
Harald Welte261af4b2018-02-12 21:20:39 +01005303 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005304
5305 /* from f_establish_fully() */
5306 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5307 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5308 /* from handover */
5309 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5310 f_ctrs_bsc_and_bts_add(0, "handover:completed");
5311 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5312 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:completed");
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01005313 f_ctrs_bts_add(1, "incoming_intra_bsc_ho:attempted");
5314 f_ctrs_bts_add(1, "incoming_intra_bsc_ho:completed");
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005315 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005316 f_shutdown_helper();
Harald Welte261af4b2018-02-12 21:20:39 +01005317}
Harald Weltee9e02e42018-01-31 23:36:25 +01005318
Oliver Smith7eabd312021-07-12 14:18:56 +02005319function 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 +02005320 var MSC_ConnHdlr vc_conn;
5321 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5322 pars.encr := valueof(t_EncrParams(encr_alg, f_rnd_octstring(8), f_rnd_octstring(16)));
5323
5324 f_init(2, true);
Oliver Smith7eabd312021-07-12 14:18:56 +02005325 f_vty_encryption_a5(enc_a5);
Neels Hofmeyraf88d9d2021-06-21 02:14:27 +02005326 f_sleep(1.0);
5327
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01005328 f_ctrs_bsc_and_bts_handover_init();
Neels Hofmeyraf88d9d2021-06-21 02:14:27 +02005329
5330 vc_conn := f_start_handler(refers(f_tc_ho_int), pars);
5331 vc_conn.done;
5332
5333 /* from f_establish_fully() */
5334 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5335 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5336 /* from handover */
5337 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5338 f_ctrs_bsc_and_bts_add(0, "handover:completed");
5339 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5340 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:completed");
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01005341 f_ctrs_bts_add(1, "incoming_intra_bsc_ho:attempted");
5342 f_ctrs_bts_add(1, "incoming_intra_bsc_ho:completed");
Neels Hofmeyraf88d9d2021-06-21 02:14:27 +02005343 f_ctrs_bsc_and_bts_verify();
Oliver Smith7eabd312021-07-12 14:18:56 +02005344 f_vty_encryption_a5_reset();
Neels Hofmeyraf88d9d2021-06-21 02:14:27 +02005345 f_shutdown_helper();
5346}
5347
5348testcase TC_ho_int_a5_0() runs on test_CT {
5349 f_tc_ho_int_a5('01'O);
5350}
5351
5352testcase TC_ho_int_a5_1() runs on test_CT {
5353 f_tc_ho_int_a5('02'O);
5354}
5355
5356testcase TC_ho_int_a5_3() runs on test_CT {
5357 f_tc_ho_int_a5('08'O);
5358}
5359
5360testcase TC_ho_int_a5_4() runs on test_CT {
Oliver Smith7eabd312021-07-12 14:18:56 +02005361 f_tc_ho_int_a5('10'O, "0 1 3 4");
Neels Hofmeyraf88d9d2021-06-21 02:14:27 +02005362}
5363
Neels Hofmeyr5f144212020-11-03 15:41:58 +00005364/* intra-BSC hand-over with CONNection FAILure and cause Radio Link Failure: check RR release cause */
5365private function f_tc_ho_int_radio_link_failure(charstring id) runs on MSC_ConnHdlr {
5366 g_pars := f_gen_test_hdlr_pars();
5367 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
5368 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Neels Hofmeyr5f144212020-11-03 15:41:58 +00005369
5370 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
5371 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
5372
5373 f_establish_fully(ass_cmd, exp_compl);
5374 f_bts_0_cfg(BSCVTY, {"neighbor bts 1"});
5375
5376 var HandoverState hs := {
5377 rr_ho_cmpl_seen := false,
5378 handover_done := false,
Neels Hofmeyrc741fcb2021-10-02 14:52:28 +02005379 old_chan_nr := -,
5380 expect_target_tsc := BTS_TSC[1]
Neels Hofmeyr5f144212020-11-03 15:41:58 +00005381 };
5382 /* issue hand-over command on VTY */
5383 f_vty_handover(BSCVTY, 0, 0, g_chan_nr, 1);
5384 /* temporarily suspend DChan processing on BTS1 to avoid race with RSLEM_register */
5385 f_rslem_suspend(RSL1_PROC);
5386
5387 /* From the MGW perspective, a handover is is characterized by
5388 * performing one MDCX operation with the MGW. So we expect to see
5389 * one more MDCX during handover. */
5390 g_media.mgcp_conn[0].mdcx_seen_exp := g_media.mgcp_conn[0].crcx_seen_exp + 1;
5391
5392 var RSL_Message rsl;
5393 var PDU_ML3_NW_MS l3;
5394 var RslChannelNr new_chan_nr;
5395 var GsmArfcn arfcn;
5396 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr)) -> value rsl {
5397 l3 := dec_PDU_ML3_NW_MS(rsl.ies[2].body.l3_info.payload);
5398 if (not ischosen(l3.msgs.rrm.handoverCommand)) {
5399 setverdict(fail, "Expected handoverCommand");
5400 mtc.stop;
5401 }
5402 }
5403 f_ChDesc2RslChanNr(l3.msgs.rrm.handoverCommand.channelDescription2,
5404 new_chan_nr, arfcn);
5405
5406 f_rslem_register(0, new_chan_nr, RSL1_PROC);
5407
5408 /* resume processing of RSL DChan messages, which was temporarily suspended
5409 * before performing a hand-over */
5410 f_rslem_resume(RSL1_PROC);
5411 RSL1.receive(tr_RSL_IPA_CRCX(new_chan_nr));
5412
5413 f_sleep(1.0);
5414
5415 /* Handover fails because no HANDO DET appears on the new lchan,
5416 * and the old lchan reports a Radio Link Failure. */
5417 RSL.send(ts_RSL_CONN_FAIL_IND(g_chan_nr, RSL_ERR_RADIO_LINK_FAIL));
5418
5419 var PDU_BSSAP rx_clear_request;
5420 BSSAP.receive(tr_BSSMAP_ClearRequest) -> value rx_clear_request;
5421 var BssmapCause cause := bit2int(rx_clear_request.pdu.bssmap.clearRequest.cause.causeValue);
5422 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5423
5424 var RR_Cause rr_cause := GSM48_RR_CAUSE_ABNORMAL_UNSPEC;
5425
5426 var MgcpCommand mgcp;
5427 interleave {
5428 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE(int2oct(enum2int(rr_cause), 1)))) {}
5429 [] RSL.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {}
Neels Hofmeyr3c5127e2021-07-22 19:18:40 +02005430 [] RSL.receive(tr_RSL_RF_CHAN_REL(g_chan_nr)) {
Neels Hofmeyr5f144212020-11-03 15:41:58 +00005431 RSL.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
Neels Hofmeyre680b012021-07-22 19:19:09 +02005432 f_rslem_unregister(0, g_chan_nr);
Neels Hofmeyr5f144212020-11-03 15:41:58 +00005433 }
5434 [] RSL1.receive(tr_RSL_DEACT_SACCH(new_chan_nr)) {}
Neels Hofmeyr3c5127e2021-07-22 19:18:40 +02005435 [] RSL1.receive(tr_RSL_RF_CHAN_REL(new_chan_nr)) {
Neels Hofmeyr5f144212020-11-03 15:41:58 +00005436 RSL1.send(ts_RSL_RF_CHAN_REL_ACK(new_chan_nr));
Neels Hofmeyre680b012021-07-22 19:19:09 +02005437 f_rslem_unregister(0, g_chan_nr, PT := RSL1_PROC);
Neels Hofmeyr5f144212020-11-03 15:41:58 +00005438 }
5439 [] BSSAP.receive(tr_BSSMAP_ClearComplete) {}
5440 }
5441
5442 f_sleep(0.5);
5443 setverdict(pass);
5444}
5445testcase TC_ho_int_radio_link_failure() runs on test_CT {
5446 var MSC_ConnHdlr vc_conn;
5447 f_init(2, true);
5448 f_sleep(1.0);
5449
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01005450 f_ctrs_bsc_and_bts_handover_init();
Neels Hofmeyr5f144212020-11-03 15:41:58 +00005451
5452 vc_conn := f_start_handler(refers(f_tc_ho_int_radio_link_failure));
5453 vc_conn.done;
5454
5455 /* from f_establish_fully() */
5456 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5457 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5458 /* from handover */
5459 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5460 f_ctrs_bsc_and_bts_add(0, "handover:stopped");
5461 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5462 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:stopped");
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01005463 f_ctrs_bts_add(1, "incoming_intra_bsc_ho:attempted");
5464 f_ctrs_bts_add(1, "incoming_intra_bsc_ho:stopped");
Neels Hofmeyr5f144212020-11-03 15:41:58 +00005465 f_ctrs_bsc_and_bts_verify();
5466 f_shutdown_helper();
5467}
5468
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02005469/* Expecting MGCP to DLCX the endpoint's two connections: towards BTS and towards MSC */
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005470private function f_expect_dlcx_conns() runs on MSC_ConnHdlr {
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02005471 var MgcpCommand mgcp;
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02005472 var template MgcpResponse mgcp_resp;
5473 var MGCP_RecvFrom mrf;
5474 var template MgcpMessage msg_resp;
5475 var template MgcpMessage msg_dlcx := {
5476 command := tr_DLCX()
5477 }
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02005478
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02005479 if (g_pars.aoip) {
5480 MGCP.receive(tr_DLCX()) -> value mgcp {
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02005481 log("Got first DLCX: ", mgcp);
5482 MGCP.send(ts_DLCX_ACK2(mgcp.line.trans_id));
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02005483 };
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02005484
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02005485 MGCP.receive(tr_DLCX()) -> value mgcp {
5486 log("Got second DLCX: ", mgcp);
5487 MGCP.send(ts_DLCX_ACK2(mgcp.line.trans_id));
5488 };
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02005489 } else {
5490 /* For SCCPLite, BSC doesn't handle the MSC-side */
5491 MGCP_MULTI.receive(tr_MGCP_RecvFrom_any(msg_dlcx)) -> value mrf {
5492 log("Got first DLCX: ", mrf.msg.command);
5493 msg_resp := {
5494 response := ts_DLCX_ACK2(mrf.msg.command.line.trans_id)
5495 }
5496 MGCP_MULTI.send(t_MGCP_SendToMrf(mrf, msg_resp));
5497 };
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02005498 }
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02005499}
5500
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005501private 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 +01005502
Neels Hofmeyrafe2ea52021-11-24 15:16:12 +01005503 var NcellReports neighbor_rep := {
5504 { rxlev := 20, bcch_freq := 0, bsic := 11 }
5505 };
5506 var octetstring l3_mr := enc_GsmRrL3Message(valueof(ts_MEAS_REP(true, 8, 8, reps := neighbor_rep)));
5507 RSL.send(ts_RSL_MEAS_RES(g_chan_nr, 0, ts_RSL_IE_UplinkMeas, ts_RSL_IE_BS_Power(0), ts_RSL_IE_L1Info,
5508 l3_mr, 0));
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005509
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005510 BSSAP.receive(tr_BSSMAP_HandoverRequired(exp_oldToNewBSSIEs));
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005511
5512 f_sleep(0.5);
5513 /* The MSC negotiates Handover Request and Handover Request Ack with
5514 * the other BSS and comes back with a BSSMAP Handover Command
5515 * containing an RR Handover Command coming from the target BSS... */
5516
5517 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
5518 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
5519 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
5520 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
5521 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
5522
5523 /* expect the Handover Command to go out on RR */
5524 var RSL_Message rsl_ho_cmd
5525 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
5526 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
5527 var RSL_IE_Body rsl_ho_cmd_l3;
5528 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
5529 log("RSL message contains no L3 Info IE, expected RR Handover Command");
5530 setverdict(fail);
5531 } else {
5532 log("Found L3 Info: ", rsl_ho_cmd_l3);
5533 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
5534 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
5535 setverdict(fail);
5536 } else {
5537 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
5538 setverdict(pass);
5539 }
5540 }
5541
5542 /* When the other BSS has reported a completed handover, this side is
5543 * torn down. */
5544
5545 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_HANDOVER_SUCCESSFUL;
5546 var BssmapCause cause := enum2int(cause_val);
5547 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5548
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005549 f_expect_dlcx_conns();
Pau Espin Pedrol06199952021-06-15 11:30:00 +02005550
5551 interleave {
5552 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE));
5553 [] RSL.receive(tr_RSL_DEACT_SACCH(g_chan_nr));
5554 [] RSL.receive(tr_RSL_RF_CHAN_REL(g_chan_nr));
Neels Hofmeyr8fcd8772021-07-22 16:12:57 +02005555 [] BSSAP.receive(tr_BSSMAP_ClearComplete);
Pau Espin Pedrol06199952021-06-15 11:30:00 +02005556 }
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005557 setverdict(pass);
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005558}
5559
5560private function f_tc_ho_out_of_this_bsc(charstring id) runs on MSC_ConnHdlr {
5561 g_pars := f_gen_test_hdlr_pars();
5562 var PDU_BSSAP ass_req := f_gen_ass_req();
5563 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
5564 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
5565 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
5566 f_establish_fully(ass_req, exp_compl);
5567
5568 f_ho_out_of_this_bsc();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005569}
5570testcase TC_ho_out_of_this_bsc() runs on test_CT {
5571 var MSC_ConnHdlr vc_conn;
5572
Neels Hofmeyrafe2ea52021-11-24 15:16:12 +01005573 f_init_vty();
5574 f_bts_0_cfg(BSCVTY,
5575 {"neighbor-list mode automatic",
5576 "handover 1",
5577 "handover algorithm 2",
5578 "handover2 window rxlev averaging 1",
5579 "neighbor lac 99 arfcn 123 bsic any"});
5580 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
5581
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005582 f_init(1, true);
5583 f_sleep(1.0);
5584
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01005585 f_ctrs_bsc_and_bts_handover_init();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005586
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005587 vc_conn := f_start_handler(refers(f_tc_ho_out_of_this_bsc));
5588 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005589
5590 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5591 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5592 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5593 f_ctrs_bsc_and_bts_add(0, "handover:completed");
5594 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
5595 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:completed");
5596 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005597 f_shutdown_helper();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005598}
5599
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00005600private function f_mo_l3_transceive(RSL_DCHAN_PT rsl := RSL,
5601 template (value) RslLinkId link_id := ts_RslLinkID_DCCH(0),
Vadim Yanitskiy2ef6a2f2020-10-08 23:17:32 +07005602 template (present) OCT1 dlci := ?,
Vadim Yanitskiyb93aa432020-10-01 14:23:11 +07005603 octetstring l3 := '0123456789'O)
5604runs on MSC_ConnHdlr {
Neels Hofmeyr43654812020-09-25 01:35:35 +02005605 /* The old lchan and conn should still be active. See that arbitrary L3
5606 * is still going through. */
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00005607 rsl.send(ts_RSL_DATA_IND(g_chan_nr, link_id, l3));
Neels Hofmeyr43654812020-09-25 01:35:35 +02005608 var template PDU_BSSAP exp_data := {
5609 discriminator := '1'B,
5610 spare := '0000000'B,
Vadim Yanitskiyb93aa432020-10-01 14:23:11 +07005611 dlci := dlci,
5612 lengthIndicator := lengthof(l3),
Neels Hofmeyr43654812020-09-25 01:35:35 +02005613 pdu := {
5614 dtap := l3
5615 }
5616 };
5617 BSSAP.receive(exp_data);
5618 setverdict(pass);
5619}
5620
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00005621private function f_mt_l3_transceive(RSL_DCHAN_PT rsl := RSL,
5622 template (present) RslLinkId link_id := tr_RslLinkID_DCCH(0),
Vadim Yanitskiy0033a3b2020-10-01 22:21:16 +07005623 template (value) OCT1 dlci := '00'O,
5624 octetstring l3 := '0123456789'O)
5625runs on MSC_ConnHdlr {
5626 BSSAP.send(PDU_BSSAP:{
5627 discriminator := '1'B,
5628 spare := '0000000'B,
5629 dlci := dlci,
5630 lengthIndicator := lengthof(l3),
5631 pdu := {
5632 dtap := l3
5633 }
5634 });
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00005635 rsl.receive(tr_RSL_DATA_REQ(g_chan_nr, link_id, l3));
Vadim Yanitskiy0033a3b2020-10-01 22:21:16 +07005636 setverdict(pass);
5637}
5638
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005639/* BSC asks for inter-BSC HO, but the MSC decides that it won't happen and
5640 * simply never sends a BSSMAP Handover Command. */
5641private function f_tc_ho_out_fail_no_msc_response(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01005642 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005643
5644 var PDU_BSSAP ass_req := f_gen_ass_req();
5645 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
5646 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
5647 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
5648 f_establish_fully(ass_req, exp_compl);
5649
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005650 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005651 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
5652
5653 BSSAP.receive(tr_BSSMAP_HandoverRequired);
5654
5655 /* osmo-bsc should time out 10 seconds after the handover started.
5656 * Let's give it a bit extra. */
5657 f_sleep(15.0);
5658
Vadim Yanitskiy74ae5eb2020-10-01 22:13:29 +07005659 f_mo_l3_transceive();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005660 f_sleep(1.0);
5661}
5662testcase TC_ho_out_fail_no_msc_response() runs on test_CT {
5663 var MSC_ConnHdlr vc_conn;
5664
5665 f_init(1, true);
5666 f_sleep(1.0);
5667
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01005668 f_ctrs_bsc_and_bts_handover_init();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005669
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005670 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_no_msc_response));
5671 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005672
5673 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5674 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5675 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5676 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
5677 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
5678 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
5679 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005680 f_shutdown_helper();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005681}
5682
5683/* BSC asks for inter-BSC HO, receives BSSMAP Handover Command, but MS reports
5684 * RR Handover Failure. */
5685private function f_tc_ho_out_fail_rr_ho_failure(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01005686 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005687
5688 var PDU_BSSAP ass_req := f_gen_ass_req();
5689 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
5690 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
5691 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
5692 f_establish_fully(ass_req, exp_compl);
5693
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005694 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005695 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
5696
5697 BSSAP.receive(tr_BSSMAP_HandoverRequired);
5698
5699 f_sleep(0.5);
5700 /* The MSC negotiates Handover Request and Handover Request Ack with
5701 * the other BSS and comes back with a BSSMAP Handover Command
5702 * containing an RR Handover Command coming from the target BSS... */
5703
5704 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
5705 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
5706 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
5707 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
5708 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
5709
5710 /* expect the Handover Command to go out on RR */
5711 var RSL_Message rsl_ho_cmd
5712 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
5713 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
5714 var RSL_IE_Body rsl_ho_cmd_l3;
5715 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
5716 log("RSL message contains no L3 Info IE, expected RR Handover Command");
5717 setverdict(fail);
5718 } else {
5719 log("Found L3 Info: ", rsl_ho_cmd_l3);
5720 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
5721 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
5722 setverdict(fail);
5723 } else {
5724 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
5725 setverdict(pass);
5726 }
5727 }
5728
5729 f_sleep(0.2);
5730 f_rsl_send_l3(ts_RRM_HandoverFailure('00'O));
5731
5732 /* Should tell the MSC about the failure */
5733 BSSAP.receive(tr_BSSMAP_HandoverFailure);
5734
5735 f_sleep(1.0);
5736
Vadim Yanitskiy74ae5eb2020-10-01 22:13:29 +07005737 f_mo_l3_transceive();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005738 f_sleep(1.0);
5739
5740 setverdict(pass);
5741 f_sleep(1.0);
5742}
5743testcase TC_ho_out_fail_rr_ho_failure() runs on test_CT {
5744 var MSC_ConnHdlr vc_conn;
5745
5746 f_init(1, true);
5747 f_sleep(1.0);
5748
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01005749 f_ctrs_bsc_and_bts_handover_init();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005750
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005751 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_rr_ho_failure));
5752 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005753
5754 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5755 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5756 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5757 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5758 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
5759 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:failed");
5760 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005761 f_shutdown_helper();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005762}
5763
Neels Hofmeyr10f2bfa2019-07-09 19:33:29 +02005764/* BSC asks for inter-BSC-out HO, receives BSSMAP Handover Command, but then no reply is received about HO outcome
5765 * (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 +02005766 * and the lchan is released. */
5767private function f_tc_ho_out_fail_no_result_after_ho_cmd(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01005768 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005769
5770 var PDU_BSSAP ass_req := f_gen_ass_req();
5771 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
5772 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
5773 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
5774 f_establish_fully(ass_req, exp_compl);
5775
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005776 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005777 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
5778
5779 BSSAP.receive(tr_BSSMAP_HandoverRequired);
5780
5781 f_sleep(0.5);
5782 /* The MSC negotiates Handover Request and Handover Request Ack with
5783 * the other BSS and comes back with a BSSMAP Handover Command
5784 * containing an RR Handover Command coming from the target BSS... */
5785
5786 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
5787 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
5788 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
5789 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
5790 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
5791
5792 /* expect the Handover Command to go out on RR */
5793 var RSL_Message rsl_ho_cmd
5794 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
5795 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
5796 var RSL_IE_Body rsl_ho_cmd_l3;
5797 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
5798 log("RSL message contains no L3 Info IE, expected RR Handover Command");
5799 setverdict(fail);
5800 } else {
5801 log("Found L3 Info: ", rsl_ho_cmd_l3);
5802 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
5803 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
5804 setverdict(fail);
5805 } else {
5806 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
5807 setverdict(pass);
5808 }
5809 }
5810
Neels Hofmeyr10f2bfa2019-07-09 19:33:29 +02005811 /* We get neither success nor failure report from the remote BSS. Eventually T8 times out and we run into 3GPP
5812 * TS 48.008 3.1.5.3.3 "Abnormal Conditions": Clear Request should go to the MSC, and RR should be released
5813 * after Clear Command */
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005814
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005815 var PDU_BSSAP rx_clear_request;
Neels Hofmeyre1797aa2019-07-09 19:34:04 +02005816 BSSAP.receive(tr_BSSMAP_ClearRequest) -> value rx_clear_request;
5817 log("Got BSSMAP Clear Request");
5818 /* Instruct BSC to clear channel */
5819 var BssmapCause cause := bit2int(rx_clear_request.pdu.bssmap.clearRequest.cause.causeValue);
5820 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5821
5822 var MgcpCommand mgcp;
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005823 interleave {
Neels Hofmeyr861a4c12018-11-07 01:23:17 +01005824 [] RSL.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
5825 log("Got Deact SACCH");
5826 }
Harald Welte924b6ea2019-02-04 01:05:34 +01005827 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
Neels Hofmeyr211169d2018-11-07 00:37:29 +01005828 log("Got RR Release");
5829 }
Neels Hofmeyr3c5127e2021-07-22 19:18:40 +02005830 [] RSL.receive(tr_RSL_RF_CHAN_REL(g_chan_nr)) {
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005831 log("Got RF Chan Rel");
5832 RSL.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
Neels Hofmeyre680b012021-07-22 19:19:09 +02005833 f_rslem_unregister(0, g_chan_nr);
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005834 }
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005835 }
5836
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005837 f_expect_dlcx_conns();
Neels Hofmeyr8fcd8772021-07-22 16:12:57 +02005838 BSSAP.receive(tr_BSSMAP_ClearComplete);
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02005839
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005840 setverdict(pass);
5841 f_sleep(1.0);
5842}
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02005843testcase TC_ho_out_fail_no_result_after_ho_cmd() runs on test_CT {
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005844 var MSC_ConnHdlr vc_conn;
5845
5846 f_init(1, true);
5847 f_sleep(1.0);
5848
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01005849 f_ctrs_bsc_and_bts_handover_init();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005850
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02005851 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_no_result_after_ho_cmd));
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005852 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005853
5854 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5855 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5856 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5857 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
5858 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
5859 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
5860 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005861 f_shutdown_helper();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005862}
5863
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005864private 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 +01005865 /* Hack: the proper way would be to wait for the BSSMAP Handover Request ACK and extract the
5866 * actual assigned chan_nr from its L3 (RR Handover Command) message. But osmo-bsc starts acting
5867 * on the lchan even before we get a chance to evaluate the BSSMAP Handover Request ACK. So we
5868 * need to assume that osmo-bsc will activate TS 1 and already set up this lchan's RSL emulation
5869 * before we get started. */
5870 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
5871 f_rslem_register(0, new_chan_nr);
5872 g_chan_nr := new_chan_nr;
Neels Hofmeyr34174bd2021-10-02 14:52:57 +02005873 var uint3_t expect_target_tsc := BTS_TSC[0];
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005874 f_sleep(1.0);
5875
5876 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
5877 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5878 activate(as_Media());
5879
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005880 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02005881 f_gen_handover_req(aoip_tla := g_pars.host_aoip_tla,
Neels Hofmeyr8ebf19c2021-06-21 05:24:01 +02005882 oldToNewBSSIEs := oldToNewBSSIEs,
5883 enc := g_pars.encr)));
Harald Welte6811d102019-04-14 22:23:14 +02005884 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005885
5886 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
5887
5888 var PDU_BSSAP rx_bssap;
5889 var octetstring ho_command_str;
5890
5891 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
Pau Espin Pedrol76ba5412019-06-10 11:00:33 +02005892
Neels Hofmeyr34174bd2021-10-02 14:52:57 +02005893 /* we're sure that the channel activation is done now, verify the parameters in it */
5894 var RSL_Message chan_act := f_rslem_get_last_act(RSL_PROC, 0, g_chan_nr);
5895 f_verify_encr_info(chan_act);
5896 f_chan_act_verify_tsc(chan_act, expect_target_tsc);
Neels Hofmeyr8ebf19c2021-06-21 05:24:01 +02005897
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005898 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
5899 log("Received L3 Info in HO Request Ack: ", ho_command_str);
5900 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
5901 log("L3 Info in HO Request Ack is ", ho_command);
5902
5903 var GsmArfcn arfcn;
5904 var RslChannelNr actual_new_chan_nr;
5905 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
5906 actual_new_chan_nr, arfcn);
5907
5908 if (actual_new_chan_nr != new_chan_nr) {
5909 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
5910 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
5911 setverdict(fail);
5912 return;
5913 }
5914 log("Handover Command chan_nr is", actual_new_chan_nr);
5915
Neels Hofmeyr34174bd2021-10-02 14:52:57 +02005916 var uint3_t got_tsc := rr_chan_desc_tsc(ho_command.msgs.rrm.handoverCommand.channelDescription2);
5917 if (not match(got_tsc, expect_target_tsc)) {
5918 setverdict(fail, "RR Handover Command: unexpected TSC in Channel Description: expected ",
5919 expect_target_tsc, " got ", got_tsc);
5920 mtc.stop;
5921 } else {
5922 log("handoverCommand: verified TSC = ", got_tsc);
5923 }
5924
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005925 /* Now the MSC forwards the RR Handover Command to the other BSC, which
5926 * tells the MS to handover to the new lchan. Here comes the new MS on
5927 * the new lchan with a Handover RACH: */
5928
5929 /* send handover detect */
5930
5931 RSL.send(ts_RSL_HANDO_DET(new_chan_nr));
5932
5933 BSSAP.receive(tr_BSSMAP_HandoverDetect);
5934
5935 /* send handover complete over the new channel */
5936
5937 var PDU_ML3_MS_NW l3_tx := valueof(ts_RRM_HandoverComplete('00'O));
5938 RSL.send(ts_RSL_EST_IND(new_chan_nr, valueof(ts_RslLinkID_DCCH(0)),
5939 enc_PDU_ML3_MS_NW(l3_tx)));
5940
5941 BSSAP.receive(tr_BSSMAP_HandoverComplete);
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005942 setverdict(pass);
5943}
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02005944
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005945private function f_tc_ho_into_this_bsc(charstring id) runs on MSC_ConnHdlr {
Pau Espin Pedrol9ae36d52021-06-15 17:29:43 +02005946 var template PDU_ML3_NW_MS exp_rr_rel_tmpl;
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005947 var template (omit) BSSMAP_oldToNewBSSIEs oldToNewBSSIEs := omit;
5948 if (not istemplatekind(g_pars.last_used_eutran_plmn, "omit")) {
5949 oldToNewBSSIEs := f_ts_BSSMAP_oldToNewBSSIEs(ts_BSSMAP_LastUsedEUTRANPLMNId(g_pars.last_used_eutran_plmn));
Pau Espin Pedrol9ae36d52021-06-15 17:29:43 +02005950 }
5951 if (g_pars.exp_fast_return) {
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005952 exp_rr_rel_tmpl := tr_RRM_RR_RELEASE_CellSelectInd;
Pau Espin Pedrol9ae36d52021-06-15 17:29:43 +02005953 } else {
5954 exp_rr_rel_tmpl := tr_RRM_RR_RELEASE;
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005955 }
5956 f_ho_into_this_bsc(id, oldToNewBSSIEs);
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02005957 f_perform_clear(exp_rr_rel_tmpl := exp_rr_rel_tmpl);
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005958 setverdict(pass);
5959}
Pau Espin Pedrol07866632020-09-03 19:10:55 +02005960function f_tc_ho_into_this_bsc_main(TestHdlrParams pars) runs on test_CT {
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005961 var MSC_ConnHdlr vc_conn;
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005962
5963 f_init(1, true);
5964 f_sleep(1.0);
5965
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01005966 f_ctrs_bsc_and_bts_handover_init();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005967
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005968 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5969 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005970
5971 vc_conn := f_start_handler(refers(f_tc_ho_into_this_bsc), pars);
5972 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005973
5974 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5975 f_ctrs_bsc_and_bts_add(0, "handover:completed");
5976 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
5977 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:completed");
5978 f_ctrs_bsc_and_bts_verify();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005979}
5980
Pau Espin Pedrol07866632020-09-03 19:10:55 +02005981testcase TC_ho_into_this_bsc() runs on test_CT {
5982 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5983 f_tc_ho_into_this_bsc_main(pars);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005984 f_shutdown_helper();
Pau Espin Pedrol07866632020-09-03 19:10:55 +02005985}
5986
Neels Hofmeyr8ebf19c2021-06-21 05:24:01 +02005987function f_tc_ho_into_this_bsc_a5(OCT1 encr_alg) runs on test_CT {
5988 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5989 pars.encr := valueof(t_EncrParams(encr_alg, f_rnd_octstring(8), f_rnd_octstring(16)));
5990 f_tc_ho_into_this_bsc_main(pars);
5991 f_shutdown_helper();
5992}
5993
5994testcase TC_ho_into_this_bsc_a5_0() runs on test_CT {
5995 f_tc_ho_into_this_bsc_a5('01'O);
5996}
5997
5998testcase TC_ho_into_this_bsc_a5_1() runs on test_CT {
5999 f_tc_ho_into_this_bsc_a5('02'O);
6000}
6001
6002testcase TC_ho_into_this_bsc_a5_3() runs on test_CT {
6003 f_tc_ho_into_this_bsc_a5('08'O);
6004}
6005
6006testcase TC_ho_into_this_bsc_a5_4() runs on test_CT {
6007 f_tc_ho_into_this_bsc_a5('10'O);
6008}
6009
Pau Espin Pedrol07866632020-09-03 19:10:55 +02006010testcase TC_ho_into_this_bsc_tla_v6() runs on test_CT {
6011 var TestHdlrParams pars := f_gen_test_hdlr_pars();
6012 pars.host_aoip_tla := "::6";
6013 f_tc_ho_into_this_bsc_main(pars);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006014 f_shutdown_helper();
Pau Espin Pedrol07866632020-09-03 19:10:55 +02006015}
6016
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02006017/* Similar to TC_ho_into_this_bsc, but when in SRVCC, HO Req contains "Old BSS
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02006018 to New BSS Information" IE with "Last Used E-UTRAN PLMN Id", which, when the
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02006019 channel is later released (RR CHannel Release), should trigger inclusion of
6020 IE "Cell Selection Indicator after Release of all TCH and SDCCH" with E-UTRAN
6021 neighbors. */
6022testcase TC_srvcc_eutran_to_geran() runs on test_CT {
6023 var TestHdlrParams pars := f_gen_test_hdlr_pars();
6024 pars.last_used_eutran_plmn := '323454'O;
Pau Espin Pedrol9ae36d52021-06-15 17:29:43 +02006025 pars.exp_fast_return := true;
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02006026 f_tc_ho_into_this_bsc_main(pars);
Pau Espin Pedrol211a7142021-06-15 16:43:03 +02006027
6028 f_ctrs_bsc_and_bts_add(0, "srvcc:attempted");
6029 f_ctrs_bsc_and_bts_add(0, "srvcc:completed");
6030 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02006031 f_shutdown_helper();
6032}
6033
Pau Espin Pedrol9ae36d52021-06-15 17:29:43 +02006034/* Same as TC_srvcc_eutran_to_geran, but test explicitly forbiding fast return
6035 on the BTS. As a result, RR Release shouldn't contain the EUTRAN neighbor
6036 list when the channel is released. */
6037testcase TC_srvcc_eutran_to_geran_forbid_fast_return() runs on test_CT {
6038 f_init_vty();
6039 f_vty_allow_srvcc_fast_return(true, 0)
6040
6041 var TestHdlrParams pars := f_gen_test_hdlr_pars();
6042 pars.last_used_eutran_plmn := '323454'O;
6043 pars.exp_fast_return := false;
6044 f_tc_ho_into_this_bsc_main(pars);
6045 f_vty_allow_srvcc_fast_return(false, 0);
6046 f_shutdown_helper();
6047}
6048
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02006049private function f_tc_srvcc_eutran_to_geran_ho_out(charstring id) runs on MSC_ConnHdlr {
6050 var template (omit) BSSMAP_oldToNewBSSIEs oldToNewBSSIEs;
6051 oldToNewBSSIEs := f_ts_BSSMAP_oldToNewBSSIEs(ts_BSSMAP_LastUsedEUTRANPLMNId(g_pars.last_used_eutran_plmn));
6052 f_ho_into_this_bsc(id, oldToNewBSSIEs);
6053 f_ho_out_of_this_bsc(oldToNewBSSIEs);
6054 setverdict(pass);
6055}
Pau Espin Pedrol9ae36d52021-06-15 17:29:43 +02006056
6057private function f_tc_srvcc_eutran_to_geran_ho_out_main(boolean disable_fast_return)
6058 runs on test_CT {
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02006059 var MSC_ConnHdlr vc_conn;
6060 var TestHdlrParams pars := f_gen_test_hdlr_pars();
6061
6062 f_init(1, true);
Pau Espin Pedrol9ae36d52021-06-15 17:29:43 +02006063 if (disable_fast_return) {
6064 f_vty_allow_srvcc_fast_return(true, 0);
6065 }
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02006066 f_sleep(1.0);
6067
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01006068 f_ctrs_bsc_and_bts_handover_init();
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02006069
6070 pars.last_used_eutran_plmn := '323454'O;
6071 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
6072 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
6073
6074 vc_conn := f_start_handler(refers(f_tc_srvcc_eutran_to_geran_ho_out), pars);
6075 vc_conn.done;
6076
6077 f_ctrs_bsc_and_bts_add(0, "handover:attempted", 2);
6078 f_ctrs_bsc_and_bts_add(0, "handover:completed", 2);
6079 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted", 1);
6080 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:completed", 1);
6081 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted", 1);
6082 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:completed", 1);
Pau Espin Pedrol211a7142021-06-15 16:43:03 +02006083
6084 f_ctrs_bsc_and_bts_add(0, "srvcc:attempted", 1);
6085 f_ctrs_bsc_and_bts_add(0, "srvcc:completed", 1);
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02006086 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol9ae36d52021-06-15 17:29:43 +02006087
6088 if (disable_fast_return) {
6089 f_vty_allow_srvcc_fast_return(false, 0);
6090 }
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02006091 f_shutdown_helper();
6092}
6093
Pau Espin Pedrol9ae36d52021-06-15 17:29:43 +02006094/* First, HO into BSC from EUTRAN (SRVCC): HO Request contains "Old BSS to New
6095 BSS Information" IE with "Last Used E-UTRAN PLMN Id".
6096 Second, HO to another BSC: HO Required contains "Old BSS to New BSS Information"
6097 IE with "Last Used E-UTRAN PLMN Id" from first step. */
6098testcase TC_srvcc_eutran_to_geran_ho_out() runs on test_CT {
6099 f_tc_srvcc_eutran_to_geran_ho_out_main(false);
6100}
6101/* Validate subsequent intra-GSM-HO works the same (with OldBSSToNewBSSInfo IE)
6102 * independently of fast-reture allowed/forbidden in local BTS */
6103testcase TC_srvcc_eutran_to_geran_ho_out_forbid_fast_return() runs on test_CT {
6104 f_tc_srvcc_eutran_to_geran_ho_out_main(true);
6105}
6106
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006107private function f_tc_ho_in_fail_msc_clears(charstring id) runs on MSC_ConnHdlr {
6108 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
6109 f_rslem_register(0, new_chan_nr);
6110 g_chan_nr := new_chan_nr;
6111 f_sleep(1.0);
6112
6113 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
6114 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
6115 activate(as_Media());
6116
Neels Hofmeyr90f80962020-06-12 16:16:55 +02006117 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006118 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02006119 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006120
6121 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
6122
6123 var PDU_BSSAP rx_bssap;
6124 var octetstring ho_command_str;
6125
6126 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
6127
6128 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
6129 log("Received L3 Info in HO Request Ack: ", ho_command_str);
6130 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
6131 log("L3 Info in HO Request Ack is ", ho_command);
6132
6133 var GsmArfcn arfcn;
6134 var RslChannelNr actual_new_chan_nr;
6135 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
6136 actual_new_chan_nr, arfcn);
6137
6138 if (actual_new_chan_nr != new_chan_nr) {
6139 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
6140 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
6141 setverdict(fail);
6142 return;
6143 }
6144 log("Handover Command chan_nr is", actual_new_chan_nr);
6145
Neels Hofmeyr61ca08d2019-05-06 23:52:22 +02006146 /* For deterministic test results, give some time for the MGW endpoint to be configured */
6147 f_sleep(1.0);
6148
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006149 /* Now the MSC forwards the RR Handover Command to the other BSC, which
6150 * tells the MS to handover to the new lchan. In this case, the MS
6151 * reports a Handover Failure to the old BSS, which forwards a BSSMAP
6152 * Handover Failure to the MSC. The procedure according to 3GPP TS
6153 * 48.008 3.1.5.3.2 "Handover Failure" is then that the MSC sends a
6154 * BSSMAP Clear Command: */
6155
6156 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
6157 var BssmapCause cause := enum2int(cause_val);
6158 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
6159
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02006160 f_expect_dlcx_conns();
Neels Hofmeyr8fcd8772021-07-22 16:12:57 +02006161 BSSAP.receive(tr_BSSMAP_ClearComplete);
6162
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006163 setverdict(pass);
6164 f_sleep(1.0);
6165
6166 setverdict(pass);
6167}
6168testcase TC_ho_in_fail_msc_clears() runs on test_CT {
6169 var MSC_ConnHdlr vc_conn;
6170 var TestHdlrParams pars := f_gen_test_hdlr_pars();
6171
6172 f_init(1, true);
6173 f_sleep(1.0);
6174
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01006175 f_ctrs_bsc_and_bts_handover_init();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006176
Neels Hofmeyr90f80962020-06-12 16:16:55 +02006177 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
6178 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006179
6180 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_msc_clears), pars);
6181 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006182
6183 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6184 f_ctrs_bsc_and_bts_add(0, "handover:stopped");
6185 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
6186 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:stopped");
6187 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006188 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006189}
6190
6191private function f_tc_ho_in_fail_msc_clears_after_ho_detect(charstring id) runs on MSC_ConnHdlr {
6192 /* Hack: the proper way would be to wait for the BSSMAP Handover Request ACK and extract the
6193 * actual assigned chan_nr from its L3 (RR Handover Command) message. But osmo-bsc starts acting
6194 * on the lchan even before we get a chance to evaluate the BSSMAP Handover Request ACK. So we
6195 * need to assume that osmo-bsc will activate TS 1 and already set up this lchan's RSL emulation
6196 * before we get started. */
6197 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
6198 f_rslem_register(0, new_chan_nr);
6199 g_chan_nr := new_chan_nr;
6200 f_sleep(1.0);
6201
6202 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
6203 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
6204 activate(as_Media());
6205
Neels Hofmeyr90f80962020-06-12 16:16:55 +02006206 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006207 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02006208 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006209
6210 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
6211
6212 var PDU_BSSAP rx_bssap;
6213 var octetstring ho_command_str;
6214
6215 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
6216
6217 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
6218 log("Received L3 Info in HO Request Ack: ", ho_command_str);
6219 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
6220 log("L3 Info in HO Request Ack is ", ho_command);
6221
6222 var GsmArfcn arfcn;
6223 var RslChannelNr actual_new_chan_nr;
6224 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
6225 actual_new_chan_nr, arfcn);
6226
6227 if (actual_new_chan_nr != new_chan_nr) {
6228 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
6229 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
6230 setverdict(fail);
6231 return;
6232 }
6233 log("Handover Command chan_nr is", actual_new_chan_nr);
6234
6235 /* Now the MSC forwards the RR Handover Command to the other BSC, which
6236 * tells the MS to handover to the new lchan. Here comes the new MS on
6237 * the new lchan with a Handover RACH: */
6238
6239 /* send handover detect */
6240
6241 RSL.send(ts_RSL_HANDO_DET(new_chan_nr));
6242
6243 BSSAP.receive(tr_BSSMAP_HandoverDetect);
6244
6245 /* The MSC chooses to clear the connection now, maybe we got the
6246 * Handover RACH on the new cell but the MS still signaled Handover
6247 * Failure to the old BSS? */
6248
6249 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
6250 var BssmapCause cause := enum2int(cause_val);
6251 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
6252
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02006253 f_expect_dlcx_conns();
Neels Hofmeyr8fcd8772021-07-22 16:12:57 +02006254 BSSAP.receive(tr_BSSMAP_ClearComplete);
6255
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006256 f_sleep(1.0);
6257}
6258testcase TC_ho_in_fail_msc_clears_after_ho_detect() runs on test_CT {
6259 var MSC_ConnHdlr vc_conn;
6260 var TestHdlrParams pars := f_gen_test_hdlr_pars();
6261
6262 f_init(1, true);
6263 f_sleep(1.0);
6264
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01006265 f_ctrs_bsc_and_bts_handover_init();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006266
Neels Hofmeyr90f80962020-06-12 16:16:55 +02006267 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
6268 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006269
6270 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_msc_clears_after_ho_detect), pars);
6271 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006272
6273 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6274 f_ctrs_bsc_and_bts_add(0, "handover:stopped");
6275 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
6276 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:stopped");
6277 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006278 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006279}
6280
6281/* The new BSS's lchan times out before the MSC decides that handover failed. */
6282private function f_tc_ho_in_fail_no_detect(charstring id) runs on MSC_ConnHdlr {
6283 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
6284 f_rslem_register(0, new_chan_nr);
6285 g_chan_nr := new_chan_nr;
6286 f_sleep(1.0);
6287
6288 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
6289 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
6290 activate(as_Media());
6291
Neels Hofmeyr90f80962020-06-12 16:16:55 +02006292 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006293 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02006294 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006295
6296 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
6297
6298 var PDU_BSSAP rx_bssap;
6299 var octetstring ho_command_str;
6300
6301 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
6302
6303 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
6304 log("Received L3 Info in HO Request Ack: ", ho_command_str);
6305 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
6306 log("L3 Info in HO Request Ack is ", ho_command);
6307
6308 var GsmArfcn arfcn;
6309 var RslChannelNr actual_new_chan_nr;
6310 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
6311 actual_new_chan_nr, arfcn);
6312
6313 if (actual_new_chan_nr != new_chan_nr) {
6314 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
6315 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
6316 setverdict(fail);
6317 return;
6318 }
6319 log("Handover Command chan_nr is", actual_new_chan_nr);
6320
6321 /* Now the MSC forwards the RR Handover Command to the other BSC, which
6322 * tells the MS to handover to the new lchan. But the MS never shows up
6323 * on the new lchan. */
6324
6325 BSSAP.receive(tr_BSSMAP_HandoverFailure);
6326
6327 /* Did osmo-bsc also send a Clear Request? */
6328 timer T := 0.5;
6329 T.start;
6330 alt {
6331 [] BSSAP.receive(tr_BSSMAP_ClearRequest);
6332 [] T.timeout { }
6333 }
6334
6335 /* MSC plays along with a Clear Command (no matter whether osmo-bsc
6336 * asked for it, this is a Handover Failure after all). */
6337
6338 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
6339 var BssmapCause cause := enum2int(cause_val);
6340 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
6341
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02006342 f_expect_dlcx_conns();
Neels Hofmeyr8fcd8772021-07-22 16:12:57 +02006343 BSSAP.receive(tr_BSSMAP_ClearComplete);
6344
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006345 f_sleep(1.0);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006346}
6347testcase TC_ho_in_fail_no_detect() runs on test_CT {
6348 var MSC_ConnHdlr vc_conn;
6349 var TestHdlrParams pars := f_gen_test_hdlr_pars();
6350
6351 f_init(1, true);
6352 f_sleep(1.0);
6353
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01006354 f_ctrs_bsc_and_bts_handover_init();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006355
Neels Hofmeyr90f80962020-06-12 16:16:55 +02006356 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
6357 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006358
6359 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_no_detect), pars);
6360 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006361
6362 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6363 f_ctrs_bsc_and_bts_add(0, "handover:error");
6364 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
6365 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:error");
6366 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006367 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006368}
6369
6370/* Same as f_tc_ho_in_fail_no_detect, but MSC fails to send a Clear Command */
6371private function f_tc_ho_in_fail_no_detect2(charstring id) runs on MSC_ConnHdlr {
6372 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
6373 f_rslem_register(0, new_chan_nr);
6374 g_chan_nr := new_chan_nr;
6375 f_sleep(1.0);
6376
6377 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
6378 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
6379 activate(as_Media());
6380
Neels Hofmeyr90f80962020-06-12 16:16:55 +02006381 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006382 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02006383 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006384
6385 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
6386
6387 var PDU_BSSAP rx_bssap;
6388 var octetstring ho_command_str;
6389
6390 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
6391
6392 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
6393 log("Received L3 Info in HO Request Ack: ", ho_command_str);
6394 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
6395 log("L3 Info in HO Request Ack is ", ho_command);
6396
6397 var GsmArfcn arfcn;
6398 var RslChannelNr actual_new_chan_nr;
6399 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
6400 actual_new_chan_nr, arfcn);
6401
6402 if (actual_new_chan_nr != new_chan_nr) {
6403 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
6404 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
6405 setverdict(fail);
6406 return;
6407 }
6408 log("Handover Command chan_nr is", actual_new_chan_nr);
6409
6410 /* Now the MSC forwards the RR Handover Command to the other BSC, which
6411 * tells the MS to handover to the new lchan. But the MS never shows up
6412 * on the new lchan. */
6413
6414 BSSAP.receive(tr_BSSMAP_HandoverFailure);
6415
6416 /* MSC plays dumb and sends no Clear Command */
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006417 var PDU_BSSAP rx_clear_request;
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02006418
6419 BSSAP.receive(tr_BSSMAP_ClearRequest) -> value rx_clear_request {
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006420 var BssmapCause cause := bit2int(rx_clear_request.pdu.bssmap.clearRequest.cause.causeValue);
6421 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
6422 };
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02006423 f_expect_dlcx_conns();
Neels Hofmeyr8fcd8772021-07-22 16:12:57 +02006424 BSSAP.receive(tr_BSSMAP_ClearComplete);
6425
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006426 f_sleep(1.0);
6427}
6428testcase TC_ho_in_fail_no_detect2() runs on test_CT {
6429 var MSC_ConnHdlr vc_conn;
6430 var TestHdlrParams pars := f_gen_test_hdlr_pars();
6431
6432 f_init(1, true);
6433 f_sleep(1.0);
6434
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01006435 f_ctrs_bsc_and_bts_handover_init();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006436
Neels Hofmeyr90f80962020-06-12 16:16:55 +02006437 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
6438 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006439
6440 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_no_detect2), pars);
6441 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006442
6443 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6444 f_ctrs_bsc_and_bts_add(0, "handover:error");
6445 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
6446 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:error");
6447 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006448 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006449}
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01006450
Neels Hofmeyr91401012019-07-11 00:42:35 +02006451type record of charstring Commands;
6452
Neels Hofmeyr666f0432020-07-04 00:53:07 +02006453private function f_bts_0_cfg(TELNETasp_PT pt, Commands cmds := {})
Neels Hofmeyr91401012019-07-11 00:42:35 +02006454{
Neels Hofmeyr666f0432020-07-04 00:53:07 +02006455 f_vty_enter_cfg_bts(pt, 0);
Neels Hofmeyr91401012019-07-11 00:42:35 +02006456 for (var integer i := 0; i < sizeof(cmds); i := i+1) {
Neels Hofmeyr666f0432020-07-04 00:53:07 +02006457 f_vty_transceive(pt, cmds[i]);
Neels Hofmeyr91401012019-07-11 00:42:35 +02006458 }
Neels Hofmeyr666f0432020-07-04 00:53:07 +02006459 f_vty_transceive(pt, "end");
Neels Hofmeyr91401012019-07-11 00:42:35 +02006460}
6461
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01006462private function f_cs7_inst_0_cfg(TELNETasp_PT pt, Commands cmds := {})
6463{
6464 f_vty_enter_cfg_cs7_inst(pt, 0);
6465 for (var integer i := 0; i < sizeof(cmds); i := i+1) {
6466 f_vty_transceive(pt, cmds[i]);
6467 }
6468 f_vty_transceive(pt, "end");
6469}
6470
Neels Hofmeyr91401012019-07-11 00:42:35 +02006471private function f_probe_for_handover(charstring log_label,
6472 charstring log_descr,
6473 charstring handover_vty_cmd,
6474 boolean expect_handover,
Neels Hofmeyr6a955cc2021-10-02 14:53:48 +02006475 boolean is_inter_bsc_handover := false,
6476 template uint3_t expect_target_tsc := ?)
Neels Hofmeyr91401012019-07-11 00:42:35 +02006477runs on MSC_ConnHdlr
6478{
Neels Hofmeyrb3fc8982020-05-11 00:16:42 +02006479 /* We're going to thwart any and all handover attempts, just be ready to handle (and ignore) handover target
6480 * lchans to be established on bts 1 or bts 2. */
6481 f_rslem_suspend(RSL1_PROC);
6482 f_rslem_suspend(RSL2_PROC);
6483
Neels Hofmeyr91401012019-07-11 00:42:35 +02006484 var RSL_Message rsl;
6485
6486 var charstring log_msg := " (expecting handover)"
6487 if (not expect_handover) {
6488 log_msg := " (expecting NO handover)";
6489 }
6490 log("f_probe_for_handover starting: " & log_label & ": " & log_descr & log_msg);
6491 f_vty_transceive(BSCVTY, handover_vty_cmd);
6492
Neels Hofmeyr91401012019-07-11 00:42:35 +02006493 timer T := 2.0;
6494 T.start;
6495
6496 alt {
6497 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr)) -> value rsl {
6498 var PDU_ML3_NW_MS l3 := dec_PDU_ML3_NW_MS(rsl.ies[2].body.l3_info.payload);
6499 log("Rx L3 from net: ", l3);
6500 if (ischosen(l3.msgs.rrm.handoverCommand)) {
6501 var RslChannelNr new_chan_nr;
6502 var GsmArfcn arfcn;
6503 f_ChDesc2RslChanNr(l3.msgs.rrm.handoverCommand.channelDescription2,
6504 new_chan_nr, arfcn);
6505 log("Handover to new chan ", new_chan_nr, " on ARFCN ", arfcn);
6506 log(l3.msgs.rrm.handoverCommand);
6507
Neels Hofmeyr6a955cc2021-10-02 14:53:48 +02006508 /* Verify correct TSC in handoverCommand */
6509 var uint3_t got_tsc := rr_chan_desc_tsc(l3.msgs.rrm.handoverCommand.channelDescription2);
6510 if (not match(got_tsc, expect_target_tsc)) {
6511 setverdict(fail, "RR Handover Command: unexpected TSC in Channel Description: expected ",
6512 expect_target_tsc, " got ", got_tsc);
6513 mtc.stop;
6514 } else {
6515 log("handoverCommand: verified TSC = ", got_tsc, " (matches ",
6516 expect_target_tsc, ")");
6517 }
6518
Neels Hofmeyr91401012019-07-11 00:42:35 +02006519 /* Need to register for new lchan on new BTS -- it's either bts 1 or bts 2. It doesn't really
6520 * matter on which BTS it really is, we're not going to follow through an entire handover
6521 * anyway. */
6522 f_rslem_register(0, new_chan_nr, RSL1_PROC);
6523 f_rslem_resume(RSL1_PROC);
6524 f_rslem_register(0, new_chan_nr, RSL2_PROC);
6525 f_rslem_resume(RSL2_PROC);
6526
6527 if (expect_handover and not is_inter_bsc_handover) {
6528 setverdict(pass);
6529 log("f_probe_for_handover(" & log_label & "): Got RSL Handover Command as expected.");
6530 } else {
6531 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected none, but got RSL Handover Command. "
6532 & log_label & ": " & log_descr);
6533 }
6534
6535 log("f_probe_for_handover(" & log_label & "): Ending the test: Handover Failure stops the procedure.");
6536 /* osmo-bsc has triggered Handover. That's all we need to know for this test, reply with
6537 * Handover Failure. */
6538 f_rsl_send_l3(ts_RRM_HandoverFailure('00'O));
6539
6540 /* target BTS is told to release lchan again; don't care which BTS nor what messages. */
6541 f_sleep(0.5);
6542 RSL1.clear;
6543 RSL2.clear;
6544 log("f_probe_for_handover(" & log_label & "): done (got RSL Handover Command)");
6545 break;
6546 } else {
6547 repeat;
6548 }
6549 }
6550 [] BSSAP.receive(tr_BSSMAP_HandoverRequired) {
6551 if (expect_handover and is_inter_bsc_handover) {
6552 setverdict(pass);
6553 log("f_probe_for_handover(" & log_label & "): Got BSSMAP Handover Required as expected.");
6554 } else {
6555 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected none, but got BSSMAP Handover Required. "
6556 & log_label & ": " & log_descr);
6557 }
6558
6559 log("f_probe_for_handover(" & log_label & "): done (got BSSMAP Handover Required)");
6560
6561 /* Note: f_tc_ho_neighbor_config_start() sets T7, the timeout for BSSMAP Handover Required, to
6562 * 1 second. There is no legal way to quickly abort a handover after a BSSMAP Handover Required,
6563 * setting a short timeout and waiting is the only way. */
6564 log("f_probe_for_handover(" & log_label & "): waiting for inter-BSC HO to time out...");
6565 f_sleep(1.5);
6566 log("f_probe_for_handover(" & log_label & "): ...done");
6567
6568 break;
6569 }
6570 [] T.timeout {
6571 if (expect_handover) {
6572 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected Handover, but got none. "
6573 & log_label & ": " & log_descr);
6574 } else {
6575 setverdict(pass);
6576 log("f_probe_for_handover(" & log_label & "): Got no Handover, as expected.");
6577 }
6578 log("f_probe_for_handover(" & log_label & "): done (got no Handover)");
6579 break;
6580 }
6581 }
6582
6583 f_rslem_resume(RSL1_PROC);
6584 f_rslem_resume(RSL2_PROC);
6585 f_sleep(3.0);
6586 RSL.clear;
6587
6588 log("f_probe_for_handover(" & log_label & "): done clearing");
6589}
6590
6591/* Test the effect of various neighbor configuration scenarios:
6592 *
6593 * To avoid complexity, block off any actual handover operation, and always remain on the lchan at bts 0.
6594 * Reconfigure the neighbors for bts 0, trigger a Handover, and probe whether osmo-bsc does or doesn't start HO.
6595 */
6596private function f_tc_ho_neighbor_config_start() runs on MSC_ConnHdlr {
6597 g_pars := f_gen_test_hdlr_pars();
6598 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
6599 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Neels Hofmeyr91401012019-07-11 00:42:35 +02006600
6601 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
6602 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
6603
6604 /* Establish lchan at bts 0 */
6605 f_establish_fully(ass_cmd, exp_compl);
6606
6607 /* Shorten the inter-BSC Handover timeout, to not wait so long for inter-BSC Handovers */
6608 f_vty_enter_cfg_network(BSCVTY);
6609 f_vty_transceive(BSCVTY, "timer T7 1");
6610 f_vty_transceive(BSCVTY, "end");
6611}
6612
6613private function f_tc_ho_neighbor_config_1(charstring id) runs on MSC_ConnHdlr {
6614 f_tc_ho_neighbor_config_start();
6615
6616 /*
6617 * bts 0 ARFCN 871 BSIC 10
6618 * bts 1 ARFCN 871 BSIC 11
6619 * bts 2 ARFCN 871 BSIC 12
6620 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
6621 */
6622
6623 log("f_tc_ho_neighbor_config: 1. No 'neighbor' config");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02006624 f_bts_0_cfg(BSCVTY, {"no neighbors"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02006625 f_probe_for_handover("1.a", "HO to bts 1 works, implicitly listed as neighbor (legacy behavior when none are configured)",
6626 "handover any to arfcn 871 bsic 11",
Neels Hofmeyr6a955cc2021-10-02 14:53:48 +02006627 true, expect_target_tsc := BTS_TSC[1]);
Neels Hofmeyr91401012019-07-11 00:42:35 +02006628
6629 f_probe_for_handover("1.b", "HO to unknown cell does not start",
6630 "handover any to arfcn 13 bsic 39",
6631 false);
6632
6633 f_probe_for_handover("1.c", "HO to 871-12 is ambiguous = error",
6634 "handover any to arfcn 871 bsic 12",
6635 false);
6636
6637 f_probe_for_handover("1.d", "HO to 871-11 still works (verify that this test properly cleans up)",
6638 "handover any to arfcn 871 bsic 11",
Neels Hofmeyr6a955cc2021-10-02 14:53:48 +02006639 true, expect_target_tsc := BTS_TSC[1]);
Neels Hofmeyr91401012019-07-11 00:42:35 +02006640}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006641testcase TC_ho_neighbor_config_1() runs on test_CT {
6642 var MSC_ConnHdlr vc_conn;
6643 f_init(3, true, guard_timeout := 60.0);
6644 f_sleep(1.0);
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01006645 f_ctrs_bsc_and_bts_handover_init();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006646 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_1));
6647 vc_conn.done;
6648
6649 /* f_tc_ho_neighbor_config_start() */
6650 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
6651 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
6652
6653 /* 1.a */
6654 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
6655 * handover quickly by sending a Handover Failure message. */
6656 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6657 f_ctrs_bsc_and_bts_add(0, "handover:failed");
6658 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
6659 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01006660 f_ctrs_bts_add(1, "incoming_intra_bsc_ho:attempted");
6661 f_ctrs_bts_add(1, "incoming_intra_bsc_ho:failed");
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006662
6663 /* 1.b */
6664 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6665 f_ctrs_bsc_and_bts_add(0, "handover:error");
6666
6667 /* 1.c */
6668 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6669 f_ctrs_bsc_and_bts_add(0, "handover:error");
6670
6671 /* 1.d */
6672 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6673 f_ctrs_bsc_and_bts_add(0, "handover:failed");
6674 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
6675 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01006676 f_ctrs_bts_add(1, "incoming_intra_bsc_ho:attempted");
6677 f_ctrs_bts_add(1, "incoming_intra_bsc_ho:failed");
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006678
6679 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006680 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006681}
6682
Neels Hofmeyr91401012019-07-11 00:42:35 +02006683private function f_tc_ho_neighbor_config_2(charstring id) runs on MSC_ConnHdlr {
6684 f_tc_ho_neighbor_config_start();
6685
6686 /*
6687 * bts 0 ARFCN 871 BSIC 10
6688 * bts 1 ARFCN 871 BSIC 11
6689 * bts 2 ARFCN 871 BSIC 12
6690 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
6691 */
6692
6693 log("f_tc_ho_neighbor_config: 2. explicit local neighbor: 'neighbor bts 1'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02006694 f_bts_0_cfg(BSCVTY, {"neighbor bts 1"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02006695 f_sleep(0.5);
6696
6697 f_probe_for_handover("2.a", "HO to bts 1 works, explicitly listed as neighbor",
6698 "handover any to arfcn 871 bsic 11",
Neels Hofmeyr6a955cc2021-10-02 14:53:48 +02006699 true, expect_target_tsc := BTS_TSC[1]);
Neels Hofmeyr91401012019-07-11 00:42:35 +02006700
6701 f_probe_for_handover("2.b", "HO to bts 2 doesn't work, not listed as neighbor",
6702 "handover any to arfcn 871 bsic 12",
6703 false);
6704}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006705testcase TC_ho_neighbor_config_2() runs on test_CT {
6706 var MSC_ConnHdlr vc_conn;
6707 f_init(3, true, guard_timeout := 50.0);
6708 f_sleep(1.0);
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01006709 f_ctrs_bsc_and_bts_handover_init();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006710 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_2));
6711 vc_conn.done;
6712
6713 /* f_tc_ho_neighbor_config_start() */
6714 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
6715 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
6716
6717 /* 2.a */
6718 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
6719 * handover quickly by sending a Handover Failure message. */
6720 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6721 f_ctrs_bsc_and_bts_add(0, "handover:failed");
6722 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
6723 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01006724 f_ctrs_bts_add(1, "incoming_intra_bsc_ho:attempted");
6725 f_ctrs_bts_add(1, "incoming_intra_bsc_ho:failed");
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006726
6727 /* 2.b */
6728 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6729 f_ctrs_bsc_and_bts_add(0, "handover:error");
6730
6731 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006732 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006733}
6734
Neels Hofmeyr91401012019-07-11 00:42:35 +02006735private function f_tc_ho_neighbor_config_3(charstring id) runs on MSC_ConnHdlr {
6736 f_tc_ho_neighbor_config_start();
6737
6738 /*
6739 * bts 0 ARFCN 871 BSIC 10
6740 * bts 1 ARFCN 871 BSIC 11
6741 * bts 2 ARFCN 871 BSIC 12
6742 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
6743 */
6744
6745 log("f_tc_ho_neighbor_config: 3. explicit local neighbor: 'neighbor bts 2'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02006746 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor bts 2"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02006747 f_sleep(0.5);
6748
6749 f_probe_for_handover("3.a", "HO to bts 1 doesn't work, not listed as neighbor",
6750 "handover any to arfcn 871 bsic 11",
6751 false);
6752 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",
6753 "handover any to arfcn 871 bsic 12",
Neels Hofmeyr6a955cc2021-10-02 14:53:48 +02006754 true, expect_target_tsc := BTS_TSC[2]);
Neels Hofmeyr91401012019-07-11 00:42:35 +02006755}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006756testcase TC_ho_neighbor_config_3() runs on test_CT {
6757 var MSC_ConnHdlr vc_conn;
6758 f_init(3, true, guard_timeout := 50.0);
6759 f_sleep(1.0);
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01006760 f_ctrs_bsc_and_bts_handover_init();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006761 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_3));
6762 vc_conn.done;
6763
6764 /* f_tc_ho_neighbor_config_start() */
6765 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
6766 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
6767
6768 /* 3.a */
6769 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6770 f_ctrs_bsc_and_bts_add(0, "handover:error");
6771
6772 /* 3.b */
6773 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
6774 * handover quickly by sending a Handover Failure message. */
6775 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6776 f_ctrs_bsc_and_bts_add(0, "handover:failed");
6777 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
6778 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01006779 f_ctrs_bts_add(2, "incoming_intra_bsc_ho:attempted");
6780 f_ctrs_bts_add(2, "incoming_intra_bsc_ho:failed");
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006781
6782 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006783 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006784}
6785
Neels Hofmeyr91401012019-07-11 00:42:35 +02006786private function f_tc_ho_neighbor_config_4(charstring id) runs on MSC_ConnHdlr {
6787 f_tc_ho_neighbor_config_start();
6788
6789 /*
6790 * bts 0 ARFCN 871 BSIC 10
6791 * bts 1 ARFCN 871 BSIC 11
6792 * bts 2 ARFCN 871 BSIC 12
6793 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
6794 */
6795
6796 log("f_tc_ho_neighbor_config: 4. explicit remote neighbor: 'neighbor lac 99 arfcn 123 bsic 45'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02006797 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor lac 99 arfcn 123 bsic 45"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02006798 f_sleep(0.5);
6799
6800 f_probe_for_handover("4.a", "HO to bts 1 doesn't work, not listed as neighbor",
6801 "handover any to arfcn 871 bsic 11",
6802 false);
6803 f_probe_for_handover("4.b", "HO to bts 2 doesn't work, not listed as neighbor",
6804 "handover any to arfcn 871 bsic 12",
6805 false);
6806 f_probe_for_handover("4.c", "HO to 123-45 triggers inter-BSC HO",
6807 "handover any to arfcn 123 bsic 45",
6808 true, true);
6809}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006810testcase TC_ho_neighbor_config_4() runs on test_CT {
6811 var MSC_ConnHdlr vc_conn;
6812 f_init(3, true, guard_timeout := 50.0);
6813 f_sleep(1.0);
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01006814 f_ctrs_bsc_and_bts_handover_init();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006815 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_4));
6816 vc_conn.done;
6817
6818 /* f_tc_ho_neighbor_config_start() */
6819 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
6820 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
6821
6822 /* 4.a */
6823 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6824 f_ctrs_bsc_and_bts_add(0, "handover:error");
6825
6826 /* 4.b */
6827 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6828 f_ctrs_bsc_and_bts_add(0, "handover:error");
6829
6830 /* 4.c */
6831 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
6832 * handover quickly by timing out after the Handover Required message */
6833 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6834 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
6835 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
6836 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
6837
6838 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006839 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006840}
6841
Neels Hofmeyr91401012019-07-11 00:42:35 +02006842private function f_tc_ho_neighbor_config_5(charstring id) runs on MSC_ConnHdlr {
6843 f_tc_ho_neighbor_config_start();
6844
6845 /*
6846 * bts 0 ARFCN 871 BSIC 10
6847 * bts 1 ARFCN 871 BSIC 11
6848 * bts 2 ARFCN 871 BSIC 12
6849 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
6850 */
6851
6852 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 +02006853 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor lac 99 arfcn 871 bsic 12"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02006854 f_sleep(0.5);
6855
6856 f_probe_for_handover("5.a", "HO to 871-12 triggers inter-BSC HO (ignoring local cells with same ARFCN+BSIC)",
6857 "handover any to arfcn 871 bsic 12",
6858 true, true);
6859}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006860testcase TC_ho_neighbor_config_5() runs on test_CT {
6861 var MSC_ConnHdlr vc_conn;
6862 f_init(3, true);
6863 f_sleep(1.0);
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01006864 f_ctrs_bsc_and_bts_handover_init();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006865 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_5));
6866 vc_conn.done;
6867
6868 /* f_tc_ho_neighbor_config_start() */
6869 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
6870 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
6871
6872 /* 5 */
6873 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
6874 * handover quickly by timing out after the Handover Required message */
6875 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6876 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
6877 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
6878 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
6879
6880 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006881 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006882}
6883
Neels Hofmeyr91401012019-07-11 00:42:35 +02006884private function f_tc_ho_neighbor_config_6(charstring id) runs on MSC_ConnHdlr {
6885 f_tc_ho_neighbor_config_start();
6886
6887 /*
6888 * bts 0 ARFCN 871 BSIC 10
6889 * bts 1 ARFCN 871 BSIC 11
6890 * bts 2 ARFCN 871 BSIC 12
6891 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
6892 */
6893
6894 log("f_tc_ho_neighbor_config: 6. config error: explicit local and remote neighbors with ambiguous ARFCN+BSIC:"
6895 & " 'neighbor bts 2; neighbor lac 99 arfcn 871 bsic 12'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02006896 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor bts 2", "neighbor lac 99 arfcn 871 bsic 12"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02006897 f_sleep(0.5);
6898
6899 f_probe_for_handover("6.a", "HO to 871-12 is ambiguous = error",
6900 "handover any to arfcn 871 bsic 12",
6901 false);
6902}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006903testcase TC_ho_neighbor_config_6() runs on test_CT {
6904 var MSC_ConnHdlr vc_conn;
6905 f_init(3, true);
6906 f_sleep(1.0);
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01006907 f_ctrs_bsc_and_bts_handover_init();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006908 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_6));
6909 vc_conn.done;
6910
6911 /* f_tc_ho_neighbor_config_start() */
6912 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
6913 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
6914
6915 /* 6.a */
6916 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
6917 * handover quickly by timing out after the Handover Required message */
6918 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6919 f_ctrs_bsc_and_bts_add(0, "handover:error");
6920
6921 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006922 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006923}
6924
Neels Hofmeyr91401012019-07-11 00:42:35 +02006925private function f_tc_ho_neighbor_config_7(charstring id) runs on MSC_ConnHdlr {
6926 f_tc_ho_neighbor_config_start();
6927
6928 /*
6929 * bts 0 ARFCN 871 BSIC 10
6930 * bts 1 ARFCN 871 BSIC 11
6931 * bts 2 ARFCN 871 BSIC 12
6932 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
6933 */
6934
6935 log("f_tc_ho_neighbor_config: 7. explicit local and remote neighbors:"
6936 & " 'neighbor bts 2; neighbor lac 99 arfcn 123 bsic 45'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02006937 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor bts 2", "neighbor lac 99 arfcn 123 bsic 45"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02006938 f_sleep(0.5);
6939
6940 f_probe_for_handover("7.a", "HO to 871-12 does HO to bts 2",
6941 "handover any to arfcn 871 bsic 12",
Neels Hofmeyr6a955cc2021-10-02 14:53:48 +02006942 true, expect_target_tsc := BTS_TSC[2]);
Neels Hofmeyr91401012019-07-11 00:42:35 +02006943 f_probe_for_handover("7.b", "HO to 123-45 triggers inter-BSC HO",
6944 "handover any to arfcn 123 bsic 45",
6945 true, true);
6946}
Neels Hofmeyr91401012019-07-11 00:42:35 +02006947testcase TC_ho_neighbor_config_7() runs on test_CT {
6948 var MSC_ConnHdlr vc_conn;
Neels Hofmeyrf2b88032020-06-16 00:35:04 +02006949 f_init(3, true, guard_timeout := 50.0);
Neels Hofmeyr91401012019-07-11 00:42:35 +02006950 f_sleep(1.0);
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01006951 f_ctrs_bsc_and_bts_handover_init();
Neels Hofmeyr91401012019-07-11 00:42:35 +02006952 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_7));
6953 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006954
6955 /* f_tc_ho_neighbor_config_start() */
6956 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
6957 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
6958
6959 /* 7.a */
6960 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
6961 * handover quickly by sending a Handover Failure message. */
6962 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6963 f_ctrs_bsc_and_bts_add(0, "handover:failed");
6964 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
6965 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01006966 f_ctrs_bts_add(2, "incoming_intra_bsc_ho:attempted");
6967 f_ctrs_bts_add(2, "incoming_intra_bsc_ho:failed");
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006968
6969 /* 7.b */
6970 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
6971 * handover quickly by timing out after the Handover Required message */
6972 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6973 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
6974 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
6975 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
6976
6977 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006978 f_shutdown_helper();
Neels Hofmeyr91401012019-07-11 00:42:35 +02006979}
6980
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01006981/* OS#3041: Open and close N connections in a normal fashion, and expect no
6982 * BSSMAP Reset just because of that. */
6983testcase TC_bssap_rlsd_does_not_cause_bssmap_reset() runs on test_CT {
6984 var default d;
6985 var integer i;
6986 var DchanTuple dt;
6987
6988 f_init();
6989
6990 /* Wait for initial BSSMAP Reset to pass */
6991 f_sleep(4.0);
6992
6993 d := activate(no_bssmap_reset());
6994
6995 /* Setup up a number of connections and RLSD them again from the MSC
6996 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
6997 * Let's do it some more times for good measure. */
Harald Weltec3260d92018-06-11 17:48:16 +02006998 for (i := 0; i < 4; i := i+1) {
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01006999 /* Since we're doing a lot of runs, give each one a fresh
7000 * T_guard from the top. */
7001 T_guard.start;
7002
7003 /* Setup a BSSAP connection and clear it right away. This is
7004 * the MSC telling the BSC about a planned release, it's not an
7005 * erratic loss of a connection. */
Harald Weltea1897182018-06-11 13:53:09 +02007006 dt := f_est_dchan(int2oct(i,1), 23+i, '00010203040506'O);
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01007007
7008 /* MSC disconnects (RLSD). */
7009 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
7010 }
7011
7012 /* In the buggy behavior, a timeout of 2 seconds happens between above
7013 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
7014 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
7015 f_sleep(4.0);
7016
7017 deactivate(d);
7018 f_shutdown_helper();
7019}
Harald Welte552620d2017-12-16 23:21:36 +01007020
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01007021/* OS#3041: Open and close N connections in a normal fashion, and expect no
7022 * BSSMAP Reset just because of that. Invoke the release by a BSSMAP Clear from
7023 * the MSC. */
7024testcase TC_bssmap_clear_does_not_cause_bssmap_reset() runs on test_CT {
7025 var default d;
7026 var integer i;
7027 var DchanTuple dt;
7028 var BSSAP_N_DATA_ind rx_di;
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01007029 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_CALL_CONTROL;
7030 var BssmapCause cause := enum2int(cause_val);
7031
7032 f_init();
7033
7034 /* Wait for initial BSSMAP Reset to pass */
7035 f_sleep(4.0);
7036
7037 d := activate(no_bssmap_reset());
7038
7039 /* Setup up a number of connections and RLSD them again from the MSC
7040 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
7041 * Let's do it some more times for good measure. */
7042 for (i := 0; i < 8; i := i+1) {
7043 /* Since we're doing a lot of runs, give each one a fresh
7044 * T_guard from the top. */
7045 T_guard.start;
7046
7047 /* Setup a BSSAP connection and clear it right away. This is
7048 * the MSC telling the BSC about a planned release, it's not an
7049 * erratic loss of a connection. */
Harald Weltea1897182018-06-11 13:53:09 +02007050 dt := f_est_dchan(int2oct(i,1), 23+i, '00010203040506'O);
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01007051
7052 /* Instruct BSC to clear channel */
7053 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
7054
7055 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02007056 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01007057 }
7058
7059 /* In the buggy behavior, a timeout of 2 seconds happens between above
7060 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
7061 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
7062 f_sleep(4.0);
7063
7064 deactivate(d);
7065 f_shutdown_helper();
7066}
7067
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01007068/* OS#3041: Open and close N connections in a normal fashion, and expect no
7069 * BSSMAP Reset just because of that. Close connections from the MS side with a
7070 * Release Ind on RSL. */
7071testcase TC_ms_rel_ind_does_not_cause_bssmap_reset() runs on test_CT {
7072 var default d;
7073 var integer i;
7074 var DchanTuple dt;
7075 var BSSAP_N_DATA_ind rx_di;
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01007076 var integer j;
7077
7078 f_init();
7079
7080 /* Wait for initial BSSMAP Reset to pass */
7081 f_sleep(4.0);
7082
7083 d := activate(no_bssmap_reset());
7084
7085 /* Setup up a number of connections and RLSD them again from the MSC
7086 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
7087 * Let's do it some more times for good measure. */
7088 for (i := 0; i < 8; i := i+1) {
7089 /* Since we're doing a lot of runs, give each one a fresh
7090 * T_guard from the top. */
7091 T_guard.start;
7092
7093 /* Setup a BSSAP connection and clear it right away. This is
7094 * the MSC telling the BSC about a planned release, it's not an
7095 * erratic loss of a connection. */
7096 dt := f_est_dchan('23'O, 23, '00010203040506'O);
7097
7098 /* simulate RLL REL IND */
7099 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0))));
7100
7101 /* expect Clear Request on MSC side */
7102 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
7103
7104 /* Instruct BSC to clear channel */
7105 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
7106 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
7107
7108 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02007109 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01007110 }
7111
7112 /* In the buggy behavior, a timeout of 2 seconds happens between above
7113 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
7114 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
7115 f_sleep(4.0);
7116
7117 deactivate(d);
7118 f_shutdown_helper();
7119}
7120
Harald Welte94e0c342018-04-07 11:33:23 +02007121/***********************************************************************
7122 * IPA style dynamic PDCH
7123 ***********************************************************************/
7124
7125private function f_dyn_ipa_pdch_act(integer bts_nr, integer trx_nr, integer ts_nr,
7126 template (omit) RSL_Cause nack := omit)
7127runs on test_CT {
7128 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(ts_nr));
7129 var RSL_Message rsl_unused;
7130 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
7131 f_vty_ts_action("pdch activate", bts_nr, trx_nr, ts_nr);
7132 /* expect the BSC to issue the related RSL command */
7133 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
7134 if (istemplatekind(nack, "omit")) {
7135 /* respond with a related acknowledgement */
7136 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
7137 } else {
7138 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_NACK(chan_nr, valueof(nack)));
7139 }
7140}
7141
7142private function f_dyn_ipa_pdch_deact(integer bts_nr, integer trx_nr, integer ts_nr,
7143 template (omit) RSL_Cause nack := omit)
7144runs on test_CT {
7145 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(ts_nr));
7146 var RSL_Message rsl_unused;
7147 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
7148 f_vty_ts_action("pdch deactivate", bts_nr, trx_nr, ts_nr);
7149 /* expect the BSC to issue the related RSL command */
7150 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_DEACT(chan_nr));
7151 if (istemplatekind(nack, "omit")) {
7152 /* respond with a related acknowledgement */
7153 f_ipa_tx(0, ts_RSL_IPA_PDCH_DEACT_ACK(chan_nr));
7154 } else {
7155 f_ipa_tx(0, ts_RSL_IPA_PDCH_DEACT_NACK(chan_nr, valueof(nack)));
7156 }
7157}
7158
7159private function f_ts_dyn_mode_get(integer bts_nr, integer trx_nr, integer ts_nr)
7160runs on test_CT return charstring {
7161 var charstring cmd, resp;
7162 cmd := "show timeslot "&int2str(bts_nr)&" "&int2str(trx_nr)&" "&int2str(ts_nr);
Stefan Sperlingcff13562018-11-13 15:24:06 +01007163 return f_vty_transceive_match_regexp_retry(BSCVTY, cmd, "*\((*)\)*", 0, 4, 1.0);
Harald Welte94e0c342018-04-07 11:33:23 +02007164}
7165
7166private function f_ts_dyn_mode_assert(integer bts_nr, integer trx_nr, integer ts_nr,
7167 template charstring exp)
7168runs on test_CT {
7169 var charstring mode := f_ts_dyn_mode_get(bts_nr, trx_nr, ts_nr);
7170 if (not match(mode, exp)) {
7171 setverdict(fail, "Unexpected TS Mode: ", mode);
Daniel Willmannafce8662018-07-06 23:11:32 +02007172 mtc.stop;
Harald Welte94e0c342018-04-07 11:33:23 +02007173 }
7174}
7175
7176private function f_ts_set_chcomb(integer bts_nr, integer trx_nr, integer ts_nr, charstring chcomb)
7177runs on test_CT {
7178 f_vty_enter_cfg_ts(BSCVTY, bts_nr, trx_nr, ts_nr);
7179 f_vty_transceive(BSCVTY, "phys_chan_config " & chcomb);
7180 f_vty_transceive(BSCVTY, "end");
7181}
7182
Pau Espin Pedrol0953bf82021-07-09 13:20:19 +02007183
7184private function f_ts_reset_chcomb(integer bts_nr) runs on test_CT {
7185 var integer i;
7186 for (i := 0; i < 8; i := i + 1) {
7187 f_ts_set_chcomb(bts_nr, 0, i, phys_chan_config[i]);
7188 }
7189}
7190
Harald Welte94e0c342018-04-07 11:33:23 +02007191private const charstring TCHF_MODE := "TCH/F mode";
7192private const charstring TCHH_MODE := "TCH/H mode";
7193private const charstring PDCH_MODE := "PDCH mode";
7194private const charstring NONE_MODE := "NONE mode";
Pau Espin Pedrol5b381082021-06-28 17:14:03 +02007195private const charstring SDCCH8_MODE := "SDCCH8 mode";
Harald Welte94e0c342018-04-07 11:33:23 +02007196
7197/* Test IPA PDCH activation / deactivation triggered by VTY */
7198testcase TC_dyn_pdch_ipa_act_deact() runs on test_CT {
7199 var RSL_Message rsl_unused;
7200
7201 /* change Timeslot 6 before f_init() starts RSL */
7202 f_init_vty();
7203 f_ts_set_chcomb(0, 0, 6, "TCH/F_PDCH");
7204 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7205
7206 f_init(1, false);
7207 f_sleep(1.0);
7208
7209 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
7210
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02007211 log("TCH/F_PDCH pchan starts out in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02007212 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
7213 /* The BSC will activate the dynamic PDCH by default, so confirm that */
7214 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
7215 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
7216 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02007217 log("TCH/F_PDCH pchan, PDCH ACT was ACKed, so now in PDCH mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02007218 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
7219
7220 /* De-activate it via VTY */
7221 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
7222 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02007223 log("TCH/F_PDCH pchan, PDCH DEACT via VTY, so now back in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02007224 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
7225
7226 /* re-activate it via VTY */
7227 f_dyn_ipa_pdch_act(0, 0, chan_nr.tn);
7228 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02007229 log("TCH/F_PDCH pchan, PDCH ACT via VTY, so now in PDCH mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02007230 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
7231
7232 /* and finally de-activate it again */
7233 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
7234 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02007235 log("TCH/F_PDCH pchan, PDCH DEACT via VTY, so now back in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02007236 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
7237
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02007238 /* clean up config */
7239 f_ts_set_chcomb(0, 0, 6, "PDCH");
7240
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007241 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02007242}
7243
7244/* Test IPA PDCH activation NACK */
7245testcase TC_dyn_pdch_ipa_act_nack() runs on test_CT {
7246 var RSL_Message rsl_unused;
7247
7248 /* change Timeslot 6 before f_init() starts RSL */
7249 f_init_vty();
7250 f_ts_set_chcomb(0, 0, 6, "TCH/F_PDCH");
7251 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7252
7253 f_init(1, false);
7254 f_sleep(1.0);
7255
7256 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
7257
7258 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
7259 /* The BSC will activate the dynamic PDCH by default, so confirm that */
7260 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
7261 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
7262 f_sleep(1.0);
7263 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
7264
7265 /* De-activate it via VTY */
7266 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
7267 f_sleep(1.0);
7268 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
7269
7270 /* re-activate it via VTY, but fail that; check BSC still assumes TCH/F mode */
7271 f_dyn_ipa_pdch_act(0, 0, chan_nr.tn, RSL_ERR_EQUIPMENT_FAIL);
7272 f_sleep(1.0);
7273 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
7274
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02007275 /* clean up config */
7276 f_ts_set_chcomb(0, 0, 6, "PDCH");
7277
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007278 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02007279}
7280
7281
7282/***********************************************************************
7283 * Osmocom style dynamic PDCH
7284 ***********************************************************************/
7285
7286private function f_dyn_osmo_pdch_act(integer bts_nr, integer trx_nr, integer ts_nr,
7287 template (omit) RSL_Cause nack := omit)
7288runs on test_CT {
7289 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(ts_nr));
7290 var RSL_Message rsl_unused;
Pau Espin Pedrol64adf372021-06-28 16:25:47 +02007291 /* ask BSC via VTY to activate a given OSMO style chan as PDCH */
Harald Welte94e0c342018-04-07 11:33:23 +02007292 /* FIXME: no VTY command to activate Osmocom PDCH !! */
7293 /* expect the BSC to issue the related RSL command */
7294 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT(chan_nr, ?));
7295 if (istemplatekind(nack, "omit")) {
7296 /* respond with a related acknowledgement */
7297 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342));
7298 } else {
7299 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, valueof(nack)));
7300 }
7301}
7302
7303private function f_dyn_osmo_pdch_deact(integer bts_nr, integer trx_nr, integer ts_nr,
7304 template (omit) RSL_Cause nack := omit)
7305runs on test_CT {
7306 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(ts_nr));
7307 var RSL_Message rsl_unused;
Pau Espin Pedrol64adf372021-06-28 16:25:47 +02007308 /* ask BSC via VTY to activate a given OSMO style chan as PDCH */
Harald Welte94e0c342018-04-07 11:33:23 +02007309 /* FIXME: no VTY command to activate Osmocom PDCH !! */
7310 /* expect the BSC to issue the related RSL command */
7311 rsl_unused := f_exp_ipa_rx(0, tr_RSL_RF_CHAN_REL(chan_nr));
7312 if (istemplatekind(nack, "omit")) {
7313 /* respond with a related acknowledgement */
7314 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(chan_nr));
7315 } else {
7316 //f_ipa_tx(0, ts_RSL_RF_CHAN_REL_NACK(chan_nr, valueof(nack)));
7317 }
7318}
7319
7320/* Test Osmocom dyn PDCH activation / deactivation triggered by VTY */
7321testcase TC_dyn_pdch_osmo_act_deact() runs on test_CT {
7322 var RSL_Message rsl_unused;
7323
7324 /* change Timeslot 6 before f_init() starts RSL */
7325 f_init_vty();
7326 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_PDCH");
7327 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7328
7329 f_init(1, false);
7330 f_sleep(1.0);
7331
7332 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(6));
7333
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02007334 log("TCH/F_TCH/H_PDCH pchan starts out in disabled mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02007335 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
7336 /* The BSC will activate the dynamic PDCH by default, so confirm that */
7337 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
7338
7339 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342));
7340 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02007341 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 +02007342 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
7343
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02007344 /* clean up config */
7345 f_ts_set_chcomb(0, 0, 6, "PDCH");
7346
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007347 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02007348}
7349
7350/* Test Osmocom dyn PDCH activation NACK behavior */
7351testcase TC_dyn_pdch_osmo_act_nack() runs on test_CT {
7352 var RSL_Message rsl_unused;
7353
7354 /* change Timeslot 6 before f_init() starts RSL */
7355 f_init_vty();
7356 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_PDCH");
7357 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7358
7359 f_init(1, false);
7360 f_sleep(1.0);
7361
7362 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(6));
7363
7364 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
7365 /* The BSC will activate the dynamic PDCH by default, so confirm that */
7366 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
7367
7368 /* NACK this activation and expect the "show timeslot" mode still to be NONE */
7369 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, RSL_ERR_EQUIPMENT_FAIL));
7370 f_sleep(1.0);
7371 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
7372
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02007373 /* clean up config */
7374 f_ts_set_chcomb(0, 0, 6, "PDCH");
7375
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007376 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02007377}
7378
Pau Espin Pedrol5b381082021-06-28 17:14:03 +02007379/* Test Osmocom dyn TS SDCCH8 activation / deactivation */
7380testcase TC_dyn_ts_sdcch8_act_deact() runs on test_CT {
7381 var RSL_Message rsl_unused, rsl_msg;
7382 var DchanTuple dt;
7383 var BSSAP_N_CONNECT_ind rx_c_ind;
7384
7385 /* change Timeslot 6 before f_init() starts RSL */
7386 f_init_vty();
7387 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_SDCCH8_PDCH");
7388 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7389
7390 f_init(1, false);
7391 f_sleep(1.0);
7392
7393 var RslChannelNr pdch_chan_nr := valueof(t_RslChanNr_PDCH(6));
7394
7395 log("TCH/F_TCH/H_SDCCH8_PDCH pchan starts out in disabled mode:");
7396 f_ts_dyn_mode_assert(0, 0, pdch_chan_nr.tn, NONE_MODE);
7397 /* The BSC will activate the dynamic PDCH by default, so confirm that */
7398 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(pdch_chan_nr, ?));
7399
7400 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(pdch_chan_nr, 2342));
7401 f_sleep(1.0);
7402 log("TCH/F_TCH/H_SDCCH8_PDC requested to PDCH ACT on startup, which was ACKed, so now in PDCH:");
7403 f_ts_dyn_mode_assert(0, 0, pdch_chan_nr.tn, PDCH_MODE);
7404
7405 /* Fill TS0 SDCCH channels (NOTE: only 3 SDCCH/4 channels are available
7406 * on CCCH+SDCCH4+CBCH) */
7407 var integer i;
Pau Espin Pedrolce4d5bb2021-10-25 13:31:25 +02007408 for (i := 0; i < NUM_SDCCH_PER_BTS; i := i + 1) {
Pau Espin Pedrol5b381082021-06-28 17:14:03 +02007409 dt := f_est_dchan('23'O, i, '00010203040506'O);
7410 }
7411
7412 /* Now the dyn ts is selected. First PDCH is released, then sdcch chan is activated */
7413 f_ipa_tx(0, ts_RSL_CHAN_RQD(int2oct(oct2int('23'O) + i, 1), 2342));
7414 rsl_unused := f_exp_ipa_rx(0, tr_RSL_RF_CHAN_REL(pdch_chan_nr));
7415 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(pdch_chan_nr));
7416
7417 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7418 dt.rsl_chan_nr := rsl_msg.ies[0].body.chan_nr;
7419
7420 f_ts_dyn_mode_assert(0, 0, dt.rsl_chan_nr.tn, SDCCH8_MODE);
7421 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(dt.rsl_chan_nr, 2342));
7422 rsl_msg := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
7423 f_ts_dyn_mode_assert(0, 0, dt.rsl_chan_nr.tn, SDCCH8_MODE);
7424
7425 f_ipa_tx(0, ts_RSL_EST_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)), '1234'O));
7426 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3('1234'O))) -> value rx_c_ind;
7427 dt.sccp_conn_id := rx_c_ind.connectionId;
7428 BSSAP.send(ts_BSSAP_CONNECT_res(dt.sccp_conn_id));
7429
7430 /* Instruct BSC to clear channel */
7431 var BssmapCause cause := 0;
7432 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
7433 f_exp_chan_rel_and_clear(dt, 0);
7434
7435 /* The BSC will switch the TS back to PDCH once the only lchan using it is released: */
7436 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(pdch_chan_nr, ?));
7437 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(pdch_chan_nr, 2342));
7438 f_sleep(1.0);
7439 f_ts_dyn_mode_assert(0, 0, pdch_chan_nr.tn, PDCH_MODE);
7440
7441 /* clean up config */
7442 f_ts_set_chcomb(0, 0, 6, "PDCH");
7443
7444 f_shutdown_helper();
7445}
7446
Neels Hofmeyre1a7c4d2021-10-23 23:13:01 +02007447/* Validate all 8 subslots of a dynamics TS configured as SDCCH8 are used */
7448testcase TC_dyn_ts_sdcch8_all_subslots_used() runs on test_CT {
7449 var ASP_RSL_Unitdata rsl_ud;
7450 var integer i;
7451 var integer chreq_total, chreq_nochan;
7452
7453 f_init_vty();
7454 for (i := 1; i < 8; i := i + 1) {
7455 if (i == 2) {
7456 f_ts_set_chcomb(0, 0, i, "TCH/F_TCH/H_SDCCH8_PDCH");
7457 } else {
7458 f_ts_set_chcomb(0, 0, i, "PDCH");
7459 }
7460 }
7461 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7462
7463 f_init(1);
7464
7465 /* The dyn TS want to activate PDCH mode, ACK that. */
7466 var RslChannelNr chan_nr;
7467 chan_nr := valueof(t_RslChanNr_PDCH(2));
7468 f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
7469 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342));
7470
7471 f_sleep(1.0);
7472
7473 /* Exhaust all dedicated SDCCH lchans.
7474 /* GSM 44.018 Table 9.1.8.2:
7475 * RA = '13'O -> Establishment cause = 0001xxxx (MS dual rate capable and asks for "SDCCH").
7476 */
7477 for (i := 0; i < NUM_SDCCH_PER_BTS; i := i+1) {
7478 f_est_dchan('13'O, NUM_SDCCH_PER_BTS + i, '00010203040506'O);
7479 }
7480
7481 /* Only the dyn TS is still available. Its first lchan gets converted to SDCCH8 */
7482 f_est_dchan_dyn('33'O, NUM_SDCCH_PER_BTS + i, '00010203040506'O);
7483 /* Also occupy the seven other SDCCH of the dyn TS */
7484 for (i := 0; i < 7; i := i+1) {
7485 f_est_dchan('33'O, NUM_SDCCH_PER_BTS + i, '00010203040506'O);
7486 }
7487
7488 /* clean up config */
7489 f_ts_reset_chcomb(0);
7490
7491 f_shutdown_helper();
7492}
7493
Pau Espin Pedrol0953bf82021-07-09 13:20:19 +02007494/* Test Osmocom dyn TS SDCCH8 activation / deactivation: If activating dyn TS as
7495 SDCCH8 would end up in having no free TCH, then BSC should decide to activate
7496 it as TCH directly instead. SYS#5309. */
7497testcase TC_dyn_ts_sdcch8_tch_call_act_deact() runs on test_CT {
7498 var RSL_Message rsl_unused, rsl_msg;
7499 var DchanTuple dt;
7500 var BSSAP_N_CONNECT_ind rx_c_ind;
7501 var integer i;
7502
7503 /* change Timeslot 6 before f_init() starts RSL */
7504 f_init_vty();
7505 for (i := 1; i < 8; i := i + 1) {
7506 if (i == 6) {
7507 f_ts_set_chcomb(0, 0, i, "TCH/F_TCH/H_SDCCH8_PDCH");
7508 } else {
7509 f_ts_set_chcomb(0, 0, i, "PDCH");
7510 }
7511 }
7512 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7513
7514 f_init(1, false);
7515 f_sleep(1.0);
7516
7517 var RslChannelNr pdch_chan_nr := valueof(t_RslChanNr_PDCH(6));
7518
7519 log("TCH/F_TCH/H_SDCCH8_PDCH pchan starts out in disabled mode:");
7520 f_ts_dyn_mode_assert(0, 0, pdch_chan_nr.tn, NONE_MODE);
7521 /* The BSC will activate the dynamic PDCH by default, so confirm that */
7522 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(pdch_chan_nr, ?));
7523
7524 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(pdch_chan_nr, 2342));
7525 f_sleep(1.0);
7526 log("TCH/F_TCH/H_SDCCH8_PDC requested to PDCH ACT on startup, which was ACKed, so now in PDCH:");
7527 f_ts_dyn_mode_assert(0, 0, pdch_chan_nr.tn, PDCH_MODE);
7528
7529 /* Fill TS0 SDCCH channels (NOTE: only 3 SDCCH/4 channels are available
7530 * on CCCH+SDCCH4+CBCH) */
Pau Espin Pedrol2ebbe7c2021-07-23 16:17:09 +02007531 var OCT1 ra := '43'O; /* RA containing reason=originating speech call*/
Pau Espin Pedrolce4d5bb2021-10-25 13:31:25 +02007532 for (i := 0; i < NUM_SDCCH_PER_BTS; i := i + 1) {
Pau Espin Pedrol2ebbe7c2021-07-23 16:17:09 +02007533 dt := f_est_dchan(ra, i, '00010203040506'O);
Pau Espin Pedrol0953bf82021-07-09 13:20:19 +02007534 }
7535
7536 /* Now the dyn ts is selected. First PDCH is released, then TCH chan is activated */
Pau Espin Pedrol2ebbe7c2021-07-23 16:17:09 +02007537 f_ipa_tx(0, ts_RSL_CHAN_RQD(int2oct(oct2int(ra) + i, 1), 2342));
Pau Espin Pedrol0953bf82021-07-09 13:20:19 +02007538 rsl_unused := f_exp_ipa_rx(0, tr_RSL_RF_CHAN_REL(pdch_chan_nr));
7539 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(pdch_chan_nr));
7540
7541 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7542 dt.rsl_chan_nr := rsl_msg.ies[0].body.chan_nr;
7543
7544 f_ts_dyn_mode_assert(0, 0, dt.rsl_chan_nr.tn, TCHH_MODE);
7545 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(dt.rsl_chan_nr, 2342));
7546 rsl_msg := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
7547 f_ts_dyn_mode_assert(0, 0, dt.rsl_chan_nr.tn, TCHH_MODE);
7548
7549 f_ipa_tx(0, ts_RSL_EST_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)), '1234'O));
7550 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3('1234'O))) -> value rx_c_ind;
7551 dt.sccp_conn_id := rx_c_ind.connectionId;
7552 BSSAP.send(ts_BSSAP_CONNECT_res(dt.sccp_conn_id));
7553
7554 /* Instruct BSC to clear channel */
7555 var BssmapCause cause := 0;
7556 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
7557 f_exp_chan_rel_and_clear(dt, 0);
7558
7559 /* The BSC will switch the TS back to PDCH once the only lchan using it is released: */
7560 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(pdch_chan_nr, ?));
7561 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(pdch_chan_nr, 2342));
7562 f_sleep(1.0);
7563 f_ts_dyn_mode_assert(0, 0, pdch_chan_nr.tn, PDCH_MODE);
7564
7565 /* clean up config */
7566 f_ts_reset_chcomb(0);
7567 /* TODO: clean up other channels? */
7568
7569 f_shutdown_helper();
7570}
7571
Pau Espin Pedrolcdf26142021-06-28 17:14:03 +02007572/* Test Osmocom dyn TS SDCCH8 activation / deactivation when SDCCH fails at BTS */
7573testcase TC_dyn_ts_sdcch8_act_nack() runs on test_CT {
7574 var RSL_Message rsl_unused, rsl_msg;
7575 var DchanTuple dt;
7576 var BSSAP_N_CONNECT_ind rx_c_ind;
7577 var GsmRrMessage rr;
7578
7579 /* change Timeslot 6 before f_init() starts RSL */
7580 f_init_vty();
7581 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_SDCCH8_PDCH");
7582 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7583
7584 f_init(1, false);
7585 f_sleep(1.0);
7586
7587 var RslChannelNr pdch_chan_nr := valueof(t_RslChanNr_PDCH(6));
7588
7589 log("TCH/F_TCH/H_SDCCH8_PDCH pchan starts out in disabled mode:");
7590 f_ts_dyn_mode_assert(0, 0, pdch_chan_nr.tn, NONE_MODE);
7591 /* The BSC will activate the dynamic PDCH by default, so confirm that */
7592 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(pdch_chan_nr, ?));
7593
7594 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(pdch_chan_nr, 2342));
7595 f_sleep(1.0);
7596 log("TCH/F_TCH/H_SDCCH8_PDC requested to PDCH ACT on startup, which was ACKed, so now in PDCH:");
7597 f_ts_dyn_mode_assert(0, 0, pdch_chan_nr.tn, PDCH_MODE);
7598
7599 /* Fill TS0 SDCCH channels (NOTE: only 3 SDCCH/4 channels are available
7600 * on CCCH+SDCCH4+CBCH) */
7601 var integer i;
Pau Espin Pedrolce4d5bb2021-10-25 13:31:25 +02007602 for (i := 0; i < NUM_SDCCH_PER_BTS; i := i + 1) {
Pau Espin Pedrolcdf26142021-06-28 17:14:03 +02007603 dt := f_est_dchan('23'O, i, '00010203040506'O);
7604 }
7605
7606 /* Now the dyn ts is selected. First PDCH is released, then sdcch chan is activated */
7607 f_ipa_tx(0, ts_RSL_CHAN_RQD(int2oct(oct2int('23'O) + i, 1), 2342));
7608 rsl_unused := f_exp_ipa_rx(0, tr_RSL_RF_CHAN_REL(pdch_chan_nr));
7609 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(pdch_chan_nr));
7610
7611 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7612 dt.rsl_chan_nr := rsl_msg.ies[0].body.chan_nr;
7613
7614 f_ts_dyn_mode_assert(0, 0, dt.rsl_chan_nr.tn, SDCCH8_MODE);
7615 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(dt.rsl_chan_nr, RSL_ERR_EQUIPMENT_FAIL));
7616 rsl_msg := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
7617 rr := dec_GsmRrMessage(rsl_msg.ies[1].body.full_imm_ass_info.payload);
7618 if (rr.header.message_type != IMMEDIATE_ASSIGNMENT_REJECT) {
7619 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Expected reject");
7620 }
7621
7622 /* FIXME? Currently the TS stays in state BORKEN: */
7623
7624 /* The BSC will switch the TS back to PDCH once the only lchan using it is released: */
7625 /* rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(pdch_chan_nr, ?));
7626 * f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(pdch_chan_nr, 2342));
7627 * f_sleep(1.0);
7628 * f_ts_dyn_mode_assert(0, 0, pdch_chan_nr.tn, PDCH_MODE)
7629 */
7630
7631 /* clean up config */
7632 f_ts_set_chcomb(0, 0, 6, "PDCH");
7633
7634 f_shutdown_helper();
7635}
7636
Stefan Sperling0796a822018-10-05 13:01:39 +02007637testcase TC_chopped_ipa_ping() runs on test_CT {
Stefan Sperling554123f2018-10-09 14:12:30 +02007638 const Integers bsc_ipa_ports := {mp_bsc_rsl_port, mp_bsc_oml_port, mp_bsc_ctrl_port};
Stefan Sperling0796a822018-10-05 13:01:39 +02007639 for (var integer i := 0; i < lengthof(bsc_ipa_ports); i := i + 1) {
7640 IPA_Testing.f_run_TC_chopped_ipa_ping(mp_bsc_ip, bsc_ipa_ports[i], CONNECT_TO_SERVER);
7641 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007642 f_shutdown_helper();
Stefan Sperling0796a822018-10-05 13:01:39 +02007643}
7644
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02007645testcase TC_chopped_ipa_payload() runs on test_CT {
7646 const Integers bsc_ipa_ports := {mp_bsc_rsl_port, mp_bsc_oml_port
7647 /* TODO: mp_bsc_ctrl_port does not work yet */};
7648 for (var integer i := 0; i < lengthof(bsc_ipa_ports); i := i + 1) {
7649 IPA_Testing.f_run_TC_chopped_ipa_payload(mp_bsc_ip, bsc_ipa_ports[i], CONNECT_TO_SERVER);
7650 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007651 f_shutdown_helper();
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02007652}
7653
Pau Espin Pedrol8f773632019-11-05 11:46:53 +01007654/* Verify the BSC sends the MS Power Parameters IE during CHAN ACT to make sure
7655 the BTS does autonomous MS power control loop */
7656testcase TC_assignment_verify_ms_power_params_ie() runs on test_CT {
7657 var MSC_ConnHdlr vc_conn;
7658 var TestHdlrParams pars := f_gen_test_hdlr_pars();
7659 //pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
7660 pars.exp_ms_power_params := true;
7661
7662 f_init(1, true);
7663 f_sleep(1.0);
7664 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
7665 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007666 f_shutdown_helper();
Pau Espin Pedrol8f773632019-11-05 11:46:53 +01007667}
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02007668
Vadim Yanitskiy4b233042021-06-30 00:58:43 +02007669/* Verify activation and deactivation of the BCCH carrier power reduction mode */
7670testcase TC_c0_power_red_mode() runs on test_CT {
7671 f_init(1);
7672
7673 for (var integer red := 6; red >= 0; red := red - 2) {
7674 /* Configure BCCH carrier power reduction mode via the VTY */
7675 f_vty_transceive(BSCVTY, "bts 0 c0-power-reduction " & int2str(red));
7676
7677 /* Expect Osmocom specific BS Power Control message on the RSL */
7678 var template RSL_Message tr_rsl_pdu := tr_RSL_BS_PWR_CTRL(
7679 chan_nr := t_RslChanNr_BCCH(0),
7680 bs_power := tr_RSL_IE_BS_Power(red / 2));
7681 tr_rsl_pdu.msg_disc := tr_RSL_MsgDisc(RSL_MDISC_CCHAN, false);
7682 var RSL_Message unused := f_exp_ipa_rx(0, tr_rsl_pdu);
7683
7684 /* Additionally verify the applied value over the CTRL interface */
7685 var CtrlValue cred := f_ctrl_get_bts(IPA_CTRL, 0, "c0-power-reduction");
7686 if (cred != int2str(red)) {
7687 setverdict(fail, "Unexpected BCCH carrier power reduction value ",
7688 cred, " (expected ", red, ")");
7689 }
7690 }
7691
7692 f_shutdown_helper();
7693}
7694
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007695/***********************************************************************
7696 * MSC Pooling
7697 ***********************************************************************/
7698
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007699template MobileIdentityLV ts_MI_TMSI_NRI_LV(integer nri_v, integer nri_bitlen := 10) :=
Harald Weltebf397612021-01-14 20:39:46 +01007700 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 +02007701
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007702private 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 +02007703runs on MSC_ConnHdlr {
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02007704 interleave {
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007705 [] rsl_pt.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch exp_rr_rel_tmpl)) {
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02007706 f_logp(BSCVTY, "Got RSL RR Release");
7707 }
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007708 [] rsl_pt.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02007709 f_logp(BSCVTY, "Got RSL Deact SACCH");
7710 }
Neels Hofmeyr3c5127e2021-07-22 19:18:40 +02007711 [] rsl_pt.receive(tr_RSL_RF_CHAN_REL(g_chan_nr)) {
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02007712 f_logp(BSCVTY, "Got RSL RF Chan Rel, sending Rel Ack");
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007713 rsl_pt.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
7714 f_rslem_unregister(0, g_chan_nr, PT := rsl_proc_pt);
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02007715 break;
7716 }
7717 }
7718}
7719
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007720friend function f_perform_clear(RSL_DCHAN_PT rsl_pt := RSL, RSLEM_PROC_PT rsl_proc_pt := RSL_PROC,
7721 template PDU_ML3_NW_MS exp_rr_rel_tmpl := tr_RRM_RR_RELEASE)
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02007722runs on MSC_ConnHdlr {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00007723 f_logp(BSCVTY, "MSC instructs BSC to clear channel");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007724 BSSAP.send(ts_BSSMAP_ClearCommand(0));
7725 interleave {
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007726 [] rsl_pt.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch exp_rr_rel_tmpl)) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00007727 f_logp(BSCVTY, "Got RSL RR Release");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007728 }
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007729 [] rsl_pt.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00007730 f_logp(BSCVTY, "Got RSL Deact SACCH");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007731 }
7732 [] BSSAP.receive(tr_BSSMAP_ClearComplete) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00007733 f_logp(BSCVTY, "Got BSSMAP Clear Complete");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007734 /* Also drop the SCCP connection */
7735 BSSAP.send(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_REQ);
7736 }
Neels Hofmeyr3c5127e2021-07-22 19:18:40 +02007737 [] rsl_pt.receive(tr_RSL_RF_CHAN_REL(g_chan_nr)) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00007738 f_logp(BSCVTY, "Got RSL RF Chan Rel, sending Rel Ack");
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007739 rsl_pt.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
7740 f_rslem_unregister(0, g_chan_nr, PT := rsl_proc_pt);
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007741 }
7742 }
7743}
7744
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007745private function f_perform_compl_l3(RSL_DCHAN_PT rsl_pt, RSLEM_PROC_PT rsl_proc_pt,
7746 template PDU_ML3_MS_NW l3_info, boolean do_clear := true, boolean expect_bssmap_l3 := true)
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007747runs on MSC_ConnHdlr {
7748 timer T := 10.0;
7749 var octetstring l3_enc := enc_PDU_ML3_MS_NW(valueof(l3_info));
7750
Neels Hofmeyr767548a2020-08-09 20:26:07 +00007751 f_logp(BSCVTY, "establish channel, send Complete Layer 3 Info");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007752 f_create_bssmap_exp(l3_enc);
7753
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007754 /* RSL_Emulation.f_chan_est() on rsl_pt:
7755 * This is basically code dup with s/RSL/rsl_pt from:
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007756 * RSL_Emulation.f_chan_est(g_pars.ra, l3_enc, g_pars.link_id, g_pars.fn);
7757 */
7758 var RSL_Message rx_rsl;
7759 var GsmRrMessage rr;
7760
7761 /* request a channel to be established */
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007762 rsl_pt.send(ts_RSLDC_ChanRqd(g_pars.ra, g_pars.fn));
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007763 /* expect immediate assignment.
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007764 * Code dup with s/RSL/rsl_pt from:
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007765 * rx_rsl := f_rx_or_fail(tr_RSL_IMM_ASSIGN);
7766 */
7767 timer Tt := 10.0;
7768
7769 /* request a channel to be established */
7770 Tt.start;
7771 alt {
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007772 [] rsl_pt.receive(tr_RSL_IMM_ASSIGN) -> value rx_rsl {
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007773 Tt.stop;
7774 }
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007775 [] rsl_pt.receive {
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007776 setverdict(fail, "Unexpected RSL message on DCHAN");
7777 mtc.stop;
7778 }
7779 [] Tt.timeout {
7780 setverdict(fail, "Timeout waiting for RSL on DCHAN");
7781 mtc.stop;
7782 }
7783 }
7784 rr := dec_GsmRrMessage(rx_rsl.ies[1].body.full_imm_ass_info.payload);
7785 g_chan_nr := rr.payload.imm_ass.chan_desc.chan_nr;
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007786 rsl_pt.send(ts_RSL_EST_IND(g_chan_nr, valueof(g_pars.link_id), l3_enc));
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007787
7788
Neels Hofmeyr66e15092020-10-12 18:44:41 +00007789 if (expect_bssmap_l3) {
7790 f_logp(BSCVTY, "expect BSSAP Complete Layer 3 Info at MSC");
7791 var template PDU_BSSAP exp_l3_compl;
7792 exp_l3_compl := tr_BSSMAP_ComplL3()
7793 if (g_pars.aoip == false) {
7794 exp_l3_compl.pdu.bssmap.completeLayer3Information.codecList := omit;
7795 } else {
7796 exp_l3_compl.pdu.bssmap.completeLayer3Information.codecList := ?;
7797 }
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007798
Neels Hofmeyr66e15092020-10-12 18:44:41 +00007799 var PDU_BSSAP bssap;
7800 T.start;
7801 alt {
7802 [] BSSAP.receive(exp_l3_compl) -> value bssap {
7803 f_logp(BSCVTY, "received expected Complete Layer 3 Info at MSC");
7804 log("rx exp_l3_compl = ", bssap);
7805 }
7806 [] BSSAP.receive(tr_BSSMAP_ComplL3) {
7807 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received non-matching COMPLETE LAYER 3 INFORMATION");
7808 }
7809 [] T.timeout {
7810 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for COMPLETE LAYER 3 INFORMATION");
7811 }
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007812 }
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007813
Neels Hofmeyr66e15092020-10-12 18:44:41 +00007814 /* start ciphering, if requested */
7815 if (ispresent(g_pars.encr)) {
7816 f_logp(BSCVTY, "start ciphering");
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007817 f_cipher_mode(g_pars.encr, rsl_pt := rsl_pt, rsl_proc_pt := rsl_proc_pt);
Neels Hofmeyr66e15092020-10-12 18:44:41 +00007818 }
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007819 }
7820
7821 if (do_clear) {
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007822 f_perform_clear(rsl_pt, rsl_proc_pt);
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007823 }
7824 setverdict(pass);
7825 f_sleep(1.0);
7826}
7827
7828private function f_tc_mscpool_compl_l3(charstring id) runs on MSC_ConnHdlr {
7829 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
7830 if (g_pars.mscpool.rsl_idx == 0) {
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007831 f_perform_compl_l3(RSL, RSL_PROC, g_pars.mscpool.l3_info);
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007832 } else if (g_pars.mscpool.rsl_idx == 1) {
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007833 f_perform_compl_l3(RSL1, RSL1_PROC, g_pars.mscpool.l3_info);
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007834 } else if (g_pars.mscpool.rsl_idx == 2) {
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007835 f_perform_compl_l3(RSL2, RSL2_PROC, g_pars.mscpool.l3_info);
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007836 }
7837}
7838
7839/* Various Complete Layer 3 by IMSI all end up with the first MSC, because the other MSCs are not connected. */
7840private function f_tc_mscpool_L3Compl_on_1_msc(charstring id) runs on MSC_ConnHdlr {
7841 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007842 f_perform_compl_l3(RSL, RSL_PROC, ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000001'H)), '00F110'O) );
7843 f_perform_compl_l3(RSL, RSL_PROC, ts_CM_SERV_REQ(CM_TYPE_MO_SMS, valueof(ts_MI_IMSI_LV('001010000000002'H))) );
7844 f_perform_compl_l3(RSL, RSL_PROC, ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010000000003'H))) );
7845 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 +02007846}
7847testcase TC_mscpool_L3Compl_on_1_msc() runs on test_CT {
7848
7849 f_init(1, true);
7850 f_sleep(1.0);
7851 var MSC_ConnHdlr vc_conn;
7852 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007853
7854 f_ctrs_msc_init();
7855
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007856 vc_conn := f_start_handler(refers(f_tc_mscpool_L3Compl_on_1_msc), pars);
7857 vc_conn.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007858
7859 f_ctrs_msc_expect(0, "mscpool:subscr:new", 4);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007860 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007861}
7862
7863/* Three Layer 3 Complete by IMSI are round-robin'ed across two connected MSCs */
7864/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
7865 * just as well using only RSL. */
7866testcase TC_mscpool_L3Complete_by_imsi_round_robin() runs on test_CT {
7867
7868 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
7869 f_sleep(1.0);
7870
7871 /* Control which MSC gets chosen next by the round-robin, otherwise
7872 * would be randomly affected by which other tests ran before this. */
7873 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
7874
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007875 f_ctrs_msc_init();
7876
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007877 var MSC_ConnHdlr vc_conn1;
7878 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
7879 pars1.mscpool.rsl_idx := 0;
7880 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000001'H)), '00F110'O));
7881 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
7882 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007883 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007884
7885 var MSC_ConnHdlr vc_conn2;
7886 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
7887 pars2.mscpool.rsl_idx := 1;
7888 pars2.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000002'H))));
7889 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
7890 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007891 f_ctrs_msc_expect(1, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007892
7893 /* Test round-robin wrap to the first MSC */
7894 var MSC_ConnHdlr vc_conn3;
7895 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
7896 pars3.mscpool.rsl_idx := 2;
7897 pars3.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010000000003'H))));
7898 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
7899 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007900 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007901 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007902}
7903
7904/* Three LU by TMSI are round-robin'ed across two connected MSCs, because they contain the NULL-NRI 0
7905 * (configured in osmo-bsc.cfg). */
7906/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
7907 * just as well using only RSL. */
7908testcase TC_mscpool_LU_by_tmsi_null_nri_0_round_robin() runs on test_CT {
7909
7910 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
7911 f_sleep(1.0);
7912
7913 /* Control which MSC gets chosen next by the round-robin, otherwise
7914 * would be randomly affected by which other tests ran before this. */
7915 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
7916
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007917 f_ctrs_msc_init();
7918
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007919 var MSC_ConnHdlr vc_conn1;
7920 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
7921 pars1.mscpool.rsl_idx := 0;
7922 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(0)), '00F110'O));
7923 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
7924 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007925 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007926
7927 var MSC_ConnHdlr vc_conn2;
7928 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
7929 pars2.mscpool.rsl_idx := 1;
7930 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(0)), '00F110'O));
7931 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
7932 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007933 f_ctrs_msc_expect(1, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007934
7935 /* Test round-robin wrap to the first MSC */
7936 var MSC_ConnHdlr vc_conn3;
7937 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
7938 pars3.mscpool.rsl_idx := 2;
7939 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(0)), '00F110'O));
7940 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
7941 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007942 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007943 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007944}
7945
7946/* Three LU by TMSI are round-robin'ed across two connected MSCs, because they contain the NULL-NRI 1
7947 * (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
7948 * NULL-NRI setting is stronger than that. */
7949/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
7950 * just as well using only RSL. */
7951testcase TC_mscpool_LU_by_tmsi_null_nri_1_round_robin() runs on test_CT {
7952
7953 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
7954 f_sleep(1.0);
7955
7956 /* Control which MSC gets chosen next by the round-robin, otherwise
7957 * would be randomly affected by which other tests ran before this. */
7958 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
7959
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007960 f_ctrs_msc_init();
7961
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007962 var MSC_ConnHdlr vc_conn1;
7963 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
7964 pars1.mscpool.rsl_idx := 0;
7965 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(1)), '00F110'O));
7966 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
7967 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007968 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007969
7970 var MSC_ConnHdlr vc_conn2;
7971 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
7972 pars2.mscpool.rsl_idx := 1;
7973 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(1)), '00F110'O));
7974 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
7975 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007976 f_ctrs_msc_expect(1, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007977
7978 /* Test round-robin wrap to the first MSC */
7979 var MSC_ConnHdlr vc_conn3;
7980 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
7981 pars3.mscpool.rsl_idx := 2;
7982 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(1)), '00F110'O));
7983 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
7984 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007985 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007986 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007987}
7988
7989/* Three Layer 3 Complete by TMSI are round-robin'ed across two connected MSCs, because they contain an NRI not
7990 * assigned to any MSC (configured in osmo-bsc.cfg). */
7991/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
7992 * just as well using only RSL. */
7993testcase TC_mscpool_L3Complete_by_tmsi_unassigned_nri_round_robin() runs on test_CT {
7994
7995 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
7996 f_sleep(1.0);
7997
7998 /* Control which MSC gets chosen next by the round-robin, otherwise
7999 * would be randomly affected by which other tests ran before this. */
8000 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
8001
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008002 f_ctrs_msc_init();
8003
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008004 var MSC_ConnHdlr vc_conn1;
8005 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
8006 pars1.mscpool.rsl_idx := 0;
8007 /* An NRI that is not assigned to any MSC */
8008 pars1.mscpool.l3_info := valueof(ts_ML3_MO_MM_IMSI_DET_Ind(valueof(ts_MI_TMSI_NRI_LV(1023))));
8009 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
8010 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008011 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008012
8013 var MSC_ConnHdlr vc_conn2;
8014 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
8015 pars2.mscpool.rsl_idx := 1;
8016 /* An NRI that is not assigned to any MSC */
8017 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(768)), '00F110'O));
8018 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
8019 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008020 f_ctrs_msc_expect(1, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008021
8022 /* Test round-robin wrap to the first MSC */
8023 var MSC_ConnHdlr vc_conn3;
8024 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
8025 pars3.mscpool.rsl_idx := 2;
8026 /* An NRI that is not assigned to any MSC */
8027 pars3.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_SS_ACT, valueof(ts_MI_TMSI_NRI_LV(819))));
8028 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
8029 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008030 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02008031 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008032}
8033
8034/* Three Layer 3 Complete by TMSI are round-robin'ed across two connected MSCs, because they contain an NRI
8035 * assigned to an MSC that is currently not connected (configured in osmo-bsc.cfg). */
8036/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
8037 * just as well using only RSL. */
8038testcase TC_mscpool_L3Complete_by_tmsi_valid_nri_msc_not_connected_round_robin() runs on test_CT {
8039
8040 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
8041 f_sleep(1.0);
8042
8043 /* Control which MSC gets chosen next by the round-robin, otherwise
8044 * would be randomly affected by which other tests ran before this. */
8045 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
8046
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008047 f_ctrs_msc_init();
8048
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008049 var MSC_ConnHdlr vc_conn1;
8050 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
8051 pars1.mscpool.rsl_idx := 0;
8052 /* An NRI that is assigned to an unconnected MSC */
8053 pars1.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(512))));
8054 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
8055 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008056 f_ctrs_msc_add(2, "mscpool:subscr:attach_lost");
8057 f_ctrs_msc_add(0, "mscpool:subscr:new");
8058 f_ctrs_msc_verify();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008059
8060 var MSC_ConnHdlr vc_conn2;
8061 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
8062 pars2.mscpool.rsl_idx := 1;
8063 /* An NRI that is assigned to an unconnected MSC */
8064 pars2.mscpool.l3_info := valueof(ts_ML3_MO_MM_IMSI_DET_Ind(valueof(ts_MI_TMSI_NRI_LV(767))));
8065 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
8066 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008067 f_ctrs_msc_add(2, "mscpool:subscr:attach_lost");
8068 f_ctrs_msc_add(1, "mscpool:subscr:new");
8069 f_ctrs_msc_verify();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008070
8071 /* Test round-robin wrap to the first MSC */
8072 var MSC_ConnHdlr vc_conn3;
8073 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
8074 pars3.mscpool.rsl_idx := 2;
8075 /* An NRI that is assigned to an unconnected MSC */
8076 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(750)), '00F110'O));
8077 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
8078 vc_conn3.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();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02008082 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008083}
8084
8085/* Three Layer 3 Complete by TMSI with valid NRI for the second MSC are all directed to the second MSC (configured in
8086 * osmo-bsc.cfg). */
8087/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
8088 * just as well using only RSL. */
8089testcase TC_mscpool_L3Complete_by_tmsi_valid_nri_1() runs on test_CT {
8090
8091 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
8092 f_sleep(1.0);
8093
8094 /* All TMSIs in this test point at the second MSC, set the round robin to point at the first MSC to make sure
8095 * this is not using round-robin. */
8096 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
8097
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008098 f_ctrs_msc_init();
8099
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008100 var MSC_ConnHdlr vc_conn1;
8101 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 1);
8102 pars1.mscpool.rsl_idx := 0;
8103 /* An NRI of the second MSC's range (256-511) */
8104 pars1.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_SMS, valueof(ts_MI_TMSI_NRI_LV(256))));
8105 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
8106 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008107 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008108
8109 var MSC_ConnHdlr vc_conn2;
8110 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
8111 pars2.mscpool.rsl_idx := 1;
8112 /* An NRI of the second MSC's range (256-511) */
8113 pars2.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(260))));
8114 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
8115 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008116 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008117
8118 var MSC_ConnHdlr vc_conn3;
8119 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 1);
8120 pars3.mscpool.rsl_idx := 2;
8121 /* An NRI of the second MSC's range (256-511) */
8122 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(511)), '00F110'O));
8123 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
8124 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008125 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02008126 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008127}
8128
8129/* Layer 3 Complete by TMSI with valid NRI for the third MSC are directed to the third MSC (configured in osmo-bsc.cfg),
8130 * while a round-robin remains unaffected by that. */
8131/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
8132 * just as well using only RSL. */
8133testcase TC_mscpool_L3Complete_by_tmsi_valid_nri_2() runs on test_CT {
8134
8135 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
8136 f_sleep(1.0);
8137
8138 /* All TMSIs in this test point at the third MSC, set the round robin to point at the second MSC to make sure
8139 * this is not using round-robin. */
8140 f_vty_transceive(BSCVTY, "mscpool roundrobin next 1");
8141
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008142 f_ctrs_msc_init();
8143
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008144 var MSC_ConnHdlr vc_conn1;
8145 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 2);
8146 pars1.mscpool.rsl_idx := 0;
8147 /* An NRI of the third MSC's range (512-767) */
8148 pars1.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_SMS, valueof(ts_MI_TMSI_NRI_LV(512))));
8149 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
8150 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008151 f_ctrs_msc_expect(2, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008152
8153 var MSC_ConnHdlr vc_conn2;
8154 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 2);
8155 pars2.mscpool.rsl_idx := 1;
8156 /* An NRI of the third MSC's range (512-767) */
8157 pars2.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(678))));
8158 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
8159 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008160 f_ctrs_msc_expect(2, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008161
8162 /* The above forwardings to third MSC have not affected the round robin, which still points at the second MSC */
8163 var MSC_ConnHdlr vc_conn3;
8164 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 1);
8165 pars3.mscpool.rsl_idx := 2;
8166 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000013'H)), '00F110'O));
8167 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
8168 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008169 f_ctrs_msc_expect(1, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02008170 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008171}
8172
8173/* LU with a TMSI but indicating a different PLMN in its previous LAI: ignore the NRI. */
8174/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
8175 * just as well using only RSL. */
8176testcase TC_mscpool_LU_by_tmsi_from_other_PLMN() runs on test_CT {
8177
8178 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
8179 f_sleep(1.0);
8180
8181 /* The TMSIs in this test points at the second MSC, but since it is from a different PLMN, round-robin is used
8182 * instead, and hits msc 0. */
8183 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
8184
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008185 f_ctrs_msc_init();
8186
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008187 /* An NRI of the second MSC's range (256-511), but a PLMN that doesn't match with osmo-bsc.cfg */
8188 var MSC_ConnHdlr vc_conn1;
8189 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
8190 pars1.mscpool.rsl_idx := 0;
8191 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(260)), '99F999'O));
8192 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
8193 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008194 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008195
8196 /* An NRI of the third MSC's range (512-767) and a matching PLMN gets directed by NRI. */
8197 var MSC_ConnHdlr vc_conn2;
8198 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 2);
8199 pars2.mscpool.rsl_idx := 1;
8200 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(555)), '00F110'O));
8201 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
8202 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008203 f_ctrs_msc_expect(2, "mscpool:subscr:known");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02008204 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008205}
8206
8207/* Make sure that whichever MSC paged a subscriber will also get the Paging Response. Page by IMSI, which would be
8208 * round-robined to another MSC, to make sure the Paging->Response relation is stronger than the NRI->MSC mapping. */
8209private function f_tc_mscpool_paging_imsi(charstring id) runs on MSC_ConnHdlr {
8210 var template BSSMAP_FIELD_CellIdentificationList cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(0) } };
8211 //cid_list := { cIl_allInBSS := ''O };
8212 var RSL_ChanNeeded rsl_chneed := RSL_CHANNEED_SDCCH;
8213 var template BSSMAP_IE_ChannelNeeded bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
8214 var BSSAP_N_UNITDATA_req paging;
8215 var hexstring imsi := '001010000000123'H;
8216
8217 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
8218
Neels Hofmeyr90f80962020-06-12 16:16:55 +02008219 paging := valueof(ts_BSSAP_UNITDATA_req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008220 valueof(ts_BSSMAP_Paging(imsi, cid_list, omit, bssmap_chneed))));
8221 BSSAP.send(paging);
8222
8223 /* Register any RSL conn so that the Paging Command gets received here. With the current RSL_Emulation's main()
8224 * handling of '[bts_role] IPA_PT.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD()))' it doesn't matter at all which
8225 * channel number is picked here. */
8226 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(0, RSL_CHAN_NR_INVALID));
8227 f_rslem_register(0, new_chan_nr);
8228 RSL.receive(tr_RSL_PAGING_CMD(tr_MI_IMSI(imsi)));
8229 f_rslem_unregister(0, new_chan_nr);
8230
8231 /* Despite the round robin pointing at the second MSC ('roundrobin next 1'), the earlier Paging for the same IMSI
8232 * causes this Paging Response to go to the first MSC (bssap_idx := 0). */
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02008233 f_perform_compl_l3(RSL, RSL_PROC, ts_PAG_RESP(valueof(ts_MI_IMSI_LV(imsi))) );
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008234 f_sleep(1.0);
8235}
8236testcase TC_mscpool_paging_and_response_imsi() runs on test_CT {
8237 f_init(nr_bts := 1, handler_mode := true, nr_msc := 3);
8238 f_sleep(1.0);
8239
8240 /* Testing a Paging on the first MSC to get a Paging Response back to the first MSC. Set round robin to the
8241 * second MSC to make sure we're getting the Paging logic, not a coincidental round robin match. */
8242 f_vty_transceive(BSCVTY, "mscpool roundrobin next 1");
8243
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008244 f_ctrs_msc_init();
8245
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008246 var MSC_ConnHdlr vc_conn1;
8247 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
8248 pars1.mscpool.rsl_idx := 0;
Neels Hofmeyr90f80962020-06-12 16:16:55 +02008249 pars1.sccp_addr_bsc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_peer;
8250 pars1.sccp_addr_msc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_own;
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008251 vc_conn1 := f_start_handler(refers(f_tc_mscpool_paging_imsi), pars1);
8252 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008253 f_ctrs_msc_expect(0, "mscpool:subscr:paged");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02008254 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008255}
8256
8257/* Make sure that whichever MSC paged a subscriber will also get the Paging Response. Page by TMSI with an NRI value
8258 * that matches a different MSC, to make sure the Paging->Response relation is stronger than the NRI->MSC mapping. */
8259private function f_tc_mscpool_paging_tmsi(charstring id) runs on MSC_ConnHdlr {
8260 var template BSSMAP_FIELD_CellIdentificationList cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(0) } };
8261 //cid_list := { cIl_allInBSS := ''O };
8262 var RSL_ChanNeeded rsl_chneed := RSL_CHANNEED_SDCCH;
8263 var template BSSMAP_IE_ChannelNeeded bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
8264 var integer nri_v := 300; /* <-- second MSC's NRI */
Harald Weltebf397612021-01-14 20:39:46 +01008265 var octetstring tmsi := f_gen_tmsi(suffix := 0, nri_v := nri_v);
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008266 var BSSAP_N_UNITDATA_req paging;
8267
8268 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
8269
Neels Hofmeyr90f80962020-06-12 16:16:55 +02008270 paging := valueof(ts_BSSAP_UNITDATA_req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008271 valueof(ts_BSSMAP_Paging('001010000000011'H, cid_list, tmsi, bssmap_chneed))));
8272 BSSAP.send(paging);
8273
8274 /* Register any RSL conn so that the Paging Command gets received here. With the current RSL_Emulation's main()
8275 * handling of '[bts_role] IPA_PT.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD()))' it doesn't matter at all which
8276 * channel number is picked here. */
8277 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(0, RSL_CHAN_NR_INVALID));
8278 f_rslem_register(0, new_chan_nr);
8279 RSL.receive(tr_RSL_PAGING_CMD(t_MI_TMSI(tmsi)));
8280 f_rslem_unregister(0, new_chan_nr);
8281
8282 /* Despite the NRI matching the second MSC (NRI from 'msc 1' in osmo-bsc.cfg) and round robin pointing at the
8283 * third MSC ('roundrobin next 2'), the earlier Paging for the same TMSI causes this Paging Response to go to
8284 * the first MSC (bssap_idx := 0). */
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02008285 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 +02008286 f_sleep(1.0);
8287}
8288testcase TC_mscpool_paging_and_response_tmsi() runs on test_CT {
8289 f_init(nr_bts := 1, handler_mode := true, nr_msc := 3);
8290 f_sleep(1.0);
8291
8292 /* Testing a Paging on the first MSC to get a Paging Response back to the first MSC. Set round robin to the
8293 * third MSC to make sure we're getting the Paging logic, not a coincidental round robin match. */
8294 f_vty_transceive(BSCVTY, "mscpool roundrobin next 2");
8295
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008296 f_ctrs_msc_init();
8297
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008298 var MSC_ConnHdlr vc_conn1;
8299 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
8300 pars1.mscpool.rsl_idx := 0;
Neels Hofmeyr90f80962020-06-12 16:16:55 +02008301 pars1.sccp_addr_bsc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_peer;
8302 pars1.sccp_addr_msc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_own;
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008303 vc_conn1 := f_start_handler(refers(f_tc_mscpool_paging_tmsi), pars1);
8304 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008305 f_ctrs_msc_expect(0, "mscpool:subscr:paged");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02008306 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008307}
8308
8309/* For round-robin, skip an MSC that has 'no allow-attach' set. */
8310/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
8311 * just as well using only RSL. */
8312testcase TC_mscpool_no_allow_attach_round_robin() runs on test_CT {
8313
8314 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
8315 f_sleep(1.0);
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00008316 /* Mark the second MSC as offloading, round-robin should skip this MSC now. */
8317 f_vty_msc_allow_attach(BSCVTY, {true, false, true});
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008318
8319 /* Control which MSC gets chosen next by the round-robin, otherwise
8320 * would be randomly affected by which other tests ran before this. */
8321 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
8322
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008323 f_ctrs_msc_init();
8324
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008325 var MSC_ConnHdlr vc_conn1;
8326 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
8327 pars1.mscpool.rsl_idx := 0;
8328 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000001'H)), '00F110'O));
8329 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
8330 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008331 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008332
8333 var MSC_ConnHdlr vc_conn2;
8334 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 2);
8335 pars2.mscpool.rsl_idx := 1;
8336 pars2.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000002'H))));
8337 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
8338 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008339 f_ctrs_msc_expect(2, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008340
8341 var MSC_ConnHdlr vc_conn3;
8342 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
8343 pars3.mscpool.rsl_idx := 2;
8344 pars3.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010000000003'H))));
8345 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
8346 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008347 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02008348 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008349}
8350
8351/* An MSC that has 'no allow-attach' set should still serve subscribers that are already attached according to their
8352 * TMSI NRI. */
8353testcase TC_mscpool_no_allow_attach_valid_nri() runs on test_CT {
8354
8355 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
8356 f_sleep(1.0);
8357
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00008358 /* Mark the second MSC as offloading, round-robin should skip this MSC now. */
8359 f_vty_msc_allow_attach(BSCVTY, {true, false, true});
8360
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008361 /* Control which MSC gets chosen next by the round-robin, otherwise
8362 * would be randomly affected by which other tests ran before this. */
8363 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
8364
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008365 f_ctrs_msc_init();
8366
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008367 /* Round robin points at msc 0, but the valid NRI directs to msc 1, even though msc 1 has 'no allow-attach'. */
8368 var MSC_ConnHdlr vc_conn1;
8369 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 1);
8370 pars1.mscpool.rsl_idx := 0;
8371 /* An NRI of the second MSC's range (256-511) */
8372 pars1.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_TMSI_NRI_LV(260))));
8373 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
8374 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008375 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008376
8377 var MSC_ConnHdlr vc_conn2;
8378 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 0);
8379 pars2.mscpool.rsl_idx := 1;
8380 pars2.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000002'H))));
8381 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
8382 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008383 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008384
8385 var MSC_ConnHdlr vc_conn3;
8386 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 2);
8387 pars3.mscpool.rsl_idx := 2;
8388 pars3.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000003'H))));
8389 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
8390 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008391 f_ctrs_msc_expect(2, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02008392 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008393}
8394
Philipp Maier783681c2020-07-16 16:47:06 +02008395/* Allow/Deny emergency calls globally via VTY */
8396private function f_vty_allow_emerg_msc(boolean allow) runs on test_CT {
8397 f_vty_enter_cfg_msc(BSCVTY, 0);
8398 if (allow) {
8399 f_vty_transceive(BSCVTY, "allow-emergency allow");
8400 } else {
8401 f_vty_transceive(BSCVTY, "allow-emergency deny");
8402 }
8403 f_vty_transceive(BSCVTY, "exit");
8404 f_vty_transceive(BSCVTY, "exit");
8405}
8406
8407/* Allow/Deny emergency calls per BTS via VTY */
8408private function f_vty_allow_emerg_bts(boolean allow, integer bts_nr) runs on test_CT {
8409 f_vty_enter_cfg_bts(BSCVTY, bts_nr);
8410 if (allow) {
8411 f_vty_transceive(BSCVTY, "rach emergency call allowed 1");
8412 } else {
8413 f_vty_transceive(BSCVTY, "rach emergency call allowed 0");
8414 }
8415 f_vty_transceive(BSCVTY, "exit");
8416 f_vty_transceive(BSCVTY, "exit");
Neels Hofmeyrb6ed80c2020-10-12 22:52:39 +00008417 f_vty_transceive(BSCVTY, "exit");
Philipp Maier783681c2020-07-16 16:47:06 +02008418}
8419
Pau Espin Pedrol9ae36d52021-06-15 17:29:43 +02008420/* Allow/Forbid Fast Return after SRVCC on a given BTS via VTY */
8421private function f_vty_allow_srvcc_fast_return(boolean allow, integer bts_nr) runs on test_CT {
8422 f_vty_enter_cfg_bts(BSCVTY, bts_nr);
8423 if (allow) {
8424 f_vty_transceive(BSCVTY, "srvcc fast-return allow");
8425 } else {
8426 f_vty_transceive(BSCVTY, "srvcc fast-return forbid");
8427 }
8428 f_vty_transceive(BSCVTY, "exit");
8429 f_vty_transceive(BSCVTY, "exit");
8430 f_vty_transceive(BSCVTY, "exit");
8431}
8432
Pau Espin Pedrol14475352021-07-22 15:48:16 +02008433/* Allow/Forbid TCH for signalling if SDCCH exhausted on a given BTS via VTY */
8434private function f_vty_allow_tch_for_signalling(boolean allow, integer bts_nr) runs on test_CT {
8435 f_vty_enter_cfg_bts(BSCVTY, bts_nr);
8436 if (allow) {
8437 f_vty_transceive(BSCVTY, "channel allocator allow-tch-for-signalling 1");
8438 } else {
8439 f_vty_transceive(BSCVTY, "channel allocator allow-tch-for-signalling 0");
8440 }
8441 f_vty_transceive(BSCVTY, "exit");
8442 f_vty_transceive(BSCVTY, "exit");
8443 f_vty_transceive(BSCVTY, "exit");
8444}
8445
Philipp Maier783681c2020-07-16 16:47:06 +02008446/* Begin assignmet procedure and send an EMERGENCY SETUP (RR) */
8447private function f_assignment_emerg_setup() runs on MSC_ConnHdlr {
8448 var PDU_ML3_MS_NW emerg_setup;
8449 var octetstring emerg_setup_enc;
8450 var RSL_Message emerg_setup_data_ind;
8451
8452 f_establish_fully(omit, omit);
8453
8454 emerg_setup := valueof(ts_ML3_MO_CC_EMERG_SETUP(1, valueof(ts_Bcap_voice)));
8455 emerg_setup_enc := enc_PDU_ML3_MS_NW(emerg_setup);
8456 emerg_setup_data_ind := valueof(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), emerg_setup_enc));
8457
8458 RSL.send(emerg_setup_data_ind);
8459}
8460
8461/* Test if the EMERGENCY SETUP gets passed on to the MSC via A when EMERGENCY
8462 * CALLS are permitted by the BSC config. */
8463private function f_TC_assignment_emerg_setup_allow(charstring id) runs on MSC_ConnHdlr {
8464 var PDU_BSSAP emerg_setup_data_ind_bssap;
8465 var PDU_ML3_MS_NW emerg_setup;
8466 timer T := 3.0;
8467
8468 f_assignment_emerg_setup()
8469
8470 T.start;
8471 alt {
8472 [] BSSAP.receive(tr_BSSAP_DTAP) -> value emerg_setup_data_ind_bssap {
8473 emerg_setup := dec_PDU_ML3_MS_NW(emerg_setup_data_ind_bssap.pdu.dtap);
8474 if (not isbound(emerg_setup.msgs.cc.emergencySetup)) {
8475 setverdict(fail, "no emergency setup");
8476 }
8477 }
8478 [] BSSAP.receive {
8479 setverdict(fail, "unexpected BSSAP message!");
8480 }
8481 [] T.timeout {
8482 setverdict(fail, "timout waiting for EMERGENCY SETUP!");
8483 }
8484 }
8485
8486 setverdict(pass);
8487}
8488
8489/* Test if the EMERGENCY SETUP gets blocked by the BSC if EMERGENCY CALLS are
8490 * forbidden by the BSC config. */
8491private function f_TC_assignment_emerg_setup_deny(charstring id) runs on MSC_ConnHdlr {
8492 var PDU_BSSAP emerg_setup_data_ind_bssap;
8493 timer T := 3.0;
8494
8495 f_assignment_emerg_setup()
8496
8497 T.start;
8498 alt {
8499 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
8500 setverdict(pass);
8501 }
8502 [] RSL.receive {
8503 setverdict(fail, "unexpected RSL message!");
8504 }
8505 [] T.timeout {
8506 setverdict(fail, "timout waiting for RR CHANNEL RELEASE!");
8507 }
8508 }
8509}
8510
8511/* EMERGENCY CALL situation #1, allowed globally and by BTS */
8512testcase TC_assignment_emerg_setup_allow() runs on test_CT {
8513 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8514 var MSC_ConnHdlr vc_conn;
8515
8516 f_init(1, true);
8517 f_sleep(1.0);
8518
8519 f_vty_allow_emerg_msc(true);
8520 f_vty_allow_emerg_bts(true, 0);
8521 vc_conn := f_start_handler(refers(f_TC_assignment_emerg_setup_allow), pars);
8522 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02008523 f_shutdown_helper();
Philipp Maier783681c2020-07-16 16:47:06 +02008524}
8525
8526/* EMERGENCY CALL situation #2, forbidden globally but allowed by BTS */
8527testcase TC_assignment_emerg_setup_deny_msc() runs on test_CT {
8528 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8529 var MSC_ConnHdlr vc_conn;
8530
8531 f_init(1, true);
8532 f_sleep(1.0);
8533
8534 f_vty_allow_emerg_msc(false);
8535 f_vty_allow_emerg_bts(true, 0);
8536 vc_conn := f_start_handler(refers(f_TC_assignment_emerg_setup_deny), pars);
8537 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02008538 f_shutdown_helper();
Philipp Maier783681c2020-07-16 16:47:06 +02008539}
8540
8541/* EMERGENCY CALL situation #3, allowed globally but forbidden by BTS */
8542testcase TC_assignment_emerg_setup_deny_bts() runs on test_CT {
8543 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8544 var MSC_ConnHdlr vc_conn;
8545
8546 /* Note: This simulates a spec violation by the MS, correct MS
8547 * implementations would not try to establish an emergency call because
8548 * the system information tells in advance that emergency calls are
8549 * not forbidden */
8550
8551 f_init(1, true);
8552 f_sleep(1.0);
8553
8554 f_vty_allow_emerg_msc(true);
8555 f_vty_allow_emerg_bts(false, 0);
8556 vc_conn := f_start_handler(refers(f_TC_assignment_emerg_setup_deny), pars);
8557 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02008558 f_shutdown_helper();
Philipp Maier783681c2020-07-16 16:47:06 +02008559}
8560
Philipp Maier82812002020-08-13 18:48:27 +02008561/* Test what happens when an emergency call arrives while all TCH channels are
8562 * busy, the BSC is expected to terminate one call in favor of the incoming
8563 * emergency call */
8564testcase TC_emerg_premption() runs on test_CT {
8565 var ASP_RSL_Unitdata rsl_ud;
8566 var integer i;
8567 var integer chreq_total, chreq_nochan;
8568 var RSL_Message rx_rsl;
8569 var RslChannelNr chan_nr;
8570
8571 f_init(1);
8572 f_sleep(1.0);
8573
8574 f_vty_allow_emerg_msc(true);
8575 f_vty_allow_emerg_bts(true, 0);
8576
8577 /* Fill up all channels on the BTS */
8578 chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total");
8579 chreq_nochan := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel");
8580 for (i := 0; i < NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS; i := i+1) {
8581 chan_nr := f_chreq_act_ack('33'O, i);
8582 }
8583 IPA_RSL[0].clear;
8584 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total",
8585 chreq_total + NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS);
8586
8587 /* Send Channel request for emegergency call */
8588 f_ipa_tx(0, ts_RSL_CHAN_RQD('A5'O, 23));
8589
8590 /* Expect the BSC to release one (the first) TCH/F on the BTS */
8591 chan_nr := valueof(t_RslChanNr_Bm(1));
8592 f_expect_chan_rel(0, chan_nr, expect_rr_chan_rel := false, expect_rll_rel_req := false);
8593
8594 /* Expect the BSC to send activate/assign the a channel for the emergency call */
8595 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
8596 chan_nr := rx_rsl.ies[0].body.chan_nr;
8597 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 33));
8598 rx_rsl := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
Philipp Maier104f4c02020-09-11 18:12:18 +02008599
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02008600 f_shutdown_helper();
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008601}
8602
8603/* Hopping parameters per a timeslot */
Vadim Yanitskiybc6654a2020-09-13 01:27:40 +07008604private type record length(0..64) of GsmArfcn ArfcnList;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008605private type record FHParamsTs {
8606 boolean enabled,
8607 uint6_t hsn,
8608 uint6_t maio,
8609 ArfcnList ma
8610};
8611
8612/* Hopping parameters per a transceiver */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008613private type record FHParamsTrx {
Philipp Maier798d8952021-10-19 14:43:19 +02008614 GsmBandArfcn arfcn,
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008615 FHParamsTs ts[8]
8616};
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008617
8618/* Randomly generate the hopping parameters for the given timeslot numbers */
8619private function f_TC_fh_params_gen(template integer tr_tn := (1, 3, 5))
8620runs on test_CT return FHParamsTrx {
8621 var FHParamsTrx fhp;
8622
Philipp Maier798d8952021-10-19 14:43:19 +02008623 /* Generate a random ARFCN in the range of 0 - 3. This ARFCN will
8624 * fall in the GSM900 band. */
8625 fhp.arfcn.arfcn := f_rnd_int(3);
8626 fhp.arfcn.pcs := false;
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07008627
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008628 for (var integer tn := 0; tn < 8; tn := tn + 1) {
8629 if (not match(tn, tr_tn)) {
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008630 fhp.ts[tn].enabled := false;
8631 fhp.ts[tn].ma := { };
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008632 continue;
8633 }
8634
8635 /* Random HSN / MAIO values: 0..63 */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008636 fhp.ts[tn].hsn := f_rnd_int(64);
8637 fhp.ts[tn].maio := f_rnd_int(64);
8638 fhp.ts[tn].ma := { };
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008639
8640 /* Random Mobile Allocation (hopping channels) */
8641 var integer ma_len := 2 + f_rnd_int(9); /* 2..10 channels */
8642 var integer step := 3 + f_rnd_int(4); /* 3..6 stepping */
8643 for (var integer i := 1; i <= ma_len; i := i + 1) {
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008644 fhp.ts[tn].ma := fhp.ts[tn].ma & { i * step };
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008645 }
8646
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008647 fhp.ts[tn].enabled := true;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008648 }
8649
8650 log("f_TC_fh_params_gen(): ", fhp);
8651 return fhp;
8652}
8653
8654/* Make sure that the given Channel Description IE matches the hopping configuration */
8655private function f_TC_fh_params_match_chan_desc(in FHParamsTrx fhp, in ChannelDescription cd)
8656{
8657 var template (present) ChannelDescription tr_cd;
8658 var template (present) MaioHsn tr_maio_hsn;
8659 var uint3_t tn := cd.chan_nr.tn;
8660
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008661 if (fhp.ts[tn].enabled) {
8662 tr_maio_hsn := tr_HsnMaio(fhp.ts[tn].hsn, fhp.ts[tn].maio);
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008663 tr_cd := tr_ChanDescH1(cd.chan_nr, tr_maio_hsn);
8664 } else {
Philipp Maier798d8952021-10-19 14:43:19 +02008665 tr_cd := tr_ChanDescH0(cd.chan_nr, fhp.arfcn.arfcn);
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008666 }
8667
8668 if (not match(cd, tr_cd)) {
8669 setverdict(fail, "Channel Description IE does not match: ",
8670 cd, " vs expected ", tr_cd);
8671 }
8672}
8673
8674/* Make sure that the given Mobile Allocation IE matches the hopping configuration */
8675private function f_TC_fh_params_match_ma(in FHParamsTrx fhp, uint3_t tn,
8676 in MobileAllocationLV ma)
8677{
8678 var template MobileAllocationLV tr_ma := f_TC_fh_params_gen_tr_ma(fhp, tn, ma);
8679
8680 if (not match(ma, tr_ma)) {
8681 setverdict(fail, "Mobile Allocation IE does not match (tn := ",
8682 tn, "): ", ma, " vs expected: ", tr_ma);
8683 } else {
8684 setverdict(pass);
8685 }
8686}
8687
8688private function f_TC_fh_params_gen_tr_ma(in FHParamsTrx fhp, uint3_t tn,
8689 in MobileAllocationLV ma)
8690return template MobileAllocationLV {
8691 /* Mobile Allocation IE is expected to be empty if hopping is not enabled */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008692 if (not fhp.ts[tn].enabled) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008693 return { len := 0, ma := ''B };
8694 }
8695
8696 var bitstring full_mask := f_pad_bit(''B, 1024, '0'B);
8697 var bitstring slot_mask := f_pad_bit(''B, 1024, '0'B);
8698 var bitstring ma_mask := ''B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008699
8700 /* Compose the full bit-mask (all channels, up to 1024 entries) */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008701 for (var integer i := 0; i < lengthof(fhp.ts); i := i + 1) {
8702 for (var integer j := 0; j < lengthof(fhp.ts[i].ma); j := j + 1) {
8703 if (full_mask[fhp.ts[i].ma[j]] == '1'B)
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008704 { continue; }
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008705 full_mask[fhp.ts[i].ma[j]] := '1'B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008706 }
8707 }
8708
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07008709 /* Take ARFCN of the TRX itself into account */
Philipp Maier798d8952021-10-19 14:43:19 +02008710 full_mask[fhp.arfcn.arfcn] := '1'B;
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07008711
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008712 /* Compose a bit-mask for the given timeslot number */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008713 for (var integer i := 0; i < lengthof(fhp.ts[tn].ma); i := i + 1) {
8714 slot_mask[fhp.ts[tn].ma[i]] := '1'B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008715 }
8716
8717 /* Finally, compose the Mobile Allocation bit-mask */
Vadim Yanitskiy3e997362020-09-05 21:08:34 +07008718 for (var integer i := 1; i < lengthof(full_mask); i := i + 1) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008719 if (full_mask[i] != '1'B)
8720 { continue; }
8721
8722 /* FIXME: ma_mask := ma_mask & slot_mask[i]; // triggers a bug in TITAN */
8723 if (slot_mask[i] == '1'B) {
8724 ma_mask := ma_mask & '1'B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008725 } else {
8726 ma_mask := ma_mask & '0'B;
8727 }
8728 }
8729
Vadim Yanitskiy3e997362020-09-05 21:08:34 +07008730 /* ARFCN 0 (if present) goes to the last position of the bit-mask */
8731 if (full_mask[0] == '1'B) {
8732 /* FIXME: ma_mask := ma_mask & slot_mask[0]; // triggers a bug in TITAN */
8733 if (slot_mask[0] == '1'B) {
8734 ma_mask := ma_mask & '1'B;
8735 } else {
8736 ma_mask := ma_mask & '0'B;
8737 }
8738 }
8739
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008740 /* Ensure that ma_mask is octet-aligned */
Vadim Yanitskiy2aa02522020-09-06 14:05:23 +07008741 var integer ma_mask_len := (lengthof(ma_mask) + 8 - 1) / 8;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008742 ma_mask := f_pad_bit(ma_mask, ma_mask_len * 8, '0'B);
8743
8744 return { len := ma_mask_len, ma := ma_mask };
8745}
8746
Philipp Maier798d8952021-10-19 14:43:19 +02008747/* Configure the appropriate band for a given arfcn, exc */
8748private function f_TC_set_band_by_arfcn(integer bts_nr, GsmBandArfcn arfcn) runs on test_CT
8749{
8750 var charstring band;
8751 var GsmBandArfcn arfcn_ := valueof(ts_GsmBandArfcn(arfcn.arfcn, arfcn.pcs, false));
8752
8753 select (arfcn_) {
8754 case (tr_GsmBandArfcn((259..293), false, ?)) { band := "GSM450"; }
8755 case (tr_GsmBandArfcn((306..340), false, ?)) { band := "GSM480"; }
8756 case (tr_GsmBandArfcn((438..511), false, ?)) { band := "GSM750"; }
8757 case (tr_GsmBandArfcn((128..251), false, ?)) { band := "GSM850"; }
8758 case (tr_GsmBandArfcn((0..124), false, ?)) { band := "GSM900"; }
8759 case (tr_GsmBandArfcn((955..1023), false, ?)) { band := "GSM900"; }
8760 case (tr_GsmBandArfcn((512..885), false, ?)) { band := "DCS1800"; }
8761 case (tr_GsmBandArfcn((512..810), true, ?)) { band := "PCS1900"; }
8762 case else { return; }
8763 }
8764
8765 f_vty_enter_cfg_bts(BSCVTY, bts_nr);
8766 f_vty_transceive(BSCVTY, "band " & band);
8767 f_vty_transceive(BSCVTY, "end");
8768}
8769
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008770/* Configure the hopping parameters in accordance with the given record */
8771private function f_TC_fh_params_set(in FHParamsTrx fhp,
8772 uint8_t bts_nr := 0,
8773 uint8_t trx_nr := 0)
8774runs on test_CT {
Philipp Maier798d8952021-10-19 14:43:19 +02008775
8776 f_TC_set_band_by_arfcn(bts_nr, fhp.arfcn);
8777
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008778 /* Enter the configuration node for the given BTS/TRX numbers */
8779 f_vty_enter_cfg_trx(BSCVTY, bts_nr, trx_nr);
8780
Philipp Maier798d8952021-10-19 14:43:19 +02008781 f_vty_transceive(BSCVTY, "arfcn " & int2str(fhp.arfcn.arfcn));
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07008782
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008783 for (var integer tn := 0; tn < lengthof(fhp.ts); tn := tn + 1) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008784 f_vty_transceive(BSCVTY, "timeslot " & int2str(tn));
8785
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008786 if (not fhp.ts[tn].enabled) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008787 f_vty_transceive(BSCVTY, "hopping enabled 0");
8788 f_vty_transceive(BSCVTY, "exit"); /* go back */
8789 continue;
8790 }
8791
8792 /* Configure HSN / MAIO values */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008793 f_vty_transceive(BSCVTY, "hopping sequence-number " & int2str(fhp.ts[tn].hsn));
8794 f_vty_transceive(BSCVTY, "hopping maio " & int2str(fhp.ts[tn].maio));
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008795
8796 /* Configure the Mobile Allocation (hopping channels) */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008797 for (var integer i := 0; i < lengthof(fhp.ts[tn].ma); i := i + 1) {
8798 f_vty_transceive(BSCVTY, "hopping arfcn add " & int2str(fhp.ts[tn].ma[i]));
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008799 }
8800
8801 f_vty_transceive(BSCVTY, "hopping enabled 1");
8802 f_vty_transceive(BSCVTY, "exit"); /* go back */
8803 }
8804
8805 f_vty_transceive(BSCVTY, "end");
8806}
8807
8808/* Disable frequency hopping on all timeslots */
8809private function f_TC_fh_params_unset(in FHParamsTrx fhp,
8810 uint8_t bts_nr := 0,
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07008811 uint8_t trx_nr := 0,
Philipp Maier798d8952021-10-19 14:43:19 +02008812 GsmBandArfcn arfcn := {pcs := false, arfcn := 871})
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008813runs on test_CT {
Philipp Maier798d8952021-10-19 14:43:19 +02008814
8815 f_TC_set_band_by_arfcn(bts_nr, arfcn);
8816
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008817 /* Enter the configuration node for the given BTS/TRX numbers */
8818 f_vty_enter_cfg_trx(BSCVTY, bts_nr, trx_nr);
8819
Philipp Maier798d8952021-10-19 14:43:19 +02008820 f_vty_transceive(BSCVTY, "arfcn " & int2str(arfcn.arfcn));
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07008821
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008822 for (var integer tn := 0; tn < lengthof(fhp.ts); tn := tn + 1) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008823 f_vty_transceive(BSCVTY, "timeslot " & int2str(tn));
8824
8825 /* Delete all ARFCNs from the Mobile Allocation (if any) */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008826 for (var integer i := 0; i < lengthof(fhp.ts[tn].ma); i := i + 1) {
8827 f_vty_transceive(BSCVTY, "hopping arfcn del " & int2str(fhp.ts[tn].ma[i]));
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008828 }
8829
8830 f_vty_transceive(BSCVTY, "hopping enabled 0");
8831 f_vty_transceive(BSCVTY, "exit"); /* go back */
8832 }
8833
8834 f_vty_transceive(BSCVTY, "end");
8835 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
8836}
8837
8838/* Verify presence and correctness of the hopping parameters (HSN, MAIO)
8839 * in the Channel Identification IE of the RSL CHANnel ACTIVation message. */
8840testcase TC_fh_params_chan_activ() runs on test_CT {
8841 var FHParamsTrx fhp := f_TC_fh_params_gen();
8842 var RSL_Message rsl_msg;
8843 var RSL_IE_Body ie;
8844
8845 f_init_vty();
8846
8847 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
8848 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
8849
8850 f_init(1);
8851
8852 /* CS domain: 3 (SDCCH/4+CBCH) + 4 (TCH/F) + 2 (TCH/H) channels available */
8853 for (var integer i := 0; i < 9; i := i + 1) {
8854 f_ipa_tx(0, ts_RSL_CHAN_RQD(f_rnd_ra_cs(), 23));
8855 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
8856
8857 /* Make sure that Channel Identification IE is present */
8858 if (not f_rsl_find_ie(rsl_msg, RSL_IE_CHAN_IDENT, ie)) {
8859 setverdict(fail, "RSL Channel Identification IE is absent");
8860 continue;
8861 }
8862
8863 /* Make sure that hopping parameters (HSN/MAIO) match */
8864 f_TC_fh_params_match_chan_desc(fhp, ie.chan_ident.ch_desc.v);
8865
8866 /* "Mobile Allocation shall be included but empty" - let's check this */
8867 if (ie.chan_ident.ma.v.len != 0) {
8868 setverdict(fail, "Mobile Allocation IE is not empty: ",
8869 ie.chan_ident.ma, ", despite it shall be");
8870 continue;
8871 }
8872 }
8873
8874 /* Disable frequency hopping */
8875 f_TC_fh_params_unset(fhp);
8876
Vadim Yanitskiy21726312020-09-04 01:45:36 +07008877 f_shutdown_helper();
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008878}
8879
8880/* Verify the hopping parameters (HSN, MAIO, MA) in (RR) Immediate Assignment */
8881testcase TC_fh_params_imm_ass() runs on test_CT {
8882 var FHParamsTrx fhp := f_TC_fh_params_gen();
8883 var RSL_Message rsl_msg;
8884 var RSL_IE_Body ie;
8885
8886 f_init_vty();
8887
8888 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
8889 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
8890
8891 f_init(1);
8892
8893 /* CS domain: 3 (SDCCH/4+CBCH) + 4 (TCH/F) + 2 (TCH/H) channels available */
8894 for (var integer i := 0; i < 9; i := i + 1) {
8895 f_ipa_tx(0, ts_RSL_CHAN_RQD(f_rnd_ra_cs(), 23));
8896 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
8897
8898 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(rsl_msg.ies[0].body.chan_nr, 33));
8899 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeC(RSL_MT_IMMEDIATE_ASSIGN_CMD));
8900
8901 /* Make sure that Full Immediate Assign Info IE is present */
8902 if (not f_rsl_find_ie(rsl_msg, RSL_IE_FULL_IMM_ASS_INFO, ie)) {
8903 setverdict(fail, "RSL Full Immediate Assign Info IE is absent");
8904 continue;
8905 }
8906
8907 /* Decode the actual Immediate Assignment message */
8908 var GsmRrMessage rr_msg := dec_GsmRrMessage(ie.full_imm_ass_info.payload);
8909 if (not match(rr_msg.header, t_RrHeader(IMMEDIATE_ASSIGNMENT, ?))) {
8910 setverdict(fail, "Failed to match Immediate Assignment: ", rr_msg);
8911 continue;
8912 }
8913
8914 /* Make sure that hopping parameters (HSN/MAIO) match */
8915 f_TC_fh_params_match_chan_desc(fhp, rr_msg.payload.imm_ass.chan_desc);
8916
8917 /* Make sure that the Mobile Allocation IE matches */
8918 f_TC_fh_params_match_ma(fhp, rr_msg.payload.imm_ass.chan_desc.chan_nr.tn,
8919 rr_msg.payload.imm_ass.mobile_allocation);
8920 }
8921
8922 /* Disable frequency hopping */
8923 f_TC_fh_params_unset(fhp);
Philipp Maier82812002020-08-13 18:48:27 +02008924
Vadim Yanitskiy21726312020-09-04 01:45:36 +07008925 f_shutdown_helper();
Philipp Maier82812002020-08-13 18:48:27 +02008926}
8927
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07008928/* Verify the hopping parameters (HSN, MAIO, MA) in (RR) Assignment Command */
8929testcase TC_fh_params_assignment_cmd() runs on test_CT {
8930 var FHParamsTrx fhp := f_TC_fh_params_gen();
8931 var RSL_Message rsl_msg;
8932 var RSL_IE_Body ie;
8933
8934 f_init_vty();
8935
8936 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
8937 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
8938
8939 f_init(1);
8940
8941 /* HACK: work around "Couldn't find Expect for CRCX" */
8942 vc_MGCP.stop;
8943
8944 var template PDU_BSSAP ass_cmd := f_gen_ass_req();
8945 ass_cmd.pdu.bssmap.assignmentRequest.codecList := ts_BSSMAP_IE_CodecList({ts_CodecFR});
8946
8947 /* CS domain (TCH): 4 (TCH/F) + 2 (TCH/H) channels available
8948 * NOTE: only 3 SDCCH/4 channels are available on CCCH+SDCCH4+CBCH */
8949 for (var integer i := 0; i < 3; i := i + 1) {
8950 /* Establish a dedicated channel, so we can trigger (late) TCH assignment */
8951 var DchanTuple dt := f_est_dchan(f_rnd_ra_cs(), 23, f_rnd_octstring(16));
8952
8953 /* Send a BSSMAP Assignment Command, expect CHANnel ACTIVation */
8954 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ass_cmd));
8955 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
8956
8957 /* ACKnowledge CHANnel ACTIVation, expect RSL DATA REQuest */
8958 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(rsl_msg.ies[0].body.chan_nr, 33));
8959 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeR(RSL_MT_DATA_REQ));
8960
8961 /* Make sure that L3 Information IE is present */
8962 if (not f_rsl_find_ie(rsl_msg, RSL_IE_L3_INFO, ie)) {
8963 setverdict(fail, "RSL L3 Information IE is absent");
8964 continue;
8965 }
8966
8967 /* Decode the L3 message and make sure it is (RR) Assignment Command */
8968 var GsmRrL3Message l3_msg := dec_GsmRrL3Message(ie.l3_info.payload);
8969 if (not match(l3_msg.header, t_RrL3Header(ASSIGNMENT_COMMAND))) {
8970 setverdict(fail, "Failed to match Assignment Command: ", l3_msg);
8971 continue;
8972 }
8973
8974 /* Make sure that hopping parameters (HSN/MAIO) match */
8975 var ChannelDescription chan_desc := l3_msg.payload.ass_cmd.chan_desc;
8976 f_TC_fh_params_match_chan_desc(fhp, chan_desc);
8977
8978 /* Make sure that Cell Channel Description IE is present if FH is enabled */
8979 if (chan_desc.h and not ispresent(l3_msg.payload.ass_cmd.cell_chan_desc)) {
Vadim Yanitskiy38d069d2020-09-02 17:18:57 +07008980 setverdict(fail, "FH enabled, but Cell Channel Description IE is absent");
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07008981 continue;
8982 }
8983
8984 /* Make sure that the Mobile Allocation IE matches (if present) */
8985 var boolean ma_present := ispresent(l3_msg.payload.ass_cmd.mobile_allocation);
8986 if (chan_desc.h and ma_present) {
8987 f_TC_fh_params_match_ma(fhp, chan_desc.chan_nr.tn,
8988 l3_msg.payload.ass_cmd.mobile_allocation.v);
8989 } else if (chan_desc.h and not ma_present) {
8990 setverdict(fail, "FH enabled, but Mobile Allocation IE is absent");
8991 continue;
8992 } else if (not chan_desc.h and ma_present) {
8993 setverdict(fail, "FH disabled, but Mobile Allocation IE is present");
8994 continue;
8995 }
8996 }
8997
8998 /* Give the IUT some time to release all channels */
8999 f_sleep(3.0);
9000
9001 /* Disable frequency hopping */
9002 f_TC_fh_params_unset(fhp);
9003
Vadim Yanitskiy21726312020-09-04 01:45:36 +07009004 f_shutdown_helper();
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07009005}
9006
Vadim Yanitskiy8f5430d2020-09-02 18:51:38 +07009007/* Verify the hopping parameters (HSN, MAIO, MA) in (RR) Handover Command */
9008private function f_TC_fh_params_handover_cmd(in FHParamsTrx fhp)
9009runs on test_CT {
9010 var RSL_Message rsl_msg;
9011 var RSL_IE_Body ie;
9012 var DchanTuple dt;
9013
9014 /* Establish a dedicated channel, so we can trigger handover */
9015 dt := f_est_dchan(f_rnd_ra_cs(), 23, f_rnd_octstring(16));
Vadim Yanitskiyc18ff472021-11-18 20:15:37 +03009016 f_sleep(0.5);
Vadim Yanitskiy8f5430d2020-09-02 18:51:38 +07009017
9018 /* Trigger handover from BTS0 to BTS1 */
9019 f_bts_0_cfg(BSCVTY, { "neighbor bts 1" });
9020 f_vty_handover(BSCVTY, 0, 0, dt.rsl_chan_nr, 1);
9021
9022 /* Expect RSL CHANnel ACTIVation on BTS1/TRX0/TS1 */
9023 rsl_msg := f_exp_ipa_rx(1, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
9024
9025 /* ACKnowledge channel activation and expect (RR) Handover Command */
9026 f_ipa_tx(1, ts_RSL_CHAN_ACT_ACK(rsl_msg.ies[0].body.chan_nr, 33));
9027 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeR(RSL_MT_DATA_REQ));
9028
9029 /* Make sure that L3 Information IE is present */
9030 if (not f_rsl_find_ie(rsl_msg, RSL_IE_L3_INFO, ie)) {
9031 setverdict(fail, "RSL L3 Information IE is absent");
9032 return;
9033 }
9034
9035 /* Decode the L3 message and make sure it is (RR) Handover Command */
9036 var GsmRrL3Message l3_msg := dec_GsmRrL3Message(ie.l3_info.payload);
9037 if (not match(l3_msg.header, t_RrL3Header(HANDOVER_COMMAND))) {
9038 setverdict(fail, "Failed to match Handover Command: ", l3_msg);
9039 return;
9040 }
9041
9042 /* Make sure that we've got SDCCH/8 on TS1 (expected to be hopping) */
9043 var ChannelDescription chan_desc := l3_msg.payload.ho_cmd.chan_desc;
9044 if (not match(chan_desc.chan_nr, t_RslChanNr_SDCCH8(1, ?))) {
9045 setverdict(fail, "Unexpected channel number: ", chan_desc.chan_nr);
9046 return;
9047 }
9048
9049 /* Make sure that hopping parameters (HSN/MAIO) match */
9050 f_TC_fh_params_match_chan_desc(fhp, chan_desc);
9051
9052 /* Make sure that Cell Channel Description IE is present */
9053 if (not ispresent(l3_msg.payload.ho_cmd.cell_chan_desc)) {
9054 setverdict(fail, "FH enabled, but Cell Channel Description IE is absent");
9055 return;
9056 }
9057
9058 /* Make sure that the Mobile Allocation (after time) IE is present and matches */
9059 var boolean ma_present := ispresent(l3_msg.payload.ho_cmd.mobile_allocation);
9060 if (ma_present) {
9061 f_TC_fh_params_match_ma(fhp, chan_desc.chan_nr.tn,
9062 l3_msg.payload.ho_cmd.mobile_allocation.v);
9063 } else {
9064 setverdict(fail, "FH enabled, but Mobile Allocation IE is absent");
9065 return;
9066 }
9067}
9068testcase TC_fh_params_handover_cmd() runs on test_CT {
9069 var FHParamsTrx fhp := f_TC_fh_params_gen();
9070
9071 f_init_vty();
9072
9073 /* (Re)configure TS0 as BCCH and TS1 as SDCCH8 on BTS1/TRX0 */
9074 f_vty_enter_cfg_trx(BSCVTY, bts := 1, trx := 0);
9075
9076 f_vty_transceive(BSCVTY, "timeslot 0");
9077 f_vty_transceive(BSCVTY, "phys_chan_config ccch");
9078 f_vty_transceive(BSCVTY, "exit"); /* go back */
9079
9080 f_vty_transceive(BSCVTY, "timeslot 1");
9081 f_vty_transceive(BSCVTY, "phys_chan_config sdcch8");
9082 f_vty_transceive(BSCVTY, "end"); /* we're done */
9083
9084 f_TC_fh_params_set(fhp, 1); /* Enable frequency hopping on BTS1 */
9085 f_vty_transceive(BSCVTY, "drop bts connection 1 oml");
9086
9087 f_init(2);
9088
9089 f_TC_fh_params_handover_cmd(fhp);
9090
9091 /* Disable frequency hopping on BTS1 */
9092 f_TC_fh_params_unset(fhp, 1);
9093
9094 /* (Re)configure TS0 as CCCH+SDCCH4+CBCH and TS1 as TCH/F */
9095 f_vty_enter_cfg_trx(BSCVTY, bts := 1, trx := 0);
9096
9097 f_vty_transceive(BSCVTY, "timeslot 0");
9098 f_vty_transceive(BSCVTY, "phys_chan_config ccch+sdcch4+cbch");
9099 f_vty_transceive(BSCVTY, "exit"); /* go back */
9100
9101 f_vty_transceive(BSCVTY, "timeslot 1");
9102 f_vty_transceive(BSCVTY, "phys_chan_config tch/f");
9103 f_vty_transceive(BSCVTY, "end"); /* we're done */
9104
9105 f_shutdown_helper();
9106}
9107
Vadim Yanitskiyca974032020-09-01 07:20:39 +07009108/* Verify the hopping parameters in System Information Type 4 */
9109testcase TC_fh_params_si4_cbch() runs on test_CT {
9110 var FHParamsTrx fhp := f_TC_fh_params_gen(tr_tn := 1);
9111 var ASP_RSL_Unitdata rx_rsl_ud;
9112 timer T := 5.0;
9113
9114 f_init_vty();
9115
9116 /* (Re)configure TS0 as BCCH and TS1 as SDCCH8+CBCH */
9117 f_vty_enter_cfg_trx(BSCVTY, trx := 0);
9118
9119 f_vty_transceive(BSCVTY, "timeslot 0");
9120 f_vty_transceive(BSCVTY, "phys_chan_config ccch");
9121 f_vty_transceive(BSCVTY, "exit"); /* go back */
9122
9123 f_vty_transceive(BSCVTY, "timeslot 1");
9124 f_vty_transceive(BSCVTY, "phys_chan_config sdcch8+cbch");
9125 f_vty_transceive(BSCVTY, "end"); /* we're done */
9126
9127 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
9128 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
9129
9130 f_init(1);
9131
9132 T.start;
9133 alt {
9134 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_BCCH_INFO(RSL_SYSTEM_INFO_4))) -> value rx_rsl_ud {
9135 var RSL_IE_Body ie := rx_rsl_ud.rsl.ies[2].body; /* FULL BCCH Information IE */
9136 var SystemInformation si := dec_SystemInformation(ie.other.payload);
9137
9138 /* Make sure that what we decoded is System Information Type 4 */
9139 if (si.header.message_type != SYSTEM_INFORMATION_TYPE_4) {
9140 setverdict(fail, "RSL FULL BCCH Information IE contains: ", si);
9141 repeat;
9142 }
9143
9144 /* Make sure that CBCH Channel Description IE is present */
9145 if (not ispresent(si.payload.si4.cbch_chan_desc)) {
9146 setverdict(fail, "CBCH Channel Description IE is absent");
9147 break;
9148 }
9149
9150 /* Finally, check the hopping parameters (HSN, MAIO) */
9151 var ChannelDescription chan_desc := si.payload.si4.cbch_chan_desc.v;
9152 f_TC_fh_params_match_chan_desc(fhp, chan_desc);
9153
9154 /* 3GPP TS 44.018, section 9.1.36.2 "CBCH Mobile Allocation":
9155 * The CBCH Mobile Allocation IE *shall* be present if FH is enabled. */
9156 if (chan_desc.h and not ispresent(si.payload.si4.cbch_mobile_alloc)) {
9157 setverdict(fail, "FH enabled, but Mobile Allocation IE is absent");
9158 break;
9159 } else if (chan_desc.h and ispresent(si.payload.si4.cbch_mobile_alloc)) {
9160 f_TC_fh_params_match_ma(fhp, chan_desc.chan_nr.tn,
9161 si.payload.si4.cbch_mobile_alloc.v);
9162 }
9163 }
9164 [] IPA_RSL[0].receive { repeat; }
9165 [] T.timeout {
9166 setverdict(fail, "Timeout waiting for RSL BCCH INFOrmation (SI4)");
9167 }
9168 }
9169
9170 /* Disable frequency hopping */
9171 f_TC_fh_params_unset(fhp);
9172
Vadim Yanitskiy8bc46012020-09-06 12:38:01 +07009173 /* (Re)configure TS0 as CCCH+SDCCH4+CBCH and TS1 as TCH/F */
Vadim Yanitskiyca974032020-09-01 07:20:39 +07009174 f_vty_enter_cfg_trx(BSCVTY, trx := 0);
9175
9176 f_vty_transceive(BSCVTY, "timeslot 0");
Vadim Yanitskiy8bc46012020-09-06 12:38:01 +07009177 f_vty_transceive(BSCVTY, "phys_chan_config ccch+sdcch4+cbch");
Vadim Yanitskiyca974032020-09-01 07:20:39 +07009178 f_vty_transceive(BSCVTY, "exit"); /* go back */
9179
9180 f_vty_transceive(BSCVTY, "timeslot 1");
9181 f_vty_transceive(BSCVTY, "phys_chan_config tch/f");
9182 f_vty_transceive(BSCVTY, "end"); /* we're done */
9183
Vadim Yanitskiy21726312020-09-04 01:45:36 +07009184 f_shutdown_helper();
Vadim Yanitskiyca974032020-09-01 07:20:39 +07009185}
9186
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02009187template (value) PDU_BSSAP_LE ts_BSSMAP_LE_BSSLAP(template (value) BSSLAP_PDU bsslap)
9188 := ts_BSSMAP_LE_ConnInfo(BSSMAP_LE_PROT_BSSLAP, data := enc_BSSLAP_PDU(valueof(bsslap)));
9189
9190private function f_match_bsslap(PDU_BSSAP_LE got_bsslap_msg,
9191 template (present) BSSLAP_PDU expect_bsslap)
9192{
9193 var BSSLAP_PDU bsslap := dec_BSSLAP_PDU(got_bsslap_msg.pdu.bssmap.co_info.bsslap_apdu.data);
9194 if (not match(bsslap, expect_bsslap)) {
9195 log("EXPECTING BSSLAP: ", expect_bsslap);
9196 log("GOT BSSLAP: ", bsslap);
9197 setverdict(fail, "BSSLAP is not as expected");
9198 mtc.stop;
9199 }
9200 setverdict(pass);
9201}
9202
9203/* GAD: this is an Ellipsoid point with uncertainty circle, encoded as in 3GPP TS 23.032 §7.3.2. */
9204const octetstring gad_ell_point_unc_circle := '10b0646d0d5f6627'O;
9205
9206private function f_expect_bsslap(template (present) BSSLAP_PDU expect_rx_bsslap) runs on MSC_ConnHdlr {
9207 var PDU_BSSAP_LE rx_bsslap;
9208 BSSAP_LE.receive(tr_BSSMAP_LE_ConnInfo(BSSMAP_LE_PROT_BSSLAP, ?)) -> value(rx_bsslap);
9209 f_match_bsslap(rx_bsslap, expect_rx_bsslap);
9210}
9211
9212/* With an active lchan, start BSSMAP Perform Location Request on A interface, starting BSSMAP-LE Perform Location
9213 * Request on Lb interface. Either with or without the SMLC doing a BSSLAP TA Request. */
9214private function f_lcs_loc_req_for_active_ms(boolean do_ta_request := false) runs on MSC_ConnHdlr {
9215 f_sleep(1.0);
9216
9217 f_establish_fully(omit, omit);
9218 f_bssap_le_register_imsi(g_pars.imsi, omit);
9219
9220 BSSAP.send(valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
9221 ts_CellId_CGI('262'H, '42'H, 23, 42))));
9222
9223 var PDU_BSSAP_LE plr;
9224 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
9225
9226 if (not do_ta_request) {
9227 /* verify TA Layer 3 in APDU. First the APDU type (BSSLAP), then the BSSLAP data contents. */
9228 var template BSSMAP_LE_IE_APDU expect_apdu := tr_BSSMAP_LE_APDU(BSSMAP_LE_PROT_BSSLAP, ?);
9229 if (not match(plr.pdu.bssmap.perf_loc_req.bsslap_apdu, expect_apdu)) {
9230 log("EXPECTING BSSMAP-LE APDU IE ", expect_apdu);
9231 log("GOT BSSMAP-LE APDU IE ", plr.pdu.bssmap.perf_loc_req.bsslap_apdu);
9232 setverdict(fail, "BSSMAP-LE APDU IE is not as expected");
9233 mtc.stop;
9234 }
9235 var template BSSLAP_PDU expect_ta_layer3 := tr_BSSLAP_TA_Layer3(tr_BSSLAP_IE_TA(0));
9236 var BSSLAP_PDU bsslap := dec_BSSLAP_PDU(plr.pdu.bssmap.perf_loc_req.bsslap_apdu.data);
9237 if (not match(bsslap, expect_ta_layer3)) {
9238 log("EXPECTING BSSLAP TA Layer 3: ", expect_ta_layer3);
9239 log("GOT BSSLAP: ", bsslap);
9240 setverdict(fail, "BSSLAP is not as expected");
9241 mtc.stop;
9242 }
9243 /* OsmoBSC directly sent the TA as BSSLAP APDU in the BSSMAP-LE Perform Location Request to the SMLC. The SMLC
9244 * has no need to request the TA from the BSC and directly responds. */
9245 } else {
9246 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
9247 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
9248 f_expect_bsslap(tr_BSSLAP_TA_Resp(?, ?));
9249 }
9250
9251 /* SMLC got the TA from the BSC, now responds with geo information data. */
9252 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(gad_ell_point_unc_circle, omit));
9253 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
9254 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(tr_BSSMAP_IE_LocationEstimate(gad_ell_point_unc_circle)));
9255
9256 /* The LCS was using an active A-interface conn. It should still remain active after this. */
9257 f_mo_l3_transceive();
9258
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02009259 f_perform_clear();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02009260
9261 f_sleep(2.0);
9262 setverdict(pass);
9263}
9264
9265/* With an active lchan, start BSSMAP Perform Location Request on A interface, starting BSSMAP-LE Perform Location
9266 * Request on Lb interface. Without the SMLC doing a BSSLAP TA Request. */
9267private function f_tc_lcs_loc_req_for_active_ms(charstring id) runs on MSC_ConnHdlr {
9268 f_lcs_loc_req_for_active_ms(false);
9269}
9270testcase TC_lcs_loc_req_for_active_ms() runs on test_CT {
9271 var MSC_ConnHdlr vc_conn;
9272 var TestHdlrParams pars := f_gen_test_hdlr_pars();
9273
9274 f_init(1, true);
9275 f_sleep(1.0);
9276 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_active_ms), pars);
9277 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01009278 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02009279}
9280
9281/* With an active lchan, start BSSMAP Perform Location Request on A interface, starting BSSMAP-LE Perform Location
9282 * Request on Lb interface. With the SMLC doing a BSSLAP TA Request. */
9283private function f_tc_lcs_loc_req_for_active_ms_ta_req(charstring id) runs on MSC_ConnHdlr {
9284 f_lcs_loc_req_for_active_ms(true);
9285}
9286testcase TC_lcs_loc_req_for_active_ms_ta_req() runs on test_CT {
9287 var MSC_ConnHdlr vc_conn;
9288 var TestHdlrParams pars := f_gen_test_hdlr_pars();
9289
9290 f_init(1, true);
9291 f_sleep(1.0);
9292 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_active_ms_ta_req), pars);
9293 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01009294 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02009295}
9296
9297/* Clear the A-interface conn only, without doing anything on Abis. Useful for LCS, for cases where there is only an A
9298 * conn without an active lchan. */
9299private function f_clear_A_conn() runs on MSC_ConnHdlr
9300{
9301 var BssmapCause cause := 0;
9302 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
9303 BSSAP.receive(tr_BSSMAP_ClearComplete);
9304 BSSAP.send(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_REQ);
9305
9306 timer no_more_bssap := 5.0;
9307 no_more_bssap.start;
9308 alt {
9309 [] no_more_bssap.timeout { break; }
9310 [] BSSAP.receive(tr_BSSAP_BSSMAP) {
9311 setverdict(fail, "Expected no more BSSAP after Clear Complete");
9312 mtc.stop;
9313 }
9314 }
9315 setverdict(pass);
9316}
9317
9318/* Verify that the A-interface connection is still working, and then clear it, without doing anything on Abis. Useful
9319 * for LCS, for cases where there is only an A conn without an active lchan. */
9320private function f_verify_active_A_conn_and_clear() runs on MSC_ConnHdlr
9321{
9322 f_logp(BSCVTY, "f_verify_active_A_conn_and_clear: test A link, then clear");
9323
9324 /* When an lchan is active, we can send some L3 data from the BTS side and verify that it shows up on the other
9325 * side towards the MSC. When there is no lchan, this is not possible. To probe whether the A-interface
9326 * connection is still up, we need something that echos back on the A-interface. Another LCS request! */
9327 BSSAP.send(valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
9328 ts_CellId_CGI('262'H, '42'H, 23, 42))));
9329 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?));
9330
9331 /* Right, the Perform Location Request showed up on Lb, now we can clear the A conn. */
9332 f_clear_A_conn();
9333 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocAbort(BSSMAP_LE_LCS_CAUSE_REQUEST_ABORTED));
9334 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
9335}
9336
9337/* With *no* active lchan, start BSSMAP Perform Location Request on A interface, starting BSSMAP-LE Perform Location
9338 * Request on Lb interface. BSC will Page for the subscriber as soon as we (virtual SMLC) request the TA via BSSLAP.
9339 */
9340private function f_tc_lcs_loc_req_for_idle_ms(charstring id) runs on MSC_ConnHdlr {
9341 f_sleep(1.0);
9342
9343 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
9344 f_bssap_le_register_imsi(g_pars.imsi, omit);
9345
9346 /* Register to receive the Paging Command */
9347 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
9348 g_chan_nr := new_chan_nr;
9349 f_rslem_register(0, g_chan_nr);
9350
9351 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
9352 valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
9353 ts_CellId_CGI('001'H, '01'H, 1, 0)))));
9354 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
9355
9356 var PDU_BSSAP_LE plr;
9357 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
9358
9359 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
9360 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
9361
9362 /* OsmoBSC needs to Page */
9363 RSL.receive(tr_RSL_PAGING_CMD(tr_MI_IMSI(g_pars.imsi)));
9364 f_logp(BSCVTY, "got Paging Command");
9365
9366 /* MS requests channel. Since the Paging was for LCS, the Paging Response does not trigger a Complete Layer 3 to
9367 * the MSC, and releases the lchan directly. */
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02009368 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);
9369 f_expect_lchan_rel(RSL, RSL_PROC);
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02009370
9371 /* From the Paging Response, the TA is now known to the BSC, and it responds to the SMLC. */
9372
9373 f_expect_bsslap(tr_BSSLAP_TA_Resp(?, ?));
9374
9375 /* SMLC got the TA from the BSC, now responds with geo information data. */
9376 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(gad_ell_point_unc_circle, omit));
9377 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
9378
9379 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(tr_BSSMAP_IE_LocationEstimate(gad_ell_point_unc_circle)));
9380
9381 /* The lchan is gone, the A-interface conn was created for the LCS only.
9382 * Still it is clearly the MSC's job to decide whether to tear down the conn or not. */
9383 f_verify_active_A_conn_and_clear();
9384
9385 f_sleep(2.0);
9386 setverdict(pass);
9387}
9388testcase TC_lcs_loc_req_for_idle_ms() runs on test_CT {
9389 var MSC_ConnHdlr vc_conn;
9390 var TestHdlrParams pars := f_gen_test_hdlr_pars();
9391
9392 f_init(1, true);
9393 f_sleep(1.0);
9394
9395 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
9396 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
9397
9398 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_idle_ms), pars);
9399 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01009400 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02009401}
9402
9403/* With no active lchan, start BSSMAP Perform Location Request on A interface, but omit IMSI; expect failure response.
9404 */
9405private function f_tc_lcs_loc_req_no_subscriber(charstring id) runs on MSC_ConnHdlr {
9406 f_sleep(1.0);
9407
9408 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
9409 f_bssap_le_register_imsi(g_pars.imsi, omit);
9410
9411 /* provoke an abort by omitting both IMSI and IMEI */
9412 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
9413 valueof(ts_BSSMAP_Perform_Location_Request(omit,
9414 ts_CellId_CGI('262'H, '42'H, 23, 42)))));
9415 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
9416
9417 /* BSC tells MSC about failure */
9418 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(
9419 locationEstimate := omit, positioningData := omit,
9420 lCS_Cause := tr_BSSMAP_LcsCause(BSSMAP_LCS_CAUSE_DATA_MISSING_IN_REQ)));
9421
9422 /* There is no lchan. Still the MSC's job to decide whether to tear down the conn or not. */
9423 f_verify_active_A_conn_and_clear();
9424
9425 f_sleep(2.0);
9426 setverdict(pass);
9427}
9428testcase TC_lcs_loc_req_no_subscriber() runs on test_CT {
9429 var MSC_ConnHdlr vc_conn;
9430 var TestHdlrParams pars := f_gen_test_hdlr_pars();
9431
9432 f_init(1, true);
9433 f_sleep(1.0);
9434
9435 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
9436 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
9437
9438 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_no_subscriber), pars);
9439 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01009440 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02009441}
9442
9443/* With an active lchan, start a Perform Location Request on the A-interface, but virtual SMLC does not answer with
9444 * BSSMAP-LE Perform Location Response (before or after sending a BSSLAP TA Request) */
9445private function f_lcs_loc_req_for_active_ms_le_timeout(boolean do_ta) runs on MSC_ConnHdlr {
9446 f_sleep(1.0);
9447
9448 f_establish_fully(omit, omit);
9449 f_bssap_le_register_imsi(g_pars.imsi, omit);
9450
9451 BSSAP.send(valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
9452 ts_CellId_CGI('262'H, '42'H, 23, 42))));
9453
9454 var PDU_BSSAP_LE plr;
9455 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
9456
9457 if (do_ta) {
9458 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
9459 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
9460 f_expect_bsslap(tr_BSSLAP_TA_Resp(?, ?));
9461 }
9462
9463 /* SMLC fails to respond, BSC runs into timeout */
9464 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocAbort(BSSMAP_LE_LCS_CAUSE_SYSTEM_FAILURE));
9465 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
9466
9467 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(
9468 locationEstimate := omit, positioningData := omit,
9469 lCS_Cause := tr_BSSMAP_LcsCause(BSSMAP_LCS_CAUSE_SYSTEM_FAILURE)));
9470
9471 /* There is no lchan. Still the MSC's job to decide whether to tear down the conn or not. */
9472 f_verify_active_A_conn_and_clear();
9473
9474 f_sleep(2.0);
9475 setverdict(pass);
9476}
9477
9478/* With an active lchan, start a Perform Location Request on the A-interface, but virtual SMLC does not answer with
9479 * BSSMAP-LE Perform Location Response, without sending a BSSLAP TA Request. */
9480private function f_tc_lcs_loc_req_for_active_ms_le_timeout(charstring id) runs on MSC_ConnHdlr {
9481 f_lcs_loc_req_for_active_ms_le_timeout(false);
9482}
9483
9484testcase TC_lcs_loc_req_for_active_ms_le_timeout() runs on test_CT {
9485 var MSC_ConnHdlr vc_conn;
9486 var TestHdlrParams pars := f_gen_test_hdlr_pars();
9487
9488 f_init(1, true);
9489 f_sleep(1.0);
9490 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_active_ms_le_timeout), pars);
9491 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01009492 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02009493}
9494
9495/* With an active lchan, start a Perform Location Request on the A-interface, but virtual SMLC does not answer with
9496 * BSSMAP-LE Perform Location Response, after sending a BSSLAP TA Request. */
9497private function f_tc_lcs_loc_req_for_active_ms_le_timeout2(charstring id) runs on MSC_ConnHdlr {
9498 f_lcs_loc_req_for_active_ms_le_timeout(true);
9499}
9500
9501testcase TC_lcs_loc_req_for_active_ms_le_timeout2() runs on test_CT {
9502 var MSC_ConnHdlr vc_conn;
9503 var TestHdlrParams pars := f_gen_test_hdlr_pars();
9504
9505 f_init(1, true);
9506 f_sleep(1.0);
9507 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_active_ms_le_timeout2), pars);
9508 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01009509 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02009510}
9511
9512/* With *no* active lchan, start a Perform Location Request, expecting that the MS will be Paged. */
9513private function f_tc_lcs_loc_req_for_idle_ms_no_pag_resp(charstring id) runs on MSC_ConnHdlr {
9514 f_sleep(1.0);
9515
9516 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
9517 f_bssap_le_register_imsi(g_pars.imsi, omit);
9518
9519 /* Register to receive the Paging Command */
9520 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
9521 g_chan_nr := new_chan_nr;
9522 f_rslem_register(0, g_chan_nr);
9523
9524 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
9525 valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
9526 ts_CellId_CGI('001'H, '01'H, 1, 0)))));
9527 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
9528
9529 var PDU_BSSAP_LE plr;
9530 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
9531
9532 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
9533 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
9534
9535 /* OsmoBSC needs to Page */
9536 var PDU_BSSAP_LE rx_bsslap;
9537 alt {
9538 [] RSL.receive(tr_RSL_PAGING_CMD(tr_MI_IMSI(g_pars.imsi))) {
9539 f_logp(BSCVTY, "got Paging Command");
9540 repeat;
9541 }
9542 [] BSSAP_LE.receive(tr_BSSMAP_LE_ConnInfo(BSSMAP_LE_PROT_BSSLAP, ?)) -> value(rx_bsslap) {
9543 /* MS does not respond to Paging, TA Req runs into timeout. */
9544 f_match_bsslap(rx_bsslap, tr_BSSLAP_Abort(?));
9545 }
9546 }
9547
9548 /* SMLC responds with failure */
9549 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(omit, BSSMAP_LE_LCS_CAUSE_REQUEST_ABORTED));
9550 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
9551
9552 /* BSC tells MSC about failure */
9553 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(
9554 locationEstimate := omit, positioningData := omit,
9555 lCS_Cause := tr_BSSMAP_LcsCause(BSSMAP_LCS_CAUSE_REQUEST_ABORTED)));
9556
9557 /* There is no lchan. Still the MSC's job to decide whether to tear down the conn or not. */
9558 f_verify_active_A_conn_and_clear();
9559
9560 f_sleep(2.0);
9561 setverdict(pass);
9562}
9563testcase TC_lcs_loc_req_for_idle_ms_no_pag_resp() runs on test_CT {
9564 var MSC_ConnHdlr vc_conn;
9565 var TestHdlrParams pars := f_gen_test_hdlr_pars();
9566
9567 f_init(1, true);
9568 f_sleep(1.0);
9569
9570 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
9571 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
9572
9573 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_idle_ms_no_pag_resp), pars);
9574 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01009575 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02009576}
9577
9578/* During an ongoing Location Request, the MS sends a CM Service Request. Expect the same A-conn to be re-used / taken
9579 * over. */
9580private function f_tc_cm_service_during_lcs_loc_req(charstring id) runs on MSC_ConnHdlr {
9581 f_sleep(1.0);
9582
9583 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
9584 f_bssap_le_register_imsi(g_pars.imsi, omit);
9585
9586 /* Register to receive the Paging Command */
9587 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
9588 g_chan_nr := new_chan_nr;
9589 f_rslem_register(0, g_chan_nr);
9590
9591 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
9592 valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
9593 ts_CellId_CGI('001'H, '01'H, 1, 0)))));
9594 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
9595
9596 var PDU_BSSAP_LE plr;
9597 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
9598
9599 /* As the A-interface conn was established for LCS, the MS coincidentally decides to issue a CM Service Request
9600 * and establish Layer 3. It should use the existing A-interface conn. */
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02009601 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 +02009602 do_clear := false, expect_bssmap_l3 := true);
9603
9604 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
9605 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
9606
9607 /* OsmoBSC already has an lchan, no need to Page, just returns the TA */
9608 f_expect_bsslap(tr_BSSLAP_TA_Resp(?, ?));
9609
9610 /* SMLC got the TA from the BSC, now responds with geo information data. */
9611 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(gad_ell_point_unc_circle, omit));
9612 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
9613 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(tr_BSSMAP_IE_LocationEstimate(gad_ell_point_unc_circle)));
9614
9615 /* The lchan should still exist, it was from a CM Service Request. */
9616 f_mo_l3_transceive();
9617
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02009618 f_perform_clear();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02009619
9620 f_sleep(2.0);
9621 setverdict(pass);
9622}
9623testcase TC_cm_service_during_lcs_loc_req() runs on test_CT {
9624 var MSC_ConnHdlr vc_conn;
9625 var TestHdlrParams pars := f_gen_test_hdlr_pars();
9626
9627 f_init(1, true);
9628 f_sleep(1.0);
9629
9630 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
9631 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
9632
9633 vc_conn := f_start_handler(refers(f_tc_cm_service_during_lcs_loc_req), pars);
9634 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01009635 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02009636}
9637
9638/* During an ongoing Perform Location Request, do a Handover, an expect a BSSLAP Reset message from the BSC to indicate
9639 * the new lchan after handover. */
9640private function f_tc_ho_during_lcs_loc_req(charstring id) runs on MSC_ConnHdlr {
9641 f_sleep(1.0);
9642
9643 f_establish_fully(omit, omit);
9644 f_bssap_le_register_imsi(g_pars.imsi, omit);
9645
9646 BSSAP.send(valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
9647 ts_CellId_CGI('262'H, '42'H, 23, 42))));
9648
9649 var PDU_BSSAP_LE plr;
9650 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
9651
9652 /* SMLC ponders the Location Request, in the meantime the BSC decides to handover */
9653 f_bts_0_cfg(BSCVTY, {"neighbor bts 1"});
9654
9655 var HandoverState hs := {
9656 rr_ho_cmpl_seen := false,
9657 handover_done := false,
Neels Hofmeyrc741fcb2021-10-02 14:52:28 +02009658 old_chan_nr := -,
9659 expect_target_tsc := BTS_TSC[1]
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02009660 };
9661 /* issue hand-over command on VTY */
9662 f_vty_handover(BSCVTY, 0, 0, g_chan_nr, 1);
9663 /* temporarily suspend DChan processing on BTS1 to avoid race with RSLEM_register */
9664 f_rslem_suspend(RSL1_PROC);
9665
9666 /* From the MGW perspective, a handover is is characterized by
9667 * performing one MDCX operation with the MGW. So we expect to see
9668 * one more MDCX during handover. */
9669 g_media.mgcp_conn[0].mdcx_seen_exp := g_media.mgcp_conn[0].crcx_seen_exp + 1;
9670
9671 alt {
9672 [] as_handover(hs);
9673 }
9674
9675 var PDU_BSSAP_LE rx_bsslap;
9676
9677 interleave {
9678 /* Expect the BSC to inform the MSC about the handover */
9679 [] BSSAP.receive(tr_BSSMAP_HandoverPerformed);
9680
9681 /* Expect the BSC to inform the SMLC about the handover */
9682 [] BSSAP_LE.receive(tr_BSSMAP_LE_ConnInfo(BSSMAP_LE_PROT_BSSLAP, ?)) -> value(rx_bsslap) {
9683 f_match_bsslap(rx_bsslap, tr_BSSLAP_Reset(BSSLAP_CAUSE_INTRA_BSS_HO));
9684 }
9685 }
9686
9687 /* SMLC now responds with geo information data. */
9688 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(gad_ell_point_unc_circle, omit));
9689 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
9690 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(tr_BSSMAP_IE_LocationEstimate(gad_ell_point_unc_circle)));
9691
9692 /* lchan still active */
9693 f_mo_l3_transceive(RSL1);
9694
9695 /* MSC decides it is done now. */
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02009696 f_perform_clear(RSL1, RSL1_PROC);
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02009697
9698 f_sleep(2.0);
9699 setverdict(pass);
9700}
9701testcase TC_ho_during_lcs_loc_req() runs on test_CT {
9702 var MSC_ConnHdlr vc_conn;
9703 var TestHdlrParams pars := f_gen_test_hdlr_pars();
9704
9705 f_init(2, true);
9706 f_sleep(1.0);
9707 vc_conn := f_start_handler(refers(f_tc_ho_during_lcs_loc_req), pars);
9708 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01009709 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02009710}
9711
Neels Hofmeyrbf037052020-10-28 22:52:02 +00009712/* Attempt Complete Layer 3 without any MSC available (OS#4832) */
9713private function f_tc_no_msc(charstring id) runs on MSC_ConnHdlr {
9714 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
9715
9716 /* Also disable attach for the single connected MSC */
9717 f_vty_msc_allow_attach(BSCVTY, { false });
9718
9719 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) ));
9720 f_chan_est(g_pars.ra, l3_enc, g_pars.link_id, g_pars.fn);
9721
9722 /* No MSC is found, expecting a proper release on RSL */
9723 interleave {
9724 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
9725 f_logp(BSCVTY, "Got RSL RR Release");
9726 }
9727 [] RSL.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
9728 f_logp(BSCVTY, "Got RSL Deact SACCH");
9729 }
Neels Hofmeyr3c5127e2021-07-22 19:18:40 +02009730 [] RSL.receive(tr_RSL_RF_CHAN_REL(g_chan_nr)) {
Neels Hofmeyrbf037052020-10-28 22:52:02 +00009731 f_logp(BSCVTY, "Got RSL RF Chan Rel, sending Rel Ack");
9732 RSL.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
Neels Hofmeyre680b012021-07-22 19:19:09 +02009733 f_rslem_unregister(0, g_chan_nr);
Neels Hofmeyrbf037052020-10-28 22:52:02 +00009734 }
9735 }
9736 setverdict(pass);
9737}
9738testcase TC_no_msc() runs on test_CT {
9739
9740 f_init(1, true);
9741 f_sleep(1.0);
9742 var MSC_ConnHdlr vc_conn;
9743 var TestHdlrParams pars := f_gen_test_hdlr_pars();
9744
9745 f_ctrs_bsc_init(counternames_bsc_mscpool);
9746
9747 vc_conn := f_start_handler(refers(f_tc_no_msc), pars);
9748 vc_conn.done;
9749
9750 f_ctrs_bsc_add("mscpool:subscr:no_msc");
9751 f_ctrs_bsc_verify();
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01009752 f_shutdown_helper();
Neels Hofmeyrbf037052020-10-28 22:52:02 +00009753}
9754
Harald Welte0ea2d5e2018-04-07 21:40:29 +02009755/* Dyn PDCH todo:
9756 * activate OSMO as TCH/F
9757 * activate OSMO as TCH/H
9758 * does the BSC-located PCU socket get the updated INFO?
9759 * what if no PCU is connected at the time?
9760 * is the info correct on delayed PCU (re)connect?
9761 */
Harald Welte94e0c342018-04-07 11:33:23 +02009762
Neels Hofmeyr87857ec2021-04-25 16:17:47 +00009763private function f_TC_refuse_mode_modif_to_vamos(charstring id) runs on MSC_ConnHdlr {
9764 var PDU_BSSAP ass_cmd := f_gen_ass_req(g_pars.use_osmux);
9765 var template PDU_BSSAP exp_compl := f_gen_exp_compl(g_pars.use_osmux);
9766
9767 /* puzzle together the ASSIGNMENT REQ for given codec[s] */
9768 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
9769 ass_cmd.pdu.bssmap.assignmentRequest.codecList := g_pars.ass_codec_list;
9770 exp_compl.pdu.bssmap.assignmentComplete.speechCodec.codecElements[0] :=
9771 g_pars.ass_codec_list.codecElements[0];
9772 if (isvalue(g_pars.expect_mr_s0_s7)) {
9773 exp_compl.pdu.bssmap.assignmentComplete.speechCodec.codecElements[0].s0_7 :=
9774 g_pars.expect_mr_s0_s7;
9775 }
9776 }
9777 ass_cmd.pdu.bssmap.assignmentRequest.channelType :=
9778 f_BSSMAP_chtype_from_codec(g_pars.ass_codec_list.codecElements[0]);
9779 log("expecting ASS COMPL like this: ", exp_compl);
9780
9781 f_establish_fully(ass_cmd, exp_compl);
9782
Neels Hofmeyr8746b0d2021-06-01 17:25:39 +02009783 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 +00009784
9785 var RSL_Message rsl;
9786
9787 timer T := 5.0;
9788 T.start;
9789 alt {
9790 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr)) -> value rsl {
9791 var PDU_ML3_NW_MS l3 := dec_PDU_ML3_NW_MS(rsl.ies[2].body.l3_info.payload);
9792 log("Rx L3 from net: ", l3);
9793 if (ischosen(l3.msgs.rrm.channelModeModify)) {
9794 setverdict(fail, "Mode Modify to VAMOS succeeded even though BTS does not support VAMOS");
9795 mtc.stop;
9796 }
9797 }
9798 [] RSL.receive(tr_RSL_MODE_MODIFY_REQ(g_chan_nr, ?)) -> value rsl {
9799 setverdict(fail, "Mode Modify to VAMOS succeeded even though BTS does not support VAMOS");
9800 mtc.stop;
9801 }
9802 [] T.timeout {
9803 /* The BTS does not exhibit BTS_FEAT_VAMOS, so no VAMOS related Mode Modify should happen. */
9804 setverdict(pass);
9805 }
9806 }
9807 T.stop;
9808}
9809
9810/* The BSC does *not* indicate BTS_FEAT_VAMOS; make sure that a channel Mode Modify to VAMOS mode is refused by
9811 * osmo-bsc. */
9812testcase TC_refuse_mode_modif_to_vamos() runs on test_CT {
9813 var TestHdlrParams pars := f_gen_test_hdlr_pars();
9814 var MSC_ConnHdlr vc_conn;
9815
9816 f_init(1, true);
9817 f_sleep(1.0);
9818
9819 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
9820 vc_conn := f_start_handler(refers(f_TC_refuse_mode_modif_to_vamos), pars);
9821 vc_conn.done;
9822 f_shutdown_helper();
9823}
9824
9825/* The BSC does *not* indicate BTS_FEAT_VAMOS; make sure that a channel activation to VAMOS mode is refused by osmo-bsc.
9826 */
9827testcase TC_refuse_chan_act_to_vamos() runs on test_CT {
9828 f_init_vty();
9829
9830 f_init(1, false);
9831 f_sleep(1.0);
9832
9833 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 1 sub-slot 0 activate-vamos fr");
9834
9835 var ASP_RSL_Unitdata rx_rsl_ud;
9836 timer T := 5.0;
9837
9838 T.start;
9839 alt {
9840 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(?, IPAC_PROTO_RSL_TRX0)) -> value rx_rsl_ud {
9841 if (rx_rsl_ud.rsl.msg_type == RSL_MT_CHAN_ACTIV) {
9842 T.stop;
9843 setverdict(fail, "CHANnel ACTivate in VAMOS mode succeeded even though BTS does not support VAMOS");
9844 mtc.stop;
9845 }
9846 repeat;
9847 }
9848 [] T.timeout {
9849 /* The BTS does not exhibit BTS_FEAT_VAMOS, so no VAMOS related CHANnel ACTivate should happen. */
9850 setverdict(pass);
9851 }
9852 }
9853}
9854
Neels Hofmeyrd2d9f332021-04-28 22:23:36 +00009855private function f_TC_reassignment_codec(charstring id) runs on MSC_ConnHdlr {
9856 /* First fully set up a speech lchan */
9857 f_TC_assignment_codec(id);
9858
9859 /* Trigger re-assignment to another lchan */
9860 var AssignmentState assignment_st := valueof(ts_AssignmentStateInit);
9861
9862 /* Re-Assignment should tell the MGW endpoint the new lchan's RTP address and port, so expecting to see exactly
9863 * one MDCX on MGCP. */
9864 g_media.mgcp_conn[0].mdcx_seen_exp := g_media.mgcp_conn[0].mdcx_seen_exp + 1;
9865
9866 /* The new lchan will see all-new IPAC_CRCX and IPAC_MDCX messages telling the BTS the same RTP address and port
9867 * as the old lchan used. */
9868 g_media.bts.ipa_crcx_seen := false;
9869 g_media.bts.ipa_mdcx_seen := false;
9870
9871 /* Send different BTS side RTP port number for the new lchan */
9872 g_media.bts.bts.port_nr := 4223;
9873
9874 f_rslem_register(0, valueof(ts_RslChanNr_Bm(2))); /* <-- FIXME: can we somehow infer the timeslot that will be used? */
9875
9876 /* Trigger re-assignment. */
9877 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot " & int2str(g_chan_nr.tn) & " sub-slot 0 assignment");
9878
9879 timer T := 5.0;
9880 T.start;
9881 alt {
9882 [] as_assignment(assignment_st);
9883 [] as_Media();
9884 [] T.timeout {
9885 break;
9886 }
9887 }
9888
9889 if (not assignment_st.assignment_done) {
9890 setverdict(fail, "Assignment did not complete");
9891 mtc.stop;
9892 }
9893
9894 f_check_mgcp_expectations()
9895 setverdict(pass);
9896
9897 f_sleep(2.0);
9898 log("show lchan summary: ", f_vty_transceive_ret(BSCVTY, "show lchan summary"));
9899
9900 /* Instruct BSC to clear channel */
9901 var BssmapCause cause := 0;
9902 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
9903 interleave {
Neels Hofmeyrd2d9f332021-04-28 22:23:36 +00009904 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {}
9905 [] RSL.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {}
Neels Hofmeyr3c5127e2021-07-22 19:18:40 +02009906 [] RSL.receive(tr_RSL_RF_CHAN_REL(g_chan_nr)) {
Neels Hofmeyrd2d9f332021-04-28 22:23:36 +00009907 RSL.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
Neels Hofmeyre680b012021-07-22 19:19:09 +02009908 f_rslem_unregister(0, g_chan_nr);
Neels Hofmeyrd2d9f332021-04-28 22:23:36 +00009909 }
9910 [] BSSAP.receive(tr_BSSMAP_ClearComplete) {
9911 BSSAP.send(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_REQ);
9912 }
9913 }
Neels Hofmeyr40a45d12021-09-23 22:57:12 +02009914 f_expect_dlcx_conns();
Neels Hofmeyrd2d9f332021-04-28 22:23:36 +00009915
9916 f_sleep(0.5);
9917}
9918
9919testcase TC_reassignment_fr() runs on test_CT {
9920 var TestHdlrParams pars := f_gen_test_hdlr_pars();
9921 var MSC_ConnHdlr vc_conn;
9922
9923 f_init(1, true);
9924 f_sleep(1.0);
9925
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01009926 f_ctrs_bsc_and_bts_handover_init();
Neels Hofmeyrd2d9f332021-04-28 22:23:36 +00009927
9928 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
9929 vc_conn := f_start_handler(refers(f_TC_reassignment_codec), pars);
9930 vc_conn.done;
9931
9932 /* from f_establish_fully() */
9933 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
9934 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
9935 /* from re-assignment */
9936 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
9937 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
9938 f_ctrs_bsc_and_bts_verify();
9939 f_shutdown_helper();
9940}
9941
Neels Hofmeyrfeda88e2021-07-19 13:51:29 +02009942const charstring REEST_LOST_CONNECTION := "REEST_LOST_CONNECTION";
9943const charstring REEST_CLEAR := "REEST_CLEAR";
9944const charstring REEST_CLEAR_DONE := "REEST_CLEAR_DONE";
9945
9946/* CM Re-Establishment, 3GPP TS 24.008 4.5.1.6.
9947 * The MS <-> BTS loses radio connection, MS shows up on second BTS and asks for CM Re-Establishment.
9948 * BSC should establish a separate A conn for the same MS, the original A conn is then cleared by
9949 * the MSC as the CM Re-Establishment is handled.
9950 *
9951 * MS bts0 bts1 bsc msc test-component
9952 * |<----->|<----------------->|<-0-->| _1 Establish channel on bts 0
9953 * | | _1 wait a bit, to settle down
9954 * |<-x x--| | _1 "lose connection"
9955 * | | REEST_LOST_CONNECTION
9956 * |----------------->|------->|--1-->| _2 new A-conn: Chan Rqd, Imm Ass, Compl L3 with CM Re-Establishment Req
9957 * | | REEST_CLEAR
9958 * | |<-0---| _1 Clear Command on first A-conn
9959 * | |--0-->| _1 Clear Complete
9960 * | |<----------------->| | _1 Release first channel
9961 * | | REEST_CLEAR_DONE
9962 * |<-----------------|<-------|<-1---| _2 Chan Activ, Assignment Command
9963 * |<-----------------|<-------|<-1---| _2 Clear Command, Release
9964 *
9965 */
9966private function f_tc_cm_reestablishment_1(charstring id) runs on MSC_ConnHdlr {
9967 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
9968 var PDU_BSSAP ass_cmd := f_gen_ass_req();
9969
9970 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
9971 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
9972
9973 f_establish_fully(ass_cmd, exp_compl);
9974
9975 /* The original channel loses connection, MS attemts CM Re-Establishment on another cell, see
9976 * f_tc_cm_reestablishment_2(). This established channel stays active until MSC sends a Clear Command. The time
9977 * when exactly that happens is determined by f_tc_cm_reestablishment_2(). */
9978 f_sleep(2.0);
9979 COORD.send(REEST_LOST_CONNECTION);
9980
9981 alt {
9982 [] COORD.receive(REEST_CLEAR);
9983 [] RSL.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
9984 setverdict(fail, "Unexpected channel release");
9985 mtc.stop;
9986 }
9987 [] RSL.receive(tr_RSL_RF_CHAN_REL(g_chan_nr)) {
9988 setverdict(fail, "Unexpected channel release");
9989 mtc.stop;
9990 }
9991 }
9992 f_perform_clear()
9993 f_expect_dlcx_conns();
Neels Hofmeyr969abd02021-09-23 22:24:08 +02009994 f_create_mgcp_delete_ep(g_media.mgcp_ep);
Neels Hofmeyrfeda88e2021-07-19 13:51:29 +02009995 COORD.send(REEST_CLEAR_DONE);
9996}
9997
9998private function f_tc_cm_reestablishment_2(charstring id) runs on MSC_ConnHdlr {
9999 f_MscConnHdlr_init(g_pars.media_nr, host_bts, host_mgw_mgcp, FR_AMR);
10000
10001 /* The MS lost the connection on the first channel, now establishes another one */
10002 COORD.receive(REEST_LOST_CONNECTION);
10003
10004 var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi));
10005 var PDU_ML3_MS_NW l3_info := valueof(ts_CM_REESTABL_REQ(mi));
10006 var octetstring l3_enc := enc_PDU_ML3_MS_NW(l3_info);
10007
10008 f_create_bssmap_exp(l3_enc);
Neels Hofmeyrc7b1f6d2021-07-20 23:21:36 +020010009 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 +020010010 BSSAP.receive(tr_BSSMAP_ComplL3(l3_enc));
10011
10012 /* MSC got the CM Re-Establishment request and first off clears the previous conn. */
10013 COORD.send(REEST_CLEAR);
10014 COORD.receive(REEST_CLEAR_DONE);
10015
10016 f_sleep(2.0);
10017
10018 /* Answer the CM Re-Establishment with an Assignment Command. */
10019 var template PDU_BSSAP expect_assignment_compl := f_gen_exp_compl();
10020 var PDU_BSSAP ass_cmd := f_gen_ass_req();
10021 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
10022 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
10023
10024 var AssignmentState st := valueof(ts_AssignmentStateInit);
10025 st.voice_call := true;
10026 st.is_assignment := true;
10027
10028 var ExpectCriteria mgcpcrit := {
10029 connid := omit,
10030 endpoint := omit,
10031 transid := omit
10032 };
10033 f_create_mgcp_expect(mgcpcrit);
10034
Neels Hofmeyrc7b1f6d2021-07-20 23:21:36 +020010035 f_rslem_dchan_queue_enable(RSL1_PROC);
Neels Hofmeyrfeda88e2021-07-19 13:51:29 +020010036
10037 BSSAP.send(ass_cmd);
10038
10039 var PDU_BSSAP bssap;
10040
10041 alt {
Neels Hofmeyrc7b1f6d2021-07-20 23:21:36 +020010042 [] as_assignment(st, rsl_pt := RSL1, rsl_proc_pt := RSL1_PROC);
10043 [] as_Media_ipacc(RSL1, RSL2);
10044 [] as_Media_mgw();
Neels Hofmeyrfeda88e2021-07-19 13:51:29 +020010045 [st.assignment_done] BSSAP.receive(expect_assignment_compl) {
10046 break;
10047 }
10048 }
10049
10050 f_sleep(3.0);
10051
10052 f_logp(BSCVTY, "f_tc_cm_reestablishment_2 clearing");
Neels Hofmeyrc7b1f6d2021-07-20 23:21:36 +020010053 f_perform_clear(RSL1, RSL1_PROC);
Neels Hofmeyrfeda88e2021-07-19 13:51:29 +020010054 f_expect_dlcx_conns();
10055}
10056
10057testcase TC_cm_reestablishment() runs on test_CT {
10058 var TestHdlrParams pars1 := f_gen_test_hdlr_pars();
10059 var MSC_ConnHdlr vc_conn1;
10060
10061 var TestHdlrParams pars2 := f_gen_test_hdlr_pars();
10062 var MSC_ConnHdlr vc_conn2;
10063 pars2.imsi := pars1.imsi;
10064 pars2.media_nr := 2;
Neels Hofmeyrbf720202021-10-02 12:58:24 +020010065 pars2.expect_tsc := BTS_TSC[1];
Neels Hofmeyrfeda88e2021-07-19 13:51:29 +020010066
10067 f_init(2, true, guard_timeout := 40.0);
10068 f_sleep(1.0);
10069
10070 vc_conn1 := f_start_handler_create(pars1);
10071 vc_conn2 := f_start_handler_create(pars2);
10072 connect(vc_conn1:COORD, vc_conn2:COORD);
10073 f_start_handler_run(vc_conn1, refers(f_tc_cm_reestablishment_1), pars1);
10074 f_start_handler_run(vc_conn2, refers(f_tc_cm_reestablishment_2), pars2);
10075 vc_conn1.done;
10076 vc_conn2.done;
10077
10078 f_shutdown_helper();
10079}
Neels Hofmeyr87857ec2021-04-25 16:17:47 +000010080
Neels Hofmeyrb07b2952021-08-07 04:23:14 +020010081function f_exp_ipa_rx_nonfatal(integer bts_nr, template (present) RSL_Message t_rx, float t_secs := 2.0,
10082 IpaStreamId sid := IPAC_PROTO_RSL_TRX0, boolean ignore_other_rx := true)
10083runs on test_CT return template (omit) RSL_Message {
10084 var ASP_RSL_Unitdata rx_rsl_ud;
10085 timer T := t_secs;
10086
10087 T.start;
10088 alt {
10089 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(t_rx, sid)) -> value rx_rsl_ud {
10090 T.stop;
10091 }
10092 [ignore_other_rx] IPA_RSL[bts_nr].receive { repeat; }
10093 [not ignore_other_rx] IPA_RSL[bts_nr].receive {
10094 log("f_exp_ipa_rx_nonfatal(): Got different message than ", t_rx);
10095 T.stop;
10096 return omit;
10097 }
10098 [] T.timeout {
10099 return omit;
10100 }
10101 }
10102 return rx_rsl_ud.rsl;
10103}
10104
10105private function f_vty_set_imm_ass(TELNETasp_PT pt, BtsNr bts_nr := 0, charstring imm_ass_setting := "post-chan-ack") {
10106 f_vty_enter_cfg_bts(pt, bts_nr);
10107 f_vty_transceive(pt, "immediate-assignment " & imm_ass_setting);
10108 f_vty_transceive(pt, "exit");
10109 f_vty_transceive(pt, "exit");
10110 f_vty_transceive(pt, "exit");
10111}
10112
10113private function f_verify_imm_ass(RSL_Message imm_ass, template uint8_t ra := ?, template GsmFrameNumber fn := ?,
Neels Hofmeyr07603cf2021-09-07 19:05:52 +020010114 template RslChannelNr chan_nr := ?,
10115 template (present) uint12_t arfcn := ?,
10116 template (present) uint3_t tsc := ?)
Neels Hofmeyrb07b2952021-08-07 04:23:14 +020010117{
10118 var RSL_IE_Body full_imm_ass_info;
10119 if (not f_rsl_find_ie(imm_ass, RSL_IE_FULL_IMM_ASS_INFO, full_imm_ass_info)) {
10120 setverdict(fail, "RSL Full Immediate Assign Info IE is absent");
10121 mtc.stop;
10122 }
10123
10124 var GsmRrMessage rr_imm_ass := dec_GsmRrMessage(full_imm_ass_info.full_imm_ass_info.payload);
10125 var template GsmRrMessage expect_imm_ass := tr_IMM_ASS(ra := ra,
10126 fn := fn,
Neels Hofmeyr07603cf2021-09-07 19:05:52 +020010127 ch_desc := tr_ChanDescH0(chan_nr, arfcn, tsc),
Neels Hofmeyrb07b2952021-08-07 04:23:14 +020010128 page_mode := ?);
10129 if (not match(rr_imm_ass, expect_imm_ass)) {
10130 log("Error: expected ", expect_imm_ass, " got ", rr_imm_ass);
10131 setverdict(fail, "Failed to match Immediate Assignment");
10132 mtc.stop;
10133 }
10134}
10135
10136testcase TC_imm_ass_post_chan_ack() runs on test_CT {
10137 var RSL_Message chan_act;
10138 var RSL_Message imm_ass;
10139
10140 f_init(1, false);
10141 f_sleep(1.0);
10142
10143 /* (should be the default anyway, just to make things clear) */
10144 f_vty_set_imm_ass(BSCVTY, 0, "post-chan-ack");
10145
10146 /* RA containing reason=LU */
10147 var GsmFrameNumber fn := 2342;
10148 var uint8_t ra := 2;
10149 f_ipa_tx(0, ts_RSL_CHAN_RQD(int2oct(ra, 1), fn));
10150
10151 chan_act := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
10152
10153 /* First send the Chan Act ACK */
10154 var RslChannelNr chan_nr := chan_act.ies[0].body.chan_nr;
Neels Hofmeyr07603cf2021-09-07 19:05:52 +020010155 var RSL_IE_Body chan_ident_ie;
10156 if (not f_rsl_find_ie(chan_act, RSL_IE_CHAN_IDENT, chan_ident_ie)) {
10157 setverdict(fail, "RSL Channel Identification IE is absent");
10158 mtc.stop;
10159 }
10160
Neels Hofmeyrb07b2952021-08-07 04:23:14 +020010161 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, fn + 10));
10162
10163 /* Then expect the Immediate Assignment, after we ACKed the chan act */
10164 imm_ass := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
10165
Neels Hofmeyr07603cf2021-09-07 19:05:52 +020010166 f_verify_imm_ass(imm_ass, ra, fn, chan_nr, chan_ident_ie.chan_ident.ch_desc.v.arfcn,
10167 chan_ident_ie.chan_ident.ch_desc.v.tsc);
Neels Hofmeyrb07b2952021-08-07 04:23:14 +020010168
10169 /* Check that the lchan is working */
10170 var octetstring l3 := '00010203040506'O;
10171 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
10172
10173 var BSSAP_N_CONNECT_ind rx_c_ind;
10174 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
10175 BSSAP.send(ts_BSSAP_CONNECT_res(rx_c_ind.connectionId));
10176
10177 f_sleep(1.0);
10178 f_shutdown_helper();
10179}
10180
10181testcase TC_imm_ass_pre_chan_ack() runs on test_CT {
10182 var RSL_Message chan_act;
10183 var RSL_Message imm_ass;
10184
10185 f_init(1, false);
10186 f_sleep(1.0);
10187
10188 f_vty_set_imm_ass(BSCVTY, 0, "pre-chan-ack");
10189
10190 /* RA containing reason=LU */
10191 var GsmFrameNumber fn := 2342;
10192 var uint8_t ra := 2;
10193 f_ipa_tx(0, ts_RSL_CHAN_RQD(int2oct(ra, 1), fn));
10194
10195 /* (set bts 0 cfg back to default) */
10196 f_vty_set_imm_ass(BSCVTY);
10197
10198 chan_act := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
10199 var RslChannelNr chan_nr := chan_act.ies[0].body.chan_nr;
Neels Hofmeyr07603cf2021-09-07 19:05:52 +020010200 var RSL_IE_Body chan_ident_ie;
10201 if (not f_rsl_find_ie(chan_act, RSL_IE_CHAN_IDENT, chan_ident_ie)) {
10202 setverdict(fail, "RSL Channel Identification IE is absent");
10203 mtc.stop;
10204 }
Neels Hofmeyrb07b2952021-08-07 04:23:14 +020010205
10206 /* *FIRST* expect the Immediate Assignment, before we ACK the chan act */
10207 imm_ass := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
Neels Hofmeyr07603cf2021-09-07 19:05:52 +020010208 f_verify_imm_ass(imm_ass, ra, fn, chan_nr, chan_ident_ie.chan_ident.ch_desc.v.arfcn,
10209 chan_ident_ie.chan_ident.ch_desc.v.tsc);
Neels Hofmeyrb07b2952021-08-07 04:23:14 +020010210
10211 /* Only now send the Chan Act ACK */
10212 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, fn+10));
10213
10214 /* Check that the lchan is working */
10215 var octetstring l3 := '00010203040506'O;
10216 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
10217
10218 var BSSAP_N_CONNECT_ind rx_c_ind;
10219 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
10220 BSSAP.send(ts_BSSAP_CONNECT_res(rx_c_ind.connectionId));
10221
10222 f_sleep(1.0);
10223 f_shutdown_helper();
10224}
10225
Neels Hofmeyr23158742021-09-07 19:08:07 +020010226testcase TC_imm_ass_pre_ts_ack() runs on test_CT {
10227 var RSL_Message chan_act;
10228 var RSL_Message imm_ass;
10229
10230 f_init(1, false);
10231 f_sleep(1.0);
10232
10233 f_vty_set_imm_ass(BSCVTY, 0, "pre-ts-ack");
10234
10235 /* RA containing reason=LU */
10236 var GsmFrameNumber fn := 2342;
10237 var uint8_t ra := 2;
10238 f_ipa_tx(0, ts_RSL_CHAN_RQD(int2oct(ra, 1), fn));
10239
10240 /* (set bts 0 cfg back to default) */
10241 f_vty_set_imm_ass(BSCVTY);
10242
10243 chan_act := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
10244 var RslChannelNr chan_nr := chan_act.ies[0].body.chan_nr;
10245 var RSL_IE_Body chan_ident_ie;
10246 if (not f_rsl_find_ie(chan_act, RSL_IE_CHAN_IDENT, chan_ident_ie)) {
10247 setverdict(fail, "RSL Channel Identification IE is absent");
10248 mtc.stop;
10249 }
10250
10251 /* *FIRST* expect the Immediate Assignment, before we ACK the chan act */
10252 imm_ass := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
10253 f_verify_imm_ass(imm_ass, ra, fn, chan_nr, chan_ident_ie.chan_ident.ch_desc.v.arfcn,
10254 chan_ident_ie.chan_ident.ch_desc.v.tsc);
10255
10256 /* Only now send the Chan Act ACK */
10257 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, fn+10));
10258
10259 /* Check that the lchan is working */
10260 var octetstring l3 := '00010203040506'O;
10261 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
10262
10263 var BSSAP_N_CONNECT_ind rx_c_ind;
10264 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
10265 BSSAP.send(ts_BSSAP_CONNECT_res(rx_c_ind.connectionId));
10266
10267 f_sleep(1.0);
10268 f_shutdown_helper();
10269}
10270
Neels Hofmeyr7a6d0602021-08-07 04:23:50 +020010271testcase TC_imm_ass_pre_chan_ack_dyn_ts() runs on test_CT {
10272 /* change Timeslot 6 before f_init() starts RSL */
10273 f_init_vty();
10274 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_PDCH");
10275 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
10276
10277 f_init(1, false);
10278 f_sleep(1.0);
10279
10280 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(6));
10281 /* The BSC will activate the dynamic PDCH by default, so confirm that */
10282 f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
10283 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2323));
10284
10285 /* clean up timeslot 6 config, will only take effect when the OML drops the next time */
10286 f_ts_set_chcomb(0, 0, 6, "PDCH");
10287
10288 /* block all static timeslots so that the dyn TS will be used */
10289 f_disable_all_tch_f();
10290 f_disable_all_tch_h();
10291 f_disable_all_sdcch();
10292
10293 var RSL_Message chan_act;
10294 var RSL_Message imm_ass;
10295
10296 f_init(1, false);
10297 f_sleep(1.0);
10298
10299 f_vty_set_imm_ass(BSCVTY, 0, "pre-chan-ack");
10300
10301 /* RA containing reason=LU */
10302 var GsmFrameNumber fn := 2342;
10303 var uint8_t ra := 2;
10304 f_ipa_tx(0, ts_RSL_CHAN_RQD(int2oct(ra, 1), fn));
10305
10306 /* (set bts 0 cfg back to default) */
10307 f_vty_set_imm_ass(BSCVTY);
10308
10309 /* Expect the dyn TS to deactivate PDCH first */
10310 f_exp_ipa_rx(0, tr_RSL_RF_CHAN_REL(chan_nr));
10311 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(chan_nr));
10312
10313 /* Now activation as SDCCH8 */
10314 chan_nr := valueof(t_RslChanNr_SDCCH8(tn := 6, sub_slot := 0));
10315
10316 chan_act := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
Neels Hofmeyr07603cf2021-09-07 19:05:52 +020010317 var RSL_IE_Body chan_ident_ie;
10318 if (not f_rsl_find_ie(chan_act, RSL_IE_CHAN_IDENT, chan_ident_ie)) {
10319 setverdict(fail, "RSL Channel Identification IE is absent");
10320 mtc.stop;
10321 }
Neels Hofmeyr7a6d0602021-08-07 04:23:50 +020010322
10323 /* *FIRST* expect the Immediate Assignment, before we ACK the chan act */
10324 imm_ass := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
Neels Hofmeyr07603cf2021-09-07 19:05:52 +020010325 f_verify_imm_ass(imm_ass, ra, fn, chan_nr, chan_ident_ie.chan_ident.ch_desc.v.arfcn,
10326 chan_ident_ie.chan_ident.ch_desc.v.tsc);
Neels Hofmeyr7a6d0602021-08-07 04:23:50 +020010327
10328 /* Only now send the Chan Act ACK */
10329 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, fn+10));
10330
10331 /* Check that the lchan is working */
10332 var octetstring l3 := '00010203040506'O;
10333 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
10334
10335 var BSSAP_N_CONNECT_ind rx_c_ind;
10336 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
10337 BSSAP.send(ts_BSSAP_CONNECT_res(rx_c_ind.connectionId));
10338
10339 f_sleep(1.0);
10340 f_shutdown_helper();
10341}
10342
Neels Hofmeyrc8b95c12021-08-07 04:24:02 +020010343testcase TC_imm_ass_pre_ts_ack_dyn_ts() runs on test_CT {
10344 /* change Timeslot 6 before f_init() starts RSL */
10345 f_init_vty();
10346 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_PDCH");
10347 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
10348
10349 f_init(1, false);
10350 f_sleep(1.0);
10351
10352 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(6));
10353 /* The BSC will activate the dynamic PDCH by default, so confirm that */
10354 f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
10355 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2323));
10356
10357 /* clean up timeslot 6 config, will only take effect when the OML drops the next time */
10358 f_ts_set_chcomb(0, 0, 6, "PDCH");
10359
10360 /* block all static timeslots so that the dyn TS will be used */
10361 f_disable_all_tch_f();
10362 f_disable_all_tch_h();
10363 f_disable_all_sdcch();
10364
10365 var RSL_Message chan_act;
10366 var RSL_Message imm_ass;
10367
10368 f_init(1, false);
10369 f_sleep(1.0);
10370
10371 f_vty_set_imm_ass(BSCVTY, 0, "pre-ts-ack");
10372
10373 /* RA containing reason=LU */
10374 var GsmFrameNumber fn := 2342;
10375 var uint8_t ra := 2;
10376 f_ipa_tx(0, ts_RSL_CHAN_RQD(int2oct(ra, 1), fn));
10377
10378 /* (set bts 0 cfg back to default) */
10379 f_vty_set_imm_ass(BSCVTY);
10380
10381 /* Expect the dyn TS to deactivate PDCH first */
10382 f_exp_ipa_rx(0, tr_RSL_RF_CHAN_REL(chan_nr));
10383
10384 /* And already the Immediate Assignment even before the PDCH Deact ACK */
10385 imm_ass := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
10386
10387 /* continue the Osmo style PDCH Deact (usual chan rel) */
10388 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(chan_nr));
10389
10390 /* Now activation as SDCCH8 */
10391 chan_nr := valueof(t_RslChanNr_SDCCH8(tn := 6, sub_slot := 0));
10392
10393 chan_act := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
Neels Hofmeyr07603cf2021-09-07 19:05:52 +020010394 var RSL_IE_Body chan_ident_ie;
10395 if (not f_rsl_find_ie(chan_act, RSL_IE_CHAN_IDENT, chan_ident_ie)) {
10396 setverdict(fail, "RSL Channel Identification IE is absent");
10397 mtc.stop;
10398 }
Neels Hofmeyrc8b95c12021-08-07 04:24:02 +020010399 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, fn+10));
10400
Neels Hofmeyr07603cf2021-09-07 19:05:52 +020010401 f_verify_imm_ass(imm_ass, ra, fn, chan_nr, chan_ident_ie.chan_ident.ch_desc.v.arfcn,
10402 chan_ident_ie.chan_ident.ch_desc.v.tsc);
Neels Hofmeyrc8b95c12021-08-07 04:24:02 +020010403
10404 /* Check that the lchan is working */
10405 var octetstring l3 := '00010203040506'O;
10406 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
10407
10408 var BSSAP_N_CONNECT_ind rx_c_ind;
10409 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
10410 BSSAP.send(ts_BSSAP_CONNECT_res(rx_c_ind.connectionId));
10411
10412 f_sleep(1.0);
10413 f_shutdown_helper();
10414}
10415
Neels Hofmeyr5d7d13f2021-09-07 14:44:36 +020010416/* GET and SET the bts.N.trx.M.rf_locked CTRL variable */
10417testcase TC_ctrl_trx_rf_locked() runs on test_CT {
10418 var MSC_ConnHdlr vc_conn;
10419
10420 f_init(nr_bts := 2, handler_mode := true, nr_msc := 1);
10421 f_sleep(1.0);
10422
10423 /* BTS 0, 1, 2 are OML unlocked, only BTS 0, 1 are actually connected to RSL. */
10424 f_ctrl_get_exp(IPA_CTRL, "rf_states",
10425 "0,0,operational,unlocked,on,rsl-up;" &
10426 "1,0,operational,unlocked,on,rsl-up;" &
10427 "2,0,operational,unlocked,on,rsl-down;" &
10428 "3,0,inoperational,locked,on,rsl-down;");
10429
10430 f_logp(BSCVTY, "TC_ctrl_trx_rf_locked: lock BTS 1 TRX 0");
10431 f_ctrl_set(IPA_CTRL, "bts.1.trx.0.rf_locked", "1");
10432 /* give it a moment to settle the FSM status */
10433 f_sleep(1.0);
10434
10435 /* Now BTS 1 TRX 0 should reflect "locked". Note the RF policy stays "on", because this is still handled
10436 * globally in osmo-bsc. Probably after sending "rf_locked 1" for a TRX, that TRX should reflect an RF policy
10437 * of "off"? But that's for a future patch if at all. */
10438 f_ctrl_get_exp(IPA_CTRL, "rf_states",
10439 "0,0,operational,unlocked,on,rsl-up;" &
10440 "1,0,operational,locked,on,rsl-up;" &
10441 "2,0,operational,unlocked,on,rsl-down;" &
10442 "3,0,inoperational,locked,on,rsl-down;");
10443
10444 f_logp(BSCVTY, "TC_ctrl_trx_rf_locked: lock the already locked TRX, nothing should change");
10445 f_ctrl_set(IPA_CTRL, "bts.1.trx.0.rf_locked", "1");
10446 f_sleep(1.0);
10447 f_ctrl_get_exp(IPA_CTRL, "rf_states",
10448 "0,0,operational,unlocked,on,rsl-up;" &
10449 "1,0,operational,locked,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: unlock BTS 1 TRX 0");
10454 f_ctrl_set(IPA_CTRL, "bts.1.trx.0.rf_locked", "0");
10455 f_sleep(1.0);
10456 f_ctrl_get_exp(IPA_CTRL, "rf_states",
10457 "0,0,operational,unlocked,on,rsl-up;" &
10458 "1,0,operational,unlocked,on,rsl-up;" &
10459 "2,0,operational,unlocked,on,rsl-down;" &
10460 "3,0,inoperational,locked,on,rsl-down;");
10461
10462 f_logp(BSCVTY, "TC_ctrl_trx_rf_locked: unlock an already unlocked TRX, nothing should change");
10463 f_ctrl_set(IPA_CTRL, "bts.0.trx.0.rf_locked", "0");
10464 f_sleep(1.0);
10465 f_ctrl_get_exp(IPA_CTRL, "rf_states",
10466 "0,0,operational,unlocked,on,rsl-up;" &
10467 "1,0,operational,unlocked,on,rsl-up;" &
10468 "2,0,operational,unlocked,on,rsl-down;" &
10469 "3,0,inoperational,locked,on,rsl-down;");
10470
10471 f_logp(BSCVTY, "TC_ctrl_trx_rf_locked: unlock an inoperational TRX");
10472 f_ctrl_set(IPA_CTRL, "bts.3.trx.0.rf_locked", "0");
10473 f_sleep(1.0);
10474 f_ctrl_get_exp(IPA_CTRL, "rf_states",
10475 "0,0,operational,unlocked,on,rsl-up;" &
10476 "1,0,operational,unlocked,on,rsl-up;" &
10477 "2,0,operational,unlocked,on,rsl-down;" &
10478 "3,0,inoperational,locked,on,rsl-down;");
10479
10480 f_shutdown_helper();
10481}
10482
Neels Hofmeyrb7581872021-11-07 14:02:49 +010010483const CounterNameVals counternames_cm_serv_rej := {
10484 { "cm_serv_rej", 0 },
10485 { "cm_serv_rej:imsi_unknown_in_hlr", 0 },
10486 { "cm_serv_rej:illegal_ms", 0 },
10487 { "cm_serv_rej:imsi_unknown_in_vlr", 0 },
10488 { "cm_serv_rej:imei_not_accepted", 0 },
10489 { "cm_serv_rej:illegal_me", 0 },
10490 { "cm_serv_rej:plmn_not_allowed", 0 },
10491 { "cm_serv_rej:loc_not_allowed", 0 },
10492 { "cm_serv_rej:roaming_not_allowed", 0 },
10493 { "cm_serv_rej:network_failure", 0 },
10494 { "cm_serv_rej:synch_failure", 0 },
10495 { "cm_serv_rej:congestion", 0 },
10496 { "cm_serv_rej:srv_opt_not_supported", 0 },
10497 { "cm_serv_rej:rqd_srv_opt_not_supported", 0 },
10498 { "cm_serv_rej:srv_opt_tmp_out_of_order", 0 },
10499 { "cm_serv_rej:call_can_not_be_identified", 0 },
10500 { "cm_serv_rej:incorrect_message", 0 },
10501 { "cm_serv_rej:invalid_mandantory_inf", 0 },
10502 { "cm_serv_rej:msg_type_not_implemented", 0 },
10503 { "cm_serv_rej:msg_type_not_compatible", 0 },
10504 { "cm_serv_rej:inf_eleme_not_implemented", 0 },
10505 { "cm_serv_rej:condtional_ie_error", 0 },
10506 { "cm_serv_rej:msg_not_compatible", 0 },
10507 { "cm_serv_rej:protocol_error", 0 },
10508 { "cm_serv_rej:retry_in_new_cell", 0 }
10509};
10510
10511private function f_TC_cm_serv_rej(charstring id) runs on MSC_ConnHdlr
10512{
10513 f_create_chan_and_exp();
Vadim Yanitskiya7fc5a62021-12-04 20:10:08 +030010514 /* we should now have a COMPL_L3 at the MSC */
Neels Hofmeyrb7581872021-11-07 14:02:49 +010010515 BSSAP.send(ts_PDU_DTAP_MT(ts_CM_SERV_REJ('02'O), '00'O));
Neels Hofmeyr87a65612021-11-16 15:56:45 +010010516 f_sleep(1.0);
Neels Hofmeyrb7581872021-11-07 14:02:49 +010010517}
10518testcase TC_cm_serv_rej() runs on test_CT {
10519 var TestHdlrParams pars := f_gen_test_hdlr_pars();
10520 var MSC_ConnHdlr vc_conn;
10521
10522 f_init(1, true);
10523 f_sleep(1.0);
10524
10525 f_ctrs_bts_init(1, counternames_cm_serv_rej);
10526
10527 vc_conn := f_start_handler(refers(f_TC_cm_serv_rej), pars);
10528 vc_conn.done;
10529
10530 f_ctrs_bts_add(0, "cm_serv_rej", 1);
10531 f_ctrs_bts_add(0, "cm_serv_rej:imsi_unknown_in_hlr", 1);
10532 f_ctrs_bts_verify();
10533
Neels Hofmeyr87a65612021-11-16 15:56:45 +010010534 f_sleep(1.0);
Neels Hofmeyrb7581872021-11-07 14:02:49 +010010535 f_shutdown_helper();
10536}
10537
Neels Hofmeyr92cfa1c2021-09-28 18:29:44 +020010538/* Reproduce a segfault happening when the SDCCH (primary) lchan is lost in-between a TCH Channel Activ and its Channel
10539 * Activ Ack (SYS#5627). */
10540private function f_TC_lost_sdcch_during_assignment(charstring id) runs on MSC_ConnHdlr {
10541 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Vadim Yanitskiyf0310e32021-10-26 00:30:59 +030010542
10543 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
10544 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Neels Hofmeyr92cfa1c2021-09-28 18:29:44 +020010545
10546 var BSSMAP_FIELD_CodecType codecType;
10547 codecType := valueof(ass_cmd.pdu.bssmap.assignmentRequest.codecList.codecElements[0].codecType);
10548
10549 f_MscConnHdlr_init(g_pars.media_nr, host_bts, host_mgw_mgcp, codecType);
10550
10551 /* First establish a signalling lchan */
10552 f_create_chan_and_exp();
10553 f_rslem_dchan_queue_enable();
10554
10555 /* we should now have a COMPL_L3 at the MSC */
Neels Hofmeyr92cfa1c2021-09-28 18:29:44 +020010556
10557 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
10558 activate(as_Media_mgw());
10559
10560 var RslChannelNr chan_nr := { u := { ch0 := RSL_CHAN_NR_Bm_ACCH }, tn := 1 };
10561 f_rslem_register(0, chan_nr);
10562
10563 f_rslem_set_auto_chan_act_ack(RSL_PROC, false);
10564 BSSAP.send(ass_cmd);
10565
10566
10567 /* Wait for the Channel Activ for the TCH channel */
10568 var ASP_RSL_Unitdata rx_rsl_ud;
10569 RSL.receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV), sid := ?)) -> value rx_rsl_ud;
10570
10571 /* make the original SDCCH disappear */
10572 RSL.send(ts_RSL_REL_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0))));
10573
10574 /* and ACK the TCH channel activation. This caused a segfault up to OsmoBSC 1.7.0 (SYS#5627) */
10575 RSL.send(ts_ASP_RSL_UD(ts_RSL_CHAN_ACT_ACK(chan_nr, 23), rx_rsl_ud.streamId));
10576
10577 interleave {
10578 [] BSSAP.receive(tr_BSSMAP_AssignmentFail);
10579 [] BSSAP.receive(tr_BSSMAP_ClearRequest);
10580 }
10581
10582 BSSAP.send(ts_BSSMAP_ClearCommand(0));
10583 BSSAP.receive(tr_BSSMAP_ClearComplete);
10584 BSSAP.send(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_REQ);
10585
10586 var MgcpCommand mgcp;
10587 MGCP.receive(tr_DLCX()) -> value mgcp {
10588 MGCP.send(ts_DLCX_ACK2(mgcp.line.trans_id));
10589 };
10590
10591 f_sleep(0.5);
10592}
10593testcase TC_lost_sdcch_during_assignment() runs on test_CT {
10594 var TestHdlrParams pars := f_gen_test_hdlr_pars();
10595 var MSC_ConnHdlr vc_conn;
10596
10597 f_init(1, true);
10598 f_sleep(1.0);
10599
Neels Hofmeyr92cfa1c2021-09-28 18:29:44 +020010600 vc_conn := f_start_handler(refers(f_TC_lost_sdcch_during_assignment), pars);
10601 vc_conn.done;
10602
10603 f_shutdown_helper();
10604}
10605
Neels Hofmeyrbd94fe72021-10-26 22:04:53 +020010606const CounterNameVals counternames_bsc_bts_all_available_allocated := {
10607 { "all_allocated:sdcch", 0 },
10608 { "all_allocated:static_sdcch", 0 },
10609 { "all_allocated:tch", 0 },
10610 { "all_allocated:static_tch", 0 }
10611}
10612
10613private function f_all_allocated_expect_counter_change(charstring_list expect_changed) runs on test_CT
10614{
10615 /* Make sure counters settle first */
10616 f_sleep(1.0);
10617
10618 /* Take a baseline of counters */
10619 f_ctrs_bsc_and_bts_init(1, counternames_bsc_bts_all_available_allocated);
10620
10621 /* Elapse some time so that we see changes in counters, hopefully where expected */
10622 f_sleep(2.0);
10623
10624 /* Get new counters */
10625 var charstring_list all_changed := {};
10626 all_changed := all_changed & f_counter_name_vals_get_changed_n(IPA_CTRL, "bsc", g_ctr_bsc);
10627 all_changed := all_changed & f_counter_name_vals_get_changed_n(IPA_CTRL, "bts", g_ctr_bts);
10628
10629 /* Compare with expectations */
10630 var charstring_list all_expect_changed := {};
10631 for (var integer i := 0; i < lengthof(expect_changed); i := i + 1) {
10632 all_expect_changed := all_expect_changed & { "bsc.0." & expect_changed[i], "bts.0." & expect_changed[i] };
10633 }
10634 f_counter_name_vals_expect_changed_list(all_changed, all_expect_changed);
10635}
10636
10637testcase TC_ratectr_all_available_allocated() runs on test_CT {
10638 var ASP_RSL_Unitdata rsl_ud;
10639 var integer i;
10640 var integer chreq_total, chreq_nochan;
10641
10642 f_init(1);
10643 f_sleep(1.0);
10644
10645 /* Exhaust all dedicated SDCCH lchans.
10646 /* GSM 44.018 Table 9.1.8.2:
10647 * RA = '13'O -> Establishment cause = 0001xxxx (MS dual rate capable and asks for "SDCCH").
10648 */
10649 for (i := 0; i < NUM_SDCCH_PER_BTS; i := i+1) {
10650 f_est_dchan('13'O, NUM_SDCCH_PER_BTS + i, '00010203040506'O);
10651 }
10652
10653 /* Since only bts 0 is connected, expecting all_allocated to become true for both bts 0 and the "global" bsc
10654 * level.
10655 * All SDCCH are now occupied. */
10656 f_all_allocated_expect_counter_change({"all_allocated:sdcch", "all_allocated:static_sdcch"});
10657
10658 /* Also fill up all remaining (TCH) channels */
10659 for (i := 0; i < NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS; i := i+1) {
10660 f_est_dchan('33'O, NUM_SDCCH_PER_BTS + i, '00010203040506'O);
10661 }
10662
10663 /* All TCH are now also occupied */
10664 f_all_allocated_expect_counter_change({"all_allocated:sdcch", "all_allocated:static_sdcch",
10665 "all_allocated:tch", "all_allocated:static_tch"});
10666
10667 f_shutdown_helper();
10668}
10669
10670testcase TC_ratectr_all_available_allocated_dyn() runs on test_CT {
10671 var ASP_RSL_Unitdata rsl_ud;
10672 var integer i;
10673 var integer chreq_total, chreq_nochan;
10674
10675 f_init_vty();
10676 f_ts_set_chcomb(0, 0, 2, "TCH/F_TCH/H_PDCH");
10677 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
10678 /* Now we have 3 TCH/F, 1 OSMO_DYN, 1 TCH/H */
10679
10680 f_init(1, guard_timeout := 60.0);
10681 f_sleep(1.0);
10682
10683 /* The dyn TS wants to activate PDCH mode, ACK that. */
10684 var RslChannelNr chan_nr;
10685 chan_nr := valueof(t_RslChanNr_PDCH(2));
10686 f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
10687 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342));
10688
10689 /* Exhaust all dedicated SDCCH lchans.
10690 /* GSM 44.018 Table 9.1.8.2:
10691 * RA = '13'O -> Establishment cause = 0001xxxx (MS dual rate capable and asks for "SDCCH").
10692 */
10693 for (i := 0; i < NUM_SDCCH_PER_BTS; i := i+1) {
10694 f_est_dchan('13'O, NUM_SDCCH_PER_BTS + i, '00010203040506'O);
10695 }
10696
10697 /* The static SDCCH should now be occupied, while still 3x8 dynamic SDCCH potentially remain. So only
10698 * all_allocated:static_sdcch is counted, all_allocated:sdcch remains zero. */
10699 f_all_allocated_expect_counter_change({"all_allocated:static_sdcch"});
10700
10701 /* Request more SDCCH, hence convert the first dyn TS to SDCCH8.
10702 * Will release them later, so remember all the DchanTuples. */
10703 var DchanTuples dyn_sddch := {};
10704 dyn_sddch := dyn_sddch & { f_est_dchan_dyn('33'O, NUM_SDCCH_PER_BTS + i, '00010203040506'O) };
10705
10706 /* Also occupy the seven other SDCCH of the dyn TS */
10707 for (i := 0; i < 7; i := i+1) {
10708 dyn_sddch := dyn_sddch & { f_est_dchan('33'O, NUM_SDCCH_PER_BTS + i, '00010203040506'O) };
10709 }
10710
10711 /* Now all dynamic SDCCH are also occupied, so for the first time all_allocated:sdcch will trigger... */
10712 f_all_allocated_expect_counter_change({"all_allocated:sdcch", "all_allocated:static_sdcch"});
10713
10714 /* occupy the remaining TCH, three TCH/F and two TCH/H lchans */
10715 for (i := 0; i < 5; i := i+1) {
10716 f_est_dchan('33'O, NUM_SDCCH_PER_BTS + i, '00010203040506'O);
10717 }
10718
10719 /* All TCH lchans are now also occupied, both static and dynamic */
10720 f_all_allocated_expect_counter_change({"all_allocated:sdcch", "all_allocated:static_sdcch",
10721 "all_allocated:tch", "all_allocated:static_tch"});
10722
10723 /* Starting to release the dyn TS: as soon as the first SDCCH gets released, all_allocated:sdcch stops
10724 * incrementing. */
10725 var BssmapCause cause := 0;
10726 var DchanTuple dt := dyn_sddch[0];
10727 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
10728 f_exp_chan_rel_and_clear(dt, 0);
10729
10730 /* one dyn TS SDCCH is free again, so only the static_sdcch should increment. For tch, both static and dynamic
10731 * count as occupied, so those still both increment. */
10732 f_all_allocated_expect_counter_change({"all_allocated:static_sdcch",
10733 "all_allocated:tch", "all_allocated:static_tch"});
10734
10735 /* Release the remaining SDCCH of the dyn TS, so it becomes available as TCH again */
10736 for (i := 1; i < lengthof(dyn_sddch); i := i+1) {
10737 dt := dyn_sddch[i];
10738 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
10739 f_exp_chan_rel_and_clear(dt, 0);
10740 }
10741
10742 /* All SDCCH on the dyn TS are released, the dyn TS wants to activate PDCH again */
10743 chan_nr := valueof(t_RslChanNr_PDCH(2));
10744 f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
10745 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342));
10746
10747 /* Now all channels are occupied except the dyn TS, so expecting only the static counters to increment */
10748 f_all_allocated_expect_counter_change({"all_allocated:static_sdcch", "all_allocated:static_tch"});
10749
10750 /* clean up config */
10751 f_ts_reset_chcomb(0);
10752
10753 f_shutdown_helper();
10754}
10755
Harald Welte28d943e2017-11-25 15:00:50 +010010756control {
Harald Welte898113b2018-01-31 18:32:21 +010010757 /* CTRL interface testing */
Harald Welte4003d112017-12-09 22:35:39 +010010758 execute( TC_ctrl_msc_connection_status() );
Stefan Sperlingb041b3d2018-01-03 17:14:55 +010010759 execute( TC_ctrl_msc0_connection_status() );
Neels Hofmeyrf65ce872021-09-23 18:40:10 +020010760 /* In SCCPlite tests, only one MSC is configured. These tests assume that three MSCs are configured, so only run
10761 * these in the AoIP test suite. */
10762 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
10763 execute( TC_stat_num_msc_connected_1() );
10764 execute( TC_stat_num_msc_connected_2() );
10765 execute( TC_stat_num_msc_connected_3() );
10766 }
Neels Hofmeyr5ce3ae42021-08-29 15:32:00 +020010767 execute( TC_stat_num_bts_connected_1() );
10768 execute( TC_stat_num_bts_connected_2() );
10769 execute( TC_stat_num_bts_connected_3() );
Harald Welte96c94412017-12-09 03:12:45 +010010770 execute( TC_ctrl() );
Neels Hofmeyrf246a922020-05-13 02:27:10 +020010771 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_SCCPlite_SERVER) {
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +020010772 execute( TC_ctrl_location() );
10773 }
Harald Welte898113b2018-01-31 18:32:21 +010010774
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +020010775 execute( TC_si_default() );
Neels Hofmeyr66aeba42020-07-06 02:21:21 +020010776 execute( TC_si2quater_2_earfcns() );
10777 execute( TC_si2quater_3_earfcns() );
10778 execute( TC_si2quater_4_earfcns() );
10779 execute( TC_si2quater_5_earfcns() );
10780 execute( TC_si2quater_6_earfcns() );
Neels Hofmeyrad132f22020-07-08 02:20:16 +020010781 execute( TC_si2quater_12_earfcns() );
10782 execute( TC_si2quater_23_earfcns() );
10783 execute( TC_si2quater_32_earfcns() );
10784 execute( TC_si2quater_33_earfcns() );
10785 execute( TC_si2quater_42_earfcns() );
10786 execute( TC_si2quater_48_earfcns() );
10787 execute( TC_si2quater_49_earfcns() );
Pau Espin Pedrol85a84432020-07-20 18:45:03 +020010788 execute( TC_si_acc_rotate() );
Alexander Couzens4ad3a352020-09-10 22:29:12 +020010789 execute( TC_si_acc_ramp_rotate() );
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +020010790
Harald Welte898113b2018-01-31 18:32:21 +010010791 /* RSL DCHAN Channel ACtivation / Deactivation */
Harald Welteae026692017-12-09 01:03:01 +010010792 execute( TC_chan_act_noreply() );
Harald Welte4003d112017-12-09 22:35:39 +010010793 execute( TC_chan_act_counter() );
Harald Welteae026692017-12-09 01:03:01 +010010794 execute( TC_chan_act_ack_noest() );
Philipp Maier9c60a622020-07-09 15:08:46 +020010795 execute( TC_chan_act_ack_noest_emerg() );
Philipp Maier606f07d2020-08-12 17:21:58 +020010796 execute( TC_chan_rqd_emerg_deny() );
Harald Welteae026692017-12-09 01:03:01 +010010797 execute( TC_chan_act_ack_est_ind_noreply() );
10798 execute( TC_chan_act_ack_est_ind_refused() );
Harald Welte618ef642017-12-14 14:58:20 +010010799 execute( TC_chan_act_nack() );
Harald Welte799c97b2017-12-14 17:50:30 +010010800 execute( TC_chan_exhaustion() );
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +070010801 execute( TC_chan_deact_silence() );
Harald Welte4003d112017-12-09 22:35:39 +010010802 execute( TC_chan_rel_rll_rel_ind() );
10803 execute( TC_chan_rel_conn_fail() );
10804 execute( TC_chan_rel_hard_clear() );
Pau Espin Pedrol841b90d2021-04-15 16:42:52 +020010805 execute( TC_chan_rel_last_eutran_plmn_hard_clear_no_csfb() );
10806 execute( TC_chan_rel_last_eutran_plmn_hard_clear_csfb() );
Harald Welte99787102019-02-04 10:41:36 +010010807 execute( TC_chan_rel_hard_clear_csfb() );
Harald Welted8c36cd2017-12-09 23:05:31 +010010808 execute( TC_chan_rel_hard_rlsd() );
Harald Welte550daf92018-06-11 19:22:13 +020010809 execute( TC_chan_rel_hard_rlsd_ms_dead() );
Harald Welte85804d42017-12-10 14:11:58 +010010810 execute( TC_chan_rel_a_reset() );
Pau Espin Pedrolc675b612020-01-09 19:55:40 +010010811 execute( TC_chan_rel_sccp_tiar_timeout() );
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +020010812 execute( TC_chan_rel_rr_cause() );
Harald Welte6f521d82017-12-11 19:52:02 +010010813
Harald Weltecfe2c962017-12-15 12:09:32 +010010814 execute( TC_outbound_connect() );
Harald Welte898113b2018-01-31 18:32:21 +010010815
10816 /* Assignment related */
Harald Welte16a4adf2017-12-14 18:54:01 +010010817 execute( TC_assignment_cic_only() );
Harald Welte235ebf12017-12-15 14:18:16 +010010818 execute( TC_assignment_csd() );
10819 execute( TC_assignment_ctm() );
10820 execute( TC_assignment_sign() );
Pau Espin Pedrol07866632020-09-03 19:10:55 +020010821 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
10822 execute( TC_assignment_aoip_tla_v6() );
10823 }
Harald Welte235ebf12017-12-15 14:18:16 +010010824 execute( TC_assignment_fr_a5_0() );
10825 execute( TC_assignment_fr_a5_1() );
Neels Hofmeyrf246a922020-05-13 02:27:10 +020010826 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welte8f67d1d2018-05-25 20:38:42 +020010827 execute( TC_assignment_fr_a5_1_codec_missing() );
10828 }
Harald Welte235ebf12017-12-15 14:18:16 +010010829 execute( TC_assignment_fr_a5_3() );
Neels Hofmeyr0d8ec532021-06-11 00:09:48 +020010830 execute( TC_assignment_fr_a5_4() );
Neels Hofmeyr0faeb7a2021-06-10 23:59:35 +020010831 execute( TC_assignment_fr_a5_4_fail() );
Neels Hofmeyr04d6e6a2021-06-11 00:10:02 +020010832 execute( TC_assignment_fr_a5_not_sup() );
Harald Welte3c86ea02018-05-10 22:28:05 +020010833 execute( TC_ciph_mode_a5_0() );
10834 execute( TC_ciph_mode_a5_1() );
Oliver Smith50b98122021-07-09 15:00:28 +020010835 execute( TC_ciph_mode_a5_2_0() );
Oliver Smith1dff88d2021-07-09 08:45:51 +020010836 execute( TC_ciph_mode_a5_2_1() );
Harald Welte3c86ea02018-05-10 22:28:05 +020010837 execute( TC_ciph_mode_a5_3() );
Neels Hofmeyr81ad27f2021-06-11 00:09:40 +020010838 execute( TC_ciph_mode_a5_4() );
Harald Welte16a4adf2017-12-14 18:54:01 +010010839
Harald Welte60aa5762018-03-21 19:33:13 +010010840 execute( TC_assignment_codec_fr() );
Neels Hofmeyr559d5d02021-04-16 16:50:49 +020010841 execute( TC_assignment_codec_fr_by_mode_modify() );
Harald Welte60aa5762018-03-21 19:33:13 +010010842 execute( TC_assignment_codec_hr() );
10843 execute( TC_assignment_codec_efr() );
10844 execute( TC_assignment_codec_amr_f() );
10845 execute( TC_assignment_codec_amr_h() );
Philipp Maier8a581d22019-03-26 18:32:48 +010010846
Neels Hofmeyrf246a922020-05-13 02:27:10 +020010847 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Philipp Maier8a581d22019-03-26 18:32:48 +010010848 execute( TC_assignment_codec_amr_f_S1() );
10849 execute( TC_assignment_codec_amr_h_S1() );
10850 execute( TC_assignment_codec_amr_f_S124() );
10851 execute( TC_assignment_codec_amr_h_S124() );
10852 execute( TC_assignment_codec_amr_f_S0() );
10853 execute( TC_assignment_codec_amr_f_S02() );
10854 execute( TC_assignment_codec_amr_f_S024() );
10855 execute( TC_assignment_codec_amr_f_S0247() );
10856 execute( TC_assignment_codec_amr_h_S0() );
10857 execute( TC_assignment_codec_amr_h_S02() );
10858 execute( TC_assignment_codec_amr_h_S024() );
10859 execute( TC_assignment_codec_amr_h_S0247() );
10860 execute( TC_assignment_codec_amr_f_S01234567() );
10861 execute( TC_assignment_codec_amr_f_S0234567() );
10862 execute( TC_assignment_codec_amr_f_zero() );
10863 execute( TC_assignment_codec_amr_f_unsupp() );
10864 execute( TC_assignment_codec_amr_h_S7() );
Neels Hofmeyr21863562020-11-26 00:34:33 +000010865 execute( TC_assignment_codec_amr_f_start_mode_auto() );
10866 execute( TC_assignment_codec_amr_h_start_mode_auto() );
Neels Hofmeyr3eb94562020-11-26 02:40:26 +000010867 execute( TC_assignment_codec_amr_f_start_mode_4() );
10868 execute( TC_assignment_codec_amr_h_start_mode_4() );
Neels Hofmeyr454d7922020-11-26 02:24:57 +000010869 execute( TC_assignment_codec_amr_startmode_cruft() );
Philipp Maier8a581d22019-03-26 18:32:48 +010010870 }
Harald Welte60aa5762018-03-21 19:33:13 +010010871
Philipp Maierac09bfc2019-01-08 13:41:39 +010010872 execute( TC_assignment_codec_fr_exhausted_req_hr() );
10873 execute( TC_assignment_codec_fr_exhausted_req_fr() );
10874 execute( TC_assignment_codec_fr_exhausted_req_fr_hr() );
10875 execute( TC_assignment_codec_fr_exhausted_req_hr_fr() );
10876 execute( TC_assignment_codec_hr_exhausted_req_fr() );
10877 execute( TC_assignment_codec_hr_exhausted_req_hr() );
10878 execute( TC_assignment_codec_hr_exhausted_req_hr_fr() );
10879 execute( TC_assignment_codec_hr_exhausted_req_fr_hr() );
10880 execute( TC_assignment_codec_req_hr_fr() );
10881 execute( TC_assignment_codec_req_fr_hr() );
Pau Espin Pedrol14475352021-07-22 15:48:16 +020010882 execute( TC_assignment_sdcch_exhausted_req_signalling() );
10883 execute( TC_assignment_sdcch_exhausted_req_signalling_tch_forbidden() );
10884 execute( TC_assignment_sdcch_exhausted_req_voice_tch_forbidden() );
Philipp Maierac09bfc2019-01-08 13:41:39 +010010885
Pau Espin Pedrol23510fb2021-07-20 17:00:38 +020010886 execute( TC_assignment_osmux() );
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +020010887
Harald Welte898113b2018-01-31 18:32:21 +010010888 /* RLL Establish Indication on inactive DCHAN / SAPI */
Harald Welte5cd20ed2017-12-13 21:03:20 +010010889 execute( TC_rll_est_ind_inact_lchan() );
10890 execute( TC_rll_est_ind_inval_sapi1() );
10891 execute( TC_rll_est_ind_inval_sapi3() );
10892 execute( TC_rll_est_ind_inval_sacch() );
10893
Vadim Yanitskiy61f784a2020-10-01 21:12:19 +070010894 /* DLCI / RSL Link ID conversion for MO/MT messages on SAPI0/SAPI3 */
10895 execute( TC_tch_dlci_link_id_sapi() );
10896
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +070010897 /* SAPI N Reject triggered by RLL establishment failures */
10898 execute( TC_rll_rel_ind_sapi_n_reject() );
10899 execute( TC_rll_err_ind_sapi_n_reject() );
10900 execute( TC_rll_timeout_sapi_n_reject() );
10901
Harald Welte898113b2018-01-31 18:32:21 +010010902 /* Paging related tests */
Harald Welte6f521d82017-12-11 19:52:02 +010010903 execute( TC_paging_imsi_nochan() );
10904 execute( TC_paging_tmsi_nochan() );
10905 execute( TC_paging_tmsi_any() );
10906 execute( TC_paging_tmsi_sdcch() );
10907 execute( TC_paging_tmsi_tch_f() );
10908 execute( TC_paging_tmsi_tch_hf() );
10909 execute( TC_paging_imsi_nochan_cgi() );
10910 execute( TC_paging_imsi_nochan_lac_ci() );
10911 execute( TC_paging_imsi_nochan_ci() );
10912 execute( TC_paging_imsi_nochan_lai() );
10913 execute( TC_paging_imsi_nochan_lac() );
10914 execute( TC_paging_imsi_nochan_all() );
Harald Welte751d3eb2018-01-31 15:51:06 +010010915 execute( TC_paging_imsi_nochan_plmn_lac_rnc() );
10916 execute( TC_paging_imsi_nochan_rnc() );
10917 execute( TC_paging_imsi_nochan_lac_rnc() );
10918 execute( TC_paging_imsi_nochan_lacs() );
10919 execute( TC_paging_imsi_nochan_lacs_empty() );
Stefan Sperling049a86e2018-03-20 15:51:00 +010010920 execute( TC_paging_imsi_nochan_cgi_unknown_cid() );
Harald Welte10985002017-12-12 09:29:15 +010010921 execute( TC_paging_imsi_a_reset() );
Harald Weltee65d40e2017-12-13 00:09:06 +010010922 execute( TC_paging_imsi_load() );
Philipp Maier779a7922018-02-16 11:00:37 +010010923 execute( TC_paging_counter() );
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +010010924 execute( TC_paging_resp_unsol() );
Harald Welte4e9b9cc2017-12-14 18:31:02 +010010925
10926 execute( TC_rsl_drop_counter() );
Stefan Sperling830dc9d2018-02-12 21:08:28 +010010927 execute( TC_rsl_unknown_unit_id() );
10928
10929 execute( TC_oml_unknown_unit_id() );
Harald Welte898113b2018-01-31 18:32:21 +010010930
10931 execute( TC_classmark() );
Harald Welteeddf0e92020-06-21 19:42:15 +020010932 execute( TC_common_id() );
Harald Welte898113b2018-01-31 18:32:21 +010010933 execute( TC_unsol_ass_fail() );
Harald Welteea99a002018-01-31 20:46:43 +010010934 execute( TC_unsol_ass_compl() );
Harald Weltefbf9b5e2018-01-31 20:41:23 +010010935 execute( TC_unsol_ho_fail() );
Harald Weltee3bd6582018-01-31 22:51:25 +010010936 execute( TC_err_82_short_msg() );
Harald Weltee9e02e42018-01-31 23:36:25 +010010937 execute( TC_err_84_unknown_msg() );
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +010010938
Harald Welte261af4b2018-02-12 21:20:39 +010010939 execute( TC_ho_int() );
Neels Hofmeyraf88d9d2021-06-21 02:14:27 +020010940 execute( TC_ho_int_a5_0() );
10941 execute( TC_ho_int_a5_1() );
10942 execute( TC_ho_int_a5_3() );
10943 execute( TC_ho_int_a5_4() );
Neels Hofmeyr5f144212020-11-03 15:41:58 +000010944 execute( TC_ho_int_radio_link_failure() );
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +010010945
Neels Hofmeyrafe2ea52021-11-24 15:16:12 +010010946 /* TC_ho_out_of_this_bsc is run last, see comment below */
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +020010947 execute( TC_ho_out_fail_no_msc_response() );
10948 execute( TC_ho_out_fail_rr_ho_failure() );
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +020010949 execute( TC_ho_out_fail_no_result_after_ho_cmd() );
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +010010950
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +010010951 execute( TC_ho_into_this_bsc() );
Neels Hofmeyr8ebf19c2021-06-21 05:24:01 +020010952 execute( TC_ho_into_this_bsc_a5_0() );
10953 execute( TC_ho_into_this_bsc_a5_1() );
10954 execute( TC_ho_into_this_bsc_a5_3() );
10955 execute( TC_ho_into_this_bsc_a5_4() );
Pau Espin Pedrol07866632020-09-03 19:10:55 +020010956 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
10957 execute( TC_ho_into_this_bsc_tla_v6() );
10958 }
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +020010959 execute( TC_srvcc_eutran_to_geran() );
Pau Espin Pedrol35801c32021-04-19 13:03:20 +020010960 execute( TC_srvcc_eutran_to_geran_ho_out() );
Pau Espin Pedrol9ae36d52021-06-15 17:29:43 +020010961 execute( TC_srvcc_eutran_to_geran_forbid_fast_return() );
10962 execute( TC_srvcc_eutran_to_geran_ho_out_forbid_fast_return() );
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +010010963 execute( TC_ho_in_fail_msc_clears() );
10964 execute( TC_ho_in_fail_msc_clears_after_ho_detect() );
10965 execute( TC_ho_in_fail_no_detect() );
10966 execute( TC_ho_in_fail_no_detect2() );
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +010010967
Neels Hofmeyr91401012019-07-11 00:42:35 +020010968 execute( TC_ho_neighbor_config_1() );
10969 execute( TC_ho_neighbor_config_2() );
10970 execute( TC_ho_neighbor_config_3() );
10971 execute( TC_ho_neighbor_config_4() );
10972 execute( TC_ho_neighbor_config_5() );
10973 execute( TC_ho_neighbor_config_6() );
10974 execute( TC_ho_neighbor_config_7() );
10975
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +010010976 execute( TC_bssap_rlsd_does_not_cause_bssmap_reset() );
Neels Hofmeyr4ff93282018-03-12 04:25:35 +010010977 execute( TC_bssmap_clear_does_not_cause_bssmap_reset() );
Neels Hofmeyrfd445c32018-03-09 15:39:31 +010010978 execute( TC_ms_rel_ind_does_not_cause_bssmap_reset() );
Harald Welte94e0c342018-04-07 11:33:23 +020010979
10980 execute( TC_dyn_pdch_ipa_act_deact() );
10981 execute( TC_dyn_pdch_ipa_act_nack() );
10982 execute( TC_dyn_pdch_osmo_act_deact() );
10983 execute( TC_dyn_pdch_osmo_act_nack() );
Pau Espin Pedrol37a4c152021-11-16 19:02:23 +010010984 execute( TC_dyn_ts_sdcch8_act_deact() );
10985 execute( TC_dyn_ts_sdcch8_all_subslots_used() );
10986 execute( TC_dyn_ts_sdcch8_tch_call_act_deact() );
10987 execute( TC_dyn_ts_sdcch8_act_nack() );
Harald Welte99f3ca02018-06-14 13:40:29 +020010988
Stefan Sperling0796a822018-10-05 13:01:39 +020010989 execute( TC_chopped_ipa_ping() );
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +020010990 execute( TC_chopped_ipa_payload() );
Stefan Sperling0796a822018-10-05 13:01:39 +020010991
Pau Espin Pedrol8f773632019-11-05 11:46:53 +010010992 /* Power control related */
10993 execute( TC_assignment_verify_ms_power_params_ie() );
Vadim Yanitskiy4b233042021-06-30 00:58:43 +020010994 execute( TC_c0_power_red_mode() );
Neels Hofmeyr4f118412020-06-04 15:25:10 +020010995
10996 /* MSC pooling */
10997 /* FIXME: in SCCPlite, indicating how many MSCs should be connected does currently not work. Since
10998 * RESET->RESET-ACK is unconditionally negotiated for all configured MSCs, they always all appear as connected
10999 * to osmo-bsc. The MSC pooling tests however require disconnecting selected MSCs, and hence don't work out as
11000 * intended on SCCPlite. So for now, run these only for SCCP/M3UA. */
11001 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
11002 execute( TC_mscpool_L3Compl_on_1_msc() );
11003 execute( TC_mscpool_L3Complete_by_imsi_round_robin() );
11004 execute( TC_mscpool_LU_by_tmsi_null_nri_0_round_robin() );
11005 execute( TC_mscpool_LU_by_tmsi_null_nri_1_round_robin() );
11006 execute( TC_mscpool_L3Complete_by_tmsi_unassigned_nri_round_robin() );
11007 execute( TC_mscpool_L3Complete_by_tmsi_valid_nri_msc_not_connected_round_robin() );
11008 execute( TC_mscpool_L3Complete_by_tmsi_valid_nri_1() );
11009 execute( TC_mscpool_L3Complete_by_tmsi_valid_nri_2() );
11010 execute( TC_mscpool_LU_by_tmsi_from_other_PLMN() );
11011 execute( TC_mscpool_paging_and_response_imsi() );
11012 execute( TC_mscpool_paging_and_response_tmsi() );
11013 execute( TC_mscpool_no_allow_attach_round_robin() );
11014 execute( TC_mscpool_no_allow_attach_valid_nri() );
11015 }
11016
Harald Welte99f3ca02018-06-14 13:40:29 +020011017 execute( TC_early_conn_fail() );
11018 execute( TC_late_conn_fail() );
Oliver Smithaf03bef2021-08-24 15:34:51 +020011019 execute( TC_stats_conn_fail() );
Harald Welte99f3ca02018-06-14 13:40:29 +020011020
Philipp Maier783681c2020-07-16 16:47:06 +020011021 /* Emergency call handling (deny / allow) */
11022 execute( TC_assignment_emerg_setup_allow() );
11023 execute( TC_assignment_emerg_setup_deny_msc() );
11024 execute( TC_assignment_emerg_setup_deny_bts() );
Philipp Maier82812002020-08-13 18:48:27 +020011025 execute( TC_emerg_premption() );
11026
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +070011027 /* Frequency hopping parameters handling */
11028 execute( TC_fh_params_chan_activ() );
11029 execute( TC_fh_params_imm_ass() );
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +070011030 execute( TC_fh_params_assignment_cmd() );
Vadim Yanitskiy8f5430d2020-09-02 18:51:38 +070011031 execute( TC_fh_params_handover_cmd() );
Vadim Yanitskiyca974032020-09-01 07:20:39 +070011032 execute( TC_fh_params_si4_cbch() );
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +020011033
11034 if (mp_enable_lcs_tests) {
11035 execute( TC_lcs_loc_req_for_active_ms() );
11036 execute( TC_lcs_loc_req_for_active_ms_ta_req() );
11037 execute( TC_lcs_loc_req_for_idle_ms() );
11038 execute( TC_lcs_loc_req_no_subscriber() );
11039 execute( TC_lcs_loc_req_for_active_ms_le_timeout() );
11040 execute( TC_lcs_loc_req_for_active_ms_le_timeout2() );
11041 execute( TC_lcs_loc_req_for_idle_ms_no_pag_resp() );
11042 execute( TC_cm_service_during_lcs_loc_req() );
11043 execute( TC_ho_during_lcs_loc_req() );
11044 }
Neels Hofmeyrbf037052020-10-28 22:52:02 +000011045
11046 execute( TC_no_msc() );
Neels Hofmeyr87857ec2021-04-25 16:17:47 +000011047
11048 execute( TC_refuse_chan_act_to_vamos() );
11049 execute( TC_refuse_mode_modif_to_vamos() );
Neels Hofmeyrd2d9f332021-04-28 22:23:36 +000011050
11051 execute( TC_reassignment_fr() );
Neels Hofmeyrfeda88e2021-07-19 13:51:29 +020011052
11053 execute( TC_cm_reestablishment() );
Neels Hofmeyrb07b2952021-08-07 04:23:14 +020011054
11055 execute( TC_imm_ass_post_chan_ack() );
11056 execute( TC_imm_ass_pre_chan_ack() );
Neels Hofmeyr23158742021-09-07 19:08:07 +020011057 execute( TC_imm_ass_pre_ts_ack() );
Neels Hofmeyr7a6d0602021-08-07 04:23:50 +020011058 execute( TC_imm_ass_pre_chan_ack_dyn_ts() );
Neels Hofmeyrc8b95c12021-08-07 04:24:02 +020011059 execute( TC_imm_ass_pre_ts_ack_dyn_ts() );
Neels Hofmeyr5d7d13f2021-09-07 14:44:36 +020011060
11061 execute( TC_ctrl_trx_rf_locked() );
Neels Hofmeyr92cfa1c2021-09-28 18:29:44 +020011062
Neels Hofmeyrbd94fe72021-10-26 22:04:53 +020011063 execute( TC_ratectr_all_available_allocated() );
11064 execute( TC_ratectr_all_available_allocated_dyn() );
11065
Neels Hofmeyrb7581872021-11-07 14:02:49 +010011066 execute( TC_cm_serv_rej() );
11067
Neels Hofmeyr92cfa1c2021-09-28 18:29:44 +020011068 execute( TC_lost_sdcch_during_assignment() );
Neels Hofmeyrafe2ea52021-11-24 15:16:12 +010011069
11070 /* Run TC_ho_out_of_this_bsc last, because it may trigger a segfault before osmo-bsc's patch
11071 * with change-id I5a3345ab0005a73597f5c27207480912a2f5aae6 */
11072 execute( TC_ho_out_of_this_bsc() );
Harald Welte28d943e2017-11-25 15:00:50 +010011073}
11074
11075}